// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // /// \file DetectorConstruction.cc /// \brief Implementation of the DetectorConstruction class // // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include "DetectorConstruction.hh" #include "DetectorMessenger.hh" #include "G4Material.hh" #include "G4NistManager.hh" #include "G4Tubs.hh" #include "G4Orb.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4RunManager.hh" #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" #include "G4UnitsTable.hh" #include "G4SubtractionSolid.hh" #include "G4UnionSolid.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() :G4VUserDetectorConstruction(), fTargetMater(0), fLogicTarget(0), fHolderMater(0), fLogicDetector(0), fWorldMater(0), fPhysiWorld(0), fVacMater(0), fInnerDetectorRadius(0), fElectrodeMater(0),fDeviceMater(0), fDetectorMessenger(0) { fTargetLength = 46.3*mm; fTargetRadius = 30.25*mm; fDetectorLength = 44*mm; fDetectorRadius = 29.75*mm; fInnerDetectorRadius = 7.3*mm; fLength = 2.3*mm; fDetectorThink = 11.7*mm; fCMDetector = 30.3*mm; fCMDeadlayerT = 7.15*mm; fWorldRadius = 10*m; DefineMaterials(); fDetectorMessenger = new DetectorMessenger(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() { delete fDetectorMessenger;} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { return ConstructVolumes(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::DefineMaterials() { // build materials // G4Element* N = new G4Element("Nitrogen", "N", 7, 14.01*g/mole); G4Element* O = new G4Element("Oxygen", "O", 8, 16.00*g/mole); // G4int ncomponents; G4double fractionmass; G4Material* Air20 = new G4Material("Air", 1.205*mg/cm3, ncomponents=2, kStateGas, 293.*kelvin, 1.*atmosphere); Air20->AddElement(N, fractionmass=0.7); Air20->AddElement(O, fractionmass=0.3); // fWorldMater = Air20; G4Material* gAl = new G4Material("gAl", 13, 26.98*g/mole, 0.1*g/cm3); fDeviceMater = gAl; // or use G4 materials data base // G4NistManager* man = G4NistManager::Instance(); fTargetMater = man->FindOrBuildMaterial("G4_Ge"); fHolderMater = man->FindOrBuildMaterial("G4_Al"); fVacMater = man->FindOrBuildMaterial("G4_Galactic"); fElectrodeMater = man->FindOrBuildMaterial("G4_Cu"); fIsoMater = man->FindOrBuildMaterial("G4_TEFLON"); ///G4cout << *(G4Material::GetMaterialTable()) << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() { // Cleanup old geometry G4GeometryManager::GetInstance()->OpenGeometry(); G4PhysicalVolumeStore::GetInstance()->Clean(); G4LogicalVolumeStore::GetInstance()->Clean(); G4SolidStore::GetInstance()->Clean(); G4bool checkOverlaps = true; // World // // (re) compute World dimensions if necessary fWorldRadius = 10*m; G4Orb* sWorld = new G4Orb("World", //name fWorldRadius); //dimensions G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld, //shape fWorldMater, //material "World"); //name fPhysiWorld = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) lWorld, //logical volume "World", //name 0, //mother volume false, //no boolean operation 0); //copy number G4Tubs* sAssembly1 = new G4Tubs("Assembly1", 0., 38*mm, 75*mm, 0., twopi); G4Tubs* sAssembly2 = new G4Tubs("Assembly2", 0., 36.5*mm, 73.5*mm, 0., twopi); G4SubtractionSolid* sAssembly = new G4SubtractionSolid("Assembly", sAssembly1, sAssembly2); G4LogicalVolume* lAssembly = new G4LogicalVolume(sAssembly, //shape fHolderMater, //material "Assembly"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,75*mm), //at (0,0,0) lAssembly, //logical volume "Assembly", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //copy number // Target // G4Tubs* sTarget1 = new G4Tubs("Target1", 0., fDetectorRadius, 0.5*fDetectorLength, 0., twopi); G4Tubs* sTarget2 = new G4Tubs("Target2", 0.,fInnerDetectorRadius, 0.5*fTargetLength, 0., twopi); G4ThreeVector zTrans1 (0., 0., fDetectorThink); G4SubtractionSolid* sTarget = new G4SubtractionSolid("Target", sTarget1, sTarget2, 0, zTrans1); fLogicTarget = new G4LogicalVolume(sTarget, //shape fTargetMater, //material "Target"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,fCMDetector), //at (0,0,0) fLogicTarget, //logical volume "Target", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //copy number G4Tubs* sTarget3 = new G4Tubs("Target3", 5.*mm, fInnerDetectorRadius, 16.15*mm, 0., twopi); G4LogicalVolume* lTarget3 = new G4LogicalVolume(sTarget3, //shape fTargetMater, //material "Target3"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,36.15*mm), //at (0,0,0) lTarget3, //logical volume "Target3", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //copy number G4Tubs* sDeadLayerT = new G4Tubs("DeadLayerT", 0., fTargetRadius, 0.5*fLength, 0., twopi); G4LogicalVolume* lDeadLayerT = new G4LogicalVolume(sDeadLayerT, //shape fTargetMater, //material "DeadLayerT"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,fCMDeadlayerT), //at (0,0,0) lDeadLayerT, //logical volume "DeadLayerT", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); G4Tubs* sDeadLayerR = new G4Tubs("DeadLayerR", fDetectorRadius, fTargetRadius, 0.5*fDetectorLength, 0., twopi); G4LogicalVolume* lDeadLayerR = new G4LogicalVolume(sDeadLayerR, //shape fTargetMater, //material "DeadLayerR"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,fCMDetector), //at (0,0,0) lDeadLayerR, //logical volume "DeadLayerR", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); // Holder // G4Tubs* sHolder1 = new G4Tubs("Holder1", 0., 31.01*mm, 32.*mm, 0., twopi); G4Tubs* sHolder2 = new G4Tubs("Holder2", 0., 30.25*mm, 32*mm, 0., twopi); G4ThreeVector zTrans2 (0., 0., -3.2*mm); G4SubtractionSolid* sHolder12 = new G4SubtractionSolid("Holder12", sHolder1, sHolder2, 0, zTrans2); G4Tubs* sHolder3 = new G4Tubs("Holder3", 31.*mm, 33.71*mm, 4.3*mm, 0., twopi); G4ThreeVector zTrans3 (0., 0., -20.7*mm); G4UnionSolid* sHolder13 = new G4UnionSolid("Holder13", sHolder12, sHolder3, 0, zTrans3); G4ThreeVector zTrans4 (0., 0., 1.3*mm); G4UnionSolid* sHolder = new G4UnionSolid("Holder", sHolder13, sHolder3, 0, zTrans4); fLogicDetector = new G4LogicalVolume(sHolder, //shape fHolderMater, //material "Holder"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,38*mm), //at (0,0,0) fLogicDetector, //logical volume "Holder", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //copy number //Electrode G4Tubs* sElectrod = new G4Tubs("Electrod", 0., 2*mm, 23.4*mm, 0., twopi); G4LogicalVolume* lElectrod = new G4LogicalVolume(sElectrod, //shape fElectrodeMater, //material "Electrod"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,43.4*mm), //at (0,0,0) lElectrod, //logical volume "Electrod", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //Support G4Tubs* sSupp1 = new G4Tubs("Supp1", 0., 13.*mm, 10.*mm, 0., twopi); G4Tubs* sSupp2 = new G4Tubs("Supp2", 0., 9.*mm, 10*mm, 0., twopi); G4ThreeVector zTrans5 (0., 0., -4*mm); G4SubtractionSolid* sSupp12 = new G4SubtractionSolid("Supp12", sSupp1, sSupp2, 0, zTrans5); G4Tubs* sSupp3 = new G4Tubs("Supp3", 0., 5.*mm, 29.25*mm, 0., twopi); G4ThreeVector zTrans6 (0., 0., 39.25*mm); G4UnionSolid* sSupp = new G4UnionSolid("Supp", sSupp12, sSupp3, 0, zTrans6); G4LogicalVolume* lSupp = new G4LogicalVolume(sSupp, //shape fHolderMater, //material "Supp3"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,80.*mm), //at (0,0,0) lSupp, //logical volume "Supp", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //Isolytor G4Tubs* sIso = new G4Tubs("Iso", 0., 9.*mm, 8*mm, 0., twopi); G4LogicalVolume* lIso = new G4LogicalVolume(sIso, //shape fIsoMater, //material "Iso"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,78.*mm), //at (0,0,0) lIso, //logical volume "Iso", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //Device G4Tubs* sDevice = new G4Tubs("Device", 5*mm, 36.5*mm, 14.25*mm, 0., twopi); G4LogicalVolume* lDevice = new G4LogicalVolume(sDevice, //shape fDeviceMater, //material "Iso"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,134.25*mm), //at (0,0,0) lDevice, //logical volume "Device", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //Vol G4Tubs* sVol1 = new G4Tubs("Vol1", 0., 36.5*mm, 2.25*mm, 0., twopi); G4Tubs* sVol2 = new G4Tubs("Vol2", 31.01*mm, 36.5*mm, 32*mm, 0., twopi); G4ThreeVector zTrans7 (0., 0., 1.3*mm); G4SubtractionSolid* sVol23 = new G4SubtractionSolid("Vol23", sVol2, sHolder3, 0, zTrans7); G4ThreeVector zTrans8 (0., 0., -20.7*mm); G4SubtractionSolid* sVol26 = new G4SubtractionSolid("Vol26", sVol23, sHolder3, 0, zTrans8); G4Tubs* sVol4 = new G4Tubs("Vol4", 13.*mm, 36.5*mm, 10.*mm, 0., twopi); G4Tubs* sVol5 = new G4Tubs("Vol5", 5.*mm, 36.5*mm, 15.*mm, 0., twopi); G4ThreeVector zTrans9 (0., 0., 34.25*mm); G4UnionSolid* sVol16 = new G4UnionSolid("Vol16", sVol1, sVol26, 0, zTrans9); G4ThreeVector zTrans10 (0., 0., 76.25*mm); G4UnionSolid* sVol14 = new G4UnionSolid("Vol14", sVol16, sVol4, 0, zTrans10); G4ThreeVector zTrans11 (0., 0., 101.25*mm); G4UnionSolid* sVol = new G4UnionSolid("Vol", sVol14, sVol5, 0, zTrans11); G4LogicalVolume* lVol = new G4LogicalVolume(sVol, //shape fVacMater, //material "Vol"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,3.75*mm), //at (0,0,0) lVol, //logical volume "Vol", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); //Cyl G4Tubs* sCyl1 = new G4Tubs("Cyl1", 2.*mm, 5.*mm, 16.15*mm, 0., twopi); G4Tubs* sCyl2 = new G4Tubs("Cyl2", 2*mm, 30.25*mm, 7.25*mm, 0., twopi); G4ThreeVector zTrans12 (0., 0., 23.4*mm); G4UnionSolid* sCyl = new G4UnionSolid("Cyl", sCyl1, sCyl2, 0, zTrans12); G4LogicalVolume* lCyl = new G4LogicalVolume(sCyl, //shape fVacMater, //material "Cyl"); //name new G4PVPlacement(0, //no rotation G4ThreeVector(0.,0.,36.15*mm), //at (0,0,0) lCyl, //logical volume "Cyl", //name lWorld, //mother volume false, //no boolean operation 0, checkOverlaps); PrintParameters(); //always return the root volume // return fPhysiWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::PrintParameters() { G4cout << "\n Target : Length = " << G4BestUnit(fTargetLength,"Length") << " Radius = " << G4BestUnit(fTargetRadius,"Length") << " Material = " << fTargetMater->GetName(); G4cout << "\n Detector : Length = " << G4BestUnit(fDetectorLength,"Length") << " Tickness = " << G4BestUnit(fDetectorRadius,"Length") << " Material = " << fHolderMater->GetName() << G4endl; G4cout << "\n" << fTargetMater << "\n" << fHolderMater << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetMaterial(G4String materialChoice) { // search the material by its name G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (pttoMaterial) { fTargetMater = pttoMaterial; if(fLogicTarget) { fLogicTarget->SetMaterial(fTargetMater); } G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } else { G4cout << "\n--> warning from DetectorConstruction::SetTargetMaterial : " << materialChoice << " not found" << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetHolderMaterial(G4String materialChoice) { // search the material by its name G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (pttoMaterial) { fHolderMater = pttoMaterial; if(fLogicDetector) { fLogicDetector->SetMaterial(fHolderMater); } G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } else { G4cout << "\n--> warning from DetectorConstruction::SetDetectorMaterial : " << materialChoice << " not found" << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetRadius(G4double value) { fTargetRadius = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetLength(G4double value) { fTargetLength = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetDetectorRadius(G4double value) { fDetectorRadius = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetDetectorLength(G4double value) { fDetectorLength = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetInnerDetectorRadius(G4double value) { fInnerDetectorRadius = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetLength(G4double value) { fLength = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetDetectorThink(G4double value) { fDetectorThink = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetCMDetector (G4double value) { fCMDetector = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetCMDeadlayerT (G4double value) { fCMDeadlayerT = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetTargetLength() { return fTargetLength; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetTargetRadius() { return fTargetRadius; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Material* DetectorConstruction::GetTargetMaterial() { return fTargetMater; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* DetectorConstruction::GetLogicTarget() { return fLogicTarget; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetDetectorLength() { return fDetectorLength; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double DetectorConstruction::GetDetectorRadius() { return fDetectorRadius; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Material* DetectorConstruction::GetHolderMaterial() { return fHolderMater; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* DetectorConstruction::GetLogicDetector() { return fLogicDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......