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 /// \file ExGflashDetectorConstruction.cc 27 /// \file ExGflashDetectorConstruction.cc 28 /// \brief Implementation of the ExGflashDetec 28 /// \brief Implementation of the ExGflashDetectorConstruction class 29 // 29 // 30 30 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 33 34 // User Classes 34 // User Classes 35 #include "ExGflashDetectorConstruction.hh" 35 #include "ExGflashDetectorConstruction.hh" 36 << 37 #include "ExGflashHomoShowerTuning.hh" 36 #include "ExGflashHomoShowerTuning.hh" 38 #include "ExGflashMessenger.hh" 37 #include "ExGflashMessenger.hh" 39 #include "ExGflashSensitiveDetector.hh" 38 #include "ExGflashSensitiveDetector.hh" 40 39 41 // G4 Classes 40 // G4 Classes 42 #include "G4AutoDelete.hh" 41 #include "G4AutoDelete.hh" 43 #include "G4Box.hh" 42 #include "G4Box.hh" 44 #include "G4Colour.hh" 43 #include "G4Colour.hh" 45 #include "G4LogicalVolume.hh" 44 #include "G4LogicalVolume.hh" 46 #include "G4Material.hh" 45 #include "G4Material.hh" 47 #include "G4NistManager.hh" 46 #include "G4NistManager.hh" 48 #include "G4PVPlacement.hh" 47 #include "G4PVPlacement.hh" 49 #include "G4RunManager.hh" 48 #include "G4RunManager.hh" 50 #include "G4SDManager.hh" 49 #include "G4SDManager.hh" 51 #include "G4SystemOfUnits.hh" 50 #include "G4SystemOfUnits.hh" 52 #include "G4ThreeVector.hh" 51 #include "G4ThreeVector.hh" 53 #include "G4VPhysicalVolume.hh" 52 #include "G4VPhysicalVolume.hh" 54 #include "G4VisAttributes.hh" 53 #include "G4VisAttributes.hh" 55 #include "globals.hh" 54 #include "globals.hh" 56 55 57 // fast simulation 56 // fast simulation >> 57 #include "G4FastSimulationManager.hh" 58 #include "GFlashHitMaker.hh" 58 #include "GFlashHitMaker.hh" 59 #include "GFlashHomoShowerParameterisation.hh" 59 #include "GFlashHomoShowerParameterisation.hh" 60 #include "GFlashParticleBounds.hh" 60 #include "GFlashParticleBounds.hh" 61 #include "GFlashShowerModel.hh" 61 #include "GFlashShowerModel.hh" 62 62 63 #include "G4FastSimulationManager.hh" << 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 64 >> 65 G4ThreadLocal GFlashShowerModel* >> 66 ExGflashDetectorConstruction::fFastShowerModel = nullptr; >> 67 G4ThreadLocal GFlashHomoShowerParameterisation* >> 68 ExGflashDetectorConstruction::fParameterisation = nullptr; >> 69 G4ThreadLocal GFlashParticleBounds* >> 70 ExGflashDetectorConstruction::fParticleBounds = nullptr; >> 71 G4ThreadLocal GFlashHitMaker* ExGflashDetectorConstruction::fHitMaker = nullptr; 64 72 65 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 66 74 67 const G4int kMaxBin = 500; 75 const G4int kMaxBin = 500; 68 76 69 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 70 78 71 ExGflashDetectorConstruction::ExGflashDetector 79 ExGflashDetectorConstruction::ExGflashDetectorConstruction() >> 80 : G4VUserDetectorConstruction(), >> 81 fNbOfCrystals(10), >> 82 fCrystal_log(nullptr), >> 83 fDetMat(nullptr), >> 84 fRegion(nullptr), >> 85 fVerbose(0), >> 86 fNLtot(40), >> 87 fNRtot(50), >> 88 fDLradl(0.5), >> 89 fDRradl(0.1) 72 { 90 { 73 if (fVerbose > 3) G4cout << "ExGflashDetecto << 91 G4cout << "ExGflashDetectorConstruction::Detector constructor" << G4endl; 74 fGflashMessenger = new ExGflashMessenger(thi 92 fGflashMessenger = new ExGflashMessenger(this); 75 93 76 // Crystall 94 // Crystall 77 fCrystalWidth = 3 * cm; << 95 fCrystalWidth = 3 * cm; 78 fCrystalLength = 140 * cm; << 96 fCrystalLength = 24 * cm; 79 << 80 DefineMaterials(); << 81 SetMaterial("G4_PbWO4"); << 82 } 97 } 83 98 84 //....oooOO0OOooo........oooOO0OOooo........oo 99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 85 100 86 ExGflashDetectorConstruction::~ExGflashDetecto 101 ExGflashDetectorConstruction::~ExGflashDetectorConstruction() 87 { 102 { 88 delete fGflashMessenger; 103 delete fGflashMessenger; 89 delete fFastShowerModel; 104 delete fFastShowerModel; 90 delete fParameterisation; 105 delete fParameterisation; 91 delete fParticleBounds; 106 delete fParticleBounds; 92 delete fHitMaker; 107 delete fHitMaker; 93 } 108 } 94 109 95 //....oooOO0OOooo........oooOO0OOooo........oo 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 96 111 97 void ExGflashDetectorConstruction::DefineMater << 112 G4VPhysicalVolume* ExGflashDetectorConstruction::Construct() 98 { 113 { 99 if (fVerbose > 3) G4cout << "Defining the ma << 114 //--------- Definitions of Solids, Logical Volumes, Physical Volumes --------- >> 115 G4cout << "Defining the materials" << G4endl; 100 // Get nist material manager 116 // Get nist material manager 101 G4NistManager* nistManager = G4NistManager:: 117 G4NistManager* nistManager = G4NistManager::Instance(); 102 // Build materials 118 // Build materials 103 fHallMat = nistManager->FindOrBuildMaterial( << 119 G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR"); 104 fDetMat = nistManager->FindOrBuildMaterial(" << 120 G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4"); 105 nistManager->FindOrBuildMaterial("G4_CESIUM_ << 106 } << 107 121 108 //....oooOO0OOooo........oooOO0OOooo........oo << 122 fDetMat = pbWO4; 109 << 110 G4VPhysicalVolume* ExGflashDetectorConstructio << 111 { << 112 //--------- Definitions of Solids, Logical V << 113 123 114 //------------------------------ 124 //------------------------------ 115 // Calorimeter segments 125 // Calorimeter segments 116 //------------------------------ 126 //------------------------------ 117 // Simplified `CMS-like` PbWO4 crystal calor 127 // Simplified `CMS-like` PbWO4 crystal calorimeter 118 128 >> 129 // Simplified `CMS-like` PbWO4 crystal calorimeter >> 130 119 // Calorimeter 131 // Calorimeter 120 G4double calo_xside = (fCrystalWidth * fNbOf 132 G4double calo_xside = (fCrystalWidth * fNbOfCrystals); 121 G4double calo_yside = (fCrystalWidth * fNbOf 133 G4double calo_yside = (fCrystalWidth * fNbOfCrystals); 122 G4double calo_zside = fCrystalLength; 134 G4double calo_zside = fCrystalLength; 123 135 124 // The Experimental Hall 136 // The Experimental Hall 125 G4double experimentalHall_x = calo_xside * 4 137 G4double experimentalHall_x = calo_xside * 4; 126 G4double experimentalHall_y = calo_yside * 4 138 G4double experimentalHall_y = calo_yside * 4; 127 G4double experimentalHall_z = calo_zside * 4 139 G4double experimentalHall_z = calo_zside * 4; 128 140 129 G4VSolid* experimentalHall_box = new G4Box(" 141 G4VSolid* experimentalHall_box = new G4Box("expHall_box", // World Volume 130 e << 142 experimentalHall_x, // x size 131 e << 143 experimentalHall_y, // y size 132 e << 144 experimentalHall_z); // z size 133 << 145 134 auto experimentalHall_log = new G4LogicalVol << 146 auto experimentalHall_log = 135 << 147 new G4LogicalVolume(experimentalHall_box, air, "expHall_log", 136 << 148 nullptr, // opt: fieldManager 137 << 149 nullptr, // opt: SensitiveDetector 138 G4VPhysicalVolume* experimentalHall_phys = << 150 nullptr); // opt: UserLimits 139 new G4PVPlacement(nullptr, << 151 G4VPhysicalVolume* experimentalHall_phys = new G4PVPlacement(nullptr, 140 G4ThreeVector(), // at << 152 G4ThreeVector(), // at (0,0,0) 141 "expHall", experimentalH << 153 "expHall", experimentalHall_log, nullptr, false, 0); 142 << 154 143 auto calo_box = new G4Box("Calorimeter", // << 155 G4Box* calo_box = new G4Box("Calorimeter", // its name 144 calo_xside / 2., << 156 calo_xside / 2., // size 145 calo_yside / 2., c << 157 calo_yside / 2., calo_zside / 2.); 146 auto calo_log = new G4LogicalVolume(calo_box << 158 auto calo_log = new G4LogicalVolume(calo_box, // its solid 147 fHallMat << 159 air, // its material 148 "calo_lo << 160 "calo_log", // its name 149 nullptr, << 161 nullptr, // opt: fieldManager 150 nullptr, << 162 nullptr, // opt: SensitiveDetector 151 nullptr) << 163 nullptr); // opt: UserLimit 152 164 153 G4double xpos = 0.0; 165 G4double xpos = 0.0; 154 G4double ypos = 0.0; 166 G4double ypos = 0.0; 155 G4double zpos = calo_zside / 2.; // face @ 167 G4double zpos = calo_zside / 2.; // face @ z= 0.0 156 168 157 new G4PVPlacement(nullptr, G4ThreeVector(xpo << 169 new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), calo_log, 158 experimentalHall_log, fals << 170 "calorimeter", experimentalHall_log, false, 1); 159 171 160 // Crystals 172 // Crystals 161 G4VSolid* crystal_box = new G4Box("Crystal", 173 G4VSolid* crystal_box = new G4Box("Crystal", // its name 162 fCrystalWi << 174 fCrystalWidth / 2, fCrystalWidth / 2, fCrystalLength / 2); 163 // size 175 // size 164 fCrystal_log = new G4LogicalVolume(crystal_b 176 fCrystal_log = new G4LogicalVolume(crystal_box, // its solid 165 fDetMat, << 177 fDetMat, // its material 166 "Crystal_ << 178 "Crystal_log"); // its name 167 179 168 for (G4int i = 0; i < fNbOfCrystals; i++) { << 180 for ( G4int i = 0; i < fNbOfCrystals; i++ ) { 169 for (G4int j = 0; j < fNbOfCrystals; j++) << 181 for ( G4int j = 0; j < fNbOfCrystals; j++ ) { 170 G4int n = i * 10 + j; << 182 G4int n = i * 10 + j; 171 G4ThreeVector crystalPos((i * fCrystalWi << 183 G4ThreeVector crystalPos( 172 (j * fCrystalWi << 184 (i * fCrystalWidth) - (calo_xside - fCrystalWidth) / 2., >> 185 (j * fCrystalWidth) - (calo_yside - fCrystalWidth) / 2., 0); 173 new G4PVPlacement(nullptr, // no rotati 186 new G4PVPlacement(nullptr, // no rotation 174 crystalPos, // transl << 187 crystalPos, // translation 175 fCrystal_log, << 188 fCrystal_log, 176 "crystal", // its nam << 189 "crystal", // its name 177 calo_log, false, n); << 190 calo_log, false, n); 178 } 191 } 179 } 192 } 180 G4cout << "There are " << fNbOfCrystals << " << 193 G4cout << "There are " << fNbOfCrystals >> 194 << " crystals per row in the calorimeter, so in total " 181 << fNbOfCrystals * fNbOfCrystals << " 195 << fNbOfCrystals * fNbOfCrystals << " crystals" << G4endl; 182 G4cout << "They have width of " << fCrystal << 196 G4cout << "Total Calorimeter size" << calo_xside / cm << " cm x " 183 << fCrystalLength / cm << " cm." << G << 197 << calo_yside / cm << " cm x " << calo_zside / cm << " cm" << G4endl; 184 G4cout << fDetMat << G4endl; << 198 G4cout << "They have width of " << fCrystalWidth / cm 185 G4cout << "Total Calorimeter size " << calo_ << 199 << " cm and a length of " << fCrystalLength / cm 186 << calo_zside / cm << " cm" << G4endl << 200 << " cm. The Material is " << fDetMat >> 201 << " Total: " << fCrystalLength / fDetMat->GetRadlen() << " X0" >> 202 << G4endl; 187 203 188 experimentalHall_log->SetVisAttributes(G4Vis 204 experimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); 189 auto caloVisAtt = new G4VisAttributes(G4Colo << 205 auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); 190 auto crystalVisAtt = new G4VisAttributes(G4C 206 auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); 191 calo_log->SetVisAttributes(caloVisAtt); 207 calo_log->SetVisAttributes(caloVisAtt); 192 fCrystal_log->SetVisAttributes(crystalVisAtt 208 fCrystal_log->SetVisAttributes(crystalVisAtt); 193 209 194 // define the fParameterisation region 210 // define the fParameterisation region 195 // G4cout << "\n ---> DetectorConstruction << 211 G4cout << "\n ---> DetectorConstruction Region Definition" << G4endl; 196 fRegion = new G4Region("crystals"); 212 fRegion = new G4Region("crystals"); 197 calo_log->SetRegion(fRegion); 213 calo_log->SetRegion(fRegion); 198 fRegion->AddRootLogicalVolume(calo_log); 214 fRegion->AddRootLogicalVolume(calo_log); 199 215 200 return experimentalHall_phys; 216 return experimentalHall_phys; 201 } 217 } 202 218 203 //....oooOO0OOooo........oooOO0OOooo........oo 219 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 204 220 205 void ExGflashDetectorConstruction::ConstructSD 221 void ExGflashDetectorConstruction::ConstructSDandField() 206 { 222 { 207 // -- fast simulation models: << 223 // -- sensitive detectors: 208 // ***************************************** << 209 // * Initializing shower modell << 210 // ***************************************** << 211 if (fParameterisation != nullptr) { << 212 fParameterisation->SetMaterial(fDetMat); << 213 if (fVerbose > 3) G4cout << "Info " << __f << 214 fParameterisation->PrintMaterial(fDetMat); << 215 } << 216 else { << 217 // -- sensitive detectors: << 218 224 219 G4SDManager* SDman = G4SDManager::GetSDMpo << 225 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 220 226 221 auto SD = new ExGflashSensitiveDetector("C << 227 auto SD = new ExGflashSensitiveDetector("Calorimeter", this); 222 << 223 SDman->AddNewDetector(SD); << 224 if (fCrystal_log != nullptr) { << 225 fCrystal_log->SetSensitiveDetector(SD); << 226 } << 227 228 228 if (fVerbose > 3) G4cout << "\n--> Creatin << 229 SDman->AddNewDetector(SD); 229 fFastShowerModel = new GFlashShowerModel(" << 230 if ( fCrystal_log != nullptr ) { 230 fParameterisation = << 231 fCrystal_log->SetSensitiveDetector(SD); 231 new GFlashHomoShowerParameterisation(fDe << 232 fFastShowerModel->SetParameterisation(*fPa << 233 // Energy Cuts to kill particles: << 234 fParticleBounds = new GFlashParticleBounds << 235 fFastShowerModel->SetParticleBounds(*fPart << 236 // Makes the EnergieSpots << 237 fHitMaker = new GFlashHitMaker(); << 238 fFastShowerModel->SetHitMaker(*fHitMaker); << 239 if (fVerbose > 3) G4cout << "end shower pa << 240 } 232 } >> 233 >> 234 // -- fast simulation models: 241 // ***************************************** 235 // ********************************************** 242 // Get Rad Len and R moliere from parameteri << 236 // * Initializing shower modell 243 fSDRadLen = fParameterisation->GetX0(); << 237 // *********************************************** 244 fSDRm = fParameterisation->GetRm(); << 238 G4cout << "\n--> Creating shower parameterization models" << G4endl; 245 if (fVerbose > 2) { << 239 fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion); 246 G4cout << "Info " << __func__ << "Total Ca << 240 fParameterisation = new GFlashHomoShowerParameterisation( 247 auto calo_xyside = fCrystalWidth * fNbOfCr << 241 fDetMat, new ExGflashHomoShowerTuning()); 248 G4cout << "Info Z " << __func__ << " " << << 242 fFastShowerModel->SetParameterisation(*fParameterisation); 249 << fCrystalLength / fSDRadLen << " << 243 // Energy Cuts to kill particles: 250 G4cout << "Info XY " << __func__ << " " << << 244 fParticleBounds = new GFlashParticleBounds(); 251 << " Rm " << G4endl; << 245 fFastShowerModel->SetParticleBounds(*fParticleBounds); 252 } << 246 // Makes the EnergieSpots >> 247 fHitMaker = new GFlashHitMaker(); >> 248 fFastShowerModel->SetHitMaker(*fHitMaker); >> 249 G4cout << "end shower parameterization." << G4endl; >> 250 // ********************************************** >> 251 // Get Rad Len and R molere ? >> 252 fSDRadLen = fDetMat->GetRadlen(); 253 } 253 } 254 254 255 //....oooOO0OOooo........oooOO0OOooo........oo 255 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 256 256 257 void ExGflashDetectorConstruction::SetLBining( 257 void ExGflashDetectorConstruction::SetLBining(G4ThreeVector Value) 258 { 258 { 259 fNLtot = (G4int)Value(0); 259 fNLtot = (G4int)Value(0); 260 if (fNLtot > kMaxBin) { << 260 if ( fNLtot > kMaxBin ) { 261 G4cout << "\n ---> warning from SetLBining << 261 G4cout << "\n ---> warning from SetLBining: " << fNLtot << " truncated to " 262 << G4endl; << 262 << kMaxBin << G4endl; 263 fNLtot = kMaxBin; 263 fNLtot = kMaxBin; 264 } 264 } 265 fDLradl = Value(1); 265 fDLradl = Value(1); 266 } 266 } 267 267 268 //....oooOO0OOooo........oooOO0OOooo........oo 268 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 269 269 270 void ExGflashDetectorConstruction::SetRBining( 270 void ExGflashDetectorConstruction::SetRBining(G4ThreeVector Value) 271 { 271 { 272 fNRtot = (G4int)Value(0); 272 fNRtot = (G4int)Value(0); 273 if (fNRtot > kMaxBin) { << 273 if ( fNRtot > kMaxBin ) { 274 G4cout << "\n ---> warning from SetRBining << 274 G4cout << "\n ---> warning from SetRBining: " << fNRtot << " truncated to " 275 << G4endl; << 275 << kMaxBin << G4endl; 276 fNRtot = kMaxBin; 276 fNRtot = kMaxBin; 277 } 277 } 278 fDRradl = Value(1); 278 fDRradl = Value(1); 279 } 279 } 280 280 281 //....oooOO0OOooo........oooOO0OOooo........oo 281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 282 282 283 void ExGflashDetectorConstruction::SetMaterial 283 void ExGflashDetectorConstruction::SetMaterial(G4String mat) 284 { 284 { 285 // search the material by its name 285 // search the material by its name 286 G4Material* pttoMaterial = G4NistManager::In << 286 G4Material* pttoMaterial = >> 287 G4NistManager::Instance()->FindOrBuildMaterial(mat); 287 288 288 if (pttoMaterial != nullptr && fDetMat != pt << 289 if ( pttoMaterial != nullptr && fDetMat != pttoMaterial ) { 289 fDetMat = pttoMaterial; 290 fDetMat = pttoMaterial; 290 if (fCrystal_log != nullptr) { << 291 if ( fCrystal_log != nullptr ) { 291 fCrystal_log->SetMaterial(fDetMat); 292 fCrystal_log->SetMaterial(fDetMat); >> 293 } >> 294 if ( fParameterisation != nullptr ) { >> 295 fParameterisation->SetMaterial(fDetMat); >> 296 fParameterisation->PrintMaterial(fDetMat); >> 297 // Get Rad Len and R molere ? >> 298 fSDRadLen = fDetMat->GetRadlen(); 292 } 299 } 293 G4RunManager::GetRunManager()->PhysicsHasB 300 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 294 } 301 } 295 } 302 } 296 303 297 //....oooOO0OOooo........oooOO0OOooo........oo 304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 298 305