/[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.18 - (hide annotations) (download)
Thu May 24 14:17:00 2007 UTC (17 years, 6 months ago) by pam-fi
Branch: MAIN
Changes since 1.17: +36 -8 lines
fixed small bug in TrkLevel1::IsBad(int) and TrkLevel1::IsSaturated(int)

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

  ViewVC Help
Powered by ViewVC 1.1.23