2 #include "TGenAcceptance.h"
3 #include "TLorentzVector.h"
9 TGenAcceptance::TGenAcceptance(
const char *name,
const char *title)
10 :TGenerator(name, title)
22 ResetBit(kThetaRange);
27 Bool_t TGenAcceptance::CheckPtYPhi(Float_t p[3])
const
33 return CheckPtYPhi(p[0], p[1], p[2]);
38 Bool_t TGenAcceptance::CheckPtYPhi(Float_t pt, Float_t y, Float_t phi)
const
44 if ( TestBit(kPtRange) && ( pt < fPtCutMin || pt > fPtCutMax ))
return kFALSE;
45 if ( TestBit(kPhiRange) && ( phi < fPhiCutMin || phi > fPhiCutMax ))
return kFALSE;
46 if ( TestBit(kYRange) && ( y < fYCutMin || y > fYCutMax ))
return kFALSE;
53 Bool_t TGenAcceptance::CheckPXYZ(Float_t p[3])
const
59 return CheckPXYZ(p[0], p[1], p[2]);
64 Bool_t TGenAcceptance::CheckPXYZ(Float_t px, Float_t py, Float_t pz)
const
77 if ( TestBit(kEtaRange)) {
79 Float_t theta = TMath::ATan2( TMath::Sqrt(px*px + py*py), pz);
80 Double_t eta = - TMath::Log(TMath::Tan(theta/2));
81 if ( eta < fEtaCutMin || eta > fEtaCutMax)
return kFALSE;
84 if ( TestBit(kPRange) ) {
86 Double_t p2 = px*px + py*py + pz*pz;
87 if ( p2 < fPCutMin*fPCutMin || p2 > fPCutMax*fPCutMax)
return kFALSE;
95 Bool_t TGenAcceptance::CheckCuts(TLorentzVector *v)
const
101 if (TestBit(kPtRange) && ( v->Pt() < fPtCutMin || v->Pt() > fPtCutMax ))
return kFALSE;
102 if (TestBit(kEtaRange) && (v->Eta() < fEtaCutMin || v->Eta() > fEtaCutMax))
return kFALSE;
103 if (TestBit(kYRange) && (v->Rapidity() < fYCutMin || v->Rapidity() > fYCutMax))
return kFALSE;
104 if (TestBit(kPRange) && (v->P() < fPCutMin || v->P() > fPCutMax))
return kFALSE;
106 if (TestBit(kPhiRange) && (v->Phi() < fPhiCutMin || v->Phi() > fPhiCutMax))
return kFALSE;
113 void TGenAcceptance::SetPtRange(Float_t lowPt, Float_t highPt)
118 const char *fName =
"SetPtRange";
119 const char *msg[2] = {
120 "%s transverse momentum [%f GeV/c] negative",
121 "Minimum transverse momentum greater than Maximum"
124 if (lowPt < 0)
Error(fName, msg[0],
"Minimum", lowPt);
125 if (highPt < 0)
Error(fName, msg[0],
"Maximum", highPt);
126 if (lowPt >= highPt)
Error(fName, msg[1]);
135 void TGenAcceptance::SetEtaRange(Float_t lowEta, Float_t highEta)
140 const char *fName =
"SetEtaRange";
141 const char *msg =
"Minimum Eta greater than Maximum";
143 if (lowEta >= highEta)
Error(fName, msg);
147 fEtaCutMax = highEta;
152 void TGenAcceptance::SetYRange(Float_t lowY, Float_t highY)
157 const char *fName =
"SetYRange";
158 const char *msg =
"Minumum Rapidity greater that Maximum";
160 if (lowY >= highY)
Error(fName, msg);
169 void TGenAcceptance::SetThetaRange(Float_t lowTheta, Float_t highTheta)
174 const char *fName =
"SetThetaRange";
175 const char *msg[2] = {
176 "%s Theta [ %f deg] out of scope 0-180 deg.",
177 "Minumum Theta greater than Maximum Theta"
180 if (lowTheta < 0 || lowTheta > 180)
Error(fName, msg[0],
"Minimum", lowTheta);
181 if (highTheta < 0 || highTheta > 180)
Error(fName, msg[0],
"Maximum", lowTheta);
182 if (lowTheta >= highTheta)
Error(fName,msg[1]);
184 Float_t lowEta = - TMath::Log(TMath::Tan(lowTheta/2));
185 Float_t highEta = - TMath::Log(TMath::Tan(highTheta/2));
187 SetEtaRange(lowEta, highEta);
196 void TGenAcceptance::SetPhiRange(Float_t lowPhi, Float_t highPhi)
202 fPhiCutMin = lowPhi * TMath::Pi() / 180;
203 fPhiCutMax = highPhi * TMath::Pi() / 180;
207 void TGenAcceptance::SetMomentumRange(Float_t lowP, Float_t highP)
213 const char *fName =
"SetMomentumRange";
214 const char *msg =
"Minimum momentum greater that Maximum";
216 if (lowP > highP)
Error(fName, msg);