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() { |
24 |
trkseqno = 0; |
trkseqno = 0; |
25 |
noint = 0; |
noint = 0; |
26 |
ncore = 0; |
ncore = 0; |
45 |
qlow = 0.; |
qlow = 0.; |
46 |
nlow = 0; |
nlow = 0; |
47 |
dX0l = 0.; |
dX0l = 0.; |
48 |
for (Int_t i = 0; i<2 ; i++){ |
memset(tbar, 0, 2*22*sizeof(Float_t)); |
49 |
for ( Int_t j = 0; j<22; j++){ |
memset(tibar, 0, 2*22*sizeof(Int_t)); |
|
tibar[j][i] = 0; |
|
|
tbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
50 |
} |
} |
51 |
|
|
52 |
/** |
/** |
86 |
**/ |
**/ |
87 |
CaloLevel2::CaloLevel2() { |
CaloLevel2::CaloLevel2() { |
88 |
// |
// |
89 |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
// CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
90 |
|
CaloTrk = 0; //ELENA |
91 |
|
// |
92 |
|
this->Clear(); |
93 |
// |
// |
|
nstrip = 0; |
|
|
qtot = 0.; |
|
|
impx = 0.; |
|
|
impy = 0.; |
|
|
tanx = 0.; |
|
|
tany = 0.; |
|
|
qmax = 0.; |
|
|
nx22 = 0; |
|
|
qx22 = 0.; |
|
|
elen = 0.; |
|
|
selen = 0.; |
|
|
for (Int_t i = 0; i<4 ; i++){ |
|
|
qq[i] = 0.; |
|
|
perr[i] = 0; |
|
|
swerr[i] = 0; |
|
|
crc[i] = 0; |
|
|
if ( i < 2 ){ |
|
|
planemax[i] = 0; |
|
|
varcfit[i] = 0.; |
|
|
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); |
|
94 |
}; |
}; |
95 |
|
/** |
96 |
|
* Create the TClonesArray |
97 |
|
**/ |
98 |
|
void CaloLevel2::Set(){//ELENA |
99 |
|
if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
100 |
|
}//ELENA |
101 |
|
|
102 |
|
/** |
103 |
|
* Clear the CaloLevel2 object |
104 |
|
**/ |
105 |
void CaloLevel2::Clear() { |
void CaloLevel2::Clear() { |
106 |
// |
// |
107 |
CaloTrk->Clear(); |
// CaloTrk->Clear(); //ELENA |
108 |
|
if(CaloTrk)CaloTrk->Delete(); //ELENA |
109 |
// |
// |
110 |
nstrip = 0; |
nstrip = 0; |
111 |
qtot = 0.; |
qtot = 0.; |
112 |
impx = 0.; |
// impx = 0.; |
113 |
impy = 0.; |
// impy = 0.; |
|
tanx = 0.; |
|
|
tany = 0.; |
|
114 |
qmax = 0.; |
qmax = 0.; |
115 |
nx22 = 0; |
nx22 = 0; |
116 |
qx22 = 0.; |
qx22 = 0.; |
117 |
elen = 0.; |
elen = 0.; |
118 |
selen = 0.; |
selen = 0.; |
119 |
for (Int_t i = 0; i<4 ; i++){ |
memset(perr, 0, 4*sizeof(Int_t)); |
120 |
qq[i] = 0.; |
memset(swerr, 0, 4*sizeof(Int_t)); |
121 |
perr[i] = 0; |
memset(crc, 0, 4*sizeof(Int_t)); |
122 |
swerr[i] = 0; |
memset(qq, 0, 4*sizeof(Int_t)); |
123 |
crc[i] = 0; |
memset(varcfit, 0, 4*sizeof(Float_t)); |
124 |
if ( i < 2 ){ |
memset(npcfit, 0, 4*sizeof(Int_t)); |
125 |
planemax[i] = 0; |
memset(tanx, 0, 2*sizeof(Int_t)); |
126 |
varcfit[i] = 0.; |
memset(tany, 0, 2*sizeof(Int_t)); |
127 |
npcfit[i] = 0; |
memset(fitmode, 0, 2*sizeof(Int_t)); |
128 |
for ( Int_t j = 0; j<22; j++){ |
memset(planemax, 0, 2*sizeof(Int_t)); |
129 |
cibar[j][i] = 0; |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
130 |
cbar[j][i] = 0.; |
memset(cbar, 0, 2*22*sizeof(Float_t)); |
|
}; |
|
|
}; |
|
|
}; |
|
131 |
good = 0; |
good = 0; |
132 |
selftrigger = 0; |
selftrigger = 0; |
133 |
estrip = TArrayF(0,NULL); |
// |
134 |
}; |
}; |
135 |
|
|
136 |
/** |
/** |
137 |
* Gives the detected energy for the given strip once loaded the event |
* Delete the CaloLevel2 object |
138 |
|
**/ |
139 |
|
void CaloLevel2::Delete() { //ELENA |
140 |
|
if(CaloTrk){ //ELENA |
141 |
|
CaloTrk->Delete(); //ELENA |
142 |
|
delete CaloTrk; //ELENA |
143 |
|
} //ELENA |
144 |
|
} //ELENA |
145 |
|
|
146 |
|
/** |
147 |
|
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
148 |
|
*/ |
149 |
|
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
150 |
|
|
151 |
|
l2->good = good; |
152 |
|
l2->selftrigger = selftrigger; |
153 |
|
l2->nstrip = nstrip; |
154 |
|
l2->nx22 = nx22; |
155 |
|
l2->qtot = qtot; |
156 |
|
l2->qx22 = qx22; |
157 |
|
l2->qmax = qmax; |
158 |
|
// l2->impx = impx; |
159 |
|
// l2->impy = impy; |
160 |
|
// l2->tanx = tanx; |
161 |
|
// l2->tany = tany; |
162 |
|
l2->elen = elen; |
163 |
|
l2->selen = selen; |
164 |
|
|
165 |
|
for(Int_t i=0;i<2;i++){ |
166 |
|
l2->planemax[i] = planemax[i]; |
167 |
|
l2->varcfit[i] = varcfit[i]; |
168 |
|
l2->npcfit[i] = npcfit[i]; |
169 |
|
} |
170 |
|
for(Int_t i=0;i<4;i++){ |
171 |
|
l2->perr[i] = perr[i]; |
172 |
|
l2->swerr[i] = swerr[i]; |
173 |
|
l2->calcrc[i] = crc[i]; |
174 |
|
l2->qq[i] = qq[i]; |
175 |
|
} |
176 |
|
|
177 |
|
if(CaloTrk){ //ELENA |
178 |
|
l2->calntrk = CaloTrk->GetEntries(); |
179 |
|
for(Int_t i=0;i<l2->calntrk;i++){ |
180 |
|
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
181 |
|
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
182 |
|
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
183 |
|
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
184 |
|
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
185 |
|
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
186 |
|
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
187 |
|
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
188 |
|
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
189 |
|
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
190 |
|
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
191 |
|
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
192 |
|
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
193 |
|
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
194 |
|
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
195 |
|
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
196 |
|
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
197 |
|
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
198 |
|
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
199 |
|
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
200 |
|
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
201 |
|
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
202 |
|
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
203 |
|
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
204 |
|
for (Int_t j=0; j<2; j++){ |
205 |
|
for (Int_t k=0; k<22; k++){ |
206 |
|
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
207 |
|
}; |
208 |
|
}; |
209 |
|
} |
210 |
|
} //ELENA |
211 |
|
} |
212 |
|
|
213 |
|
/** |
214 |
|
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
215 |
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
216 |
**/ |
**/ |
217 |
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
Float_t CaloLevel2::impx(Int_t tr){ |
218 |
Int_t splane = 0; |
if ( tr == 0 ) return(cbar[0][0]); |
219 |
Int_t sstrip = 0; |
if ( tr == 1 ) { |
220 |
// |
if ( !CaloTrk ) return(-110.); |
221 |
if ( nstrip == 0 ) return(0.); |
TClonesArray &t = *(CaloTrk); |
222 |
// |
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
223 |
for (Int_t i = 0; i<nstrip; i++ ){ |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
224 |
if ( view == 0 ){ |
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][0]); |
|
if ( estrip.At(i) > 0. ){ |
|
|
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
|
|
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
|
|
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
|
|
}; |
|
|
} else { |
|
|
if ( estrip.At(i) < 0. ){ |
|
|
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
|
|
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
|
|
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
|
|
}; |
|
225 |
}; |
}; |
226 |
}; |
}; |
227 |
return(0.); |
if ( tr !=0 && tr !=1 ){ |
228 |
|
printf(" Cannot get impx for other than calo or selftrigger tracks!\n"); |
229 |
|
} else { |
230 |
|
printf(" Cannot find selftrigger block\n"); |
231 |
|
}; |
232 |
|
return(-100.); |
233 |
}; |
}; |
234 |
|
|
235 |
/** |
/** |
236 |
* Given estrip entry returns energy and strip |
* Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. |
237 |
|
* @param tr : if tr = 0 use the calorimeter "normal" fit, if 1 use the calorimeter "selftrigger" fit (if any!) |
238 |
**/ |
**/ |
239 |
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
Float_t CaloLevel2::impy(Int_t tr){ |
240 |
if ( entry>nstrip ) return(0.); |
if ( tr == 0 ) return(cbar[0][1]); |
241 |
// |
if ( tr == 1 ) { |
242 |
if ( estrip.At(entry) > 0. ){ |
if ( !CaloTrk ) return(-110.); |
243 |
view = 0; |
TClonesArray &t = *(CaloTrk); |
244 |
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
for (Int_t itrk=0; itrk<ntrk(); itrk++){ |
245 |
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
246 |
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
if ( calotrack->trkseqno == -1 ) return(calotrack->tbar[0][1]); |
247 |
|
}; |
248 |
}; |
}; |
249 |
if ( estrip.At(entry) < 0. ){ |
if ( tr !=0 && tr !=1 ){ |
250 |
view = 1; |
printf(" Cannot get impy for other than calo or selftrigger tracks!\n"); |
251 |
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
} else { |
252 |
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
printf(" Cannot find selftrigger block\n"); |
253 |
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
}; |
254 |
}; |
return(-100.); |
255 |
// |
}; |
256 |
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
/** |
257 |
// |
* Should return the energy in GeV if the particle would be an electron |
258 |
view = -1; |
* using a parametrization taken from Monte Carlo simulation |
259 |
plane = -1; |
**/ |
|
strip = -1; |
|
|
return(0.); |
|
|
} |
|
|
|
|
260 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
261 |
if ( nstrip == 0 ) return; |
if ( nstrip == 0 ) return; |
262 |
energy = qtot * 40.82 * 0.000106; |
energy = qtot * 40.82 * 0.000106; |
275 |
printf(" stored track related variables = %i \n",ntrk()); |
printf(" stored track related variables = %i \n",ntrk()); |
276 |
return(NULL); |
return(NULL); |
277 |
} |
} |
278 |
|
if(!CaloTrk)return 0; //ELENA |
279 |
TClonesArray &t = *(CaloTrk); |
TClonesArray &t = *(CaloTrk); |
280 |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
281 |
return calotrack; |
return calotrack; |