1 |
/** |
2 |
* \file src/CaloLevel2.cpp |
3 |
* \author Emiliano Mocchiutti |
4 |
* |
5 |
**/ |
6 |
#include <TObject.h> |
7 |
#include <CaloLevel2.h> |
8 |
ClassImp(CaloTrkVar); |
9 |
ClassImp(CaloLevel2); |
10 |
|
11 |
/** |
12 |
* CaloTrkVar constructor |
13 |
**/ |
14 |
CaloTrkVar::CaloTrkVar() { |
15 |
trkseqno = 0; |
16 |
noint = 0; |
17 |
ncore = 0; |
18 |
qcore = 0.; |
19 |
ncyl = 0; |
20 |
qcyl = 0.; |
21 |
qtrack = 0.; |
22 |
qtrackx = 0.; |
23 |
qtracky = 0.; |
24 |
dxtrack = 0.; |
25 |
dytrack = 0.; |
26 |
qlast = 0.; |
27 |
nlast = 0; |
28 |
qpre = 0.; |
29 |
npre = 0; |
30 |
qpresh = 0.; |
31 |
npresh = 0; |
32 |
qtr = 0.; |
33 |
ntr = 0; |
34 |
planetot = 0; |
35 |
qmean = 0.; |
36 |
qlow = 0.; |
37 |
nlow = 0; |
38 |
dX0l = 0.; |
39 |
for (Int_t i = 0; i<2 ; i++){ |
40 |
for ( Int_t j = 0; j<22; j++){ |
41 |
tibar[j][i] = 0; |
42 |
tbar[j][i] = 0.; |
43 |
}; |
44 |
}; |
45 |
} |
46 |
|
47 |
/** |
48 |
* Copies from t to this |
49 |
**/ |
50 |
CaloTrkVar::CaloTrkVar(const CaloTrkVar &t){ |
51 |
trkseqno = t.trkseqno; |
52 |
noint = t.noint; |
53 |
ncore = t.ncore; |
54 |
qcore = t.qcore; |
55 |
ncyl = t.ncyl; |
56 |
qcyl = t.qcyl; |
57 |
qtrack = t.qtrack; |
58 |
qtrackx = t.qtrackx; |
59 |
qtracky = t.qtracky; |
60 |
dxtrack = t.dxtrack; |
61 |
dytrack = t.dytrack; |
62 |
qlast = t.qlast; |
63 |
nlast = t.nlast; |
64 |
qpre = t.qpre; |
65 |
npre = t.npre; |
66 |
qpresh = t.qpresh; |
67 |
npresh = t.npresh; |
68 |
qtr = t.qtr; |
69 |
ntr = t.ntr; |
70 |
planetot = t.planetot; |
71 |
qmean = t.qmean; |
72 |
dX0l = t.dX0l; |
73 |
qlow = t.qlow; |
74 |
nlow = t.nlow; |
75 |
memcpy(tibar,t.tibar,sizeof(tibar)); |
76 |
memcpy(tbar,t.tbar,sizeof(tbar)); |
77 |
} |
78 |
|
79 |
/** |
80 |
* CaloLevel2 constructor |
81 |
**/ |
82 |
CaloLevel2::CaloLevel2() { |
83 |
// |
84 |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
85 |
// |
86 |
nstrip = 0; |
87 |
qtot = 0.; |
88 |
impx = 0.; |
89 |
impy = 0.; |
90 |
tanx = 0.; |
91 |
tany = 0.; |
92 |
qmax = 0.; |
93 |
nx22 = 0; |
94 |
qx22 = 0.; |
95 |
elen = 0.; |
96 |
selen = 0.; |
97 |
for (Int_t i = 0; i<4 ; i++){ |
98 |
qq[i] = 0.; |
99 |
perr[i] = 0; |
100 |
swerr[i] = 0; |
101 |
crc[i] = 0; |
102 |
if ( i < 2 ){ |
103 |
planemax[i] = 0; |
104 |
varcfit[i] = 0.; |
105 |
npcfit[i] = 0; |
106 |
for ( Int_t j = 0; j<22; j++){ |
107 |
cibar[j][i] = 0; |
108 |
cbar[j][i] = 0.; |
109 |
}; |
110 |
}; |
111 |
}; |
112 |
good = 0; |
113 |
selftrigger = 0; |
114 |
estrip = TArrayF(0,NULL); |
115 |
}; |
116 |
|
117 |
void CaloLevel2::Clear() { |
118 |
// |
119 |
CaloTrk->Clear(); |
120 |
// |
121 |
nstrip = 0; |
122 |
qtot = 0.; |
123 |
impx = 0.; |
124 |
impy = 0.; |
125 |
tanx = 0.; |
126 |
tany = 0.; |
127 |
qmax = 0.; |
128 |
nx22 = 0; |
129 |
qx22 = 0.; |
130 |
elen = 0.; |
131 |
selen = 0.; |
132 |
for (Int_t i = 0; i<4 ; i++){ |
133 |
qq[i] = 0.; |
134 |
perr[i] = 0; |
135 |
swerr[i] = 0; |
136 |
crc[i] = 0; |
137 |
if ( i < 2 ){ |
138 |
planemax[i] = 0; |
139 |
varcfit[i] = 0.; |
140 |
npcfit[i] = 0; |
141 |
for ( Int_t j = 0; j<22; j++){ |
142 |
cibar[j][i] = 0; |
143 |
cbar[j][i] = 0.; |
144 |
}; |
145 |
}; |
146 |
}; |
147 |
good = 0; |
148 |
selftrigger = 0; |
149 |
// estrip = TArrayF(0,NULL); |
150 |
estrip.Reset(); |
151 |
}; |
152 |
|
153 |
|
154 |
/** |
155 |
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
156 |
*/ |
157 |
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
158 |
|
159 |
l2->good = good; |
160 |
l2->selftrigger = selftrigger; |
161 |
l2->nstrip = nstrip; |
162 |
l2->nx22 = nx22; |
163 |
l2->qtot = qtot; |
164 |
l2->qx22 = qx22; |
165 |
l2->qmax = qmax; |
166 |
l2->impx = impx; |
167 |
l2->impy = impy; |
168 |
l2->tanx = tanx; |
169 |
l2->tany = tany; |
170 |
l2->elen = elen; |
171 |
l2->selen = selen; |
172 |
|
173 |
for(Int_t i=0;i<2;i++){ |
174 |
l2->planemax[i] = planemax[i]; |
175 |
l2->varcfit[i] = varcfit[i]; |
176 |
l2->npcfit[i] = npcfit[i]; |
177 |
} |
178 |
for(Int_t i=0;i<4;i++){ |
179 |
l2->perr[i] = perr[i]; |
180 |
l2->swerr[i] = swerr[i]; |
181 |
l2->calcrc[i] = crc[i]; |
182 |
l2->qq[i] = qq[i]; |
183 |
} |
184 |
|
185 |
l2->calntrk = CaloTrk->GetEntries(); |
186 |
|
187 |
for(Int_t i=0;i<l2->calntrk;i++){ |
188 |
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
189 |
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
190 |
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
191 |
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
192 |
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
193 |
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
194 |
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
195 |
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
196 |
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
197 |
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
198 |
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
199 |
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
200 |
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
201 |
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
202 |
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
203 |
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
204 |
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
205 |
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
206 |
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
207 |
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
208 |
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
209 |
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
210 |
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
211 |
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
212 |
} |
213 |
|
214 |
} |
215 |
|
216 |
/** |
217 |
* Gives the detected energy for the given strip once loaded the event |
218 |
**/ |
219 |
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
220 |
Int_t splane = 0; |
221 |
Int_t sstrip = 0; |
222 |
// |
223 |
if ( nstrip == 0 ) return(0.); |
224 |
// |
225 |
for (Int_t i = 0; i<nstrip; i++ ){ |
226 |
if ( view == 0 ){ |
227 |
if ( estrip.At(i) > 0. ){ |
228 |
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
229 |
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
230 |
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
231 |
}; |
232 |
} else { |
233 |
if ( estrip.At(i) < 0. ){ |
234 |
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
235 |
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
236 |
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
237 |
}; |
238 |
}; |
239 |
}; |
240 |
return(0.); |
241 |
}; |
242 |
|
243 |
/** |
244 |
* Given estrip entry returns energy and strip |
245 |
**/ |
246 |
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
247 |
if ( entry>nstrip ) return(0.); |
248 |
// |
249 |
if ( estrip.At(entry) > 0. ){ |
250 |
view = 0; |
251 |
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
252 |
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
253 |
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
254 |
}; |
255 |
if ( estrip.At(entry) < 0. ){ |
256 |
view = 1; |
257 |
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
258 |
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
259 |
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
260 |
}; |
261 |
// |
262 |
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
263 |
// |
264 |
view = -1; |
265 |
plane = -1; |
266 |
strip = -1; |
267 |
return(0.); |
268 |
} |
269 |
|
270 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
271 |
if ( nstrip == 0 ) return; |
272 |
energy = qtot * 40.82 * 0.000106; |
273 |
sigma = 0.; |
274 |
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
275 |
return; |
276 |
}; |
277 |
|
278 |
/** |
279 |
* Returns pointer to the set of track-related variables "itrk" |
280 |
**/ |
281 |
CaloTrkVar *CaloLevel2::GetCaloTrkVar(Int_t itrk){ |
282 |
// |
283 |
if(itrk >= ntrk()){ |
284 |
printf(" CaloLevel2 ERROR: track related variables set %i does not exists! \n",itrk); |
285 |
printf(" stored track related variables = %i \n",ntrk()); |
286 |
return(NULL); |
287 |
} |
288 |
TClonesArray &t = *(CaloTrk); |
289 |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
290 |
return calotrack; |
291 |
} |