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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/iort_therapy/src/IORTPrimaryGeneratorAction.cc (Version 11.3.0) and /examples/advanced/iort_therapy/src/IORTPrimaryGeneratorAction.cc (Version 1.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 // This is the *BASIC* version of IORT, a Gean    
 27 //                                                
 28 // Main Authors: G.Russo(a,b), C.Casarino*(c),    
 29 // Contributor Authors: S.Guatelli(e)             
 30 // Past Authors: G.Arnetta(c), S.E.Mazzaglia(d    
 31 //                                                
 32 //   (a) Fondazione Istituto San Raffaele G.Gi    
 33 //   (b) IBFM-CNR , Segrate (Milano), Italy       
 34 //   (c) LATO (Laboratorio di Tecnologie Oncol    
 35 //   (d) Laboratori Nazionali del Sud of the I    
 36 //   (e) University of Wollongong, Australia      
 37 //                                                
 38 //   *Corresponding author, email to carlo.cas    
 39 //////////////////////////////////////////////    
 40                                                   
 41 #include "G4SystemOfUnits.hh"                     
 42 #include "IORTPrimaryGeneratorAction.hh"          
 43 #include "IORTPrimaryGeneratorMessenger.hh"       
 44                                                   
 45 #include "globals.hh"                             
 46 #include "G4Event.hh"                             
 47 #include "G4ParticleGun.hh"                       
 48 #include "G4ParticleTable.hh"                     
 49 #include "G4ParticleDefinition.hh"                
 50 #include "Randomize.hh"                           
 51                                                   
 52 IORTPrimaryGeneratorAction::IORTPrimaryGenerat    
 53 {                                                 
 54   // Define the messenger                         
 55   gunMessenger = new IORTPrimaryGeneratorMesse    
 56                                                   
 57   particleGun  = new G4ParticleGun();             
 58                                                   
 59   SetDefaultPrimaryParticle();                    
 60 }                                                 
 61                                                   
 62 IORTPrimaryGeneratorAction::~IORTPrimaryGenera    
 63 {                                                 
 64   delete particleGun;                             
 65                                                   
 66   delete gunMessenger;                            
 67 }                                                 
 68                                                   
 69 void IORTPrimaryGeneratorAction::SetDefaultPri    
 70 {                                                 
 71   // ****************************                 
 72   // Default primary particle                     
 73   // ****************************                 
 74                                                   
 75   // Define primary particles: electrons // pr    
 76   G4ParticleTable* particleTable = G4ParticleT    
 77   G4ParticleDefinition* particle = particleTab    
 78   particleGun -> SetParticleDefinition(particl    
 79                                                   
 80   // Define the energy of primary particles:      
 81   // gaussian distribution with mean energy =     
 82   // and sigma = 400.0 *keV                       
 83   G4double defaultMeanKineticEnergy = 10.0 *CL    
 84   meanKineticEnergy = defaultMeanKineticEnergy    
 85                                                   
 86   G4double defaultsigmaEnergy = 100.0 *CLHEP::    
 87   sigmaEnergy = defaultsigmaEnergy;               
 88                                                   
 89   // Define the parameters of the initial posi    
 90   // the y, z coordinates have a gaussian dist    
 91                                                   
 92   G4double defaultX0 = -862.817 *CLHEP::mm;       
 93   X0 = defaultX0;                                 
 94                                                   
 95   G4double defaultY0 = 0.0 *CLHEP::mm;            
 96   Y0 = defaultY0;                                 
 97                                                   
 98   G4double defaultZ0 = 0.0 *CLHEP::mm;            
 99   Z0 = defaultZ0;                                 
100                                                   
101   G4double defaultsigmaY = 1. *CLHEP::mm;         
102   sigmaY = defaultsigmaY;                         
103                                                   
104   G4double defaultsigmaZ = 1. *CLHEP::mm;         
105   sigmaZ = defaultsigmaZ;                         
106                                                   
107   // Define the parameters of the momentum of     
108   // The momentum along the y and z axis has a    
109                                                   
110 /*                                                
111   G4double defaultsigmaMomentumY = 0.0;           
112   sigmaMomentumY = defaultsigmaMomentumY;         
113                                                   
114   G4double defaultsigmaMomentumZ = 0.0;           
115   sigmaMomentumZ = defaultsigmaMomentumZ;         
116 */                                                
117                                                   
118   G4double defaultTheta = 6.0 *CLHEP::deg;        
119   Theta = defaultTheta;                           
120                                                   
121 }                                                 
122                                                   
123 void IORTPrimaryGeneratorAction::GeneratePrima    
124 {                                                 
125   // ****************************************     
126   // Set the beam angular apread                  
127   // and spot size                                
128   // beam spot size                               
129   // ****************************************     
130                                                   
131   // Set the position of the primary particles    
132   G4double x = X0;                                
133   G4double y = Y0;                                
134   G4double z = Z0;                                
135                                                   
136   if ( sigmaY > 0.0 )                             
137     {                                             
138       y += G4RandGauss::shoot( Y0, sigmaY );      
139     }                                             
140                                                   
141   if ( sigmaZ > 0.0 )                             
142     {                                             
143       z += G4RandGauss::shoot( Z0, sigmaZ );      
144     }                                             
145                                                   
146   particleGun -> SetParticlePosition(G4ThreeVe    
147                                                   
148   // *****************************************    
149   // Set the beam energy and energy spread        
150   // *****************************************    
151                                                   
152   G4double kineticEnergy = G4RandGauss::shoot(    
153   particleGun -> SetParticleEnergy ( kineticEn    
154                                                   
155   // Set the direction of the primary particle    
156                                                   
157                                                   
158   /*                                              
159   G4double momentumX = 1.0;                       
160   G4double momentumY = 0.0;                       
161   G4double momentumZ = 0.0;                       
162                                                   
163   if ( sigmaMomentumY  > 0.0 )                    
164     {                                             
165       momentumY += G4RandGauss::shoot( 0., sig    
166     }                                             
167   if ( sigmaMomentumZ  > 0.0 )                    
168     {                                             
169       momentumZ += G4RandGauss::shoot( 0., sig    
170     }                                             
171                                                   
172   particleGun -> SetParticleMomentumDirection(    
173                                                   
174   */                                              
175                                                   
176                                                   
177   G4double Mx;                                    
178   G4double My;                                    
179   G4double Mz;                                    
180   G4double condizione;                            
181                                                   
182 while (true)  {                                   
183                                                   
184   //Mx =  CLHEP::RandFlat::shoot(0.9,1);          
185   //My =  CLHEP::RandFlat::shoot(-0.1,0.1);       
186   //Mz =  CLHEP::RandFlat::shoot(-0.1,0.1);       
187                                                   
188   Mx =  CLHEP::RandFlat::shoot(0.7,1);            
189   My =  CLHEP::RandFlat::shoot(-0.3,0.3); // r    
190   Mz =  CLHEP::RandFlat::shoot(-0.3,0.3);         
191                                                   
192   condizione = std::sqrt(Mx*Mx + My*My + Mz*Mz    
193                                                   
194                                                   
195   if (condizione < 1)  {                          
196     Mx = Mx/condizione;                           
197     My = My/condizione;                           
198     Mz = Mz/condizione;                           
199                                                   
200                                                   
201     if (Mx > std::cos(Theta)) {                   
202       break;                                      
203         }                                         
204     }                                             
205 }                                                 
206                                                   
207                                                   
208   particleGun -> SetParticleMomentumDirection(    
209                                                   
210                                                   
211   // Generate a primary particle                  
212   particleGun -> GeneratePrimaryVertex( anEven    
213 }                                                 
214                                                   
215 void IORTPrimaryGeneratorAction::SetmeanKineti    
216 {                                                 
217   meanKineticEnergy = val;                        
218   G4cout << "The mean Kinetic energy of the in    
219          << meanKineticEnergy/MeV << G4endl;      
220 }                                                 
221                                                   
222 void IORTPrimaryGeneratorAction::SetsigmaEnerg    
223 {                                                 
224  sigmaEnergy = val;                               
225  G4cout << "The sigma of the kinetic energy of    
226         << sigmaEnergy/MeV << G4endl;             
227 }                                                 
228                                                   
229 void IORTPrimaryGeneratorAction::SetXposition     
230 { X0 = val;}                                      
231                                                   
232 void IORTPrimaryGeneratorAction::SetYposition     
233 { Y0 = val;}                                      
234                                                   
235 void IORTPrimaryGeneratorAction::SetZposition     
236 { Z0 = val;}                                      
237                                                   
238 void IORTPrimaryGeneratorAction::SetsigmaY (G4    
239 { sigmaY = val;}                                  
240                                                   
241 void IORTPrimaryGeneratorAction::SetsigmaZ (G4    
242 { sigmaZ = val;}                                  
243                                                   
244 /*                                                
245 void IORTPrimaryGeneratorAction::SetsigmaMomen    
246 { sigmaMomentumY = val;}                          
247                                                   
248 void IORTPrimaryGeneratorAction::SetsigmaMomen    
249 { sigmaMomentumZ = val;}                          
250 */                                                
251                                                   
252 void IORTPrimaryGeneratorAction::SetTheta (G4d    
253 { Theta = val;}                                   
254                                                   
255                                                   
256 G4double IORTPrimaryGeneratorAction::GetmeanKi    
257 { return meanKineticEnergy;}                      
258                                                   
259