FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndFixStepParticleGun Class Reference

#include <PndFixStepParticleGun.h>

Inheritance diagram for PndFixStepParticleGun:

Public Member Functions

 PndFixStepParticleGun ()
 
 PndFixStepParticleGun (Int_t pdgid, Int_t mult=1)
 
virtual ~PndFixStepParticleGun ()
 
void SetPDGType (Int_t pdg)
 
void SetMultiplicity (Int_t mult)
 
void SetPRange (Double32_t pmin=0, Double32_t pmax=10, Double32_t pstep=1)
 
void SetPtRange (Double32_t ptmin=0, Double32_t ptmax=10, Double32_t ptstep=1)
 
void SetPhiRange (Double32_t phimin=0, Double32_t phimax=360, Double32_t phistep=1)
 
void SetEtaRange (Double32_t etamin=-5, Double32_t etamax=7, Double32_t etastep=1)
 
void SetYRange (Double32_t ymin=-5, Double32_t ymax=7, Double32_t ystep=1)
 
void SetThetaRange (Double32_t thetamin=0, Double32_t thetamax=90, Double32_t thetastep=1)
 
void SetCosThetaRange (Double32_t costhetamin=-1, Double32_t costhetamax=1, Double32_t costhetastep=0.1)
 
void SetXYZ (Double32_t x=0, Double32_t y=0, Double32_t z=0)
 
void SetBoxXYZ (Double32_t x1=0, Double32_t y1=0, Double32_t x2=0, Double32_t y2=0, Double32_t z=0)
 
void SetDebug (Bool_t debug=0)
 
int GetNEvents ()
 
Bool_t Init ()
 
virtual Bool_t ReadEvent (FairPrimaryGenerator *primGen)
 

Private Member Functions

void CalcActValues (PndRangeValues *val1, PndRangeValues *val2, PndRangeValues *val3)
 
bool IsEndOfRanges (PndRangeValues *val1, PndRangeValues *val2, PndRangeValues *val3)
 
 ClassDef (PndFixStepParticleGun, 1)
 

Private Attributes

Int_t fPDGType
 
Int_t fMult
 
Int_t fEvent
 
Double32_t fPDGMass
 
PndRangeValues fPt
 
PndRangeValues fPhi
 
PndRangeValues fEta
 
PndRangeValues fRapidity
 
PndRangeValues fP
 
PndRangeValues fTheta
 
PndRangeValues fCosTheta
 
Double32_t fX
 
Double32_t fY
 
Double32_t fZ
 
Double32_t fX1
 
Double32_t fY1
 
Double32_t fX2
 
Double32_t fY2
 
Bool_t fEtaRangeIsSet
 
Bool_t fYRangeIsSet
 
Bool_t fThetaRangeIsSet
 
Bool_t fCosThetaIsSet
 
Bool_t fPtRangeIsSet
 
Bool_t fPRangeIsSet
 
Bool_t fPointVtxIsSet
 
Bool_t fBoxVtxIsSet
 
Bool_t fDebug
 
Bool_t fDoit
 
Bool_t fFirstRun
 

Detailed Description

Definition at line 47 of file PndFixStepParticleGun.h.

Constructor & Destructor Documentation

PndFixStepParticleGun::PndFixStepParticleGun ( )

Default constructor.

Definition at line 17 of file PndFixStepParticleGun.cxx.

References fEta, fP, fPhi, fPt, fRapidity, fTheta, PndRangeValues::SetStart(), PndRangeValues::SetStep(), and PndRangeValues::SetStop().

17  :
18  fPDGType(0),fMult(0),fEvent(0), fPDGMass(0),
19  fX(0),fY(0),fZ(0),
20  fX1(0),fY1(0),fX2(0),fY2(0),
23  fPointVtxIsSet(0),fBoxVtxIsSet(0),fDebug(0), fDoit(kTRUE), fFirstRun(kTRUE)
24 {
25  fPt.SetStart(0); fPt.SetStop(0); fPt.SetStep(0);
29  fP.SetStart(0);fP.SetStop(0); fP.SetStep(0);
31 }
void SetStep(Double32_t val)
void SetStop(Double32_t val)
void SetStart(Double32_t val)
PndFixStepParticleGun::PndFixStepParticleGun ( Int_t  pdgid,
Int_t  mult = 1 
)

Constructor with PDG-ID, multiplicity

Parameters
pdgidParticle type (PDG encoding)
multMultiplicity (default is 1)

Definition at line 34 of file PndFixStepParticleGun.cxx.

References fEta, fP, fPhi, fPt, fRapidity, fTheta, SetPhiRange(), PndRangeValues::SetStart(), PndRangeValues::SetStep(), and PndRangeValues::SetStop().

34  :
35  fPDGType(pdgid),fMult(mult), fEvent(0),fPDGMass(0),
36  fX(0),fY(0),fZ(0),
37  fX1(0),fY1(0),fX2(0),fY2(0),
40  fPointVtxIsSet(0),fBoxVtxIsSet(0),fDebug(1), fDoit(kTRUE), fFirstRun(kTRUE)
41 {
42  // Constructor. Set default kinematics limits
43  fPt.SetStart(0); fPt.SetStop(0); fPt.SetStep(0);
47  fP.SetStart(0);fP.SetStop(0); fP.SetStep(0);
49 
50  SetPhiRange();
51 }
void SetStep(Double32_t val)
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360, Double32_t phistep=1)
void SetStop(Double32_t val)
void SetStart(Double32_t val)
Double_t mult
virtual PndFixStepParticleGun::~PndFixStepParticleGun ( )
inlinevirtual

Destructor

Definition at line 61 of file PndFixStepParticleGun.h.

61 {};

Member Function Documentation

void PndFixStepParticleGun::CalcActValues ( PndRangeValues val1,
PndRangeValues val2,
PndRangeValues val3 
)
private

Definition at line 167 of file PndFixStepParticleGun.cxx.

References PndRangeValues::fActualValue, fDoit, fEvent, fFirstRun, PndRangeValues::fStart, PndRangeValues::fStep, and PndRangeValues::fStop.

Referenced by ReadEvent().

168 {
169  if (val1 == 0)
170  val1 = new PndRangeValues();
171  if (val2 == 0)
172  val2 = new PndRangeValues();
173  if (val3 == 0)
174  val3 = new PndRangeValues();
175 
176  if (fDoit){
177  if (fFirstRun == kTRUE){
178  fFirstRun = kFALSE;
179  }
180  else {
181  val3->fActualValue += val3->fStep;
182  }
183  if (val3->fActualValue > val3->fStop && fDoit){
184  val3->fActualValue = val3->fStart;
185  val2->fActualValue += val2->fStep;
186  if (val2->fActualValue > val2->fStop && fDoit){
187  val2->fActualValue = val2->fStart;
188  val1->fActualValue += val1->fStep;
189  if (val1->fActualValue > val1->fStop && fDoit){
190  fDoit = false;
191  }
192  }
193  }
194  }
195  if (fDoit) fEvent++;
196  else
197  std::cout << "End of range reached at EventNr: " << fEvent << std::endl;
198 }
PndFixStepParticleGun::ClassDef ( PndFixStepParticleGun  ,
 
)
private
int PndFixStepParticleGun::GetNEvents ( )
Bool_t PndFixStepParticleGun::Init ( )

Initializer

Definition at line 53 of file PndFixStepParticleGun.cxx.

References fBoxVtxIsSet, fEtaRangeIsSet, fPDGMass, fPDGType, fPhi, fPointVtxIsSet, fPRangeIsSet, fPtRangeIsSet, PndRangeValues::fStart, PndRangeValues::fStop, fThetaRangeIsSet, fYRangeIsSet, and particle.

54 {
55  // Initialize generator
56 
57  if (fPhi.fStop-fPhi.fStart>360)
58  Fatal("Init()","PndFixStepParticleGun: phi range is too wide: %f<phi<%f",
61  Fatal("Init()","PndFixStepParticleGun: Cannot set P and Pt ranges simultaneously");
63  Fatal("Init()","PndFixStepParticleGun: Cannot set P and Y ranges simultaneously");
64  if ( (fThetaRangeIsSet && fYRangeIsSet) ||
67  Fatal("Init()","PndFixStepParticleGun: Cannot set Y, Theta or Eta ranges simultaneously");
69  Fatal("Init()","PndFixStepParticleGun: Cannot set point and box vertices simultaneously");
70 
71  // Check for particle type
72  TDatabasePDG* pdgBase = TDatabasePDG::Instance();
73  TParticlePDG *particle = pdgBase->GetParticle(fPDGType);
74  if (! particle) Fatal("PndFixStepParticleGun","PDG code %d not defined.",fPDGType);
75  fPDGMass = particle->Mass();
76  return kTRUE;
77 }
const int particle
bool PndFixStepParticleGun::IsEndOfRanges ( PndRangeValues val1,
PndRangeValues val2,
PndRangeValues val3 
)
private

Definition at line 200 of file PndFixStepParticleGun.cxx.

References PndRangeValues::fActualValue, PndRangeValues::fStep, and PndRangeValues::fStop.

Referenced by ReadEvent().

200  {
201  if ((val1 == 0 || (val1->fActualValue + val1->fStep) > val1->fStop) &&
202  (val2 == 0 || (val2->fActualValue + val2->fStep) > val2->fStop) &&
203  (val3 == 0 || (val3->fActualValue + val3->fStep) > val3->fStop))
204  return true;
205  else
206  return false;
207 }
Bool_t PndFixStepParticleGun::ReadEvent ( FairPrimaryGenerator *  primGen)
virtual

Creates an event with given type and multiplicity.

Parameters
primGenpointer to the PndPrimaryGenerator

Definition at line 80 of file PndFixStepParticleGun.cxx.

References acos(), CalcActValues(), CAMath::Cos(), eta, PndRangeValues::fActualValue, fCosTheta, fCosThetaIsSet, fDebug, fEta, fEtaRangeIsSet, fP, fPDGMass, fPDGType, fPhi, fPRangeIsSet, fPt, fPtRangeIsSet, fRapidity, fTheta, fThetaRangeIsSet, fX, fY, fYRangeIsSet, fZ, IsEndOfRanges(), phi, printf(), pt(), pz, CAMath::Sin(), CAMath::Sqrt(), CAMath::Tan(), theta, and y.

81 {
82  // Generate one event: produce primary particles emitted from one vertex.
83  // Primary particles are distributed uniformly along
84  // those kinematics variables which were limitted by setters.
85  // if SetCosTheta() function is used, the distribution will be uniform in
86  // cos(theta)
87 
88  Double32_t pabs=0, phi, pt=0, theta=0, eta, y, mt, px, py, pz=0;
89 
90  // Generate particles
91  PndRangeValues* outerVal = &fPhi;
92  PndRangeValues* midVal = 0;
93  PndRangeValues* innerVal = 0;
94  if (fThetaRangeIsSet){
95  if (fCosThetaIsSet){
96  midVal = &fCosTheta;
97  //std::cout << "CosTheta selected: " << midVal->fStart << " " << midVal->fStop << " " << midVal->fStep << " " << midVal->fActualValue << " " <<std::endl;
98  } else
99  midVal = &fTheta;
100  }
101  else if (fEtaRangeIsSet)
102  midVal = &fEta;
103  else if (fYRangeIsSet)
104  midVal = &fRapidity;
105 
106  if (fPtRangeIsSet)
107  innerVal = &fPt;
108  else if (fPRangeIsSet)
109  innerVal = &fP;
110 
111  if (IsEndOfRanges(outerVal, midVal, innerVal) == true) return kTRUE;
112 
113  CalcActValues(outerVal, midVal, innerVal);
114  // std::cout << "outerVal, midVal, innerVal: " << outerVal->fActualValue << " " << midVal->fActualValue << " " << innerVal->fActualValue << std::endl;
115  // std::cout << "phi, cosTheta, p: " << fPhi.fActualValue << " " << fCosTheta.fActualValue << " " << fP.fActualValue << std::endl;
116 
117  if (fPRangeIsSet ) pabs = fP.fActualValue;
118  else if (fPtRangeIsSet) pt = fPt.fActualValue;
119 
120  phi = fPhi.fActualValue * TMath::DegToRad();
121 
122 
123  if(fThetaRangeIsSet) {
124  if (fCosThetaIsSet)
126  else
127  theta = fTheta.fActualValue * TMath::DegToRad();
128  }
129 
130  else if (fEtaRangeIsSet) {
132  theta = 2*TMath::ATan(TMath::Exp(-eta));
133  }
134  else if (fYRangeIsSet) {
136  mt = TMath::Sqrt(fPDGMass*fPDGMass + pt*pt);
137  pz = mt * TMath::SinH(y);
138  }
139 
141  if (fPRangeIsSet ) {
142  pz = pabs*TMath::Cos(theta);
143  pt = pabs*TMath::Sin(theta);
144  }
145  else if (fPtRangeIsSet)
146  pz = pt/TMath::Tan(theta);
147  }
148 
149  px = pt*TMath::Cos(phi);
150  py = pt*TMath::Sin(phi);
151 
152 /* if (fBoxVtxIsSet) {
153  fX = gRandom->Uniform(fX1,fX2);
154  fY = gRandom->Uniform(fY1,fY2);
155  }
156 */
157  if (fDebug)
158  printf("FlatGen: kf=%d, p=(%.2f, %.2f, %.2f) GeV, x=(%.1f, %.1f, %.1f) cm, Theta=%.1f phi=%.1f\n",
159  fPDGType, px, py, pz, fX, fY, fZ, theta*TMath::RadToDeg(), phi*TMath::RadToDeg());
160 
161  primGen->AddTrack(fPDGType, px, py, pz, fX, fY, fZ);
162  // }
163  return kTRUE;
164 
165 }
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
static T Sin(const T &x)
Definition: PndCAMath.h:42
bool IsEndOfRanges(PndRangeValues *val1, PndRangeValues *val2, PndRangeValues *val3)
float Tan(float x)
Definition: PndCAMath.h:165
static T Cos(const T &x)
Definition: PndCAMath.h:43
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
TString pt(TString pts, TString exts="px py pz")
Definition: invexp.C:133
void CalcActValues(PndRangeValues *val1, PndRangeValues *val2, PndRangeValues *val3)
TParticlePDG * eta
Double_t y
double pz[39]
Definition: pipisigmas.h:14
void PndFixStepParticleGun::SetBoxXYZ ( Double32_t  x1 = 0,
Double32_t  y1 = 0,
Double32_t  x2 = 0,
Double32_t  y2 = 0,
Double32_t  z = 0 
)
inline

Definition at line 92 of file PndFixStepParticleGun.h.

References fBoxVtxIsSet, fX1, fX2, fY1, fY2, fZ, and z.

void PndFixStepParticleGun::SetCosThetaRange ( Double32_t  costhetamin = -1,
Double32_t  costhetamax = 1,
Double32_t  costhetastep = 0.1 
)
inline
void PndFixStepParticleGun::SetDebug ( Bool_t  debug = 0)
inline

Definition at line 95 of file PndFixStepParticleGun.h.

References fDebug.

Referenced by sim_radlength_complete().

95 {fDebug = debug;}
void PndFixStepParticleGun::SetEtaRange ( Double32_t  etamin = -5,
Double32_t  etamax = 7,
Double32_t  etastep = 1 
)
inline

Definition at line 77 of file PndFixStepParticleGun.h.

References fEta, fEtaRangeIsSet, PndRangeValues::SetStart(), PndRangeValues::SetStep(), and PndRangeValues::SetStop().

78  {fEta.SetStart(etamin); fEta.SetStop(etamax); fEta.SetStep(etastep); fEtaRangeIsSet=kTRUE;};
void SetStep(Double32_t val)
void SetStop(Double32_t val)
void SetStart(Double32_t val)
void PndFixStepParticleGun::SetMultiplicity ( Int_t  mult)
inline

Definition at line 66 of file PndFixStepParticleGun.h.

References fMult, and mult.

66 {fMult = mult; };
Double_t mult
void PndFixStepParticleGun::SetPDGType ( Int_t  pdg)
inline

Modifiers

Definition at line 64 of file PndFixStepParticleGun.h.

References fPDGType.

Referenced by Mrun_sim1_PndFlatGen(), and sim_radlength_complete().

64 {fPDGType = pdg; };
void PndFixStepParticleGun::SetPhiRange ( Double32_t  phimin = 0,
Double32_t  phimax = 360,
Double32_t  phistep = 1 
)
inline

Definition at line 74 of file PndFixStepParticleGun.h.

References fPhi, PndRangeValues::SetStart(), PndRangeValues::SetStep(), and PndRangeValues::SetStop().

Referenced by Mrun_sim1_PndFlatGen(), PndFixStepParticleGun(), and sim_radlength_complete().

75  {fPhi.SetStart(phimin); fPhi.SetStop(phimax); fPhi.SetStep(phistep);};
void SetStep(Double32_t val)
void SetStop(Double32_t val)
void SetStart(Double32_t val)
void PndFixStepParticleGun::SetPRange ( Double32_t  pmin = 0,
Double32_t  pmax = 10,
Double32_t  pstep = 1 
)
inline
void PndFixStepParticleGun::SetPtRange ( Double32_t  ptmin = 0,
Double32_t  ptmax = 10,
Double32_t  ptstep = 1 
)
inline

Definition at line 71 of file PndFixStepParticleGun.h.

References fPt, fPtRangeIsSet, PndRangeValues::SetStart(), PndRangeValues::SetStep(), and PndRangeValues::SetStop().

72  {fPt.SetStart(ptmin); fPt.SetStop(ptmax); fPt.SetStep(ptstep); fPtRangeIsSet=kTRUE;};
void SetStep(Double32_t val)
void SetStop(Double32_t val)
void SetStart(Double32_t val)
void PndFixStepParticleGun::SetThetaRange ( Double32_t  thetamin = 0,
Double32_t  thetamax = 90,
Double32_t  thetastep = 1 
)
inline
void PndFixStepParticleGun::SetXYZ ( Double32_t  x = 0,
Double32_t  y = 0,
Double32_t  z = 0 
)
inline

Definition at line 89 of file PndFixStepParticleGun.h.

References fPointVtxIsSet, fX, fY, fZ, x, y, and z.

void PndFixStepParticleGun::SetYRange ( Double32_t  ymin = -5,
Double32_t  ymax = 7,
Double32_t  ystep = 1 
)
inline

Member Data Documentation

Bool_t PndFixStepParticleGun::fBoxVtxIsSet
private

Definition at line 137 of file PndFixStepParticleGun.h.

Referenced by Init(), and SetBoxXYZ().

PndRangeValues PndFixStepParticleGun::fCosTheta
private

Definition at line 125 of file PndFixStepParticleGun.h.

Referenced by GetNEvents(), ReadEvent(), and SetCosThetaRange().

Bool_t PndFixStepParticleGun::fCosThetaIsSet
private

Definition at line 132 of file PndFixStepParticleGun.h.

Referenced by ReadEvent(), and SetCosThetaRange().

Bool_t PndFixStepParticleGun::fDebug
private

Definition at line 138 of file PndFixStepParticleGun.h.

Referenced by ReadEvent(), and SetDebug().

Bool_t PndFixStepParticleGun::fDoit
private

Definition at line 139 of file PndFixStepParticleGun.h.

Referenced by CalcActValues().

PndRangeValues PndFixStepParticleGun::fEta
private

Definition at line 118 of file PndFixStepParticleGun.h.

Referenced by GetNEvents(), PndFixStepParticleGun(), ReadEvent(), and SetEtaRange().

Bool_t PndFixStepParticleGun::fEtaRangeIsSet
private

Definition at line 129 of file PndFixStepParticleGun.h.

Referenced by Init(), ReadEvent(), and SetEtaRange().

Int_t PndFixStepParticleGun::fEvent
private

Definition at line 110 of file PndFixStepParticleGun.h.

Referenced by CalcActValues().

Bool_t PndFixStepParticleGun::fFirstRun
private

Definition at line 140 of file PndFixStepParticleGun.h.

Referenced by CalcActValues().

Int_t PndFixStepParticleGun::fMult
private

Definition at line 109 of file PndFixStepParticleGun.h.

Referenced by SetMultiplicity().

PndRangeValues PndFixStepParticleGun::fP
private

Definition at line 122 of file PndFixStepParticleGun.h.

Referenced by GetNEvents(), PndFixStepParticleGun(), ReadEvent(), and SetPRange().

Double32_t PndFixStepParticleGun::fPDGMass
private

Definition at line 112 of file PndFixStepParticleGun.h.

Referenced by Init(), and ReadEvent().

Int_t PndFixStepParticleGun::fPDGType
private

Definition at line 108 of file PndFixStepParticleGun.h.

Referenced by Init(), ReadEvent(), and SetPDGType().

PndRangeValues PndFixStepParticleGun::fPhi
private
Bool_t PndFixStepParticleGun::fPointVtxIsSet
private

Definition at line 136 of file PndFixStepParticleGun.h.

Referenced by Init(), and SetXYZ().

Bool_t PndFixStepParticleGun::fPRangeIsSet
private

Definition at line 135 of file PndFixStepParticleGun.h.

Referenced by Init(), ReadEvent(), and SetPRange().

PndRangeValues PndFixStepParticleGun::fPt
private

Definition at line 114 of file PndFixStepParticleGun.h.

Referenced by GetNEvents(), PndFixStepParticleGun(), ReadEvent(), and SetPtRange().

Bool_t PndFixStepParticleGun::fPtRangeIsSet
private

Definition at line 134 of file PndFixStepParticleGun.h.

Referenced by Init(), ReadEvent(), and SetPtRange().

PndRangeValues PndFixStepParticleGun::fRapidity
private

Definition at line 120 of file PndFixStepParticleGun.h.

Referenced by GetNEvents(), PndFixStepParticleGun(), ReadEvent(), and SetYRange().

PndRangeValues PndFixStepParticleGun::fTheta
private
Bool_t PndFixStepParticleGun::fThetaRangeIsSet
private

Definition at line 131 of file PndFixStepParticleGun.h.

Referenced by Init(), ReadEvent(), SetCosThetaRange(), and SetThetaRange().

Double32_t PndFixStepParticleGun::fX
private

Definition at line 126 of file PndFixStepParticleGun.h.

Referenced by ReadEvent(), and SetXYZ().

Double32_t PndFixStepParticleGun::fX1
private

Definition at line 127 of file PndFixStepParticleGun.h.

Referenced by SetBoxXYZ().

Double32_t PndFixStepParticleGun::fX2
private

Definition at line 127 of file PndFixStepParticleGun.h.

Referenced by SetBoxXYZ().

Double32_t PndFixStepParticleGun::fY
private

Definition at line 126 of file PndFixStepParticleGun.h.

Referenced by ReadEvent(), and SetXYZ().

Double32_t PndFixStepParticleGun::fY1
private

Definition at line 127 of file PndFixStepParticleGun.h.

Referenced by SetBoxXYZ().

Double32_t PndFixStepParticleGun::fY2
private

Definition at line 127 of file PndFixStepParticleGun.h.

Referenced by SetBoxXYZ().

Bool_t PndFixStepParticleGun::fYRangeIsSet
private

Definition at line 130 of file PndFixStepParticleGun.h.

Referenced by Init(), ReadEvent(), and SetYRange().

Double32_t PndFixStepParticleGun::fZ
private

Definition at line 126 of file PndFixStepParticleGun.h.

Referenced by ReadEvent(), SetBoxXYZ(), and SetXYZ().


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