34 #include <TDatabasePDG.h>
37 #include <TParticlePDG.h>
103 Double_t X1 = TMath::Min(x1, x2);
104 Double_t X2 = TMath::Max(x1, x2);
105 Double_t Y1 = TMath::Min(y1, y2);
106 Double_t Y2 = TMath::Max(y1, y2);
107 Double_t dX = 0.5 * (X2 - X1);
108 Double_t dY = 0.5 * (Y2 - Y1);
109 Double_t x = 0.5 * (X1 + X2);
110 Double_t y = 0.5 * (Y1 + Y2);
120 TDatabasePDG* pdgBase = TDatabasePDG::Instance();
121 TParticlePDG* particle = pdgBase->GetParticle(
GetPDGType());
124 LOG(fatal) <<
"FairBoxGenerator: PDG " <<
GetPDGType() <<
" not defined";
127 if (fPhiMax - fPhiMin > 360) {
128 LOG(fatal) <<
"FairBoxGenerator:Init(): phi range is too wide: " << fPhiMin <<
"<phi<" << fPhiMax;
130 if (fEkinRangeIsSet) {
132 LOG(fatal) <<
"FairBoxGenerator:Init(): Cannot set P and Ekin ranges simultaneously";
135 fPMin = TMath::Sqrt(fEkinMin * fEkinMin + 2 * fEkinMin *
GetPDGMass());
136 fPMax = TMath::Sqrt(fEkinMax * fEkinMax + 2 * fEkinMax *
GetPDGMass());
137 fPRangeIsSet = kTRUE;
138 fEkinRangeIsSet = kFALSE;
141 if (fPRangeIsSet && fPtRangeIsSet) {
142 LOG(fatal) <<
"FairBoxGenerator:Init(): Cannot set P and Pt ranges simultaneously";
144 if (fPRangeIsSet && fYRangeIsSet) {
145 LOG(fatal) <<
"FairBoxGenerator:Init(): Cannot set P and Y ranges simultaneously";
147 if ((fThetaRangeIsSet && fYRangeIsSet) || (fThetaRangeIsSet && fEtaRangeIsSet)
148 || (fYRangeIsSet && fEtaRangeIsSet)) {
149 LOG(fatal) <<
"FairBoxGenerator:Init(): Cannot set Y, Theta or Eta ranges simultaneously";
162 Double32_t pabs = 0, phi, pt = 0, theta = 0, eta, y, mt, px, py, pz = 0;
166 phi = gRandom->Uniform(fPhiMin, fPhiMax) * TMath::DegToRad();
169 pabs = gRandom->Uniform(fPMin, fPMax);
170 }
else if (fPtRangeIsSet) {
171 pt = gRandom->Uniform(fPtMin, fPtMax);
174 if (fThetaRangeIsSet) {
176 theta = acos(gRandom->Uniform(cos(fThetaMin * TMath::DegToRad()), cos(fThetaMax * TMath::DegToRad())));
178 theta = gRandom->Uniform(fThetaMin, fThetaMax) * TMath::DegToRad();
180 }
else if (fEtaRangeIsSet) {
181 eta = gRandom->Uniform(fEtaMin, fEtaMax);
182 theta = 2 * TMath::ATan(TMath::Exp(-eta));
183 }
else if (fYRangeIsSet) {
184 y = gRandom->Uniform(fYMin, fYMax);
186 pz = mt * TMath::SinH(y);
189 if (fThetaRangeIsSet || fEtaRangeIsSet) {
191 pz = pabs * TMath::Cos(theta);
192 pt = pabs * TMath::Sin(theta);
193 }
else if (fPtRangeIsSet) {
194 pz = pt / TMath::Tan(theta);
198 px = pt * TMath::Cos(phi);
199 py = pt * TMath::Sin(phi);
201 LOG(debug) <<
"FairBoxGen: " << Form(
"PDG %i p=(%.2f, %.2f, %.2f) GeV,",
GetPDGType(), px, py, pz);
void SetMultiplicity(Int_t mult)
ClassImp(FairEventBuilder)
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
virtual FairGenerator * CloneGenerator() const
void SetPDGType(Int_t pdg)
void SetBoxXYZ(Double32_t x1=0, Double32_t y1=0, Double32_t x2=0, Double32_t y2=0, Double32_t z=0)
virtual void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz, Double_t vx, Double_t vy, Double_t vz, Int_t parent=-1, Bool_t wanttracking=true, Double_t e=-9e9, Double_t tof=0., Double_t weight=0., TMCProcess proc=kPPrimary)
Double_t GetPDGMass() const
virtual void GenerateEventParameters()
void SetVertex(Double_t vx, Double_t vy, Double_t vz, Double_t evx=0, Double_t evy=0, Double_t evz=0, eVertexSmear sm=kBox)
Int_t GetMultiplicity() const
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)