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 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 /// \file ExGflashDetectorConstruction.cc
 28 /// \brief Implementation of the ExGflashDetectorConstruction class
 29 //
 30 
 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33 
 34 // User Classes
 35 #include "ExGflashDetectorConstruction.hh"
 36 
 37 #include "ExGflashHomoShowerTuning.hh"
 38 #include "ExGflashMessenger.hh"
 39 #include "ExGflashSensitiveDetector.hh"
 40 
 41 // G4 Classes
 42 #include "G4AutoDelete.hh"
 43 #include "G4Box.hh"
 44 #include "G4Colour.hh"
 45 #include "G4LogicalVolume.hh"
 46 #include "G4Material.hh"
 47 #include "G4NistManager.hh"
 48 #include "G4PVPlacement.hh"
 49 #include "G4RunManager.hh"
 50 #include "G4SDManager.hh"
 51 #include "G4SystemOfUnits.hh"
 52 #include "G4ThreeVector.hh"
 53 #include "G4VPhysicalVolume.hh"
 54 #include "G4VisAttributes.hh"
 55 #include "globals.hh"
 56 
 57 // fast simulation
 58 #include "GFlashHitMaker.hh"
 59 #include "GFlashHomoShowerParameterisation.hh"
 60 #include "GFlashParticleBounds.hh"
 61 #include "GFlashShowerModel.hh"
 62 
 63 #include "G4FastSimulationManager.hh"
 64 
 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 66 
 67 const G4int kMaxBin = 500;
 68 
 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70 
 71 ExGflashDetectorConstruction::ExGflashDetectorConstruction()
 72 {
 73   if (fVerbose > 3) G4cout << "ExGflashDetectorConstruction::Detector constructor" << G4endl;
 74   fGflashMessenger = new ExGflashMessenger(this);
 75 
 76   // Crystall
 77   fCrystalWidth = 3 * cm;
 78   fCrystalLength = 140 * cm;
 79 
 80   DefineMaterials();
 81   SetMaterial("G4_PbWO4");
 82 }
 83 
 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 85 
 86 ExGflashDetectorConstruction::~ExGflashDetectorConstruction()
 87 {
 88   delete fGflashMessenger;
 89   delete fFastShowerModel;
 90   delete fParameterisation;
 91   delete fParticleBounds;
 92   delete fHitMaker;
 93 }
 94 
 95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 96 
 97 void ExGflashDetectorConstruction::DefineMaterials()
 98 {
 99   if (fVerbose > 3) G4cout << "Defining the materials" << G4endl;
100   // Get nist material manager
101   G4NistManager* nistManager = G4NistManager::Instance();
102   // Build materials
103   fHallMat = nistManager->FindOrBuildMaterial("G4_AIR");
104   fDetMat = nistManager->FindOrBuildMaterial("G4_PbWO4");
105   nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
110 G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
111 {
112   //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
113 
114   //------------------------------
115   // Calorimeter segments
116   //------------------------------
117   // Simplified `CMS-like` PbWO4 crystal calorimeter
118 
119   // Calorimeter
120   G4double calo_xside = (fCrystalWidth * fNbOfCrystals);
121   G4double calo_yside = (fCrystalWidth * fNbOfCrystals);
122   G4double calo_zside = fCrystalLength;
123 
124   // The Experimental Hall
125   G4double experimentalHall_x = calo_xside * 4;
126   G4double experimentalHall_y = calo_yside * 4;
127   G4double experimentalHall_z = calo_zside * 4;
128 
129   G4VSolid* experimentalHall_box = new G4Box("expHall_box",  // World Volume
130                                              experimentalHall_x,  // x size
131                                              experimentalHall_y,  // y size
132                                              experimentalHall_z);  // z size
133 
134   auto experimentalHall_log = new G4LogicalVolume(experimentalHall_box, fHallMat, "expHall_log",
135                                                   nullptr,  // opt: fieldManager
136                                                   nullptr,  // opt: SensitiveDetector
137                                                   nullptr);  // opt: UserLimits
138   G4VPhysicalVolume* experimentalHall_phys =
139     new G4PVPlacement(nullptr,
140                       G4ThreeVector(),  // at (0,0,0)
141                       "expHall", experimentalHall_log, nullptr, false, 0);
142 
143   auto calo_box = new G4Box("Calorimeter",  // its name
144                             calo_xside / 2.,  // size
145                             calo_yside / 2., calo_zside / 2.);
146   auto calo_log = new G4LogicalVolume(calo_box,  // its solid
147                                       fHallMat,  // its material
148                                       "calo_log",  // its name
149                                       nullptr,  // opt: fieldManager
150                                       nullptr,  // opt: SensitiveDetector
151                                       nullptr);  // opt: UserLimit
152 
153   G4double xpos = 0.0;
154   G4double ypos = 0.0;
155   G4double zpos = calo_zside / 2.;  // face @ z= 0.0
156 
157   new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), calo_log, "calorimeter",
158                     experimentalHall_log, false, 1);
159 
160   // Crystals
161   G4VSolid* crystal_box = new G4Box("Crystal",  // its name
162                                     fCrystalWidth / 2, fCrystalWidth / 2, fCrystalLength / 2);
163   // size
164   fCrystal_log = new G4LogicalVolume(crystal_box,  // its solid
165                                      fDetMat,  // its material
166                                      "Crystal_log");  // its name
167 
168   for (G4int i = 0; i < fNbOfCrystals; i++) {
169     for (G4int j = 0; j < fNbOfCrystals; j++) {
170       G4int n = i * 10 + j;
171       G4ThreeVector crystalPos((i * fCrystalWidth) - (calo_xside - fCrystalWidth) / 2.,
172                                (j * fCrystalWidth) - (calo_yside - fCrystalWidth) / 2., 0);
173       new G4PVPlacement(nullptr,  // no rotation
174                         crystalPos,  // translation
175                         fCrystal_log,
176                         "crystal",  // its name
177                         calo_log, false, n);
178     }
179   }
180   G4cout << "There are " << fNbOfCrystals << " crystals per row in the calorimeter, so in total "
181          << fNbOfCrystals * fNbOfCrystals << " crystals" << G4endl;
182   G4cout << "They have width of  " << fCrystalWidth / cm << "  cm and a length of  "
183          << fCrystalLength / cm << " cm." << G4endl;
184   G4cout << fDetMat << G4endl;
185   G4cout << "Total Calorimeter size " << calo_xside / cm << " cm x " << calo_yside / cm << " cm x "
186          << calo_zside / cm << " cm" << G4endl;
187 
188   experimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible());
189   auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
190   auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
191   calo_log->SetVisAttributes(caloVisAtt);
192   fCrystal_log->SetVisAttributes(crystalVisAtt);
193 
194   // define the fParameterisation region
195   //  G4cout << "\n ---> DetectorConstruction Region Definition" << G4endl;
196   fRegion = new G4Region("crystals");
197   calo_log->SetRegion(fRegion);
198   fRegion->AddRootLogicalVolume(calo_log);
199 
200   return experimentalHall_phys;
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204 
205 void ExGflashDetectorConstruction::ConstructSDandField()
206 {
207   // -- fast simulation models:
208   // **********************************************
209   // * Initializing shower modell
210   // ***********************************************
211   if (fParameterisation != nullptr) {
212     fParameterisation->SetMaterial(fDetMat);
213     if (fVerbose > 3) G4cout << "Info " << __func__ << " Param Mat " << fDetMat << G4endl;
214     fParameterisation->PrintMaterial(fDetMat);
215   }
216   else {
217     // -- sensitive detectors:
218 
219     G4SDManager* SDman = G4SDManager::GetSDMpointer();
220 
221     auto SD = new ExGflashSensitiveDetector("Calorimeter", this);
222 
223     SDman->AddNewDetector(SD);
224     if (fCrystal_log != nullptr) {
225       fCrystal_log->SetSensitiveDetector(SD);
226     }
227 
228     if (fVerbose > 3) G4cout << "\n--> Creating shower parameterization models" << G4endl;
229     fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
230     fParameterisation =
231       new GFlashHomoShowerParameterisation(fDetMat, new ExGflashHomoShowerTuning());
232     fFastShowerModel->SetParameterisation(*fParameterisation);
233     // Energy Cuts to kill particles:
234     fParticleBounds = new GFlashParticleBounds();
235     fFastShowerModel->SetParticleBounds(*fParticleBounds);
236     // Makes the EnergieSpots
237     fHitMaker = new GFlashHitMaker();
238     fFastShowerModel->SetHitMaker(*fHitMaker);
239     if (fVerbose > 3) G4cout << "end shower parameterization." << G4endl;
240   }
241   // **********************************************
242   // Get Rad Len and R moliere from parameterisation
243   fSDRadLen = fParameterisation->GetX0();
244   fSDRm = fParameterisation->GetRm();
245   if (fVerbose > 2) {
246     G4cout << "Info " << __func__ << "Total Calorimeter size" << G4endl;
247     auto calo_xyside = fCrystalWidth * fNbOfCrystals;
248     G4cout << "Info Z " << __func__ << " " << fCrystalLength / cm << " cm "
249            << fCrystalLength / fSDRadLen << " RadLen " << G4endl;
250     G4cout << "Info XY " << __func__ << " " << calo_xyside / cm << " cm " << calo_xyside / fSDRm
251            << " Rm " << G4endl;
252   }
253 }
254 
255 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
256 
257 void ExGflashDetectorConstruction::SetLBining(G4ThreeVector Value)
258 {
259   fNLtot = (G4int)Value(0);
260   if (fNLtot > kMaxBin) {
261     G4cout << "\n ---> warning from SetLBining: " << fNLtot << " truncated to " << kMaxBin
262            << G4endl;
263     fNLtot = kMaxBin;
264   }
265   fDLradl = Value(1);
266 }
267 
268 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
269 
270 void ExGflashDetectorConstruction::SetRBining(G4ThreeVector Value)
271 {
272   fNRtot = (G4int)Value(0);
273   if (fNRtot > kMaxBin) {
274     G4cout << "\n ---> warning from SetRBining: " << fNRtot << " truncated to " << kMaxBin
275            << G4endl;
276     fNRtot = kMaxBin;
277   }
278   fDRradl = Value(1);
279 }
280 
281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
282 
283 void ExGflashDetectorConstruction::SetMaterial(G4String mat)
284 {
285   // search the material by its name
286   G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(mat);
287 
288   if (pttoMaterial != nullptr && fDetMat != pttoMaterial) {
289     fDetMat = pttoMaterial;
290     if (fCrystal_log != nullptr) {
291       fCrystal_log->SetMaterial(fDetMat);
292     }
293     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
294   }
295 }
296 
297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
298