StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJetSkimEvent.cxx
1 //StJetSkimEvent.cxx
2 //M.L. Miller (MIT)
3 //12/06
4 
5 #include <iostream>
6 
7 //local
8 #include "StPythiaEvent.h"
9 #include "StJetSkimEvent.h"
10 
11 ClassImp(StJetSkimTrigHeader)
12 ClassImp(StJetSkimTrig)
13 ClassImp(StJetSkimVert)
14 ClassImp(StJetSkimEvent)
15 
17  init();
18 }
19 
20 StJetSkimTrigHeader::StJetSkimTrigHeader(const StJetSkimTrigHeader & t) {
21  this->runId = t.runId;
22  this->trigId = t.trigId;
23  this->prescale = t.prescale;
24  this->eastBarrelTowerThreshold = t.eastBarrelTowerThreshold;
25  this->eastBarrelTriggerPatchThreshold = t.eastBarrelTriggerPatchThreshold;
26  this->eastBarrelJetPatchThreshold = t.eastBarrelJetPatchThreshold;
27  this->westBarrelTowerThreshold = t.westBarrelTowerThreshold;
28  this->westBarrelTriggerPatchThreshold = t.westBarrelTriggerPatchThreshold;
29  this->westBarrelJetPatchThreshold = t.westBarrelJetPatchThreshold;
30  this->endcapTowerThreshold = t.endcapTowerThreshold;
31  this->endcapTriggerPatchThreshold = t.endcapTriggerPatchThreshold;
32  this->endcapJetPatchThreshold = t.endcapJetPatchThreshold;
33  this->totalEnergyThreshold = t.totalEnergyThreshold;
34 }
35 
36 StJetSkimTrigHeader::~StJetSkimTrigHeader() { /*no-op*/ }
37 
38 StJetSkimTrigHeader& StJetSkimTrigHeader::operator=(const StJetSkimTrigHeader & rhs) {
39  if(this != &rhs) {
40  TObject::operator=(rhs);
41 
42  this->runId = rhs.runId;
43  this->trigId = rhs.trigId;
44  this->prescale = rhs.prescale;
45  this->eastBarrelTowerThreshold = rhs.eastBarrelTowerThreshold;
46  this->eastBarrelTriggerPatchThreshold = rhs.eastBarrelTriggerPatchThreshold;
47  this->eastBarrelJetPatchThreshold = rhs.eastBarrelJetPatchThreshold;
48  this->westBarrelTowerThreshold = rhs.westBarrelTowerThreshold;
49  this->westBarrelTriggerPatchThreshold = rhs.westBarrelTriggerPatchThreshold;
50  this->westBarrelJetPatchThreshold = rhs.westBarrelJetPatchThreshold;
51  this->endcapTowerThreshold = rhs.endcapTowerThreshold;
52  this->endcapTriggerPatchThreshold = rhs.endcapTriggerPatchThreshold;
53  this->endcapJetPatchThreshold = rhs.endcapJetPatchThreshold;
54  this->totalEnergyThreshold = rhs.totalEnergyThreshold;
55  }
56 
57  return *this;
58 }
59 
60 void StJetSkimTrigHeader::Clear(const char *option) {
61  TObject::Clear(option);
62  init();
63 }
64 
65 void StJetSkimTrigHeader::init() {
66  this->runId = -1;
67  this->trigId = -1;
68  this->prescale = 0.;
69  this->eastBarrelTowerThreshold = -1;
70  this->eastBarrelTriggerPatchThreshold = -1;
71  this->eastBarrelJetPatchThreshold = -1;
72  this->westBarrelTowerThreshold = -1;
73  this->westBarrelTriggerPatchThreshold = -1;
74  this->westBarrelJetPatchThreshold = -1;
75  this->endcapTowerThreshold = -1;
76  this->endcapTriggerPatchThreshold = -1;
77  this->endcapJetPatchThreshold = -1;
78  this->totalEnergyThreshold = -1;
79 }
80 
81 StJetSkimTrig::StJetSkimTrig() : TObject()
82 {
83  init();
84 }
85 
86 StJetSkimTrig::StJetSkimTrig(const StJetSkimTrig& t) : TObject()
87 {
88  this->mTrigId = t.trigId();
89  this->mDidFire = t.didFire();
90  this->mShouldFire = t.shouldFire();
91  this->mShouldFireBBC = t.shouldFireBBC();
92  this->mShouldFireBemc = t.shouldFireBemc();
93  this->mShouldFireEemc = t.shouldFireEemc();
94  this->mShouldFireL2 = t.shouldFireL2();
95  this->mTowers = t.mTowers;
96  this->mTriggerPatches = t.mTriggerPatches;
97  this->mJetPatches = t.mJetPatches;
98  this->mTotalEnergy = t.totalEnergy();
99 
100  memcpy(this->mL2ResultEmulated,t.mL2ResultEmulated,sizeof(this->mL2ResultEmulated));
101 }
102 
103 StJetSkimTrig::~StJetSkimTrig() { /* no-op */ }
104 
105 StJetSkimTrig& StJetSkimTrig::operator=(const StJetSkimTrig& rhs)
106 {
107  if(this != &rhs) {
108  TObject::operator=(rhs);
109 
110  this->mTrigId = rhs.trigId();
111  this->mDidFire = rhs.didFire();
112  this->mShouldFire = rhs.shouldFire();
113  this->mShouldFireBBC = rhs.shouldFireBBC();
114  this->mShouldFireBemc = rhs.shouldFireBemc();
115  this->mShouldFireEemc = rhs.shouldFireEemc();
116  this->mShouldFireL2 = rhs.shouldFireL2();
117  this->mTowers = rhs.mTowers;
118  this->mTriggerPatches = rhs.mTriggerPatches;
119  this->mJetPatches = rhs.mJetPatches;
120  this->mTotalEnergy = rhs.totalEnergy();
121 
122  memcpy(this->mL2ResultEmulated,rhs.mL2ResultEmulated,sizeof(this->mL2ResultEmulated));
123  }
124 
125  return *this;
126 }
127 
128 void StJetSkimTrig::init() {
129  this->mTrigId = -1;
130  this->mDidFire = -1;
131  this->mShouldFire = -1;
132  this->mShouldFireBBC = -1;
133  this->mShouldFireBemc = -1;
134  this->mShouldFireEemc = -1;
135  this->mShouldFireL2 = -1;
136  this->mTotalEnergy = -1;
137  this->mTowers.clear();
138  this->mTriggerPatches.clear();
139  this->mJetPatches.clear();
140 
141  memset(this->mL2ResultEmulated,0,sizeof(this->mL2ResultEmulated));
142 }
143 
144 void StJetSkimTrig::clear() {
145  this->Clear();
146 }
147 
148 void StJetSkimTrig::Clear(const char *option) {
149  TObject::Clear(option);
150  init();
151 }
152 
153 map<int,int>& StJetSkimTrig::towersAboveThreshold(int detector) const{
154  map<int,int> *theMap = new map<int,int>;
155  for(map<int,int>::const_iterator it=mTowers.begin(); it!=mTowers.end(); it++) {
156  if( (detector==0) && (it->first > 0) ) {
157  (*theMap)[it->first] = it->second;
158  }
159  else if( (detector==1) && (it->first <= 0) ) {
160  (*theMap)[TMath::Abs(it->first)] = it->second;
161  }
162  }
163  return (*theMap);
164 }
165 
166 map<int,int>& StJetSkimTrig::triggerPatchesAboveThreshold(int detector) const{
167  map<int,int> *theMap = new map<int,int>;
168  for(map<int,int>::const_iterator it=mTriggerPatches.begin(); it!=mTriggerPatches.end(); it++) {
169  if( (detector==0) && (it->first > 0) ) {
170  (*theMap)[it->first - 1] = it->second;
171  }
172  else if( (detector==1) && (it->first <= 0) ) {
173  (*theMap)[TMath::Abs(it->first)] = it->second;
174  }
175  }
176  return (*theMap);
177 }
178 
179 map<int,int>& StJetSkimTrig::jetPatchesAboveThreshold(int detector) const{
180  map<int,int> *theMap = new map<int,int>;
181  for(map<int,int>::const_iterator it=mJetPatches.begin(); it!=mJetPatches.end(); it++) {
182  if( (detector==0) && (it->first > 0) ) {
183  (*theMap)[it->first - 1] = it->second;
184  }
185  else if( (detector==1) && (it->first <= 0) ) {
186  (*theMap)[TMath::Abs(it->first)] = it->second;
187  }
188  }
189  return (*theMap);
190 }
191 
192 void StJetSkimTrig::addTowerAboveThreshold(int detector, int aID, int aADC) {
193  pair<int,int> p1(aID,aADC);
194  if(detector == 1) p1.first = (-1)*aID;
195  pair<map<int,int>::iterator,bool> p2 = mTowers.insert(p1);
196  if(!p2.second) {
197  cerr << "Error! towersAboveThreshold map already contains key == " << p1.first << endl;
198  }
199 }
200 
201 void StJetSkimTrig::addTriggerPatchAboveThreshold(int detector, int aID, int aADC) {
202  pair<int,int> p1(aID+1,aADC);
203  if(detector == 1) p1.first = (-1)*aID;
204  pair<map<int,int>::iterator,bool> p2 = mTriggerPatches.insert(p1);
205  if(!p2.second) {
206  cerr << "Error! triggerPatchesAboveThreshold map already contains key == " << p1.first << endl;
207  }
208 }
209 
210 void StJetSkimTrig::addJetPatchAboveThreshold(int detector, int aID, int aADC) {
211  pair<int,int> p1(aID+1,aADC);
212  if(detector == 1) p1.first = (-1)*aID;
213  pair<map<int,int>::iterator,bool> p2 = mJetPatches.insert(p1);
214  if(!p2.second) {
215  cerr << "Error! jetPatchesAboveThreshold map already contains key == " << p1.first << endl;
216  }
217 }
218 
219 void StJetSkimTrig::setL2ResultEmulated(const int* rhs) {
220  memcpy(mL2ResultEmulated,rhs,sizeof(mL2ResultEmulated));
221 }
222 
223 StJetSkimVert::StJetSkimVert()
224 {
225  for (int i=0; i<3; ++i) {
226  mPosition[i] = 0.;
227  mPosError[i] = 0.;
228  }
229  mVertexFinderId = mNTracksUsed = mNBTOFMatch = mNCTBMatch = mNBEMCMatch = mNEEMCMatch = mNCrossCentralMembrane = mRefMultNeg = mRefMultPos = mRefMultFtpcWest = mRefMultFtpcEast = 0;
230  mRanking = mSumTrackPt = mMeanDip = mChiSquared = 0.;
231 }
232 
233 void StJetSkimVert::setPosition(float* x)
234 {
235  mPosition[0] = x[0];
236  mPosition[1] = x[1];
237  mPosition[2] = x[2];
238 }
239 void StJetSkimVert::setError(float* x)
240 {
241  mPosError[0] = x[0];
242  mPosError[1] = x[1];
243  mPosError[2] = x[2];
244 }
245 
246 
247 
248 void StJetSkimVert::clear()
249 {
250  for (int i=0; i<3; ++i) {
251  mPosition[i] = 0.;
252  mPosError[i] = 0.;
253  }
254  mVertexFinderId = mNTracksUsed = mNBTOFMatch = mNCTBMatch = mNBEMCMatch = mNEEMCMatch = mNCrossCentralMembrane = mRefMultNeg = mRefMultPos = mRefMultFtpcWest = mRefMultFtpcEast = 0;
255  mRanking = mSumTrackPt = mMeanDip = mChiSquared = 0.;
256 }
257 
258 void StJetSkimVert::Clear(const char *option) {
259  this->clear();
260  TObject::Clear(option);
261 }
262 
263 bool StJetSkimVert::operator==(const StJetSkimVert &rhs) const {
264  if (this == &rhs) return true;
265 
266  for(int i=0; i<3; i++) {
267  if(mPosition[i] != rhs.position()[i]) return false;
268  if(mPosError[i] != rhs.posError()[i]) return false;
269  }
270 
271  if(mRanking != rhs.ranking()) return false;
272  if(mNTracksUsed != rhs.nTracksUsed()) return false;
273  if(mNBTOFMatch != rhs.nBTOFMatch()) return false;
274  if(mNCTBMatch != rhs.nCTBMatch()) return false;
275  if(mNBEMCMatch != rhs.nBEMCMatch()) return false;
276  if(mNEEMCMatch != rhs.nEEMCMatch()) return false;
277  if(mNCrossCentralMembrane != rhs.nCrossCentralMembrane()) return false;
278  if(mSumTrackPt != rhs.sumTrackPt()) return false;
279  if(mMeanDip != rhs.meanDip()) return false;
280  if(mChiSquared != rhs.chiSquared()) return false;
281  if(mRefMultNeg != rhs.refMultNeg()) return false;
282  if(mRefMultPos != rhs.refMultPos()) return false;
283  if(mRefMultFtpcWest != rhs.refMultFtpcWest()) return false;
284  if(mRefMultFtpcEast != rhs.refMultFtpcEast()) return false;
285 
286  return true;
287 }
288 
289 StJetSkimEvent::StJetSkimEvent() : TObject(), mTriggers(new TClonesArray("StJetSkimTrig",100)), mVertices(new TClonesArray("StJetSkimVert",100)), mBestVert(NULL), mMcEvent(NULL)
290 {
291  mMudstFileName = "Undefined";
292  mBestVertRef = NULL;
293  mFill = mRunId = mEventId = mbx7 = mbx48 = mSpinBits = 0;
294  mEbbc = mWbbc = mBbcTimeBin = 0;
295  mVpdTdiff = mVpdZvertex = -999.;
296  mVpdEastHits = mVpdWestHits = -1;
297  mZdcWestRate = 0;
298  mZdcEastRate = 0;
299  mZdcCoincidenceRate = 0;
300  mBbcWestRate = 0;
301  mBbcEastRate = 0;
302  mBbcCoincidenceRate = 0;
303  mIsValid = mIsPolLong = mIsPolTrans = mIsMaskedUsingBx48 = mOffsetBx48minusBX7 = mSpin4usingBx48 = 0;
304 
305  memset(mBarrelJetPatchTh,0,sizeof(mBarrelJetPatchTh));
306  memset(mEndcapJetPatchTh,0,sizeof(mEndcapJetPatchTh));
307  memset(mOverlapJetPatchTh,0,sizeof(mOverlapJetPatchTh));
308 
309  memset(mBarrelHighTowerTh,0,sizeof(mBarrelHighTowerTh));
310  memset(mEndcapHighTowerTh,0,sizeof(mEndcapHighTowerTh));
311 
312  memset(mBarrelJetPatchAdc,0,sizeof(mBarrelJetPatchAdc));
313  memset(mEndcapJetPatchAdc,0,sizeof(mEndcapJetPatchAdc));
314  memset(mOverlapJetPatchAdc,0,sizeof(mOverlapJetPatchAdc));
315 
316  mEmcLayer2 = 0;
317 
318  mNVpdEGoodHits = 0;
319  mNVpdWGoodHits = 0;
320  mEarliestVpdEHit = 99999.;
321  mEarliestVpdWHit = 99999.;
322  mClosestVpdEHit = 99999.;
323  mClosestVpdWHit = 99999.;
324  mLatestVpdEHit = -99999.;
325  mLatestVpdWHit = -99999.;
326 
327  mTstart = -999;
328  mNTzero = 0;
329  mNTzeroCan = 0;
330  mTCanFirst = 99999.;
331  mTCanLast = -99999.;
332 }
333 
334 StJetSkimEvent::StJetSkimEvent(const StJetSkimEvent &other) : TObject()
335 {
336  this->mFill = other.fill();
337  this->mRunId = other.runId();
338  this->mEventId = other.eventId();
339  this->mMudstFileName= other.mudstFileName();
340 
341  mTriggers = new TClonesArray("StJetSkimTrig",100);
342  for(int i=0; i<other.triggers()->GetEntries(); i++) {
343  this->setTrig(*(StJetSkimTrig*)other.triggers()->At(i));
344  }
345 
346  mVertices = new TClonesArray("StJetSkimTrig",100);
347  for(int i=0; i<other.vertices()->GetEntries(); i++) {
348  this->setVert(*(StJetSkimVert*)other.vertices()->At(i));
349  }
350 
351  mBestVert = other.bestVert();
352  if(mBestVert) this->setBestVert(*mBestVert);
353  mBestVert = NULL;
354 
355  this->mbx7 = other.bx7();
356  this->mbx48 = other.bx48();
357  this->mSpinBits = other.spinBits();
358  this->mEbbc = other.eBbc();
359  this->mWbbc = other.wBbc();
360  this->mBbcTimeBin = other.bbcTimeBin();
361 
362  this->mVpdTdiff = other.vpdTdiff();
363  this->mVpdZvertex = other.vpdZvertex();
364  this->mVpdEastHits = other.vpdEastHits();
365  this->mVpdWestHits = other.vpdWestHits();
366 
367  this->mNVpdEGoodHits = other.vpdEGoodHits();
368  this->mNVpdWGoodHits = other.vpdWGoodHits();
369  this->mEarliestVpdEHit = other.earliestVpdEHit();
370  this->mEarliestVpdWHit = other.earliestVpdWHit();
371  this->mClosestVpdEHit = other.closestVpdEHit();
372  this->mClosestVpdWHit = other.closestVpdWHit();
373  this->mLatestVpdEHit = other.latestVpdEHit();
374  this->mLatestVpdWHit = other.latestVpdWHit();
375 
376  this->mTstart = other.tStart();
377  this->mNTzero = other.nTzero();
378  this->mNTzeroCan = other.nTzeroCan();
379  this->mTCanFirst = other.tCanFirst();
380  this->mTCanLast = other.tCanLast();
381 
382  mZdcWestRate = other.mZdcWestRate;
383  mZdcEastRate = other.mZdcEastRate;
384  mZdcCoincidenceRate = other.mZdcCoincidenceRate;
385  mBbcWestRate = other.mBbcWestRate;
386  mBbcEastRate = other.mBbcEastRate;
387  mBbcCoincidenceRate = other.mBbcCoincidenceRate;
388 
389  this->mIsValid = other.isValid();
390  this->mIsPolLong = other.isPolLong();
391  this->mIsPolTrans = other.isPolTrans();
392  this->mIsMaskedUsingBx48 = other.isMaskedUsingBx48();
393  this->mOffsetBx48minusBX7 = other.offsetBx48minusBX7();
394  this->mSpin4usingBx48 = other.spin4usingBx48();
395 
396  memcpy(mL2Result,other.mL2Result,sizeof(mL2Result));
397 
398  memcpy(mBarrelJetPatchTh,other.mBarrelJetPatchTh,sizeof(mBarrelJetPatchTh));
399  memcpy(mEndcapJetPatchTh,other.mEndcapJetPatchTh,sizeof(mEndcapJetPatchTh));
400  memcpy(mOverlapJetPatchTh,other.mOverlapJetPatchTh,sizeof(mOverlapJetPatchTh));
401 
402  memcpy(mBarrelHighTowerTh,other.mBarrelHighTowerTh,sizeof(mBarrelHighTowerTh));
403  memcpy(mEndcapHighTowerTh,other.mEndcapHighTowerTh,sizeof(mEndcapHighTowerTh));
404 
405  memcpy(mBarrelJetPatchAdc,other.mBarrelJetPatchAdc,sizeof(mBarrelJetPatchAdc));
406  memcpy(mEndcapJetPatchAdc,other.mEndcapJetPatchAdc,sizeof(mEndcapJetPatchAdc));
407  memcpy(mOverlapJetPatchAdc,other.mOverlapJetPatchAdc,sizeof(mOverlapJetPatchAdc));
408 
409  mEmcLayer2 = other.mEmcLayer2;
410 }
411 
412 StJetSkimEvent::~StJetSkimEvent()
413 {
414  if(mTriggers) mTriggers->Delete();
415  if(mVertices) mVertices->Delete();
416 }
417 
418 StJetSkimEvent& StJetSkimEvent::operator=(const StJetSkimEvent &rhs)
419 {
420  if(this != &rhs) {
421  TObject::operator=(rhs);
422 
423  this->mFill = rhs.fill();
424  this->mRunId = rhs.runId();
425  this->mEventId = rhs.eventId();
426  this->mMudstFileName= rhs.mudstFileName();
427 
428  mTriggers->Delete();
429  for(int i=0; i<rhs.triggers()->GetEntries(); i++) {
430  this->setTrig(*(StJetSkimTrig*)rhs.triggers()->At(i));
431  }
432 
433  mVertices->Delete();
434  for(int i=0; i<rhs.vertices()->GetEntries(); i++) {
435  this->setVert(*(StJetSkimVert*)rhs.vertices()->At(i));
436  }
437 
438  mBestVert = rhs.bestVert();
439  if(mBestVert) this->setBestVert(*mBestVert);
440  mBestVert = NULL;
441 
442  this->mbx7 = rhs.bx7();
443  this->mbx48 = rhs.bx48();
444  this->mSpinBits = rhs.spinBits();
445  this->mEbbc = rhs.eBbc();
446  this->mWbbc = rhs.wBbc();
447  this->mBbcTimeBin = rhs.bbcTimeBin();
448 
449  this->mVpdTdiff = rhs.vpdTdiff();
450  this->mVpdZvertex = rhs.vpdZvertex();
451  this->mVpdEastHits = rhs.vpdEastHits();
452  this->mVpdWestHits = rhs.vpdWestHits();
453 
454  this->mNVpdEGoodHits = rhs.vpdEGoodHits();
455  this->mNVpdWGoodHits = rhs.vpdWGoodHits();
456  this->mEarliestVpdEHit = rhs.earliestVpdEHit();
457  this->mEarliestVpdWHit = rhs.earliestVpdWHit();
458  this->mClosestVpdEHit = rhs.closestVpdEHit();
459  this->mClosestVpdWHit = rhs.closestVpdWHit();
460  this->mLatestVpdEHit = rhs.latestVpdEHit();
461  this->mLatestVpdWHit = rhs.latestVpdWHit();
462 
463  this->mTstart = rhs.tStart();
464  this->mNTzero = rhs.nTzero();
465  this->mNTzeroCan = rhs.nTzeroCan();
466  this->mTCanFirst = rhs.tCanFirst();
467  this->mTCanLast = rhs.tCanLast();
468 
469  mZdcWestRate = rhs.mZdcWestRate;
470  mZdcEastRate = rhs.mZdcEastRate;
471  mZdcCoincidenceRate = rhs.mZdcCoincidenceRate;
472  mBbcWestRate = rhs.mBbcWestRate;
473  mBbcEastRate = rhs.mBbcEastRate;
474  mBbcCoincidenceRate = rhs.mBbcCoincidenceRate;
475 
476  this->mIsValid = rhs.isValid();
477  this->mIsPolLong = rhs.isPolLong();
478  this->mIsPolTrans = rhs.isPolTrans();
479  this->mIsMaskedUsingBx48 = rhs.isMaskedUsingBx48();
480  this->mOffsetBx48minusBX7 = rhs.offsetBx48minusBX7();
481  this->mSpin4usingBx48 = rhs.spin4usingBx48();
482 
483  memcpy(mL2Result,rhs.mL2Result,sizeof(mL2Result));
484 
485  memcpy(mBarrelJetPatchTh,rhs.mBarrelJetPatchTh,sizeof(mBarrelJetPatchTh));
486  memcpy(mEndcapJetPatchTh,rhs.mEndcapJetPatchTh,sizeof(mEndcapJetPatchTh));
487  memcpy(mOverlapJetPatchTh,rhs.mOverlapJetPatchTh,sizeof(mOverlapJetPatchTh));
488 
489  memcpy(mBarrelHighTowerTh,rhs.mBarrelHighTowerTh,sizeof(mBarrelHighTowerTh));
490  memcpy(mEndcapHighTowerTh,rhs.mEndcapHighTowerTh,sizeof(mEndcapHighTowerTh));
491 
492  memcpy(mBarrelJetPatchAdc,rhs.mBarrelJetPatchAdc,sizeof(mBarrelJetPatchAdc));
493  memcpy(mEndcapJetPatchAdc,rhs.mEndcapJetPatchAdc,sizeof(mEndcapJetPatchAdc));
494  memcpy(mOverlapJetPatchAdc,rhs.mOverlapJetPatchAdc,sizeof(mOverlapJetPatchAdc));
495 
496  mEmcLayer2 = rhs.mEmcLayer2;
497  }
498 
499  return *this;
500 }
501 
502 void StJetSkimEvent::clear()
503 {
504  mMudstFileName = "Undefined";
505  mFill = mRunId = mEventId = mbx7 = mbx48 = mSpinBits = 0;
506  mEbbc = mWbbc = mBbcTimeBin = 0;
507  mVpdTdiff = mVpdZvertex = -999.;
508  mVpdEastHits = mVpdWestHits = -1;
509  mZdcWestRate = 0;
510  mZdcEastRate = 0;
511  mZdcCoincidenceRate = 0;
512  mBbcWestRate = 0;
513  mBbcEastRate = 0;
514  mBbcCoincidenceRate = 0;
515  mIsValid = mIsPolLong = mIsPolTrans = mIsMaskedUsingBx48 = mOffsetBx48minusBX7 = mSpin4usingBx48 = 0;
516  mTriggers->Clear("c");
517  mVertices->Clear("c");
518  mBestVert = NULL;
519  mBestVertRef.Clear();
520  mTrigHeaderArrayRef.Clear();
521 
522  memset(mBarrelJetPatchTh,0,sizeof(mBarrelJetPatchTh));
523  memset(mEndcapJetPatchTh,0,sizeof(mEndcapJetPatchTh));
524  memset(mOverlapJetPatchTh,0,sizeof(mOverlapJetPatchTh));
525 
526  memset(mBarrelHighTowerTh,0,sizeof(mBarrelHighTowerTh));
527  memset(mEndcapHighTowerTh,0,sizeof(mEndcapHighTowerTh));
528 
529  memset(mBarrelJetPatchAdc,0,sizeof(mBarrelJetPatchAdc));
530  memset(mEndcapJetPatchAdc,0,sizeof(mEndcapJetPatchAdc));
531  memset(mOverlapJetPatchAdc,0,sizeof(mOverlapJetPatchAdc));
532 
533  mEmcLayer2 = 0;
534 
535  mNVpdEGoodHits = 0;
536  mNVpdWGoodHits = 0;
537  mEarliestVpdEHit = 99999.;
538  mEarliestVpdWHit = 99999.;
539  mClosestVpdEHit = 99999.;
540  mClosestVpdWHit = 99999.;
541  mLatestVpdEHit = -99999.;
542  mLatestVpdWHit = -99999.;
543 
544  mTstart = -999.;
545  mNTzero = 0;
546  mNTzeroCan = 0;
547  mTCanFirst = 99999.;
548  mTCanLast = -99999.;
549 }
550 
551 void StJetSkimEvent::Clear(const char *option) {
552  this->clear();
553  TObject::Clear(option);
554 }
555 
556 StJetSkimVert* StJetSkimEvent::bestVert() const {
557  return (mBestVertRef.GetObject() ? (StJetSkimVert*)mBestVertRef.GetObject() : mBestVert);
558 }
559 
560 void StJetSkimEvent::setBestVert(const StJetSkimVert & v) {
561  for(int i=0; i<mVertices->GetEntries(); i++) {
562  if(v == *(StJetSkimVert*)(mVertices->At(i))) {
563  this->setBestVert(i);
564  break;
565  }
566  }
567 
568  if(this->bestVert() == NULL) {
569  cerr << "StJetSkimEvent::setBestVert -- Error! Couldn't set best vertex" << endl;
570  cerr << "StJetSkimEvent::setBestVert -- Make sure the vertex is already in the new clones array" << endl;
571  }
572 }
573 
574 void StJetSkimEvent::setBestVert(int clonesArrayIndex) {
575  mBestVertRef = (StJetSkimVert*)mVertices->At(clonesArrayIndex);
576 }
577 
578 void StJetSkimEvent::setL2Result(const int* rhs) {
579  memcpy(mL2Result,rhs,sizeof(mL2Result));
580 }
581 
582 void StJetSkimEvent::setTrig(const StJetSkimTrig& t)
583 {
584  int addAt = mTriggers->GetLast()+1;
585 
586  //and here's the crazy syntax
587  TClonesArray& arrayRef = *(mTriggers);
588  new ( arrayRef[addAt]) StJetSkimTrig( t );
589 }
590 
591 void StJetSkimEvent::setVert(const StJetSkimVert& t)
592 {
593  int addAt = mVertices->GetLast()+1;
594 
595  //and here's the crazy syntax
596  TClonesArray& arrayRef = *(mVertices);
597  new ( arrayRef[addAt]) StJetSkimVert( t );
598 }
599 
600 StJetSkimTrigHeader* StJetSkimEvent::trigHeader(int trigId) {
601  TClonesArray *tmp = this->trigHeaders();
602  if(!tmp) {
603  cout << "ERROR LOADING TRIGGER HEADERS!" << endl;
604  return NULL;
605  }
606  for(int i=0; i<tmp->GetEntries(); i++) {
607  StJetSkimTrigHeader* header = (StJetSkimTrigHeader*)tmp->At(i);
608  if(header->trigId == trigId) return header;
609  }
610  return NULL;
611 }
612 
613 StJetSkimTrig* StJetSkimEvent::trigger(int trigId) {
614  TClonesArray *tmp = this->triggers();
615  for(int i=0; i<tmp->GetEntries(); i++) {
616  StJetSkimTrig* trigger = (StJetSkimTrig*)tmp->At(i);
617  if(trigger->trigId() == trigId) return trigger;
618  }
619  return NULL;
620 }
621 
622 map<int,int> StJetSkimEvent::barrelJetPatchesAboveTh(int i) const
623 {
624  map<int,int> m;
625  for (int jp = 0; jp < 18; ++jp) {
626  int adc = barrelJetPatchAdc(jp);
627  if (adc > barrelJetPatchTh(i)) m.insert(make_pair(jp,adc));
628  }
629  return m;
630 }
631 
632 map<int,int> StJetSkimEvent::endcapJetPatchesAboveTh(int i) const
633 {
634  map<int,int> m;
635  for (int jp = 0; jp < 6; ++jp) {
636  int adc = endcapJetPatchAdc(jp);
637  if (adc > endcapJetPatchTh(i)) m.insert(make_pair(jp,adc));
638  }
639  return m;
640 }
641 
642 map<int,int> StJetSkimEvent::overlapJetPatchesAboveTh(int i) const
643 {
644  map<int,int> m;
645  for (int jp = 0; jp < 6; ++jp) {
646  int adc = overlapJetPatchAdc(jp);
647  if (adc > overlapJetPatchTh(i)) m.insert(make_pair(jp,adc));
648  }
649  return m;
650 }