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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/hadronic/Hadr07/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/hadronic/Hadr07/src/DetectorConstruction.cc (Version 7.0.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 DetectorConstruction.cc                 
 27 /// \brief Implementation of the DetectorConst    
 28 //                                                
 29 //                                                
 30 //....oooOO0OOooo........oooOO0OOooo........oo    
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32                                                   
 33 #include "DetectorConstruction.hh"                
 34                                                   
 35 #include "DetectorMessenger.hh"                   
 36                                                   
 37 #include "G4AutoDelete.hh"                        
 38 #include "G4Box.hh"                               
 39 #include "G4GeometryManager.hh"                   
 40 #include "G4GlobalMagFieldMessenger.hh"           
 41 #include "G4LogicalVolume.hh"                     
 42 #include "G4LogicalVolumeStore.hh"                
 43 #include "G4Material.hh"                          
 44 #include "G4NistManager.hh"                       
 45 #include "G4PVPlacement.hh"                       
 46 #include "G4PVReplica.hh"                         
 47 #include "G4PhysicalConstants.hh"                 
 48 #include "G4PhysicalVolumeStore.hh"               
 49 #include "G4RunManager.hh"                        
 50 #include "G4SolidStore.hh"                        
 51 #include "G4SystemOfUnits.hh"                     
 52 #include "G4UImanager.hh"                         
 53 #include "G4UniformMagField.hh"                   
 54 #include "G4UnitsTable.hh"                        
 55                                                   
 56 #include <iomanip>                                
 57                                                   
 58 //....oooOO0OOooo........oooOO0OOooo........oo    
 59                                                   
 60 DetectorConstruction::DetectorConstruction()      
 61 {                                                 
 62   // default parameter values of the absorbers    
 63   fNbOfAbsor = 1;                                 
 64   fAbsorThickness[0] = 0 * mm;  // dummy, for     
 65   fAbsorThickness[1] = 1 * mm;                    
 66   fAbsorSizeYZ = 1 * mm;                          
 67                                                   
 68   ComputeParameters();                            
 69                                                   
 70   // materials                                    
 71   DefineMaterials();                              
 72   SetAbsorMaterial(1, "G4_Si");                   
 73                                                   
 74   // create commands for interactive definitio    
 75   fDetectorMessenger = new DetectorMessenger(t    
 76 }                                                 
 77                                                   
 78 //....oooOO0OOooo........oooOO0OOooo........oo    
 79                                                   
 80 DetectorConstruction::~DetectorConstruction()     
 81 {                                                 
 82   delete fDetectorMessenger;                      
 83 }                                                 
 84                                                   
 85 //....oooOO0OOooo........oooOO0OOooo........oo    
 86                                                   
 87 G4VPhysicalVolume* DetectorConstruction::Const    
 88 {                                                 
 89   return ConstructVolumes();                      
 90 }                                                 
 91                                                   
 92 //....oooOO0OOooo........oooOO0OOooo........oo    
 93                                                   
 94 void DetectorConstruction::DefineMaterials()      
 95 {                                                 
 96   G4NistManager* man = G4NistManager::Instance    
 97                                                   
 98   man->FindOrBuildMaterial("G4_AIR");             
 99                                                   
100   G4Element* H = man->FindOrBuildElement("H");    
101   G4Element* O = man->FindOrBuildElement("O");    
102                                                   
103   G4Material* H2O = new G4Material("Water", 1.    
104   H2O->AddElement(H, 2);                          
105   H2O->AddElement(O, 1);                          
106   H2O->GetIonisation()->SetMeanExcitationEnerg    
107                                                   
108   G4Element* Hf = man->FindOrBuildElement("Hf"    
109                                                   
110   G4Material* HfO2 = new G4Material("HfO2", 9.    
111   HfO2->AddElement(Hf, 1);                        
112   HfO2->AddElement(O, 2);                         
113                                                   
114   // example of vacuum                            
115   G4double density = universe_mean_density;  /    
116   G4double pressure = 3.e-18 * pascal;            
117   G4double temperature = 2.73 * kelvin;           
118   G4Material* Galactic =                          
119     new G4Material("Galactic", 1., 1.008 * g /    
120                                                   
121   fDefaultMaterial = Galactic;                    
122                                                   
123   //  G4cout << *(G4Material::GetMaterialTable    
124 }                                                 
125                                                   
126 //....oooOO0OOooo........oooOO0OOooo........oo    
127                                                   
128 G4Material* DetectorConstruction::MaterialWith    
129                                                   
130 {                                                 
131   // define a material from an isotope            
132   //                                              
133   G4int ncomponents;                              
134   G4double abundance, massfraction;               
135                                                   
136   G4Isotope* isotope = new G4Isotope(symbol, Z    
137                                                   
138   G4Element* element = new G4Element(name, sym    
139   element->AddIsotope(isotope, abundance = 100    
140                                                   
141   G4Material* material = new G4Material(name,     
142   material->AddElement(element, massfraction =    
143                                                   
144   return material;                                
145 }                                                 
146                                                   
147 //....oooOO0OOooo........oooOO0OOooo........oo    
148                                                   
149 void DetectorConstruction::ComputeParameters()    
150 {                                                 
151   // Compute total thickness of absorbers         
152   fAbsorSizeX = 0.;                               
153   for (G4int iAbs = 1; iAbs <= fNbOfAbsor; iAb    
154     fAbsorSizeX += fAbsorThickness[iAbs];         
155   }                                               
156   fWorldSizeX = 1.2 * fAbsorSizeX;                
157   fWorldSizeYZ = 1.2 * fAbsorSizeYZ;              
158 }                                                 
159                                                   
160 //....oooOO0OOooo........oooOO0OOooo........oo    
161                                                   
162 G4VPhysicalVolume* DetectorConstruction::Const    
163 {                                                 
164   // complete the Calor parameters definition     
165   ComputeParameters();                            
166                                                   
167   // Cleanup old geometry                         
168   G4GeometryManager::GetInstance()->OpenGeomet    
169   G4PhysicalVolumeStore::GetInstance()->Clean(    
170   G4LogicalVolumeStore::GetInstance()->Clean()    
171   G4SolidStore::GetInstance()->Clean();           
172                                                   
173   //                                              
174   // World                                        
175   //                                              
176   G4Box* solidWorld = new G4Box("World",  // n    
177                                 fWorldSizeX /     
178                                                   
179   G4LogicalVolume* logicWorld = new G4LogicalV    
180                                                   
181                                                   
182                                                   
183   fPhysiWorld = new G4PVPlacement(0,  // no ro    
184                                   G4ThreeVecto    
185                                   logicWorld,     
186                                   "World",  //    
187                                   0,  // mothe    
188                                   false,  // n    
189                                   0);  // copy    
190                                                   
191   //                                              
192   // Absorbers                                    
193   //                                              
194   fXfront[0] = -0.5 * fAbsorSizeX;                
195   //                                              
196   for (G4int k = 1; k <= fNbOfAbsor; k++) {       
197     G4Material* material = fAbsorMaterial[k];     
198     G4String matname = material->GetName();       
199                                                   
200     G4Box* solidAbsor =                           
201       new G4Box(matname, fAbsorThickness[k] /     
202                                                   
203     G4LogicalVolume* logicAbsor = new G4Logica    
204                                                   
205                                                   
206                                                   
207     fXfront[k] = fXfront[k - 1] + fAbsorThickn    
208     G4double xcenter = fXfront[k] + 0.5 * fAbs    
209     G4ThreeVector position = G4ThreeVector(xce    
210                                                   
211     new G4PVPlacement(0,  // no rotation          
212                       position,  // position      
213                       logicAbsor,  // logical     
214                       matname,  // name           
215                       logicWorld,  // mother      
216                       false,  // no boulean op    
217                       k);  // copy number         
218   }                                               
219                                                   
220   PrintParameters();                              
221                                                   
222   // always return the physical World             
223   //                                              
224   return fPhysiWorld;                             
225 }                                                 
226                                                   
227 //....oooOO0OOooo........oooOO0OOooo........oo    
228                                                   
229 void DetectorConstruction::PrintParameters()      
230 {                                                 
231   G4cout << "\n-------------------------------    
232          << "\n ---> The Absorber is " << fNbO    
233   for (G4int i = 1; i <= fNbOfAbsor; i++) {       
234     G4cout << "\n \t" << std::setw(12) << fAbs    
235            << G4BestUnit(fAbsorThickness[i], "    
236   }                                               
237   G4cout << "\n-------------------------------    
238 }                                                 
239                                                   
240 //....oooOO0OOooo........oooOO0OOooo........oo    
241                                                   
242 void DetectorConstruction::SetNbOfAbsor(G4int     
243 {                                                 
244   // set the number of Absorbers                  
245   //                                              
246   if (ival < 1 || ival > (kMaxAbsor - 1)) {       
247     G4cout << "\n ---> warning from SetfNbOfAb    
248            << kMaxAbsor - 1 << ". Command refu    
249     return;                                       
250   }                                               
251   fNbOfAbsor = ival;                              
252   G4RunManager::GetRunManager()->ReinitializeG    
253 }                                                 
254                                                   
255 //....oooOO0OOooo........oooOO0OOooo........oo    
256                                                   
257 void DetectorConstruction::SetAbsorMaterial(G4    
258 {                                                 
259   // search the material by its name              
260   //                                              
261   if (iabs > fNbOfAbsor || iabs <= 0) {           
262     G4cout << "\n --->warning from SetfAbsorMa    
263            << " out of range. Command refused"    
264     return;                                       
265   }                                               
266                                                   
267   G4Material* pttoMaterial = G4NistManager::In    
268   if (pttoMaterial) {                             
269     fAbsorMaterial[iabs] = pttoMaterial;          
270     G4RunManager::GetRunManager()->PhysicsHasB    
271   }                                               
272 }                                                 
273                                                   
274 //....oooOO0OOooo........oooOO0OOooo........oo    
275                                                   
276 void DetectorConstruction::SetAbsorThickness(G    
277 {                                                 
278   // change Absorber thickness                    
279   //                                              
280   if (iabs > fNbOfAbsor || iabs <= 0) {           
281     G4cout << "\n --->warning from SetfAbsorTh    
282            << " out of range. Command refused"    
283     return;                                       
284   }                                               
285   if (val <= DBL_MIN) {                           
286     G4cout << "\n --->warning from SetfAbsorTh    
287            << " out of range. Command refused"    
288     return;                                       
289   }                                               
290   fAbsorThickness[iabs] = val;                    
291   G4RunManager::GetRunManager()->ReinitializeG    
292 }                                                 
293                                                   
294 //....oooOO0OOooo........oooOO0OOooo........oo    
295                                                   
296 void DetectorConstruction::SetAbsorSizeYZ(G4do    
297 {                                                 
298   // change the transverse size                   
299   //                                              
300   if (val <= DBL_MIN) {                           
301     G4cout << "\n --->warning from SetfAbsorSi    
302            << " out of range. Command refused"    
303     return;                                       
304   }                                               
305   fAbsorSizeYZ = val;                             
306   G4RunManager::GetRunManager()->ReinitializeG    
307 }                                                 
308                                                   
309 //....oooOO0OOooo........oooOO0OOooo........oo    
310                                                   
311 void DetectorConstruction::ConstructSDandField    
312 {                                                 
313   if (fFieldMessenger.Get() == 0) {               
314     // Create global magnetic field messenger.    
315     // Uniform magnetic field is then created     
316     // the field value is not zero.               
317     G4ThreeVector fieldValue = G4ThreeVector()    
318     G4GlobalMagFieldMessenger* msg = new G4Glo    
319     // msg->SetVerboseLevel(1);                   
320     G4AutoDelete::Register(msg);                  
321     fFieldMessenger.Put(msg);                     
322   }                                               
323 }                                                 
324                                                   
325 //....oooOO0OOooo........oooOO0OOooo........oo    
326