StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcOfflineCalibrationEvent.cxx
1 /*
2  * StEmcOfflineCalibrationEvent.cxx
3  * J. Kevin Adkins, University of Kentucky
4  * June 15, 2014
5  *
6  * Access methods and tree creating algorithm for
7  * BEMC calibration trees. This was updated from
8  * the previous method to be a bit more streamlined
9  * and user friendly. Also added independent trigger
10  * class easier definition of triggered events
11  */
12 
13 #include "TClonesArray.h"
14 #include "StEmcOfflineCalibrationEvent.h"
15 #include <map>
16 #include <algorithm>
17 
23 //----------------------------------------------------------------------------------
25 {
26  Clear();
27 }
28 
30 
31 void StEmcOfflineCalibrationTrack::Clear(Option_t* option)
32 {
33  fill(mTowerId, mTowerId+9, -1);
34  fill(mTowerAdc, mTowerAdc+9, -1);
35  fill(mTowerStatus, mTowerStatus+9, -1);
36  fill(mTowerPed, mTowerPed+9, -1.);
37  fill(mTowerPedRms, mTowerPedRms+9, -1.);
38 
39  fill(mPreshowerAdc, mPreshowerAdc+9, -1);
40  fill(mPreshowerStatus, mPreshowerStatus+9, -1);
41  fill(mPreshowerPed, mPreshowerPed+9, -1.);
42  fill(mPreshowerPedRms, mPreshowerPedRms+9, -1.);
43 
44  fill(mSmdeId, mSmdeId+11, -1);
45  fill(mSmdeAdc, mSmdeAdc+11, -1);
46  fill(mSmdeStatus, mSmdeStatus+11, -1);
47  fill(mSmdePed, mSmdePed+11, -1.);
48  fill(mSmdePedRms, mSmdePedRms+11, -1.);
49 
50  fill(mSmdpId, mSmdpId+11, -1);
51  fill(mSmdpAdc, mSmdpAdc+11, -1);
52  fill(mSmdpStatus, mSmdpStatus+11, -1);
53  fill(mSmdpPed, mSmdpPed+11, -1.);
54  fill(mSmdpPedRms, mSmdpPedRms+11, -1.);
55 
56  mTowerExitId = -1;
57  mVertexIndex = -1;
58  mFlag = -10;
59  mBad = -10;
60  mNHits = -1;
61  mNFitPoints = -1;
62  mNDedxPoints = -1;
63  mNHitsPossible = -1;
64  mCharge = -10;
65 
66  mP = -99.;
67  mEta = -99.;
68  mPhi = -99.;
69  mDeDx = -99.;
70  mNSigmaElectron = -99.;
71  mNSigmaPion = -99.;
72  mNSigmaKaon = -99.;
73  mNSigmaProton = -99.;
74  mHighestNeighbor = -99.;
75  mDeta = -99.;
76  mDphi = -99.;
77  mMomentum.setX(-99.); mMomentum.setY(-99.); mMomentum.setZ(-99.);
78 
79  mTofMatchedFlag = -10;
80  mVpdVz = -999.;
81  mDcaGlobal = -1.;
82  mTofTime = -1.;
83  mTofBeta = -10.;
84  mTofPathLength = -10.;
85  mTofSigmaElectron = -100.;
86  mTofProbElectron = -100.;
87 }
88 
89 void StEmcOfflineCalibrationTrack::setTowerId(Int_t id, Int_t aTid) { mTowerId[id] = aTid; }
90 void StEmcOfflineCalibrationTrack::setTowerAdc(Int_t id, Int_t aAdc) { mTowerAdc[id] = aAdc; }
91 void StEmcOfflineCalibrationTrack::setTowerStatus(Int_t id, Int_t aStat) { mTowerStatus[id] = aStat; }
92 void StEmcOfflineCalibrationTrack::setTowerPedestal(Int_t id, Float_t aPed) { mTowerPed[id] = aPed; }
93 void StEmcOfflineCalibrationTrack::setTowerPedestalRms(Int_t id, Float_t aRms) { mTowerPedRms[id] = aRms; }
94 void StEmcOfflineCalibrationTrack::setPreshowerAdc(Int_t id, Int_t bAdc) { mPreshowerAdc[id] = bAdc; }
95 void StEmcOfflineCalibrationTrack::setPreshowerStatus(Int_t id, Int_t bStat) { mPreshowerStatus[id] = bStat; }
96 void StEmcOfflineCalibrationTrack::setPreshowerPedestal(Int_t id, Float_t bPed) { mPreshowerPed[id] = bPed; }
97 void StEmcOfflineCalibrationTrack::setPreshowerPedestalRms(Int_t id, Float_t bRms) { mPreshowerPedRms[id] = bRms; }
98 void StEmcOfflineCalibrationTrack::setPreshowerCap(Int_t id, UChar_t bCap) { mPreshowerCap[id] = bCap; }
99 
100 void StEmcOfflineCalibrationTrack::setSmdeId(Int_t id, Int_t smdeId) { mSmdeId[id] = smdeId; }
101 void StEmcOfflineCalibrationTrack::setSmdeAdc(Int_t id, Int_t smdeAdc) { mSmdeAdc[id] = smdeAdc; }
102 void StEmcOfflineCalibrationTrack::setSmdeStatus(Int_t id, Int_t smdeStat) { mSmdeStatus[id] = smdeStat; }
103 void StEmcOfflineCalibrationTrack::setSmdePedestal(Int_t id, Float_t smdePed) { mSmdePed[id] = smdePed; }
104 void StEmcOfflineCalibrationTrack::setSmdePedestalRms(Int_t id, Float_t smdeRms) { mSmdePedRms[id] = smdeRms; }
105 void StEmcOfflineCalibrationTrack::setSmdpId(Int_t id, Int_t smdpId) { mSmdpId[id] = smdpId; }
106 void StEmcOfflineCalibrationTrack::setSmdpAdc(Int_t id, Int_t smdpAdc) { mSmdpAdc[id] = smdpAdc; }
107 void StEmcOfflineCalibrationTrack::setSmdpStatus(Int_t id, Int_t smdpStat) { mSmdpStatus[id] = smdpStat; }
108 void StEmcOfflineCalibrationTrack::setSmdpPedestal(Int_t id, Float_t smdpPed) { mSmdpPed[id] = smdpPed; }
109 void StEmcOfflineCalibrationTrack::setSmdpPedestalRms(Int_t id, Float_t smdpRms) { mSmdpPedRms[id] = smdpRms; }
110 
111 void StEmcOfflineCalibrationTrack::setTowerExitId(Int_t aTowExitId) { mTowerExitId = aTowExitId; }
112 void StEmcOfflineCalibrationTrack::setVertexIndex(Int_t aVertInd) { mVertexIndex = aVertInd; }
113 void StEmcOfflineCalibrationTrack::setFlag(Int_t aFlag) { mFlag = aFlag; }
114 void StEmcOfflineCalibrationTrack::setBad(Int_t aBad) { mBad = aBad; }
115 void StEmcOfflineCalibrationTrack::setNHits(Int_t aHits) { mNHits = aHits; }
116 void StEmcOfflineCalibrationTrack::setNFitPoints(Int_t aFitPts) { mNFitPoints = aFitPts; }
117 void StEmcOfflineCalibrationTrack::setNDedxPoints(Int_t aDeDxPts) { mNDedxPoints = aDeDxPts; }
118 void StEmcOfflineCalibrationTrack::setNHitsPossible(Int_t aHitsPoss) { mNHitsPossible = aHitsPoss; }
119 void StEmcOfflineCalibrationTrack::setCharge(Int_t aCharge) { mCharge = aCharge; }
120 void StEmcOfflineCalibrationTrack::setP(Double_t aP) { mP = aP; }
121 void StEmcOfflineCalibrationTrack::setEta(Double_t aEta) { mEta = aEta; }
122 void StEmcOfflineCalibrationTrack::setPhi(Double_t aPhi) { mPhi = aPhi; }
123 void StEmcOfflineCalibrationTrack::setDeDx(Double_t aDeDx) { mDeDx = aDeDx; }
124 void StEmcOfflineCalibrationTrack::setNSigmaElectron(Double_t aNSElec) { mNSigmaElectron = aNSElec; }
125 void StEmcOfflineCalibrationTrack::setNSigmaPion(Double_t aNSPion) { mNSigmaPion = aNSPion; }
126 void StEmcOfflineCalibrationTrack::setNSigmaKaon(Double_t aNSKaon) { mNSigmaKaon = aNSKaon; }
127 void StEmcOfflineCalibrationTrack::setNSigmaProton(Double_t aNSProton) { mNSigmaProton = aNSProton; }
128 void StEmcOfflineCalibrationTrack::setHighestNeighbor(Float_t aHN) { mHighestNeighbor = aHN; }
129 void StEmcOfflineCalibrationTrack::setDeta(Float_t aDeta) { mDeta = aDeta; }
130 void StEmcOfflineCalibrationTrack::setDphi(Float_t aDphi) { mDphi = aDphi; }
131 void StEmcOfflineCalibrationTrack::setMomentum(StThreeVectorF aMom) { mMomentum = aMom; }
132 void StEmcOfflineCalibrationTrack::setTofMatchedFlag(Int_t aTofFlag) { mTofMatchedFlag = aTofFlag; }
133 void StEmcOfflineCalibrationTrack::setVpdVz(Float_t aVpdVz) { mVpdVz = aVpdVz; }
134 void StEmcOfflineCalibrationTrack::setDcaGlobal(Float_t aDca) { mDcaGlobal = aDca; }
135 void StEmcOfflineCalibrationTrack::setTofTime(Float_t aTofTime) { mTofTime = aTofTime; }
136 void StEmcOfflineCalibrationTrack::setTofBeta(Float_t aTofBeta) { mTofBeta = aTofBeta; }
137 void StEmcOfflineCalibrationTrack::setTofPathlength(Float_t aTofPL) { mTofPathLength = aTofPL; }
138 void StEmcOfflineCalibrationTrack::setTofSigmaElectron(Float_t aTofSE) { mTofSigmaElectron = aTofSE; }
139 void StEmcOfflineCalibrationTrack::setTofProbElectron(Float_t aTofPE) { mTofProbElectron = aTofPE; }
140 //----------------------------------------------------------------------------------
141 StEmcOfflineCalibrationEvent::StEmcOfflineCalibrationEvent()
142 {
143  mTracks = new TClonesArray("StEmcOfflineCalibrationTrack",150);
144  mTriggers = new TClonesArray("StEmcOfflineCalibrationTrigger",20);
145  mVertices = new TClonesArray("StEmcOfflineCalibrationVertex",10);
146  Clear();
147 }
148 
149 StEmcOfflineCalibrationEvent::~StEmcOfflineCalibrationEvent()
150 {
151  Clear();
152  mTracks->Delete();
153  mVertices->Delete();
154  mTriggers->Delete();
155 
156  if(mTracks) delete mTracks;
157  if(mVertices) delete mVertices;
158  if(mTriggers) delete mTriggers;
159 }
160 
161 void StEmcOfflineCalibrationEvent::Clear(Option_t* option)
162 {
163  mTracks->Clear(option);
164  mTriggers->Clear(option);
165  mVertices->Clear(option);
166 
167  mFillNum = 0;
168  mDate = 0;
169  mTime = 0;
170  mRunNum = 0;
171  mEventId = 0;
172 
173  fill(mHighTowerTh, mHighTowerTh+4, 0);
174  fill(mHighTowerAdc, mHighTowerAdc+4800, 0);
175 }
176 
177 Int_t StEmcOfflineCalibrationEvent::nVertices() const { return mVertices->GetEntriesFast(); }
178 Int_t StEmcOfflineCalibrationEvent::nTriggers() const { return mTriggers->GetEntriesFast(); }
179 Int_t StEmcOfflineCalibrationEvent::nTracks() const { return mTracks->GetEntriesFast(); }
180 
181 StEmcOfflineCalibrationVertex* StEmcOfflineCalibrationEvent::vertex(Int_t iVert) const { return (StEmcOfflineCalibrationVertex*)mVertices->At(iVert); }
182 StEmcOfflineCalibrationTrack* StEmcOfflineCalibrationEvent::track(Int_t iTrack) const { return (StEmcOfflineCalibrationTrack*)mTracks->At(iTrack); }
183 StEmcOfflineCalibrationTrigger* StEmcOfflineCalibrationEvent::trigger(Int_t trigId) const {
184  TClonesArray *tmp = this->triggers();
185  for(int i=0; i<tmp->GetEntries(); i++) {
187  if(trigger->trigId() == trigId) return trigger;
188  }
189  return NULL;
190 }
191 
192 map<Int_t, Int_t> StEmcOfflineCalibrationEvent::towersAboveHighTowerTh(Int_t th) const
193 {
194  map<Int_t, Int_t> aMap;
195  for (Int_t iTow = 0; iTow < 4800; ++iTow){
196  Int_t softId = iTow+1;
197  Int_t mAdc = highTowerAdc(softId);
198  if (mAdc > highTowerTh(th))
199  aMap.insert(make_pair(softId,mAdc));
200  }
201  return aMap;
202 }
203 
204 void StEmcOfflineCalibrationEvent::setFill(Int_t aFill) { mFillNum = aFill; }
205 void StEmcOfflineCalibrationEvent::setRunNum(Int_t aRunNum) { mRunNum = aRunNum; }
206 void StEmcOfflineCalibrationEvent::setEventId(Int_t aEventId) { mEventId = aEventId; }
207 void StEmcOfflineCalibrationEvent::setDate(Int_t aDate) { mDate = aDate; }
208 void StEmcOfflineCalibrationEvent::setTime(Int_t aTime) { mTime = aTime; }
209 void StEmcOfflineCalibrationEvent::setHighTowerTh(Int_t level, Int_t thresh) { mHighTowerTh[level] = thresh; }
210 void StEmcOfflineCalibrationEvent::setHighTowerAdc(Int_t softId, Int_t adc) { mHighTowerAdc[softId-1] = adc; }
211 
212 // Adding functions
213 StEmcOfflineCalibrationTrack* StEmcOfflineCalibrationEvent::addTrack(){
214  return new ( (*mTracks)[mTracks->GetEntriesFast()] ) StEmcOfflineCalibrationTrack;
215 }
216 
217 StEmcOfflineCalibrationVertex* StEmcOfflineCalibrationEvent::addVertex(){
218  return new ( (*mVertices)[mVertices->GetEntriesFast()] ) StEmcOfflineCalibrationVertex;
219 }
220 
221 StEmcOfflineCalibrationTrigger* StEmcOfflineCalibrationEvent::addTrigger(){
222  return new ( (*mTriggers)[mTriggers->GetEntriesFast()] ) StEmcOfflineCalibrationTrigger;
223 }
224 
225 //----------------------------------------------------------------------------------
226 
227 StEmcOfflineCalibrationTrigger::StEmcOfflineCalibrationTrigger()
228 {
229  InitTrigValues();
230 }
231 
233 
234 void StEmcOfflineCalibrationTrigger::InitTrigValues()
235 {
236  mTrigId = -1;
237  mShouldFire = false;
238  mDidFire = false;
239 }
240 
241 void StEmcOfflineCalibrationTrigger::ClearTrigValues()
242 {
243  InitTrigValues();
244 }
245 
246 void StEmcOfflineCalibrationTrigger::setTrigId(Int_t aTrigId) { mTrigId = aTrigId; }
247 void StEmcOfflineCalibrationTrigger::setDidFire(Bool_t aDidFire) { mDidFire = aDidFire; }
248 void StEmcOfflineCalibrationTrigger::setShouldFire(Bool_t aShouldFire) { mShouldFire = aShouldFire; }
249 //----------------------------------------------------------------------------------
250 StEmcOfflineCalibrationVertex::StEmcOfflineCalibrationVertex()
251 {
252  mTracks.Clear();
253  mRanking = -999.;
254  mX = mY = mZ = -999.;
255 }
257 
258 void StEmcOfflineCalibrationVertex::setRanking(Double_t aRanking) { mRanking = aRanking; }
259 void StEmcOfflineCalibrationVertex::setX(Double_t aX) { mX = aX; }
260 void StEmcOfflineCalibrationVertex::setY(Double_t aY) { mY = aY; }
261 void StEmcOfflineCalibrationVertex::setZ(Double_t aZ) { mZ = aZ; }
262 //----------------------------------------------------------------------------------
263 StEmcOfflineCalibrationCluster::StEmcOfflineCalibrationCluster(){ Clear(); }
265 void StEmcOfflineCalibrationCluster::setCentralTrack(StEmcOfflineCalibrationTrack *tk) { mCentralTrack = tk; }
266 void StEmcOfflineCalibrationCluster::Clear(Option_t *option){ mNeighborTracks.Clear(); mCentralTrack = 0; }
267 //----------------------------------------------------------------------------------