1 |
mocchiut |
1.1 |
#include <CaloEnergy.h> |
2 |
|
|
#include <PamLevel2.h> |
3 |
|
|
|
4 |
|
|
//-------------------------------------- |
5 |
|
|
/** |
6 |
|
|
* Default constructor |
7 |
|
|
*/ |
8 |
|
|
CaloEnergy::CaloEnergy(){ |
9 |
|
|
Clear(); |
10 |
|
|
} |
11 |
|
|
|
12 |
|
|
CaloEnergy::CaloEnergy(PamLevel2 *l2p){ |
13 |
|
|
// |
14 |
|
|
Clear(); |
15 |
|
|
// |
16 |
|
|
L2 = l2p; |
17 |
|
|
// |
18 |
|
|
if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n"); |
19 |
|
|
// |
20 |
|
|
OBT = 0; |
21 |
|
|
PKT = 0; |
22 |
|
|
atime = 0; |
23 |
|
|
sntr = "start"; |
24 |
|
|
AOBT = 0; |
25 |
|
|
APKT = 0; |
26 |
|
|
aatime = 0; |
27 |
|
|
asntr = "start"; |
28 |
|
|
// |
29 |
|
|
debug = false; |
30 |
|
|
// |
31 |
|
|
fLong = false; |
32 |
|
|
fSimu = false; |
33 |
|
|
fPl = 1; |
34 |
mocchiut |
1.2 |
fRad = -1; |
35 |
mocchiut |
1.1 |
// |
36 |
|
|
this->DefineGeometry(); |
37 |
|
|
fXosel = true; |
38 |
|
|
fXesel = true; |
39 |
|
|
fYosel = true; |
40 |
|
|
fYesel = true; |
41 |
mocchiut |
1.2 |
fConv_rxe = 44.4; |
42 |
|
|
fConv_rxo = 44.4; |
43 |
|
|
fConv_ryo = 44.4; |
44 |
|
|
fConv_rye = 44.4; |
45 |
mocchiut |
1.1 |
// |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
CaloEnergy::CaloEnergy(PamLevel2 *l2p, Bool_t simulation){ |
49 |
|
|
// |
50 |
|
|
Clear(); |
51 |
|
|
// |
52 |
|
|
L2 = l2p; |
53 |
|
|
// |
54 |
|
|
if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n"); |
55 |
|
|
// |
56 |
|
|
OBT = 0; |
57 |
|
|
PKT = 0; |
58 |
|
|
atime = 0; |
59 |
|
|
sntr = "start"; |
60 |
|
|
// |
61 |
|
|
AOBT = 0; |
62 |
|
|
APKT = 0; |
63 |
|
|
aatime = 0; |
64 |
|
|
asntr = "start"; |
65 |
|
|
// |
66 |
|
|
debug = false; |
67 |
|
|
// |
68 |
|
|
fLong = false; |
69 |
|
|
fSimu = simulation; |
70 |
|
|
fPl = 1; |
71 |
mocchiut |
1.2 |
fRad = -1; |
72 |
mocchiut |
1.1 |
// |
73 |
|
|
this->DefineGeometry(); |
74 |
|
|
fXosel =true; |
75 |
|
|
fXesel = true; |
76 |
|
|
fYosel = true; |
77 |
|
|
fYesel = true; |
78 |
mocchiut |
1.2 |
fConv_rxe = 44.4; |
79 |
|
|
fConv_rxo = 44.4; |
80 |
|
|
fConv_ryo = 44.4; |
81 |
|
|
fConv_rye = 44.4; |
82 |
mocchiut |
1.1 |
// |
83 |
|
|
} |
84 |
|
|
|
85 |
mocchiut |
1.2 |
void CaloEnergy::SetConversionFactor(TString section, Float_t conv){ |
86 |
|
|
section.ToUpper(); |
87 |
|
|
if ( section.Contains("XO") ) fConv_rxo = conv; |
88 |
|
|
if ( section.Contains("XE") ) fConv_rxe = conv; |
89 |
|
|
if ( section.Contains("YO") ) fConv_ryo = conv; |
90 |
|
|
if ( section.Contains("YE") ) fConv_rye = conv; |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
Float_t CaloEnergy::GetConversionFactor(TString section){ |
94 |
|
|
section.ToUpper(); |
95 |
|
|
if ( section.Contains("XO") ) return(fConv_rxo); |
96 |
|
|
if ( section.Contains("XE") ) return(fConv_rxe); |
97 |
|
|
if ( section.Contains("YO") ) return(fConv_ryo); |
98 |
|
|
if ( section.Contains("YE") ) return(fConv_rye); |
99 |
|
|
printf(" ERROR: section not recognized \n"); |
100 |
|
|
return(-1000.); |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
Int_t CaloEnergy::GetMaxplane(TString section){ |
104 |
|
|
section.ToUpper(); |
105 |
|
|
if ( section.Contains("XO") ) return fMax_planexo; |
106 |
|
|
if ( section.Contains("XE") ) return fMax_planexe; |
107 |
|
|
if ( section.Contains("YO") ) return fMax_planeyo; |
108 |
|
|
if ( section.Contains("YE") ) return fMax_planeye; |
109 |
|
|
return(-1); |
110 |
|
|
} |
111 |
|
|
|
112 |
mocchiut |
1.1 |
void CaloEnergy::DefineGeometry(){ |
113 |
|
|
// |
114 |
mocchiut |
1.2 |
fM = 2. + 0.096; // real position from cbar |
115 |
|
|
fM1 = 2. - 0.122 - 0.096; // due to calculation of xe1 etc. |
116 |
mocchiut |
1.1 |
if ( fM1 < 0. ) fM1 = 0.; |
117 |
|
|
// |
118 |
|
|
CaloStrip *cs = new CaloStrip(fSimu); |
119 |
|
|
|
120 |
|
|
// vista y piano 0 striscia 0 |
121 |
|
|
cs->Set(1,0,0); |
122 |
|
|
xe1= cs->GetY(); |
123 |
|
|
z1= cs->GetZ(); |
124 |
|
|
// vista y piano 0 striscia 31 |
125 |
|
|
cs->Set(1,0,31); |
126 |
|
|
xe2= cs->GetY(); |
127 |
|
|
// vista y piano 0 striscia 32 |
128 |
|
|
cs->Set(1,0,32); |
129 |
|
|
xe3= cs->GetY(); |
130 |
|
|
// vista y piano 0 striscia 63 |
131 |
|
|
cs->Set(1,0,63); |
132 |
|
|
xe4= cs->GetY(); |
133 |
|
|
// vista y piano 0 striscia 64 |
134 |
|
|
cs->Set(1,0,64); |
135 |
|
|
xe5= cs->GetY(); |
136 |
|
|
// vista y piano 0 striscia 95 |
137 |
|
|
cs->Set(1,0,95); |
138 |
|
|
xe6= cs->GetY(); |
139 |
|
|
|
140 |
|
|
// vista x piano 0 striscia 0 |
141 |
|
|
cs->Set(0,0,0); |
142 |
|
|
yo1= cs->GetX(); |
143 |
|
|
z2= cs->GetZ(); |
144 |
|
|
// vista x piano 0 striscia 31 |
145 |
|
|
cs->Set(0,0,31); |
146 |
|
|
yo2= cs->GetX(); |
147 |
|
|
// vista x piano 0 striscia 32 |
148 |
|
|
cs->Set(0,0,32); |
149 |
|
|
yo3= cs->GetX(); |
150 |
|
|
// vista x piano 0 striscia 63 |
151 |
|
|
cs->Set(0,0,63); |
152 |
|
|
yo4= cs->GetX(); |
153 |
|
|
// vista x piano 0 striscia 64 |
154 |
|
|
cs->Set(0,0,64); |
155 |
|
|
yo5= cs->GetX(); |
156 |
|
|
// vista x piano 0 striscia 95 |
157 |
|
|
cs->Set(0,0,95); |
158 |
|
|
yo6= cs->GetX(); |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
// vista y piano 1 striscia 0 |
162 |
|
|
cs->Set(1,1,0); |
163 |
|
|
xo1= cs->GetY(); |
164 |
|
|
z3= cs->GetZ(); |
165 |
|
|
// vista y piano 1 striscia 31 |
166 |
|
|
cs->Set(1,1,31); |
167 |
|
|
xo2= cs->GetY(); |
168 |
|
|
// vista y piano 1 striscia 32 |
169 |
|
|
cs->Set(1,1,32); |
170 |
|
|
xo3= cs->GetY(); |
171 |
|
|
// vista y piano 1 striscia 63 |
172 |
|
|
cs->Set(1,1,63); |
173 |
|
|
xo4= cs->GetY(); |
174 |
|
|
// vista y piano 1 striscia 64 |
175 |
|
|
cs->Set(1,1,64); |
176 |
|
|
xo5= cs->GetY(); |
177 |
|
|
// vista y piano 1 striscia 95 |
178 |
|
|
cs->Set(1,1,95); |
179 |
|
|
xo6= cs->GetY(); |
180 |
|
|
|
181 |
|
|
// vista x piano 1 striscia 0 |
182 |
|
|
cs->Set(0,1,0); |
183 |
|
|
ye1= cs->GetX(); |
184 |
|
|
z4= cs->GetZ(); |
185 |
|
|
// vista x piano 1 striscia 31 |
186 |
|
|
cs->Set(0,1,31); |
187 |
|
|
ye2= cs->GetX(); |
188 |
|
|
// vista x piano 1 striscia 32 |
189 |
|
|
cs->Set(0,1,32); |
190 |
|
|
ye3= cs->GetX(); |
191 |
|
|
// vista x piano 1 striscia 63 |
192 |
|
|
cs->Set(0,1,63); |
193 |
|
|
ye4= cs->GetX(); |
194 |
|
|
// vista x piano 1 striscia 64 |
195 |
|
|
cs->Set(0,1,64); |
196 |
|
|
ye5= cs->GetX(); |
197 |
|
|
// vista x piano 1 striscia 95 |
198 |
|
|
cs->Set(0,1,95); |
199 |
|
|
ye6= cs->GetX(); |
200 |
|
|
|
201 |
|
|
// |
202 |
|
|
for (Int_t p = 0; p<22; p ++){ |
203 |
|
|
for (Int_t v = 0; v<2; v++ ){ |
204 |
|
|
cs->Set(v,p,0); |
205 |
|
|
trk_z[p][v]= cs->GetZ(); // << cooordinata Z piano |
206 |
|
|
}; |
207 |
|
|
}; |
208 |
|
|
// |
209 |
|
|
delete cs; |
210 |
|
|
// |
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
void CaloEnergy::Clear(){ |
214 |
|
|
// |
215 |
|
|
fEnergy = 0.; |
216 |
mocchiut |
1.2 |
fEnergyxe = 0.; |
217 |
|
|
fEnergyxo = 0.; |
218 |
|
|
fEnergyye = 0.; |
219 |
|
|
fEnergyyo = 0.; |
220 |
mocchiut |
1.1 |
memset(enstrip,0,2*22*96*(sizeof(Float_t))); |
221 |
|
|
en = 0.; |
222 |
|
|
view = 0; |
223 |
|
|
plane = 0; |
224 |
|
|
strip = 0; |
225 |
|
|
energyxe = 0.; |
226 |
|
|
energyyo = 0.; |
227 |
|
|
energyxo = 0.; |
228 |
|
|
energyye = 0.; |
229 |
|
|
memset(en_xep,0,11*sizeof(Float_t)); |
230 |
|
|
memset(en_yep,0,11*sizeof(Float_t)); |
231 |
|
|
memset(en_xop,0,11*sizeof(Float_t)); |
232 |
|
|
memset(en_yop,0,11*sizeof(Float_t)); |
233 |
|
|
// |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
void CaloEnergy::Print(){ |
237 |
|
|
// |
238 |
|
|
printf("========================================================================\n"); |
239 |
|
|
printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime); |
240 |
|
|
printf(" fEnergy :.............. %f \n",fEnergy); |
241 |
mocchiut |
1.2 |
printf(" fMax_plane :........... %f \n",fMax_plane); |
242 |
|
|
printf(" fMax_planexo :......... %i \n",fMax_planexo); |
243 |
|
|
printf(" fMax_planexe :......... %i \n",fMax_planexe); |
244 |
|
|
printf(" fMax_planeyo :......... %i \n",fMax_planeyo); |
245 |
|
|
printf(" fMax_planeye :......... %i \n",fMax_planeye); |
246 |
mocchiut |
1.1 |
printf(" fCount :.............. %f \n",fCount); |
247 |
|
|
printf(" fXesel :.............. %i \n",fXesel); |
248 |
|
|
printf(" fXosel :.............. %i \n",fXosel); |
249 |
|
|
printf(" fYesel :.............. %i \n",fYesel); |
250 |
|
|
printf(" fYosel :.............. %i \n",fYosel); |
251 |
|
|
printf(" fSimu :.............. %i \n",fSimu); |
252 |
|
|
printf(" fM :.............. %f \n",fM); |
253 |
|
|
printf(" fM1 :.............. %f \n",fM1); |
254 |
mocchiut |
1.2 |
printf(" fRad :.............. %i \n",fRad); |
255 |
|
|
printf(" fPl :.............. %i \n",fPl); |
256 |
|
|
printf(" fConv_rxe ............. %f \n",fConv_rxe); |
257 |
|
|
printf(" fConv_rxo ............. %f \n",fConv_rxo); |
258 |
|
|
printf(" fConv_ryo ............. %f \n",fConv_ryo); |
259 |
|
|
printf(" fConv_rye ............. %f \n",fConv_rye); |
260 |
mocchiut |
1.1 |
printf(" fLong :.............. %i \n",fLong); |
261 |
|
|
printf(" energyxe:.............. %f \n",energyxe); |
262 |
|
|
printf(" energyxo:.............. %f \n",energyxo); |
263 |
|
|
printf(" energyye:.............. %f \n",energyye); |
264 |
|
|
printf(" energyyo:.............. %f \n",energyyo); |
265 |
|
|
printf(" debug :.............. %i \n",debug); |
266 |
|
|
|
267 |
|
|
printf("========================================================================\n"); |
268 |
|
|
// |
269 |
|
|
} |
270 |
|
|
|
271 |
|
|
void CaloEnergy::Delete(){ |
272 |
|
|
Clear(); |
273 |
|
|
} |
274 |
|
|
|
275 |
|
|
|
276 |
|
|
Bool_t CaloEnergy::IsInsideAcceptance(TString section){ |
277 |
|
|
return(this->IsInsideAcceptance(section,true)); |
278 |
|
|
} |
279 |
|
|
|
280 |
|
|
Bool_t CaloEnergy::IsInsideAcceptance(TString section, Bool_t fast){ |
281 |
|
|
// |
282 |
|
|
// |
283 |
|
|
TString ntr = section; |
284 |
|
|
if ( !L2 ){ |
285 |
|
|
printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); |
286 |
|
|
printf(" ERROR: CaloEnergy variables not filled \n"); |
287 |
|
|
return false; |
288 |
|
|
}; |
289 |
|
|
// |
290 |
|
|
Bool_t newentry = false; |
291 |
|
|
// |
292 |
|
|
if ( L2->IsORB() ){ |
293 |
|
|
if ( L2->GetOrbitalInfo()->pkt_num != APKT || L2->GetOrbitalInfo()->OBT != AOBT || L2->GetOrbitalInfo()->absTime != aatime || strcmp(ntr.Data(),asntr.Data()) ){ |
294 |
|
|
newentry = true; |
295 |
|
|
AOBT = L2->GetOrbitalInfo()->OBT; |
296 |
|
|
APKT = L2->GetOrbitalInfo()->pkt_num; |
297 |
|
|
aatime = L2->GetOrbitalInfo()->absTime; |
298 |
|
|
asntr = ntr; |
299 |
|
|
}; |
300 |
|
|
} else { |
301 |
|
|
newentry = true; |
302 |
|
|
}; |
303 |
|
|
// |
304 |
|
|
if ( !newentry ) return fSel; |
305 |
|
|
// |
306 |
|
|
if ( debug ) printf(" ########## IsInsideAcceptance ######### \n"); |
307 |
|
|
// |
308 |
|
|
fSel = false; |
309 |
|
|
section.ToUpper(); |
310 |
|
|
fXosel = false; |
311 |
|
|
fXesel = false; |
312 |
|
|
fYosel = false; |
313 |
|
|
fYesel = false; |
314 |
|
|
fCount = 0.; |
315 |
|
|
// |
316 |
|
|
Int_t ss = Int_t(section.Contains("XO"))+Int_t(section.Contains("XE"))+Int_t(section.Contains("YO"))+Int_t(section.Contains("YE")); |
317 |
|
|
if ( ss > 1 ) fast = false; |
318 |
|
|
if ( !ss ){ |
319 |
|
|
printf(" ERROR: section must be XO or XE or YO or YE while it is %s \n",section.Data()); |
320 |
|
|
}; |
321 |
|
|
// |
322 |
|
|
Float_t track_coordx[22][2]; |
323 |
|
|
Float_t track_coordy[22][2]; |
324 |
|
|
// |
325 |
|
|
Float_t tgx_cl2; |
326 |
|
|
Float_t tgy_cl2; |
327 |
|
|
tgx_cl2 = L2->GetCaloLevel2()->tanx[0]; |
328 |
|
|
tgy_cl2 = L2->GetCaloLevel2()->tany[0]; |
329 |
|
|
// |
330 |
|
|
for (Int_t p=0; p<22; p++){ |
331 |
|
|
track_coordy[p][1] = L2->GetCaloLevel2()->cbar[p][1]; |
332 |
|
|
track_coordx[p][1] = L2->GetCaloLevel2()->cbar[p][0] - fabs(trk_z[p][1]-trk_z[p][0])*tgx_cl2; |
333 |
|
|
track_coordx[p][0] = L2->GetCaloLevel2()->cbar[p][0]; |
334 |
|
|
track_coordy[p][0] = L2->GetCaloLevel2()->cbar[p][1] - fabs(trk_z[p][1]-trk_z[p][0])*tgy_cl2; |
335 |
|
|
if ( debug ) printf(" p %i track_coordy[p][1] %f track_coordx[p][1] %f track_coordx[p][0] %f track_coordy[p][0] %f \n",p,track_coordy[p][1],track_coordx[p][1],track_coordx[p][0],track_coordy[p][0]); |
336 |
|
|
}; |
337 |
|
|
// |
338 |
|
|
if ( debug ) printf(" acceptance fast %i ss %i tgx %f tgy %f\n",fast,ss,tgx_cl2,tgy_cl2); |
339 |
|
|
// |
340 |
|
|
if ( section.Contains("XO") ){ |
341 |
|
|
for (Int_t i=0; i<11; i++) { |
342 |
|
|
if |
343 |
|
|
( |
344 |
|
|
(((track_coordx[2*i+1][1]>=(-12.054+fM))&& |
345 |
|
|
(track_coordx[2*i+1][1]<=(-4.246-fM)))&& |
346 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo1 + fM1)&& |
347 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo2 - fM1 ))|| |
348 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo3 + fM1)&& |
349 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo4 - fM1 ))|| |
350 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo5 + fM1)&& |
351 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo6 - fM1 ))))|| |
352 |
|
|
|
353 |
|
|
(((track_coordx[2*i+1][1]>=(-4.004+fM))&& |
354 |
|
|
(track_coordx[2*i+1][1]<=(3.804-fM)))&& |
355 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo1 + fM1)&& |
356 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo2 - fM1 ))|| |
357 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo3 + fM1)&& |
358 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo4 - fM1))|| |
359 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo5 + fM1)&& |
360 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo6 - fM1 ))))|| |
361 |
|
|
|
362 |
|
|
(((track_coordx[2*i+1][1]>=(4.046+fM))&& |
363 |
|
|
(track_coordx[2*i+1][1]<=(11.854-fM)))&& |
364 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo1 + fM1)&& |
365 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo2 - fM1))|| |
366 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo3 + fM1)&& |
367 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo4 - fM1 ))|| |
368 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo5 + fM1)&& |
369 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo6 - fM1 )))) |
370 |
|
|
){ |
371 |
|
|
fXosel = true; |
372 |
|
|
} else { |
373 |
|
|
if ( fast ) return false; |
374 |
|
|
fXosel = false; |
375 |
|
|
break; |
376 |
|
|
}; |
377 |
|
|
}; |
378 |
|
|
}; |
379 |
|
|
// |
380 |
|
|
if ( section.Contains("XE") ){ |
381 |
|
|
for (Int_t i=0; i<11; i++) { |
382 |
|
|
if |
383 |
|
|
( |
384 |
|
|
(((track_coordx[2*i][1]>=(-11.854+fM))&& |
385 |
|
|
(track_coordx[2*i][1]<=(-4.046-fM)))&& |
386 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i][1]>=xe1 + fM1)&& |
387 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe2 - fM1 ))|| |
388 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][1]>=xe3 + fM1)&& |
389 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe4 - fM1 ))|| |
390 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][1]>=xe5 + fM1)&& |
391 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe6 - fM1 ))))|| |
392 |
|
|
|
393 |
|
|
(((track_coordx[2*i][1]>=(-3.804+fM))&& |
394 |
|
|
(track_coordx[2*i][1]<=(4.004-fM)))&& |
395 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i][1]>=xe1 + fM1)&& |
396 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe2 - fM1 ))|| |
397 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][1]>=xe3 + fM1)&& |
398 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe4 - fM1))|| |
399 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][1]>=xe5 + fM1)&& |
400 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe6 - fM1 ))))|| |
401 |
|
|
|
402 |
|
|
(((track_coordx[2*i][1]>=(4.246+fM))&& |
403 |
|
|
(track_coordx[2*i][1]<=(12.054-fM)))&& |
404 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i][1]>=xe1 + fM1)&& |
405 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe2 - fM1))|| |
406 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][1]>=xe3 + fM1)&& |
407 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe4 - fM1 ))|| |
408 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][1]>=xe5 + fM1)&& |
409 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][1]<=xe6 - fM1 )))) |
410 |
|
|
){ |
411 |
|
|
fXesel = true; |
412 |
|
|
} else { |
413 |
|
|
if ( fast ) return false; |
414 |
|
|
fXesel = false; |
415 |
|
|
break; |
416 |
|
|
}; |
417 |
|
|
}; |
418 |
|
|
}; |
419 |
|
|
// |
420 |
|
|
if ( section.Contains("YE") ){ |
421 |
|
|
for (Int_t i=0; i<11; i++) { |
422 |
|
|
if |
423 |
|
|
( |
424 |
|
|
(((track_coordy[2*i+1][0]>=(-12.154+fM))&& |
425 |
|
|
(track_coordy[2*i+1][0]<=(-4.346-fM)))&& |
426 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye1 + fM1)&& |
427 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye2 - fM1 ))|| |
428 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye3 + fM1)&& |
429 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye4 - fM1 ))|| |
430 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye5 + fM1)&& |
431 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye6 - fM1 ))))|| |
432 |
|
|
|
433 |
|
|
(((track_coordy[2*i+1][0]>=(-4.104+fM))&& |
434 |
|
|
(track_coordy[2*i+1][0]<=(3.704-fM)))&& |
435 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye1 + fM1)&& |
436 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye2 - fM1 ))|| |
437 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye3 + fM1)&& |
438 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye4 - fM1))|| |
439 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye5 + fM1)&& |
440 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye6 - fM1 ))))|| |
441 |
|
|
|
442 |
|
|
(((track_coordy[2*i+1][0]>=(3.946+fM))&& |
443 |
|
|
(track_coordy[2*i+1][0]<=(11.754-fM)))&& |
444 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye1 + fM1)&& |
445 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye2 - fM1))|| |
446 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye3 + fM1)&& |
447 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye4 - fM1 ))|| |
448 |
|
|
((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye5 + fM1)&& |
449 |
|
|
(L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye6 - fM1 )))) |
450 |
|
|
){ |
451 |
|
|
fYesel = true; |
452 |
|
|
} else { |
453 |
|
|
if ( fast ) return false; |
454 |
|
|
fYesel = false; |
455 |
|
|
break; |
456 |
|
|
}; |
457 |
|
|
}; |
458 |
|
|
}; |
459 |
|
|
// |
460 |
|
|
if ( section.Contains("YO") ){ |
461 |
|
|
for (Int_t i=0; i<11; i++) { |
462 |
|
|
if ( debug ) printf(" i %i track_coordy[2*i][0] %f L2->GetCaloLevel2()->cbar[2*i][0] %f \n",i,track_coordy[2*i][0],L2->GetCaloLevel2()->cbar[2*i][0]); |
463 |
|
|
if ( debug ) printf(" i %i fm %f fm1 %f yo1 %g yo2 %f yo3 %f yo4 %f yo5 %f yo6 %f \n",i,fM,fM1,yo1,yo2,yo3,yo4,yo5,yo6); |
464 |
|
|
if |
465 |
|
|
( |
466 |
|
|
(((track_coordy[2*i][0]>=(-11.954+fM))&& |
467 |
|
|
(track_coordy[2*i][0]<=(-4.146-fM)))&& |
468 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i][0]>=yo1 + fM1)&& |
469 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo2 - fM1 ))|| |
470 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][0]>=yo3 + fM1)&& |
471 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo4 - fM1 ))|| |
472 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][0]>=yo5 + fM1)&& |
473 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo6 - fM1 ))))|| |
474 |
|
|
|
475 |
|
|
(((track_coordy[2*i][0]>=(-3.904+fM))&& |
476 |
|
|
(track_coordy[2*i][0]<=(+3.904-fM)))&& |
477 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i][0]>=yo1 + fM1)&& |
478 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo2 - fM1 ))|| |
479 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][0]>=yo3 + fM1)&& |
480 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo4 - fM1))|| |
481 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][0]>=yo5 + fM1)&& |
482 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo6 - fM1 ))))|| |
483 |
|
|
|
484 |
|
|
(((track_coordy[2*i][0]>=(4.146+fM))&& |
485 |
|
|
(track_coordy[2*i][0]<=(11.954-fM)))&& |
486 |
|
|
(((L2->GetCaloLevel2()->cbar[2*i][0]>=yo1 + fM1)&& |
487 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo2 - fM1))|| |
488 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][0]>=yo3 + fM1)&& |
489 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo4 - fM1 ))|| |
490 |
|
|
((L2->GetCaloLevel2()->cbar[2*i][0]>=yo5 + fM1)&& |
491 |
|
|
(L2->GetCaloLevel2()->cbar[2*i][0]<=yo6 - fM1 )))) |
492 |
|
|
){ |
493 |
|
|
fYosel = true; |
494 |
|
|
} else { |
495 |
|
|
if ( fast ) return false; |
496 |
|
|
fYosel = false; |
497 |
|
|
break; |
498 |
|
|
}; |
499 |
|
|
}; |
500 |
|
|
}; |
501 |
|
|
// |
502 |
|
|
fSel = ( fXesel || fYesel || fXosel || fYosel ); |
503 |
|
|
fCount = (Float_t)((Int_t)fXesel+(Int_t)fXosel+(Int_t)fYesel+(Int_t)fYosel); |
504 |
|
|
if ( debug ) printf(" IsInside XE %i XO %i YE %i YO %i => SEL %i \n",fXesel,fXosel,fYesel,fYosel,fSel); |
505 |
|
|
// |
506 |
|
|
return fSel; |
507 |
|
|
// |
508 |
|
|
} |
509 |
|
|
|
510 |
|
|
void CaloEnergy::Process(){ |
511 |
|
|
TString xo = "XO"; |
512 |
|
|
this->Process(xo); |
513 |
|
|
} |
514 |
|
|
|
515 |
|
|
|
516 |
|
|
void CaloEnergy::Process(TString section){ |
517 |
|
|
// |
518 |
|
|
TString ntr = section; |
519 |
|
|
if ( !L2 ){ |
520 |
|
|
printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); |
521 |
|
|
printf(" ERROR: CaloEnergy variables not filled \n"); |
522 |
|
|
return; |
523 |
|
|
}; |
524 |
|
|
// |
525 |
|
|
Bool_t newentry = false; |
526 |
|
|
// |
527 |
|
|
if ( L2->IsORB() ){ |
528 |
|
|
if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || strcmp(ntr.Data(),sntr.Data()) ){ |
529 |
|
|
newentry = true; |
530 |
|
|
OBT = L2->GetOrbitalInfo()->OBT; |
531 |
|
|
PKT = L2->GetOrbitalInfo()->pkt_num; |
532 |
|
|
atime = L2->GetOrbitalInfo()->absTime; |
533 |
|
|
sntr = ntr; |
534 |
|
|
}; |
535 |
|
|
} else { |
536 |
|
|
newentry = true; |
537 |
|
|
}; |
538 |
|
|
// |
539 |
|
|
if ( !newentry ) return; |
540 |
|
|
// |
541 |
|
|
if ( debug ) printf(" Processing event at OBT %u PKT %u time %u section %s\n",OBT,PKT,atime,section.Data()); |
542 |
|
|
// |
543 |
|
|
Clear(); |
544 |
|
|
// |
545 |
mocchiut |
1.2 |
if ( (fM1+0.122-0.244*(Float_t)fRad) < 0. ) printf("Error: (fM1+0.122-0.244*(Float_t)fRad) < 0. fM1 %f fRad %i %f \n",fM1,fRad,(fM1+0.122-0.244*(Float_t)fRad)); |
546 |
|
|
// |
547 |
mocchiut |
1.1 |
if ( fLong ){ |
548 |
|
|
// use long fit to measure energy |
549 |
|
|
} else { |
550 |
|
|
// |
551 |
|
|
if ( this->IsInsideAcceptance(section) ){ |
552 |
|
|
// |
553 |
|
|
for (Int_t ch=0; ch< L2->GetCaloLevel1()->istrip; ch++){ |
554 |
|
|
en = L2->GetCaloLevel1()->DecodeEstrip(ch,view,plane,strip); |
555 |
|
|
enstrip[view][plane][strip]=en; |
556 |
|
|
}; |
557 |
|
|
for (Int_t i=0;i<11;i++){ |
558 |
|
|
for(strip=0; strip<96; strip++) { |
559 |
mocchiut |
1.2 |
if ( fRad < 0 ){ |
560 |
|
|
en_xep[i] += enstrip[1][2*i][strip]; |
561 |
|
|
en_yop[i] += enstrip[0][2*i][strip]; |
562 |
|
|
en_xop[i] += enstrip[1][2*i+1][strip]; |
563 |
|
|
en_yep[i] += enstrip[0][2*i+1][strip]; |
564 |
|
|
} else { |
565 |
|
|
if ( strip >= L2->GetCaloLevel2()->cibar[2*i][1]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i][1]-1+fRad ) en_xep[i] += enstrip[1][2*i][strip]; |
566 |
|
|
if ( strip >= L2->GetCaloLevel2()->cibar[2*i][0]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i][0]-1+fRad ) en_yop[i] += enstrip[0][2*i][strip]; |
567 |
|
|
if ( strip >= L2->GetCaloLevel2()->cibar[2*i+1][1]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i+1][1]-1+fRad ) en_xop[i] += enstrip[1][2*i+1][strip]; |
568 |
|
|
if ( strip >= L2->GetCaloLevel2()->cibar[2*i+1][0]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i+1][0]-1+fRad ) en_yep[i] += enstrip[0][2*i+1][strip]; |
569 |
|
|
}; |
570 |
mocchiut |
1.1 |
}; |
571 |
|
|
energyxe += en_xep[i]; |
572 |
|
|
energyyo += en_yop[i]; |
573 |
|
|
energyxo += en_xop[i]; |
574 |
|
|
energyye += en_yep[i]; |
575 |
|
|
}; |
576 |
|
|
fMax_plane = 0; |
577 |
mocchiut |
1.2 |
fMax_planexo = 0; |
578 |
|
|
fMax_planexe = 0; |
579 |
|
|
fMax_planeyo = 0; |
580 |
|
|
fMax_planeye = 0; |
581 |
mocchiut |
1.1 |
Float_t en_maxplane = 0.; |
582 |
|
|
Float_t max_en= 0.; |
583 |
|
|
if ( fXosel ){ |
584 |
|
|
max_en = 0.; |
585 |
|
|
for (Int_t ipl =0; ipl < 11; ipl ++) { |
586 |
|
|
if(en_xop[ipl] > max_en) { |
587 |
|
|
max_en = en_xop[ipl]; |
588 |
mocchiut |
1.2 |
fMax_planexo = ipl; |
589 |
mocchiut |
1.1 |
}; |
590 |
|
|
}; |
591 |
|
|
// |
592 |
mocchiut |
1.2 |
for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexo+fPl)) ;iplm++) en_maxplane += en_xop[iplm]; |
593 |
|
|
fEnergyxo = en_maxplane/fConv_rxo; |
594 |
mocchiut |
1.1 |
}; |
595 |
|
|
if ( fXesel ){ |
596 |
|
|
max_en = 0.; |
597 |
|
|
for (Int_t ipl =0; ipl < 11; ipl ++) { |
598 |
|
|
if(en_xep[ipl] > max_en) { |
599 |
|
|
max_en = en_xep[ipl]; |
600 |
mocchiut |
1.2 |
fMax_planexe = ipl; |
601 |
mocchiut |
1.1 |
}; |
602 |
|
|
}; |
603 |
|
|
// |
604 |
mocchiut |
1.2 |
for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexe+fPl)) ;iplm++) en_maxplane += en_xep[iplm]; |
605 |
|
|
fEnergyxe = en_maxplane/fConv_rxe; |
606 |
mocchiut |
1.1 |
}; |
607 |
|
|
if ( fYosel ){ |
608 |
|
|
max_en = 0.; |
609 |
|
|
for (Int_t ipl =0; ipl < 11; ipl ++) { |
610 |
|
|
if(en_yop[ipl] > max_en) { |
611 |
|
|
max_en = en_yop[ipl]; |
612 |
mocchiut |
1.2 |
fMax_planeyo = ipl; |
613 |
mocchiut |
1.1 |
}; |
614 |
|
|
}; |
615 |
|
|
// |
616 |
mocchiut |
1.2 |
for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planeyo+fPl)) ;iplm++) en_maxplane += en_yop[iplm]; |
617 |
|
|
fEnergyyo = en_maxplane/fConv_ryo; |
618 |
mocchiut |
1.1 |
}; |
619 |
|
|
if ( fYesel ){ |
620 |
|
|
max_en = 0.; |
621 |
|
|
for (Int_t ipl =0; ipl < 11; ipl ++) { |
622 |
|
|
if(en_yep[ipl] > max_en) { |
623 |
|
|
max_en = en_yep[ipl]; |
624 |
mocchiut |
1.2 |
fMax_planeye = ipl; |
625 |
mocchiut |
1.1 |
}; |
626 |
|
|
}; |
627 |
|
|
// |
628 |
mocchiut |
1.2 |
for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planeye+fPl)) ;iplm++) en_maxplane += en_yep[iplm]; |
629 |
|
|
fEnergyye = en_maxplane/fConv_rye; |
630 |
mocchiut |
1.1 |
}; |
631 |
|
|
// |
632 |
mocchiut |
1.2 |
fMax_plane = (Float_t)(fMax_planeyo+fMax_planeye+fMax_planexo+fMax_planexe)/fCount; |
633 |
|
|
fEnergy = (fEnergyxe+fEnergyyo+fEnergyye+fEnergyxo)/fCount; |
634 |
mocchiut |
1.1 |
// |
635 |
mocchiut |
1.2 |
if ( debug ) printf(" fMax_plane %f conv_r %f en_maxplane %f encalo %f \n",fMax_plane,fConv_rxo,en_maxplane,fEnergy); |
636 |
mocchiut |
1.1 |
if ( debug ) printf(" XE %i XO %i YE %i YO %i \n",fXesel,fXosel,fYesel,fYosel); |
637 |
|
|
// |
638 |
|
|
} else { |
639 |
|
|
if ( debug ) printf(" Outside acceptance \n"); |
640 |
|
|
fEnergy = -1.; |
641 |
|
|
}; |
642 |
|
|
}; |
643 |
|
|
// |
644 |
|
|
} |