StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StChargedPionEvent.cxx
1 // $Id: StChargedPionEvent.cxx,v 1.10 2009/01/04 17:42:58 kocolosk Exp $
2 
3 #include "StChargedPionEvent.h"
4 
5 #include "TClass.h"
6 
7 #include "StMessMgr.h"
8 
9 #include "StChargedPionVertex.h"
10 #include "StChargedPionTrack.h"
11 #include "StChargedPionJet.h"
12 
13 ClassImp(StChargedPionEvent)
14 
15 StChargedPionEvent::StChargedPionEvent() : mSpinQA(0), mTriggerBits(0), mSimuTriggerBits(0) {
16  mVertices = new TClonesArray("StChargedPionVertex", 20);
17  mTracks = new TClonesArray("StChargedPionTrack", 50);
18  mJets = new TClonesArray("StChargedPionJet", 50);
19 
20  memset(mL2Result, 0, 36);
21  memset(mL2ResultEmulated, 0, 36);
22 
23  StChargedPionEvent::Class()->IgnoreTObjectStreamer();
24  StChargedPionVertex::Class()->IgnoreTObjectStreamer();
25  StChargedPionTrack::Class()->IgnoreTObjectStreamer();
26  StChargedPionJet::Class()->IgnoreTObjectStreamer();
27 }
28 
29 StChargedPionEvent::~StChargedPionEvent() {
30  if(mVertices) delete mVertices;
31  if(mTracks) delete mTracks;
32  if(mJets) delete mJets;
33 }
34 
35 StChargedPionEvent::StChargedPionEvent(const StChargedPionEvent & e) :
36  mRunId(e.mRunId), mEventId(e.mEventId), mBx7(e.mBx7), mBbcTimeBin(e.mBbcTimeBin),
37  mSpinBit(e.mSpinBit), mSpinQA(e.mSpinQA),
38  mTriggerBits(e.mTriggerBits), mSimuTriggerBits(e.mSimuTriggerBits) {
39 
40  memcpy(mL2Result, e.mL2Result, 36);
41  memcpy(mL2ResultEmulated, e.mL2ResultEmulated, 36);
42 
43  for(unsigned i=0; i<e.nVertices(); ++i) {
44  addVertex(e.vertex(i));
45  }
46 
47  for(unsigned i=0; i<e.nTracks(); ++i) {
48  addTrack(e.track(i));
49  }
50 
51  for(unsigned i=0; i<e.nJets(); ++i) {
52  addJet(e.jet(i));
53  }
54 }
55 
56 StChargedPionEvent& StChargedPionEvent::operator=(const StChargedPionEvent & e) {
57  if (this == &e) return *this;
58 
59  this->Clear();
60  mRunId = e.mRunId;
61  mEventId = e.mEventId;
62  mBx7 = e.mBx7;
63  mBbcTimeBin = e.mBbcTimeBin;
64  mSpinBit = e.mSpinBit;
65  mSpinQA = e.mSpinQA;
66  mTriggerPrescales = e.mTriggerPrescales;
67  mTriggerBits = e.mTriggerBits;
68  mSimuTriggerBits = e.mSimuTriggerBits;
69 
70  memcpy(mL2Result, e.mL2Result, 36);
71  memcpy(mL2ResultEmulated, e.mL2ResultEmulated, 36);
72 
73  for(unsigned i=0; i<e.nVertices(); ++i) {
74  addVertex(e.vertex(i));
75  }
76 
77  for(unsigned i=0; i<e.nTracks(); ++i) {
78  addTrack(e.track(i));
79  }
80 
81  for(unsigned i=0; i<e.nJets(); ++i) {
82  addJet(e.jet(i));
83  }
84 
85  return *this;
86 }
87 
88 void StChargedPionEvent::copy(const StChargedPionEvent& e) {
89  *this = e;
90 }
91 
92 void StChargedPionEvent::Clear(Option_t* o) {
93  mSpinQA = 0;
94  mTriggerBits = 0;
95  mSimuTriggerBits = 0;
96  mVertices->Clear();
97  mTracks->Clear();
98 
99  // use ::Delete here so ROOT doesn't hold onto memory allocated for jet particles
100  mJets->Delete();
101 
102  mTriggerPrescales.clear();
103  mHighTowers.clear();
104  mTriggerPatches.clear();
105  mJetPatches.clear();
106 }
107 
108 bool StChargedPionEvent::isSpinValid() const {
109  return (isPolValid() && !isBxingMasked() && isNullOffset());
110 }
111 
112 bool StChargedPionEvent::isTrigger(unsigned int trigId) const {
113  map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
114  if(it==mTriggerLookup.end()) return false;
115  return mTriggerBits & it->second;
116 }
117 
118 bool StChargedPionEvent::isSimuTrigger(unsigned int trigId) const {
119  map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
120  if(it==mTriggerLookup.end()) return false;
121  return mSimuTriggerBits & it->second;
122 }
123 
124 float StChargedPionEvent::prescale(unsigned int trigId) const {
125  map<unsigned int, float>::const_iterator it = mTriggerPrescales.find(trigId);
126  if(it==mTriggerPrescales.end()) return -1.0;
127  return it->second;
128 }
129 
130 int StChargedPionEvent::highTowerAdc(short towerId) const {
131  map<short, int>::const_iterator it = mHighTowers.find(towerId);
132  if(it==mHighTowers.end()) return -1;
133  return it->second;
134 }
135 
136 int StChargedPionEvent::triggerPatchAdc(short patchId) const {
137  map<short, int>::const_iterator it = mTriggerPatches.find(patchId);
138  if(it==mTriggerPatches.end()) return -1;
139  return it->second;
140 }
141 
142 int StChargedPionEvent::jetPatchAdc(short patchId) const {
143  map<short, int>::const_iterator it = mJetPatches.find(patchId);
144  if(it==mJetPatches.end()) return -1;
145  return it->second;
146 }
147 
148 StChargedPionVertex* StChargedPionEvent::vertex(int i) {
149  return static_cast<StChargedPionVertex*>(mVertices->At(i));
150 }
151 
152 const StChargedPionVertex* StChargedPionEvent::vertex(int i) const {
153  return static_cast<StChargedPionVertex*>(mVertices->At(i));
154 }
155 
156 StChargedPionTrack* StChargedPionEvent::track(int i) {
157  return static_cast<StChargedPionTrack*>(mTracks->At(i));
158 }
159 
160 const StChargedPionTrack* StChargedPionEvent::track(int i) const {
161  return static_cast<StChargedPionTrack*>(mTracks->At(i));
162 }
163 
164 StChargedPionJet* StChargedPionEvent::jet(int i) {
165  return static_cast<StChargedPionJet*>(mJets->At(i));
166 }
167 
168 const StChargedPionJet* StChargedPionEvent::jet(int i) const {
169  return static_cast<StChargedPionJet*>(mJets->At(i));
170 }
171 
172 void StChargedPionEvent::addTrigger(unsigned int trigId) {
173  map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
174  if(it!=mTriggerLookup.end()) {
175  mTriggerBits |= it->second;
176  }
177 }
178 
179 void StChargedPionEvent::addSimuTrigger(unsigned int trigId) {
180  map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
181  if(it!=mTriggerLookup.end()) {
182  mSimuTriggerBits |= it->second;
183  }
184 }
185 
186 void StChargedPionEvent::setL2Result(const void *address, bool emulated) {
187  if(emulated) {
188  memcpy(mL2ResultEmulated, address, 20);
189  memcpy(mL2ResultEmulated+5, (int*)address+6, 16);
190  }
191  else {
192  memcpy(mL2Result, address, 20);
193  memcpy(mL2Result+5, (int*)address+6, 16);
194  }
195 }
196 
197 void StChargedPionEvent::addVertex(const StChargedPionVertex* v) {
198  new ( (*mVertices)[mVertices->GetEntriesFast()] ) StChargedPionVertex(*v);
199 }
200 
201 void StChargedPionEvent::addTrack(const StChargedPionTrack* t) {
202  new ( (*mTracks)[mTracks->GetEntriesFast()] ) StChargedPionTrack(*t);
203 }
204 
205 void StChargedPionEvent::addJet(const StChargedPionJet* j) {
206  new ( (*mJets)[mJets->GetEntriesFast()] ) StChargedPionJet(*j);
207 }
208 
209 /*****************************************************************************
210  * $Log: StChargedPionEvent.cxx,v $
211  * Revision 1.10 2009/01/04 17:42:58 kocolosk
212  * extra includes for standalone builds against ROOT 5.16+
213  *
214  * Revision 1.9 2008/12/29 15:58:28 kocolosk
215  * removed commented code and added Id and Log as needed
216  *
217  *****************************************************************************/
218 
void setL2Result(const void *address, bool emulated=false)
address to dijet result