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 #include "eRositaDetectorConstruction.hh" 27 #include "eRositaDetectorConstruction.hh" 28 #include "eRositaTrackerSD.hh" 28 #include "eRositaTrackerSD.hh" 29 29 30 #include "G4Box.hh" 30 #include "G4Box.hh" 31 #include "G4Colour.hh" 31 #include "G4Colour.hh" 32 #include "G4GeometryManager.hh" 32 #include "G4GeometryManager.hh" 33 #include "G4GeometryTolerance.hh" 33 #include "G4GeometryTolerance.hh" 34 #include "G4ios.hh" 34 #include "G4ios.hh" 35 #include "G4LogicalVolume.hh" 35 #include "G4LogicalVolume.hh" 36 #include "G4Material.hh" 36 #include "G4Material.hh" 37 #include "G4PhysicalConstants.hh" 37 #include "G4PhysicalConstants.hh" 38 #include "G4PVParameterised.hh" 38 #include "G4PVParameterised.hh" 39 #include "G4PVPlacement.hh" 39 #include "G4PVPlacement.hh" 40 #include "G4SDManager.hh" 40 #include "G4SDManager.hh" 41 #include "G4SystemOfUnits.hh" 41 #include "G4SystemOfUnits.hh" 42 #include "G4UserLimits.hh" 42 #include "G4UserLimits.hh" 43 #include "G4VisAttributes.hh" 43 #include "G4VisAttributes.hh" 44 44 45 //....oooOO0OOooo........oooOO0OOooo........oo 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 46 47 eRositaDetectorConstruction::eRositaDetectorCo 47 eRositaDetectorConstruction::eRositaDetectorConstruction() 48 { 48 { 49 } 49 } 50 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 52 52 53 eRositaDetectorConstruction::~eRositaDetectorC 53 eRositaDetectorConstruction::~eRositaDetectorConstruction() 54 { 54 { 55 } 55 } 56 56 57 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 58 58 59 auto eRositaDetectorConstruction::Construct() 59 auto eRositaDetectorConstruction::Construct() -> G4VPhysicalVolume* 60 { 60 { 61 // ----------------------- 61 // ----------------------- 62 // - Material definition - 62 // - Material definition - 63 // ----------------------- 63 // ----------------------- 64 64 65 /* 65 /* 66 // Nitrogen 66 // Nitrogen 67 constexpr auto NITROGEN_ATOMIC_NUMBER{7.}; 67 constexpr auto NITROGEN_ATOMIC_NUMBER{7.}; 68 constexpr auto NITROGEN_MOLAR_MASS{14.01 * 68 constexpr auto NITROGEN_MOLAR_MASS{14.01 * g / mole}; 69 69 70 auto *nitrogen = new G4Element("Nitrogen", 70 auto *nitrogen = new G4Element("Nitrogen", "N", NITROGEN_ATOMIC_NUMBER, NITROGEN_MOLAR_MASS); 71 71 72 // Oxygen 72 // Oxygen 73 constexpr auto OXYGEN_ATOMIC_NUMBER{8.}; 73 constexpr auto OXYGEN_ATOMIC_NUMBER{8.}; 74 constexpr auto OXYGEN_MOLAR_MASS{16.00 * g 74 constexpr auto OXYGEN_MOLAR_MASS{16.00 * g / mole}; 75 75 76 auto *oxygen = new G4Element("Oxygen", "O" 76 auto *oxygen = new G4Element("Oxygen", "O", OXYGEN_ATOMIC_NUMBER, OXYGEN_MOLAR_MASS); 77 77 78 // Air 78 // Air 79 constexpr auto AIR_DENSITY{1.29 * mg / cm3 79 constexpr auto AIR_DENSITY{1.29 * mg / cm3}; 80 constexpr auto AIR_NUMBER_OF_ELEMENTS{2}; 80 constexpr auto AIR_NUMBER_OF_ELEMENTS{2}; 81 constexpr auto NITROGEN_PERCENTAGE{70}; 81 constexpr auto NITROGEN_PERCENTAGE{70}; 82 constexpr auto OXYGEN_PERCENTAGE{30}; 82 constexpr auto OXYGEN_PERCENTAGE{30}; 83 83 84 auto *air = new G4Material("Air", AIR_DENS 84 auto *air = new G4Material("Air", AIR_DENSITY, AIR_NUMBER_OF_ELEMENTS); 85 air->AddElement(nitrogen, NITROGEN_PERCENT 85 air->AddElement(nitrogen, NITROGEN_PERCENTAGE * perCent); 86 air->AddElement(oxygen, OXYGEN_PERCENTAGE 86 air->AddElement(oxygen, OXYGEN_PERCENTAGE * perCent); 87 */ 87 */ 88 88 89 // Copper 89 // Copper 90 constexpr auto COPPER_ATOMIC_NUMBER{29.}; 90 constexpr auto COPPER_ATOMIC_NUMBER{29.}; 91 constexpr auto COPPER_DENSITY{8.92 * g / c 91 constexpr auto COPPER_DENSITY{8.92 * g / cm3}; 92 constexpr auto COPPER_MOLAR_MASS{63.55 * g 92 constexpr auto COPPER_MOLAR_MASS{63.55 * g / mole}; 93 93 94 auto *copper = new G4Material("Copper", CO 94 auto *copper = new G4Material("Copper", COPPER_ATOMIC_NUMBER, COPPER_MOLAR_MASS, COPPER_DENSITY); 95 95 96 // // Aluminium (for testing) 96 // // Aluminium (for testing) 97 // constexpr auto COPPER_ATOMIC_NUMBER{13. 97 // constexpr auto COPPER_ATOMIC_NUMBER{13.}; 98 // constexpr auto COPPER_DENSITY{2.7 * g / 98 // constexpr auto COPPER_DENSITY{2.7 * g / cm3}; 99 // constexpr auto COPPER_MOLAR_MASS{26.98 99 // constexpr auto COPPER_MOLAR_MASS{26.98 * g / mole}; 100 100 101 // auto *copper = new G4Material("Aluminiu 101 // auto *copper = new G4Material("Aluminium", COPPER_ATOMIC_NUMBER, COPPER_MOLAR_MASS, COPPER_DENSITY); 102 102 103 // Silicon 103 // Silicon 104 constexpr auto SILICON_ATOMIC_NUMBER{14.}; 104 constexpr auto SILICON_ATOMIC_NUMBER{14.}; 105 constexpr auto SILICON_DENSITY{2.33 * g / 105 constexpr auto SILICON_DENSITY{2.33 * g / cm3}; 106 constexpr auto SILICON_MOLAR_MASS{28.09 * 106 constexpr auto SILICON_MOLAR_MASS{28.09 * g / mole}; 107 107 108 auto *silicon = new G4Material("Silicon", 108 auto *silicon = new G4Material("Silicon", SILICON_ATOMIC_NUMBER, SILICON_MOLAR_MASS, SILICON_DENSITY); 109 109 110 // Vacuum 110 // Vacuum 111 111 112 constexpr auto VACUUM_ATOMIC_NUMBER{1}; 112 constexpr auto VACUUM_ATOMIC_NUMBER{1}; 113 constexpr auto VACUUM_DENSITY{universe_mea 113 constexpr auto VACUUM_DENSITY{universe_mean_density}; // from PhysicalConstants.h 114 constexpr auto VACUUM_MOLAR_MASS{1.01 * g 114 constexpr auto VACUUM_MOLAR_MASS{1.01 * g / mole}; 115 constexpr auto VACUUM_PRESSURE{3.e-18 * pa 115 constexpr auto VACUUM_PRESSURE{3.e-18 * pascal}; 116 constexpr auto VACUUM_TEMPERATURE{2.73 * k 116 constexpr auto VACUUM_TEMPERATURE{2.73 * kelvin}; 117 117 118 vacuum = new G4Material("Galactic", VACUUM 118 vacuum = new G4Material("Galactic", VACUUM_ATOMIC_NUMBER, VACUUM_MOLAR_MASS, VACUUM_DENSITY, kStateGas, VACUUM_TEMPERATURE, VACUUM_PRESSURE); 119 119 120 // Print all the materials defined. 120 // Print all the materials defined. 121 G4cout << G4endl << "The materials defined 121 G4cout << G4endl << "The materials defined are : " << G4endl << G4endl; 122 G4cout << *(G4Material::GetMaterialTable() 122 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 123 123 124 // --------- Sizes of the principal geomet 124 // --------- Sizes of the principal geometrical components (solids) --------- 125 125 126 // world volume 126 // world volume 127 constexpr auto WORLD_HALF_LENGTH{50.0 * mm 127 constexpr auto WORLD_HALF_LENGTH{50.0 * mm}; 128 128 129 worldHalfLength = WORLD_HALF_LENGTH; 129 worldHalfLength = WORLD_HALF_LENGTH; 130 130 131 // target: 0.5 cm * 0.5 cm * 3 cm 131 // target: 0.5 cm * 0.5 cm * 3 cm 132 constexpr auto TARGET_HALF_LENGTH{2.5 * mm 132 constexpr auto TARGET_HALF_LENGTH{2.5 * mm}; 133 constexpr auto TARGET_HALF_DEPTH{15.0 * mm 133 constexpr auto TARGET_HALF_DEPTH{15.0 * mm}; 134 134 135 targetHalfLength = TARGET_HALF_LENGTH; 135 targetHalfLength = TARGET_HALF_LENGTH; 136 targetHalfDepth = TARGET_HALF_DEPTH; 136 targetHalfDepth = TARGET_HALF_DEPTH; 137 137 138 // tracker (CCD): 4 cm * 450 mu_m * 4 cm 138 // tracker (CCD): 4 cm * 450 mu_m * 4 cm 139 constexpr auto TRACKER_HALF_LENGTH{20.0 * 139 constexpr auto TRACKER_HALF_LENGTH{20.0 * mm}; 140 constexpr auto TRACKER_HALF_DEPTH{0.225 * 140 constexpr auto TRACKER_HALF_DEPTH{0.225 * mm}; 141 141 142 trackerHalfLength = TRACKER_HALF_LENGTH; 142 trackerHalfLength = TRACKER_HALF_LENGTH; 143 trackerHalfDepth = TRACKER_HALF_DEPTH; 143 trackerHalfDepth = TRACKER_HALF_DEPTH; 144 144 145 //--------- positions of the principal geo 145 //--------- positions of the principal geometrical components -------- 146 146 147 // target position: (0 cm, 0 cm, 0 cm) 147 // target position: (0 cm, 0 cm, 0 cm) 148 constexpr auto TARGET_INITIAL_POSITION_X{0 148 constexpr auto TARGET_INITIAL_POSITION_X{0.0 * cm}; 149 constexpr auto TARGET_INITIAL_POSITION_Y{0 149 constexpr auto TARGET_INITIAL_POSITION_Y{0.0 * cm}; 150 constexpr auto TARGET_INITIAL_POSITION_Z{0 150 constexpr auto TARGET_INITIAL_POSITION_Z{0.0 * cm}; 151 151 152 targetPositionX = TARGET_INITIAL_POSITION_ 152 targetPositionX = TARGET_INITIAL_POSITION_X; 153 targetPositionY = TARGET_INITIAL_POSITION_ 153 targetPositionY = TARGET_INITIAL_POSITION_Y; 154 targetPositionZ = TARGET_INITIAL_POSITION_ 154 targetPositionZ = TARGET_INITIAL_POSITION_Z; 155 155 156 // tracker position: (0 cm, 2 cm, 0 cm) 156 // tracker position: (0 cm, 2 cm, 0 cm) 157 constexpr auto TRACKER_INITIAL_POSITION_X{ 157 constexpr auto TRACKER_INITIAL_POSITION_X{0.0 * cm}; 158 constexpr auto TRACKER_INITIAL_POSITION_Y{ 158 constexpr auto TRACKER_INITIAL_POSITION_Y{2.0 * cm}; 159 constexpr auto TRACKER_INITIAL_POSITION_Z{ 159 constexpr auto TRACKER_INITIAL_POSITION_Z{0.0 * cm}; 160 160 161 trackerPositionX = TRACKER_INITIAL_POSITIO 161 trackerPositionX = TRACKER_INITIAL_POSITION_X; 162 trackerPositionY = TRACKER_INITIAL_POSITIO 162 trackerPositionY = TRACKER_INITIAL_POSITION_Y; 163 trackerPositionZ = TRACKER_INITIAL_POSITIO 163 trackerPositionZ = TRACKER_INITIAL_POSITION_Z; 164 164 165 // ------------ 165 // ------------ 166 // - Material - 166 // - Material - 167 // ------------ 167 // ------------ 168 168 169 // worldMaterial = air; 169 // worldMaterial = air; 170 worldMaterial = vacuum; 170 worldMaterial = vacuum; 171 targetMaterial = copper; 171 targetMaterial = copper; 172 trackerMaterial = silicon; 172 trackerMaterial = silicon; 173 173 174 //--------- Definitions of Solids, Logical 174 //--------- Definitions of Solids, Logical Volumes, Physical Volumes --------- 175 175 176 // --------- 176 // --------- 177 // - World - 177 // - World - 178 // --------- 178 // --------- 179 179 180 worldSolid = new G4Box("world", worldHalfL 180 worldSolid = new G4Box("world", worldHalfLength, worldHalfLength, worldHalfLength); // cube 181 worldLogicalVolume = new G4LogicalVolume(w 181 worldLogicalVolume = new G4LogicalVolume(worldSolid, worldMaterial, "World", nullptr, nullptr, nullptr); 182 182 183 // Place the world physical volume unrotat 183 // Place the world physical volume unrotated at (0, 0, 0). 184 worldPhysicalVolume = new G4PVPlacement(nu 184 worldPhysicalVolume = new G4PVPlacement(nullptr, // no rotation 185 G4ThreeVector(), // at (0, 0, 0) 185 G4ThreeVector(), // at (0, 0, 0) 186 worldLogicalVolume, // its logical vol 186 worldLogicalVolume, // its logical volume 187 "World", // its name 187 "World", // its name 188 nullptr, // its mother volume 188 nullptr, // its mother volume 189 false, // no boolean operations 189 false, // no boolean operations 190 0); // copy number 190 0); // copy number 191 191 192 // ---------- 192 // ---------- 193 // - Target - 193 // - Target - 194 // ---------- 194 // ---------- 195 195 196 auto targetPosition = G4ThreeVector(target 196 auto targetPosition = G4ThreeVector(targetPositionX, targetPositionY, targetPositionZ); 197 197 198 targetSolid = new G4Box("target", targetHa 198 targetSolid = new G4Box("target", targetHalfLength, targetHalfLength, targetHalfDepth); 199 targetLogicalVolume = new G4LogicalVolume( 199 targetLogicalVolume = new G4LogicalVolume(targetSolid, targetMaterial, "Target", nullptr, nullptr, nullptr); 200 targetPhysicalVolume = new G4PVPlacement(n 200 targetPhysicalVolume = new G4PVPlacement(nullptr, // no rotation 201 targetPosition, // at (x, y, z) 201 targetPosition, // at (x, y, z) 202 targetLogicalVolume, // its logical vo 202 targetLogicalVolume, // its logical volume 203 "Target", // its name 203 "Target", // its name 204 worldLogicalVolume, // its mother volu 204 worldLogicalVolume, // its mother volume 205 false, // no boolean operations 205 false, // no boolean operations 206 0); // copy number 206 0); // copy number 207 207 208 // ----------- 208 // ----------- 209 // - Tracker - 209 // - Tracker - 210 // ----------- 210 // ----------- 211 211 212 auto trackerPosition = G4ThreeVector(track 212 auto trackerPosition = G4ThreeVector(trackerPositionX, trackerPositionY, trackerPositionZ); 213 213 214 trackerSolid = new G4Box("tracker", tracke 214 trackerSolid = new G4Box("tracker", trackerHalfLength, trackerHalfDepth, trackerHalfLength); 215 trackerLogicalVolume = new G4LogicalVolume 215 trackerLogicalVolume = new G4LogicalVolume(trackerSolid, trackerMaterial, "Tracker", nullptr, nullptr, nullptr); 216 trackerPhysicalVolume = new G4PVPlacement( 216 trackerPhysicalVolume = new G4PVPlacement(nullptr, // no rotation 217 trackerPosition, // at (x, y, z) 217 trackerPosition, // at (x, y, z) 218 trackerLogicalVolume, // its logical v 218 trackerLogicalVolume, // its logical volume 219 "Tracker", // its name 219 "Tracker", // its name 220 worldLogicalVolume, // its mother volu 220 worldLogicalVolume, // its mother volume 221 false, // no boolean operations 221 false, // no boolean operations 222 0); // copy number 222 0); // copy number 223 223 224 //----------------------- 224 //----------------------- 225 // - Sensitive detector - 225 // - Sensitive detector - 226 //----------------------- 226 //----------------------- 227 227 228 constexpr auto TRACKER_SENSITIVE_DETECTOR_ 228 constexpr auto TRACKER_SENSITIVE_DETECTOR_NAME{"eRosita/TrackerChamberSD"}; 229 auto *trackerSensitiveDetector = new eRosi 229 auto *trackerSensitiveDetector = new eRositaTrackerSD(TRACKER_SENSITIVE_DETECTOR_NAME); 230 trackerLogicalVolume->SetSensitiveDetector 230 trackerLogicalVolume->SetSensitiveDetector(trackerSensitiveDetector); 231 231 232 //------------------ 232 //------------------ 233 // - Visualization - 233 // - Visualization - 234 //------------------ 234 //------------------ 235 235 236 // make world volume invisible 236 // make world volume invisible 237 worldVisualizationStyle = new G4VisAttribu 237 worldVisualizationStyle = new G4VisAttributes(); 238 worldVisualizationStyle->SetVisibility(fal 238 worldVisualizationStyle->SetVisibility(false); 239 worldLogicalVolume->SetVisAttributes(world 239 worldLogicalVolume->SetVisAttributes(worldVisualizationStyle); 240 240 241 // render the target in reddish color 241 // render the target in reddish color 242 targetVisualizationStyle = new G4VisAttrib 242 targetVisualizationStyle = new G4VisAttributes(); 243 // targetVisualizationStyle->SetColor(G4Co 243 // targetVisualizationStyle->SetColor(G4Color(1.0, 0.3, 0.3)); // reddish 244 targetVisualizationStyle->SetColor(G4Color 244 targetVisualizationStyle->SetColor(G4Color(1.0, 1.0, 1.0)); // black 245 targetLogicalVolume->SetVisAttributes(targ 245 targetLogicalVolume->SetVisAttributes(targetVisualizationStyle); 246 246 247 // render the tracker in blueish color 247 // render the tracker in blueish color 248 trackerVisualizationStyle = new G4VisAttri 248 trackerVisualizationStyle = new G4VisAttributes(); 249 // trackerVisualizationStyle->SetColor(G4C 249 // trackerVisualizationStyle->SetColor(G4Color(0.3, 0.3, 1.0)); // blueish 250 trackerVisualizationStyle->SetColor(G4Colo 250 trackerVisualizationStyle->SetColor(G4Color(1.0, 1.0, 1.0)); // black 251 trackerLogicalVolume->SetVisAttributes(tra 251 trackerLogicalVolume->SetVisAttributes(trackerVisualizationStyle); 252 252 253 return worldPhysicalVolume; 253 return worldPhysicalVolume; 254 } 254 } 255 255 256 //....oooOO0OOooo........oooOO0OOooo........oo 256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 257 257 258 void eRositaDetectorConstruction::ConstructSDa 258 void eRositaDetectorConstruction::ConstructSDandField() 259 { 259 { 260 G4SDManager::GetSDMpointer()->SetVerboseLe 260 G4SDManager::GetSDMpointer()->SetVerboseLevel(1); 261 auto *sensitiveDetectorManager = G4SDManag 261 auto *sensitiveDetectorManager = G4SDManager::GetSDMpointer(); 262 262 263 constexpr auto TRACKER_SENSITIVE_DETECTOR_ 263 constexpr auto TRACKER_SENSITIVE_DETECTOR_NAME{"eRosita/TrackerChamberSD"}; 264 auto *trackerSensitiveDetector = new eRosi 264 auto *trackerSensitiveDetector = new eRositaTrackerSD(TRACKER_SENSITIVE_DETECTOR_NAME); 265 sensitiveDetectorManager->AddNewDetector(t 265 sensitiveDetectorManager->AddNewDetector(trackerSensitiveDetector); 266 trackerLogicalVolume->SetSensitiveDetector 266 trackerLogicalVolume->SetSensitiveDetector(trackerSensitiveDetector); 267 } 267 } 268 268 269 //....oooOO0OOooo........oooOO0OOooo........oo 269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 270 270 271 /* 271 /* 272 void eRositaDetectorConstruction::SetTargetMat 272 void eRositaDetectorConstruction::SetTargetMaterial(G4String materialName) 273 { 273 { 274 // search the material by name 274 // search the material by name 275 auto *material = G4Material::GetMaterial(m 275 auto *material = G4Material::GetMaterial(materialName); 276 if (material != nullptr) { 276 if (material != nullptr) { 277 targetMaterial = material; 277 targetMaterial = material; 278 targetLogicalVolume->SetMaterial(mater 278 targetLogicalVolume->SetMaterial(material); 279 G4cout << "\n----> The target is " << 279 G4cout << "\n----> The target is " << targetFullLength / cm << " cm long and made of " << materialName << G4endl; 280 } 280 } 281 } 281 } 282 */ 282 */ 283 283