/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkLevel1.cpp
ViewVC logotype

Annotation of /DarthVader/TrackerLevel2/src/TrkLevel1.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (hide annotations) (download)
Tue Mar 12 11:02:03 2013 UTC (11 years, 8 months ago) by pam-fi
Branch: MAIN
Changes since 1.25: +16 -0 lines
Add digital position finding for saturated clusters.

Digital p.f. is now the default for saturated clusters. P.f. for non-saturated cluster is unmodified.

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

  ViewVC Help
Powered by ViewVC 1.1.23