// // // RPC-Parameterisation.cc // // // class RPC_Parameterisation - implementation // // // *********************************** // * Implements RPC Parameterisation * // *********************************** // // ---------------------------------------------------------------------- // Author: Miguel Couceiro // Version: 3.0 // Date: May 2009 // ---------------------------------------------------------------------- /* ********************** */ /* **** Header Files **** */ /* ********************** */ #include #include "../include/RPC-Parameterisation.hh" /* ********************************* */ /* **** Constructors/Destructor **** */ /* ********************************* */ // Constructor RPC_Parameterisation::RPC_Parameterisation() { m_nNumber = 0; DeleteArrayParameters(); } // Destructor RPC_Parameterisation::~RPC_Parameterisation() { DeleteArrayParameters(); } /* ************************************ */ /* **** Protected member functions **** */ /* ************************************ */ // CreateArrayParameters function - creates all the array parameters needed for parameterization void RPC_Parameterisation::CreateArrayParameters (void) { // Initialize all vectors m_fXPos.resize(m_nNumber); m_fYPos.resize(m_nNumber); m_fZPos.resize(m_nNumber); m_vOrigin.resize(m_nNumber); m_pRotation.resize(m_nNumber); m_fHalfX.resize(m_nNumber); m_fHalfY.resize(m_nNumber); m_fHalfZ.resize(m_nNumber); m_sMaterial.resize(m_nNumber); m_sName_sld.resize(m_nNumber); m_sName_log.resize(m_nNumber); m_sName_phys.resize(m_nNumber); #ifdef G4VIS_USE m_Color.resize(m_nNumber); m_pVisAtt.resize(m_nNumber); #endif // G4VIS_USE for (G4int i = 0 ; i < m_nNumber ; i++) { m_fXPos[i] = 0; m_fYPos[i] = 0; m_fZPos[i] = 0; m_vOrigin[i] = G4ThreeVector(0.0, 0.0, 0.0); m_pRotation[i] = 0; m_fHalfX[i] = 0; m_fHalfY[i] = 0; m_fHalfZ[i] = 0; m_sMaterial[i] = "GalaticVacuum"; m_sName_sld[i] = ""; m_sName_log[i] = ""; m_sName_phys[i] = ""; #ifdef G4VIS_USE m_Color[i] = G4Color(0.0, 0.0, 0.0); m_pVisAtt[i] = new G4VisAttributes(); m_pVisAtt[i]->SetVisibility(true); m_pVisAtt[i]->SetForceWireframe(true); m_pVisAtt[i]->SetForceSolid(false); m_pVisAtt[i]->SetForceAuxEdgeVisible(false); #endif // G4VIS_USE } } // DeleteArrayParameters function - deletes all the array parameters needed for parameterization void RPC_Parameterisation::DeleteArrayParameters (void) { // Delete all vector components for (G4int i = 0 ; i < m_nNumber ; i++) { if (m_pRotation[i] != 0) delete m_pRotation[i]; m_pRotation[i] = 0; } // Clear all vectors m_fXPos.clear(); m_fYPos.clear(); m_fZPos.clear(); m_vOrigin.clear(); m_pRotation.clear(); m_fHalfX.clear(); m_fHalfY.clear(); m_fHalfZ.clear(); m_sMaterial.clear(); m_sName_sld.clear(); m_sName_log.clear(); m_sName_phys.clear(); // Delete modules visualization attributes #ifdef G4VIS_USE for (G4int i = 0 ; i < m_nNumber ; i++) { if (m_pVisAtt[i] != 0) delete m_pVisAtt[i]; m_pVisAtt[i] = 0; } m_Color.clear(); m_pVisAtt.clear(); #endif // G4VIS_USE } /* ************************************* */ /* **** Overloaded member functions **** */ /* ************************************* */ // ComputeTransformation function - compute the placement location of the 'copyNo' copy number void RPC_Parameterisation::ComputeTransformation (const G4int copyNo, G4VPhysicalVolume* physVol) const { physVol->SetRotation(m_pRotation[copyNo]); physVol->SetTranslation(m_vOrigin[copyNo]); physVol->GetLogicalVolume()->GetSolid()->SetName(m_sName_sld[copyNo]); physVol->GetLogicalVolume()->SetName(m_sName_log[copyNo]); physVol->SetName(m_sName_phys[copyNo]); #ifdef G4VIS_USE physVol->GetLogicalVolume()->SetVisAttributes(m_pVisAtt[copyNo]); #endif // G4VIS_USE } // ComputeDimensions function - compute the dimensions of the Block with 'copyNo' copy number void RPC_Parameterisation::ComputeDimensions (G4Box& volElement, const G4int copyNo, const G4VPhysicalVolume* physVol) const { volElement.SetXHalfLength(m_fHalfX[copyNo]); volElement.SetYHalfLength(m_fHalfY[copyNo]); volElement.SetZHalfLength(m_fHalfZ[copyNo]); } // ComputePosition function void RPC_Parameterisation::ComputePosition (const G4int copyNo, G4ThreeVector &vPosition, G4RotationMatrix &vRotation) const { vPosition = m_vOrigin[copyNo]; vRotation = *(m_pRotation[copyNo]); } // ComputeMaterial function - compute the material of the Layer with 'copyNo' copy number G4Material* RPC_Parameterisation::ComputeMaterial (const G4int copyNo, G4VPhysicalVolume *physVol, const G4VTouchable*) { G4Material* theMaterial = (Materials::GetInstance())->GetMaterial(m_sMaterial[copyNo]); physVol->GetLogicalVolume()->SetMaterial(theMaterial); return (theMaterial); }