Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 << 26 // >> 27 // $Id$ >> 28 // >> 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 31 27 #include "eRositaDetectorConstruction.hh" 32 #include "eRositaDetectorConstruction.hh" 28 #include "eRositaTrackerSD.hh" 33 #include "eRositaTrackerSD.hh" 29 34 >> 35 #include "G4PhysicalConstants.hh" >> 36 #include "G4SystemOfUnits.hh" >> 37 #include "G4Material.hh" 30 #include "G4Box.hh" 38 #include "G4Box.hh" 31 #include "G4Colour.hh" << 32 #include "G4GeometryManager.hh" << 33 #include "G4GeometryTolerance.hh" << 34 #include "G4ios.hh" << 35 #include "G4LogicalVolume.hh" 39 #include "G4LogicalVolume.hh" 36 #include "G4Material.hh" << 37 #include "G4PhysicalConstants.hh" << 38 #include "G4PVParameterised.hh" << 39 #include "G4PVPlacement.hh" 40 #include "G4PVPlacement.hh" >> 41 #include "G4PVParameterised.hh" 40 #include "G4SDManager.hh" 42 #include "G4SDManager.hh" 41 #include "G4SystemOfUnits.hh" << 43 #include "G4GeometryTolerance.hh" >> 44 #include "G4GeometryManager.hh" >> 45 42 #include "G4UserLimits.hh" 46 #include "G4UserLimits.hh" >> 47 43 #include "G4VisAttributes.hh" 48 #include "G4VisAttributes.hh" >> 49 #include "G4Colour.hh" 44 50 45 //....oooOO0OOooo........oooOO0OOooo........oo << 51 #include "G4ios.hh" 46 52 >> 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 54 47 eRositaDetectorConstruction::eRositaDetectorCo 55 eRositaDetectorConstruction::eRositaDetectorConstruction() >> 56 48 { 57 { >> 58 49 } 59 } 50 60 51 //....oooOO0OOooo........oooOO0OOooo........oo << 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 << 62 53 eRositaDetectorConstruction::~eRositaDetectorC 63 eRositaDetectorConstruction::~eRositaDetectorConstruction() 54 { 64 { >> 65 55 } 66 } 56 67 57 //....oooOO0OOooo........oooOO0OOooo........oo << 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 << 69 59 auto eRositaDetectorConstruction::Construct() << 70 G4VPhysicalVolume* eRositaDetectorConstruction::Construct() 60 { 71 { 61 // ----------------------- << 72 //--------- Material definition --------- 62 // - Material definition - << 63 // ----------------------- << 64 << 65 /* << 66 // Nitrogen << 67 constexpr auto NITROGEN_ATOMIC_NUMBER{7.}; << 68 constexpr auto NITROGEN_MOLAR_MASS{14.01 * << 69 << 70 auto *nitrogen = new G4Element("Nitrogen", << 71 << 72 // Oxygen << 73 constexpr auto OXYGEN_ATOMIC_NUMBER{8.}; << 74 constexpr auto OXYGEN_MOLAR_MASS{16.00 * g << 75 << 76 auto *oxygen = new G4Element("Oxygen", "O" << 77 << 78 // Air << 79 constexpr auto AIR_DENSITY{1.29 * mg / cm3 << 80 constexpr auto AIR_NUMBER_OF_ELEMENTS{2}; << 81 constexpr auto NITROGEN_PERCENTAGE{70}; << 82 constexpr auto OXYGEN_PERCENTAGE{30}; << 83 << 84 auto *air = new G4Material("Air", AIR_DENS << 85 air->AddElement(nitrogen, NITROGEN_PERCENT << 86 air->AddElement(oxygen, OXYGEN_PERCENTAGE << 87 */ << 88 << 89 // Copper << 90 constexpr auto COPPER_ATOMIC_NUMBER{29.}; << 91 constexpr auto COPPER_DENSITY{8.92 * g / c << 92 constexpr auto COPPER_MOLAR_MASS{63.55 * g << 93 73 94 auto *copper = new G4Material("Copper", CO << 74 G4double a, z; 95 << 75 G4double density; 96 // // Aluminium (for testing) << 76 // G4int nel; 97 // constexpr auto COPPER_ATOMIC_NUMBER{13. << 77 98 // constexpr auto COPPER_DENSITY{2.7 * g / << 78 // //Air 99 // constexpr auto COPPER_MOLAR_MASS{26.98 << 79 // G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole); 100 << 80 // G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole); 101 // auto *copper = new G4Material("Aluminiu << 102 << 103 // Silicon << 104 constexpr auto SILICON_ATOMIC_NUMBER{14.}; << 105 constexpr auto SILICON_DENSITY{2.33 * g / << 106 constexpr auto SILICON_MOLAR_MASS{28.09 * << 107 << 108 auto *silicon = new G4Material("Silicon", << 109 << 110 // Vacuum << 111 << 112 constexpr auto VACUUM_ATOMIC_NUMBER{1}; << 113 constexpr auto VACUUM_DENSITY{universe_mea << 114 constexpr auto VACUUM_MOLAR_MASS{1.01 * g << 115 constexpr auto VACUUM_PRESSURE{3.e-18 * pa << 116 constexpr auto VACUUM_TEMPERATURE{2.73 * k << 117 << 118 vacuum = new G4Material("Galactic", VACUUM << 119 << 120 // Print all the materials defined. << 121 G4cout << G4endl << "The materials defined << 122 G4cout << *(G4Material::GetMaterialTable() << 123 << 124 // --------- Sizes of the principal geomet << 125 << 126 // world volume << 127 constexpr auto WORLD_HALF_LENGTH{50.0 * mm << 128 << 129 worldHalfLength = WORLD_HALF_LENGTH; << 130 << 131 // target: 0.5 cm * 0.5 cm * 3 cm << 132 constexpr auto TARGET_HALF_LENGTH{2.5 * mm << 133 constexpr auto TARGET_HALF_DEPTH{15.0 * mm << 134 << 135 targetHalfLength = TARGET_HALF_LENGTH; << 136 targetHalfDepth = TARGET_HALF_DEPTH; << 137 << 138 // tracker (CCD): 4 cm * 450 mu_m * 4 cm << 139 constexpr auto TRACKER_HALF_LENGTH{20.0 * << 140 constexpr auto TRACKER_HALF_DEPTH{0.225 * << 141 << 142 trackerHalfLength = TRACKER_HALF_LENGTH; << 143 trackerHalfDepth = TRACKER_HALF_DEPTH; << 144 << 145 //--------- positions of the principal geo << 146 << 147 // target position: (0 cm, 0 cm, 0 cm) << 148 constexpr auto TARGET_INITIAL_POSITION_X{0 << 149 constexpr auto TARGET_INITIAL_POSITION_Y{0 << 150 constexpr auto TARGET_INITIAL_POSITION_Z{0 << 151 << 152 targetPositionX = TARGET_INITIAL_POSITION_ << 153 targetPositionY = TARGET_INITIAL_POSITION_ << 154 targetPositionZ = TARGET_INITIAL_POSITION_ << 155 << 156 // tracker position: (0 cm, 2 cm, 0 cm) << 157 constexpr auto TRACKER_INITIAL_POSITION_X{ << 158 constexpr auto TRACKER_INITIAL_POSITION_Y{ << 159 constexpr auto TRACKER_INITIAL_POSITION_Z{ << 160 << 161 trackerPositionX = TRACKER_INITIAL_POSITIO << 162 trackerPositionY = TRACKER_INITIAL_POSITIO << 163 trackerPositionZ = TRACKER_INITIAL_POSITIO << 164 81 165 // ------------ << 82 // G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2); 166 // - Material - << 83 // Air->AddElement(N, 70*perCent); 167 // ------------ << 84 // Air->AddElement(O, 30*perCent); 168 << 85 169 // worldMaterial = air; << 86 //Copper 170 worldMaterial = vacuum; << 87 G4Material* Cu = 171 targetMaterial = copper; << 88 new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.92*g/cm3); 172 trackerMaterial = silicon; << 89 173 << 90 // //Aluminium for testing 174 //--------- Definitions of Solids, Logical << 91 // G4Material* Cu = 175 << 92 // new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3); 176 // --------- << 93 177 // - World - << 94 //Silicon 178 // --------- << 95 G4Material* Si = 179 << 96 new G4Material("Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3); 180 worldSolid = new G4Box("world", worldHalfL << 97 181 worldLogicalVolume = new G4LogicalVolume(w << 98 // Vacuum 182 << 99 density = universe_mean_density; //from PhysicalConstants.h 183 // Place the world physical volume unrotat << 100 G4double pressure = 3.e-18*pascal; 184 worldPhysicalVolume = new G4PVPlacement(nu << 101 G4double temperature = 2.73*kelvin; 185 G4ThreeVector(), // at (0, 0, 0) << 102 a = 1.01*g/mole; 186 worldLogicalVolume, // its logical vol << 103 z = 1; 187 "World", // its name << 104 vacuum = new G4Material("Galactic", z, a, 188 nullptr, // its mother volume << 105 density, kStateGas, temperature, pressure); 189 false, // no boolean operations << 106 190 0); // copy number << 107 // Print all the materials defined. 191 << 108 // 192 // ---------- << 109 G4cout << G4endl << "The materials defined are : " << G4endl << G4endl; 193 // - Target - << 110 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 194 // ---------- << 111 195 << 112 //--------- Sizes of the principal geometrical components (solids) --------- 196 auto targetPosition = G4ThreeVector(target << 113 197 << 114 // world volume 198 targetSolid = new G4Box("target", targetHa << 115 hWorldLength = 50.0*mm; 199 targetLogicalVolume = new G4LogicalVolume( << 116 200 targetPhysicalVolume = new G4PVPlacement(n << 117 // target 201 targetPosition, // at (x, y, z) << 118 hTargetLength = 2.5*mm; 202 targetLogicalVolume, // its logical vo << 119 hTargetDepth = 15.0*mm; 203 "Target", // its name << 120 204 worldLogicalVolume, // its mother volu << 121 // CCD 205 false, // no boolean operations << 122 hTrackerLength = 20.0*mm; 206 0); // copy number << 123 hTrackerDepth = 0.225*mm; 207 << 124 208 // ----------- << 125 //--------- positions of the principal geometrical components -------- 209 // - Tracker - << 126 210 // ----------- << 127 // target 211 << 128 xPosTarget = 0.0*cm; 212 auto trackerPosition = G4ThreeVector(track << 129 yPosTarget = 0.0*cm; 213 << 130 zPosTarget = 0.0*cm; 214 trackerSolid = new G4Box("tracker", tracke << 131 215 trackerLogicalVolume = new G4LogicalVolume << 132 // tracker 216 trackerPhysicalVolume = new G4PVPlacement( << 133 xPosTracker = 0.0*cm; 217 trackerPosition, // at (x, y, z) << 134 yPosTracker = 2.0*cm; 218 trackerLogicalVolume, // its logical v << 135 zPosTracker = 0.0*cm; 219 "Tracker", // its name << 136 220 worldLogicalVolume, // its mother volu << 137 //--------- material names of the principal geometrical components -------- 221 false, // no boolean operations << 138 222 0); // copy number << 139 // WorldMater = Air; 223 << 140 WorldMater = vacuum; 224 //----------------------- << 141 TargetMater = Cu; 225 // - Sensitive detector - << 142 TrackerMater = Si; 226 //----------------------- << 143 227 << 144 //--------- Definitions of Solids, Logical Volumes, Physical Volumes --------- 228 constexpr auto TRACKER_SENSITIVE_DETECTOR_ << 145 229 auto *trackerSensitiveDetector = new eRosi << 146 230 trackerLogicalVolume->SetSensitiveDetector << 147 //------------------------------ 231 << 148 // World 232 //------------------ << 149 //------------------------------ 233 // - Visualization - << 150 234 //------------------ << 151 solidWorld= new G4Box("world",hWorldLength,hWorldLength,hWorldLength); 235 << 152 logicWorld= new G4LogicalVolume(solidWorld,WorldMater,"World",0,0,0); 236 // make world volume invisible << 153 237 worldVisualizationStyle = new G4VisAttribu << 154 // Must place the World Physical volume unrotated at (0,0,0). 238 worldVisualizationStyle->SetVisibility(fal << 155 // 239 worldLogicalVolume->SetVisAttributes(world << 156 physiWorld = new G4PVPlacement(0, // no rotation 240 << 157 G4ThreeVector(), // at (0,0,0) 241 // render the target in reddish color << 158 logicWorld, // its logical volume 242 targetVisualizationStyle = new G4VisAttrib << 159 "World", // its name 243 // targetVisualizationStyle->SetColor(G4Co << 160 0, // its mother volume 244 targetVisualizationStyle->SetColor(G4Color << 161 false, // no boolean operations 245 targetLogicalVolume->SetVisAttributes(targ << 162 0); // copy number 246 << 163 247 // render the tracker in blueish color << 164 248 trackerVisualizationStyle = new G4VisAttri << 165 //------------------------------ 249 // trackerVisualizationStyle->SetColor(G4C << 166 // Target 250 trackerVisualizationStyle->SetColor(G4Colo << 167 //------------------------------ 251 trackerLogicalVolume->SetVisAttributes(tra << 168 252 << 169 G4ThreeVector positionTarget = 253 return worldPhysicalVolume; << 170 G4ThreeVector(xPosTarget,yPosTarget,zPosTarget); 254 } << 171 255 << 172 solidTarget = new G4Box("target",hTargetLength,hTargetLength,hTargetDepth); 256 //....oooOO0OOooo........oooOO0OOooo........oo << 173 logicTarget = new G4LogicalVolume(solidTarget,TargetMater,"Target",0,0,0); >> 174 physiTarget = new G4PVPlacement(0, // no rotation >> 175 positionTarget, // at (x,y,z) >> 176 logicTarget, // its logical volume >> 177 "Target", // its name >> 178 logicWorld, // its mother volume >> 179 false, // no boolean operations >> 180 0); // copy number >> 181 >> 182 >> 183 //------------------------------ >> 184 // Tracker >> 185 //------------------------------ >> 186 >> 187 G4ThreeVector positionTracker = >> 188 G4ThreeVector(xPosTracker,yPosTracker,zPosTracker); >> 189 >> 190 solidTracker = >> 191 new G4Box("tracker",hTrackerLength,hTrackerDepth,hTrackerLength); >> 192 logicTracker = >> 193 new G4LogicalVolume(solidTracker,TrackerMater,"Tracker",0,0,0); >> 194 physiTracker = new G4PVPlacement(0, // no rotation >> 195 positionTracker, // at (x,y,z) >> 196 logicTracker, // its logical volume >> 197 "Tracker", // its name >> 198 logicWorld, // its mother volume >> 199 false, // no boolean operations >> 200 0); // copy number >> 201 >> 202 >> 203 >> 204 >> 205 //------------------------------------------------ >> 206 // Sensitive detectors >> 207 //------------------------------------------------ >> 208 >> 209 G4SDManager* SDman = G4SDManager::GetSDMpointer(); >> 210 >> 211 G4String trackerChamberSDname = "eRosita/TrackerChamberSD"; >> 212 eRositaTrackerSD* aTrackerSD = new eRositaTrackerSD( trackerChamberSDname ); >> 213 SDman->AddNewDetector( aTrackerSD ); >> 214 logicTracker->SetSensitiveDetector( aTrackerSD ); >> 215 >> 216 >> 217 //--------- Visualization attributes ------------------------------- >> 218 >> 219 // use this to make world volume invisible >> 220 visWorld = new G4VisAttributes(); >> 221 visWorld->SetVisibility(false); >> 222 logicWorld->SetVisAttributes(visWorld); >> 223 >> 224 // render target in redish color >> 225 visTarget = new G4VisAttributes(); >> 226 // visTarget->SetColor(G4Color(1.0,0.3,0.3)); // redish >> 227 visTarget->SetColor(G4Color(1.0,1.0,1.0)); // black >> 228 logicTarget->SetVisAttributes(visTarget); >> 229 >> 230 // render tracker in blueish color >> 231 visTracker = new G4VisAttributes(); >> 232 // visTracker->SetColor(G4Color(0.3,0.3,1.0)); // blueish >> 233 visTracker->SetColor(G4Color(1.0,1.0,1.0)); // black >> 234 logicTracker->SetVisAttributes(visTracker); 257 235 258 void eRositaDetectorConstruction::ConstructSDa << 259 { << 260 G4SDManager::GetSDMpointer()->SetVerboseLe << 261 auto *sensitiveDetectorManager = G4SDManag << 262 236 263 constexpr auto TRACKER_SENSITIVE_DETECTOR_ << 237 264 auto *trackerSensitiveDetector = new eRosi << 238 return physiWorld; 265 sensitiveDetectorManager->AddNewDetector(t << 266 trackerLogicalVolume->SetSensitiveDetector << 267 } 239 } 268 240 269 //....oooOO0OOooo........oooOO0OOooo........oo << 241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 270 << 271 /* 242 /* 272 void eRositaDetectorConstruction::SetTargetMat << 243 void eRositaDetectorConstruction::setTargetMaterial(G4String materialName) 273 { 244 { 274 // search the material by name << 245 // search the material by its name 275 auto *material = G4Material::GetMaterial(m << 246 G4Material* pttoMaterial = G4Material::GetMaterial(materialName); 276 if (material != nullptr) { << 247 if (pttoMaterial) 277 targetMaterial = material; << 248 {TargetMater = pttoMaterial; 278 targetLogicalVolume->SetMaterial(mater << 249 logicTarget->SetMaterial(pttoMaterial); 279 G4cout << "\n----> The target is " << << 250 G4cout << "\n----> The target is " << fTargetLength/cm << " cm of " 280 } << 251 << materialName << G4endl; >> 252 } 281 } 253 } 282 */ << 254 */ >> 255 283 256