StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJets.cxx
1 // $Id: StJets.cxx,v 1.4 2010/06/30 17:51:58 pibero Exp $
2 #include "StJet.h"
3 #include "StJets.h"
4 
5 #include "TrackToJetIndex.h"
6 #include "TowerToJetIndex.h"
7 
8 ClassImp(StJets);
9 
10 StJets::StJets()
11  : mDylanPoints(0)
12  , mSumEmcE(0)
13  , mEventId(0)
14  , mEventNumber(0)
15  , mRunId(0)
16  , mRunNumber(0)
17  , mCorrupt(false)
18  , mJets(new TClonesArray("StJet",100))
19  , mTrackToJetIndices(new TClonesArray("TrackToJetIndex",100))
20  , mTowerToJetIndices(new TClonesArray("TowerToJetIndex",100))
21 {
22 }
23 
24 StJets::~StJets()
25 {
26  mJets->Delete();
27  mTrackToJetIndices->Delete();
28  mTowerToJetIndices->Delete();
29 
30  delete mJets;
31  delete mTrackToJetIndices;
32  delete mTowerToJetIndices;
33 
34  mJets = 0;
35  mTrackToJetIndices = 0;
36  mTowerToJetIndices = 0;
37 }
38 
39 void StJets::Clear(bool clearAll)
40 {
41  mJets->Clear();
42  mTrackToJetIndices->Clear();
43  mTowerToJetIndices->Clear();
44  mDylanPoints = 0;
45  mSumEmcE = 0.;
46 }
47 
48 void StJets::addTrackToIndex(TrackToJetIndex& t2j)
49 {
50  new ((*mTrackToJetIndices)[mTrackToJetIndices->GetEntriesFast()]) TrackToJetIndex(t2j);
51 }
52 
53 void StJets::addTowerToIndex(TowerToJetIndex& t2j)
54 {
55  new ((*mTowerToJetIndices)[mTowerToJetIndices->GetEntriesFast()]) TowerToJetIndex(t2j);
56 }
57 
58 void StJets::addJet(StJet& jet)
59 {
60  new((*mJets)[nJets()]) StJet(jet);
61 }
62 
63 TObjArray StJets::tracks(int jetIndex) const
64 {
65  TObjArray a;
66  for (int i = 0; i < mTrackToJetIndices->GetEntriesFast(); ++i) {
67  TrackToJetIndex* track = (TrackToJetIndex*)mTrackToJetIndices->At(i);
68  if (track->jetIndex() == jetIndex) a.Add(track);
69  }
70  return a;
71 }
72 
73 TObjArray StJets::towers(int jetIndex) const
74 {
75  TObjArray a;
76  for (int i = 0; i < mTowerToJetIndices->GetEntriesFast(); ++i) {
77  TowerToJetIndex* tower = (TowerToJetIndex*)mTowerToJetIndices->At(i);
78  if (tower->jetIndex() == jetIndex) a.Add(tower);
79  }
80  return a;
81 }
82 
83 vector<TLorentzVector*> StJets::particles(int jetIndex) const
84 {
85  vector<TLorentzVector*> v;
86  for (int i = 0; i < mTrackToJetIndices->GetEntriesFast(); ++i) {
87  TrackToJetIndex* track = (TrackToJetIndex*)mTrackToJetIndices->At(i);
88  if (track->jetIndex() == jetIndex) v.push_back(track);
89  }
90  for (int i = 0; i < mTowerToJetIndices->GetEntriesFast(); ++i) {
91  TowerToJetIndex* tower = (TowerToJetIndex*)mTowerToJetIndices->At(i);
92  if (tower->jetIndex() == jetIndex) v.push_back(tower);
93  }
94  return v;
95 }
96 
97 bool StJets::inBounds(int i)
98 {
99  return (i>0 && i<nJets());
100 }
101 
102 double StJets::e(int i) const
103 {
104  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
105  return (j) ? j->E() : -999.;
106 }
107 
108 double StJets::et(int i) const
109 {
110  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
111  return (j) ? j->et() : -999.;
112 }
113 
114 double StJets::p(int i) const
115 {
116  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
117  return (j) ? j->P() : -999.;
118 }
119 
120 double StJets::pt(int i) const
121 {
122  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
123  return (j) ? j->Pt() : -999.;
124 }
125 
126 double StJets::phi(int i) const
127 {
128  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
129  return (j) ? j->Phi() : -999.;
130 }
131 
132 double StJets::eta(int i) const
133 {
134  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
135  return (j) ? j->Eta() : -999.;
136 }
137 
138 int StJets::nCell(int i) const
139 {
140  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
141  return (j) ? j->nCell : -999;
142 }
143 
144 int StJets::charge(int i) const
145 {
146  StJet* j = dynamic_cast<StJet*>(mJets->UncheckedAt(i));
147  return (j) ? j->charge : -999;
148 }
Int_t nCell
The number of 4-vectors contributing to this jet.
Definition: StJet.h:98
Definition: StJets.h:24
double e(int jetIndex) const
User Interface as per Thomas H&#39;s request. Access jet kinematics based on index:
Definition: StJets.cxx:102
int nJets() const
The number of jets found in this event.
Definition: StJets.h:39
TClonesArray * tracks()
The track/tower to jet indices TClonesArray: this contains all the 4momenta contained in jets for jet...
Definition: StJets.h:47
int charge
The summed coulomb charge of the tracks in this jet.
Definition: StJet.h:101
Definition: StJet.h:91