Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/gammaray_telescope/src/GammaRayTelDetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 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/advanced/gammaray_telescope/src/GammaRayTelDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/gammaray_telescope/src/GammaRayTelDetectorConstruction.cc (Version 5.2.p1)


  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 //                                                
 27 // -------------------------------------------    
 28 //      GEANT 4 class implementation file         
 29 //      CERN Geneva Switzerland                   
 30 //                                                
 31 //                                                
 32 //      ------------ GammaRayTelDetectorConstr    
 33 //           by F.Longo, R.Giannitrapani & G.S    
 34 //                                                
 35 // *******************************************    
 36                                                   
 37 #include "GammaRayTelAnticoincidenceSD.hh"        
 38 #include "GammaRayTelCalorimeterSD.hh"            
 39 #include "GammaRayTelDetectorConstruction.hh"     
 40 #include "GammaRayTelDetectorMessenger.hh"        
 41 #include "GammaRayTelTrackerSD.hh"                
 42                                                   
 43 #include "G4AutoDelete.hh"                        
 44 #include "G4Box.hh"                               
 45 #include "G4Colour.hh"                            
 46 #include "G4FieldManager.hh"                      
 47 #include "G4GlobalMagFieldMessenger.hh"           
 48 #include "G4LogicalVolume.hh"                     
 49 #include "G4Material.hh"                          
 50 #include "G4PhysicalConstants.hh"                 
 51 #include "G4PVPlacement.hh"                       
 52 #include "G4PVReplica.hh"                         
 53 #include "G4RegionStore.hh"                       
 54 #include "G4RunManager.hh"                        
 55 #include "G4SDManager.hh"                         
 56 #include "G4SystemOfUnits.hh"                     
 57 #include "G4TransportationManager.hh"             
 58 #include "G4UImanager.hh"                         
 59 #include "G4UniformMagField.hh"                   
 60 #include "G4VisAttributes.hh"                     
 61                                                   
 62 //....oooOO0OOooo........oooOO0OOooo........oo    
 63                                                   
 64 G4ThreadLocal G4GlobalMagFieldMessenger *Gamma    
 65                                                   
 66 GammaRayTelDetectorConstruction::GammaRayTelDe    
 67 {                                                 
 68   // Initialize thread-local sensitive detecto    
 69   trackerSD.Put(nullptr);                         
 70   calorimeterSD.Put(nullptr);                     
 71   anticoincidenceSD.Put(nullptr);                 
 72                                                   
 73   ComputePayloadParameters();                     
 74                                                   
 75   // create commands for interactive definitio    
 76   detectorMessenger = new GammaRayTelDetectorM    
 77 }                                                 
 78                                                   
 79 //....oooOO0OOooo........oooOO0OOooo........oo    
 80                                                   
 81 GammaRayTelDetectorConstruction::~GammaRayTelD    
 82   delete detectorMessenger;                       
 83 }                                                 
 84                                                   
 85 //....oooOO0OOooo........oooOO0OOooo........oo    
 86                                                   
 87 auto GammaRayTelDetectorConstruction::Construc    
 88   DefineMaterials();                              
 89   return ConstructPayload();                      
 90 }                                                 
 91                                                   
 92 //....oooOO0OOooo........oooOO0OOooo........oo    
 93                                                   
 94 void GammaRayTelDetectorConstruction::DefineMa    
 95   G4String name;                                  
 96   G4String symbol;                                
 97                                                   
 98   G4int numberOfAtoms;                            
 99   G4int numberOfComponents;                       
100                                                   
101   //                                              
102   // define Elements                              
103   //                                              
104                                                   
105   constexpr auto HYDROGEN_ATOMIC_NUMBER{1.};      
106   constexpr auto HYDROGEN_MOLAR_MASS{1.01 * g     
107   auto *hydrogen = new G4Element(name = "Hydro    
108                                                   
109   constexpr auto CARBON_ATOMIC_NUMBER{6.};        
110     constexpr auto CARBON_MOLAR_MASS{12.01 * g    
111   auto *carbon = new G4Element(name = "Carbon"    
112                                                   
113   constexpr auto NITROGEN_ATOMIC_NUMBER{7.};      
114     constexpr auto NITROGEN_MOLAR_MASS{14.006     
115   auto *nitrogen = new G4Element(name = "Nitro    
116                                                   
117   constexpr auto OXYGEN_ATOMIC_NUMBER{8.};        
118   constexpr auto OXYGEN_MOLAR_MASS{15.99 * g /    
119   auto *oxygen = new G4Element(name = "Oxygen"    
120                                                   
121   constexpr auto ALUMINIUM_ATOMIC_NUMBER{13.};    
122     constexpr auto ALUMINIUM_MOLAR_MASS{26.98     
123   auto *aluminium = new G4Element(name = "Alum    
124                                                   
125     constexpr auto SILICON_ATOMIC_NUMBER{14.};    
126     constexpr auto SILICON_MOLAR_MASS{28.09 *     
127   auto *silicon = new G4Element(name = "Silico    
128                                                   
129     constexpr auto IRON_ATOMIC_NUMBER{26.};       
130     constexpr auto IRON_MOLAR_MASS{55.845 * g     
131   auto *iron = new G4Element(name = "Iron", sy    
132                                                   
133     constexpr auto IODINE_ATOMIC_NUMBER{53.};     
134     constexpr auto IODINE_MOLAR_MASS{126.904 *    
135   auto *iodine = new G4Element(name = "Iodine"    
136                                                   
137     constexpr auto CESIUM_ATOMIC_NUMBER{55};      
138     constexpr auto CESIUM_MOLAR_MASS{132.905 *    
139   auto *cesium = new G4Element(name = "Cesium"    
140                                                   
141     constexpr auto LEAD_ATOMIC_NUMBER{82};        
142     constexpr auto LEAD_MOLAR_MASS{207.19 * g     
143   auto *lead = new G4Element(name = "Lead", sy    
144                                                   
145   //                                              
146   // define simple materials                      
147   //                                              
148                                                   
149     constexpr auto TUNGSTEN_ATOMIC_NUMBER{74.}    
150     constexpr auto TUNGSTEN_DENSITY{19.3 * g /    
151     constexpr auto TUNGSTEN_MOLAR_MASS{183.84     
152   auto *tungsten = new G4Material(name = "Tung    
153                                                   
154   //                                              
155   // Define a material from elements.             
156   // Case 1: chemical molecule                    
157   //                                              
158                                                   
159   constexpr auto SCINTILLATOR_MATERIAL_DENSITY    
160   auto *scintillatorMaterial = new G4Material(    
161   scintillatorMaterial->AddElement(carbon, num    
162   scintillatorMaterial->AddElement(hydrogen, n    
163                                                   
164   constexpr auto CESIUM_IODIDE_DENSITY{4.53 *     
165   auto *cesiumIodide = new G4Material(name = "    
166   cesiumIodide->AddElement(cesium, numberOfAto    
167   cesiumIodide->AddElement(iodine, numberOfAto    
168                                                   
169   //                                              
170   // Define a material from elements.             
171   // Case 2: mixture by fractional mass           
172   //                                              
173                                                   
174   constexpr auto AIR_DENSITY{1.290 * mg / cm3}    
175   constexpr auto AIR_NITROGEN_MASS_FRACTION{0.    
176   constexpr auto AIR_OXYGEN_MASS_FRACTION{0.3}    
177                                                   
178   auto *air = new G4Material(name = "Air", AIR    
179   air->AddElement(nitrogen, AIR_NITROGEN_MASS_    
180   air->AddElement(oxygen, AIR_OXYGEN_MASS_FRAC    
181                                                   
182   constexpr auto ALUMINIUM_DENSITY{2.700 * g /    
183   constexpr auto ALUMINIUM_MASS_FRACTION{1.};     
184   auto *Al = new G4Material(name = "Aluminum",    
185   Al->AddElement(aluminium, ALUMINIUM_MASS_FRA    
186                                                   
187   constexpr auto SILICON_DENSITY{2.333 * g / c    
188   constexpr auto SILICON_MASS_FRACTION{1.};       
189   auto *Si = new G4Material(name = "Silicon",     
190   Si->AddElement(silicon, SILICON_MASS_FRACTIO    
191                                                   
192   constexpr auto IRON_DENSITY{7.87 * g / cm3};    
193   constexpr auto IRON_MASS_FRACTION{1.};          
194   auto *Fe = new G4Material(name = "Iron", IRO    
195   Fe->AddElement(iron, IRON_MASS_FRACTION);       
196                                                   
197   constexpr auto LEAD_DENSITY{11.35 * g / cm3}    
198   constexpr auto LEAD_MASS_FRACTION{1.};          
199   auto *Pb = new G4Material(name = "Lead", LEA    
200   Pb->AddElement(lead, LEAD_MASS_FRACTION);       
201                                                   
202   //                                              
203   // examples of vacuum                           
204   //                                              
205   constexpr auto VACUUM_ATOMIC_NUMBER{1.};        
206   constexpr auto VACUUM_DENSITY{universe_mean_    
207   constexpr auto VACUUM_MOLAR_MASS{1.01 * g /     
208     constexpr auto VACUUM_PRESSURE{3.e-18 * pa    
209     constexpr auto VACUUM_TEMPERATURE{2.73 * k    
210   auto *vacuum = new G4Material(name = "Galact    
211                                                   
212   constexpr auto BEAM_DENSITY{1.e-5 * g / cm3}    
213   constexpr auto BEAM_MASS_FRACTION{1.};          
214   constexpr auto BEAM_PRESSURE{2.e-2 * bar};      
215   constexpr auto BEAM_TEMPERATURE{STP_Temperat    
216   auto *beam = new G4Material(name = "Beam", B    
217   beam->AddMaterial(air, BEAM_MASS_FRACTION);     
218                                                   
219   G4cout << *(G4Material::GetMaterialTable())     
220                                                   
221   // default materials of the payload             
222                                                   
223     defaultMaterial = vacuum;                     
224                                                   
225   converterMaterial = tungsten;                   
226   acdMaterial = scintillatorMaterial; // antic    
227   calMaterial = cesiumIodide; // calorimeter (    
228   tkrMaterial = Si; // tracker (TKR)              
229 }                                                 
230                                                   
231 //....oooOO0OOooo........oooOO0OOooo........oo    
232                                                   
233 auto GammaRayTelDetectorConstruction::Construc    
234   // complete the payload parameters definitio    
235   ComputePayloadParameters();                     
236                                                   
237   //                                              
238   // World                                        
239   //                                              
240                                                   
241   solidWorld = new G4Box("World", worldSizeXY     
242   logicWorld = new G4LogicalVolume(solidWorld,    
243   physiWorld = new G4PVPlacement(nullptr, G4Th    
244                                                   
245   //                                              
246   // Payload                                      
247   //                                              
248                                                   
249   solidPayload = new G4Box("Payload", payloadS    
250   logicPayload = new G4LogicalVolume(solidPayl    
251   physiPayload = new G4PVPlacement(nullptr, G4    
252                                                   
253   //                                              
254   // Calorimeter (CAL)                            
255   //                                              
256                                                   
257   solidCAL = new G4Box("CAL", calSizeXY / 2, c    
258   logicCAL = new G4LogicalVolume(solidCAL, def    
259   physiCAL = new G4PVPlacement(nullptr,           
260           G4ThreeVector(0, 0,                     
261                   -payloadSizeZ / 2 + calSizeZ    
262             "CAL", logicCAL, physiPayload, fal    
263                                                   
264   //                                              
265   // Tracker (TKR)                                
266   //                                              
267                                                   
268   solidTKR = new G4Box("TKR", tkrSizeXY / 2, t    
269   logicTKR = new G4LogicalVolume(solidTKR, def    
270   physiTKR = new G4PVPlacement(nullptr,           
271           G4ThreeVector(0, 0,                     
272                   -payloadSizeZ / 2 + calSizeZ    
273                       + tkrSizeZ / 2),            
274             "TKR", logicTKR, physiPayload, fal    
275                                                   
276   //                                              
277   // Anticoincidence, Top Side (ACT)              
278   //                                              
279                                                   
280   solidACT = new G4Box("ACT", actSizeXY / 2, a    
281   logicACT = new G4LogicalVolume(solidACT, acd    
282   physiACT = new G4PVPlacement(nullptr,           
283       G4ThreeVector(0, 0,                         
284           -payloadSizeZ / 2 + calSizeZ + calTK    
285               + acdTKRDistance + actSizeZ / 2)    
286             "ACT", logicACT, physiPayload, fal    
287                                                   
288   //                                              
289   // Anticoincidence, Lateral Side (ACL)          
290   //                                              
291                                                   
292   solidACL1 = new G4Box("ACL1", acl1SizeX / 2,    
293   logicACL1 = new G4LogicalVolume(solidACL1, a    
294                                                   
295   physiACL1 = new G4PVPlacement(nullptr,          
296       G4ThreeVector(-payloadSizeXY / 2 + acl1S    
297           -payloadSizeXY / 2 + acl1SizeY / 2,     
298           -payloadSizeZ / 2 + acl1SizeZ / 2),     
299             "ACL1", logicACL1, physiPayload, f    
300                                                   
301   physiACL1 = new G4PVPlacement(nullptr,          
302       G4ThreeVector(payloadSizeXY / 2 - acl1Si    
303           payloadSizeXY / 2 - acl1SizeY / 2,      
304           -payloadSizeZ / 2 + acl1SizeZ / 2),     
305             "ACL1", logicACL1, physiPayload, f    
306                                                   
307   solidACL2 = new G4Box("ACL2", acl2SizeX / 2,    
308   logicACL2 = new G4LogicalVolume(solidACL2, a    
309                                                   
310   physiACL2 = new G4PVPlacement(nullptr,          
311       G4ThreeVector(-payloadSizeXY / 2 + acl2S    
312           payloadSizeXY / 2 - acl2SizeY / 2,      
313           -payloadSizeZ / 2 + acl2SizeZ / 2),     
314             "ACL2", logicACL2, physiPayload, f    
315                                                   
316   physiACL2 = new G4PVPlacement(nullptr,          
317       G4ThreeVector(payloadSizeXY / 2 - acl2Si    
318           -payloadSizeXY / 2 + acl2SizeY / 2,     
319           -payloadSizeZ / 2 + acl2SizeZ / 2),     
320             "ACL2", logicACL2, physiPayload, f    
321                                                   
322   //                                              
323   // Tracker Structure (Plane + Converter + TK    
324   //                                              
325                                                   
326   solidPlane = new G4Box("Plane", tkrSizeXY /     
327   logicPlane = new G4LogicalVolume(solidPlane,    
328                                                   
329   solidTKRDetectorY = new G4Box("TKRDetectorY"    
330   logicTKRDetectorY = new G4LogicalVolume(soli    
331                                                   
332   solidTKRDetectorX = new G4Box("TKRDetectorX"    
333   logicTKRDetectorX = new G4LogicalVolume(soli    
334                                                   
335   solidConverter = new G4Box("Converter", tkrS    
336   logicConverter = new G4LogicalVolume(solidCo    
337                                                   
338   G4int i = 0;                                    
339                                                   
340   for (i = 0; i < numberOfTKRLayers; i++) {       
341     physiTKRDetectorY = new G4PVPlacement(null    
342             G4ThreeVector(0., 0.,                 
343                 -tkrSizeZ / 2 + tkrSiliconThic    
344                     + (i) * tkrLayerDistance),    
345             "TKRDetectorY", logicTKRDetectorY,    
346                                                   
347     physiTKRDetectorX = new G4PVPlacement(null    
348             G4ThreeVector(0., 0.,                 
349                 -tkrSizeZ / 2 + tkrSiliconThic    
350                     + tkrViewsDistance + tkrSi    
351                     + (i) * tkrLayerDistance),    
352             "TKRDetectorX", logicTKRDetectorX,    
353                                                   
354     physiConverter = new G4PVPlacement(nullptr    
355             G4ThreeVector(0., 0.,                 
356                 -tkrSizeZ / 2 + 2 * tkrSilicon    
357                     + tkrViewsDistance + conve    
358                     + (i) * tkrLayerDistance),    
359             "Converter", logicConverter, physi    
360                                                   
361     physiPlane = new G4PVPlacement(nullptr,       
362             G4ThreeVector(0., 0.,                 
363                 -tkrSizeZ / 2 + 2 * tkrSilicon    
364                     + tkrViewsDistance + conve    
365                     + tkrSupportThickness / 2     
366                     + (i) * tkrLayerDistance),    
367             "Plane", logicPlane, physiTKR, fal    
368   }                                               
369                                                   
370   auto *solidTKRActiveTileX = new G4Box("Activ    
371   auto *solidTKRActiveTileY = new G4Box("Activ    
372                                                   
373   auto *logicTKRActiveTileX = new G4LogicalVol    
374   auto *logicTKRActiveTileY = new G4LogicalVol    
375                                                   
376   G4int j = 0;                                    
377   G4int k = 0;                                    
378                                                   
379   G4double x = 0.;                                
380   G4double y = 0.;                                
381   G4double z = 0.;                                
382                                                   
383   for (i = 0; i < numberOfTKRTiles; i++) {        
384     for (j = 0; j < numberOfTKRTiles; j++) {      
385       k = i * numberOfTKRTiles + j;               
386                                                   
387       x = -tkrSizeXY / 2 + tilesSeparation + s    
388                     + tkrActiveTileXY / 2         
389                     + (i)                         
390                         * ((2 * siliconGuardRi    
391                             + tkrActiveTileXY)    
392                                                   
393       y = -tkrSizeXY / 2 + tilesSeparation + s    
394           + tkrActiveTileXY / 2                   
395           + (j)                                   
396                         * ((2 * siliconGuardRi    
397                             + tkrActiveTileXY)    
398       z = 0.;                                     
399                                                   
400       new G4PVPlacement(nullptr, G4ThreeVector    
401                                                   
402       x = -tkrSizeXY / 2 + tilesSeparation + s    
403           + tkrActiveTileXY / 2                   
404           + (j)                                   
405                         * ((2 * siliconGuardRi    
406                             + tkrActiveTileXY)    
407                                                   
408       y = -tkrSizeXY / 2 + tilesSeparation + s    
409           + tkrActiveTileXY / 2                   
410           + (i)                                   
411                         * ((2 * siliconGuardRi    
412                             + tkrActiveTileXY)    
413       z = 0.;                                     
414                                                   
415       new G4PVPlacement(nullptr, G4ThreeVector    
416     }                                             
417   }                                               
418                                                   
419   // Strips                                       
420                                                   
421   // Silicon Strips                               
422                                                   
423   /*                                              
424     G4double tkrXStripX{0.};                      
425     G4double tkrYStripY{0.};                      
426     G4double tkrYStripX{0.};                      
427     G4double tkrXStripY{0.};                      
428   */                                              
429                                                   
430   tkrXStripX = tkrYStripY = tkrSiliconPitch;      
431   tkrYStripX = tkrXStripY = tkrActiveTileXY;      
432   tkrZStrip = tkrSiliconThickness;                
433                                                   
434   auto *solidTKRStripX = new G4Box("Strip X",     
435   logicTKRStripX = new G4LogicalVolume(solidTK    
436                                                   
437   auto *solidTKRStripY = new G4Box("Strip Y",     
438   logicTKRStripY = new G4LogicalVolume(solidTK    
439                                                   
440   for (i = 0; i < numberOfTKRStrips; i++) {       
441     new G4PVPlacement(nullptr,                    
442             G4ThreeVector(                        
443                 -tkrActiveTileXY / 2 + tkrSili    
444                     + (i) * tkrSiliconPitch, 0    
445             logicTKRStripX, "Strip X", logicTK    
446                                                   
447     new G4PVPlacement(nullptr,                    
448             G4ThreeVector(0.,                     
449                 -tkrActiveTileXY / 2 + tkrSili    
450                     + (i) * tkrSiliconPitch, 0    
451             logicTKRStripY, "Strip Y", logicTK    
452   }                                               
453                                                   
454   //                                              
455   // Calorimeter Structure (CALLayerX + CALLay    
456   //                                              
457                                                   
458   solidCALLayerX = new G4Box("CALLayerX", calS    
459   logicCALLayerX = new G4LogicalVolume(solidCA    
460                                                   
461   solidCALLayerY = new G4Box("CALLayerY", calS    
462   logicCALLayerY = new G4LogicalVolume(solidCA    
463                                                   
464   for (i = 0; i < numberOfCALLayers; i++) {       
465     physiCALLayerY = new G4PVPlacement(nullptr    
466             G4ThreeVector(0, 0,                   
467                 -calSizeZ / 2 + calBarThicknes    
468                     + (i) * 2 * calBarThicknes    
469             "CALLayerY", logicCALLayerY, physi    
470                                                   
471     physiCALLayerX = new G4PVPlacement(nullptr    
472             G4ThreeVector(0, 0,                   
473                 -calSizeZ / 2 + calBarThicknes    
474                     + (i) * 2 * calBarThicknes    
475             "CALLayerX", logicCALLayerX, physi    
476   }                                               
477                                                   
478   //                                              
479   // Calorimeter Structure (CALDetectorX + CAL    
480   //                                              
481                                                   
482   solidCALDetectorX = new G4Box("CALDetectorX"    
483   logicCALDetectorX = new G4LogicalVolume(soli    
484                                                   
485   solidCALDetectorY = new G4Box("CALDetectorY"    
486   logicCALDetectorY = new G4LogicalVolume(soli    
487                                                   
488   for (i = 0; i < numberOfCALBars; i++) {         
489     physiCALDetectorY = new G4PVPlacement(null    
490             G4ThreeVector(-calSizeXY / 2 + cal    
491             logicCALDetectorY, "CALDetectorY",    
492                                                   
493     physiCALDetectorX = new G4PVPlacement(null    
494             G4ThreeVector(0, -calSizeXY / 2 +     
495             logicCALDetectorX, "CALDetectorX",    
496   }                                               
497                                                   
498 /*                                                
499      // Cuts by Region                            
500                                                   
501     G4String regionName[] = {"Calorimeter", "T    
502                                                   
503     if (calorimeterCutRegion) {                   
504         delete calorimeterCutRegion;              
505     }                                             
506     calorimeterCutRegion = new G4Region(region    
507     logicCAL->SetRegion(calorimeterCutRegion);    
508     calorimeterCutRegion->AddRootLogicalVolume    
509                                                   
510     if (trackerCutRegion != nullptr) {            
511         delete trackerCutRegion;                  
512     }                                             
513     trackerCutRegion = new G4Region(regionName    
514     logicTKR->SetRegion(trackerCutRegion);        
515     trackerCutRegion->AddRootLogicalVolume(log    
516 */                                                
517                                                   
518   //                                              
519   // Visualization attributes                     
520   //                                              
521   // Invisible Volume                             
522   logicWorld->SetVisAttributes(G4VisAttributes    
523   logicPayload->SetVisAttributes(G4VisAttribut    
524   logicTKR->SetVisAttributes(G4VisAttributes::    
525   logicTKRActiveTileX->SetVisAttributes(G4VisA    
526   logicTKRActiveTileY->SetVisAttributes(G4VisA    
527   logicPlane->SetVisAttributes(G4VisAttributes    
528   logicConverter->SetVisAttributes(G4VisAttrib    
529   logicCAL->SetVisAttributes(G4VisAttributes::    
530   logicCALLayerX->SetVisAttributes(G4VisAttrib    
531   logicCALLayerY->SetVisAttributes(G4VisAttrib    
532   logicTKRStripX->SetVisAttributes(G4VisAttrib    
533   logicTKRStripY->SetVisAttributes(G4VisAttrib    
534                                                   
535   // Some visualization styles                    
536                                                   
537   auto *visualizationStyle1 = new G4VisAttribu    
538   visualizationStyle1->SetVisibility(true);       
539   visualizationStyle1->SetForceSolid(TRUE);       
540                                                   
541   auto *visualizationStyle2 = new G4VisAttribu    
542   visualizationStyle2->SetVisibility(true);       
543   visualizationStyle2->SetForceSolid(FALSE);      
544                                                   
545   auto *visualizationStyle3 = new G4VisAttribu    
546   visualizationStyle3->SetVisibility(true);       
547   visualizationStyle3->SetForceWireframe(TRUE)    
548                                                   
549   // Visible Volumes                              
550                                                   
551   logicCALDetectorX->SetVisAttributes(visualiz    
552   logicCALDetectorY->SetVisAttributes(visualiz    
553   logicTKRDetectorX->SetVisAttributes(visualiz    
554   logicTKRDetectorY->SetVisAttributes(visualiz    
555   logicACT->SetVisAttributes(visualizationStyl    
556   logicACL1->SetVisAttributes(visualizationSty    
557   logicACL2->SetVisAttributes(visualizationSty    
558                                                   
559   //                                              
560   // always return the physical World             
561   //                                              
562   PrintPayloadParameters();                       
563                                                   
564   return physiWorld;                              
565 }                                                 
566                                                   
567 //....oooOO0OOooo........oooOO0OOooo........oo    
568                                                   
569 void GammaRayTelDetectorConstruction::Construc    
570   //                                              
571   // Sensitive detector: Tracker                  
572   //                                              
573   if (trackerSD.Get() == nullptr) {               
574       constexpr auto TRACKER_SENSITIVE_DETECTO    
575     auto *sensitiveDetector = new GammaRayTelT    
576     trackerSD.Put(sensitiveDetector);             
577   }                                               
578                                                   
579   G4SDManager::GetSDMpointer()->AddNewDetector    
580                                                   
581   // Flags the strips as sensitive .              
582   if (logicTKRStripX != nullptr) {                
583     SetSensitiveDetector(logicTKRStripX, track    
584   }                                               
585   if (logicTKRStripY != nullptr) {                
586     SetSensitiveDetector(logicTKRStripY, track    
587   }                                               
588                                                   
589   //                                              
590   // Sensitive detector: Calorimeter              
591   //                                              
592   if (calorimeterSD.Get() == nullptr) {           
593       constexpr auto CALORIMETER_SENSITIVE_DET    
594     auto *sensitiveDetector = new GammaRayTelC    
595     calorimeterSD.Put(sensitiveDetector);         
596   }                                               
597                                                   
598   G4SDManager::GetSDMpointer()->AddNewDetector    
599   if (logicCALDetectorX != nullptr) {             
600     SetSensitiveDetector(logicCALDetectorX, ca    
601   }                                               
602   if (logicCALDetectorY != nullptr) {             
603     SetSensitiveDetector(logicCALDetectorY, ca    
604   }                                               
605                                                   
606   //                                              
607   // Sensitive detector: Anticoincidence          
608   //                                              
609   if (anticoincidenceSD.Get() == nullptr) {       
610       constexpr auto ANTICOINCIDENCE_SENSITIVE    
611     auto *sensitiveDetector = new GammaRayTelA    
612     anticoincidenceSD.Put(sensitiveDetector);     
613   }                                               
614                                                   
615   G4SDManager::GetSDMpointer()->AddNewDetector    
616   if (logicACT != nullptr) {                      
617     SetSensitiveDetector(logicACT, anticoincid    
618   }                                               
619   if (logicACL1 != nullptr) {                     
620     SetSensitiveDetector(logicACL1, anticoinci    
621   }                                               
622   if (logicACL2 != nullptr) {                     
623     SetSensitiveDetector(logicACL2, anticoinci    
624   }                                               
625                                                   
626   // Create global magnetic field messenger.      
627   // Uniform magnetic field is then created au    
628   auto fieldValue = G4ThreeVector();              
629   fMagFieldMessenger = new G4GlobalMagFieldMes    
630   fMagFieldMessenger->SetVerboseLevel(1);         
631                                                   
632   // Register the field messenger for deleting    
633   G4AutoDelete::Register (fMagFieldMessenger);    
634 }                                                 
635                                                   
636 //....oooOO0OOooo........oooOO0OOooo........oo    
637                                                   
638 void GammaRayTelDetectorConstruction::PrintPay    
639   G4cout                                          
640       << "\n----------------------------------    
641     << "---> The tracker is composed by " << n    
642     << ", each made of " << converterMaterial-    
643     << " and " << converterThickness / mm << "    
644     << "\n------------------------------------    
645 }                                                 
646                                                   
647 //....oooOO0OOooo........oooOO0OOooo........oo    
648                                                   
649 void GammaRayTelDetectorConstruction::SetConve    
650   // search the material by its name              
651   G4Material *material = G4Material::GetMateri    
652   if (material != nullptr) {                      
653     converterMaterial = material;                 
654     logicConverter->SetMaterial(material);        
655     PrintPayloadParameters();                     
656   }                                               
657 }                                                 
658                                                   
659 //....oooOO0OOooo........oooOO0OOooo........oo    
660                                                   
661 void GammaRayTelDetectorConstruction::SetConve    
662   converterThickness = value;                     
663 }                                                 
664                                                   
665 //....oooOO0OOooo........oooOO0OOooo........oo    
666                                                   
667 void GammaRayTelDetectorConstruction::SetTKRSi    
668   tkrSiliconThickness = value;                    
669 }                                                 
670                                                   
671 //....oooOO0OOooo........oooOO0OOooo........oo    
672                                                   
673 void GammaRayTelDetectorConstruction::SetTKRSi    
674   tkrSiliconPitch = value;                        
675 }                                                 
676                                                   
677 //....oooOO0OOooo........oooOO0OOooo........oo    
678                                                   
679 void GammaRayTelDetectorConstruction::SetTKRTi    
680   tkrSiliconTileXY = value;                       
681 }                                                 
682                                                   
683 //....oooOO0OOooo........oooOO0OOooo........oo    
684                                                   
685 void GammaRayTelDetectorConstruction::SetNbOfT    
686   numberOfTKRLayers = value;                      
687 }                                                 
688                                                   
689 //....oooOO0OOooo........oooOO0OOooo........oo    
690                                                   
691 void GammaRayTelDetectorConstruction::SetNbOfT    
692   numberOfTKRTiles = value;                       
693 }                                                 
694                                                   
695 //....oooOO0OOooo........oooOO0OOooo........oo    
696                                                   
697 void GammaRayTelDetectorConstruction::SetTKRLa    
698     tkrLayerDistance = value;                     
699 }                                                 
700                                                   
701 //....oooOO0OOooo........oooOO0OOooo........oo    
702                                                   
703 void GammaRayTelDetectorConstruction::SetTKRVi    
704     tkrViewsDistance = value;                     
705 }                                                 
706                                                   
707 //....oooOO0OOooo........oooOO0OOooo........oo    
708                                                   
709 void GammaRayTelDetectorConstruction::SetNbOfC    
710     numberOfCALLayers = value;                    
711 }                                                 
712                                                   
713 //....oooOO0OOooo........oooOO0OOooo........oo    
714                                                   
715 void GammaRayTelDetectorConstruction::SetNbOfC    
716     numberOfCALBars = value;                      
717 }                                                 
718                                                   
719 //....oooOO0OOooo........oooOO0OOooo........oo    
720                                                   
721 void GammaRayTelDetectorConstruction::SetCALBa    
722     calBarThickness = value;                      
723 }                                                 
724                                                   
725 //....oooOO0OOooo........oooOO0OOooo........oo    
726                                                   
727 void GammaRayTelDetectorConstruction::SetACDTh    
728     acdThickness = value;                         
729 }                                                 
730                                                   
731 //....oooOO0OOooo........oooOO0OOooo........oo    
732                                                   
733 void GammaRayTelDetectorConstruction::SetMagFi    
734     // Just invoke manually the MT-safe comman    
735     std::stringstream stream;                     
736     stream << "/globalField/setValue 0 0 " <<     
737                                                   
738     G4String command = stream.str();              
739     G4cout << "Going to execute: " << command     
740                                                   
741     auto *uiManager = G4UImanager::GetUIpointe    
742     uiManager->ApplyCommand(command);             
743 }                                                 
744                                                   
745 //....oooOO0OOooo........oooOO0OOooo........oo    
746                                                   
747 void GammaRayTelDetectorConstruction::UpdateGe    
748     // delete payloadSD;                          
749     G4RunManager::GetRunManager()->DefineWorld    
750     G4RunManager::GetRunManager()->PhysicsHasB    
751     G4RegionStore::GetInstance()->UpdateMateri    
752     G4RunManager::GetRunManager()->Reinitializ    
753 }                                                 
754