1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file src/CaloLevel2.cpp |
3 |
|
|
* \author Emiliano Mocchiutti |
4 |
|
|
* |
5 |
|
|
**/ |
6 |
|
|
#include <TObject.h> |
7 |
|
|
#include <CaloLevel2.h> |
8 |
mocchiut |
1.9 |
|
9 |
|
|
// |
10 |
mocchiut |
1.1 |
ClassImp(CaloTrkVar); |
11 |
|
|
ClassImp(CaloLevel2); |
12 |
|
|
|
13 |
|
|
/** |
14 |
|
|
* CaloTrkVar constructor |
15 |
|
|
**/ |
16 |
|
|
CaloTrkVar::CaloTrkVar() { |
17 |
mocchiut |
1.7 |
this->Clear(); |
18 |
mocchiut |
1.15 |
} |
19 |
mocchiut |
1.7 |
|
20 |
|
|
/** |
21 |
|
|
* Clear variables |
22 |
|
|
**/ |
23 |
mocchiut |
1.15 |
void CaloTrkVar::Clear(Option_t *t) { |
24 |
|
|
//void CaloTrkVar::Clear() { |
25 |
mocchiut |
1.1 |
trkseqno = 0; |
26 |
|
|
noint = 0; |
27 |
|
|
ncore = 0; |
28 |
|
|
qcore = 0.; |
29 |
|
|
ncyl = 0; |
30 |
|
|
qcyl = 0.; |
31 |
|
|
qtrack = 0.; |
32 |
|
|
qtrackx = 0.; |
33 |
|
|
qtracky = 0.; |
34 |
|
|
dxtrack = 0.; |
35 |
|
|
dytrack = 0.; |
36 |
|
|
qlast = 0.; |
37 |
|
|
nlast = 0; |
38 |
|
|
qpre = 0.; |
39 |
|
|
npre = 0; |
40 |
|
|
qpresh = 0.; |
41 |
|
|
npresh = 0; |
42 |
|
|
qtr = 0.; |
43 |
|
|
ntr = 0; |
44 |
|
|
planetot = 0; |
45 |
|
|
qmean = 0.; |
46 |
|
|
qlow = 0.; |
47 |
|
|
nlow = 0; |
48 |
|
|
dX0l = 0.; |
49 |
mocchiut |
1.5 |
memset(tbar, 0, 2*22*sizeof(Float_t)); |
50 |
|
|
memset(tibar, 0, 2*22*sizeof(Int_t)); |
51 |
mocchiut |
1.1 |
} |
52 |
|
|
|
53 |
|
|
/** |
54 |
|
|
* Copies from t to this |
55 |
|
|
**/ |
56 |
|
|
CaloTrkVar::CaloTrkVar(const CaloTrkVar &t){ |
57 |
|
|
trkseqno = t.trkseqno; |
58 |
|
|
noint = t.noint; |
59 |
|
|
ncore = t.ncore; |
60 |
|
|
qcore = t.qcore; |
61 |
|
|
ncyl = t.ncyl; |
62 |
|
|
qcyl = t.qcyl; |
63 |
|
|
qtrack = t.qtrack; |
64 |
|
|
qtrackx = t.qtrackx; |
65 |
|
|
qtracky = t.qtracky; |
66 |
|
|
dxtrack = t.dxtrack; |
67 |
|
|
dytrack = t.dytrack; |
68 |
|
|
qlast = t.qlast; |
69 |
|
|
nlast = t.nlast; |
70 |
|
|
qpre = t.qpre; |
71 |
|
|
npre = t.npre; |
72 |
|
|
qpresh = t.qpresh; |
73 |
|
|
npresh = t.npresh; |
74 |
|
|
qtr = t.qtr; |
75 |
|
|
ntr = t.ntr; |
76 |
|
|
planetot = t.planetot; |
77 |
|
|
qmean = t.qmean; |
78 |
|
|
dX0l = t.dX0l; |
79 |
|
|
qlow = t.qlow; |
80 |
|
|
nlow = t.nlow; |
81 |
|
|
memcpy(tibar,t.tibar,sizeof(tibar)); |
82 |
|
|
memcpy(tbar,t.tbar,sizeof(tbar)); |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
/** |
86 |
|
|
* CaloLevel2 constructor |
87 |
|
|
**/ |
88 |
|
|
CaloLevel2::CaloLevel2() { |
89 |
|
|
// |
90 |
pam-fi |
1.10 |
// CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
91 |
|
|
CaloTrk = 0; //ELENA |
92 |
mocchiut |
1.7 |
// |
93 |
|
|
this->Clear(); |
94 |
mocchiut |
1.1 |
// |
95 |
mocchiut |
1.15 |
} |
96 |
pam-fi |
1.11 |
/** |
97 |
|
|
* Create the TClonesArray |
98 |
|
|
**/ |
99 |
|
|
void CaloLevel2::Set(){//ELENA |
100 |
|
|
if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
101 |
|
|
}//ELENA |
102 |
mocchiut |
1.1 |
|
103 |
mocchiut |
1.8 |
/** |
104 |
|
|
* Clear the CaloLevel2 object |
105 |
|
|
**/ |
106 |
mocchiut |
1.15 |
void CaloLevel2::Clear(Option_t *t ) { |
107 |
mocchiut |
1.2 |
// |
108 |
mocchiut |
1.15 |
// CaloTrk->Clear(); //ELENA |
109 |
pam-fi |
1.10 |
if(CaloTrk)CaloTrk->Delete(); //ELENA |
110 |
mocchiut |
1.2 |
// |
111 |
|
|
nstrip = 0; |
112 |
mocchiut |
1.16 |
nsatstrip = 0; |
113 |
mocchiut |
1.2 |
qtot = 0.; |
114 |
mocchiut |
1.12 |
// impx = 0.; |
115 |
|
|
// impy = 0.; |
116 |
mocchiut |
1.2 |
qmax = 0.; |
117 |
|
|
nx22 = 0; |
118 |
|
|
qx22 = 0.; |
119 |
|
|
elen = 0.; |
120 |
|
|
selen = 0.; |
121 |
mocchiut |
1.5 |
memset(perr, 0, 4*sizeof(Int_t)); |
122 |
|
|
memset(swerr, 0, 4*sizeof(Int_t)); |
123 |
|
|
memset(crc, 0, 4*sizeof(Int_t)); |
124 |
|
|
memset(qq, 0, 4*sizeof(Int_t)); |
125 |
mocchiut |
1.12 |
memset(varcfit, 0, 4*sizeof(Float_t)); |
126 |
|
|
memset(npcfit, 0, 4*sizeof(Int_t)); |
127 |
|
|
memset(tanx, 0, 2*sizeof(Int_t)); |
128 |
|
|
memset(tany, 0, 2*sizeof(Int_t)); |
129 |
|
|
memset(fitmode, 0, 2*sizeof(Int_t)); |
130 |
mocchiut |
1.5 |
memset(planemax, 0, 2*sizeof(Int_t)); |
131 |
mocchiut |
1.14 |
memset(selfdelay, 0, 4*7*sizeof(Int_t)); |
132 |
mocchiut |
1.5 |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
133 |
|
|
memset(cbar, 0, 2*22*sizeof(Float_t)); |
134 |
mocchiut |
1.2 |
good = 0; |
135 |
|
|
selftrigger = 0; |
136 |
mocchiut |
1.9 |
// |
137 |
mocchiut |
1.15 |
} |
138 |
mocchiut |
1.2 |
|
139 |
pam-fi |
1.10 |
/** |
140 |
|
|
* Delete the CaloLevel2 object |
141 |
|
|
**/ |
142 |
mocchiut |
1.15 |
void CaloLevel2::Delete(Option_t *t) { //ELENA |
143 |
pam-fi |
1.10 |
if(CaloTrk){ //ELENA |
144 |
|
|
CaloTrk->Delete(); //ELENA |
145 |
|
|
delete CaloTrk; //ELENA |
146 |
|
|
} //ELENA |
147 |
|
|
} //ELENA |
148 |
pam-fi |
1.4 |
|
149 |
|
|
/** |
150 |
|
|
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
151 |
|
|
*/ |
152 |
|
|
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
153 |
|
|
|
154 |
|
|
l2->good = good; |
155 |
|
|
l2->selftrigger = selftrigger; |
156 |
|
|
l2->nstrip = nstrip; |
157 |
|
|
l2->nx22 = nx22; |
158 |
|
|
l2->qtot = qtot; |
159 |
|
|
l2->qx22 = qx22; |
160 |
|
|
l2->qmax = qmax; |
161 |
mocchiut |
1.12 |
// l2->impx = impx; |
162 |
|
|
// l2->impy = impy; |
163 |
|
|
// l2->tanx = tanx; |
164 |
|
|
// l2->tany = tany; |
165 |
pam-fi |
1.4 |
l2->elen = elen; |
166 |
|
|
l2->selen = selen; |
167 |
|
|
|
168 |
|
|
for(Int_t i=0;i<2;i++){ |
169 |
|
|
l2->planemax[i] = planemax[i]; |
170 |
|
|
l2->varcfit[i] = varcfit[i]; |
171 |
|
|
l2->npcfit[i] = npcfit[i]; |
172 |
|
|
} |
173 |
|
|
for(Int_t i=0;i<4;i++){ |
174 |
|
|
l2->perr[i] = perr[i]; |
175 |
|
|
l2->swerr[i] = swerr[i]; |
176 |
|
|
l2->calcrc[i] = crc[i]; |
177 |
|
|
l2->qq[i] = qq[i]; |
178 |
|
|
} |
179 |
|
|
|
180 |
pam-fi |
1.10 |
if(CaloTrk){ //ELENA |
181 |
|
|
l2->calntrk = CaloTrk->GetEntries(); |
182 |
|
|
for(Int_t i=0;i<l2->calntrk;i++){ |
183 |
|
|
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
184 |
|
|
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
185 |
|
|
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
186 |
|
|
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
187 |
|
|
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
188 |
|
|
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
189 |
|
|
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
190 |
|
|
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
191 |
|
|
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
192 |
|
|
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
193 |
|
|
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
194 |
|
|
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
195 |
|
|
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
196 |
|
|
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
197 |
|
|
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
198 |
|
|
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
199 |
|
|
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
200 |
|
|
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
201 |
|
|
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
202 |
|
|
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
203 |
|
|
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
204 |
|
|
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
205 |
|
|
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
206 |
|
|
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
207 |
|
|
for (Int_t j=0; j<2; j++){ |
208 |
|
|
for (Int_t k=0; k<22; k++){ |
209 |
|
|
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
210 |
|
|
}; |
211 |
|
|
}; |
212 |
|
|
} |
213 |
|
|
} //ELENA |
214 |
pam-fi |
1.4 |
} |
215 |
|
|
|
216 |
mocchiut |
1.1 |
/** |
217 |
mocchiut |
1.12 |
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
218 |
|
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
219 |
|
|
**/ |
220 |
|
|
Float_t CaloLevel2::impx(Int_t tr){ |
221 |
|
|
if ( tr == 0 ) return(cbar[0][0]); |
222 |
|
|
if ( tr == 1 ) { |
223 |
|
|
if ( !CaloTrk ) return(-110.); |
224 |
|
|
TClonesArray &t = *(CaloTrk); |
225 |
|
|
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
226 |
|
|
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
227 |
|
|
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][0]); |
228 |
|
|
}; |
229 |
|
|
}; |
230 |
|
|
if ( tr !=0 && tr !=1 ){ |
231 |
|
|
printf(" Cannot get impx for other than calo or selftrigger tracks!\n"); |
232 |
|
|
} else { |
233 |
|
|
printf(" Cannot find selftrigger block\n"); |
234 |
|
|
}; |
235 |
|
|
return(-100.); |
236 |
mocchiut |
1.15 |
} |
237 |
mocchiut |
1.12 |
|
238 |
|
|
/** |
239 |
|
|
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
240 |
|
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
241 |
|
|
**/ |
242 |
|
|
Float_t CaloLevel2::impy(Int_t tr){ |
243 |
|
|
if ( tr == 0 ) return(cbar[0][1]); |
244 |
|
|
if ( tr == 1 ) { |
245 |
|
|
if ( !CaloTrk ) return(-110.); |
246 |
|
|
TClonesArray &t = *(CaloTrk); |
247 |
|
|
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
248 |
|
|
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
249 |
|
|
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][1]); |
250 |
|
|
}; |
251 |
|
|
}; |
252 |
|
|
if ( tr !=0 && tr !=1 ){ |
253 |
|
|
printf(" Cannot get impy for other than calo or selftrigger tracks!\n"); |
254 |
|
|
} else { |
255 |
|
|
printf(" Cannot find selftrigger block\n"); |
256 |
|
|
}; |
257 |
|
|
return(-100.); |
258 |
mocchiut |
1.15 |
} |
259 |
mocchiut |
1.12 |
/** |
260 |
mocchiut |
1.8 |
* Should return the energy in GeV if the particle would be an electron |
261 |
|
|
* using a parametrization taken from Monte Carlo simulation |
262 |
|
|
**/ |
263 |
mocchiut |
1.1 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
264 |
|
|
if ( nstrip == 0 ) return; |
265 |
mocchiut |
1.16 |
energy = qtot * 260.; |
266 |
|
|
// energy = qtot * 40.82 * 0.000106; |
267 |
mocchiut |
1.1 |
sigma = 0.; |
268 |
|
|
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
269 |
|
|
return; |
270 |
mocchiut |
1.15 |
} |
271 |
mocchiut |
1.1 |
|
272 |
|
|
/** |
273 |
|
|
* Returns pointer to the set of track-related variables "itrk" |
274 |
|
|
**/ |
275 |
|
|
CaloTrkVar *CaloLevel2::GetCaloTrkVar(Int_t itrk){ |
276 |
|
|
// |
277 |
|
|
if(itrk >= ntrk()){ |
278 |
|
|
printf(" CaloLevel2 ERROR: track related variables set %i does not exists! \n",itrk); |
279 |
|
|
printf(" stored track related variables = %i \n",ntrk()); |
280 |
|
|
return(NULL); |
281 |
|
|
} |
282 |
pam-fi |
1.10 |
if(!CaloTrk)return 0; //ELENA |
283 |
mocchiut |
1.1 |
TClonesArray &t = *(CaloTrk); |
284 |
|
|
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
285 |
|
|
return calotrack; |
286 |
|
|
} |
287 |
mocchiut |
1.13 |
|
288 |
|
|
/** |
289 |
|
|
* Retrieves the calorimeter track matching the seqno-th tracker stored track. |
290 |
|
|
* (If seqno = -1 retrieves the self-trigger calorimeter track) |
291 |
|
|
*/ |
292 |
|
|
CaloTrkVar *CaloLevel2::GetCaloStoredTrack(int seqno){ |
293 |
|
|
|
294 |
|
|
if( ntrk()==0 ){ |
295 |
|
|
printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i but no Calorimeter tracks are stored\n",seqno); |
296 |
|
|
return NULL; |
297 |
|
|
}; |
298 |
|
|
|
299 |
|
|
CaloTrkVar *c = 0; |
300 |
|
|
Int_t it_calo=0; |
301 |
|
|
|
302 |
|
|
do { |
303 |
|
|
c = GetCaloTrkVar(it_calo); |
304 |
|
|
it_calo++; |
305 |
|
|
} while( c && seqno != c->trkseqno && it_calo < ntrk()); |
306 |
|
|
|
307 |
|
|
if(!c || seqno != c->trkseqno){ |
308 |
|
|
c = 0; |
309 |
|
|
if(seqno!=-1 && seqno !=-2 && seqno!=-3 ) printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i does not match Calorimeter stored tracks\n",seqno); |
310 |
|
|
}; |
311 |
|
|
return c; |
312 |
|
|
|
313 |
mocchiut |
1.15 |
} |