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