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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/basic/B4/B4c/src/DetectorConstruction.cc (Version 11.3.0) and /examples/basic/B4/B4c/src/DetectorConstruction.cc (Version 9.5.p2)


  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 B4/B4c/src/DetectorConstruction.cc      
 28 /// \brief Implementation of the B4c::Detector    
 29                                                   
 30 #include "DetectorConstruction.hh"                
 31                                                   
 32 #include "CalorimeterSD.hh"                       
 33                                                   
 34 #include "G4AutoDelete.hh"                        
 35 #include "G4Box.hh"                               
 36 #include "G4Colour.hh"                            
 37 #include "G4GlobalMagFieldMessenger.hh"           
 38 #include "G4LogicalVolume.hh"                     
 39 #include "G4Material.hh"                          
 40 #include "G4NistManager.hh"                       
 41 #include "G4PVPlacement.hh"                       
 42 #include "G4PVReplica.hh"                         
 43 #include "G4PhysicalConstants.hh"                 
 44 #include "G4SDManager.hh"                         
 45 #include "G4SystemOfUnits.hh"                     
 46 #include "G4VisAttributes.hh"                     
 47                                                   
 48 namespace B4c                                     
 49 {                                                 
 50                                                   
 51 //....oooOO0OOooo........oooOO0OOooo........oo    
 52                                                   
 53 G4ThreadLocal G4GlobalMagFieldMessenger* Detec    
 54                                                   
 55 //....oooOO0OOooo........oooOO0OOooo........oo    
 56                                                   
 57 G4VPhysicalVolume* DetectorConstruction::Const    
 58 {                                                 
 59   // Define materials                             
 60   DefineMaterials();                              
 61                                                   
 62   // Define volumes                               
 63   return DefineVolumes();                         
 64 }                                                 
 65                                                   
 66 //....oooOO0OOooo........oooOO0OOooo........oo    
 67                                                   
 68 void DetectorConstruction::DefineMaterials()      
 69 {                                                 
 70   // Lead material defined using NIST Manager     
 71   auto nistManager = G4NistManager::Instance()    
 72   nistManager->FindOrBuildMaterial("G4_Pb");      
 73                                                   
 74   // Liquid argon material                        
 75   G4double a;  // mass of a mole;                 
 76   G4double z;  // z=mean number of protons;       
 77   G4double density;                               
 78   new G4Material("liquidArgon", z = 18., a = 3    
 79   // The argon by NIST Manager is a gas with a    
 80                                                   
 81   // Vacuum                                       
 82   new G4Material("Galactic", z = 1., a = 1.01     
 83                  kStateGas, 2.73 * kelvin, 3.e    
 84                                                   
 85   // Print materials                              
 86   G4cout << *(G4Material::GetMaterialTable())     
 87 }                                                 
 88                                                   
 89 //....oooOO0OOooo........oooOO0OOooo........oo    
 90                                                   
 91 G4VPhysicalVolume* DetectorConstruction::Defin    
 92 {                                                 
 93   // Geometry parameters                          
 94   fNofLayers = 10;                                
 95   G4double absoThickness = 10. * mm;              
 96   G4double gapThickness = 5. * mm;                
 97   G4double calorSizeXY = 10. * cm;                
 98                                                   
 99   auto layerThickness = absoThickness + gapThi    
100   auto calorThickness = fNofLayers * layerThic    
101   auto worldSizeXY = 1.2 * calorSizeXY;           
102   auto worldSizeZ = 1.2 * calorThickness;         
103                                                   
104   // Get materials                                
105   auto defaultMaterial = G4Material::GetMateri    
106   auto absorberMaterial = G4Material::GetMater    
107   auto gapMaterial = G4Material::GetMaterial("    
108                                                   
109   if (!defaultMaterial || !absorberMaterial ||    
110     G4ExceptionDescription msg;                   
111     msg << "Cannot retrieve materials already     
112     G4Exception("DetectorConstruction::DefineV    
113   }                                               
114                                                   
115   //                                              
116   // World                                        
117   //                                              
118   auto worldS = new G4Box("World",  // its nam    
119                           worldSizeXY / 2, wor    
120                                                   
121   auto worldLV = new G4LogicalVolume(worldS,      
122                                      defaultMa    
123                                      "World");    
124                                                   
125   auto worldPV = new G4PVPlacement(nullptr,  /    
126                                    G4ThreeVect    
127                                    worldLV,  /    
128                                    "World",  /    
129                                    nullptr,  /    
130                                    false,  //     
131                                    0,  // copy    
132                                    fCheckOverl    
133                                                   
134   //                                              
135   // Calorimeter                                  
136   //                                              
137   auto calorimeterS = new G4Box("Calorimeter",    
138                                 calorSizeXY /     
139                                                   
140   auto calorLV = new G4LogicalVolume(calorimet    
141                                      defaultMa    
142                                      "Calorime    
143                                                   
144   new G4PVPlacement(nullptr,  // no rotation      
145                     G4ThreeVector(),  // at (0    
146                     calorLV,  // its logical v    
147                     "Calorimeter",  // its nam    
148                     worldLV,  // its mother  v    
149                     false,  // no boolean oper    
150                     0,  // copy number            
151                     fCheckOverlaps);  // check    
152                                                   
153   //                                              
154   // Layer                                        
155   //                                              
156   auto layerS = new G4Box("Layer",  // its nam    
157                           calorSizeXY / 2, cal    
158                                                   
159   auto layerLV = new G4LogicalVolume(layerS,      
160                                      defaultMa    
161                                      "Layer");    
162                                                   
163   new G4PVReplica("Layer",  // its name           
164                   layerLV,  // its logical vol    
165                   calorLV,  // its mother         
166                   kZAxis,  // axis of replicat    
167                   fNofLayers,  // number of re    
168                   layerThickness);  // witdth     
169                                                   
170   //                                              
171   // Absorber                                     
172   //                                              
173   auto absorberS = new G4Box("Abso",  // its n    
174                              calorSizeXY / 2,     
175                                                   
176   auto absorberLV = new G4LogicalVolume(absorb    
177                                         absorb    
178                                         "AbsoL    
179                                                   
180   new G4PVPlacement(nullptr,  // no rotation      
181                     G4ThreeVector(0., 0., -gap    
182                     absorberLV,  // its logica    
183                     "Abso",  // its name          
184                     layerLV,  // its mother  v    
185                     false,  // no boolean oper    
186                     0,  // copy number            
187                     fCheckOverlaps);  // check    
188                                                   
189   //                                              
190   // Gap                                          
191   //                                              
192   auto gapS = new G4Box("Gap",  // its name       
193                         calorSizeXY / 2, calor    
194                                                   
195   auto gapLV = new G4LogicalVolume(gapS,  // i    
196                                    gapMaterial    
197                                    "GapLV");      
198                                                   
199   new G4PVPlacement(nullptr,  // no rotation      
200                     G4ThreeVector(0., 0., abso    
201                     gapLV,  // its logical vol    
202                     "Gap",  // its name           
203                     layerLV,  // its mother  v    
204                     false,  // no boolean oper    
205                     0,  // copy number            
206                     fCheckOverlaps);  // check    
207                                                   
208   //                                              
209   // print parameters                             
210   //                                              
211   G4cout << G4endl << "-----------------------    
212          << "---> The calorimeter is " << fNof    
213          << "mm of " << absorberMaterial->GetN    
214          << gapMaterial->GetName() << " ] " <<    
215          << "---------------------------------    
216                                                   
217   //                                              
218   // Visualization attributes                     
219   //                                              
220   worldLV->SetVisAttributes(G4VisAttributes::G    
221   calorLV->SetVisAttributes(G4VisAttributes(G4    
222                                                   
223   //                                              
224   // Always return the physical World             
225   //                                              
226   return worldPV;                                 
227 }                                                 
228                                                   
229 //....oooOO0OOooo........oooOO0OOooo........oo    
230                                                   
231 void DetectorConstruction::ConstructSDandField    
232 {                                                 
233   // G4SDManager::GetSDMpointer()->SetVerboseL    
234                                                   
235   //                                              
236   // Sensitive detectors                          
237   //                                              
238   auto absoSD = new CalorimeterSD("AbsorberSD"    
239   G4SDManager::GetSDMpointer()->AddNewDetector    
240   SetSensitiveDetector("AbsoLV", absoSD);         
241                                                   
242   auto gapSD = new CalorimeterSD("GapSD", "Gap    
243   G4SDManager::GetSDMpointer()->AddNewDetector    
244   SetSensitiveDetector("GapLV", gapSD);           
245                                                   
246   //                                              
247   // Magnetic field                               
248   //                                              
249   // Create global magnetic field messenger.      
250   // Uniform magnetic field is then created au    
251   // the field value is not zero.                 
252   G4ThreeVector fieldValue;                       
253   fMagFieldMessenger = new G4GlobalMagFieldMes    
254   fMagFieldMessenger->SetVerboseLevel(1);         
255                                                   
256   // Register the field messenger for deleting    
257   G4AutoDelete::Register(fMagFieldMessenger);     
258 }                                                 
259                                                   
260 //....oooOO0OOooo........oooOO0OOooo........oo    
261                                                   
262 }  // namespace B4c                               
263