1 |
mocchiut |
1.1 |
#include <CaloNuclei.h> |
2 |
|
|
|
3 |
|
|
//-------------------------------------- |
4 |
|
|
/** |
5 |
|
|
* Default constructor |
6 |
|
|
*/ |
7 |
|
|
CaloNuclei::CaloNuclei(){ |
8 |
|
|
Clear(); |
9 |
|
|
}; |
10 |
|
|
|
11 |
|
|
CaloNuclei::CaloNuclei(PamLevel2 *l2p){ |
12 |
|
|
// |
13 |
|
|
Clear(); |
14 |
|
|
// |
15 |
|
|
L2 = l2p; |
16 |
|
|
// |
17 |
|
|
if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n"); |
18 |
|
|
// |
19 |
|
|
OBT = 0; |
20 |
|
|
PKT = 0; |
21 |
|
|
atime = 0; |
22 |
|
|
N = 5; |
23 |
mocchiut |
1.2 |
R = 3; |
24 |
mocchiut |
1.1 |
// |
25 |
mocchiut |
1.4 |
debug = false; |
26 |
mocchiut |
1.5 |
usetrack = true; |
27 |
mocchiut |
1.4 |
// |
28 |
mocchiut |
1.1 |
}; |
29 |
|
|
|
30 |
|
|
void CaloNuclei::Clear(){ |
31 |
|
|
// |
32 |
mocchiut |
1.3 |
tr = 0; |
33 |
mocchiut |
1.5 |
sntr = 0; |
34 |
mocchiut |
1.1 |
interplane = 0; |
35 |
|
|
preq = 0.; |
36 |
|
|
postq = 0.; |
37 |
|
|
dedx1 = 0.; |
38 |
|
|
dedx3 = 0.; |
39 |
|
|
qpremean = 0.; |
40 |
|
|
qpremeanN = 0.; |
41 |
|
|
// |
42 |
|
|
multhit = false; |
43 |
|
|
gap = false; |
44 |
|
|
// |
45 |
|
|
}; |
46 |
|
|
|
47 |
|
|
void CaloNuclei::Print(){ |
48 |
|
|
// |
49 |
mocchiut |
1.2 |
Process(); |
50 |
|
|
// |
51 |
mocchiut |
1.3 |
printf("========================================================================\n"); |
52 |
mocchiut |
1.5 |
printf(" OBT: %u PKT: %u ATIME: %u Track %i Use track %i \n",OBT,PKT,atime,tr,usetrack); |
53 |
|
|
printf(" interplane [number of available dE/dx before interaction]:.. %i\n",interplane); |
54 |
|
|
printf(" ethr [threshold used to determine interplane]:.............. %f \n",ethr); |
55 |
|
|
printf(" dedx1 [dE/dx from the first calorimeter plane]:............. %f \n",dedx1); |
56 |
|
|
printf(" stdedx1 [dE/dx from the first calorimeter plane standalone]: %f \n",stdedx1); |
57 |
|
|
printf(" dedx3 [dE/dx (average) if the first 3 Si planes]:........... %f \n",dedx3); |
58 |
|
|
printf(" multhit [true if interplane determined by multiple hits]:... %i \n",multhit); |
59 |
|
|
printf(" gap [true if interplane determined by a gap]:............... %i \n",gap); |
60 |
|
|
printf(" preq [total energy in MIP before the interaction plane]:.... %f \n",preq); |
61 |
|
|
printf(" postq [total energy in MIP after the interaction plane]:.... %f \n",postq); |
62 |
|
|
printf(" qpremean [truncated mean using 3 planes and 3 strips]:...... %f \n",qpremean); |
63 |
|
|
printf(" N [no of used plane]:....................................... %i \n",N); |
64 |
|
|
printf(" R [no strip used per plane ]:............................... %i \n",R); |
65 |
|
|
printf(" qpremeanN [truncated mean using N planes and R strips]:..... %f \n",qpremeanN); |
66 |
mocchiut |
1.3 |
printf("========================================================================\n"); |
67 |
mocchiut |
1.1 |
// |
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
void CaloNuclei::Delete(){ |
71 |
|
|
Clear(); |
72 |
|
|
//delete this; |
73 |
|
|
}; |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
void CaloNuclei::Process(){ |
77 |
mocchiut |
1.3 |
Process(0); |
78 |
|
|
}; |
79 |
|
|
|
80 |
|
|
void CaloNuclei::Process(Int_t ntr){ |
81 |
|
|
// |
82 |
mocchiut |
1.1 |
if ( !L2 ){ |
83 |
|
|
printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); |
84 |
|
|
printf(" ERROR: CaloNuclei variables not filled \n"); |
85 |
|
|
return; |
86 |
|
|
}; |
87 |
|
|
// |
88 |
|
|
Bool_t newentry = false; |
89 |
|
|
// |
90 |
|
|
if ( L2->IsORB() ){ |
91 |
mocchiut |
1.5 |
if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr ){ |
92 |
mocchiut |
1.1 |
newentry = true; |
93 |
|
|
OBT = L2->GetOrbitalInfo()->OBT; |
94 |
|
|
PKT = L2->GetOrbitalInfo()->pkt_num; |
95 |
|
|
atime = L2->GetOrbitalInfo()->absTime; |
96 |
mocchiut |
1.5 |
sntr = ntr; |
97 |
mocchiut |
1.1 |
}; |
98 |
|
|
} else { |
99 |
|
|
newentry = true; |
100 |
|
|
}; |
101 |
|
|
// |
102 |
|
|
if ( !newentry ) return; |
103 |
|
|
// |
104 |
mocchiut |
1.3 |
tr = ntr; |
105 |
|
|
// |
106 |
mocchiut |
1.4 |
if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); |
107 |
mocchiut |
1.1 |
// |
108 |
|
|
Clear(); |
109 |
mocchiut |
1.6 |
if ( debug ) printf(" Always calculate stdedx1 \n"); |
110 |
mocchiut |
1.1 |
// |
111 |
mocchiut |
1.5 |
// Always calculate stdedx1 |
112 |
mocchiut |
1.1 |
// |
113 |
|
|
Int_t view = 0; |
114 |
|
|
Int_t plane = 0; |
115 |
|
|
Int_t strip = 0; |
116 |
mocchiut |
1.5 |
Int_t indx = 0; |
117 |
|
|
Float_t vfpl[96]; |
118 |
|
|
Int_t stfpl[96]; |
119 |
|
|
memset(vfpl, 0, 96*sizeof(Float_t)); |
120 |
|
|
memset(stfpl, 0, 96*sizeof(Int_t)); |
121 |
mocchiut |
1.1 |
Float_t mip = 0.; |
122 |
mocchiut |
1.5 |
for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){ |
123 |
|
|
// |
124 |
|
|
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
125 |
|
|
// |
126 |
|
|
// put in vfpl vector the energy release on the first plane |
127 |
|
|
// |
128 |
|
|
if ( strip != -1 && view == 1 && plane == 0 ) { |
129 |
|
|
stfpl[indx] = strip; |
130 |
|
|
vfpl[indx] = mip; |
131 |
|
|
indx++; |
132 |
|
|
}; |
133 |
|
|
// |
134 |
|
|
}; |
135 |
|
|
// |
136 |
mocchiut |
1.6 |
if ( debug ) printf(" find energy released along the strip of maximum on the first plane and on the two neighbour strips \n"); |
137 |
|
|
// |
138 |
mocchiut |
1.5 |
// find energy released along the strip of maximum on the first plane and on the two neighbour strips |
139 |
|
|
// |
140 |
|
|
if ( indx > 0 ){ |
141 |
|
|
Int_t mindx = (Int_t)TMath::LocMax(indx,stfpl); |
142 |
|
|
for (Int_t ii=0; ii<indx; ii++){ |
143 |
|
|
if ( stfpl[ii] == stfpl[mindx] ) stdedx1 += vfpl[ii]; |
144 |
|
|
if ( (mindx-1)>=0 && stfpl[ii] == stfpl[mindx-1] ) stdedx1 += vfpl[ii]; |
145 |
|
|
if ( (mindx+1)<96 && stfpl[ii] == stfpl[mindx+1] ) stdedx1 += vfpl[ii]; |
146 |
|
|
}; |
147 |
|
|
} else { |
148 |
|
|
stdedx1 = 0.; |
149 |
|
|
}; |
150 |
|
|
// |
151 |
mocchiut |
1.6 |
if ( debug ) printf(" if ( !usetrack ) return: usetrack %i ntr %i \n",usetrack,ntr); |
152 |
mocchiut |
1.5 |
// |
153 |
|
|
// |
154 |
mocchiut |
1.8 |
// if ( !usetrack ) return; |
155 |
mocchiut |
1.5 |
// |
156 |
|
|
PamTrack *ptrack = 0; |
157 |
|
|
CaloTrkVar *track = 0; |
158 |
mocchiut |
1.8 |
// |
159 |
|
|
if ( usetrack ){ |
160 |
|
|
if ( ntr >= 0 ){ |
161 |
|
|
ptrack = L2->GetTrack(ntr); |
162 |
|
|
if ( ptrack ) track = ptrack->GetCaloTrack(); |
163 |
|
|
} else { |
164 |
|
|
track = L2->GetCaloStoredTrack(ntr); |
165 |
|
|
}; |
166 |
|
|
// |
167 |
|
|
if ( !track && ntr >= 0 ){ |
168 |
|
|
printf(" ERROR: cannot find any track!\n"); |
169 |
|
|
printf(" ERROR: CaloNuclei variables not completely filled \n"); |
170 |
|
|
return; |
171 |
|
|
}; |
172 |
mocchiut |
1.5 |
} else { |
173 |
mocchiut |
1.8 |
if ( ntr >= 0 ){ |
174 |
mocchiut |
1.9 |
if ( debug ) printf(" ERROR: you asked not to use a track but you are looking for track number %i !\n",ntr); |
175 |
|
|
if ( debug ) printf(" ERROR: CaloNuclei variables not completely filled \n"); |
176 |
mocchiut |
1.8 |
return; |
177 |
|
|
}; |
178 |
mocchiut |
1.5 |
}; |
179 |
|
|
// |
180 |
mocchiut |
1.1 |
// Float_t defethr = 6. * 0.90; |
181 |
|
|
Float_t defethr = 6.25; // = (sqrt(9) - 0.5) ** 2.; |
182 |
|
|
// |
183 |
|
|
// Calculate dedx1 and dedx3 |
184 |
|
|
// |
185 |
|
|
for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){ |
186 |
|
|
// |
187 |
|
|
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
188 |
|
|
// |
189 |
mocchiut |
1.5 |
if ( ntr >= 0 ){ |
190 |
|
|
// |
191 |
|
|
if ( strip != -1 && |
192 |
|
|
view == 1 && |
193 |
|
|
plane == 0 && |
194 |
|
|
( strip == (track->tibar[0][1]-1) || strip == (track->tibar[0][1]-2) || strip == (track->tibar[0][1]) ) |
195 |
|
|
&& true ){ |
196 |
|
|
dedx1 += mip; |
197 |
|
|
}; |
198 |
|
|
if ( strip != -1 && |
199 |
|
|
(( view == 1 && ( plane == 0 || plane == 1 ) ) || |
200 |
|
|
( view == 0 && plane == 0 )) && |
201 |
|
|
(( view == 0 && ( strip == track->tibar[0][0] || strip == (track->tibar[0][0]-1) || strip == (track->tibar[0][0]-2) )) || |
202 |
|
|
( view == 1 && ( strip == track->tibar[0][1] || strip == (track->tibar[0][1]-1) || strip == (track->tibar[0][1]-2) )) || |
203 |
|
|
( view == 1 && ( strip == track->tibar[1][1] || strip == (track->tibar[1][1]-1) || strip == (track->tibar[1][1]-2) ))) && |
204 |
|
|
true ){ |
205 |
|
|
dedx3 += mip; |
206 |
|
|
}; |
207 |
|
|
} else { |
208 |
|
|
// |
209 |
|
|
if ( strip != -1 && |
210 |
|
|
view == 1 && |
211 |
|
|
plane == 0 && |
212 |
|
|
( strip == (L2->GetCaloLevel2()->cibar[0][1]-1) || strip == (L2->GetCaloLevel2()->cibar[0][1]-2) || strip == (L2->GetCaloLevel2()->cibar[0][1]) ) |
213 |
|
|
&& true ){ |
214 |
|
|
dedx1 += mip; |
215 |
|
|
}; |
216 |
|
|
if ( strip != -1 && |
217 |
|
|
(( view == 1 && ( plane == 0 || plane == 1 ) ) || |
218 |
|
|
( view == 0 && plane == 0 )) && |
219 |
|
|
(( view == 0 && ( strip == L2->GetCaloLevel2()->cibar[0][0] || strip == (L2->GetCaloLevel2()->cibar[0][0]-1) || strip == (L2->GetCaloLevel2()->cibar[0][0]-2) )) || |
220 |
|
|
( view == 1 && ( strip == L2->GetCaloLevel2()->cibar[0][1] || strip == (L2->GetCaloLevel2()->cibar[0][1]-1) || strip == (L2->GetCaloLevel2()->cibar[0][1]-2) )) || |
221 |
|
|
( view == 1 && ( strip == L2->GetCaloLevel2()->cibar[1][1] || strip == (L2->GetCaloLevel2()->cibar[1][1]-1) || strip == (L2->GetCaloLevel2()->cibar[1][1]-2) ))) && |
222 |
|
|
true ){ |
223 |
|
|
dedx3 += mip; |
224 |
|
|
}; |
225 |
mocchiut |
1.1 |
}; |
226 |
|
|
// |
227 |
|
|
}; |
228 |
|
|
// |
229 |
|
|
dedx3 /= 3.; |
230 |
|
|
// Float_t mesethr = dedx1 * 0.90; |
231 |
|
|
Float_t mesethr = 0.; |
232 |
|
|
if ( dedx1 > 0. ) mesethr = (sqrt(dedx1) - 0.50)*(sqrt(dedx1) - 0.50); |
233 |
|
|
Bool_t aldone = false; |
234 |
|
|
// |
235 |
|
|
retry: |
236 |
|
|
// |
237 |
mocchiut |
1.4 |
if ( debug ) printf("retry\n"); |
238 |
mocchiut |
1.1 |
// |
239 |
|
|
interplane = 0; |
240 |
|
|
// |
241 |
|
|
ethr = TMath::Max(defethr,mesethr); |
242 |
|
|
// |
243 |
|
|
// Find the interaction plane "interplane" |
244 |
|
|
// |
245 |
|
|
Int_t gapth = 3; |
246 |
|
|
Int_t nhit[2] = {0,0}; |
247 |
|
|
Int_t splane[2] = {-1,-1}; |
248 |
|
|
Int_t sview[2] = {-1,-1}; |
249 |
|
|
Int_t interpl[2] = {-1,-1}; |
250 |
|
|
Int_t interv[2] = {-1,-1}; |
251 |
|
|
Bool_t wmulthit[2] = {false,false}; |
252 |
|
|
Bool_t wgap[2] = {false,false}; |
253 |
|
|
Int_t ii = 0; |
254 |
|
|
while ( ii<L2->GetCaloLevel1()->istrip ){ |
255 |
|
|
// |
256 |
|
|
mip = L2->GetCaloLevel1()->DecodeEstrip(ii,view,plane,strip); |
257 |
|
|
// |
258 |
mocchiut |
1.5 |
if ( ntr >= 0 ){ |
259 |
|
|
if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] && |
260 |
|
|
( strip == (track->tibar[plane][view]-1) || strip == (track->tibar[plane][view]-2) || strip == (track->tibar[plane][view]) ) |
261 |
|
|
&& true ){ |
262 |
|
|
if ( debug ) printf(" inside loop: ii %i mip %f view %i plane %i strip %i tibar %i nhit %i splane %i sview %i \n",ii,mip,view,plane,strip,track->tibar[plane][view]-1,nhit[view],splane[view],sview[view]); |
263 |
|
|
interpl[view] = plane; |
264 |
|
|
interv[view] = view; |
265 |
|
|
if ( splane[view] != plane || sview[view] != view ){ |
266 |
|
|
if ( nhit[view] > 1 ){ |
267 |
|
|
wmulthit[view] = true; |
268 |
|
|
// if ( splane[view] == -1 ) splane[view] = 0; // |
269 |
|
|
// if ( sview[view] == -1 ) sview[view] = view; // |
270 |
|
|
interpl[view] = splane[view]; |
271 |
|
|
interv[view] = sview[view]; |
272 |
|
|
}; |
273 |
|
|
if ( plane > splane[view]+gapth ){ |
274 |
|
|
wgap[view] = true; |
275 |
|
|
// if ( splane[view] == -1 ) splane[view] = 0;// |
276 |
|
|
// if ( sview[view] == -1 ) sview[view] = view; // |
277 |
|
|
interpl[view] = splane[view]; |
278 |
|
|
interv[view] = sview[view]; |
279 |
|
|
}; |
280 |
|
|
splane[view] = plane; |
281 |
|
|
sview[view] = view; |
282 |
|
|
nhit[view] = 1; |
283 |
|
|
} else { |
284 |
|
|
nhit[view]++; |
285 |
|
|
}; |
286 |
|
|
}; |
287 |
|
|
} else { |
288 |
|
|
if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] && |
289 |
|
|
( strip == (L2->GetCaloLevel2()->cibar[plane][view]-1) || strip == (L2->GetCaloLevel2()->cibar[plane][view]-2) || strip == (L2->GetCaloLevel2()->cibar[plane][view]) ) |
290 |
|
|
&& true ){ |
291 |
|
|
if ( debug ) printf(" inside loop: ii %i mip %f view %i plane %i strip %i cibar %i nhit %i splane %i sview %i \n",ii,mip,view,plane,strip,L2->GetCaloLevel2()->cibar[plane][view]-1,nhit[view],splane[view],sview[view]); |
292 |
|
|
interpl[view] = plane; |
293 |
|
|
interv[view] = view; |
294 |
|
|
if ( splane[view] != plane || sview[view] != view ){ |
295 |
|
|
if ( nhit[view] > 1 ){ |
296 |
|
|
wmulthit[view] = true; |
297 |
|
|
// if ( splane[view] == -1 ) splane[view] = 0; // |
298 |
|
|
// if ( sview[view] == -1 ) sview[view] = view; // |
299 |
|
|
interpl[view] = splane[view]; |
300 |
|
|
interv[view] = sview[view]; |
301 |
mocchiut |
1.1 |
}; |
302 |
mocchiut |
1.5 |
if ( plane > splane[view]+gapth ){ |
303 |
|
|
wgap[view] = true; |
304 |
|
|
// if ( splane[view] == -1 ) splane[view] = 0;// |
305 |
|
|
// if ( sview[view] == -1 ) sview[view] = view; // |
306 |
|
|
interpl[view] = splane[view]; |
307 |
|
|
interv[view] = sview[view]; |
308 |
|
|
}; |
309 |
|
|
splane[view] = plane; |
310 |
|
|
sview[view] = view; |
311 |
|
|
nhit[view] = 1; |
312 |
|
|
} else { |
313 |
|
|
nhit[view]++; |
314 |
mocchiut |
1.1 |
}; |
315 |
|
|
}; |
316 |
|
|
}; |
317 |
|
|
// |
318 |
|
|
ii++; |
319 |
|
|
// |
320 |
|
|
}; |
321 |
|
|
// |
322 |
mocchiut |
1.4 |
if (debug ) printf("conversion interpl %i interv %i multhit %i interplane %i \n",interpl[0],interv[0],multhit,interplane); |
323 |
mocchiut |
1.1 |
Int_t winterplane[2] = {-1,-1}; |
324 |
|
|
// |
325 |
|
|
for ( Int_t view = 0; view < 2; view++){ |
326 |
|
|
// |
327 |
|
|
if ( nhit[view] > 1 && !wmulthit[view] && !wgap[view] ){ |
328 |
|
|
wmulthit[view] = true; |
329 |
|
|
interpl[view] = splane[view]; |
330 |
|
|
interv[view] = sview[view]; |
331 |
|
|
}; |
332 |
|
|
// |
333 |
|
|
if ( wmulthit[view] ) multhit = true; |
334 |
|
|
if ( wgap[view] ) gap = true; |
335 |
|
|
// |
336 |
|
|
// convert view and plane number of interaction plane into number of available dE/dx measurements before the interaction plane |
337 |
|
|
// |
338 |
|
|
if ( interpl[view] >= 0 ) { |
339 |
|
|
if ( interv[view] == 0 ){ |
340 |
|
|
winterplane[view] = (1 + interpl[view]) * 2; |
341 |
|
|
} else { |
342 |
|
|
winterplane[view] = (1 + interpl[view]) + (1 + interpl[view] - 1); |
343 |
|
|
}; |
344 |
|
|
if ( wmulthit[view] ) winterplane[view]--; |
345 |
|
|
}; |
346 |
|
|
}; |
347 |
|
|
if ( winterplane[0] > 0 && winterplane[1] > 0 ){ |
348 |
|
|
if ( multhit ){ |
349 |
|
|
interplane = TMath::Min(winterplane[0],winterplane[1]); |
350 |
|
|
} else { |
351 |
|
|
interplane = TMath::Max(winterplane[0],winterplane[1]); |
352 |
|
|
}; |
353 |
|
|
} else { |
354 |
|
|
if ( !winterplane[0] || !winterplane[1] ){ |
355 |
|
|
interplane = 0; |
356 |
|
|
} else { |
357 |
|
|
interplane = TMath::Max(winterplane[0],winterplane[1]); |
358 |
|
|
}; |
359 |
|
|
}; |
360 |
|
|
// |
361 |
mocchiut |
1.4 |
if ( debug ) printf("2conversion interpl %i interv %i multhit %i interplane %i \n",interpl[1],interv[1],multhit,interplane); |
362 |
|
|
if ( debug ) printf("3conversion winterpl0 %i winterpl1 %i \n",winterplane[0],winterplane[1]); |
363 |
mocchiut |
1.1 |
// |
364 |
|
|
Int_t ipl = 0; |
365 |
|
|
if ( interplane > 0 ){ |
366 |
|
|
// |
367 |
|
|
// Calculate preq, postq, qpremean |
368 |
|
|
// |
369 |
|
|
ii = 0; |
370 |
|
|
Int_t ind = -1; |
371 |
|
|
Int_t qsplane = -1; |
372 |
|
|
Int_t qsview = -1; |
373 |
mocchiut |
1.2 |
Int_t ind2 = -1; |
374 |
|
|
Int_t qsplane2 = -1; |
375 |
|
|
Int_t qsview2 = -1; |
376 |
mocchiut |
1.1 |
Float_t qme[200]; |
377 |
|
|
memset(qme,0,200*sizeof(Float_t)); |
378 |
mocchiut |
1.2 |
Float_t qme2[2112]; |
379 |
|
|
memset(qme2,0,2112*sizeof(Float_t)); |
380 |
mocchiut |
1.1 |
// |
381 |
|
|
while ( ii<L2->GetCaloLevel1()->istrip ){ |
382 |
|
|
// |
383 |
|
|
mip = L2->GetCaloLevel1()->DecodeEstrip(ii,view,plane,strip); |
384 |
|
|
// |
385 |
|
|
if ( strip != -1 ){ |
386 |
|
|
if ( view == 0 ){ |
387 |
|
|
ipl = (1 + plane) * 2; |
388 |
|
|
} else { |
389 |
|
|
ipl = (1 + plane) + (1 + plane - 1 ); |
390 |
|
|
}; |
391 |
|
|
if ( ipl > interplane ){ |
392 |
|
|
postq += mip; |
393 |
|
|
} else { |
394 |
|
|
preq += mip; |
395 |
mocchiut |
1.5 |
if ( ntr >= 0 ){ |
396 |
|
|
if ( strip == (track->tibar[plane][view]-1) || strip == (track->tibar[plane][view]-2) || strip == (track->tibar[plane][view]) ){ |
397 |
|
|
if ( qsplane != plane || qsview != view ){ |
398 |
|
|
qsplane = plane; |
399 |
|
|
qsview = view; |
400 |
|
|
ind++; |
401 |
|
|
if ( debug && ind > 199 ) printf(" AAAGH!! \n"); |
402 |
|
|
qme[ind] = 0.; |
403 |
|
|
}; |
404 |
|
|
qme[ind] += mip; |
405 |
mocchiut |
1.1 |
}; |
406 |
mocchiut |
1.5 |
for ( Int_t ns = 0; ns < R ; ns++){ |
407 |
|
|
Int_t ms = track->tibar[plane][view] - 1 - ns + (R - 1)/2; |
408 |
|
|
if ( strip == ms ){ |
409 |
|
|
if ( qsplane2 != plane || qsview2 != view ){ |
410 |
|
|
qsplane2 = plane; |
411 |
|
|
qsview2 = view; |
412 |
|
|
ind2++; |
413 |
|
|
if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n"); |
414 |
|
|
qme2[ind2] = 0.; |
415 |
|
|
}; |
416 |
|
|
qme2[ind2] += mip; |
417 |
|
|
}; |
418 |
|
|
}; |
419 |
|
|
} else { |
420 |
|
|
if ( strip == (L2->GetCaloLevel2()->cibar[plane][view]-1) || strip == (L2->GetCaloLevel2()->cibar[plane][view]-2) || strip == (L2->GetCaloLevel2()->cibar[plane][view]) ){ |
421 |
|
|
if ( qsplane != plane || qsview != view ){ |
422 |
|
|
qsplane = plane; |
423 |
|
|
qsview = view; |
424 |
|
|
ind++; |
425 |
|
|
if ( debug && ind > 199 ) printf(" AAAGH!! \n"); |
426 |
|
|
qme[ind] = 0.; |
427 |
mocchiut |
1.2 |
}; |
428 |
mocchiut |
1.5 |
qme[ind] += mip; |
429 |
mocchiut |
1.2 |
}; |
430 |
mocchiut |
1.5 |
for ( Int_t ns = 0; ns < R ; ns++){ |
431 |
|
|
Int_t ms = L2->GetCaloLevel2()->cibar[plane][view] - 1 - ns + (R - 1)/2; |
432 |
|
|
if ( strip == ms ){ |
433 |
|
|
if ( qsplane2 != plane || qsview2 != view ){ |
434 |
|
|
qsplane2 = plane; |
435 |
|
|
qsview2 = view; |
436 |
|
|
ind2++; |
437 |
|
|
if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n"); |
438 |
|
|
qme2[ind2] = 0.; |
439 |
|
|
}; |
440 |
|
|
qme2[ind2] += mip; |
441 |
|
|
}; |
442 |
|
|
}; |
443 |
|
|
}; |
444 |
mocchiut |
1.1 |
}; |
445 |
|
|
// |
446 |
|
|
}; |
447 |
|
|
// |
448 |
|
|
ii++; |
449 |
|
|
// |
450 |
|
|
}; |
451 |
|
|
// |
452 |
|
|
// here we must calculate qpremean, order vector qme, select 3 lowest measurements and caculate the mean... |
453 |
|
|
// |
454 |
mocchiut |
1.4 |
if ( debug ){ |
455 |
|
|
for (Int_t l=0; l < interplane; l++){ |
456 |
|
|
printf(" qme[%i] = %f \n",l,qme[l]); |
457 |
|
|
}; |
458 |
|
|
}; |
459 |
|
|
// |
460 |
mocchiut |
1.1 |
Long64_t work[200]; |
461 |
|
|
ind = 0; |
462 |
|
|
Int_t l = 0; |
463 |
mocchiut |
1.5 |
Int_t RN = 0; |
464 |
mocchiut |
1.1 |
Float_t qm = 0.; |
465 |
mocchiut |
1.2 |
Float_t qm2 = 0.; |
466 |
|
|
// |
467 |
|
|
Float_t qmt = ethr*0.8; // *0.9 |
468 |
|
|
// |
469 |
mocchiut |
1.1 |
Int_t uplim = TMath::Max(3,N); |
470 |
mocchiut |
1.2 |
// |
471 |
mocchiut |
1.1 |
while ( l < uplim && ind < interplane ){ |
472 |
|
|
qm = TMath::KOrdStat(interplane,qme,ind,work); |
473 |
mocchiut |
1.2 |
if ( qm >= qmt ){ |
474 |
mocchiut |
1.5 |
if ( l < 3 ){ |
475 |
|
|
qpremean += qm; |
476 |
|
|
RN++; |
477 |
|
|
}; |
478 |
mocchiut |
1.1 |
l++; |
479 |
mocchiut |
1.4 |
if ( debug ) printf(" value no %i qm %f qmt %f \n",l,qm,qmt); |
480 |
mocchiut |
1.2 |
}; |
481 |
|
|
ind++; |
482 |
|
|
}; |
483 |
|
|
// |
484 |
mocchiut |
1.5 |
qpremean /= (Float_t)RN; |
485 |
mocchiut |
1.4 |
// |
486 |
mocchiut |
1.2 |
ind = 0; |
487 |
|
|
l = 0; |
488 |
mocchiut |
1.5 |
RN = 0; |
489 |
mocchiut |
1.2 |
while ( l < uplim && ind < interplane ){ |
490 |
|
|
qm2 = TMath::KOrdStat(interplane,qme2,ind,work); |
491 |
|
|
if ( qm2 >= qmt ){ |
492 |
mocchiut |
1.5 |
if ( l < N ){ |
493 |
|
|
qpremeanN += qm2; |
494 |
|
|
RN++; |
495 |
|
|
}; |
496 |
mocchiut |
1.2 |
l++; |
497 |
mocchiut |
1.5 |
if ( debug ) printf(" qm2 value no %i qm %f qmt %f RN %i \n",l,qm2,qmt,RN); |
498 |
mocchiut |
1.1 |
}; |
499 |
|
|
ind++; |
500 |
|
|
}; |
501 |
|
|
// |
502 |
mocchiut |
1.5 |
qpremeanN /= (Float_t)RN; |
503 |
mocchiut |
1.1 |
// |
504 |
mocchiut |
1.4 |
if ( debug ) printf(" charge is %f \n",sqrt(qpremean)); |
505 |
mocchiut |
1.1 |
// |
506 |
|
|
if ( mesethr != ethr && interplane >= 3 && !aldone ){ |
507 |
|
|
Float_t mesethr2 = (sqrt(qpremean) - 0.50)*(sqrt(qpremean) - 0.50); |
508 |
|
|
if ( mesethr2 < mesethr*0.90 ){ |
509 |
|
|
mesethr = (sqrt(dedx1) - 0.25)*(sqrt(dedx1) - 0.25); |
510 |
|
|
} else { |
511 |
|
|
mesethr = mesethr2; |
512 |
|
|
}; |
513 |
|
|
aldone = true; |
514 |
mocchiut |
1.7 |
if ( mesethr > defethr ){ |
515 |
|
|
interplane = 0; |
516 |
|
|
preq = 0.; |
517 |
|
|
postq = 0.; |
518 |
|
|
qpremean = 0.; |
519 |
|
|
qpremeanN = 0.; |
520 |
|
|
multhit = false; |
521 |
|
|
gap = false; |
522 |
|
|
goto retry; |
523 |
|
|
}; |
524 |
mocchiut |
1.1 |
}; |
525 |
|
|
}; |
526 |
|
|
// |
527 |
mocchiut |
1.5 |
if ( debug ) this->Print(); |
528 |
mocchiut |
1.4 |
if ( debug ) printf(" esci \n"); |
529 |
mocchiut |
1.1 |
// |
530 |
|
|
}; |