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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 ]

Diff markup

Differences between /examples/extended/hadronic/ParticleFluence/ConcentricSpheres/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/hadronic/ParticleFluence/ConcentricSpheres/src/DetectorConstruction.cc (Version 8.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 /// \file DetectorConstruction.cc                 
 27 /// \brief Implementation of the DetectorConst    
 28 //                                                
 29 //                                                
 30                                                   
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32 //....oooOO0OOooo........oooOO0OOooo........oo    
 33                                                   
 34 #include "DetectorConstruction.hh"                
 35                                                   
 36 #include "DetectorMessenger.hh"                   
 37 #include "PrimaryGeneratorAction.hh"              
 38                                                   
 39 #include "G4Box.hh"                               
 40 #include "G4GeometryManager.hh"                   
 41 #include "G4LogicalVolume.hh"                     
 42 #include "G4LogicalVolumeStore.hh"                
 43 #include "G4Material.hh"                          
 44 #include "G4NistManager.hh"                       
 45 #include "G4PVPlacement.hh"                       
 46 #include "G4PhysicalConstants.hh"                 
 47 #include "G4PhysicalVolumeStore.hh"               
 48 #include "G4RunManager.hh"                        
 49 #include "G4SolidStore.hh"                        
 50 #include "G4Sphere.hh"                            
 51 #include "G4SystemOfUnits.hh"                     
 52 #include "G4ThreeVector.hh"                       
 53 #include "globals.hh"                             
 54                                                   
 55 //....oooOO0OOooo........oooOO0OOooo........oo    
 56                                                   
 57 DetectorConstruction::DetectorConstruction()      
 58   : fMaterialTracker(nullptr),                    
 59     fMaterialEmCalo(nullptr),                     
 60     fMaterialHadCalo(nullptr),                    
 61     fExperimentalHall_log(nullptr),               
 62     fExperimentalHall_phys(nullptr),              
 63     fLogicTrackerShell(nullptr),                  
 64     fPhysiTrackerShell(nullptr),                  
 65     fLogicEmCaloShell(nullptr),                   
 66     fPhysiEmCaloShell(nullptr),                   
 67     fLogicHadCaloShell(nullptr),                  
 68     fPhysiHadCaloShell(nullptr),                  
 69     fLogicScoringTrackerShell(nullptr),           
 70     fPhysiScoringTrackerShell(nullptr),           
 71     fLogicScoringEmCaloShell(nullptr),            
 72     fPhysiScoringEmCaloShell(nullptr),            
 73     fLogicScoringHadCaloShell(nullptr),           
 74     fPhysiScoringHadCaloShell(nullptr),           
 75     fDetectorMessenger(nullptr),                  
 76     fInnerRadiusTracker(10.0 * cm),               
 77     fOuterRadiusTracker(20.0 * cm),  //***LOOK    
 78     fInnerRadiusEmCalo(30.0 * cm),                
 79     fOuterRadiusEmCalo(60.0 * cm),                
 80     fInnerRadiusHadCalo(70.0 * cm),               
 81     fOuterRadiusHadCalo(170.0 * cm)               
 82 {                                                 
 83   // G4cout << " BEGIN  DetectorConstruction::    
 84   fMaterialTracker = G4NistManager::Instance()    
 85                                                   
 86   fMaterialEmCalo = G4NistManager::Instance()-    
 87   fMaterialHadCalo = G4NistManager::Instance()    
 88   fDetectorMessenger = new DetectorMessenger(t    
 89   // G4cout << " END  DetectorConstruction::De    
 90 }                                                 
 91                                                   
 92 //....oooOO0OOooo........oooOO0OOooo........oo    
 93                                                   
 94 DetectorConstruction::~DetectorConstruction()     
 95 {                                                 
 96   delete fDetectorMessenger;                      
 97 }                                                 
 98                                                   
 99 //....oooOO0OOooo........oooOO0OOooo........oo    
100                                                   
101 G4VPhysicalVolume* DetectorConstruction::Const    
102 {                                                 
103   // G4cout << " BEGIN  DetectorConstruction::    
104   return ConstructDetector();                     
105 }                                                 
106                                                   
107 //....oooOO0OOooo........oooOO0OOooo........oo    
108                                                   
109 G4VPhysicalVolume* DetectorConstruction::Const    
110 {                                                 
111   // G4cout << " BEGIN  DetectorConstruction::    
112                                                   
113   // Clean old geometry, if any.                  
114   G4GeometryManager::GetInstance()->OpenGeomet    
115                                                   
116   G4PhysicalVolumeStore::GetInstance()->Clean(    
117   G4LogicalVolumeStore::GetInstance()->Clean()    
118   G4SolidStore::GetInstance()->Clean();           
119                                                   
120   // Check that the radii are resonable           
121   G4bool isOK = true;                             
122   if (fInnerRadiusTracker < 0.0 || fOuterRadiu    
123       || fInnerRadiusEmCalo < fOuterRadiusTrac    
124       || fOuterRadiusEmCalo < fInnerRadiusEmCa    
125       || fInnerRadiusHadCalo < fOuterRadiusEmC    
126       || fOuterRadiusHadCalo < fInnerRadiusHad    
127   {                                               
128     isOK = false;                                 
129   }                                               
130   if (!isOK) {                                    
131     G4cerr << G4endl << "ERROR: the radii are     
132            << " InnerRadiusTracker = " << fInn    
133            << " OuterRadiusTracker = " << fOut    
134            << " InnerRadiusEmCalo  = " << fInn    
135            << " OuterRadiusEmCalo  = " << fOut    
136            << " InnerRadiusHadCalo = " << fInn    
137            << " OuterRadiusHadCalo = " << fOut    
138            << " ScoringThickness   = " << fSco    
139     return nullptr;                               
140   }                                               
141                                                   
142   // The detector consists of 3 concentric ful    
143   // positioned at the center, (0.0, 0.0, 0.0)    
144   // The world volume (experimental hall) is a    
145   // spherical shell.                             
146   // and it is filled of "G4_Galactic" materia    
147                                                   
148   G4double expHall_x = 1.1 * fOuterRadiusHadCa    
149   G4double expHall_y = 1.1 * fOuterRadiusHadCa    
150   G4double expHall_z = 1.1 * fOuterRadiusHadCa    
151                                                   
152   G4Material* vacuum = G4NistManager::Instance    
153                                                   
154   G4Box* experimentalHall_box = new G4Box("exp    
155                                                   
156   fExperimentalHall_log = new G4LogicalVolume(    
157                                                   
158                                                   
159                                                   
160                                                   
161                                                   
162                                                   
163   fExperimentalHall_phys = new G4PVPlacement(0    
164                                              G    
165                                              "    
166                                              f    
167                                              0    
168                                              f    
169                                              0    
170                                                   
171   // 1st (innermost) spherical shell: Tracker     
172   G4Sphere* solidTrackerShell = new G4Sphere("    
173                                              f    
174                                              f    
175                                              0    
176                                                   
177                                              2    
178                                                   
179                                              0    
180                                                   
181                                              C    
182                                                   
183   fLogicTrackerShell = new G4LogicalVolume(sol    
184                                            fMa    
185                                            "lo    
186                                            0,     
187                                            0,     
188                                            0);    
189   fPhysiTrackerShell = new G4PVPlacement(0,  /    
190                                          G4Thr    
191                                          "phys    
192                                          fLogi    
193                                          fExpe    
194                                          false    
195                                          0);      
196                                                   
197   // Scoring tracker shell (a thin vacuum laye    
198   G4Sphere* solidScoringTrackerShell =            
199     new G4Sphere("solidScoringTrackerShell",      
200                  fOuterRadiusTracker,  // Inne    
201                  fOuterRadiusTracker + fScorin    
202                  0.0,  // Starting Phi angle o    
203                        // in radians              
204                  2.0 * CLHEP::pi,  // Delta Ph    
205                                    // in radia    
206                  0.0,  // Starting Theta angle    
207                        // in radians              
208                  CLHEP::pi);  // Delta Theta a    
209                               // in radians       
210   fLogicScoringTrackerShell = new G4LogicalVol    
211                                                   
212                                                   
213                                                   
214                                                   
215                                                   
216                                                   
217   fPhysiScoringTrackerShell = new G4PVPlacemen    
218                                                   
219                                                   
220                                                   
221                                                   
222                                                   
223                                                   
224                                                   
225                                                   
226                                                   
227   // 2nd (middle) spherical shell: EM Calo        
228   G4Sphere* solidEmCaloShell = new G4Sphere("s    
229                                             fI    
230                                             fO    
231                                             0.    
232                                                   
233                                             2.    
234                                                   
235                                             0.    
236                                                   
237                                             CL    
238                                                   
239   fLogicEmCaloShell = new G4LogicalVolume(soli    
240                                           fMat    
241                                           "log    
242                                           0,      
243                                           0,      
244                                           0);     
245   fPhysiEmCaloShell = new G4PVPlacement(0,  //    
246                                         G4Thre    
247                                         "physi    
248                                         fLogic    
249                                         fExper    
250                                         false,    
251                                         0);  /    
252                                                   
253   // Scoring EmCalo shell (a thin vacuum layer    
254   G4Sphere* solidScoringEmCaloShell =             
255     new G4Sphere("solidScoringEmCaloShell",  /    
256                  fOuterRadiusEmCalo,  // Inner    
257                  fOuterRadiusEmCalo + fScoring    
258                  0.0,  // Starting Phi angle o    
259                        // in radians              
260                  2.0 * CLHEP::pi,  // Delta Ph    
261                                    // in radia    
262                  0.0,  // Starting Theta angle    
263                        // segment in radians      
264                  CLHEP::pi);  // Delta Theta a    
265                               // in radians       
266   fLogicScoringEmCaloShell = new G4LogicalVolu    
267                                                   
268                                                   
269                                                   
270                                                   
271                                                   
272                                                   
273   fPhysiScoringEmCaloShell = new G4PVPlacement    
274                                                   
275                                                   
276                                                   
277                                                   
278                                                   
279                                                   
280                                                   
281                                                   
282   // 3rd (outmost) spherical shell: HAD Calo      
283   G4Sphere* solidHadCaloShell = new G4Sphere("    
284                                              f    
285                                              f    
286                                              0    
287                                                   
288                                              2    
289                                                   
290                                              0    
291                                                   
292                                              C    
293                                                   
294   fLogicHadCaloShell = new G4LogicalVolume(sol    
295                                            fMa    
296                                            "lo    
297                                            0,     
298                                            0,     
299                                            0);    
300   fPhysiHadCaloShell = new G4PVPlacement(0,  /    
301                                          G4Thr    
302                                          "phys    
303                                          fLogi    
304                                          fExpe    
305                                          false    
306                                          0);      
307                                                   
308   // Scoring HadCalo shell (a thin vacuum laye    
309   G4Sphere* solidScoringHadCaloShell =            
310     new G4Sphere("solidScoringHadCaloShell",      
311                  fOuterRadiusHadCalo,  // Inne    
312                  fOuterRadiusHadCalo + fScorin    
313                  0.0,  // Starting Phi angle o    
314                        // segment in radians      
315                  2.0 * CLHEP::pi,  // Delta Ph    
316                                    // in radia    
317                  0.0,  // Starting Theta angle    
318                        // segment in radians      
319                  CLHEP::pi);  // Delta Theta a    
320                               // in radians       
321   fLogicScoringHadCaloShell = new G4LogicalVol    
322                                                   
323                                                   
324                                                   
325                                                   
326                                                   
327                                                   
328   fPhysiScoringHadCaloShell = new G4PVPlacemen    
329                                                   
330                                                   
331                                                   
332                                                   
333                                                   
334                                                   
335                                                   
336                                                   
337                                                   
338   G4cout << "DetectorConstruction::ConstructSp    
339          << "\t World (box) size: " << G4endl     
340          << "\t y : -/+ " << expHall_y << " mm    
341          << "\t z : -/+ " << expHall_z << " mm    
342   PrintParameters();                              
343   // G4cout << " END  DetectorConstruction::Co    
344                                                   
345   return fExperimentalHall_phys;                  
346 }                                                 
347                                                   
348 //....oooOO0OOooo........oooOO0OOooo........oo    
349                                                   
350 void DetectorConstruction::SetMaterialTracker(    
351 {                                                 
352   fMaterialTracker = G4NistManager::Instance()    
353   if (!fMaterialTracker) {                        
354     G4cout << G4endl << G4endl << "WARNING: th    
355            << G4endl << "     ===> the default    
356     fMaterialTracker = G4NistManager::Instance    
357   }                                               
358   if (fLogicTrackerShell) fLogicTrackerShell->    
359 }                                                 
360                                                   
361 //....oooOO0OOooo........oooOO0OOooo........oo    
362                                                   
363 void DetectorConstruction::SetMaterialEmCalo(c    
364 {                                                 
365   fMaterialEmCalo = G4NistManager::Instance()-    
366   if (!fMaterialEmCalo) {                         
367     G4cout << G4endl << G4endl << "WARNING: th    
368            << G4endl << "     ===> the default    
369     fMaterialEmCalo = G4NistManager::Instance(    
370   }                                               
371   if (fLogicEmCaloShell) fLogicEmCaloShell->Se    
372 }                                                 
373                                                   
374 //....oooOO0OOooo........oooOO0OOooo........oo    
375                                                   
376 void DetectorConstruction::SetMaterialHadCalo(    
377 {                                                 
378   fMaterialHadCalo = G4NistManager::Instance()    
379   if (fMaterialHadCalo == nullptr) {              
380     G4cout << G4endl << G4endl << "WARNING: th    
381            << G4endl << "     ===> the default    
382     fMaterialHadCalo = G4NistManager::Instance    
383   }                                               
384   if (fLogicHadCaloShell) fLogicHadCaloShell->    
385 }                                                 
386                                                   
387 //....oooOO0OOooo........oooOO0OOooo........oo    
388                                                   
389 void DetectorConstruction::UpdateGeometry()       
390 {                                                 
391   // G4cout << " BEGIN  DetectorConstruction::    
392   G4RunManager::GetRunManager()->ReinitializeG    
393   PrintParameters();                              
394   // Update also the position of the gun          
395   const PrimaryGeneratorAction* pPrimaryAction    
396     G4RunManager::GetRunManager()->GetUserPrim    
397   if (pPrimaryAction) pPrimaryAction->SetGunPo    
398   // G4cout << " END  DetectorConstruction::Up    
399 }                                                 
400                                                   
401 //....oooOO0OOooo........oooOO0OOooo........oo    
402                                                   
403 void DetectorConstruction::PrintParameters()      
404 {                                                 
405   G4cout << G4endl << " ------  DetectorConstr    
406          << " MaterialTracker = " << fMaterial    
407          << " MaterialEmCalo  = " << fMaterial    
408          << " MaterialHadCalo = " << fMaterial    
409          << " InnerRadiusTracker = " << fInner    
410          << " OuterRadiusTracker = " << fOuter    
411          << " InnerRadiusEmCalo  = " << fInner    
412          << " OuterRadiusEmCalo  = " << fOuter    
413          << " InnerRadiusHadCalo = " << fInner    
414          << " OuterRadiusHadCalo = " << fOuter    
415          << " ScoringThickness   = " << fScori    
416          << " --------------------------------    
417 }                                                 
418                                                   
419 //....oooOO0OOooo........oooOO0OOooo........oo    
420