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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/B3/B3a/src/DetectorConstruction.cc (Version 11.3.0) and /examples/basic/B3/B3a/src/DetectorConstruction.cc (Version 5.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 //                                                
 27 /// \file B3/B3a/src/DetectorConstruction.cc      
 28 /// \brief Implementation of the B3::DetectorC    
 29                                                   
 30 #include "DetectorConstruction.hh"                
 31                                                   
 32 #include "G4Box.hh"                               
 33 #include "G4LogicalVolume.hh"                     
 34 #include "G4MultiFunctionalDetector.hh"           
 35 #include "G4NistManager.hh"                       
 36 #include "G4PSDoseDeposit.hh"                     
 37 #include "G4PSEnergyDeposit.hh"                   
 38 #include "G4PVPlacement.hh"                       
 39 #include "G4PhysicalConstants.hh"                 
 40 #include "G4RotationMatrix.hh"                    
 41 #include "G4SDManager.hh"                         
 42 #include "G4SystemOfUnits.hh"                     
 43 #include "G4Transform3D.hh"                       
 44 #include "G4Tubs.hh"                              
 45 #include "G4VisAttributes.hh"                     
 46                                                   
 47 namespace B3                                      
 48 {                                                 
 49                                                   
 50 //....oooOO0OOooo........oooOO0OOooo........oo    
 51                                                   
 52 DetectorConstruction::DetectorConstruction()      
 53 {                                                 
 54   DefineMaterials();                              
 55 }                                                 
 56                                                   
 57 //....oooOO0OOooo........oooOO0OOooo........oo    
 58                                                   
 59 void DetectorConstruction::DefineMaterials()      
 60 {                                                 
 61   G4NistManager* man = G4NistManager::Instance    
 62                                                   
 63   G4bool isotopes = false;                        
 64                                                   
 65   G4Element* O = man->FindOrBuildElement("O",     
 66   G4Element* Si = man->FindOrBuildElement("Si"    
 67   G4Element* Lu = man->FindOrBuildElement("Lu"    
 68                                                   
 69   auto LSO = new G4Material("Lu2SiO5", 7.4 * g    
 70   LSO->AddElement(Lu, 2);                         
 71   LSO->AddElement(Si, 1);                         
 72   LSO->AddElement(O, 5);                          
 73 }                                                 
 74                                                   
 75 //....oooOO0OOooo........oooOO0OOooo........oo    
 76                                                   
 77 G4VPhysicalVolume* DetectorConstruction::Const    
 78 {                                                 
 79   // Gamma detector Parameters                    
 80   //                                              
 81   G4double cryst_dX = 6 * cm, cryst_dY = 6 * c    
 82   G4int nb_cryst = 32;                            
 83   G4int nb_rings = 9;                             
 84   //                                              
 85   G4double dPhi = twopi / nb_cryst, half_dPhi     
 86   G4double cosdPhi = std::cos(half_dPhi);         
 87   G4double tandPhi = std::tan(half_dPhi);         
 88   //                                              
 89   G4double ring_R1 = 0.5 * cryst_dY / tandPhi;    
 90   G4double ring_R2 = (ring_R1 + cryst_dZ) / co    
 91   //                                              
 92   G4double detector_dZ = nb_rings * cryst_dX;     
 93   //                                              
 94   G4NistManager* nist = G4NistManager::Instanc    
 95   G4Material* default_mat = nist->FindOrBuildM    
 96   G4Material* cryst_mat = nist->FindOrBuildMat    
 97                                                   
 98   //                                              
 99   // World                                        
100   //                                              
101   G4double world_sizeXY = 2.4 * ring_R2;          
102   G4double world_sizeZ = 1.2 * detector_dZ;       
103                                                   
104   auto solidWorld =                               
105     new G4Box("World",  // its name               
106               0.5 * world_sizeXY, 0.5 * world_    
107                                                   
108   auto logicWorld = new G4LogicalVolume(solidW    
109                                         defaul    
110                                         "World    
111                                                   
112   auto physWorld = new G4PVPlacement(nullptr,     
113                                      G4ThreeVe    
114                                      logicWorl    
115                                      "World",     
116                                      nullptr,     
117                                      false,  /    
118                                      0,  // co    
119                                      fCheckOve    
120                                                   
121   //                                              
122   // ring                                         
123   //                                              
124   auto solidRing = new G4Tubs("Ring", ring_R1,    
125                                                   
126   auto logicRing = new G4LogicalVolume(solidRi    
127                                        default    
128                                        "Ring")    
129                                                   
130   //                                              
131   // define crystal                               
132   //                                              
133   G4double gap = 0.5 * mm;  // a gap for wrapp    
134   G4double dX = cryst_dX - gap, dY = cryst_dY     
135   auto solidCryst = new G4Box("crystal", dX /     
136                                                   
137   auto logicCryst = new G4LogicalVolume(solidC    
138                                         cryst_    
139                                         "Cryst    
140                                                   
141   // place crystals within a ring                 
142   //                                              
143   for (G4int icrys = 0; icrys < nb_cryst; icry    
144     G4double phi = icrys * dPhi;                  
145     G4RotationMatrix rotm = G4RotationMatrix()    
146     rotm.rotateY(90 * deg);                       
147     rotm.rotateZ(phi);                            
148     G4ThreeVector uz = G4ThreeVector(std::cos(    
149     G4ThreeVector position = (ring_R1 + 0.5 *     
150     G4Transform3D transform = G4Transform3D(ro    
151                                                   
152     new G4PVPlacement(transform,  // rotation,    
153                       logicCryst,  // its logi    
154                       "crystal",  // its name     
155                       logicRing,  // its mothe    
156                       false,  // no boolean op    
157                       icrys,  // copy number      
158                       fCheckOverlaps);  // che    
159   }                                               
160                                                   
161   //                                              
162   // full detector                                
163   //                                              
164   auto solidDetector = new G4Tubs("Detector",     
165                                                   
166   auto logicDetector = new G4LogicalVolume(sol    
167                                            def    
168                                            "De    
169                                                   
170   //                                              
171   // place rings within detector                  
172   //                                              
173   G4double OG = -0.5 * (detector_dZ + cryst_dX    
174   for (G4int iring = 0; iring < nb_rings; irin    
175     OG += cryst_dX;                               
176     new G4PVPlacement(nullptr,  // no rotation    
177                       G4ThreeVector(0, 0, OG),    
178                       logicRing,  // its logic    
179                       "ring",  // its name        
180                       logicDetector,  // its m    
181                       false,  // no boolean op    
182                       iring,  // copy number      
183                       fCheckOverlaps);  // che    
184   }                                               
185                                                   
186   //                                              
187   // place detector in world                      
188   //                                              
189   new G4PVPlacement(nullptr,  // no rotation      
190                     G4ThreeVector(),  // at (0    
191                     logicDetector,  // its log    
192                     "Detector",  // its name      
193                     logicWorld,  // its mother    
194                     false,  // no boolean oper    
195                     0,  // copy number            
196                     fCheckOverlaps);  // check    
197                                                   
198   //                                              
199   // patient                                      
200   //                                              
201   G4double patient_radius = 8 * cm;               
202   G4double patient_dZ = 10 * cm;                  
203   G4Material* patient_mat = nist->FindOrBuildM    
204                                                   
205   auto solidPatient = new G4Tubs("Patient", 0.    
206                                                   
207   auto logicPatient = new G4LogicalVolume(soli    
208                                           pati    
209                                           "Pat    
210                                                   
211   //                                              
212   // place patient in world                       
213   //                                              
214   new G4PVPlacement(nullptr,  // no rotation      
215                     G4ThreeVector(),  // at (0    
216                     logicPatient,  // its logi    
217                     "Patient",  // its name       
218                     logicWorld,  // its mother    
219                     false,  // no boolean oper    
220                     0,  // copy number            
221                     fCheckOverlaps);  // check    
222                                                   
223   // Visualization attributes                     
224   //                                              
225   logicRing->SetVisAttributes(G4VisAttributes:    
226   logicDetector->SetVisAttributes(G4VisAttribu    
227                                                   
228   // Print materials                              
229   G4cout << *(G4Material::GetMaterialTable())     
230                                                   
231   // always return the physical World             
232   //                                              
233   return physWorld;                               
234 }                                                 
235                                                   
236 //....oooOO0OOooo........oooOO0OOooo........oo    
237                                                   
238 void DetectorConstruction::ConstructSDandField    
239 {                                                 
240   G4SDManager::GetSDMpointer()->SetVerboseLeve    
241                                                   
242   // declare crystal as a MultiFunctionalDetec    
243   //                                              
244   auto cryst = new G4MultiFunctionalDetector("    
245   G4SDManager::GetSDMpointer()->AddNewDetector    
246   G4VPrimitiveScorer* primitiv1 = new G4PSEner    
247   cryst->RegisterPrimitive(primitiv1);            
248   SetSensitiveDetector("CrystalLV", cryst);       
249                                                   
250   // declare patient as a MultiFunctionalDetec    
251   //                                              
252   auto patient = new G4MultiFunctionalDetector    
253   G4SDManager::GetSDMpointer()->AddNewDetector    
254   G4VPrimitiveScorer* primitiv2 = new G4PSDose    
255   patient->RegisterPrimitive(primitiv2);          
256   SetSensitiveDetector("PatientLV", patient);     
257 }                                                 
258                                                   
259 //....oooOO0OOooo........oooOO0OOooo........oo    
260                                                   
261 }  // namespace B3                                
262