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 |
|
|
15 |
**/ |
**/ |
16 |
CaloTrkVar::CaloTrkVar() { |
CaloTrkVar::CaloTrkVar() { |
17 |
this->Clear(); |
this->Clear(); |
18 |
}; |
} |
19 |
|
|
20 |
/** |
/** |
21 |
* Clear variables |
* Clear variables |
22 |
**/ |
**/ |
23 |
void CaloTrkVar::Clear() { |
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; |
87 |
**/ |
**/ |
88 |
CaloLevel2::CaloLevel2() { |
CaloLevel2::CaloLevel2() { |
89 |
// |
// |
90 |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
// CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
91 |
estrip = TArrayI(0,NULL); |
CaloTrk = 0; //ELENA |
92 |
// |
// |
93 |
this->Clear(); |
this->Clear(); |
94 |
// |
// |
95 |
}; |
} |
96 |
|
/** |
97 |
|
* Create the TClonesArray |
98 |
|
**/ |
99 |
|
void CaloLevel2::Set(){//ELENA |
100 |
|
if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
101 |
|
}//ELENA |
102 |
|
|
103 |
/** |
/** |
104 |
* Clear the CaloLevel2 object |
* Clear the CaloLevel2 object |
105 |
**/ |
**/ |
106 |
void CaloLevel2::Clear() { |
void CaloLevel2::Clear(Option_t *t ) { |
107 |
// |
// |
108 |
CaloTrk->Clear(); |
// CaloTrk->Clear(); //ELENA |
109 |
|
if(CaloTrk)CaloTrk->Delete(); //ELENA |
110 |
// |
// |
111 |
nstrip = 0; |
nstrip = 0; |
112 |
qtot = 0.; |
qtot = 0.; |
113 |
impx = 0.; |
// impx = 0.; |
114 |
impy = 0.; |
// impy = 0.; |
|
tanx = 0.; |
|
|
tany = 0.; |
|
115 |
qmax = 0.; |
qmax = 0.; |
116 |
nx22 = 0; |
nx22 = 0; |
117 |
qx22 = 0.; |
qx22 = 0.; |
121 |
memset(swerr, 0, 4*sizeof(Int_t)); |
memset(swerr, 0, 4*sizeof(Int_t)); |
122 |
memset(crc, 0, 4*sizeof(Int_t)); |
memset(crc, 0, 4*sizeof(Int_t)); |
123 |
memset(qq, 0, 4*sizeof(Int_t)); |
memset(qq, 0, 4*sizeof(Int_t)); |
124 |
memset(varcfit, 0, 2*sizeof(Float_t)); |
memset(varcfit, 0, 4*sizeof(Float_t)); |
125 |
memset(npcfit, 0, 2*sizeof(Int_t)); |
memset(npcfit, 0, 4*sizeof(Int_t)); |
126 |
|
memset(tanx, 0, 2*sizeof(Int_t)); |
127 |
|
memset(tany, 0, 2*sizeof(Int_t)); |
128 |
|
memset(fitmode, 0, 2*sizeof(Int_t)); |
129 |
memset(planemax, 0, 2*sizeof(Int_t)); |
memset(planemax, 0, 2*sizeof(Int_t)); |
130 |
|
memset(selfdelay, 0, 4*7*sizeof(Int_t)); |
131 |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
132 |
memset(cbar, 0, 2*22*sizeof(Float_t)); |
memset(cbar, 0, 2*22*sizeof(Float_t)); |
133 |
good = 0; |
good = 0; |
134 |
selftrigger = 0; |
selftrigger = 0; |
135 |
estrip.Reset(); |
// |
136 |
}; |
} |
137 |
|
|
138 |
|
/** |
139 |
|
* Delete the CaloLevel2 object |
140 |
|
**/ |
141 |
|
void CaloLevel2::Delete(Option_t *t) { //ELENA |
142 |
|
if(CaloTrk){ //ELENA |
143 |
|
CaloTrk->Delete(); //ELENA |
144 |
|
delete CaloTrk; //ELENA |
145 |
|
} //ELENA |
146 |
|
} //ELENA |
147 |
|
|
148 |
/** |
/** |
149 |
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
157 |
l2->qtot = qtot; |
l2->qtot = qtot; |
158 |
l2->qx22 = qx22; |
l2->qx22 = qx22; |
159 |
l2->qmax = qmax; |
l2->qmax = qmax; |
160 |
l2->impx = impx; |
// l2->impx = impx; |
161 |
l2->impy = impy; |
// l2->impy = impy; |
162 |
l2->tanx = tanx; |
// l2->tanx = tanx; |
163 |
l2->tany = tany; |
// l2->tany = tany; |
164 |
l2->elen = elen; |
l2->elen = elen; |
165 |
l2->selen = selen; |
l2->selen = selen; |
166 |
|
|
176 |
l2->qq[i] = qq[i]; |
l2->qq[i] = qq[i]; |
177 |
} |
} |
178 |
|
|
179 |
l2->calntrk = CaloTrk->GetEntries(); |
if(CaloTrk){ //ELENA |
180 |
|
l2->calntrk = CaloTrk->GetEntries(); |
181 |
for(Int_t i=0;i<l2->calntrk;i++){ |
for(Int_t i=0;i<l2->calntrk;i++){ |
182 |
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
183 |
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
184 |
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
185 |
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
186 |
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
187 |
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
188 |
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
189 |
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
190 |
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
191 |
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
192 |
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
193 |
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
194 |
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
195 |
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
196 |
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
197 |
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
198 |
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
199 |
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
200 |
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
201 |
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
202 |
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
203 |
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
204 |
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
205 |
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
206 |
for (Int_t j=0; j<2; j++){ |
for (Int_t j=0; j<2; j++){ |
207 |
for (Int_t k=0; k<22; k++){ |
for (Int_t k=0; k<22; k++){ |
208 |
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
209 |
}; |
}; |
210 |
}; |
}; |
211 |
} |
} |
212 |
|
} //ELENA |
213 |
} |
} |
214 |
|
|
215 |
/** |
/** |
216 |
* Returns the detected energy for the given strip once loaded the event |
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
217 |
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
218 |
**/ |
**/ |
219 |
Float_t CaloLevel2::GetEstrip(Int_t sview, Int_t splane, Int_t sstrip){ |
Float_t CaloLevel2::impx(Int_t tr){ |
220 |
Int_t view = -1; |
if ( tr == 0 ) return(cbar[0][0]); |
221 |
Int_t plane = -1; |
if ( tr == 1 ) { |
222 |
Int_t strip = -1; |
if ( !CaloTrk ) return(-110.); |
223 |
Float_t mip = 0.; |
TClonesArray &t = *(CaloTrk); |
224 |
// |
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
225 |
if ( nstrip == 0 ) return(0.); |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
226 |
// |
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][0]); |
227 |
for (Int_t i = 0; i<nstrip; i++ ){ |
}; |
228 |
// |
}; |
229 |
mip = DecodeEstrip(i,view,plane,strip); |
if ( tr !=0 && tr !=1 ){ |
230 |
// |
printf(" Cannot get impx for other than calo or selftrigger tracks!\n"); |
231 |
if ( view == sview && splane == plane && sstrip == strip ) return(mip); |
} else { |
232 |
// |
printf(" Cannot find selftrigger block\n"); |
|
// entry are ordered by strip, plane and view number. Go out if you pass the input strip |
|
|
// |
|
|
if ( view == sview && plane == splane && strip > sstrip ) return(0.); |
|
|
if ( view == sview && plane > splane ) return(0.); |
|
|
if ( view > sview ) return(0.); |
|
|
// |
|
233 |
}; |
}; |
234 |
return(0.); |
return(-100.); |
235 |
}; |
} |
236 |
|
|
237 |
/** |
/** |
238 |
* Given estrip entry returns energy plus view, plane and strip numbers |
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
239 |
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
240 |
**/ |
**/ |
241 |
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
Float_t CaloLevel2::impy(Int_t tr){ |
242 |
// |
if ( tr == 0 ) return(cbar[0][1]); |
243 |
if ( entry>nstrip ) return(0.); |
if ( tr == 1 ) { |
244 |
// |
if ( !CaloTrk ) return(-110.); |
245 |
// printf(" num lim %f \n",std::numeric_limits<Float_t>::max()); |
TClonesArray &t = *(CaloTrk); |
246 |
// printf(" estrip.At(%i) = %i \n",entry,estrip.At(entry)); |
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
247 |
// |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
248 |
Int_t eval = 0; |
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][1]); |
|
if ( estrip.At(entry) > 0. ){ |
|
|
view = 0; |
|
|
eval = estrip.At(entry); |
|
|
} else { |
|
|
view = 1; |
|
|
eval = -estrip.At(entry); |
|
|
}; |
|
|
// |
|
|
Int_t fbi = 0; |
|
|
fbi = (Int_t)truncf((Float_t)(eval/1000000000)); |
|
|
// |
|
|
Int_t plom = 0; |
|
|
plom = (Int_t)truncf((Float_t)((eval-fbi*1000000000)/10000000)); |
|
|
// |
|
|
Float_t tim = 100000.; |
|
|
plane = plom; |
|
|
if ( fbi == 1 ) tim = 10000.; |
|
|
if ( plom > 21 ){ |
|
|
plane = plom - 22; |
|
|
if ( fbi == 1 ){ |
|
|
tim = 1000.; |
|
|
} else { |
|
|
tim = 100.; |
|
249 |
}; |
}; |
250 |
}; |
}; |
251 |
if ( plom > 43 ){ |
if ( tr !=0 && tr !=1 ){ |
252 |
plane = plom - 44; |
printf(" Cannot get impy for other than calo or selftrigger tracks!\n"); |
253 |
tim = 10.; |
} else { |
254 |
}; |
printf(" Cannot find selftrigger block\n"); |
|
if ( plom > 65 ){ |
|
|
plane = plom - 66; |
|
|
tim = 1.; |
|
255 |
}; |
}; |
256 |
// |
return(-100.); |
|
strip = (Int_t)truncf((Float_t)((eval - fbi*1000000000 -plom*10000000)/100000)); |
|
|
// |
|
|
Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim; |
|
|
// |
|
|
if ( mip > 0. && mip < 99999. ) return(mip); |
|
|
// |
|
|
printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry); |
|
|
// |
|
|
view = -1; |
|
|
plane = -1; |
|
|
strip = -1; |
|
|
return(0.); |
|
257 |
} |
} |
|
|
|
258 |
/** |
/** |
259 |
* Should return the energy in GeV if the particle would be an electron |
* Should return the energy in GeV if the particle would be an electron |
260 |
* using a parametrization taken from Monte Carlo simulation |
* using a parametrization taken from Monte Carlo simulation |
265 |
sigma = 0.; |
sigma = 0.; |
266 |
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
267 |
return; |
return; |
268 |
}; |
} |
269 |
|
|
270 |
/** |
/** |
271 |
* Returns pointer to the set of track-related variables "itrk" |
* Returns pointer to the set of track-related variables "itrk" |
277 |
printf(" stored track related variables = %i \n",ntrk()); |
printf(" stored track related variables = %i \n",ntrk()); |
278 |
return(NULL); |
return(NULL); |
279 |
} |
} |
280 |
|
if(!CaloTrk)return 0; //ELENA |
281 |
TClonesArray &t = *(CaloTrk); |
TClonesArray &t = *(CaloTrk); |
282 |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
283 |
return calotrack; |
return calotrack; |
284 |
} |
} |
285 |
|
|
286 |
|
/** |
287 |
|
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
288 |
|
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
289 |
|
*/ |
290 |
|
CaloTrkVar *CaloLevel2::GetCaloStoredTrack(int seqno){ |
291 |
|
|
292 |
|
if( ntrk()==0 ){ |
293 |
|
printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i but no Calorimeter tracks are stored\n",seqno); |
294 |
|
return NULL; |
295 |
|
}; |
296 |
|
|
297 |
|
CaloTrkVar *c = 0; |
298 |
|
Int_t it_calo=0; |
299 |
|
|
300 |
|
do { |
301 |
|
c = GetCaloTrkVar(it_calo); |
302 |
|
it_calo++; |
303 |
|
} while( c && seqno != c->trkseqno && it_calo < ntrk()); |
304 |
|
|
305 |
|
if(!c || seqno != c->trkseqno){ |
306 |
|
c = 0; |
307 |
|
if(seqno!=-1 && seqno !=-2 && seqno!=-3 ) printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i does not match Calorimeter stored tracks\n",seqno); |
308 |
|
}; |
309 |
|
return c; |
310 |
|
|
311 |
|
} |