Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 ()
 

Detailed Description

Definition at line 66 of file CCalPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

CCalPrimaryGeneratorAction::CCalPrimaryGeneratorAction ( )

Definition at line 49 of file CCalPrimaryGeneratorAction.cc.

49  : particleGun(0),
50  generatorInput(singleFixed), verboseLevel(0), n_particle(1),
51  particleName("pi-"), particleEnergy(100*GeV), particlePosition(0.,0.,0.),
52  particleDir(1.,1.,0.1), isInitialized(0), scanSteps(0) {
53 
54  //Initialise the messenger
55  gunMessenger = new CCalPrimaryGeneratorMessenger(this);
56 
57  //Default settings:
60  SetMinimumEta(0.);
61  SetMaximumEta(3.5);
63  SetMaximumPhi(360.*degree);
64  SetStepsPhi(1);
65  SetStepsEta(1);
66 
67  // Number of particles per gun
68  particleGun = new G4ParticleGun(n_particle);
69 
70  // Getting particle definition
72  G4ParticleDefinition* particle = particleTable->FindParticle(particleName);
73  particleGun->SetParticleDefinition(particle);
74 
75  // Setting particle properties
76  particleGun->SetParticleEnergy(particleEnergy);
77  particleGun->SetParticleMomentumDirection(particleDir);
78  particleGun->SetParticlePosition(particlePosition);
79  print(0);
80 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
static constexpr double TeV
Definition: G4SIunits.hh:218
void SetParticlePosition(G4ThreeVector aPosition)
static constexpr double degree
Definition: G4SIunits.hh:144
void print(G4double elem)
void SetParticleEnergy(G4double aKineticEnergy)
static G4ParticleTable * GetParticleTable()
static constexpr double GeV
Definition: G4SIunits.hh:217
G4bool isInitialized()
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

Here is the call graph for this function:

CCalPrimaryGeneratorAction::~CCalPrimaryGeneratorAction ( )

Definition at line 82 of file CCalPrimaryGeneratorAction.cc.

82  {
83  if (gunMessenger)
84  delete gunMessenger;
85  if (particleGun)
86  delete particleGun;
87 }

Member Function Documentation

void CCalPrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 89 of file CCalPrimaryGeneratorAction.cc.

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

Here is the call graph for this function:

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:

G4ThreeVector CCalPrimaryGeneratorAction::GetParticlePosition ( )
inline

Definition at line 90 of file CCalPrimaryGeneratorAction.hh.

90 {return particleGun->GetParticlePosition();}
G4ThreeVector GetParticlePosition()

Here is the call graph for this function:

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetGunPosition ( const G4ThreeVector pos) const

Definition at line 328 of file CCalPrimaryGeneratorAction.cc.

328  {
329 
330  particleGun->SetParticlePosition(pos);
331 }
void SetParticlePosition(G4ThreeVector aPosition)

Here is the call graph for this function:

void CCalPrimaryGeneratorAction::SetMaximumEnergy ( G4double  p)

Definition at line 216 of file CCalPrimaryGeneratorAction.cc.

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

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetMaximumEta ( G4double  p)

Definition at line 300 of file CCalPrimaryGeneratorAction.cc.

300  {
301 
302  etaMax = p;
303 #ifdef debug
304  if (verboseLevel >= 1 ) {
305  G4cout << " CCalPrimaryGeneratorAction: setting max. value of eta to "
306  << etaMax << G4endl;
307  }
308 #endif
309 }
const char * p
Definition: xmltok.h:285
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetMaximumPhi ( G4double  p)

Definition at line 252 of file CCalPrimaryGeneratorAction.cc.

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

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetMinimumEnergy ( G4double  p)

Definition at line 198 of file CCalPrimaryGeneratorAction.cc.

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

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetMinimumEta ( G4double  p)

Definition at line 288 of file CCalPrimaryGeneratorAction.cc.

288  {
289 
290  etaMin = p;
291 #ifdef debug
292  if (verboseLevel >= 1 ) {
293  G4cout << " CCalPrimaryGeneratorAction: setting min. value of eta to "
294  << etaMin << G4endl;
295  }
296 #endif
297 }
const char * p
Definition: xmltok.h:285
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetMinimumPhi ( G4double  p)

Definition at line 234 of file CCalPrimaryGeneratorAction.cc.

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

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetRandom ( G4String  val)

Definition at line 173 of file CCalPrimaryGeneratorAction.cc.

173  {
174 
175  if (val=="on") {
176  generatorInput = singleRandom;
177  print (1);
178  } else {
179  generatorInput = singleFixed;
180  print (1);
181  }
182 }
void print(G4double elem)

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetRunNo ( G4int  val)

Definition at line 333 of file CCalPrimaryGeneratorAction.cc.

333  {
335 }
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:

void CCalPrimaryGeneratorAction::SetScan ( G4String  val)

Definition at line 185 of file CCalPrimaryGeneratorAction.cc.

185  {
186 
187  if (val=="on") {
188  generatorInput = singleScan;
189  scanSteps = 0;
190  print (1);
191  } else {
192  generatorInput = singleFixed;
193  print (1);
194  }
195 }
void print(G4double elem)

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetStepsEta ( G4int  val)

Definition at line 312 of file CCalPrimaryGeneratorAction.cc.

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

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetStepsPhi ( G4int  val)

Definition at line 270 of file CCalPrimaryGeneratorAction.cc.

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

Here is the caller graph for this function:

void CCalPrimaryGeneratorAction::SetVerboseLevel ( G4int  val)

Definition at line 168 of file CCalPrimaryGeneratorAction.cc.

168  {
169  verboseLevel = val;
170 }

Here is the caller graph for this function:


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