Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
IORTPrimaryGeneratorAction Class Reference

#include <IORTPrimaryGeneratorAction.hh>

Inheritance diagram for IORTPrimaryGeneratorAction:
G4VUserPrimaryGeneratorAction

Public Member Functions

 IORTPrimaryGeneratorAction ()
 
 ~IORTPrimaryGeneratorAction ()
 
void SetsigmaEnergy (G4double)
 
void SetmeanKineticEnergy (G4double)
 
void GeneratePrimaries (G4Event *)
 
void SetXposition (G4double)
 
void SetYposition (G4double)
 
void SetZposition (G4double)
 
void SetsigmaY (G4double)
 
void SetsigmaZ (G4double)
 
void SetTheta (G4double)
 
G4double GetmeanKineticEnergy (void)
 
G4ParticleGunGetParticleGun (void)
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Detailed Description

Definition at line 50 of file IORTPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

IORTPrimaryGeneratorAction::IORTPrimaryGeneratorAction ( )

Definition at line 55 of file IORTPrimaryGeneratorAction.cc.

56 {
57  // Define the messenger
58  gunMessenger = new IORTPrimaryGeneratorMessenger(this);
59 
60  particleGun = new G4ParticleGun();
61 
62  SetDefaultPrimaryParticle();
63 }
IORTPrimaryGeneratorAction::~IORTPrimaryGeneratorAction ( )

Definition at line 65 of file IORTPrimaryGeneratorAction.cc.

66 {
67  delete particleGun;
68 
69  delete gunMessenger;
70 }

Member Function Documentation

void IORTPrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 132 of file IORTPrimaryGeneratorAction.cc.

References IORTAnalysisManager::GetInstance(), G4INCL::DeJongSpin::shoot(), CLHEP::RandFlat::shoot(), test::x, and z.

133 {
134 #ifdef G4ANALYSIS_USE_ROOT
135  // Increment the event counter
136  IORTAnalysisManager::GetInstance()->startNewEvent();
137 #endif
138 
139  // ****************************************
140  // Set the beam angular apread
141  // and spot size
142  // beam spot size
143  // ****************************************
144 
145  // Set the position of the primary particles
146  G4double x = X0;
147  G4double y = Y0;
148  G4double z = Z0;
149 
150  if ( sigmaY > 0.0 )
151  {
152  y += G4RandGauss::shoot( Y0, sigmaY );
153  }
154 
155  if ( sigmaZ > 0.0 )
156  {
157  z += G4RandGauss::shoot( Z0, sigmaZ );
158  }
159 
160  particleGun -> SetParticlePosition(G4ThreeVector( x , y , z ) );
161 
162  // ********************************************
163  // Set the beam energy and energy spread
164  // ********************************************
165 
166  G4double kineticEnergy = G4RandGauss::shoot( meanKineticEnergy, sigmaEnergy );
167  particleGun -> SetParticleEnergy ( kineticEnergy );
168 
169  // Set the direction of the primary particles
170 
171 
172  /*
173  G4double momentumX = 1.0;
174  G4double momentumY = 0.0;
175  G4double momentumZ = 0.0;
176 
177  if ( sigmaMomentumY > 0.0 )
178  {
179  momentumY += G4RandGauss::shoot( 0., sigmaMomentumY );
180  }
181  if ( sigmaMomentumZ > 0.0 )
182  {
183  momentumZ += G4RandGauss::shoot( 0., sigmaMomentumZ );
184  }
185 
186  particleGun -> SetParticleMomentumDirection( G4ThreeVector(momentumX,momentumY,momentumZ) );
187 
188  */
189 
190 
191  G4double Mx;
192  G4double My;
193  G4double Mz;
194  G4double condizione;
195 
196 while (true) {
197 
198  //Mx = CLHEP::RandFlat::shoot(0.9,1);
199  //My = CLHEP::RandFlat::shoot(-0.1,0.1);
200  //Mz = CLHEP::RandFlat::shoot(-0.1,0.1);
201 
202  Mx = CLHEP::RandFlat::shoot(0.7,1);
203  My = CLHEP::RandFlat::shoot(-0.3,0.3); // ranges good for 0<Theta<20
204  Mz = CLHEP::RandFlat::shoot(-0.3,0.3);
205 
206  condizione = std::sqrt(Mx*Mx + My*My + Mz*Mz);
207 
208 
209  if (condizione < 1) {
210  Mx = Mx/condizione;
211  My = My/condizione;
212  Mz = Mz/condizione;
213 
214 
215  if (Mx > std::cos(Theta)) {
216  break;
217  }
218  }
219 }
220 
221 
222  particleGun -> SetParticleMomentumDirection( G4ThreeVector(Mx,My,Mz) );
223 
224 
225  // Generate a primary particle
226  particleGun -> GeneratePrimaryVertex( anEvent );
227 }
ThreeVector shoot(const G4int Ap, const G4int Af)
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
static double shoot()
Definition: RandFlat.cc:59
static IORTAnalysisManager * GetInstance()
double G4double
Definition: G4Types.hh:76
G4double IORTPrimaryGeneratorAction::GetmeanKineticEnergy ( void  )

Definition at line 275 of file IORTPrimaryGeneratorAction.cc.

276 { return meanKineticEnergy;}
G4ParticleGun* IORTPrimaryGeneratorAction::GetParticleGun ( void  )
inline

Definition at line 71 of file IORTPrimaryGeneratorAction.hh.

71 {return particleGun;}
void IORTPrimaryGeneratorAction::SetmeanKineticEnergy ( G4double  val)

Definition at line 229 of file IORTPrimaryGeneratorAction.cc.

References IORTAnalysisManager::GetInstance().

230 {
231  meanKineticEnergy = val;
232 #ifdef G4ANALYSIS_USE_ROOT
233  // Update the beam-data in the analysis manager
234  IORTAnalysisManager::GetInstance()->setBeamMetaData(meanKineticEnergy, sigmaEnergy);
235 #endif
236 
237 }
static IORTAnalysisManager * GetInstance()
void IORTPrimaryGeneratorAction::SetsigmaEnergy ( G4double  val)

Definition at line 239 of file IORTPrimaryGeneratorAction.cc.

References IORTAnalysisManager::GetInstance().

240 {
241  sigmaEnergy = val;
242 #ifdef G4ANALYSIS_USE_ROOT
243  // Update the sigmaenergy in the metadata.
244  IORTAnalysisManager::GetInstance()->setBeamMetaData(meanKineticEnergy, sigmaEnergy);
245 #endif
246 }
static IORTAnalysisManager * GetInstance()
void IORTPrimaryGeneratorAction::SetsigmaY ( G4double  val)

Definition at line 257 of file IORTPrimaryGeneratorAction.cc.

258 { sigmaY = val;}
void IORTPrimaryGeneratorAction::SetsigmaZ ( G4double  val)

Definition at line 260 of file IORTPrimaryGeneratorAction.cc.

261 { sigmaZ = val;}
void IORTPrimaryGeneratorAction::SetTheta ( G4double  val)

Definition at line 271 of file IORTPrimaryGeneratorAction.cc.

272 { Theta = val;}
void IORTPrimaryGeneratorAction::SetXposition ( G4double  val)

Definition at line 248 of file IORTPrimaryGeneratorAction.cc.

249 { X0 = val;}
void IORTPrimaryGeneratorAction::SetYposition ( G4double  val)

Definition at line 251 of file IORTPrimaryGeneratorAction.cc.

252 { Y0 = val;}
void IORTPrimaryGeneratorAction::SetZposition ( G4double  val)

Definition at line 254 of file IORTPrimaryGeneratorAction.cc.

255 { Z0 = val;}

The documentation for this class was generated from the following files: