7 #include "StJetTrack.h"
8 #include "StJetTower.h"
9 #include "StJetCandidate.h"
13 StJetCandidate::StJetCandidate(
const TVector3&
vertex,
const TLorentzVector& fourMomentum,
float area,
float area_error)
14 : mPt(fourMomentum.Pt())
15 , mEta(fourMomentum.Eta())
16 , mPhi(fourMomentum.Phi())
17 , mE(fourMomentum.E())
19 , mAreaError(area_error)
21 mDetEta = detEta(vertex);
24 float StJetCandidate::detEta(
const TVector3&
vertex)
const
27 if (getBarrelDetectorEta(vertex,DetEta))
return DetEta;
28 if (getEndcapDetectorEta(vertex,DetEta))
return DetEta;
32 bool StJetCandidate::getBarrelDetectorEta(
const TVector3& vertex,
float& detEta)
const
36 static const double BEMC_RADIUS = 225.405;
39 static const double EEMC_Z = 270.190;
40 TVector3 pos = momentum();
41 pos.SetMag(BEMC_RADIUS/pos.Unit().Perp());
45 return fabs(pos.Z()) < EEMC_Z;
48 bool StJetCandidate::getEndcapDetectorEta(
const TVector3& vertex,
float& detEta)
const
52 static const double EEMC_Z = 270.190;
53 TVector3 pos = momentum();
56 pos.SetMag((EEMC_Z-vertex.z())/pos.Unit().z());
62 TVector3 pos2(pos.x(),pos.y(),-pos.z());
63 TVector3 vertex2(vertex.x(),vertex.y(),-vertex.z());
64 pos2.SetMag((EEMC_Z-vertex2.z())/pos2.Unit().z());
69 return fabs(detEta) < 2.5;
72 StJetTrack* StJetCandidate::leadingChargedParticle()
const
75 for (
int i = 0; i < numberOfTracks(); ++i) {
77 if (!lcp || t->pt() > lcp->pt()) lcp = t;
82 float StJetCandidate::deltaR(
const StJetElement* element)
const
84 return momentum().DeltaR(element->momentum());
87 float StJetCandidate::sumTrackPt()
const
90 for (
int i = 0; i < numberOfTracks(); ++i) s +=
track(i)->pt();
94 float StJetCandidate::sumTrackPt(
float radius)
const
97 for (
int i = 0; i < numberOfTracks(); ++i) {
99 if (deltaR(t) < radius) s += t->pt();
104 float StJetCandidate::sumTowerPt()
const
107 for (
int i = 0; i < numberOfTowers(); ++i) s += tower(i)->pt();
111 float StJetCandidate::sumTowerPt(
float radius)
const
114 for (
int i = 0; i < numberOfTowers(); ++i) {
116 if (deltaR(t) < radius) s += t->pt();
121 StJetTrack* StJetCandidate::getTrackById(
int id)
const
123 for (
int i = 0; i < numberOfTracks(); ++i) {
125 if (t->id() == id)
return t;
130 StJetTower* StJetCandidate::getTowerById(
int id)
const
132 for (
int i = 0; i < numberOfTowers(); ++i) {
134 if (t->id() == id)
return t;
139 float StJetCandidate::getJetPatchPhi(
int jetPatch)
141 return TVector2::Phi_mpi_pi((150 - (jetPatch % 6) * 60) * TMath::DegToRad());
144 bool StJetCandidate::getBarrelJetPatchEtaPhi(
int jetPatch,
float& eta,
float& phi)
154 if (jetPatch < 0 || jetPatch >= 18)
return false;
185 if (jetPatch >= 0 && jetPatch < 6) eta = 0.5;
186 if (jetPatch >= 6 && jetPatch < 12) eta = -0.5;
187 if (jetPatch >= 12 && jetPatch < 18) eta = -0.1;
189 phi = getJetPatchPhi(jetPatch);
194 bool StJetCandidate::getEndcapJetPatchEtaPhi(
int jetPatch,
float& eta,
float& phi)
196 if (jetPatch >= 0 && jetPatch < 6)
201 phi = getJetPatchPhi(jetPatch);
206 bool StJetCandidate::getOverlapJetPatchEtaPhi(
int jetPatch,
float& eta,
float& phi)
208 if (jetPatch >= 0 && jetPatch < 6)
213 phi = getJetPatchPhi(jetPatch);
218 bool StJetCandidate::getBarrelJetPatchId(
float eta,
float phi,
int&
id)
231 if (eta < -1 || eta > 1)
return false;
234 if (phi < -M_PI || phi > M_PI) phi = TVector2::Phi_mpi_pi(phi);
237 static const double PI_OVER_3 = M_PI/3;
239 if (0 <= eta && eta <= 1) {
240 if ( 2*PI_OVER_3 <= phi && phi < M_PI)
id = 0;
241 if ( PI_OVER_3 <= phi && phi < 2*PI_OVER_3)
id = 1;
242 if ( 0 <= phi && phi < PI_OVER_3)
id = 2;
243 if ( -PI_OVER_3 <= phi && phi < 0)
id = 3;
244 if (-2*PI_OVER_3 <= phi && phi < -PI_OVER_3)
id = 4;
245 if ( -M_PI <= phi && phi < -2*PI_OVER_3)
id = 5;
248 if (-1 <= eta && eta < 0) {
249 if ( 2*PI_OVER_3 <= phi && phi < M_PI)
id = 6;
250 if ( PI_OVER_3 <= phi && phi < 2*PI_OVER_3)
id = 7;
251 if ( 0 <= phi && phi < PI_OVER_3)
id = 8;
252 if ( -PI_OVER_3 <= phi && phi < 0)
id = 9;
253 if (-2*PI_OVER_3 <= phi && phi < -PI_OVER_3)
id = 10;
254 if ( -M_PI <= phi && phi < -2*PI_OVER_3)
id = 11;
257 return (0 <=
id &&
id < 12);
260 bool StJetCandidate::getEndcapJetPatchId(
float eta,
float phi,
int&
id)
266 if (eta < 1 || eta > 2)
return false;
269 if (phi < -M_PI || phi > M_PI) phi = TVector2::Phi_mpi_pi(phi);
272 static const double PI_OVER_3 = M_PI/3;
274 if (1 <= eta && eta <= 2) {
275 if ( 2*PI_OVER_3 <= phi && phi < M_PI)
id = 0;
276 if ( PI_OVER_3 <= phi && phi < 2*PI_OVER_3)
id = 1;
277 if ( 0 <= phi && phi < PI_OVER_3)
id = 2;
278 if ( -PI_OVER_3 <= phi && phi < 0)
id = 3;
279 if (-2*PI_OVER_3 <= phi && phi < -PI_OVER_3)
id = 4;
280 if ( -M_PI <= phi && phi < -2*PI_OVER_3)
id = 5;
283 return (0 <=
id &&
id < 6);
286 bool StJetCandidate::getOverlapJetPatchId(
float eta,
float phi,
int&
id)
292 if (eta < 0.4 || eta > 1.4)
return false;
295 if (phi < -M_PI || phi > M_PI) phi = TVector2::Phi_mpi_pi(phi);
298 static const double PI_OVER_3 = M_PI/3;
300 if (0.4 <= eta && eta <= 1.4) {
301 if ( 2*PI_OVER_3 <= phi && phi < M_PI)
id = 0;
302 if ( PI_OVER_3 <= phi && phi < 2*PI_OVER_3)
id = 1;
303 if ( 0 <= phi && phi < PI_OVER_3)
id = 2;
304 if ( -PI_OVER_3 <= phi && phi < 0)
id = 3;
305 if (-2*PI_OVER_3 <= phi && phi < -PI_OVER_3)
id = 4;
306 if ( -M_PI <= phi && phi < -2*PI_OVER_3)
id = 5;
309 return (0 <=
id &&
id < 6);