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] [ 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/biasing/GB03/src/GB03DetectorConstruction.cc (Version 11.3.0) and /examples/extended/biasing/GB03/src/GB03DetectorConstruction.cc (Version 4.1.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 /// \file GB03DetectorConstruction.cc             
 28 /// \brief Implementation of the GB03DetectorC    
 29                                                   
 30 #include "GB03DetectorConstruction.hh"            
 31                                                   
 32 #include "GB03BOptrGeometryBasedBiasing.hh"       
 33 #include "GB03DetectorMessenger.hh"               
 34                                                   
 35 #include "G4Box.hh"                               
 36 #include "G4Colour.hh"                            
 37 #include "G4LogicalVolume.hh"                     
 38 #include "G4Material.hh"                          
 39 #include "G4MultiFunctionalDetector.hh"           
 40 #include "G4PSEnergyDeposit.hh"                   
 41 #include "G4PSFlatSurfaceFlux.hh"                 
 42 #include "G4PVPlacement.hh"                       
 43 #include "G4PVReplica.hh"                         
 44 #include "G4PhysicalConstants.hh"                 
 45 #include "G4RunManager.hh"                        
 46 #include "G4SDChargedFilter.hh"                   
 47 #include "G4SDManager.hh"                         
 48 #include "G4SDNeutralFilter.hh"                   
 49 #include "G4SystemOfUnits.hh"                     
 50 #include "G4VisAttributes.hh"                     
 51 #include "G4ios.hh"                               
 52                                                   
 53 G4int GB03DetectorConstruction::fNumberOfLayer    
 54 G4ThreadLocal G4bool GB03DetectorConstruction:    
 55                                                   
 56 //....oooOO0OOooo........oooOO0OOooo........oo    
 57                                                   
 58 GB03DetectorConstruction::GB03DetectorConstruc    
 59   : G4VUserDetectorConstruction(),                
 60     fTotalThickness(2.0 * m),                     
 61     fLayerThickness(0.),                          
 62     fConstructed(false),                          
 63     fWorldMaterial(0),                            
 64     fAbsorberMaterial(0),                         
 65     fGapMaterial(0),                              
 66     fLayerSolid(0),                               
 67     fGapSolid(0),                                 
 68     fWorldLogical(0),                             
 69     fCalorLogical(0),                             
 70     fLayerLogical(0),                             
 71     fGapLogical(0),                               
 72     fWorldPhysical(0),                            
 73     fCalorPhysical(0),                            
 74     fLayerPhysical(0),                            
 75     fGapPhysical(0),                              
 76     fDetectorMessenger(0),                        
 77     fVerboseLevel(1)                              
 78 {                                                 
 79   fLayerThickness = fTotalThickness / fNumberO    
 80   fCalName = "Calor";                             
 81   fDetectorMessenger = new GB03DetectorMesseng    
 82 }                                                 
 83                                                   
 84 //....oooOO0OOooo........oooOO0OOooo........oo    
 85                                                   
 86 GB03DetectorConstruction::~GB03DetectorConstru    
 87 {                                                 
 88   delete fDetectorMessenger;                      
 89 }                                                 
 90                                                   
 91 //....oooOO0OOooo........oooOO0OOooo........oo    
 92                                                   
 93 G4VPhysicalVolume* GB03DetectorConstruction::C    
 94 {                                                 
 95   if (!fConstructed) {                            
 96     fConstructed = true;                          
 97     DefineMaterials();                            
 98     SetupGeometry();                              
 99   }                                               
100   if (GetVerboseLevel() > 0) {                    
101     PrintCalorParameters();                       
102   }                                               
103                                                   
104   return fWorldPhysical;                          
105 }                                                 
106                                                   
107 //....oooOO0OOooo........oooOO0OOooo........oo    
108                                                   
109 void GB03DetectorConstruction::ConstructSDandF    
110 {                                                 
111   if (!fConstructedSDandField) {                  
112     fConstructedSDandField = true;                
113     SetupDetectors();                             
114     SetupBiasing();                               
115   }                                               
116 }                                                 
117                                                   
118 //....oooOO0OOooo........oooOO0OOooo........oo    
119                                                   
120 void GB03DetectorConstruction::DefineMaterials    
121 {                                                 
122   G4String name, symbol;  // a=mass of a mole;    
123   G4double a, z, density;  // z=mean number of    
124   G4int iz;  // iz=number of protons  in an is    
125   G4int n;  // n=number of nucleons in an isot    
126                                                   
127   G4int ncomponents, natoms;                      
128   G4double abundance, fractionmass;               
129   G4double temperature, pressure;                 
130                                                   
131   //                                              
132   // define Elements                              
133   //                                              
134                                                   
135   a = 1.01 * g / mole;                            
136   G4Element* H = new G4Element(name = "Hydroge    
137                                                   
138   a = 12.01 * g / mole;                           
139   G4Element* C = new G4Element(name = "Carbon"    
140                                                   
141   a = 14.01 * g / mole;                           
142   G4Element* N = new G4Element(name = "Nitroge    
143                                                   
144   a = 16.00 * g / mole;                           
145   G4Element* O = new G4Element(name = "Oxygen"    
146                                                   
147   //                                              
148   // define an Element from isotopes, by relat    
149   //                                              
150                                                   
151   G4Isotope* U5 = new G4Isotope(name = "U235",    
152   G4Isotope* U8 = new G4Isotope(name = "U238",    
153                                                   
154   G4Element* U = new G4Element(name = "enriche    
155   U->AddIsotope(U5, abundance = 90. * perCent)    
156   U->AddIsotope(U8, abundance = 10. * perCent)    
157                                                   
158   //                                              
159   // define simple materials                      
160   //                                              
161                                                   
162   new G4Material(name = "Aluminium", z = 13.,     
163   new G4Material(name = "Silicon", z = 14., a     
164   new G4Material(name = "Iron", z = 26., a = 5    
165   new G4Material(name = "ArgonGas", z = 18., a    
166   new G4Material(name = "He", z = 2., a = 4.0     
167                                                   
168   density = 1.390 * g / cm3;                      
169   a = 39.95 * g / mole;                           
170   new G4Material(name = "liquidArgon", z = 18.    
171                                                   
172   density = 11.35 * g / cm3;                      
173   a = 207.19 * g / mole;                          
174   G4Material* Pb = new G4Material(name = "Lead    
175                                                   
176   //                                              
177   // define a material from elements.   case 1    
178   //                                              
179                                                   
180   density = 1.000 * g / cm3;                      
181   G4Material* H2O = new G4Material(name = "Wat    
182   H2O->AddElement(H, natoms = 2);                 
183   H2O->AddElement(O, natoms = 1);                 
184                                                   
185   density = 1.032 * g / cm3;                      
186   G4Material* Sci = new G4Material(name = "Sci    
187   Sci->AddElement(C, natoms = 9);                 
188   Sci->AddElement(H, natoms = 10);                
189                                                   
190   //                                              
191   // define a material from elements.   case 2    
192   //                                              
193                                                   
194   density = 1.290 * mg / cm3;                     
195   G4Material* Air = new G4Material(name = "Air    
196   Air->AddElement(N, fractionmass = 0.7);         
197   Air->AddElement(O, fractionmass = 0.3);         
198                                                   
199   //                                              
200   // examples of vacuum                           
201   //                                              
202                                                   
203   density = universe_mean_density;                
204   pressure = 3.e-18 * pascal;                     
205   temperature = 2.73 * kelvin;                    
206   G4Material* Vacuum = new G4Material(name = "    
207                                       kStateGa    
208                                                   
209   if (GetVerboseLevel() > 1) {                    
210     G4cout << *(G4Material::GetMaterialTable()    
211   }                                               
212                                                   
213   // default materials of the calorimeter         
214   fWorldMaterial = Vacuum;                        
215   fAbsorberMaterial = Pb;                         
216   fGapMaterial = Sci;                             
217 }                                                 
218                                                   
219 //....oooOO0OOooo........oooOO0OOooo........oo    
220                                                   
221 void GB03DetectorConstruction::SetupGeometry()    
222 {                                                 
223   //                                              
224   // World                                        
225   //                                              
226   G4VSolid* worldSolid = new G4Box("World", 2.    
227   fWorldLogical = new G4LogicalVolume(worldSol    
228   fWorldPhysical = new G4PVPlacement(0, G4Thre    
229                                                   
230   //                                              
231   // Calorimeter                                  
232   //                                              
233   G4VSolid* calorSolid = new G4Box("Calor", 0.    
234   fCalorLogical = new G4LogicalVolume(calorSol    
235   fCalorPhysical = new G4PVPlacement(0, G4Thre    
236                                      fWorldLog    
237                                                   
238   //                                              
239   // Layers --- as absorbers                      
240   //                                              
241   fLayerSolid = new G4Box("Layer", 0.5 * m, 0.    
242   fLayerLogical = new G4LogicalVolume(fLayerSo    
243   fLayerPhysical = new G4PVReplica(fCalName +     
244                                    fNumberOfLa    
245                                                   
246   //                                              
247   // Gap                                          
248   //                                              
249   fGapSolid = new G4Box("Gap", 0.5 * m, 0.5 *     
250   fGapLogical = new G4LogicalVolume(fGapSolid,    
251   fGapPhysical = new G4PVPlacement(0, G4ThreeV    
252                                    fCalName +     
253                                                   
254   //                                              
255   // Visualization attributes                     
256   //                                              
257   fWorldLogical->SetVisAttributes(G4VisAttribu    
258   G4VisAttributes* simpleBoxVisAtt = new G4Vis    
259   simpleBoxVisAtt->SetVisibility(true);           
260   fCalorLogical->SetVisAttributes(simpleBoxVis    
261   fLayerLogical->SetVisAttributes(simpleBoxVis    
262   fGapLogical->SetVisAttributes(simpleBoxVisAt    
263 }                                                 
264                                                   
265 //....oooOO0OOooo........oooOO0OOooo........oo    
266                                                   
267 void GB03DetectorConstruction::SetupDetectors(    
268 {                                                 
269   G4SDManager::GetSDMpointer()->SetVerboseLeve    
270   G4String filterName;                            
271                                                   
272   G4SDNeutralFilter* neutralFilter = new G4SDN    
273   G4SDChargedFilter* chargedFilter = new G4SDC    
274                                                   
275   for (G4int j = 0; j < 2; j++) {                 
276     // Loop counter j = 0 : absorber              
277     //                = 1 : gap                   
278     G4String detName = fCalName;                  
279     if (j == 0) {                                 
280       detName += "_abs";                          
281     }                                             
282     else {                                        
283       detName += "_gap";                          
284     }                                             
285     G4MultiFunctionalDetector* det = new G4Mul    
286     G4SDManager::GetSDMpointer()->AddNewDetect    
287     // The second argument in each primitive m    
288     // hierarchy, the copy number of that leve    
289     // G4THitsMap.                                
290     // For absorber (j = 0), the copy number o    
291     // For gap (j = 1), the copy number of its    
292     // since there is only one physical volume    
293     // to its mother.                             
294     G4VPrimitiveScorer* primitive;                
295     primitive = new G4PSEnergyDeposit("eDep",     
296     det->RegisterPrimitive(primitive);            
297     primitive = new G4PSFlatSurfaceFlux("nNeut    
298     primitive->SetFilter(neutralFilter);          
299     det->RegisterPrimitive(primitive);            
300     primitive = new G4PSFlatSurfaceFlux("nChar    
301     primitive->SetFilter(chargedFilter);          
302     det->RegisterPrimitive(primitive);            
303                                                   
304     if (j == 0) {                                 
305       SetSensitiveDetector(fLayerLogical, det)    
306     }                                             
307     else {                                        
308       SetSensitiveDetector(fGapLogical, det);     
309     }                                             
310   }                                               
311   G4SDManager::GetSDMpointer()->SetVerboseLeve    
312 }                                                 
313                                                   
314 //....oooOO0OOooo........oooOO0OOooo........oo    
315                                                   
316 void GB03DetectorConstruction::SetupBiasing()     
317 {                                                 
318   GB03BOptrGeometryBasedBiasing* biasingOperat    
319   biasingOperator->AttachTo(fLayerLogical);       
320 }                                                 
321                                                   
322 //....oooOO0OOooo........oooOO0OOooo........oo    
323                                                   
324 void GB03DetectorConstruction::PrintCalorParam    
325 {                                                 
326   G4cout << "---------------------------------    
327   G4cout << " Absorber is made of " << fAbsorb    
328          << fGapMaterial->GetName() << G4endl     
329          << "---------------------------------    
330 }                                                 
331                                                   
332 //....oooOO0OOooo........oooOO0OOooo........oo    
333                                                   
334 void GB03DetectorConstruction::SetAbsorberMate    
335 {                                                 
336   // search the material by its name              
337   G4Material* pttoMaterial = G4Material::GetMa    
338   if (pttoMaterial) {                             
339     fAbsorberMaterial = pttoMaterial;             
340     if (fConstructed) {                           
341       fCalorLogical->SetMaterial(fAbsorberMate    
342       fLayerLogical->SetMaterial(fAbsorberMate    
343     }                                             
344     G4RunManager::GetRunManager()->GeometryHas    
345     if (GetVerboseLevel() > 1) {                  
346       PrintCalorParameters();                     
347     }                                             
348   }                                               
349   else {                                          
350     G4cerr << materialChoice << " is not defin    
351   }                                               
352 }                                                 
353                                                   
354 //....oooOO0OOooo........oooOO0OOooo........oo    
355                                                   
356 G4String GB03DetectorConstruction::GetAbsorber    
357 {                                                 
358   return fAbsorberMaterial->GetName();            
359 }                                                 
360                                                   
361 //....oooOO0OOooo........oooOO0OOooo........oo    
362                                                   
363 void GB03DetectorConstruction::SetGapMaterial(    
364 {                                                 
365   // search the material by its name              
366   G4Material* pttoMaterial = G4Material::GetMa    
367   if (pttoMaterial) {                             
368     fGapMaterial = pttoMaterial;                  
369     if (fConstructed) {                           
370       fGapLogical->SetMaterial(fGapMaterial);     
371     }                                             
372     G4RunManager::GetRunManager()->GeometryHas    
373     if (GetVerboseLevel() > 1) {                  
374       PrintCalorParameters();                     
375     }                                             
376   }                                               
377   else {                                          
378     G4cerr << materialChoice << " is not defin    
379   }                                               
380 }                                                 
381                                                   
382 //....oooOO0OOooo........oooOO0OOooo........oo    
383                                                   
384 G4String GB03DetectorConstruction::GetGapMater    
385 {                                                 
386   return fGapMaterial->GetName();                 
387 }                                                 
388                                                   
389 //....oooOO0OOooo........oooOO0OOooo........oo    
390                                                   
391 void GB03DetectorConstruction::SetNumberOfLaye    
392 {                                                 
393   fNumberOfLayers = nl;                           
394   fLayerThickness = fTotalThickness / fNumberO    
395   if (!fConstructed) return;                      
396                                                   
397   fLayerSolid->SetZHalfLength(fLayerThickness     
398   fGapSolid->SetZHalfLength(fLayerThickness /     
399                                                   
400   fCalorLogical->RemoveDaughter(fLayerPhysical    
401   delete fLayerPhysical;                          
402   fLayerPhysical = new G4PVReplica(fCalName +     
403                                    fNumberOfLa    
404   fGapPhysical->SetTranslation(G4ThreeVector(0    
405                                                   
406   G4RunManager::GetRunManager()->GeometryHasBe    
407 }                                                 
408                                                   
409 //....oooOO0OOooo........oooOO0OOooo........oo    
410