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