Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IORTPrimaryGeneratorAction Class Reference

#include <IORTPrimaryGeneratorAction.hh>

Inheritance diagram for IORTPrimaryGeneratorAction:
Collaboration diagram for IORTPrimaryGeneratorAction:

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.

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

Here is the call graph for this function:

G4double IORTPrimaryGeneratorAction::GetmeanKineticEnergy ( void  )

Definition at line 273 of file IORTPrimaryGeneratorAction.cc.

274 { 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 227 of file IORTPrimaryGeneratorAction.cc.

228 {
229  meanKineticEnergy = val;
230 
231  // Update the beam-data in the analysis manager
233  setBeamMetaData(meanKineticEnergy, sigmaEnergy);
234 
235 
236 }
static IORTAnalysisManager * GetInstance()

Here is the call graph for this function:

void IORTPrimaryGeneratorAction::SetsigmaEnergy ( G4double  val)

Definition at line 238 of file IORTPrimaryGeneratorAction.cc.

239 {
240  sigmaEnergy = val;
241  // Update the sigmaenergy in the metadata.
243  setBeamMetaData(meanKineticEnergy, sigmaEnergy);
244 }
static IORTAnalysisManager * GetInstance()

Here is the call graph for this function:

void IORTPrimaryGeneratorAction::SetsigmaY ( G4double  val)

Definition at line 255 of file IORTPrimaryGeneratorAction.cc.

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

Definition at line 258 of file IORTPrimaryGeneratorAction.cc.

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

Definition at line 269 of file IORTPrimaryGeneratorAction.cc.

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

Definition at line 246 of file IORTPrimaryGeneratorAction.cc.

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

Definition at line 249 of file IORTPrimaryGeneratorAction.cc.

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

Definition at line 252 of file IORTPrimaryGeneratorAction.cc.

253 { Z0 = val;}

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