5 |
**/ |
**/ |
6 |
#include <TObject.h> |
#include <TObject.h> |
7 |
#include <CaloLevel2.h> |
#include <CaloLevel2.h> |
8 |
|
|
9 |
|
// |
10 |
ClassImp(CaloTrkVar); |
ClassImp(CaloTrkVar); |
11 |
ClassImp(CaloLevel2); |
ClassImp(CaloLevel2); |
12 |
|
|
14 |
* CaloTrkVar constructor |
* CaloTrkVar constructor |
15 |
**/ |
**/ |
16 |
CaloTrkVar::CaloTrkVar() { |
CaloTrkVar::CaloTrkVar() { |
17 |
|
this->Clear(); |
18 |
|
} |
19 |
|
|
20 |
|
/** |
21 |
|
* Clear variables |
22 |
|
**/ |
23 |
|
void CaloTrkVar::Clear(Option_t *t) { |
24 |
|
//void CaloTrkVar::Clear() { |
25 |
trkseqno = 0; |
trkseqno = 0; |
26 |
noint = 0; |
noint = 0; |
27 |
ncore = 0; |
ncore = 0; |
46 |
qlow = 0.; |
qlow = 0.; |
47 |
nlow = 0; |
nlow = 0; |
48 |
dX0l = 0.; |
dX0l = 0.; |
49 |
for (Int_t i = 0; i<2 ; i++){ |
memset(tbar, 0, 2*22*sizeof(Float_t)); |
50 |
for ( Int_t j = 0; j<22; j++){ |
memset(tibar, 0, 2*22*sizeof(Int_t)); |
|
tibar[j][i] = 0; |
|
|
tbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
51 |
} |
} |
52 |
|
|
53 |
/** |
/** |
87 |
**/ |
**/ |
88 |
CaloLevel2::CaloLevel2() { |
CaloLevel2::CaloLevel2() { |
89 |
// |
// |
90 |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
// CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
91 |
|
CaloTrk = 0; //ELENA |
92 |
// |
// |
93 |
nstrip = 0; |
this->Clear(); |
94 |
qtot = 0.; |
// |
95 |
impx = 0.; |
} |
96 |
impy = 0.; |
/** |
97 |
tanx = 0.; |
* Create the TClonesArray |
98 |
tany = 0.; |
**/ |
99 |
qmax = 0.; |
void CaloLevel2::Set(){//ELENA |
100 |
nx22 = 0; |
if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
101 |
qx22 = 0.; |
}//ELENA |
102 |
elen = 0.; |
//-------------------------------------- |
103 |
selen = 0.; |
// |
104 |
for (Int_t i = 0; i<4 ; i++){ |
// |
105 |
qq[i] = 0.; |
//-------------------------------------- |
106 |
perr[i] = 0; |
void CaloLevel2::SetTrackArray(TClonesArray *track){//ELENA |
107 |
swerr[i] = 0; |
// if(track && strcmp(track->GetClass()->GetName(),"CaloTrkVar")==0){ |
108 |
crc[i] = 0; |
if(track ){ |
109 |
if ( i < 2 ){ |
if(CaloTrk)CaloTrk->Clear("C"); |
110 |
planemax[i] = 0; |
CaloTrk = track; |
111 |
varcfit[i] = 0.; |
} |
112 |
npcfit[i] = 0; |
} |
|
for ( Int_t j = 0; j<22; j++){ |
|
|
cibar[j][i] = 0; |
|
|
cbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
good = 0; |
|
|
selftrigger = 0; |
|
|
estrip = TArrayF(0,NULL); |
|
|
}; |
|
113 |
|
|
114 |
void CaloLevel2::Clear() { |
/** |
115 |
|
* Clear the CaloLevel2 object |
116 |
|
**/ |
117 |
|
void CaloLevel2::Clear(Option_t *t ) { |
118 |
// |
// |
119 |
CaloTrk->Clear(); |
// CaloTrk->Clear(); //ELENA |
120 |
|
if(CaloTrk)CaloTrk->Delete(); //ELENA |
121 |
// |
// |
122 |
nstrip = 0; |
nstrip = 0; |
123 |
|
nsatstrip = 0; |
124 |
qtot = 0.; |
qtot = 0.; |
125 |
impx = 0.; |
// impx = 0.; |
126 |
impy = 0.; |
// impy = 0.; |
|
tanx = 0.; |
|
|
tany = 0.; |
|
127 |
qmax = 0.; |
qmax = 0.; |
128 |
nx22 = 0; |
nx22 = 0; |
129 |
qx22 = 0.; |
qx22 = 0.; |
130 |
elen = 0.; |
elen = 0.; |
131 |
selen = 0.; |
selen = 0.; |
132 |
for (Int_t i = 0; i<4 ; i++){ |
memset(perr, 0, 4*sizeof(Int_t)); |
133 |
qq[i] = 0.; |
memset(swerr, 0, 4*sizeof(Int_t)); |
134 |
perr[i] = 0; |
memset(crc, 0, 4*sizeof(Int_t)); |
135 |
swerr[i] = 0; |
memset(qq, 0, 4*sizeof(Int_t)); |
136 |
crc[i] = 0; |
memset(varcfit, 0, 4*sizeof(Float_t)); |
137 |
if ( i < 2 ){ |
memset(npcfit, 0, 4*sizeof(Int_t)); |
138 |
planemax[i] = 0; |
memset(tanx, 0, 2*sizeof(Int_t)); |
139 |
varcfit[i] = 0.; |
memset(tany, 0, 2*sizeof(Int_t)); |
140 |
npcfit[i] = 0; |
memset(fitmode, 0, 2*sizeof(Int_t)); |
141 |
for ( Int_t j = 0; j<22; j++){ |
memset(planemax, 0, 2*sizeof(Int_t)); |
142 |
cibar[j][i] = 0; |
memset(selfdelay, 0, 4*7*sizeof(Int_t)); |
143 |
cbar[j][i] = 0.; |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
144 |
}; |
memset(cbar, 0, 2*22*sizeof(Float_t)); |
|
}; |
|
|
}; |
|
145 |
good = 0; |
good = 0; |
146 |
selftrigger = 0; |
selftrigger = 0; |
147 |
estrip = TArrayF(0,NULL); |
// |
148 |
}; |
} |
149 |
|
|
150 |
|
/** |
151 |
|
* Delete the CaloLevel2 object |
152 |
|
**/ |
153 |
|
void CaloLevel2::Delete(Option_t *t) { //ELENA |
154 |
|
if(CaloTrk){ //ELENA |
155 |
|
CaloTrk->Delete(); //ELENA |
156 |
|
delete CaloTrk; //ELENA |
157 |
|
} //ELENA |
158 |
|
} //ELENA |
159 |
|
|
160 |
/** |
/** |
161 |
* Gives the detected energy for the given strip once loaded the event |
* CaloLevel2 |
162 |
**/ |
**/ |
163 |
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
Bool_t CaloLevel2::IsGood(Bool_t strict) { |
164 |
Int_t splane = 0; |
// |
165 |
Int_t sstrip = 0; |
if ( strict ){ |
166 |
// |
if ( !good ) return(false); |
167 |
if ( nstrip == 0 ) return(0.); |
if ( perr[0] ) return(false); |
168 |
// |
if ( perr[1] ) return(false); |
169 |
for (Int_t i = 0; i<nstrip; i++ ){ |
if ( perr[2] ) return(false); |
170 |
if ( view == 0 ){ |
if ( perr[3] ) return(false); |
171 |
if ( estrip.At(i) > 0. ){ |
if ( swerr[0] ) return(false); |
172 |
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
if ( swerr[1] ) return(false); |
173 |
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
if ( swerr[2] ) return(false); |
174 |
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
if ( swerr[3] ) return(false); |
175 |
}; |
if ( crc[0] ) return(false); |
176 |
} else { |
if ( crc[1] ) return(false); |
177 |
if ( estrip.At(i) < 0. ){ |
if ( crc[2] ) return(false); |
178 |
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
if ( crc[3] ) return(false); |
179 |
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
} else { |
180 |
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
if ( perr[0] == 129 || perr[0] == 136 || perr[0] == 142 || perr[0] == 143 ) return(false); |
181 |
}; |
if ( perr[1] == 129 || perr[1] == 136 || perr[1] == 142 || perr[1] == 143 ) return(false); |
182 |
}; |
if ( perr[2] == 129 || perr[2] == 136 || perr[2] == 142 || perr[2] == 143 ) return(false); |
183 |
|
if ( perr[3] == 129 || perr[3] == 136 || perr[3] == 142 || perr[3] == 143 ) return(false); |
184 |
}; |
}; |
185 |
return(0.); |
// |
186 |
}; |
return(true); |
187 |
|
} |
188 |
|
|
189 |
/** |
/** |
190 |
* Given estrip entry returns energy and strip |
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
191 |
|
*/ |
192 |
|
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
193 |
|
|
194 |
|
l2->good = good; |
195 |
|
l2->selftrigger = selftrigger; |
196 |
|
l2->nstrip = nstrip; |
197 |
|
l2->nx22 = nx22; |
198 |
|
l2->qtot = qtot; |
199 |
|
l2->qx22 = qx22; |
200 |
|
l2->qmax = qmax; |
201 |
|
// l2->impx = impx; |
202 |
|
// l2->impy = impy; |
203 |
|
// l2->tanx = tanx; |
204 |
|
// l2->tany = tany; |
205 |
|
l2->elen = elen; |
206 |
|
l2->selen = selen; |
207 |
|
|
208 |
|
for(Int_t i=0;i<2;i++){ |
209 |
|
l2->planemax[i] = planemax[i]; |
210 |
|
l2->varcfit[i] = varcfit[i]; |
211 |
|
l2->npcfit[i] = npcfit[i]; |
212 |
|
} |
213 |
|
for(Int_t i=0;i<4;i++){ |
214 |
|
l2->perr[i] = perr[i]; |
215 |
|
l2->swerr[i] = swerr[i]; |
216 |
|
l2->calcrc[i] = crc[i]; |
217 |
|
l2->qq[i] = qq[i]; |
218 |
|
} |
219 |
|
|
220 |
|
if(CaloTrk){ //ELENA |
221 |
|
l2->calntrk = CaloTrk->GetEntries(); |
222 |
|
for(Int_t i=0;i<l2->calntrk;i++){ |
223 |
|
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
224 |
|
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
225 |
|
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
226 |
|
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
227 |
|
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
228 |
|
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
229 |
|
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
230 |
|
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
231 |
|
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
232 |
|
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
233 |
|
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
234 |
|
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
235 |
|
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
236 |
|
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
237 |
|
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
238 |
|
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
239 |
|
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
240 |
|
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
241 |
|
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
242 |
|
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
243 |
|
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
244 |
|
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
245 |
|
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
246 |
|
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
247 |
|
for (Int_t j=0; j<2; j++){ |
248 |
|
for (Int_t k=0; k<22; k++){ |
249 |
|
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
250 |
|
}; |
251 |
|
}; |
252 |
|
} |
253 |
|
} //ELENA |
254 |
|
} |
255 |
|
|
256 |
|
/** |
257 |
|
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
258 |
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
259 |
**/ |
**/ |
260 |
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
Float_t CaloLevel2::impx(Int_t tr){ |
261 |
if ( entry>nstrip ) return(0.); |
if ( tr == 0 ) return(cbar[0][0]); |
262 |
// |
if ( tr == 1 ) { |
263 |
if ( estrip.At(entry) > 0. ){ |
if ( !CaloTrk ) return(-110.); |
264 |
view = 0; |
TClonesArray &t = *(CaloTrk); |
265 |
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
266 |
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
267 |
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][0]); |
268 |
}; |
}; |
269 |
if ( estrip.At(entry) < 0. ){ |
}; |
270 |
view = 1; |
if ( tr !=0 && tr !=1 ){ |
271 |
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
printf(" Cannot get impx for other than calo or selftrigger tracks!\n"); |
272 |
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
} else { |
273 |
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
printf(" Cannot find selftrigger block\n"); |
274 |
}; |
}; |
275 |
// |
return(-100.); |
|
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
|
|
// |
|
|
view = -1; |
|
|
plane = -1; |
|
|
strip = -1; |
|
|
return(0.); |
|
276 |
} |
} |
277 |
|
|
278 |
|
/** |
279 |
|
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
280 |
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
281 |
|
**/ |
282 |
|
Float_t CaloLevel2::impy(Int_t tr){ |
283 |
|
if ( tr == 0 ) return(cbar[0][1]); |
284 |
|
if ( tr == 1 ) { |
285 |
|
if ( !CaloTrk ) return(-110.); |
286 |
|
TClonesArray &t = *(CaloTrk); |
287 |
|
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
288 |
|
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
289 |
|
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][1]); |
290 |
|
}; |
291 |
|
}; |
292 |
|
if ( tr !=0 && tr !=1 ){ |
293 |
|
printf(" Cannot get impy for other than calo or selftrigger tracks!\n"); |
294 |
|
} else { |
295 |
|
printf(" Cannot find selftrigger block\n"); |
296 |
|
}; |
297 |
|
return(-100.); |
298 |
|
} |
299 |
|
/** |
300 |
|
* Should return the energy in GeV if the particle would be an electron |
301 |
|
* using a parametrization taken from Monte Carlo simulation |
302 |
|
**/ |
303 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
304 |
if ( nstrip == 0 ) return; |
if ( nstrip == 0 ) return; |
305 |
energy = qtot * 40.82 * 0.000106; |
energy = qtot / 260.; |
306 |
|
// energy = qtot * 40.82 * 0.000106; |
307 |
sigma = 0.; |
sigma = 0.; |
308 |
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
309 |
return; |
return; |
310 |
}; |
} |
311 |
|
|
312 |
/** |
/** |
313 |
* Returns pointer to the set of track-related variables "itrk" |
* Returns pointer to the set of track-related variables "itrk" |
319 |
printf(" stored track related variables = %i \n",ntrk()); |
printf(" stored track related variables = %i \n",ntrk()); |
320 |
return(NULL); |
return(NULL); |
321 |
} |
} |
322 |
|
if(!CaloTrk)return 0; //ELENA |
323 |
TClonesArray &t = *(CaloTrk); |
TClonesArray &t = *(CaloTrk); |
324 |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
325 |
return calotrack; |
return calotrack; |
326 |
} |
} |
327 |
|
|
328 |
|
/** |
329 |
|
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
330 |
|
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
331 |
|
*/ |
332 |
|
CaloTrkVar *CaloLevel2::GetCaloStoredTrack(int seqno){ |
333 |
|
|
334 |
|
if( ntrk()==0 ){ |
335 |
|
printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i but no Calorimeter tracks are stored\n",seqno); |
336 |
|
return NULL; |
337 |
|
}; |
338 |
|
|
339 |
|
CaloTrkVar *c = 0; |
340 |
|
Int_t it_calo=0; |
341 |
|
|
342 |
|
do { |
343 |
|
c = GetCaloTrkVar(it_calo); |
344 |
|
it_calo++; |
345 |
|
} while( c && seqno != c->trkseqno && it_calo < ntrk()); |
346 |
|
|
347 |
|
if(!c || seqno != c->trkseqno){ |
348 |
|
c = 0; |
349 |
|
if(seqno!=-1 && seqno !=-2 && seqno!=-3 ) printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i does not match Calorimeter stored tracks\n",seqno); |
350 |
|
}; |
351 |
|
return c; |
352 |
|
|
353 |
|
} |