1 |
/** |
2 |
* \file TrkLevel1.cpp |
3 |
* \author Elena Vannuccini |
4 |
*/ |
5 |
#include <TrkLevel1.h> |
6 |
#include <iostream> |
7 |
using namespace std; |
8 |
//...................................... |
9 |
// F77 routines |
10 |
//...................................... |
11 |
extern "C" { |
12 |
|
13 |
// int readetaparam_(); |
14 |
float cog_(int*,int*); |
15 |
float pfaeta_(int*,float*); |
16 |
float pfaeta2_(int*,float*); |
17 |
float pfaeta3_(int*,float*); |
18 |
float pfaeta4_(int*,float*); |
19 |
float pfaetal_(int*,float*); |
20 |
|
21 |
} |
22 |
//-------------------------------------- |
23 |
// |
24 |
// |
25 |
//-------------------------------------- |
26 |
TrkCluster::TrkCluster(){ |
27 |
|
28 |
// cout << "TrkCluster::TrkCluster()"<<endl; |
29 |
view = -1; |
30 |
maxs = -1; |
31 |
indmax = -1; |
32 |
|
33 |
CLlength = 0; |
34 |
clsignal = 0; |
35 |
clsigma = 0; |
36 |
cladc = 0; |
37 |
clbad = 0; |
38 |
|
39 |
}; |
40 |
//-------------------------------------- |
41 |
// |
42 |
// |
43 |
//-------------------------------------- |
44 |
TrkCluster::TrkCluster(const TrkCluster& t){ |
45 |
|
46 |
view = t.view; |
47 |
maxs = t.maxs; |
48 |
indmax = t.indmax; |
49 |
|
50 |
CLlength = t.CLlength; |
51 |
if(CLlength){ |
52 |
clsignal = new Float_t[CLlength]; |
53 |
clsigma = new Float_t[CLlength]; |
54 |
cladc = new Int_t[CLlength]; |
55 |
clbad = new Bool_t[CLlength]; |
56 |
for(Int_t i=0; i<CLlength;i++){ |
57 |
clsignal[i] = t.clsignal[i]; |
58 |
clsigma[i] = t.clsigma[i]; |
59 |
cladc[i] = t.cladc[i]; |
60 |
clbad[i] = t.clbad[i]; |
61 |
}; |
62 |
}; |
63 |
}; |
64 |
//-------------------------------------- |
65 |
// |
66 |
// |
67 |
//-------------------------------------- |
68 |
void TrkCluster::Clear(){ |
69 |
|
70 |
// cout << "void TrkCluster::Clear()"<<endl; |
71 |
if(CLlength){ |
72 |
delete [] clsignal; |
73 |
delete [] clsigma; |
74 |
delete [] cladc; |
75 |
delete [] clbad; |
76 |
} |
77 |
|
78 |
view = 0; |
79 |
maxs = 0; |
80 |
indmax = 0; |
81 |
|
82 |
CLlength = 0; |
83 |
clsignal = 0; |
84 |
clsigma = 0; |
85 |
cladc = 0; |
86 |
clbad = 0; |
87 |
|
88 |
}; |
89 |
//-------------------------------------- |
90 |
// |
91 |
// |
92 |
//-------------------------------------- |
93 |
/** |
94 |
* Evaluate the cluster signal including a maximum number of adjacent |
95 |
* strips, around maxs, having a significant signal. |
96 |
* @param nstrip Maximum number of strips. |
97 |
* @param cut Inclusion cut ( s > cut*sigma ). |
98 |
* If nstrip<=0 only the inclusion cut is used to determine the cluster size. |
99 |
*/ |
100 |
Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut){ |
101 |
|
102 |
if(CLlength<=0)return 0; |
103 |
|
104 |
Float_t s = 0; |
105 |
|
106 |
if( nstrip<=0 ){ |
107 |
// for(Int_t is = 0; is < CLlength; is++){ |
108 |
// Float_t scut = cut*clsigma[is]; |
109 |
// if(clsignal[is] > scut) s += clsignal[is]; |
110 |
// }; |
111 |
for(Int_t is = indmax+1; is < CLlength; is++){ |
112 |
Float_t scut = cut*clsigma[is]; |
113 |
if(clsignal[is] > scut) s += clsignal[is]; |
114 |
else break; |
115 |
}; |
116 |
for(Int_t is = indmax; is >=0; is--){ |
117 |
Float_t scut = cut*clsigma[is]; |
118 |
if(clsignal[is] > scut) s += clsignal[is]; |
119 |
else break; |
120 |
}; |
121 |
return s; |
122 |
}; |
123 |
|
124 |
|
125 |
Int_t il = indmax; |
126 |
Int_t ir = indmax; |
127 |
Int_t inc = 0; |
128 |
|
129 |
if( clsignal[indmax] < cut*clsigma[indmax] ) return 0; |
130 |
|
131 |
while ( inc < nstrip ){ |
132 |
Float_t sl = -100000; |
133 |
Float_t sr = -100000; |
134 |
if( il >= 0 ) sl = clsignal[il]; |
135 |
if( ir < CLlength ) sr = clsignal[ir]; |
136 |
if( sl == sr && inc == 0 ){ |
137 |
s += clsignal[il]; //cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl; |
138 |
il--; |
139 |
ir++; |
140 |
}else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){ |
141 |
s += sl;//cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl; |
142 |
il--; |
143 |
}else if ( sl < sr && sr > cut*clsigma[ir] ){ |
144 |
s += sr;//cout << inc<<" - " << clsignal[ir]<<" "<<s<<endl; |
145 |
ir++; |
146 |
}else break; |
147 |
|
148 |
inc++; |
149 |
} |
150 |
return s; |
151 |
}; |
152 |
|
153 |
|
154 |
/** |
155 |
* Evaluate the cluster signal-to-noise, as defined by Turchetta, including a |
156 |
* maximum number of adjacent strips, around maxs, having a significant signal. |
157 |
* @param nstrip Maximum number of strips. |
158 |
* @param cut Inclusion cut ( s > cut*sigma ). |
159 |
* If nstrip<=0 only the inclusion cut is used to determine the cluster size. |
160 |
*/ |
161 |
Float_t TrkCluster::GetSignalToNoise(Int_t nstrip, Float_t cut){ |
162 |
|
163 |
if(CLlength<=0)return 0; |
164 |
|
165 |
Float_t sn = 0; |
166 |
|
167 |
if( nstrip<=0 ){ |
168 |
for(Int_t is = indmax+1; is < CLlength; is++){ |
169 |
Float_t scut = cut*clsigma[is]; |
170 |
if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is]; |
171 |
else break; |
172 |
}; |
173 |
for(Int_t is = indmax; is >=0; is--){ |
174 |
Float_t scut = cut*clsigma[is]; |
175 |
if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is]; |
176 |
else break; |
177 |
}; |
178 |
return sn; |
179 |
}; |
180 |
|
181 |
|
182 |
Int_t il = indmax; |
183 |
Int_t ir = indmax; |
184 |
Int_t inc = 0; |
185 |
|
186 |
if( clsignal[indmax] < cut*clsigma[indmax] ) return 0; |
187 |
|
188 |
while ( inc < nstrip ){ |
189 |
Float_t sl = -100000; |
190 |
Float_t sr = -100000; |
191 |
if( il >= 0 ) sl = clsignal[il]; |
192 |
if( ir < CLlength ) sr = clsignal[ir]; |
193 |
if( sl == sr && inc == 0 ){ |
194 |
sn += clsignal[il]/clsigma[il]; |
195 |
il--; |
196 |
ir++; |
197 |
}else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){ |
198 |
sn += sl/clsigma[il]; |
199 |
il--; |
200 |
}else if ( sl < sr && sr > cut*clsigma[ir] ){ |
201 |
sn += sr/clsigma[ir]; |
202 |
ir++; |
203 |
}else break; |
204 |
|
205 |
inc++; |
206 |
} |
207 |
return sn; |
208 |
}; |
209 |
/** |
210 |
* Evaluate the cluster multiplicity. |
211 |
* @param cut Inclusion cut. |
212 |
*/ |
213 |
Int_t TrkCluster::GetMultiplicity(Float_t cut){ |
214 |
|
215 |
if(CLlength<=0)return 0; |
216 |
|
217 |
Int_t m = 0; |
218 |
|
219 |
for(Int_t is = indmax+1; is < CLlength; is++){ |
220 |
Float_t scut = cut*clsigma[is]; |
221 |
if(clsignal[is] > scut) m++; |
222 |
else break; |
223 |
}; |
224 |
for(Int_t is = indmax; is >=0; is--){ |
225 |
Float_t scut = cut*clsigma[is]; |
226 |
if(clsignal[is] > scut) m++; |
227 |
else break; |
228 |
}; |
229 |
return m; |
230 |
}; |
231 |
/** |
232 |
* True if the cluster contains bad strips. |
233 |
* @param nbad Number of strips around the maximum. |
234 |
*/ |
235 |
Bool_t TrkCluster::IsBad(Int_t nbad){ |
236 |
|
237 |
if(CLlength<=0)return 0; |
238 |
|
239 |
Int_t il,ir; |
240 |
il = indmax; |
241 |
ir = indmax; |
242 |
for(Int_t i=1; i<nbad; i++){ |
243 |
if (ir == CLlength-1 && il == 0)break; |
244 |
else if (ir == CLlength-1 && il != 0)il--; |
245 |
else if (ir != CLlength-1 && il == 0)ir++; |
246 |
else{ |
247 |
if(clsignal[il-1] > clsignal[ir+1])il--; |
248 |
else ir++; |
249 |
} |
250 |
} |
251 |
Int_t isbad = 0; |
252 |
for(Int_t i=il; i<=ir; i++)isbad += clbad[i]; |
253 |
|
254 |
return ( isbad != nbad ); |
255 |
}; |
256 |
/** |
257 |
* True if the cluster contains saturated strips. |
258 |
* @param nbad Number of strips around the maximum. |
259 |
*/ |
260 |
Bool_t TrkCluster::IsSaturated(Int_t nbad){ |
261 |
|
262 |
if(CLlength<=0)return 0; |
263 |
|
264 |
Int_t il,ir; |
265 |
il = indmax; |
266 |
ir = indmax; |
267 |
for(Int_t i=1; i<nbad; i++){ |
268 |
if (ir == CLlength-1 && il == 0)break; |
269 |
else if (ir == CLlength-1 && il != 0)il--; |
270 |
else if (ir != CLlength-1 && il == 0)ir++; |
271 |
else{ |
272 |
if(clsignal[il-1] > clsignal[ir+1])il--; |
273 |
else ir++; |
274 |
} |
275 |
} |
276 |
Int_t isbad = 0; |
277 |
for(Int_t i=il; i<=ir; i++){ |
278 |
if( IsX() && cladc[i] > 2980 )isbad++; |
279 |
if( IsY() && cladc[i] < 80 )isbad++; |
280 |
} |
281 |
return ( isbad != 0 ); |
282 |
|
283 |
} |
284 |
//-------------------------------------- |
285 |
// |
286 |
// |
287 |
//-------------------------------------- |
288 |
void TrkCluster::Dump(){ |
289 |
|
290 |
cout << "----- Cluster" << endl; |
291 |
cout << "View "<<view << " - Ladder "<<GetLadder()<<endl; |
292 |
cout << "Position of maximun "<< maxs <<endl; |
293 |
cout << "Multiplicity "<< GetMultiplicity() <<endl; |
294 |
cout << "Tot signal "<< GetSignal() << " (ADC channels)"<<endl ; |
295 |
cout << "Signal/Noise "<< GetSignalToNoise()<<endl; |
296 |
cout << "COG "<< GetCOG(0)<<endl;; |
297 |
cout << "Strip signals "; |
298 |
for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i]; |
299 |
cout <<endl<< "Strip sigmas "; |
300 |
for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i]; |
301 |
cout <<endl<< "Strip ADC "; |
302 |
for(Int_t i =0; i<CLlength; i++)cout << " " <<cladc[i]; |
303 |
cout <<endl<< "Strip BAD "; |
304 |
for(Int_t i =0; i<CLlength; i++){ |
305 |
if(i==indmax)cout << " *" <<clbad[i]<<"*"; |
306 |
else cout << " " <<clbad[i]; |
307 |
} |
308 |
cout << endl; |
309 |
|
310 |
} |
311 |
//-------------------------------------- |
312 |
// |
313 |
// |
314 |
//-------------------------------------- |
315 |
/** |
316 |
* Method to fill a level1 struct with only one cluster (done to use F77 p.f.a. routines on a cluster basis). |
317 |
*/ |
318 |
void TrkCluster::GetLevel1Struct(cTrkLevel1* l1){ |
319 |
|
320 |
// cTrkLevel1* l1 = new cTrkLevel1; |
321 |
|
322 |
// cTrkLevel1* l1 = &level1event_ ; |
323 |
|
324 |
l1->nclstr1 = 1; |
325 |
l1->view[0] = view; |
326 |
l1->ladder[0] = GetLadder(); |
327 |
l1->maxs[0] = maxs; |
328 |
l1->mult[0] = GetMultiplicity(); |
329 |
l1->dedx[0] = GetSignal(); |
330 |
l1->indstart[0] = 1; |
331 |
l1->indmax[0] = indmax+1; |
332 |
l1->totCLlength = CLlength; |
333 |
for(Int_t i=0; i<CLlength; i++){ |
334 |
l1->clsignal[i] = clsignal[i]; |
335 |
l1->clsigma[i] = clsigma[i]; |
336 |
l1->cladc[i] = cladc[i]; |
337 |
l1->clbad[i] = clbad[i]; |
338 |
}; |
339 |
|
340 |
// return l1; |
341 |
}; |
342 |
//-------------------------------------- |
343 |
// |
344 |
// |
345 |
//-------------------------------------- |
346 |
/** |
347 |
* Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs). |
348 |
* @param ncog Number of strips to evaluate COG. |
349 |
* If ncog=0, the COG of the cluster is evaluated according to the cluster multiplicity (defined by the inclusion cut). |
350 |
* If ncog>0, the COG is evaluated using ncog strips, even if they have a negative signal (according to G.Landi) |
351 |
*/ |
352 |
Float_t TrkCluster::GetCOG(Int_t ncog){ |
353 |
|
354 |
int ic = 1; |
355 |
GetLevel1Struct(); |
356 |
return cog_(&ncog,&ic); |
357 |
|
358 |
}; |
359 |
/** |
360 |
* Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs), |
361 |
* choosing the number of strips according to the angle, as implemented for the eta-algorythm . |
362 |
* @param angle Projected angle in degree. |
363 |
*/ |
364 |
Float_t TrkCluster::GetCOG(Float_t angle){ |
365 |
|
366 |
Int_t neta = 0; |
367 |
|
368 |
// Float_t eta = GetETA(0,angle); |
369 |
// for(neta=2; neta<10; neta++) if( eta == GetETA(neta,angle) ) break; |
370 |
// if(eta != GetETA(neta,angle) )cout << "Attenzione!! pasticcio "<<endl; |
371 |
|
372 |
if( view%2 ){ //Y |
373 |
neta=2; |
374 |
}else{ //X |
375 |
if( fabs(angle) <= 10. ){ |
376 |
neta = 2; |
377 |
}else if( fabs(angle) > 10. && fabs(angle) <= 15. ){ |
378 |
neta = 3; |
379 |
}else{ |
380 |
neta = 4; |
381 |
}; |
382 |
}; |
383 |
|
384 |
return GetCOG(neta); |
385 |
|
386 |
}; |
387 |
//-------------------------------------- |
388 |
// |
389 |
// |
390 |
//-------------------------------------- |
391 |
/** |
392 |
* Evaluates the cluster position, in pitch units, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm. |
393 |
* @param neta Number of strips to evaluate ETA. |
394 |
* @param angle Projected (effective) angle between particle track and detector plane. |
395 |
* Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle. |
396 |
*/ |
397 |
Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi){ |
398 |
|
399 |
// cout << "GetETA(neta,angle) "<< neta << " "<< angle; |
400 |
// LoadPfaParam(); |
401 |
|
402 |
TrkParams::Load(4); |
403 |
if( !TrkParams::IsLoaded(4) ){ |
404 |
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
405 |
return 0; |
406 |
} |
407 |
|
408 |
float ax = angle; |
409 |
int ic = 1; |
410 |
GetLevel1Struct(); |
411 |
if( neta == 0 && !landi) return pfaeta_(&ic,&ax); |
412 |
else if(neta == 0 && landi ) return pfaetal_(&ic,&ax); |
413 |
else if(neta == 2 ) return pfaeta2_(&ic,&ax); |
414 |
else if(neta == 3 ) return pfaeta3_(&ic,&ax); |
415 |
else if(neta == 4 ) return pfaeta4_(&ic,&ax); |
416 |
else cout << "ETA"<<neta<<" not implemented\n"; |
417 |
return 0; |
418 |
|
419 |
}; |
420 |
|
421 |
/** |
422 |
* Evaluates the cluster position, in pitch units, relative to the strip with |
423 |
* the maximum signal (TrkCluster::maxs), by applying the PFA set as default (see TrkParams). |
424 |
* @param angle Projected (effective) angle between particle track and detector plane. |
425 |
*/ |
426 |
Float_t TrkCluster::GetPositionPU(float angle){ |
427 |
|
428 |
if( TrkParams::GetPFA() == 0 )return GetETA(0,angle,false); |
429 |
if( TrkParams::GetPFA() == 1 )return 0.; |
430 |
if( TrkParams::GetPFA() == 2 )return GetETA(2,angle,false); |
431 |
if( TrkParams::GetPFA() == 3 )return GetETA(3,angle,false); |
432 |
if( TrkParams::GetPFA() == 4 )return GetETA(4,angle,false); |
433 |
if( TrkParams::GetPFA() == 5 )return GetETA(0,angle,true); |
434 |
if( TrkParams::GetPFA() == 6 )return 0.; |
435 |
if( TrkParams::GetPFA() == 7 )return 0.; |
436 |
if( TrkParams::GetPFA() == 8 )return 0.; |
437 |
if( TrkParams::GetPFA() == 9 )return 0.; |
438 |
if( TrkParams::GetPFA() == 10 )return GetCOG(0); |
439 |
if( TrkParams::GetPFA() == 11 )return GetCOG(1); |
440 |
if( TrkParams::GetPFA() == 12 )return GetCOG(2); |
441 |
if( TrkParams::GetPFA() == 13 )return GetCOG(3); |
442 |
if( TrkParams::GetPFA() == 14 )return GetCOG(4); |
443 |
|
444 |
return 0.; |
445 |
|
446 |
} |
447 |
|
448 |
//-------------------------------------- |
449 |
// |
450 |
// |
451 |
//-------------------------------------- |
452 |
TrkLevel1::TrkLevel1(){ |
453 |
|
454 |
// cout << "TrkLevel1::TrkLevel1()"<<endl; |
455 |
// Cluster = new TClonesArray("TrkCluster"); |
456 |
Cluster = 0; |
457 |
for(Int_t i=0; i<12 ; i++){ |
458 |
good[i] = -1; |
459 |
for(Int_t j=0; j<24 ; j++){ |
460 |
cn[j][i]=0; |
461 |
cnn[j][i]=0; |
462 |
}; |
463 |
}; |
464 |
TrkParams::SetTrackingMode(); |
465 |
TrkParams::SetPrecisionFactor(); |
466 |
TrkParams::SetStepMin(); |
467 |
TrkParams::SetPFA(); |
468 |
} |
469 |
//-------------------------------------- |
470 |
// |
471 |
// |
472 |
//-------------------------------------- |
473 |
void TrkLevel1::Set(){ |
474 |
if(!Cluster)Cluster = new TClonesArray("TrkCluster"); |
475 |
} |
476 |
//-------------------------------------- |
477 |
// |
478 |
// |
479 |
//-------------------------------------- |
480 |
void TrkLevel1::Dump(){ |
481 |
|
482 |
cout<<"DSP status: "; |
483 |
for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" "; |
484 |
cout<<endl; |
485 |
cout<<"VA1 mask : "<<endl; |
486 |
for(Int_t i=0; i<12 ; i++){ |
487 |
for(Int_t ii=0; ii<24 ; ii++){ |
488 |
Int_t mask = cnn[ii][i]; |
489 |
if(mask>0)mask=1; |
490 |
cout<<mask<<" "; |
491 |
} |
492 |
cout <<endl; |
493 |
} |
494 |
|
495 |
if(!Cluster)return; |
496 |
TClonesArray &t = *Cluster; |
497 |
for(int i=0; i<this->nclstr(); i++) ((TrkCluster *)t[i])->Dump(); |
498 |
|
499 |
} |
500 |
/** |
501 |
* \brief Dump processing status |
502 |
*/ |
503 |
void TrkLevel1::StatusDump(int view){ |
504 |
cout << "DSP n. "<<view+1<<" (level1-)status: "<<hex<<showbase<<good[view]<<dec<<endl; |
505 |
}; |
506 |
/** |
507 |
* \brief Check event status |
508 |
* |
509 |
* Check the event status, according to a flag-mask given as input. |
510 |
* Return true if the view passes the check. |
511 |
* |
512 |
* @param view View number (0-11) |
513 |
* @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet, |
514 |
* no crc error, no software alarm) |
515 |
* |
516 |
* @see TrkLevel2 class definition to know how the status flag is defined |
517 |
* |
518 |
*/ |
519 |
Bool_t TrkLevel1::StatusCheck(int view, int flagmask){ |
520 |
|
521 |
if( view<0 || view >= 12)return false; |
522 |
return !(good[view]&flagmask); |
523 |
|
524 |
}; |
525 |
|
526 |
|
527 |
//-------------------------------------- |
528 |
// |
529 |
// |
530 |
//-------------------------------------- |
531 |
/** |
532 |
* Fills a TrkLevel1 object with values from a struct cTrkLevel1 (to get data from F77 common). |
533 |
*/ |
534 |
void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){ |
535 |
|
536 |
// cout << "void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full)"<<endl; |
537 |
|
538 |
Clear(); |
539 |
// --------------- |
540 |
// *** CLUSTER *** |
541 |
// --------------- |
542 |
TrkCluster* t_cl = new TrkCluster(); |
543 |
if(!Cluster)Cluster = new TClonesArray("TrkCluster"); |
544 |
TClonesArray &t = *Cluster; |
545 |
for(int i=0; i<l1->nclstr1; i++){ |
546 |
|
547 |
t_cl->Clear(); |
548 |
// if( full || (!full && l1->whichtrack[i]) ){ |
549 |
|
550 |
t_cl->view = l1->view[i]; |
551 |
t_cl->maxs = l1->maxs[i]; |
552 |
|
553 |
if( full || (!full && l1->whichtrack[i]) ){ |
554 |
t_cl->indmax = l1->indmax[i] - l1->indstart[i]; |
555 |
Int_t from = l1->indstart[i] -1; |
556 |
Int_t to = l1->totCLlength ; |
557 |
if(i != l1->nclstr1-1)to = l1->indstart[i+1] -1 ; |
558 |
t_cl->CLlength = to - from ; |
559 |
|
560 |
t_cl->clsignal = new Float_t[t_cl->CLlength]; |
561 |
t_cl->clsigma = new Float_t[t_cl->CLlength]; |
562 |
t_cl->cladc = new Int_t[t_cl->CLlength]; |
563 |
t_cl->clbad = new Bool_t[t_cl->CLlength]; |
564 |
|
565 |
Int_t index = 0; |
566 |
for(Int_t is = from; is < to; is++ ){ |
567 |
t_cl->clsignal[index] = (Float_t) l1->clsignal[is]; |
568 |
t_cl->clsigma[index] = (Float_t) l1->clsigma[is]; |
569 |
t_cl->cladc[index] = (Int_t) l1->cladc[is]; |
570 |
t_cl->clbad[index] = (Bool_t) l1->clbad[is]; |
571 |
index++; |
572 |
}; |
573 |
} |
574 |
new(t[i]) TrkCluster(*t_cl); // <<< store cluster |
575 |
}; |
576 |
|
577 |
delete t_cl; |
578 |
|
579 |
// ------------------------- |
580 |
// ****general variables**** |
581 |
// ------------------------- |
582 |
for(Int_t i=0; i<12 ; i++){ |
583 |
good[i] = l1->good[i]; |
584 |
for(Int_t j=0; j<24 ; j++){ |
585 |
cn[j][i] = l1->cnev[j][i]; |
586 |
// cnrms[j][i] = l1->cnrmsev[j][i]; |
587 |
cnn[j][i] = l1->cnnev[j][i]; |
588 |
}; |
589 |
}; |
590 |
|
591 |
} |
592 |
/** |
593 |
* Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common). |
594 |
*/ |
595 |
|
596 |
void TrkLevel1::GetLevel1Struct(cTrkLevel1* l1) { |
597 |
|
598 |
// cTrkLevel1* l1 = &level1event_ ; |
599 |
|
600 |
for(Int_t i=0; i<12 ; i++){ |
601 |
l1->good[i] = good[i]; |
602 |
for(Int_t j=0; j<24 ; j++){ |
603 |
l1->cnev[j][i] = cn[j][i] ; |
604 |
l1->cnnev[j][i] = cnn[j][i] ; |
605 |
l1->cnrmsev[j][i] = 0. ; |
606 |
}; |
607 |
l1->fshower[i] = 0; |
608 |
}; |
609 |
|
610 |
l1->nclstr1=0; |
611 |
l1->totCLlength=0; |
612 |
Int_t index=0; |
613 |
if(Cluster){ |
614 |
Int_t i=0; |
615 |
for(Int_t ii=0;ii<Cluster->GetEntries();ii++){ |
616 |
TrkCluster *clu = GetCluster(ii); |
617 |
// ---------------------------------------- |
618 |
// attenzione!! |
619 |
// se il cluster non e` salvato (view = 0) |
620 |
// DEVE essere escluso dal common F77 |
621 |
// ---------------------------------------- |
622 |
if(clu->view != 0 ){ |
623 |
l1->view[i] = clu->view; |
624 |
l1->ladder[i] = clu->GetLadder(); |
625 |
l1->maxs[i] = clu->maxs; |
626 |
l1->mult[i] = clu->GetMultiplicity(); |
627 |
l1->dedx[i] = clu->GetSignal(); |
628 |
l1->indstart[i] = index+1; |
629 |
l1->indmax[i] = l1->indstart[i] + clu->indmax; |
630 |
l1->totCLlength += clu->CLlength; |
631 |
for(Int_t iw=0; iw < clu->CLlength; iw++){ |
632 |
l1->clsignal[index] = clu->clsignal[iw]; |
633 |
l1->clsigma[index] = clu->clsigma[iw]; |
634 |
l1->cladc[index] = clu->cladc[iw]; |
635 |
l1->clbad[index] = clu->clbad[iw]; |
636 |
index++; |
637 |
} |
638 |
i++; |
639 |
} |
640 |
} |
641 |
l1->nclstr1 = i; |
642 |
} |
643 |
|
644 |
// return l1; |
645 |
} |
646 |
//-------------------------------------- |
647 |
// |
648 |
// |
649 |
//-------------------------------------- |
650 |
void TrkLevel1::Clear(){ |
651 |
|
652 |
for(Int_t i=0; i<12 ; i++){ |
653 |
good[i] = -1; |
654 |
for(Int_t j=0; j<24 ; j++){ |
655 |
cn[j][i] = 0; |
656 |
cnn[j][i] = 0; |
657 |
}; |
658 |
}; |
659 |
// if(Cluster)Cluster->Clear("C"); |
660 |
if(Cluster)Cluster->Delete(); |
661 |
|
662 |
} |
663 |
//-------------------------------------- |
664 |
// |
665 |
// |
666 |
//-------------------------------------- |
667 |
void TrkLevel1::Delete(){ |
668 |
|
669 |
// Clear(); |
670 |
if(Cluster)Cluster->Delete(); |
671 |
if(Cluster)delete Cluster; |
672 |
|
673 |
} |
674 |
//-------------------------------------- |
675 |
// |
676 |
// |
677 |
//-------------------------------------- |
678 |
TrkCluster *TrkLevel1::GetCluster(int is){ |
679 |
|
680 |
if(!Cluster)return 0; |
681 |
if(is >= nclstr()){ |
682 |
cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl; |
683 |
cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl; |
684 |
return 0; |
685 |
} |
686 |
|
687 |
TClonesArray &t = *(Cluster); |
688 |
TrkCluster *cluster = (TrkCluster*)t[is]; |
689 |
return cluster; |
690 |
} |
691 |
//-------------------------------------- |
692 |
// |
693 |
// |
694 |
//-------------------------------------- |
695 |
// /** |
696 |
// * Load Position-Finding-Algorythm parameters (call the F77 routine). |
697 |
// * |
698 |
// */ |
699 |
// int TrkLevel1::LoadPfaParam(TString path){ |
700 |
|
701 |
// if( path.IsNull() ){ |
702 |
// path = gSystem->Getenv("PAM_CALIB"); |
703 |
// if(path.IsNull()){ |
704 |
// cout << " TrkLevel1::LoadPfaParam() ==> No PAMELA environment variables defined "<<endl; |
705 |
// return 0; |
706 |
// } |
707 |
// path.Append("/trk-param/eta_param-0/"); |
708 |
// } |
709 |
|
710 |
// strcpy(path_.path,path.Data()); |
711 |
// path_.pathlen = path.Length(); |
712 |
// path_.error = 0; |
713 |
// cout <<"Loading p.f.a. parameters: "<<path<<endl; |
714 |
// return readetaparam_(); |
715 |
// } |
716 |
|
717 |
// /** |
718 |
// * Load magnetic field parameters (call the F77 routine). |
719 |
// * |
720 |
// */ |
721 |
// int TrkLevel1::LoadFieldParam(TString path){ |
722 |
|
723 |
// // if( strcmp(path_.path,path.Data()) ){ |
724 |
// if( path.IsNull() ){ |
725 |
// path = gSystem->Getenv("PAM_CALIB"); |
726 |
// if(path.IsNull()){ |
727 |
// cout << " TrkLevel1::LoadFieldParam() ==> No PAMELA environment variables defined "<<endl; |
728 |
// return 0; |
729 |
// } |
730 |
// path.Append("/trk-param/field_param-0/"); |
731 |
// } |
732 |
// cout <<"Loading magnetic field "<<path<<endl; |
733 |
// strcpy(path_.path,path.Data()); |
734 |
// path_.pathlen = path.Length(); |
735 |
// path_.error = 0; |
736 |
// return readb_(); |
737 |
// // } |
738 |
// // return 0; |
739 |
// } |
740 |
// /** |
741 |
// * Load magnetic field parameters (call the F77 routine). |
742 |
// * |
743 |
// */ |
744 |
// int TrkLevel1::LoadChargeParam(TString path){ |
745 |
|
746 |
// // if( strcmp(path_.path,path.Data()) ){ |
747 |
// if( path.IsNull() ){ |
748 |
// path = gSystem->Getenv("PAM_CALIB"); |
749 |
// if(path.IsNull()){ |
750 |
// cout << " TrkLevel1::LoadChargeParam() ==> No PAMELA environment variables defined "<<endl; |
751 |
// return 0; |
752 |
// } |
753 |
// path.Append("/trk-param/charge_param-1/"); |
754 |
// } |
755 |
// cout <<"Loading charge-correlation parameters: "<<path<<endl; |
756 |
// strcpy(path_.path,path.Data()); |
757 |
// path_.pathlen = path.Length(); |
758 |
// path_.error = 0; |
759 |
// return readchargeparam_(); |
760 |
// // } |
761 |
// // return 0; |
762 |
// } |
763 |
// /** |
764 |
// * Load magnetic field parameters (call the F77 routine). |
765 |
// * |
766 |
// */ |
767 |
// int TrkLevel1::LoadAlignmentParam(TString path){ |
768 |
|
769 |
// // if( strcmp(path_.path,path.Data()) ){ |
770 |
// if( path.IsNull() ){ |
771 |
// path = gSystem->Getenv("PAM_CALIB"); |
772 |
// if(path.IsNull()){ |
773 |
// cout << " TrkLevel1::LoadAlignmentParam() ==> No PAMELA environment variables defined "<<endl; |
774 |
// return 0; |
775 |
// } |
776 |
// path.Append("/trk-param/align_param-0/"); |
777 |
// } |
778 |
// cout <<"Loading alignment parameters: "<<path<<endl; |
779 |
// strcpy(path_.path,path.Data()); |
780 |
// path_.pathlen = path.Length(); |
781 |
// path_.error = 0; |
782 |
// return readalignparam_(); |
783 |
// // } |
784 |
// // return 0; |
785 |
// } |
786 |
// /** |
787 |
// * Load magnetic field parameters (call the F77 routine). |
788 |
// * |
789 |
// */ |
790 |
// int TrkLevel1::LoadMipParam(TString path){ |
791 |
|
792 |
// // if( strcmp(path_.path,path.Data()) ){ |
793 |
// if( path.IsNull() ){ |
794 |
// path = gSystem->Getenv("PAM_CALIB"); |
795 |
// if(path.IsNull()){ |
796 |
// cout << " TrkLevel1::LoadMipParam() ==> No PAMELA environment variables defined "<<endl; |
797 |
// return 0; |
798 |
// } |
799 |
// path.Append("/trk-param/mip_param-0/"); |
800 |
// } |
801 |
// cout <<"Loading ADC-to-MIP conversion parameters: "<<path<<endl; |
802 |
// strcpy(path_.path,path.Data()); |
803 |
// path_.pathlen = path.Length(); |
804 |
// path_.error = 0; |
805 |
// return readmipparam_(); |
806 |
// // } |
807 |
// // return 0; |
808 |
// } |
809 |
// /** |
810 |
// * Load magnetic field parameters (call the F77 routine). |
811 |
// * |
812 |
// */ |
813 |
// int TrkLevel1::LoadVKMaskParam(TString path){ |
814 |
|
815 |
// // if( strcmp(path_.path,path.Data()) ){ |
816 |
// if( path.IsNull() ){ |
817 |
// path = gSystem->Getenv("PAM_CALIB"); |
818 |
// if(path.IsNull()){ |
819 |
// cout << " TrkLevel1::LoadVKMaskParam() ==> No PAMELA environment variables defined "<<endl; |
820 |
// return 0; |
821 |
// } |
822 |
// path.Append("/trk-param/mask_param-1/"); |
823 |
// } |
824 |
// cout <<"Loading VK-mask parameters: "<<path<<endl; |
825 |
// strcpy(path_.path,path.Data()); |
826 |
// path_.pathlen = path.Length(); |
827 |
// path_.error = 0; |
828 |
// return readvkmask_(); |
829 |
// // } |
830 |
// // return 0; |
831 |
// } |
832 |
|
833 |
// /** |
834 |
// * Load all (default) parameters. Environment variable must be defined. |
835 |
// * |
836 |
// */ |
837 |
// int TrkLevel1::LoadParams(){ |
838 |
|
839 |
// int result=0; |
840 |
|
841 |
// result = result * LoadFieldParam(); |
842 |
// result = result * LoadPfaParam(); |
843 |
// result = result * LoadChargeParam(); |
844 |
// result = result * LoadAlignmentParam(); |
845 |
// result = result * LoadMipParam(); |
846 |
// result = result * LoadVKMaskParam(); |
847 |
|
848 |
// return result; |
849 |
// } |
850 |
|
851 |
|
852 |
|
853 |
int TrkLevel1::GetPfaNbinsAngle(){ |
854 |
TrkParams::Load(4); |
855 |
if( !TrkParams::IsLoaded(4) ){ |
856 |
cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters not loaded"<<endl; |
857 |
return 0; |
858 |
} |
859 |
return pfa_.nangbin; |
860 |
}; |
861 |
|
862 |
int TrkLevel1::GetPfaNbinsETA(){ |
863 |
TrkParams::Load(4); |
864 |
if( !TrkParams::IsLoaded(4) ){ |
865 |
cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters not loaded"<<endl; |
866 |
return 0; |
867 |
} |
868 |
return pfa_.netaval; |
869 |
}; |
870 |
|
871 |
/** |
872 |
* |
873 |
* |
874 |
*/ |
875 |
float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){ |
876 |
|
877 |
TrkParams::Load(4); |
878 |
if( !TrkParams::IsLoaded(4) ){ |
879 |
cout << "float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
880 |
return 0; |
881 |
} |
882 |
|
883 |
int nbins = GetPfaNbinsETA(); |
884 |
if(!nbins)return 0; |
885 |
|
886 |
float *fcorr = new float [nbins]; |
887 |
|
888 |
if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ |
889 |
for(int ib=0; ib<nbins; ib++){ |
890 |
fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib]; |
891 |
cout << pfa_.eta2[nang][ib] << " - " << pfa_.feta2[nang][nladder][nview][ib]<<endl;; |
892 |
} |
893 |
}else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ |
894 |
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib]; |
895 |
}else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ |
896 |
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib]; |
897 |
}else{ |
898 |
cout << pfa<<" pfa parameters not implemented "<<endl; |
899 |
return 0; |
900 |
} |
901 |
|
902 |
return fcorr; |
903 |
|
904 |
}; |
905 |
|
906 |
float* TrkLevel1::GetPfaAbs(TString pfa, int nang){ |
907 |
|
908 |
TrkParams::Load(4); |
909 |
if( !TrkParams::IsLoaded(4) ){ |
910 |
cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
911 |
return 0; |
912 |
} |
913 |
|
914 |
int nbins = GetPfaNbinsETA(); |
915 |
if(!nbins)return 0; |
916 |
|
917 |
float *fcorr = new float [nbins]; |
918 |
|
919 |
if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ |
920 |
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib]; |
921 |
}else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ |
922 |
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib]; |
923 |
}else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ |
924 |
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib]; |
925 |
}else{ |
926 |
cout << pfa<<" pfa parameters not implemented "<<endl; |
927 |
return 0; |
928 |
} |
929 |
|
930 |
return fcorr; |
931 |
|
932 |
}; |
933 |
|
934 |
/** |
935 |
* Method to call the F77 routine that performs level1->level2 processing. |
936 |
* The level2 output is stored in a common block, which can be retrieved |
937 |
* by mean of the method TrkLevel2::SetFromLevel2Struct(). |
938 |
* NB If the TrkLevel1 object is readout from a tree, and the |
939 |
* TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention |
940 |
* should be payed to the fact that single clusters (clusters not associated |
941 |
* with any track) might not be stored. Full reprocessing should be done starting |
942 |
* from level0 data. |
943 |
*/ |
944 |
//int TrkLevel1::ProcessEvent(int pfa){ |
945 |
int TrkLevel1::ProcessEvent(){ |
946 |
|
947 |
// cout << "int TrkLevel1::ProcessEvent()" << endl; |
948 |
TrkParams::Load( ); |
949 |
if( !TrkParams::IsLoaded() )return 0; |
950 |
|
951 |
GetLevel1Struct(); |
952 |
|
953 |
// analysisflight_(&pfa); |
954 |
// TrkParams::SetPFA(pfa); |
955 |
analysisflight_(); |
956 |
|
957 |
return 1; |
958 |
|
959 |
} |
960 |
|
961 |
|
962 |
ClassImp(TrkLevel1); |
963 |
ClassImp(TrkCluster); |