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4.p3 ] [ 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/eFLASH_radiotherapy/src/FlashDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/eFLASH_radiotherapy/src/FlashDetectorConstruction.cc (Version 9.1.p3)


  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 FlashDetectorConstruction.cc            
 28 /// \brief Implementation of the FlashDetector    
 29                                                   
 30                                                   
 31 #include "FlashDetectorConstruction.hh"           
 32                                                   
 33 #include "G4RunManager.hh"                        
 34                                                   
 35 #include "G4Material.hh"                          
 36 #include "G4NistManager.hh"                       
 37 #include "G4Region.hh"                            
 38 #include "G4SDManager.hh"                         
 39                                                   
 40 #include "G4AutoDelete.hh"                        
 41 #include "G4Box.hh"                               
 42 #include "G4GlobalMagFieldMessenger.hh"           
 43 #include "G4LogicalVolume.hh"                     
 44 #include "G4PVParameterised.hh"                   
 45 #include "G4PVPlacement.hh"                       
 46 #include "G4Tubs.hh"                              
 47                                                   
 48 #include "G4GeometryManager.hh"                   
 49 #include "G4GeometryTolerance.hh"                 
 50                                                   
 51 #include "G4UserLimits.hh"                        
 52                                                   
 53 #include "G4Colour.hh"                            
 54 #include "G4VisAttributes.hh"                     
 55                                                   
 56 #include "G4SystemOfUnits.hh"                     
 57                                                   
 58 #include "FlashApplicator.hh"                     
 59                                                   
 60                                                   
 61 #include "G4MaterialPropertiesTable.hh"           
 62                                                   
 63 #include "G4PSEnergyDeposit.hh"                   
 64 #include "G4PhysicalConstants.hh"                 
 65 #include "G4SystemOfUnits.hh"                     
 66 #include "G4VPrimitiveScorer.hh"                  
 67 #include "G4VisAttributes.hh"                     
 68 #include "FlashDetectorMessenger.hh"              
 69                                                   
 70 #include "FlashSensitiveDetector.hh"              
 71                                                   
 72 //....oooOO0OOooo........oooOO0OOooo........oo    
 73                                                   
 74 FlashDetectorConstruction::FlashDetectorConstr    
 75     : G4VUserDetectorConstruction(), physicalT    
 76 fPhantomLogicalVolume(0),fPhant_phys(0),          
 77       fCheckOverlaps(true),                       
 78       fActivateDet(false)                         
 79        {                                          
 80                                                   
 81   DefineMaterials();                              
 82   fDetectorMessenger = new FlashDetectorMessen    
 83                                                   
 84   SetPhantomSize(30. *cm, 30. *cm, 30. *cm);      
 85   SetAirGap(0*cm); // Set the air gap between     
 86   SetDetectorThickness(10*um); //Set the SiC d    
 87   SetDetector_subThickness(370*um);               
 88   SetDetectorWidth(2*mm); //Set the SiC detect    
 89   SetDetectorPosition(13*mm); // Position of t    
 90                                                   
 91   // Change the following parameters to change    
 92   nDet = 40;                                      
 93   fDet_ctc = 3 * mm;                              
 94                                                   
 95 }                                                 
 96                                                   
 97 //....oooOO0OOooo........oooOO0OOooo........oo    
 98                                                   
 99 FlashDetectorConstruction::~FlashDetectorConst    
100                                                   
101   delete fDetectorMessenger;                      
102 }                                                 
103                                                   
104 //....oooOO0OOooo........oooOO0OOooo........oo    
105                                                   
106 void FlashDetectorConstruction::DefineMaterial    
107   nist = G4NistManager::Instance();               
108 //write here a function to define custom mater    
109 G4bool isotopes = false;                          
110  Si = nist->FindOrBuildElement("Si", isotopes)    
111  C = nist->FindOrBuildElement("C", isotopes);     
112                                                   
113   }                                               
114                                                   
115                                                   
116 //                                                
117 G4VPhysicalVolume *                               
118 FlashDetectorConstruction::ConstructPhantom(G4    
119 //This function creates a cubic phantom with t    
120                                                   
121  fPhantomMaterial = nist->FindOrBuildMaterial(    
122                                                   
123  fPosition_coefficient = CollPos;                 
124                                                   
125  fPhantom_coordinateX = (fPosition_coefficient    
126                                                   
127  fPhantomPosition =  G4ThreeVector(fPhantom_co    
128                                                   
129                                                   
130   // Definition of the solid volume of the Pha    
131   fPhantom = new G4Box("Phantom", fPhantomSize    
132                       fPhantomSizeZ / 2);         
133                                                   
134   // Definition of the logical volume of the P    
135   fPhantomLogicalVolume =                         
136       new G4LogicalVolume(fPhantom, fPhantomMa    
137                                                   
138   // Definition of the physical volume of the     
139   fPhant_phys =                                   
140       new G4PVPlacement(0, fPhantomPosition, "    
141                         physicalTreatmentRoom,    
142 //define the region to set cuts in FlashPhysic    
143   G4Region *PhantomRegion = new G4Region("Phan    
144   fPhantomLogicalVolume->SetRegion(PhantomRegi    
145   PhantomRegion->AddRootLogicalVolume(fPhantom    
146                                                   
147   // Visualisation attributes of the phantom      
148   red = new G4VisAttributes(G4Colour(0 / 255.,    
149   red->SetVisibility(true);                       
150                                                   
151   blue = new G4VisAttributes(G4Colour(0 / 255.    
152   blue->SetVisibility(true);                      
153                                                   
154   fPhantomLogicalVolume->SetVisAttributes(red)    
155 //set step limit in phantom                       
156   G4double maxStep = 0.1 * mm;                    
157   fStepLimit = new G4UserLimits(maxStep);         
158   fPhantomLogicalVolume->SetUserLimits(fStepLi    
159                                                   
160   return fPhant_phys;                             
161 }                                                 
162                                                   
163                                                   
164 void FlashDetectorConstruction::ConstructDetec    
165  //Detector                                       
166                                                   
167                                                   
168   G4double fDensity_SiC=3.22*g/cm3;               
169                                                   
170   SiC=new G4Material("SiC", fDensity_SiC,2);      
171   SiC->AddElement(Si,1);                          
172   SiC->AddElement(C,1);                           
173                                                   
174  fDetectorMaterial=SiC;                           
175                                                   
176                                                   
177                                                   
178  fDet_box = new G4Box("Detector",fDet_thicknes    
179                                                   
180   // Definition of the logical volume of the D    
181   fDetLogicalVolume =                             
182       new G4LogicalVolume(fDet_box, fDetectorM    
183                                                   
184                                                   
185   fDet_sub = new G4Box("Det_sub",fDet_sub_thic    
186                                                   
187     // Definition of the logical volume of the    
188     fDet_sub_LogicalVolume =                      
189         new G4LogicalVolume(fDet_sub, fDetecto    
190                                                   
191                                                   
192   G4double posInit = (nDet - 1) * fDet_ctc / 2    
193                                                   
194                                                   
195 if (fActivateDet) {                               
196     // Placement physical volumes of the detec    
197     for (int i = 0; i < nDet; i++){               
198                                                   
199     std::ostringstream os;                        
200     os << "Det_Phys_";                            
201     if (i < 10)                                   
202     {                                             
203         os << "00";                               
204     } else if (i < 100){                          
205         os << "0";                                
206     }                                             
207     os << i ;                                     
208     G4String name = os.str();                     
209                                                   
210     G4cout << "Position: " << -posInit + fDet_    
211                                                   
212     fDet_phys.push_back(new G4PVPlacement(        
213         0,                                        
214   //  G4ThreeVector(fDetectorPosition, 0, -pos    
215   G4ThreeVector(-fPhantomSizeX/2+fDetectorPosi    
216         name,                                     
217         fDetLogicalVolume,                        
218         fPhant_phys,                              
219         false,                                    
220         i,                                        
221         fCheckOverlaps                            
222     ));                                           
223                                                   
224                                                   
225     fDet_sub_phys.push_back (new G4PVPlacement    
226            (0,                                    
227             G4ThreeVector(-fPhantomSizeX/2+fDe    
228             "Det_sub_Phys",                       
229             fDet_sub_LogicalVolume,               
230             fPhant_phys,                          
231             false,                                
232             i,                                    
233             fCheckOverlaps));                     
234                                                   
235                                                   
236                                                   
237     }                                             
238 }                                                 
239                                                   
240 }                                                 
241                                                   
242 G4VPhysicalVolume *FlashDetectorConstruction::    
243   // -----------------------------                
244   // Treatment room - World volume                
245   //------------------------------                
246   // Treatment room sizes                         
247   const G4double worldX = 400.0 * cm;             
248   const G4double worldY = 400.0 * cm;             
249   const G4double worldZ = 400.0 * cm;             
250   G4bool isotopes = false;                        
251                                                   
252   airNist = G4NistManager::Instance()->FindOrB    
253   // Air                                          
254   //                                              
255                                                   
256   G4Box *treatmentRoom = new G4Box("TreatmentR    
257   logicTreatmentRoom = new G4LogicalVolume(tre    
258                                            "lo    
259   physicalTreatmentRoom =                         
260       new G4PVPlacement(0, G4ThreeVector(), "p    
261                         logicTreatmentRoom, 0,    
262                                                   
263   // The treatment room is invisible in the Vi    
264   logicTreatmentRoom->SetVisAttributes(G4VisAt    
265                                                   
266   // -----------------------------                
267   // Applicator + phantom +Default dimensions     
268   //------------------------------                
269                                                   
270                                                   
271                                                   
272                                                   
273   Collimator = new FlashApplicator(physicalTre    
274                                                   
275                                                   
276                                                   
277  fPhantom_physical =                              
278         ConstructPhantom(Collimator->fFinalApp    
279   Collimator->fHightFinalApplicatorFlash+fAirG    
280                                                   
281                                                   
282   ConstructDetector();                            
283                                                   
284   return physicalTreatmentRoom;                   
285 }                                                 
286                                                   
287                                                   
288                                                   
289 void FlashDetectorConstruction::ConstructSDand    
290 if (fActivateDet){                                
291                                                   
292     G4SDManager * SDman = G4SDManager::GetSDMp    
293                                                   
294     // Sensitive detector                         
295     FlashSensitiveDetector *fSensDet = new Fla    
296                                                   
297     SDman->AddNewDetector(fSensDet);              
298     fDetLogicalVolume->SetSensitiveDetector(fS    
299                                                   
300 }                                                 
301                                                   
302 }                                                 
303                                                   
304                                                   
305 /////MESSANGER ///                                
306                                                   
307 G4bool FlashDetectorConstruction::SetPhantomMa    
308 {                                                 
309                                                   
310     if (G4Material* pMat = G4NistManager::Inst    
311     {                                             
312   fPhantomMaterial  = pMat;                       
313                                                   
314   if (fPhantomLogicalVolume)                      
315   {                                               
316                                                   
317       fPhantomLogicalVolume ->  SetMaterial(pM    
318                                                   
319       G4RunManager::GetRunManager() -> Physics    
320       G4RunManager::GetRunManager() -> Geometr    
321       G4cout << "The material of Phantom/Detec    
322   }                                               
323     }                                             
324     else                                          
325     {                                             
326   G4cout << "WARNING: material \"" << material    
327       " table [located in $G4INSTALL/source/ma    
328   G4cout << "Use command \"/parameter/nist\" t    
329   return false;                                   
330     }                                             
331                                                   
332     return true;                                  
333 }                                                 
334                                                   
335                                                   
336 void FlashDetectorConstruction::SetPhantomSize    
337 {                                                 
338     if (sizeX > 0.) fPhantomSizeX = sizeX;        
339     if (sizeY > 0.) fPhantomSizeY = sizeY;        
340     if (sizeZ > 0.) fPhantomSizeZ = sizeZ;        
341 }                                                 
342                                                   
343 void FlashDetectorConstruction::SetAirGap(G4do    
344 {                                                 
345                                                   
346    fAirGap=displ;                                 
347 }                                                 
348                                                   
349 G4bool FlashDetectorConstruction::SetDetectorM    
350 {                                                 
351                                                   
352     if (G4Material* pMat = G4NistManager::Inst    
353     {                                             
354   fDetectorMaterial  = pMat;                      
355                                                   
356   if (fDetLogicalVolume)                          
357   {                                               
358                                                   
359       fDetLogicalVolume ->  SetMaterial(pMat);    
360                                                   
361       G4RunManager::GetRunManager() -> Physics    
362       G4RunManager::GetRunManager() -> Geometr    
363       G4cout << "The material of Phantom/Detec    
364   }                                               
365     }                                             
366     else                                          
367     {                                             
368   G4cout << "WARNING: material \"" << material    
369       " table [located in $G4INSTALL/source/ma    
370   G4cout << "Use command \"/parameter/nist\" t    
371   return false;                                   
372     }                                             
373                                                   
374     return true;                                  
375 }                                                 
376                                                   
377                                                   
378                                                   
379                                                   
380 void FlashDetectorConstruction::SetDetectorThi    
381 {                                                 
382                                                   
383    fDet_thickness=thickness;                      
384 }                                                 
385                                                   
386 void FlashDetectorConstruction::SetDetectorWid    
387 {                                                 
388                                                   
389    fDet_width=width;                              
390 }                                                 
391                                                   
392 void FlashDetectorConstruction::SetDetector_su    
393 {                                                 
394                                                   
395     fDet_sub_thickness= thickness_sub;            
396 }                                                 
397                                                   
398                                                   
399 void FlashDetectorConstruction::SetDetectorPos    
400 {                                                 
401                                                   
402    fDetectorPosition=position;                    
403 }                                                 
404                                                   
405 void FlashDetectorConstruction::ActivateDetArr    
406     fActivateDet = fbool;                         
407 }                                                 
408