49 generatorInput(
singleFixed), verboseLevel(0), n_particle(1),
50 particleName(
"pi-"), particleEnergy(100*
GeV), particlePosition(0.,0.,0.),
90 if (isInitialized == 0) initialize();
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);
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;
114 if (scanSteps == 0) {
115 scanPhiStep = (phiMax - phiMin) / phiSteps;
116 phiValue = phiMin - scanPhiStep;
120 scanEtaStep = (etaMax - etaMin) / etaSteps;
121 scanPhiStep = (phiMax - phiMin) / phiSteps;
123 if (verboseLevel > 2 ) {
124 G4cout <<
" scanEtaStep " << scanEtaStep <<
" # of Steps " << etaSteps
126 G4cout <<
" scanPhiStep " << scanPhiStep <<
" # of Steps " << phiSteps
132 if (phiMax - phiValue < 1.E-6 * scanPhiStep) {
133 if (etaMax - etaValue < 1.E-6 * scanEtaStep) {
137 etaValue += scanEtaStep;
141 phiValue += scanPhiStep;
143 G4double theta = std::atan(std::exp(-etaValue))*2.;
145 G4double scanX = std::sin(theta)*std::cos(phiValue);
146 G4double scanY = std::sin(theta)*std::sin(phiValue);
148 if (verboseLevel >= 2 ) {
149 G4cout <<
"Scan eta " << etaValue <<
" Phi " << phiValue/
deg
155 if (verboseLevel > 2 ) {
156 G4cout <<
"Shooting in " << particleDir <<
" direction "<<
G4endl;
200 G4cerr <<
"CCalPrimaryGeneratorAction::SetMinimumEnergy: value " << p/
GeV
201 <<
"GeV is out of bounds, it will not be used" <<
G4endl;
206 if (verboseLevel >= 1 ) {
207 G4cout <<
" CCalPrimaryGeneratorAction: setting min. value of energy to "
218 G4cerr <<
"CCalPrimaryGeneratorAction::SetMaximumEnergy: value " << p/
GeV
219 <<
"GeV is out of bounds, it will not be used" <<
G4endl;
224 if (verboseLevel >= 1 ) {
225 G4cout <<
" CCalPrimaryGeneratorAction: setting max. value of energy to "
235 if (std::fabs(p)>2.*
pi) {
236 G4cerr <<
"CCalPrimaryGeneratorAction::SetMinimumPhi: setting value quite "
238 G4cerr <<
" Should be given in radians - Please check" <<
G4endl;
240 phiMin = std::fabs(p);
242 if (verboseLevel >= 1 ) {
243 G4cout <<
" CCalPrimaryGeneratorAction: setting min. value of phi to "
253 if (std::fabs(p)>2.*
pi) {
254 G4cerr <<
"CCalPrimaryGeneratorAction::SetMaximumPhi: setting value quite "
256 G4cerr <<
" Should be given in radians - Please check" <<
G4endl;
258 phiMax = std::fabs(p);
260 if (verboseLevel >= 1 ) {
261 G4cout <<
" CCalPrimaryGeneratorAction: setting max. value of phi to "
272 G4cerr <<
"CCalPrimaryGeneratorAction::SetStepsPhi: value " << val
273 <<
" is out of bounds, it will not be used" <<
G4endl;
278 if (verboseLevel >= 1 ) {
279 G4cout <<
" CCalPrimaryGeneratorAction: setting no. of steps in phi to "
291 if (verboseLevel >= 1 ) {
292 G4cout <<
" CCalPrimaryGeneratorAction: setting min. value of eta to "
303 if (verboseLevel >= 1 ) {
304 G4cout <<
" CCalPrimaryGeneratorAction: setting max. value of eta to "
314 G4cerr<<
"CCalPrimaryGeneratorAction::SetStepsEta: value " << val <<
" is out of bounds, it will not be used"<<
G4endl;
319 if (verboseLevel >= 1 ) {
320 G4cout <<
" CCalPrimaryGeneratorAction: setting no. of steps in eta to "
336 void CCalPrimaryGeneratorAction::initialize(){
344 void CCalPrimaryGeneratorAction::print(
G4int val){
347 if (verboseLevel >= val) {
351 <<
"**********************************************************************" <<
G4endl
353 <<
"* CCalPrimaryGeneratorAction DEFAULT Random Energy/Direction setting:*" <<
G4endl
356 <<
"* Energy in [ "<< energyMin/
GeV <<
" - " << energyMax/
GeV <<
"] (GeV) "<<
G4endl
357 <<
"* Phi angle in [ "<< phiMin <<
" - " << phiMax <<
"] (rad) "<<
G4endl
359 <<
"* Eta in [ "<< etaMin <<
" - " << etaMax <<
"] "<<
G4endl
362 <<
"**********************************************************************" <<
G4endl;
365 <<
"**********************************************************************" <<
G4endl
367 <<
"* CCalPrimaryGeneratorAction DEFAULT Scan Direction settings : *" <<
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
375 <<
"**********************************************************************" <<
G4endl;
378 <<
"*******************************************************************" <<
G4endl
380 <<
"* CCalPrimaryGeneratorAction: Current settings : *" <<
G4endl
389 <<
"*******************************************************************" <<
G4endl;
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetVerboseLevel(G4int val)
CLHEP::Hep3Vector G4ThreeVector
void GeneratePrimaries(G4Event *anEvent)
void SetMinimumEta(G4double p)
~CCalPrimaryGeneratorAction()
void SetMaximumEta(G4double p)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
G4ThreeVector GetParticlePosition()
void SetStepsPhi(G4int val)
virtual void GeneratePrimaryVertex(G4Event *evt)
const G4String & GetParticleName() const
CCalPrimaryGeneratorAction()
void SetStepsEta(G4int val)
void SetScan(G4String val)
G4ParticleMomentum GetParticleMomentumDirection() const
void SetParticlePosition(G4ThreeVector aPosition)
G4GLOB_DLL std::ostream G4cout
void SetRandom(G4String val)
void SetGunPosition(const G4ThreeVector &pos) const
void SetMinimumEnergy(G4double p)
G4int GetNumberOfParticles() const
void SetParticleEnergy(G4double aKineticEnergy)
static G4RunManager * GetRunManager()
void SetMinimumPhi(G4double p)
static G4ParticleTable * GetParticleTable()
void SetRunIDCounter(G4int i)
G4ParticleDefinition * GetParticleDefinition() const
void SetMaximumEnergy(G4double p)
void SetMaximumPhi(G4double p)
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4double GetParticleEnergy() const
G4GLOB_DLL std::ostream G4cerr