Geant4  10.02.p03
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 ()
 

Private Member Functions

void SetDefaultPrimaryParticle ()
 

Private Attributes

G4double meanKineticEnergy
 
G4double sigmaEnergy
 
G4double X0
 
G4double Y0
 
G4double Z0
 
G4double sigmaY
 
G4double sigmaZ
 
G4double Theta
 
G4ParticleGunparticleGun
 
IORTPrimaryGeneratorMessengergunMessenger
 

Detailed Description

Definition at line 50 of file IORTPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

◆ IORTPrimaryGeneratorAction()

IORTPrimaryGeneratorAction::IORTPrimaryGeneratorAction ( )

Definition at line 55 of file IORTPrimaryGeneratorAction.cc.

Here is the call graph for this function:

◆ ~IORTPrimaryGeneratorAction()

IORTPrimaryGeneratorAction::~IORTPrimaryGeneratorAction ( )

Definition at line 65 of file IORTPrimaryGeneratorAction.cc.

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

Member Function Documentation

◆ GeneratePrimaries()

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 
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
Double_t y
static double shoot()
Definition: RandFlat.cc:59
static IORTAnalysisManager * GetInstance()
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:

◆ GetmeanKineticEnergy()

G4double IORTPrimaryGeneratorAction::GetmeanKineticEnergy ( void  )

Definition at line 273 of file IORTPrimaryGeneratorAction.cc.

◆ GetParticleGun()

G4ParticleGun* IORTPrimaryGeneratorAction::GetParticleGun ( void  )
inline

Definition at line 71 of file IORTPrimaryGeneratorAction.hh.

71 {return particleGun;}
Here is the call graph for this function:

◆ SetDefaultPrimaryParticle()

void IORTPrimaryGeneratorAction::SetDefaultPrimaryParticle ( )
private

Definition at line 72 of file IORTPrimaryGeneratorAction.cc.

73 {
74  // ****************************
75  // Default primary particle
76  // ****************************
77 
78  // Define primary particles: electrons // protons
80  G4ParticleDefinition* particle = particleTable -> FindParticle("e-"); // ("proton")
81  particleGun -> SetParticleDefinition(particle);
82 
83  // Define the energy of primary particles:
84  // gaussian distribution with mean energy = 10.0 *MeV
85  // and sigma = 400.0 *keV
86  G4double defaultMeanKineticEnergy = 10.0 *CLHEP::MeV;
87  meanKineticEnergy = defaultMeanKineticEnergy;
88 
89  G4double defaultsigmaEnergy = 100.0 *CLHEP::keV;
90  sigmaEnergy = defaultsigmaEnergy;
91 
92  // Write these values into the analysis if needed. Have to be written separately on change.
94  setBeamMetaData(meanKineticEnergy, sigmaEnergy);
95 
96 
97  // Define the parameters of the initial position:
98  // the y, z coordinates have a gaussian distribution
99 
100 
101  G4double defaultX0 = -862.817 *CLHEP::mm;
102  X0 = defaultX0;
103 
104  G4double defaultY0 = 0.0 *CLHEP::mm;
105  Y0 = defaultY0;
106 
107  G4double defaultZ0 = 0.0 *CLHEP::mm;
108  Z0 = defaultZ0;
109 
110  G4double defaultsigmaY = 1. *CLHEP::mm;
111  sigmaY = defaultsigmaY;
112 
113  G4double defaultsigmaZ = 1. *CLHEP::mm;
114  sigmaZ = defaultsigmaZ;
115 
116  // Define the parameters of the momentum of primary particles:
117  // The momentum along the y and z axis has a gaussian distribution
118 
119 /*
120  G4double defaultsigmaMomentumY = 0.0;
121  sigmaMomentumY = defaultsigmaMomentumY;
122 
123  G4double defaultsigmaMomentumZ = 0.0;
124  sigmaMomentumZ = defaultsigmaMomentumZ;
125 */
126 
127  G4double defaultTheta = 6.0 *CLHEP::deg;
128  Theta = defaultTheta;
129 
130 }
static const double deg
static IORTAnalysisManager * GetInstance()
static const double mm
Definition: SystemOfUnits.h:94
static G4ParticleTable * GetParticleTable()
double G4double
Definition: G4Types.hh:76
static const double keV
static const double MeV
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetmeanKineticEnergy()

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:

◆ SetsigmaEnergy()

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:

◆ SetsigmaY()

void IORTPrimaryGeneratorAction::SetsigmaY ( G4double  val)

Definition at line 255 of file IORTPrimaryGeneratorAction.cc.

◆ SetsigmaZ()

void IORTPrimaryGeneratorAction::SetsigmaZ ( G4double  val)

Definition at line 258 of file IORTPrimaryGeneratorAction.cc.

◆ SetTheta()

void IORTPrimaryGeneratorAction::SetTheta ( G4double  val)

Definition at line 269 of file IORTPrimaryGeneratorAction.cc.

◆ SetXposition()

void IORTPrimaryGeneratorAction::SetXposition ( G4double  val)

Definition at line 246 of file IORTPrimaryGeneratorAction.cc.

◆ SetYposition()

void IORTPrimaryGeneratorAction::SetYposition ( G4double  val)

Definition at line 249 of file IORTPrimaryGeneratorAction.cc.

◆ SetZposition()

void IORTPrimaryGeneratorAction::SetZposition ( G4double  val)

Definition at line 252 of file IORTPrimaryGeneratorAction.cc.

Member Data Documentation

◆ gunMessenger

IORTPrimaryGeneratorMessenger* IORTPrimaryGeneratorAction::gunMessenger
private

Definition at line 88 of file IORTPrimaryGeneratorAction.hh.

◆ meanKineticEnergy

G4double IORTPrimaryGeneratorAction::meanKineticEnergy
private

Definition at line 75 of file IORTPrimaryGeneratorAction.hh.

◆ particleGun

G4ParticleGun* IORTPrimaryGeneratorAction::particleGun
private

Definition at line 87 of file IORTPrimaryGeneratorAction.hh.

◆ sigmaEnergy

G4double IORTPrimaryGeneratorAction::sigmaEnergy
private

Definition at line 76 of file IORTPrimaryGeneratorAction.hh.

◆ sigmaY

G4double IORTPrimaryGeneratorAction::sigmaY
private

Definition at line 80 of file IORTPrimaryGeneratorAction.hh.

◆ sigmaZ

G4double IORTPrimaryGeneratorAction::sigmaZ
private

Definition at line 81 of file IORTPrimaryGeneratorAction.hh.

◆ Theta

G4double IORTPrimaryGeneratorAction::Theta
private

Definition at line 84 of file IORTPrimaryGeneratorAction.hh.

◆ X0

G4double IORTPrimaryGeneratorAction::X0
private

Definition at line 77 of file IORTPrimaryGeneratorAction.hh.

◆ Y0

G4double IORTPrimaryGeneratorAction::Y0
private

Definition at line 78 of file IORTPrimaryGeneratorAction.hh.

◆ Z0

G4double IORTPrimaryGeneratorAction::Z0
private

Definition at line 79 of file IORTPrimaryGeneratorAction.hh.


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