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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/field/field01/src/F01DetectorConstruction.cc (Version 11.3.0) and /examples/extended/field/field01/src/F01DetectorConstruction.cc (Version 6.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 /// \file field/field01/src/F01DetectorConstru    
 27 /// \brief Implementation of the F01DetectorCo    
 28 //                                                
 29 //                                                
 30 //                                                
 31 //                                                
 32 //....oooOO0OOooo........oooOO0OOooo........oo    
 33 //....oooOO0OOooo........oooOO0OOooo........oo    
 34                                                   
 35 #include "F01DetectorConstruction.hh"             
 36                                                   
 37 #include "F01CalorimeterSD.hh"                    
 38 #include "F01DetectorMessenger.hh"                
 39                                                   
 40 #include "G4AutoDelete.hh"                        
 41 #include "G4GeometryManager.hh"                   
 42 #include "G4FieldBuilder.hh"                      
 43 #include "G4LogicalVolume.hh"                     
 44 #include "G4LogicalVolumeStore.hh"                
 45 #include "G4Material.hh"                          
 46 #include "G4PVPlacement.hh"                       
 47 #include "G4PhysicalConstants.hh"                 
 48 #include "G4PhysicalVolumeStore.hh"               
 49 #include "G4RunManager.hh"                        
 50 #include "G4SDManager.hh"                         
 51 #include "G4SolidStore.hh"                        
 52 #include "G4SystemOfUnits.hh"                     
 53 #include "G4Tubs.hh"                              
 54 #include "G4UniformMagField.hh"                   
 55                                                   
 56 //....oooOO0OOooo........oooOO0OOooo........oo    
 57                                                   
 58 F01DetectorConstruction::F01DetectorConstructi    
 59 {                                                 
 60   // create commands for interactive definitio    
 61                                                   
 62   G4cout << "F01DetectorConstruction::F01Detec    
 63                                                   
 64   fDetectorMessenger = new F01DetectorMessenge    
 65                                                   
 66   // create field builder                         
 67   // this will create commands for field confi    
 68   G4FieldBuilder::Instance();                     
 69   // G4FieldBuilder::Instance()->SetVerboseLev    
 70                                                   
 71   // create materials                             
 72                                                   
 73   DefineMaterials();                              
 74 }                                                 
 75                                                   
 76 //....oooOO0OOooo........oooOO0OOooo........oo    
 77                                                   
 78 F01DetectorConstruction::~F01DetectorConstruct    
 79 {                                                 
 80   // delete fDetectorMessenger;                   
 81 }                                                 
 82                                                   
 83 //....oooOO0OOooo........oooOO0OOooo........oo    
 84                                                   
 85 G4VPhysicalVolume* F01DetectorConstruction::Co    
 86 {                                                 
 87   return ConstructCalorimeter();                  
 88 }                                                 
 89                                                   
 90 //....oooOO0OOooo........oooOO0OOooo........oo    
 91                                                   
 92 void F01DetectorConstruction::DefineMaterials(    
 93 {                                                 
 94   // This function illustrates the possible wa    
 95                                                   
 96   G4String name, symbol;  // a=mass of a mole;    
 97   G4double a, z, density;  // z=mean number of    
 98   G4int nel;                                      
 99   G4int ncomponents;                              
100   G4double fractionmass, pressure, temperature    
101                                                   
102   //                                              
103   // define Elements                              
104   //                                              
105                                                   
106   a = 1.01 * g / mole;                            
107   auto elH = new G4Element(name = "Hydrogen",     
108                                                   
109   a = 12.01 * g / mole;                           
110   auto elC = new G4Element(name = "Carbon", sy    
111                                                   
112   a = 14.01 * g / mole;                           
113   auto elN = new G4Element(name = "Nitrogen",     
114                                                   
115   a = 16.00 * g / mole;                           
116   auto elO = new G4Element(name = "Oxygen", sy    
117                                                   
118   a = 39.948 * g / mole;                          
119   auto elAr = new G4Element(name = "Argon", sy    
120                                                   
121   //                                              
122   // define simple materials                      
123   //                                              
124                                                   
125   // Mylar                                        
126                                                   
127   density = 1.39 * g / cm3;                       
128   auto mylar = new G4Material(name = "Mylar",     
129   mylar->AddElement(elO, 2);                      
130   mylar->AddElement(elC, 5);                      
131   mylar->AddElement(elH, 4);                      
132                                                   
133   // Polypropelene                                
134                                                   
135   auto CH2 = new G4Material("Polypropelene", 0    
136   CH2->AddElement(elH, 2);                        
137   CH2->AddElement(elC, 1);                        
138                                                   
139   // Krypton as detector gas, STP                 
140                                                   
141   density = 3.700 * mg / cm3;                     
142   a = 83.80 * g / mole;                           
143   auto Kr = new G4Material(name = "Kr", z = 36    
144                                                   
145   // Dry air (average composition)                
146                                                   
147   density = 1.7836 * mg / cm3;  // STP            
148   auto argon = new G4Material(name = "Argon",     
149   argon->AddElement(elAr, 1);                     
150                                                   
151   density = 1.25053 * mg / cm3;  // STP           
152   auto nitrogen = new G4Material(name = "N2",     
153   nitrogen->AddElement(elN, 2);                   
154                                                   
155   density = 1.4289 * mg / cm3;  // STP            
156   auto oxygen = new G4Material(name = "O2", de    
157   oxygen->AddElement(elO, 2);                     
158                                                   
159   density = 1.2928 * mg / cm3;  // STP            
160   density *= 1.0e-8;  // pumped vacuum            
161                                                   
162   temperature = STP_Temperature;                  
163   pressure = 1.0e-8 * STP_Pressure;               
164                                                   
165   auto air =                                      
166     new G4Material(name = "Air", density, ncom    
167   air->AddMaterial(nitrogen, fractionmass = 0.    
168   air->AddMaterial(oxygen, fractionmass = 0.23    
169                                                   
170   air->AddMaterial(argon, fractionmass = 0.012    
171                                                   
172   // Xenon as detector gas, STP                   
173                                                   
174   density = 5.858 * mg / cm3;                     
175   a = 131.29 * g / mole;                          
176   auto Xe = new G4Material(name = "Xenon", z =    
177                                                   
178   // Carbon dioxide, STP                          
179                                                   
180   density = 1.842 * mg / cm3;                     
181   auto CarbonDioxide = new G4Material(name = "    
182   CarbonDioxide->AddElement(elC, 1);              
183   CarbonDioxide->AddElement(elO, 2);              
184                                                   
185   // 80% Xe + 20% CO2, STP                        
186                                                   
187   density = 5.0818 * mg / cm3;                    
188   auto Xe20CO2 = new G4Material(name = "Xe20CO    
189   Xe20CO2->AddMaterial(Xe, fractionmass = 0.92    
190   Xe20CO2->AddMaterial(CarbonDioxide, fraction    
191                                                   
192   // 80% Kr + 20% CO2, STP                        
193                                                   
194   density = 3.601 * mg / cm3;                     
195   auto Kr20CO2 = new G4Material(name = "Kr20CO    
196   Kr20CO2->AddMaterial(Kr, fractionmass = 0.89    
197   Kr20CO2->AddMaterial(CarbonDioxide, fraction    
198                                                   
199   // Print material table -- silence it for no    
200   // G4cout << *(G4Material::GetMaterialTable(    
201   G4cout << "F01DetectorConstruction: not prin    
202          << G4endl;                               
203                                                   
204   // default materials of the calorimeter         
205                                                   
206   fAbsorberMaterial = air;  //  Kr20CO2;   //     
207                                                   
208   fWorldMaterial = air;                           
209 }                                                 
210                                                   
211 //....oooOO0OOooo........oooOO0OOooo........oo    
212                                                   
213 G4VPhysicalVolume* F01DetectorConstruction::Co    
214 {                                                 
215   // In case an old geometry is present... cle    
216                                                   
217   if (fPhysiWorld) {                              
218     G4GeometryManager::GetInstance()->OpenGeom    
219     G4PhysicalVolumeStore::GetInstance()->Clea    
220     G4LogicalVolumeStore::GetInstance()->Clean    
221     G4SolidStore::GetInstance()->Clean();         
222   }                                               
223                                                   
224   // Compute the Calor parameters definition a    
225                                                   
226   ComputeCalorParameters();                       
227   PrintCalorParameters();                         
228                                                   
229   // World                                        
230                                                   
231   fSolidWorld = new G4Tubs("World",  // its na    
232                            0., fWorldSizeR, fW    
233                                                   
234   fLogicWorld = new G4LogicalVolume(fSolidWorl    
235                                     fWorldMate    
236                                     "World");     
237                                                   
238   fPhysiWorld = new G4PVPlacement(nullptr,  //    
239                                   G4ThreeVecto    
240                                   "World",  //    
241                                   fLogicWorld,    
242                                   nullptr,  //    
243                                   false,  // n    
244                                   0);  // copy    
245   // Absorber                                     
246                                                   
247   fSolidAbsorber =                                
248     new G4Tubs("Absorber", 1.0 * mm, fAbsorber    
249                                                   
250   fLogicAbsorber = new G4LogicalVolume(fSolidA    
251                                                   
252   fPhysiAbsorber = new G4PVPlacement(nullptr,     
253                                      fLogicAbs    
254                                                   
255   return fPhysiWorld;                             
256 }                                                 
257                                                   
258 //....oooOO0OOooo........oooOO0OOooo........oo    
259                                                   
260 void F01DetectorConstruction::PrintCalorParame    
261 {                                                 
262   G4cout << "\n The  WORLD   is made of " << f    
263          << fWorldMaterial->GetName();            
264   G4cout << ", the transverse size (R) of the     
265   G4cout << " The ABSORBER is made of " << fAb    
266          << fAbsorberMaterial->GetName();         
267   G4cout << ", the transverse size (R) is " <<    
268   G4cout << " Z position of the (middle of the    
269   G4cout << G4endl;                               
270 }                                                 
271                                                   
272 //....oooOO0OOooo........oooOO0OOooo........oo    
273                                                   
274 void F01DetectorConstruction::SetAbsorberMater    
275 {                                                 
276   // get the pointer to the material table        
277   const G4MaterialTable* theMaterialTable = G4    
278                                                   
279   // search the material by its name              
280   G4Material* material;                           
281   for (size_t j = 0; j < theMaterialTable->siz    
282     material = (*theMaterialTable)[j];            
283     if (material->GetName() == materialChoice)    
284       fAbsorberMaterial = material;               
285       fLogicAbsorber->SetMaterial(material);      
286       G4RunManager::GetRunManager()->PhysicsHa    
287     }                                             
288   }                                               
289 }                                                 
290                                                   
291 //....oooOO0OOooo........oooOO0OOooo........oo    
292                                                   
293 void F01DetectorConstruction::SetWorldMaterial    
294 {                                                 
295   // get the pointer to the material table        
296   const G4MaterialTable* theMaterialTable = G4    
297                                                   
298   // search the material by its name              
299   G4Material* material;                           
300   for (size_t j = 0; j < theMaterialTable->siz    
301     material = (*theMaterialTable)[j];            
302     if (material->GetName() == materialChoice)    
303       fWorldMaterial = material;                  
304       fLogicWorld->SetMaterial(material);         
305       G4RunManager::GetRunManager()->PhysicsHa    
306     }                                             
307   }                                               
308 }                                                 
309                                                   
310 //....oooOO0OOooo........oooOO0OOooo........oo    
311                                                   
312 void F01DetectorConstruction::SetAbsorberThick    
313 {                                                 
314   // change Absorber thickness and recompute t    
315   fAbsorberThickness = val;                       
316   ComputeCalorParameters();                       
317   G4RunManager::GetRunManager()->GeometryHasBe    
318 }                                                 
319                                                   
320 //....oooOO0OOooo........oooOO0OOooo........oo    
321                                                   
322 void F01DetectorConstruction::SetAbsorberRadiu    
323 {                                                 
324   // change the transverse size and recompute     
325   fAbsorberRadius = val;                          
326   ComputeCalorParameters();                       
327   G4RunManager::GetRunManager()->GeometryHasBe    
328 }                                                 
329                                                   
330 //....oooOO0OOooo........oooOO0OOooo........oo    
331                                                   
332 void F01DetectorConstruction::SetWorldSizeZ(G4    
333 {                                                 
334   fWorldSizeZ = val;                              
335   ComputeCalorParameters();                       
336   G4RunManager::GetRunManager()->GeometryHasBe    
337 }                                                 
338                                                   
339 //....oooOO0OOooo........oooOO0OOooo........oo    
340                                                   
341 void F01DetectorConstruction::SetWorldSizeR(G4    
342 {                                                 
343   fWorldSizeR = val;                              
344   ComputeCalorParameters();                       
345   G4RunManager::GetRunManager()->GeometryHasBe    
346 }                                                 
347                                                   
348 //....oooOO0OOooo........oooOO0OOooo........oo    
349                                                   
350 void F01DetectorConstruction::SetAbsorberZpos(    
351 {                                                 
352   fZAbsorber = val;                               
353   ComputeCalorParameters();                       
354   G4RunManager::GetRunManager()->GeometryHasBe    
355 }                                                 
356                                                   
357 //....oooOO0OOooo........oooOO0OOooo........oo    
358                                                   
359 void F01DetectorConstruction::SetFieldValue(G4    
360 {                                                 
361   fFieldVector = value;                           
362                                                   
363   G4UniformMagField* magField = nullptr;          
364   if (fFieldVector != G4ThreeVector(0.,0.,0.))    
365     magField = new G4UniformMagField(fFieldVec    
366   }                                               
367                                                   
368   // Set field to the field builder               
369   auto fieldBuilder = G4FieldBuilder::Instance    
370   fieldBuilder->SetGlobalField(magField);         
371 }                                                 
372                                                   
373 //....oooOO0OOooo........oooOO0OOooo........oo    
374 #include "G4FieldManager.hh"                      
375                                                   
376 void F01DetectorConstruction::ConstructSDandFi    
377 {                                                 
378   // Sensitive Detectors: Absorber                
379                                                   
380   if (!fCalorimeterSD.Get()) {                    
381     auto calorimeterSD = new F01CalorimeterSD(    
382     fCalorimeterSD.Put(calorimeterSD);            
383   }                                               
384   G4SDManager::GetSDMpointer()->AddNewDetector    
385   SetSensitiveDetector(fLogicAbsorber, fCalori    
386                                                   
387   // Create detector field                        
388   SetFieldValue(fFieldVector);                    
389                                                   
390   // Construct all Geant4 field objects           
391   auto fieldBuilder = G4FieldBuilder::Instance    
392   fieldBuilder->ConstructFieldSetup();            
393 }                                                 
394                                                   
395 //....oooOO0OOooo........oooOO0OOooo........oo    
396