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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/advanced/nanobeam/src/DetectorConstruction.cc (Version 11.3.0) and /examples/advanced/nanobeam/src/DetectorConstruction.cc (Version 9.1.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 // Please cite the following paper if you use     
 27 // Nucl.Instrum.Meth.B260:20-27, 2007             
 28 //                                                
 29 // Based on purging magnet advanced example.      
 30 //                                                
 31                                                   
 32 #include "DetectorConstruction.hh"                
 33                                                   
 34 #include "G4PhysicalConstants.hh"                 
 35 #include "G4SystemOfUnits.hh"                     
 36 #include "G4NistManager.hh"                       
 37 #include "G4RunManager.hh"                        
 38                                                   
 39 // Field                                          
 40 #include "G4Mag_UsualEqRhs.hh"                    
 41 #include "G4TransportationManager.hh"             
 42 #include "G4ClassicalRK4.hh"                      
 43 #include "G4PropagatorInField.hh"                 
 44                                                   
 45 //....oooOO0OOooo........oooOO0OOooo........oo    
 46                                                   
 47 G4ThreadLocal TabulatedField3D* DetectorConstr    
 48                                                   
 49 //....oooOO0OOooo........oooOO0OOooo........oo    
 50                                                   
 51 DetectorConstruction::DetectorConstruction()      
 52 {                                                 
 53  fDetectorMessenger = new DetectorMessenger(th    
 54                                                   
 55  // Default values (square field, coef calcula    
 56                                                   
 57  fModel=1;                                        
 58  fG1=-11.964623;                                  
 59  fG2=16.494652;                                   
 60  fG3=9.866770;                                    
 61  fG4=-6.244493;                                   
 62  fCoef=0;                                         
 63  fProfile=1;                                      
 64  fGrid=0;                                         
 65                                                   
 66 }                                                 
 67                                                   
 68 //....oooOO0OOooo........oooOO0OOooo........oo    
 69                                                   
 70 DetectorConstruction::~DetectorConstruction()     
 71 { delete fDetectorMessenger;}                     
 72                                                   
 73 //....oooOO0OOooo........oooOO0OOooo........oo    
 74                                                   
 75 G4VPhysicalVolume* DetectorConstruction::Const    
 76                                                   
 77 {                                                 
 78   DefineMaterials();                              
 79   return ConstructVolumes();                      
 80 }                                                 
 81                                                   
 82 //....oooOO0OOooo........oooOO0OOooo........oo    
 83                                                   
 84 void DetectorConstruction::DefineMaterials()      
 85 {                                                 
 86   G4String name, symbol;                          
 87   G4double density;                               
 88                                                   
 89   G4double z, a;                                  
 90                                                   
 91   // Vacuum standard definition...                
 92   density = universe_mean_density;                
 93   G4Material* vacuum = new G4Material(name="Va    
 94   density);                                       
 95                                                   
 96   // NIST                                         
 97   G4NistManager *man=G4NistManager::Instance()    
 98   man->SetVerbose(1);                             
 99                                                   
100   //                                              
101                                                   
102   G4cout << G4endl << *(G4Material::GetMateria    
103                                                   
104   // Default materials in setup.                  
105   fDefaultMaterial = vacuum;                      
106   fGridMaterial = man->FindOrBuildMaterial("G4    
107 }                                                 
108                                                   
109 //....oooOO0OOooo........oooOO0OOooo........oo    
110                                                   
111 G4VPhysicalVolume* DetectorConstruction::Const    
112 {                                                 
113                                                   
114   fSolidWorld = new G4Box("World",        //it    
115          12*m/2,12*m/2,22*m/2);   //its size      
116                                                   
117                                                   
118   fLogicWorld = new G4LogicalVolume(fSolidWorl    
119             fDefaultMaterial, //its material      
120             "World");   //its name                
121                                                   
122   fPhysiWorld = new G4PVPlacement(0,      //no    
123            G4ThreeVector(), //at (0,0,0)          
124                                  "World",   //    
125                                  fLogicWorld,     
126                                  NULL,      //    
127                                  false,     //    
128                                  0);      //co    
129                                                   
130                                                   
131   // MAGNET VOLUME                                
132                                                   
133   fSolidVol = new G4Box("Vol",        //its na    
134          10*m/2,10*m/2,9.120*m/2);    //its si    
135                                                   
136                                                   
137   fLogicVol = new G4LogicalVolume(fSolidVol,      
138           fDefaultMaterial, //its material        
139           "Vol");   //its name                    
140                                                   
141   fPhysiVol = new G4PVPlacement(0,      //no r    
142            G4ThreeVector(0,0,-4310*mm), //at (    
143                                  "Vol",     //    
144                                  fLogicVol,       
145                                  fPhysiWorld,     
146                                  false,     //    
147                                  0);      //co    
148                                                   
149   // GRID                                         
150                                                   
151   if (fGrid==1)                                   
152   {                                               
153                                                   
154   G4cout << G4endl;                               
155                                                   
156   G4cout << " ********************** " << G4en    
157   G4cout << " **** GRID IN PLACE *** " << G4en    
158   G4cout << " ********************** " << G4en    
159                                                   
160   G4double x_grid=5.0*mm;                         
161   G4double y_grid=5.0*mm;                         
162   G4double grid_Zpos=(250+200)*mm;      // 250    
163                                                   
164   //G4double thickness_grid=10*micrometer;        
165   G4double thickness_grid=100*micrometer;         
166                                                   
167   G4double z_grid=thickness_grid/2.0;             
168                                                   
169   fSolidGridVol= new G4Box("GridVolume",x_grid    
170                                                   
171   fLogicGridVol = new G4LogicalVolume(fSolidGr    
172               fGridMaterial,            //its     
173               "GridVolume");    //its name        
174                                                   
175   fPhysiGridVol = new G4PVPlacement(0,            
176            G4ThreeVector(0,0,grid_Zpos),  // o    
177                                  fLogicGridVol    
178                                  "GridVolume",    
179                                  fLogicWorld,     
180                                  false,           
181                                  0);              
182                                                   
183   // Holes in grid                                
184                                                   
185   G4double holeSize= 9e-3*mm;                     
186   G4double pix_grid=1.3e-2*mm;                    
187   G4int    num_half_grid=100;                     
188                                                   
189   fSolidGridVol_Hole= new G4Box("GridHole",hol    
190                                                   
191   fLogicGridVol_Hole = new G4LogicalVolume(fSo    
192            fDefaultMaterial,                      
193            "GridHole");                           
194                                                   
195                                                   
196   for(int i=-num_half_grid;i<num_half_grid;i++    
197   {                                               
198       for (int j=-num_half_grid;j<num_half_gri    
199   {                                               
200                                                   
201         G4double  x0_grid,y0_grid,z0_grid;        
202         G4int  number_index_grid;                 
203                                                   
204         x0_grid=pix_grid*i;                       
205         y0_grid=pix_grid*j;                       
206         z0_grid=0.0*mm;                           
207                                                   
208     number_index_grid=(i+num_half_grid)*1000+(    
209                                                   
210       fPhysiGridVol_Hole  = new G4PVPlacement(    
211            G4ThreeVector(x0_grid,y0_grid,z0_gr    
212                                  fLogicGridVol    
213                  "GridHole",        //its name    
214                                  fLogicGridVol    
215                                  false,           
216                                  number_index_    
217   }                                               
218   }                                               
219                                                   
220   // Grid imaging plane                           
221                                                   
222   G4double ContVolSizeXY = 1*m;                   
223   G4double ImPlaneWidth = 0.001*mm;               
224                                                   
225   fSolidControlVol_GridShadow =                   
226     new G4Box                                     
227     ("ControlVol_GridShadow", ContVolSizeXY/2,    
228                                                   
229   fLogicControlVol_GridShadow =                   
230     new G4LogicalVolume                           
231     (fSolidControlVol_GridShadow, fDefaultMate    
232                                                   
233   fPhysiControlVol_GridShadow =                   
234     new G4PVPlacement                             
235     ( 0, G4ThreeVector(0,0,(250+300)*mm), fLog    
236       fLogicWorld, false, 0);                     
237                                                   
238                                                   
239   } // end GRID                                   
240                                                   
241   // STEP MINIMUM SIZE                            
242   fLogicVol->SetUserLimits(new G4UserLimits(1*    
243                                                   
244   return fPhysiWorld;                             
245 }                                                 
246                                                   
247 //....oooOO0OOooo........oooOO0OOooo........oo    
248                                                   
249 void DetectorConstruction::SetG1(G4float value    
250 {                                                 
251   fG1 = value;                                    
252   G4RunManager::GetRunManager()->ReinitializeG    
253 }                                                 
254                                                   
255 //....oooOO0OOooo........oooOO0OOooo........oo    
256                                                   
257 void DetectorConstruction::SetG2(G4float value    
258 {                                                 
259   fG2 = value;                                    
260   G4RunManager::GetRunManager()->ReinitializeG    
261 }                                                 
262                                                   
263 //....oooOO0OOooo........oooOO0OOooo........oo    
264                                                   
265 void DetectorConstruction::SetG3(G4float value    
266 {                                                 
267   fG3 = value;                                    
268   G4RunManager::GetRunManager()->ReinitializeG    
269 }                                                 
270                                                   
271 //....oooOO0OOooo........oooOO0OOooo........oo    
272                                                   
273 void DetectorConstruction::SetG4(G4float value    
274 {                                                 
275   fG4 = value;                                    
276   G4RunManager::GetRunManager()->ReinitializeG    
277 }                                                 
278                                                   
279 //....oooOO0OOooo........oooOO0OOooo........oo    
280                                                   
281 void DetectorConstruction::SetModel(G4int mode    
282 {                                                 
283   if (modelChoice==1) fModel=1;                   
284   if (modelChoice==2) fModel=2;                   
285   if (modelChoice==3) fModel=3;                   
286   G4RunManager::GetRunManager()->ReinitializeG    
287 }                                                 
288                                                   
289 //....oooOO0OOooo........oooOO0OOooo........oo    
290                                                   
291 void DetectorConstruction::SetCoef(G4int val)     
292 {                                                 
293   fCoef=val;                                      
294   G4RunManager::GetRunManager()->ReinitializeG    
295 }                                                 
296                                                   
297 //....oooOO0OOooo........oooOO0OOooo........oo    
298                                                   
299 G4int DetectorConstruction::GetCoef()             
300 {                                                 
301   return fCoef;                                   
302 }                                                 
303                                                   
304 //....oooOO0OOooo........oooOO0OOooo........oo    
305                                                   
306 void DetectorConstruction::SetProfile(G4int my    
307 {                                                 
308   fProfile=myProfile;                             
309   G4RunManager::GetRunManager()->ReinitializeG    
310 }                                                 
311                                                   
312 //....oooOO0OOooo........oooOO0OOooo........oo    
313                                                   
314 void DetectorConstruction::SetGrid(G4int myGri    
315 {                                                 
316   fGrid=myGrid;                                   
317   G4RunManager::GetRunManager()->ReinitializeG    
318 }                                                 
319                                                   
320 //....oooOO0OOooo........oooOO0OOooo........oo    
321                                                   
322 void DetectorConstruction::ConstructSDandField    
323 {                                                 
324       fField = new TabulatedField3D(fG1, fG2,     
325                                                   
326       //This is thread-local                      
327       G4FieldManager* fFieldMgr =                 
328   G4TransportationManager::GetTransportationMa    
329                                                   
330       G4Mag_UsualEqRhs* fEquation = new G4Mag_    
331                                                   
332       G4ClassicalRK4* fStepper = new G4Classic    
333                                                   
334       G4ChordFinder* fChordFinder = new G4Chor    
335                                                   
336       fFieldMgr->SetChordFinder(fChordFinder);    
337       fFieldMgr->SetDetectorField(fField);        
338                                                   
339       // SI: 01-07-2018 : following settings w    
340       //  instead of 1e-9*m, but they now indu    
341       //  *** G4Exception : GeomNav1002           
342       //  issued by : G4PropagatorInField::Com    
343                                                   
344       fFieldMgr->GetChordFinder()->SetDeltaCho    
345       fFieldMgr->SetDeltaIntersection(1e-7*m);    
346       fFieldMgr->SetDeltaOneStep(1e-7*m);         
347                                                   
348       //                                          
349                                                   
350       // To avoid G4MagIntegratorDriver::OneGo    
351                                                   
352       if (fCoef==1)                               
353       {                                           
354         G4PropagatorInField* fPropInField =       
355           G4TransportationManager::GetTranspor    
356         fPropInField->SetMinimumEpsilonStep(1e    
357         fPropInField->SetMaximumEpsilonStep(1e    
358                                                   
359       }                                           
360       else                                        
361       {                                           
362         G4PropagatorInField* fPropInField =       
363           G4TransportationManager::GetTranspor    
364         fPropInField->SetMinimumEpsilonStep(1e    
365         fPropInField->SetMaximumEpsilonStep(1e    
366       }                                           
367                                                   
368 }                                                 
369                                                   
370