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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/B01/src/B01DetectorConstruction.cc (Version 11.3.0) and /examples/extended/biasing/B01/src/B01DetectorConstruction.cc (Version 7.0)


  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 biasing/B01/src/B01DetectorConstruct    
 27 /// \brief Implementation of the B01DetectorCo    
 28 //                                                
 29 //                                                
 30 //                                                
 31                                                   
 32 #include "B01DetectorConstruction.hh"             
 33                                                   
 34 #include "G4Box.hh"                               
 35 #include "G4Colour.hh"                            
 36 #include "G4LogicalVolume.hh"                     
 37 #include "G4Material.hh"                          
 38 #include "G4PVPlacement.hh"                       
 39 #include "G4PhysicalConstants.hh"                 
 40 #include "G4SystemOfUnits.hh"                     
 41 #include "G4ThreeVector.hh"                       
 42 #include "G4Tubs.hh"                              
 43 #include "G4Types.hh"                             
 44 #include "G4VisAttributes.hh"                     
 45 #include "globals.hh"                             
 46                                                   
 47 #include <set>                                    
 48 #include <sstream>                                
 49                                                   
 50 // For Primitive Scorers                          
 51 #include "G4MultiFunctionalDetector.hh"           
 52 #include "G4PSNofCollision.hh"                    
 53 #include "G4PSPopulation.hh"                      
 54 #include "G4PSTrackCounter.hh"                    
 55 #include "G4PSTrackLength.hh"                     
 56 #include "G4SDManager.hh"                         
 57 #include "G4SDParticleFilter.hh"                  
 58                                                   
 59 // for importance biasing                         
 60 #include "G4IStore.hh"                            
 61                                                   
 62 // for weight window technique                    
 63 #include "G4WeightWindowStore.hh"                 
 64                                                   
 65 //....oooOO0OOooo........oooOO0OOooo........oo    
 66                                                   
 67 B01DetectorConstruction::B01DetectorConstructi    
 68   : G4VUserDetectorConstruction(), fLogicalVol    
 69 {                                                 
 70   ;                                               
 71 }                                                 
 72                                                   
 73 //....oooOO0OOooo........oooOO0OOooo........oo    
 74                                                   
 75 B01DetectorConstruction::~B01DetectorConstruct    
 76 {                                                 
 77   fLogicalVolumeVector.clear();                   
 78   fPhysicalVolumeVector.clear();                  
 79 }                                                 
 80                                                   
 81 //....oooOO0OOooo........oooOO0OOooo........oo    
 82                                                   
 83 G4VPhysicalVolume* B01DetectorConstruction::Co    
 84 {                                                 
 85   G4double pos_x;                                 
 86   G4double pos_y;                                 
 87   G4double pos_z;                                 
 88                                                   
 89   G4double density, pressure, temperature;        
 90   G4double A;                                     
 91   G4int Z;                                        
 92                                                   
 93   G4String name, symbol;                          
 94   G4double z;                                     
 95   G4double fractionmass;                          
 96                                                   
 97   A = 1.01 * g / mole;                            
 98   G4Element* elH = new G4Element(name = "Hydro    
 99                                                   
100   A = 12.01 * g / mole;                           
101   G4Element* elC = new G4Element(name = "Carbo    
102                                                   
103   A = 16.00 * g / mole;                           
104   G4Element* elO = new G4Element(name = "Oxyge    
105                                                   
106   A = 22.99 * g / mole;                           
107   G4Element* elNa = new G4Element(name = "Natr    
108                                                   
109   A = 200.59 * g / mole;                          
110   G4Element* elHg = new G4Element(name = "Hg",    
111                                                   
112   A = 26.98 * g / mole;                           
113   G4Element* elAl = new G4Element(name = "Alum    
114                                                   
115   A = 28.09 * g / mole;                           
116   G4Element* elSi = new G4Element(name = "Sili    
117                                                   
118   A = 39.1 * g / mole;                            
119   G4Element* elK = new G4Element(name = "K", s    
120                                                   
121   A = 69.72 * g / mole;                           
122   G4Element* elCa = new G4Element(name = "Calz    
123                                                   
124   A = 55.85 * g / mole;                           
125   G4Element* elFe = new G4Element(name = "Iron    
126                                                   
127   density = universe_mean_density;  // from Ph    
128   pressure = 3.e-18 * pascal;                     
129   temperature = 2.73 * kelvin;                    
130   G4Material* Galactic = new G4Material(name =    
131                                         kState    
132                                                   
133   density = 2.03 * g / cm3;                       
134   G4Material* Concrete = new G4Material("Concr    
135   Concrete->AddElement(elH, fractionmass = 0.0    
136   Concrete->AddElement(elO, fractionmass = 0.5    
137   Concrete->AddElement(elNa, fractionmass = 0.    
138   Concrete->AddElement(elHg, fractionmass = 0.    
139   Concrete->AddElement(elAl, fractionmass = 0.    
140   Concrete->AddElement(elSi, fractionmass = 0.    
141   Concrete->AddElement(elK, fractionmass = 0.0    
142   Concrete->AddElement(elCa, fractionmass = 0.    
143   Concrete->AddElement(elFe, fractionmass = 0.    
144   Concrete->AddElement(elC, fractionmass = 0.0    
145                                                   
146   /////////////////////////////                   
147   // world cylinder volume                        
148   ////////////////////////////                    
149                                                   
150   // world solid                                  
151                                                   
152   G4double innerRadiusCylinder = 0 * cm;          
153   G4double outerRadiusCylinder = 100 * cm;        
154   G4double heightCylinder = 100 * cm;             
155   G4double startAngleCylinder = 0 * deg;          
156   G4double spanningAngleCylinder = 360 * deg;     
157                                                   
158   G4Tubs* worldCylinder = new G4Tubs("worldCyl    
159                                      heightCyl    
160                                                   
161   // logical world                                
162                                                   
163   G4LogicalVolume* worldCylinder_log =            
164     new G4LogicalVolume(worldCylinder, Galacti    
165   fLogicalVolumeVector.push_back(worldCylinder    
166                                                   
167   name = "shieldWorld";                           
168   fWorldVolume = new G4PVPlacement(0, G4ThreeV    
169                                                   
170   fPhysicalVolumeVector.push_back(fWorldVolume    
171                                                   
172   // creating 18 slabs of 10 cm thick concrete    
173                                                   
174   G4double innerRadiusShield = 0 * cm;            
175   G4double outerRadiusShield = 100 * cm;          
176   G4double heightShield = 5 * cm;                 
177   G4double startAngleShield = 0 * deg;            
178   G4double spanningAngleShield = 360 * deg;       
179                                                   
180   G4Tubs* aShield = new G4Tubs("aShield", inne    
181                                startAngleShiel    
182                                                   
183   // logical shield                               
184                                                   
185   G4LogicalVolume* aShield_log = new G4Logical    
186   fLogicalVolumeVector.push_back(aShield_log);    
187                                                   
188   G4VisAttributes* pShieldVis = new G4VisAttri    
189   pShieldVis->SetForceSolid(true);                
190   aShield_log->SetVisAttributes(pShieldVis);      
191                                                   
192   // physical shields                             
193                                                   
194   G4int i;                                        
195   G4double startz = -85 * cm;                     
196   for (i = 1; i <= 18; i++) {                     
197     name = GetCellName(i);                        
198     pos_x = 0 * cm;                               
199     pos_y = 0 * cm;                               
200     pos_z = startz + (i - 1) * (2 * heightShie    
201     G4VPhysicalVolume* pvol = new G4PVPlacemen    
202                                                   
203     fPhysicalVolumeVector.push_back(pvol);        
204   }                                               
205                                                   
206   // filling the rest of the world volume behi    
207   // another slab which should get the same im    
208   // or lower weight bound as the last slab       
209   //                                              
210   innerRadiusShield = 0 * cm;                     
211   outerRadiusShield = 100 * cm;                   
212   heightShield = 5 * cm;                          
213   startAngleShield = 0 * deg;                     
214   spanningAngleShield = 360 * deg;                
215                                                   
216   G4Tubs* aRest = new G4Tubs("Rest", innerRadi    
217                              startAngleShield,    
218                                                   
219   G4LogicalVolume* aRest_log = new G4LogicalVo    
220   fLogicalVolumeVector.push_back(aRest_log);      
221   name = "rest";                                  
222                                                   
223   pos_x = 0 * cm;                                 
224   pos_y = 0 * cm;                                 
225   pos_z = 95 * cm;                                
226   G4VPhysicalVolume* pvol_rest = new G4PVPlace    
227                                                   
228                                                   
229                                                   
230   fPhysicalVolumeVector.push_back(pvol_rest);     
231                                                   
232   SetSensitive();                                 
233   return fWorldVolume;                            
234 }                                                 
235                                                   
236 //....oooOO0OOooo........oooOO0OOooo........oo    
237                                                   
238 G4VIStore* B01DetectorConstruction::CreateImpo    
239 {                                                 
240   G4cout << " B01DetectorConstruction:: Creati    
241   if (!fPhysicalVolumeVector.size()) {            
242     G4Exception("B01DetectorConstruction::Crea    
243                 RunMustBeAborted, "no physical    
244   }                                               
245                                                   
246   fWorldVolume = fPhysicalVolumeVector[0];        
247                                                   
248   // creating and filling the importance store    
249                                                   
250   G4IStore* istore = G4IStore::GetInstance();     
251                                                   
252   G4int n = 0;                                    
253   G4double imp = 1;                               
254   istore->AddImportanceGeometryCell(1, *fWorld    
255   for (std::vector<G4VPhysicalVolume*>::iterat    
256        it != fPhysicalVolumeVector.end() - 1;     
257   {                                               
258     if (*it != fWorldVolume) {                    
259       imp = std::pow(2., n++);                    
260       G4cout << "Going to assign importance: "    
261              << G4endl;                           
262       istore->AddImportanceGeometryCell(imp, *    
263     }                                             
264   }                                               
265                                                   
266   // the remaining part pf the geometry (rest)    
267   // importance as the last conrete cell          
268   //                                              
269   istore->AddImportanceGeometryCell(imp, *(fPh    
270                                     ++n);         
271                                                   
272   return istore;                                  
273 }                                                 
274                                                   
275 //....oooOO0OOooo........oooOO0OOooo........oo    
276                                                   
277 G4VWeightWindowStore* B01DetectorConstruction:    
278 {                                                 
279   if (!fPhysicalVolumeVector.size()) {            
280     G4Exception("B01DetectorConstruction::Crea    
281                 RunMustBeAborted, "no physical    
282   }                                               
283                                                   
284   fWorldVolume = fPhysicalVolumeVector[0];        
285                                                   
286   // creating and filling the weight window st    
287                                                   
288   G4WeightWindowStore* wwstore = G4WeightWindo    
289                                                   
290   // create one energy region covering the ene    
291   //                                              
292   std::set<G4double, std::less<G4double>> enBo    
293   enBounds.insert(1 * GeV);                       
294   wwstore->SetGeneralUpperEnergyBounds(enBound    
295                                                   
296   G4int n = 0;                                    
297   G4double lowerWeight = 1;                       
298   std::vector<G4double> lowerWeights;             
299                                                   
300   lowerWeights.push_back(1);                      
301   G4GeometryCell gWorldCell(*fWorldVolume, 0);    
302   wwstore->AddLowerWeights(gWorldCell, lowerWe    
303                                                   
304   for (std::vector<G4VPhysicalVolume*>::iterat    
305        it != fPhysicalVolumeVector.end() - 1;     
306   {                                               
307     if (*it != fWorldVolume) {                    
308       lowerWeight = 1. / std::pow(2., n++);       
309       G4cout << "Going to assign lower weight:    
310              << ", to volume: " << (*it)->GetN    
311       G4GeometryCell gCell(*(*it), n);            
312       lowerWeights.clear();                       
313       lowerWeights.push_back(lowerWeight);        
314       wwstore->AddLowerWeights(gCell, lowerWei    
315     }                                             
316   }                                               
317                                                   
318   // the remaining part pf the geometry (rest)    
319   // lower weight bound  as the last conrete c    
320   //                                              
321   G4GeometryCell gRestCell(*(fPhysicalVolumeVe    
322   wwstore->AddLowerWeights(gRestCell, lowerWei    
323                                                   
324   return wwstore;                                 
325 }                                                 
326                                                   
327 //....oooOO0OOooo........oooOO0OOooo........oo    
328                                                   
329 G4String B01DetectorConstruction::GetCellName(    
330 {                                                 
331   std::ostringstream os;                          
332   os << "cell_";                                  
333   if (i < 10) {                                   
334     os << "0";                                    
335   }                                               
336   os << i;                                        
337   G4String name = os.str();                       
338   return name;                                    
339 }                                                 
340                                                   
341 G4VPhysicalVolume* B01DetectorConstruction::Ge    
342 {                                                 
343   return fWorldVolume;                            
344 }                                                 
345                                                   
346 //....oooOO0OOooo........oooOO0OOooo........oo    
347                                                   
348 void B01DetectorConstruction::SetSensitive()      
349 {                                                 
350   //  ----------------------------------------    
351   //   The collection names of defined Primiti    
352   //   0       ConcreteSD/Collisions              
353   //   1       ConcreteSD/CollWeight              
354   //   2       ConcreteSD/Population              
355   //   3       ConcreteSD/TrackEnter              
356   //   4       ConcreteSD/SL                      
357   //   5       ConcreteSD/SLW                     
358   //   6       ConcreteSD/SLWE                    
359   //   7       ConcreteSD/SLW_V                   
360   //   8       ConcreteSD/SLWE_V                  
361   //  ----------------------------------------    
362                                                   
363   // moved to ConstructSDandField() for MT com    
364 }                                                 
365                                                   
366 //....oooOO0OOooo........oooOO0OOooo........oo    
367                                                   
368 void B01DetectorConstruction::ConstructSDandFi    
369 {                                                 
370   //  Sensitive Detector Manager.                 
371   G4SDManager* SDman = G4SDManager::GetSDMpoin    
372   // Sensitive Detector Name                      
373   G4String concreteSDname = "ConcreteSD";         
374                                                   
375   //------------------------                      
376   // MultiFunctionalDetector                      
377   //------------------------                      
378   //                                              
379   // Define MultiFunctionalDetector with name.    
380   G4MultiFunctionalDetector* MFDet = new G4Mul    
381   SDman->AddNewDetector(MFDet);  // Register S    
382                                                   
383   G4String fltName, particleName;                 
384   G4SDParticleFilter* neutronFilter =             
385     new G4SDParticleFilter(fltName = "neutronF    
386                                                   
387   MFDet->SetFilter(neutronFilter);                
388                                                   
389   for (std::vector<G4LogicalVolume*>::iterator    
390        it != fLogicalVolumeVector.end(); it++)    
391   {                                               
392     //      (*it)->SetSensitiveDetector(MFDet)    
393     SetSensitiveDetector((*it)->GetName(), MFD    
394   }                                               
395                                                   
396   G4String psName;                                
397   G4PSNofCollision* scorer0 = new G4PSNofColli    
398   MFDet->RegisterPrimitive(scorer0);              
399                                                   
400   G4PSNofCollision* scorer1 = new G4PSNofColli    
401   scorer1->Weighted(true);                        
402   MFDet->RegisterPrimitive(scorer1);              
403                                                   
404   G4PSPopulation* scorer2 = new G4PSPopulation    
405   MFDet->RegisterPrimitive(scorer2);              
406                                                   
407   G4PSTrackCounter* scorer3 = new G4PSTrackCou    
408   MFDet->RegisterPrimitive(scorer3);              
409                                                   
410   G4PSTrackLength* scorer4 = new G4PSTrackLeng    
411   MFDet->RegisterPrimitive(scorer4);              
412                                                   
413   G4PSTrackLength* scorer5 = new G4PSTrackLeng    
414   scorer5->Weighted(true);                        
415   MFDet->RegisterPrimitive(scorer5);              
416                                                   
417   G4PSTrackLength* scorer6 = new G4PSTrackLeng    
418   scorer6->Weighted(true);                        
419   scorer6->MultiplyKineticEnergy(true);           
420   MFDet->RegisterPrimitive(scorer6);              
421                                                   
422   G4PSTrackLength* scorer7 = new G4PSTrackLeng    
423   scorer7->Weighted(true);                        
424   scorer7->DivideByVelocity(true);                
425   MFDet->RegisterPrimitive(scorer7);              
426                                                   
427   G4PSTrackLength* scorer8 = new G4PSTrackLeng    
428   scorer8->Weighted(true);                        
429   scorer8->MultiplyKineticEnergy(true);           
430   scorer8->DivideByVelocity(true);                
431   MFDet->RegisterPrimitive(scorer8);              
432 }                                                 
433                                                   
434 //....oooOO0OOooo........oooOO0OOooo........oo    
435