Geant4  10.02.p03
CCalPrimaryGeneratorAction Class Reference

#include <CCalPrimaryGeneratorAction.hh>

Inheritance diagram for CCalPrimaryGeneratorAction:
Collaboration diagram for CCalPrimaryGeneratorAction:

Public Member Functions

 CCalPrimaryGeneratorAction ()
 
 ~CCalPrimaryGeneratorAction ()
 
void GeneratePrimaries (G4Event *anEvent)
 
void SetVerboseLevel (G4int val)
 
void SetRandom (G4String val)
 
void SetScan (G4String val)
 
void SetMinimumEnergy (G4double p)
 
void SetMaximumEnergy (G4double p)
 
void SetMinimumPhi (G4double p)
 
void SetMaximumPhi (G4double p)
 
void SetStepsPhi (G4int val)
 
void SetMinimumEta (G4double p)
 
void SetMaximumEta (G4double p)
 
void SetStepsEta (G4int val)
 
void SetGunPosition (const G4ThreeVector &pos) const
 
void SetRunNo (G4int val)
 
G4ThreeVector GetParticlePosition ()
 
G4double GetParticleEnergy ()
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Private Member Functions

void initialize ()
 
void print (G4int val)
 

Private Attributes

CCalPrimaryGeneratorMessengergunMessenger
 
G4ParticleGunparticleGun
 
generatorInputType generatorInput
 
G4int verboseLevel
 
G4int n_particle
 
G4String particleName
 
G4double particleEnergy
 
G4ThreeVector particlePosition
 
G4ThreeVector particleDir
 
G4double energyMin
 
G4double energyMax
 
G4double etaMin
 
G4double etaMax
 
G4double phiMin
 
G4double phiMax
 
G4int etaSteps
 
G4int phiSteps
 
G4int isInitialized
 
G4double etaValue
 
G4double phiValue
 
G4int scanSteps
 

Detailed Description

Definition at line 66 of file CCalPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

◆ CCalPrimaryGeneratorAction()

CCalPrimaryGeneratorAction::CCalPrimaryGeneratorAction ( )

Definition at line 48 of file CCalPrimaryGeneratorAction.cc.

48  : particleGun(0),
50  particleName("pi-"), particleEnergy(100*GeV), particlePosition(0.,0.,0.),
51  particleDir(1.,1.,0.1), isInitialized(0), scanSteps(0) {
52 
53  //Initialise the messenger
55 
56  //Default settings:
59  SetMinimumEta(0.);
60  SetMaximumEta(3.5);
62  SetMaximumPhi(360.*degree);
63  SetStepsPhi(1);
64  SetStepsEta(1);
65 
66  // Number of particles per gun
68 
69  // Getting particle definition
71  G4ParticleDefinition* particle = particleTable->FindParticle(particleName);
73 
74  // Setting particle properties
78  print(0);
79 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
void SetParticlePosition(G4ThreeVector aPosition)
static const double GeV
Definition: G4SIunits.hh:214
void SetParticleEnergy(G4double aKineticEnergy)
static G4ParticleTable * GetParticleTable()
static const double degree
Definition: G4SIunits.hh:143
static const double TeV
Definition: G4SIunits.hh:215
CCalPrimaryGeneratorMessenger * gunMessenger
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
Here is the call graph for this function:

◆ ~CCalPrimaryGeneratorAction()

CCalPrimaryGeneratorAction::~CCalPrimaryGeneratorAction ( )

Definition at line 81 of file CCalPrimaryGeneratorAction.cc.

81  {
82  if (gunMessenger)
83  delete gunMessenger;
84  if (particleGun)
85  delete particleGun;
86 }
CCalPrimaryGeneratorMessenger * gunMessenger

Member Function Documentation

◆ GeneratePrimaries()

void CCalPrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 88 of file CCalPrimaryGeneratorAction.cc.

88  {
89 
90  if (isInitialized == 0) initialize();
91 
95 
98  G4double theta = std::atan(std::exp(-eta))*2.;
99  G4double randomX = std::sin(theta)*std::cos(phi);
100  G4double randomY = std::sin(theta)*std::sin(phi);
101  G4double randomZ = std::cos(theta);
102 
103  particleDir = G4ThreeVector(randomX,randomY,randomZ);
105 #ifdef debug
106  if (verboseLevel >= 2 ) {
107  G4cout << "Energy " << particleEnergy/GeV << " GeV; Theta "
108  << theta/deg << " degree; Phi " << phi/deg << " degree" << G4endl;
109  G4cout << "Shooting in " << particleDir << " direction "<< G4endl;
110  }
111 #endif
112  } else if (generatorInput == singleScan) {
113  G4double scanEtaStep, scanPhiStep;
114  if (scanSteps == 0) {
115  scanPhiStep = (phiMax - phiMin) / phiSteps;
116  phiValue = phiMin - scanPhiStep; //first step is going to change scanCurrentPhiValue
117  etaValue = etaMin;
118  }
119 
120  scanEtaStep = (etaMax - etaMin) / etaSteps;
121  scanPhiStep = (phiMax - phiMin) / phiSteps;
122 #ifdef debug
123  if (verboseLevel > 2 ) {
124  G4cout << " scanEtaStep " << scanEtaStep << " # of Steps " << etaSteps
125  << G4endl;
126  G4cout << " scanPhiStep " << scanPhiStep << " # of Steps " << phiSteps
127  << G4endl;
128  }
129 #endif
130 
131  //----- First scan in phi, then in eta
132  if (phiMax - phiValue < 1.E-6 * scanPhiStep) { // !only <= 1.E6 steps allowed
133  if (etaMax - etaValue < 1.E-6 * scanEtaStep) { // !only <= 1.E6 steps allowed
134  G4cout << " Scan completed!" << G4endl;
135  return;
136  } else {
137  etaValue += scanEtaStep;
138  phiValue = phiMin;
139  }
140  } else {
141  phiValue += scanPhiStep;
142  }
143  G4double theta = std::atan(std::exp(-etaValue))*2.;
144 
145  G4double scanX = std::sin(theta)*std::cos(phiValue);
146  G4double scanY = std::sin(theta)*std::sin(phiValue);
147  G4double scanZ = std::cos(theta);
148  if (verboseLevel >= 2 ) {
149  G4cout << "Scan eta " << etaValue << " Phi " << phiValue/deg
150  << " theta " << theta/deg << G4endl;
151  }
152  particleDir = G4ThreeVector(scanX,scanY,scanZ);
154 #ifdef debug
155  if (verboseLevel > 2 ) {
156  G4cout << "Shooting in " << particleDir << " direction "<< G4endl;
157  }
158 #endif
159  scanSteps++;
160  }
161 
162  // Generate GEANT4 primary vertex
164 }
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
static double shoot()
Definition: RandFlat.cc:59
G4GLOB_DLL std::ostream G4cout
static const double deg
Definition: G4SIunits.hh:151
static const double GeV
Definition: G4SIunits.hh:214
void SetParticleEnergy(G4double aKineticEnergy)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ GetParticleEnergy()

G4double CCalPrimaryGeneratorAction::GetParticleEnergy ( )
inline

Definition at line 91 of file CCalPrimaryGeneratorAction.hh.

91 {return particleGun->GetParticleEnergy();}
G4double GetParticleEnergy() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetParticlePosition()

G4ThreeVector CCalPrimaryGeneratorAction::GetParticlePosition ( )
inline

Definition at line 90 of file CCalPrimaryGeneratorAction.hh.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void CCalPrimaryGeneratorAction::initialize ( )
private

Definition at line 336 of file CCalPrimaryGeneratorAction.cc.

336  {
337 
338  isInitialized = 1;
339 
340  print (1);
341 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

void CCalPrimaryGeneratorAction::print ( G4int  val)
private

Definition at line 344 of file CCalPrimaryGeneratorAction.cc.

344  {
345 
346 #ifdef debug
347  if (verboseLevel >= val) {
348 
349  if (generatorInput == singleRandom) {
350  G4cout << G4endl
351  << "**********************************************************************" << G4endl
352  << "* *" << G4endl
353  << "* CCalPrimaryGeneratorAction DEFAULT Random Energy/Direction setting:*" << G4endl
354  << "* *" << G4endl
355  << "* *" << G4endl
356  << "* Energy in [ "<< energyMin/GeV << " - " << energyMax/GeV << "] (GeV) "<< G4endl
357  << "* Phi angle in [ "<< phiMin << " - " << phiMax << "] (rad) "<< G4endl
358  << "* [ "<< phiMin/degree << " - " << phiMax/degree << "] (deg) "<< G4endl
359  << "* Eta in [ "<< etaMin << " - " << etaMax << "] "<< G4endl
360  << "* *" << G4endl
361  << "* *" << G4endl
362  << "**********************************************************************" << G4endl;
363  } else if (generatorInput == singleScan) {
364  G4cout << G4endl
365  << "**********************************************************************" << G4endl
366  << "* *" << G4endl
367  << "* CCalPrimaryGeneratorAction DEFAULT Scan Direction settings : *" << G4endl
368  << "* *" << G4endl
369  << "* *" << G4endl
370  << "* Phi angle in [ " << phiMin/degree << " - " << phiMax/degree << "] (deg) " << G4endl
371  << "* Eta in [ " << etaMin << " - " << etaMax << "] " << G4endl
372  << "* Steps along eta " << etaSteps << " and along phi " << phiSteps << G4endl
373  << "* *" << G4endl
374  << "* *" << G4endl
375  << "**********************************************************************" << G4endl;
376  } else if (generatorInput == singleFixed) {
377  G4cout << G4endl
378  << "*******************************************************************" << G4endl
379  << "* *" << G4endl
380  << "* CCalPrimaryGeneratorAction: Current settings : *" << G4endl
381  << "* *" << G4endl
382  << "* " << particleGun->GetNumberOfParticles()
384  << " of " << particleGun->GetParticleEnergy()/GeV << " GeV" << G4endl
385  << "* will be shot from " << particleGun->GetParticlePosition() << G4endl;
386  G4cout << "* in direction " << particleGun->GetParticleMomentumDirection() << G4endl;
387  G4cout << "* *" << G4endl
388  << "* *" << G4endl
389  << "*******************************************************************" << G4endl;
390  }
391  }
392 #endif
393 
394 }
G4ThreeVector GetParticlePosition()
G4ParticleMomentum GetParticleMomentumDirection() const
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
G4double GetParticleEnergy() const
static const double GeV
Definition: G4SIunits.hh:214
G4int GetNumberOfParticles() const
static const double degree
Definition: G4SIunits.hh:143
#define G4endl
Definition: G4ios.hh:61
G4ParticleDefinition * GetParticleDefinition() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetGunPosition()

void CCalPrimaryGeneratorAction::SetGunPosition ( const G4ThreeVector pos) const

Definition at line 327 of file CCalPrimaryGeneratorAction.cc.

327  {
328 
330 }
void SetParticlePosition(G4ThreeVector aPosition)
Here is the call graph for this function:

◆ SetMaximumEnergy()

void CCalPrimaryGeneratorAction::SetMaximumEnergy ( G4double  p)

Definition at line 215 of file CCalPrimaryGeneratorAction.cc.

215  {
216 
217  if (p <= 0.) {
218  G4cerr << "CCalPrimaryGeneratorAction::SetMaximumEnergy: value " << p/GeV
219  << "GeV is out of bounds, it will not be used" << G4endl;
220  G4cerr << " Should be >0. Please check" << G4endl;
221  } else {
222  energyMax = p;
223 #ifdef debug
224  if (verboseLevel >= 1 ) {
225  G4cout << " CCalPrimaryGeneratorAction: setting max. value of energy to "
226  << energyMax/GeV << " GeV " << G4endl;
227  }
228 #endif
229  }
230 }
G4GLOB_DLL std::ostream G4cout
static const double GeV
Definition: G4SIunits.hh:214
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetMaximumEta()

void CCalPrimaryGeneratorAction::SetMaximumEta ( G4double  p)

Definition at line 299 of file CCalPrimaryGeneratorAction.cc.

299  {
300 
301  etaMax = p;
302 #ifdef debug
303  if (verboseLevel >= 1 ) {
304  G4cout << " CCalPrimaryGeneratorAction: setting max. value of eta to "
305  << etaMax << G4endl;
306  }
307 #endif
308 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ SetMaximumPhi()

void CCalPrimaryGeneratorAction::SetMaximumPhi ( G4double  p)

Definition at line 251 of file CCalPrimaryGeneratorAction.cc.

251  {
252 
253  if (std::fabs(p)>2.*pi) {
254  G4cerr << "CCalPrimaryGeneratorAction::SetMaximumPhi: setting value quite "
255  << "large" << G4endl;
256  G4cerr << " Should be given in radians - Please check" << G4endl;
257  } else {
258  phiMax = std::fabs(p);
259 #ifdef debug
260  if (verboseLevel >= 1 ) {
261  G4cout << " CCalPrimaryGeneratorAction: setting max. value of phi to "
262  << phiMax << G4endl;
263  }
264 #endif
265  }
266 }
G4GLOB_DLL std::ostream G4cout
static const double pi
Definition: G4SIunits.hh:74
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetMinimumEnergy()

void CCalPrimaryGeneratorAction::SetMinimumEnergy ( G4double  p)

Definition at line 197 of file CCalPrimaryGeneratorAction.cc.

197  {
198 
199  if (p <= 0.) {
200  G4cerr << "CCalPrimaryGeneratorAction::SetMinimumEnergy: value " << p/GeV
201  << "GeV is out of bounds, it will not be used" << G4endl;
202  G4cerr << " Should be >0. Please check" << G4endl;
203  } else {
204  energyMin = p;
205 #ifdef debug
206  if (verboseLevel >= 1 ) {
207  G4cout << " CCalPrimaryGeneratorAction: setting min. value of energy to "
208  << energyMin/GeV << " GeV " << G4endl;
209  }
210 #endif
211  }
212 }
G4GLOB_DLL std::ostream G4cout
static const double GeV
Definition: G4SIunits.hh:214
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetMinimumEta()

void CCalPrimaryGeneratorAction::SetMinimumEta ( G4double  p)

Definition at line 287 of file CCalPrimaryGeneratorAction.cc.

287  {
288 
289  etaMin = p;
290 #ifdef debug
291  if (verboseLevel >= 1 ) {
292  G4cout << " CCalPrimaryGeneratorAction: setting min. value of eta to "
293  << etaMin << G4endl;
294  }
295 #endif
296 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ SetMinimumPhi()

void CCalPrimaryGeneratorAction::SetMinimumPhi ( G4double  p)

Definition at line 233 of file CCalPrimaryGeneratorAction.cc.

233  {
234 
235  if (std::fabs(p)>2.*pi) {
236  G4cerr << "CCalPrimaryGeneratorAction::SetMinimumPhi: setting value quite "
237  << "large" << G4endl;
238  G4cerr << " Should be given in radians - Please check" << G4endl;
239  } else {
240  phiMin = std::fabs(p);
241 #ifdef debug
242  if (verboseLevel >= 1 ) {
243  G4cout << " CCalPrimaryGeneratorAction: setting min. value of phi to "
244  << phiMin << G4endl;
245  }
246 #endif
247  }
248 }
G4GLOB_DLL std::ostream G4cout
static const double pi
Definition: G4SIunits.hh:74
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetRandom()

void CCalPrimaryGeneratorAction::SetRandom ( G4String  val)

Definition at line 172 of file CCalPrimaryGeneratorAction.cc.

172  {
173 
174  if (val=="on") {
176  print (1);
177  } else {
179  print (1);
180  }
181 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRunNo()

void CCalPrimaryGeneratorAction::SetRunNo ( G4int  val)

Definition at line 332 of file CCalPrimaryGeneratorAction.cc.

332  {
334 }
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetRunIDCounter(G4int i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetScan()

void CCalPrimaryGeneratorAction::SetScan ( G4String  val)

Definition at line 184 of file CCalPrimaryGeneratorAction.cc.

184  {
185 
186  if (val=="on") {
188  scanSteps = 0;
189  print (1);
190  } else {
192  print (1);
193  }
194 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetStepsEta()

void CCalPrimaryGeneratorAction::SetStepsEta ( G4int  val)

Definition at line 311 of file CCalPrimaryGeneratorAction.cc.

311  {
312 
313  if (val <= 0) {
314  G4cerr<<"CCalPrimaryGeneratorAction::SetStepsEta: value " << val << " is out of bounds, it will not be used"<<G4endl;
315  G4cerr<<" Should be > 0 Please check"<<G4endl;
316  } else {
317  etaSteps = val;
318 #ifdef debug
319  if (verboseLevel >= 1 ) {
320  G4cout << " CCalPrimaryGeneratorAction: setting no. of steps in eta to "
321  << etaSteps << G4endl;
322  }
323 #endif
324  }
325 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetStepsPhi()

void CCalPrimaryGeneratorAction::SetStepsPhi ( G4int  val)

Definition at line 269 of file CCalPrimaryGeneratorAction.cc.

269  {
270 
271  if (val <= 0) {
272  G4cerr << "CCalPrimaryGeneratorAction::SetStepsPhi: value " << val
273  << " is out of bounds, it will not be used" << G4endl;
274  G4cerr << " Should be > 0 Please check" << G4endl;
275  } else {
276  phiSteps = val;
277 #ifdef debug
278  if (verboseLevel >= 1 ) {
279  G4cout << " CCalPrimaryGeneratorAction: setting no. of steps in phi to "
280  << phiSteps << G4endl;
281  }
282 #endif
283  }
284 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ SetVerboseLevel()

void CCalPrimaryGeneratorAction::SetVerboseLevel ( G4int  val)

Definition at line 167 of file CCalPrimaryGeneratorAction.cc.

167  {
168  verboseLevel = val;
169 }
Here is the caller graph for this function:

Member Data Documentation

◆ energyMax

G4double CCalPrimaryGeneratorAction::energyMax
private

Definition at line 105 of file CCalPrimaryGeneratorAction.hh.

◆ energyMin

G4double CCalPrimaryGeneratorAction::energyMin
private

Definition at line 105 of file CCalPrimaryGeneratorAction.hh.

◆ etaMax

G4double CCalPrimaryGeneratorAction::etaMax
private

Definition at line 106 of file CCalPrimaryGeneratorAction.hh.

◆ etaMin

G4double CCalPrimaryGeneratorAction::etaMin
private

Definition at line 106 of file CCalPrimaryGeneratorAction.hh.

◆ etaSteps

G4int CCalPrimaryGeneratorAction::etaSteps
private

Definition at line 108 of file CCalPrimaryGeneratorAction.hh.

◆ etaValue

G4double CCalPrimaryGeneratorAction::etaValue
private

Definition at line 111 of file CCalPrimaryGeneratorAction.hh.

◆ generatorInput

generatorInputType CCalPrimaryGeneratorAction::generatorInput
private

Definition at line 96 of file CCalPrimaryGeneratorAction.hh.

◆ gunMessenger

CCalPrimaryGeneratorMessenger* CCalPrimaryGeneratorAction::gunMessenger
private

Definition at line 94 of file CCalPrimaryGeneratorAction.hh.

◆ isInitialized

G4int CCalPrimaryGeneratorAction::isInitialized
private

Definition at line 110 of file CCalPrimaryGeneratorAction.hh.

◆ n_particle

G4int CCalPrimaryGeneratorAction::n_particle
private

Definition at line 99 of file CCalPrimaryGeneratorAction.hh.

◆ particleDir

G4ThreeVector CCalPrimaryGeneratorAction::particleDir
private

Definition at line 103 of file CCalPrimaryGeneratorAction.hh.

◆ particleEnergy

G4double CCalPrimaryGeneratorAction::particleEnergy
private

Definition at line 101 of file CCalPrimaryGeneratorAction.hh.

◆ particleGun

G4ParticleGun* CCalPrimaryGeneratorAction::particleGun
private

Definition at line 95 of file CCalPrimaryGeneratorAction.hh.

◆ particleName

G4String CCalPrimaryGeneratorAction::particleName
private

Definition at line 100 of file CCalPrimaryGeneratorAction.hh.

◆ particlePosition

G4ThreeVector CCalPrimaryGeneratorAction::particlePosition
private

Definition at line 102 of file CCalPrimaryGeneratorAction.hh.

◆ phiMax

G4double CCalPrimaryGeneratorAction::phiMax
private

Definition at line 107 of file CCalPrimaryGeneratorAction.hh.

◆ phiMin

G4double CCalPrimaryGeneratorAction::phiMin
private

Definition at line 107 of file CCalPrimaryGeneratorAction.hh.

◆ phiSteps

G4int CCalPrimaryGeneratorAction::phiSteps
private

Definition at line 108 of file CCalPrimaryGeneratorAction.hh.

◆ phiValue

G4double CCalPrimaryGeneratorAction::phiValue
private

Definition at line 111 of file CCalPrimaryGeneratorAction.hh.

◆ scanSteps

G4int CCalPrimaryGeneratorAction::scanSteps
private

Definition at line 112 of file CCalPrimaryGeneratorAction.hh.

◆ verboseLevel

G4int CCalPrimaryGeneratorAction::verboseLevel
private

Definition at line 98 of file CCalPrimaryGeneratorAction.hh.


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