StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJetCandidate.cxx
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 3 September 2009
5 //
6 
7 #include "StJetTrack.h"
8 #include "StJetTower.h"
9 #include "StJetCandidate.h"
10 
11 ClassImp(StJetCandidate);
12 
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())
18  , mArea(area)
19  , mAreaError(area_error)
20 {
21  mDetEta = detEta(vertex);
22 }
23 
24 float StJetCandidate::detEta(const TVector3& vertex) const
25 {
26  float DetEta;
27  if (getBarrelDetectorEta(vertex,DetEta)) return DetEta;
28  if (getEndcapDetectorEta(vertex,DetEta)) return DetEta;
29  return -999;
30 }
31 
32 bool StJetCandidate::getBarrelDetectorEta(const TVector3& vertex, float& detEta) const
33 {
34  // Front plate of BEMC or BPRS layer
35  // See StEmcGeom/geometry/StEmcGeom.cxx
36  static const double BEMC_RADIUS = 225.405; // cm
37  // EEMC preshower1 layer
38  // See StEEmcUtil/EEmcGeom/EEmcGeomDefs.h
39  static const double EEMC_Z = 270.190; // cm
40  TVector3 pos = momentum();
41  pos.SetMag(BEMC_RADIUS/pos.Unit().Perp());
42  pos += vertex;
43  detEta = pos.Eta();
44  // return fabs(detEta) < 1;
45  return fabs(pos.Z()) < EEMC_Z;
46 }
47 
48 bool StJetCandidate::getEndcapDetectorEta(const TVector3& vertex, float& detEta) const
49 {
50  // EEMC preshower1 layer
51  // See StEEmcUtil/EEmcGeom/EEmcGeomDefs.h
52  static const double EEMC_Z = 270.190; // cm
53  TVector3 pos = momentum();
54  if (pos.z() > 0) {
55  // Real endcap
56  pos.SetMag((EEMC_Z-vertex.z())/pos.Unit().z());
57  pos += vertex;
58  detEta = pos.Eta();
59  }
60  else {
61  // Mirror endcap (flip about xy-plane, solve and flip sign)
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());
65  pos2 += vertex2;
66  detEta = -pos2.Eta();
67  }
68  // return fabs(detEta) > 1 && fabs(detEta) < 2;
69  return fabs(detEta) < 2.5;
70 }
71 
72 StJetTrack* StJetCandidate::leadingChargedParticle() const
73 {
74  StJetTrack* lcp = 0;
75  for (int i = 0; i < numberOfTracks(); ++i) {
76  StJetTrack* t = track(i);
77  if (!lcp || t->pt() > lcp->pt()) lcp = t;
78  }
79  return lcp;
80 }
81 
82 float StJetCandidate::deltaR(const StJetElement* element) const
83 {
84  return momentum().DeltaR(element->momentum());
85 }
86 
87 float StJetCandidate::sumTrackPt() const
88 {
89  float s = 0;
90  for (int i = 0; i < numberOfTracks(); ++i) s += track(i)->pt();
91  return s;
92 }
93 
94 float StJetCandidate::sumTrackPt(float radius) const
95 {
96  float s = 0;
97  for (int i = 0; i < numberOfTracks(); ++i) {
98  const StJetTrack* t = track(i);
99  if (deltaR(t) < radius) s += t->pt();
100  }
101  return s;
102 }
103 
104 float StJetCandidate::sumTowerPt() const
105 {
106  float s = 0;
107  for (int i = 0; i < numberOfTowers(); ++i) s += tower(i)->pt();
108  return s;
109 }
110 
111 float StJetCandidate::sumTowerPt(float radius) const
112 {
113  float s = 0;
114  for (int i = 0; i < numberOfTowers(); ++i) {
115  const StJetTower* t = tower(i);
116  if (deltaR(t) < radius) s += t->pt();
117  }
118  return s;
119 }
120 
121 StJetTrack* StJetCandidate::getTrackById(int id) const
122 {
123  for (int i = 0; i < numberOfTracks(); ++i) {
124  StJetTrack* t = track(i);
125  if (t->id() == id) return t;
126  }
127  return 0;
128 }
129 
130 StJetTower* StJetCandidate::getTowerById(int id) const
131 {
132  for (int i = 0; i < numberOfTowers(); ++i) {
133  StJetTower* t = tower(i);
134  if (t->id() == id) return t;
135  }
136  return 0;
137 }
138 
139 float StJetCandidate::getJetPatchPhi(int jetPatch)
140 {
141  return TVector2::Phi_mpi_pi((150 - (jetPatch % 6) * 60) * TMath::DegToRad());
142 }
143 
144 bool StJetCandidate::getBarrelJetPatchEtaPhi(int jetPatch, float& eta, float& phi)
145 {
146  //
147  // Pibero Djawotho <pibero@tamu.edu>
148  // Texas A&M University
149  // 5 September 2009
150  // Revised 9 Feruary 2010 to include middle jet patches
151  //
152 
153  // Sanity check
154  if (jetPatch < 0 || jetPatch >= 18) return false;
155 
156  //
157  // The jet patches are numbered starting with JP0 centered at 150 degrees
158  // looking from the West into the IR (intersection region) and increasing
159  // clockwise, i.e. JP1 at 90 degrees, JP2 at 30 degrees, etc. On the East
160  // side the numbering picks up at JP6 centered again at 150 degrees and
161  // increasing clockwise (again as seen from the *West* into the IR). Thus
162  // JP0 and JP6 are in the same phi location in the STAR coordinate system.
163  // So are JP1 and JP7, etc.
164  //
165  // Jet Patch# Eta Phi Quadrant
166  //
167  // 0 0.5 150 10'
168  // 1 0.5 90 12'
169  // 2 0.5 30 2'
170  // 3 0.5 -30 4'
171  // 4 0.5 -90 6'
172  // 5 0.5 -150 8'
173  // 6 -0.5 150 10'
174  // 7 -0.5 90 12'
175  // 8 -0.5 30 2'
176  // 9 -0.5 -30 4'
177  // 10 -0.5 -90 6'
178  // 11 -0.5 -150 8'
179  //
180  // http://www.nikhef.nl/~ogrebeny/emc/files/Towers%20Layout.pdf
181  // http://www.nikhef.nl/~ogrebeny/emc/files/BEMC.pdf
182  // http://drupal.star.bnl.gov/STAR/system/files/BEMC_y2004.pdf
183  //
184 
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;
188 
189  phi = getJetPatchPhi(jetPatch);
190 
191  return true;
192 }
193 
194 bool StJetCandidate::getEndcapJetPatchEtaPhi(int jetPatch, float& eta, float& phi)
195 {
196  if (jetPatch >= 0 && jetPatch < 6)
197  eta = 1.5;
198  else
199  return false;
200 
201  phi = getJetPatchPhi(jetPatch);
202 
203  return true;
204 }
205 
206 bool StJetCandidate::getOverlapJetPatchEtaPhi(int jetPatch, float& eta, float& phi)
207 {
208  if (jetPatch >= 0 && jetPatch < 6)
209  eta = 0.9;
210  else
211  return false;
212 
213  phi = getJetPatchPhi(jetPatch);
214 
215  return true;
216 }
217 
218 bool StJetCandidate::getBarrelJetPatchId(float eta, float phi, int& id)
219 {
220  //
221  // Pibero Djawotho <pibero@tamu.edu>
222  // Texas A&M University
223  // 5 September 2009
224  // To do: Need to include possibility of returning middle jet patch
225  //
226 
227  // Jet patch id is left at -1 on failure
228  id = -1;
229 
230  // Check range of eta
231  if (eta < -1 || eta > 1) return false;
232 
233  // Map phi into [-pi,pi] if necessary
234  if (phi < -M_PI || phi > M_PI) phi = TVector2::Phi_mpi_pi(phi);
235 
236  // Get jet patch id
237  static const double PI_OVER_3 = M_PI/3;
238 
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;
246  }
247 
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;
255  }
256 
257  return (0 <= id && id < 12);
258 }
259 
260 bool StJetCandidate::getEndcapJetPatchId(float eta, float phi, int& id)
261 {
262  // Jet patch id is left at -1 on failure
263  id = -1;
264 
265  // Check range of eta
266  if (eta < 1 || eta > 2) return false;
267 
268  // Map phi into [-pi,pi] if necessary
269  if (phi < -M_PI || phi > M_PI) phi = TVector2::Phi_mpi_pi(phi);
270 
271  // Get jet patch id
272  static const double PI_OVER_3 = M_PI/3;
273 
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;
281  }
282 
283  return (0 <= id && id < 6);
284 }
285 
286 bool StJetCandidate::getOverlapJetPatchId(float eta, float phi, int& id)
287 {
288  // Jet patch id is left at -1 on failure
289  id = -1;
290 
291  // Check range of eta
292  if (eta < 0.4 || eta > 1.4) return false;
293 
294  // Map phi into [-pi,pi] if necessary
295  if (phi < -M_PI || phi > M_PI) phi = TVector2::Phi_mpi_pi(phi);
296 
297  // Get jet patch id
298  static const double PI_OVER_3 = M_PI/3;
299 
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;
307  }
308 
309  return (0 <= id && id < 6);
310 }