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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by pam-fi, Wed Oct 11 06:53:01 2006 UTC revision 1.20 by pam-fi, Mon Aug 20 15:47:57 2007 UTC
# Line 11  using namespace std; Line 11  using namespace std;
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  //--------------------------------------  //--------------------------------------
# Line 24  extern "C" { Line 24  extern "C" {
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  //--------------------------------------  //--------------------------------------
# Line 74  TrkCluster::TrkCluster(const TrkCluster& Line 90  TrkCluster::TrkCluster(const TrkCluster&
90  //  //
91  //--------------------------------------  //--------------------------------------
92  /**  /**
93   * Evaluate the cluster signal including all adjacent strip with a significant signal ( s > cut*sigma ).   * Evaluate the cluster signal including a maximum number of adjacent
94   * @param cut Inclusion cut.   * 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   */   */
99  Float_t TrkCluster::GetSignal(Float_t cut){  Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut){
100          Float_t s = 0;      
101          for(Int_t is = 0; is < CLlength; is++){      if(CLlength<=0)return 0;
102                  Float_t scut = cut*clsigma[is];  
103                  if(clsignal[is] > scut) s += clsignal[is];      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          };          };
120          return s;          return s;
121        };
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  };  };
151    
152    
153  /**  /**
154   * Evaluate the cluster signal 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.
156     * @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   */   */
160  Float_t TrkCluster::GetSignal(Int_t nstrip){  Float_t TrkCluster::GetSignalToNoise(Int_t nstrip, Float_t cut){
161                    
162          Float_t s = 0;      if(CLlength<=0)return 0;
163          Int_t il = indmax;  
164          Int_t ir = indmax;      Float_t sn = 0;
165          Int_t inc = 0;      
166                if( nstrip<=0 ){
167          while ( inc<nstrip ){          for(Int_t is = indmax+1; is < CLlength; is++){
168                  Float_t sl = 0;              Float_t scut = cut*clsigma[is];
169                  Float_t sr = 0;              if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is];
170                  if( il >= 0       ) sl = clsignal[il];              else break;
171                  if( ir < CLlength ) sr = clsignal[ir];          };
172                  if( sl == sr && inc == 0 ){          for(Int_t is = indmax; is >=0; is--){
173                          s += clsignal[il];              Float_t scut = cut*clsigma[is];
174                          il--;              if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is];
175                          ir++;              else break;
                 }else if ( sl >= sr && sl>0 && inc !=0){  
                         s += sl;  
                         il--;  
                 }else if ( sl < sr && sr>0 ){  
                         s += sr;  
                         ir++;  
                 }else break;  
                   
                 inc++;  
         }  
         return s;  
 };  
 /**  
  * Evaluate the cluster signal-to-noise, as defined by Turchetta, including all adjacent strip with a significant signal ( s > cut*sigma ).  
  * @param cut Inclusion cut.  
  */  
 Float_t TrkCluster::GetSignalToNoise(Float_t cut){  
         Float_t sn = 0;  
         for(Int_t is = 0; is < CLlength; is++){  
                 Float_t scut = cut*clsigma[is];  
                 if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is];  
176          };          };
177          return sn;          return sn;
178  };      };
179  /**      
180   * Evaluate the cluster signal-to-noise, as defined by Turchetta, including a ( maximum ) fixed number of adjacent strips (with s>0) around the maxs.      
181   * @param nstrip Number of strips.      Int_t il = indmax;
182   */      Int_t ir = indmax;
183  Float_t TrkCluster::GetSignalToNoise(Int_t nstrip){      Int_t inc = 0;
184            
185          Float_t sn = 0;      if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;
186          Int_t il = indmax;  
187          Int_t ir = indmax;      while ( inc < nstrip ){
188          Int_t inc = 0;          Float_t sl = -100000;
189                    Float_t sr = -100000;
190          while ( inc<nstrip ){          if( il >= 0       ) sl = clsignal[il];
191                  Float_t sl = 0;          if( ir < CLlength ) sr = clsignal[ir];
192                  Float_t sr = 0;          if( sl == sr && inc == 0 ){
193                  if( il >= 0       ) sl = clsignal[il];              sn += clsignal[il]/clsigma[il];
194                  if( ir < CLlength ) sr = clsignal[ir];              il--;
195                  if( sl == sr && inc == 0 ){              ir++;
196                          sn += clsignal[il]/clsigma[is];          }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){
197                          il--;              sn += sl/clsigma[il];
198                          ir++;              il--;
199                  }else if ( sl >= sr && sl>0 && inc !=0){          }else if ( sl < sr && sr > cut*clsigma[ir] ){
200                          sn += sl/clsigma[il];              sn += sr/clsigma[ir];
201                          il--;              ir++;
202                  }else if ( sl < sr && sr>0 ){          }else break;
203                          sn += sr/clsigma[ir];          
204                          ir++;          inc++;
205                  }else break;      }
206                        return sn;
                 inc++;  
         }  
         return sn;  
207  };  };
208  /**  /**
209   * Evaluate the cluster multiplicity.   * Evaluate the cluster multiplicity.
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-1 && il == 0)break;
243          };          else if (ir == CLlength-1 && il != 0)il--;
244                    else if (ir != CLlength-1 && 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-1 && il == 0)break;
268            else if (ir == CLlength-1 && il != 0)il--;
269            else if (ir != CLlength-1 && 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()<<endl;
295          cout <<endl<< "Strip signals       ";      cout << "COG                 "<< GetCOG(0)<<endl;;
296          for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];      cout << "Strip signals       ";
297          cout <<endl<< "Strip sigmas        ";      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];
298          for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];      cout <<endl<< "Strip sigmas        ";
299          cout <<endl<< "Strip ADC           ";      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];
300          for(Int_t i =0; i<CLlength; i++)cout << " " <<cladc[i];      cout <<endl<< "Strip ADC           ";
301          cout <<endl<< "Strip BAD           ";      for(Int_t i =0; i<CLlength; i++)cout << " " <<cladc[i];
302          for(Int_t i =0; i<CLlength; i++){      cout <<endl<< "Strip BAD           ";
303                  if(i==indmax)cout << "  *" <<clbad[i]<<"*";      for(Int_t i =0; i<CLlength; i++){
304                  else cout << " " <<clbad[i];          if(i==indmax)cout << "  *" <<clbad[i]<<"*";
305          }          else cout << " " <<clbad[i];
306          cout << endl;      }
307        cout << endl;
308                    
309  }  }
310  //--------------------------------------  //--------------------------------------
# Line 242  void TrkCluster::Dump(){ Line 314  void TrkCluster::Dump(){
314  /**  /**
315   * 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).
316   */   */
317  cTrkLevel1* TrkCluster::GetLevel1Struct(){  void TrkCluster::GetLevel1Struct(cTrkLevel1* l1){
318                                    
319          cTrkLevel1* l1 = new cTrkLevel1;  //    cTrkLevel1* l1 = new cTrkLevel1;
320            
321          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];  
         };  
322                    
323          return l1;      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    //    return l1;
340  };  };
341  //--------------------------------------  //--------------------------------------
342  //  //
# Line 276  cTrkLevel1* TrkCluster::GetLevel1Struct( Line 350  cTrkLevel1* TrkCluster::GetLevel1Struct(
350   */   */
351  Float_t TrkCluster::GetCOG(Int_t ncog){  Float_t TrkCluster::GetCOG(Int_t ncog){
352                    
353          int ic = 1;      int ic = 1;
354          level1event_ = *GetLevel1Struct();      GetLevel1Struct();
355          return cog_(&ncog,&ic);      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            if( fabs(angle) <= 10. ){
375                neta = 2;
376            }else if( fabs(angle) > 10. && fabs(angle) <= 15. ){
377                neta = 3;
378            }else{
379                neta = 4;
380            };
381        };
382    
383        return GetCOG(neta);
384                    
385  };  };
386  //--------------------------------------  //--------------------------------------
# Line 293  Float_t TrkCluster::GetCOG(Int_t ncog){ Line 395  Float_t TrkCluster::GetCOG(Int_t ncog){
395   */   */
396  Float_t TrkCluster::GetETA(Int_t neta, float angle){  Float_t TrkCluster::GetETA(Int_t neta, float angle){
397                    
398    //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;
399  //      LoadPfaParam();  //      LoadPfaParam();
400          int ic = 1;  
401          level1event_ = *GetLevel1Struct();      TrkParams::Load(4);
402          if(neta == 0)      return pfaeta_(&ic,&angle);      if( !TrkParams::IsLoaded(4) ){
403          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";  
404          return 0;          return 0;
405                }
406    
407        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  };  };
418    
419  //--------------------------------------  //--------------------------------------
# Line 310  Float_t TrkCluster::GetETA(Int_t neta, f Line 421  Float_t TrkCluster::GetETA(Int_t neta, f
421  //  //
422  //--------------------------------------  //--------------------------------------
423  TrkLevel1::TrkLevel1(){  TrkLevel1::TrkLevel1(){
424                
425  //      good1 = -1;  //    cout << "TrkLevel1::TrkLevel1()"<<endl;
426            //    Cluster = new TClonesArray("TrkCluster");
427          Cluster = new TClonesArray("TrkCluster");      Cluster = 0;
428                for(Int_t i=0; i<12 ; i++){
429          for(Int_t i=0; i<12 ; i++){          good[i] = -1;
430  //              crc[i] = -1;          for(Int_t j=0; j<24 ; j++){
431                  good[i] = -1;              cn[j][i]=0;
432                  for(Int_t j=0; j<24 ; j++){              cnn[j][i]=0;
433                          cnev[j][i]=0;          };
434                          cnnev[j][i]=0;      };
435                  };      TrkParams::SetTrackingMode();
436  //              fshower[i]=0;      TrkParams::SetPrecisionFactor();
437          };      TrkParams::SetStepMin();
438        TrkParams::SetPFA();
439    }
440    //--------------------------------------
441    //
442    //
443    //--------------------------------------
444    void TrkLevel1::Set(){
445        if(!Cluster)Cluster = new TClonesArray("TrkCluster");
446  }  }
447  //--------------------------------------  //--------------------------------------
448  //  //
# Line 331  TrkLevel1::TrkLevel1(){ Line 450  TrkLevel1::TrkLevel1(){
450  //--------------------------------------  //--------------------------------------
451  void TrkLevel1::Dump(){  void TrkLevel1::Dump(){
452            
453          cout<<"DSP status: ";      cout<<"DSP status: ";
454          for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" ";      for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" ";
455          cout<<endl;      cout<<endl;
456                cout<<"VA1 mask : "<<endl;
457          TClonesArray &t  = *Cluster;      for(Int_t i=0; i<12 ; i++){
458          for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();          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        
466        if(!Cluster)return;
467        TClonesArray &t  = *Cluster;
468        for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();
469        
470  }  }
471    /**
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  //--------------------------------------  //--------------------------------------
499  //  //
500  //  //
# Line 346  void TrkLevel1::Dump(){ Line 502  void TrkLevel1::Dump(){
502  /**  /**
503   * 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).
504   */   */
505  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;  
506    
507          //  ****general variables****  //    cout << "void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full)"<<endl;
508        
509          for(Int_t i=0; i<12 ; i++){      Clear();
510                  good[i] = -1;      //  ---------------
511                  for(Int_t j=0; j<24 ; j++){      //  *** CLUSTER ***
512                          cnev[j][i]     = l1->cnev[j][i];      //  ---------------
513                          cnnev[j][i] = l1->cnnev[j][i];      TrkCluster* t_cl = new TrkCluster();
514                  };      if(!Cluster)Cluster = new TClonesArray("TrkCluster");
515        TClonesArray &t = *Cluster;
516        for(int i=0; i<l1->nclstr1; i++){
517    
518            t_cl->Clear();
519    //      if( full || (!full && l1->whichtrack[i]) ){
520            
521            t_cl->view     = l1->view[i];
522            t_cl->maxs     = l1->maxs[i];
523    
524            if( full || (!full && l1->whichtrack[i]) ){
525                t_cl->indmax   = l1->indmax[i] - l1->indstart[i];      
526                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    
536                Int_t index = 0;
537                for(Int_t is = from; is < to; is++ ){
538                    t_cl->clsignal[index] = (Float_t) l1->clsignal[is];
539                    t_cl->clsigma[index]  = (Float_t) l1->clsigma[is];
540                    t_cl->cladc[index]    = (Int_t)   l1->cladc[is];
541                    t_cl->clbad[index]    = (Bool_t)  l1->clbad[is];
542                    index++;
543                };
544            }
545            new(t[i]) TrkCluster(*t_cl); // <<< store cluster
546        };
547        
548        delete t_cl;
549        
550        //  -------------------------
551        //  ****general variables****
552        //  -------------------------    
553        for(Int_t i=0; i<12 ; i++){
554            good[i] = l1->good[i];
555            for(Int_t j=0; j<24 ; j++){
556                cn[j][i]     = l1->cnev[j][i];
557    //          cnrms[j][i]  = l1->cnrmsev[j][i];
558                cnn[j][i]    = l1->cnnev[j][i];
559          };          };
560                };
561        
562  }  }
563  /**  /**
564   * 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).
565   */   */
566    
567  cTrkLevel1* TrkLevel1::GetLevel1Struct() {  void TrkLevel1::GetLevel1Struct(cTrkLevel1* l1) {
568            
569          cTrkLevel1 *l1=0;  //    cTrkLevel1* l1 = &level1event_ ;
570          //      
571          for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
572                  l1->good[i] = good[i];          l1->good[i] = good[i];
573                  for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
574                          l1->cnev[j][i]  = cnev[j][i];              l1->cnev[j][i]    = cn[j][i]  ;
575                          l1->cnnev[j][i] = cnnev[j][i];              l1->cnnev[j][i]   = cnn[j][i] ;
576                  };              l1->cnrmsev[j][i] = 0. ;
577          };          };
578                    l1->fshower[i] = 0;
579  //  *** CLUSTERS ***      };
580      l1->nclstr1 =  Cluster->GetEntries();  
581          for(Int_t i=0;i<l1->nclstr1;i++){      l1->nclstr1=0;
582        l1->totCLlength=0;
583                  l1->view[i]     = ((TrkCluster *)Cluster->At(i))->view;      Int_t index=0;
584                  l1->maxs[i]     = ((TrkCluster *)Cluster->At(i))->maxs;      if(Cluster){
585                  // COMPLETARE //          Int_t i=0;
586                  // COMPLETARE //          for(Int_t ii=0;ii<Cluster->GetEntries();ii++){
587                  // COMPLETARE //              TrkCluster *clu = GetCluster(ii);
588                  // COMPLETARE //              // ----------------------------------------
589                  // COMPLETARE //              // attenzione!!
590                  // COMPLETARE //              // se il cluster non e` salvato (view = 0)
591                                // DEVE essere escluso dal common F77
592                // ----------------------------------------
593                if(clu->view != 0 ){
594                    l1->view[i]     = clu->view;
595                    l1->ladder[i]   = clu->GetLadder();
596                    l1->maxs[i]     = clu->maxs;
597                    l1->mult[i]     = clu->GetMultiplicity();
598                    l1->dedx[i]     = clu->GetSignal();
599                    l1->indstart[i] = index+1;
600                    l1->indmax[i]   = l1->indstart[i] + clu->indmax;
601                    l1->totCLlength += clu->CLlength;
602                    for(Int_t iw=0; iw < clu->CLlength; iw++){
603                        l1->clsignal[index] = clu->clsignal[iw];
604                        l1->clsigma[index]  = clu->clsigma[iw];
605                        l1->cladc[index]    = clu->cladc[iw];
606                        l1->clbad[index]    = clu->clbad[iw];
607                        index++;
608                    }
609                    i++;
610                }
611          }          }
612          // COMPLETARE //          l1->nclstr1 =  i;      
613          // COMPLETARE //      }
614          // COMPLETARE //  
615          // COMPLETARE //  //    return l1;
         // COMPLETARE //  
         // COMPLETARE //  
         return l1;  
616  }  }
617  //--------------------------------------  //--------------------------------------
618  //  //
619  //  //
620  //--------------------------------------  //--------------------------------------
621  void TrkLevel1::Clear(){  void TrkLevel1::Clear(){
622                
623          for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
624                  good[i] = -1;          good[i] = -1;
625                  for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
626                          cnev[j][i]     = 0;              cn[j][i]    = 0;
627                          cnnev[j][i] = 0;              cnn[j][i]   = 0;
628                  };          };
629          };      };
630          //  //    if(Cluster)Cluster->Clear("C");
631          Cluster->Clear();      if(Cluster)Cluster->Delete();
632        
633  }  }
634  //--------------------------------------  //--------------------------------------
635  //  //
636  //  //
637  //--------------------------------------  //--------------------------------------
638  void TrkLevel1::Delete(){  void TrkLevel1::Delete(){
639                
640          for(Int_t i=0; i<12 ; i++){  //    Clear();
641                  good[i] = -1;      if(Cluster)Cluster->Delete();
642                  for(Int_t j=0; j<24 ; j++){      if(Cluster)delete Cluster;
643                          cnev[j][i]     = 0;      
                         cnnev[j][i] = 0;  
                 };  
         };  
         //  
         Cluster->Delete();  
   
644  }  }
   
645  //--------------------------------------  //--------------------------------------
646  //  //
647  //  //
648  //--------------------------------------  //--------------------------------------
649  TrkCluster *TrkLevel1::GetCluster(int is){  TrkCluster *TrkLevel1::GetCluster(int is){
650    
651          if(is >= this->nclstr()){      if(!Cluster)return 0;
652                  cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl;      if(is >= nclstr()){
653                  cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl;          cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl;
654                  return 0;          cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl;
655          }          return 0;
656          TClonesArray &t = *(Cluster);      }
657          TrkCluster *cluster = (TrkCluster*)t[is];      
658          return cluster;      TClonesArray &t = *(Cluster);
659        TrkCluster *cluster = (TrkCluster*)t[is];
660        return cluster;
661  }  }
662  //--------------------------------------  //--------------------------------------
663  //  //
664  //  //
665  //--------------------------------------  //--------------------------------------
666    // /**
667    //  * Load Position-Finding-Algorythm parameters (call the F77 routine).
668    //  *
669    //  */
670    // int TrkLevel1::LoadPfaParam(TString path){
671            
672    //     if( path.IsNull() ){
673    //      path = gSystem->Getenv("PAM_CALIB");
674    //      if(path.IsNull()){
675    //          cout << " TrkLevel1::LoadPfaParam() ==> No PAMELA environment variables defined "<<endl;
676    //          return 0;
677    //      }
678    //      path.Append("/trk-param/eta_param-0/");
679    //     }
680    
681    //     strcpy(path_.path,path.Data());
682    //     path_.pathlen = path.Length();
683    //     path_.error   = 0;
684    //     cout <<"Loading p.f.a. parameters: "<<path<<endl;
685    //     return readetaparam_();
686    // }
687    
688    // /**
689    //  * Load magnetic field parameters (call the F77 routine).
690    //  *
691    //  */
692    // int TrkLevel1::LoadFieldParam(TString path){
693            
694    // //    if( strcmp(path_.path,path.Data()) ){
695    //     if( path.IsNull() ){
696    //      path = gSystem->Getenv("PAM_CALIB");
697    //      if(path.IsNull()){
698    //          cout << " TrkLevel1::LoadFieldParam() ==> No PAMELA environment variables defined "<<endl;
699    //          return 0;
700    //      }
701    //      path.Append("/trk-param/field_param-0/");
702    //     }
703    //     cout <<"Loading magnetic field "<<path<<endl;
704    //     strcpy(path_.path,path.Data());
705    //     path_.pathlen = path.Length();
706    //     path_.error   = 0;
707    //     return readb_();
708    // //    }      
709    // //    return 0;
710    // }
711    // /**
712    //  * Load magnetic field parameters (call the F77 routine).
713    //  *
714    //  */
715    // int TrkLevel1::LoadChargeParam(TString path){
716            
717    // //    if( strcmp(path_.path,path.Data()) ){
718    //     if( path.IsNull() ){
719    //      path = gSystem->Getenv("PAM_CALIB");
720    //      if(path.IsNull()){
721    //          cout << " TrkLevel1::LoadChargeParam() ==> No PAMELA environment variables defined "<<endl;
722    //          return 0;
723    //      }
724    //      path.Append("/trk-param/charge_param-1/");
725    //     }
726    //     cout <<"Loading charge-correlation parameters: "<<path<<endl;
727    //     strcpy(path_.path,path.Data());
728    //     path_.pathlen = path.Length();
729    //     path_.error   = 0;
730    //     return readchargeparam_();
731    // //    }      
732    // //    return 0;
733    // }
734    // /**
735    //  * Load magnetic field parameters (call the F77 routine).
736    //  *
737    //  */
738    // int TrkLevel1::LoadAlignmentParam(TString path){
739            
740    // //    if( strcmp(path_.path,path.Data()) ){
741    //     if( path.IsNull() ){
742    //      path = gSystem->Getenv("PAM_CALIB");
743    //      if(path.IsNull()){
744    //          cout << " TrkLevel1::LoadAlignmentParam() ==> No PAMELA environment variables defined "<<endl;
745    //          return 0;
746    //      }
747    //      path.Append("/trk-param/align_param-0/");
748    //     }
749    //     cout <<"Loading alignment parameters: "<<path<<endl;
750    //     strcpy(path_.path,path.Data());
751    //     path_.pathlen = path.Length();
752    //     path_.error   = 0;
753    //     return readalignparam_();
754    // //    }      
755    // //    return 0;
756    // }
757    // /**
758    //  * Load magnetic field parameters (call the F77 routine).
759    //  *
760    //  */
761    // int TrkLevel1::LoadMipParam(TString path){
762            
763    // //    if( strcmp(path_.path,path.Data()) ){
764    //     if( path.IsNull() ){
765    //      path = gSystem->Getenv("PAM_CALIB");
766    //      if(path.IsNull()){
767    //          cout << " TrkLevel1::LoadMipParam() ==> No PAMELA environment variables defined "<<endl;
768    //          return 0;
769    //      }
770    //      path.Append("/trk-param/mip_param-0/");
771    //     }
772    //     cout <<"Loading ADC-to-MIP conversion parameters: "<<path<<endl;
773    //     strcpy(path_.path,path.Data());
774    //     path_.pathlen = path.Length();
775    //     path_.error   = 0;
776    //     return readmipparam_();
777    // //    }      
778    // //    return 0;
779    // }
780    // /**
781    //  * Load magnetic field parameters (call the F77 routine).
782    //  *
783    //  */
784    // int TrkLevel1::LoadVKMaskParam(TString path){
785            
786    // //    if( strcmp(path_.path,path.Data()) ){
787    //     if( path.IsNull() ){
788    //      path = gSystem->Getenv("PAM_CALIB");
789    //      if(path.IsNull()){
790    //          cout << " TrkLevel1::LoadVKMaskParam() ==> No PAMELA environment variables defined "<<endl;
791    //          return 0;
792    //      }
793    //      path.Append("/trk-param/mask_param-1/");
794    //     }
795    //     cout <<"Loading VK-mask parameters: "<<path<<endl;
796    //     strcpy(path_.path,path.Data());
797    //     path_.pathlen = path.Length();
798    //     path_.error   = 0;
799    //     return readvkmask_();
800    // //    }      
801    // //    return 0;
802    // }
803    
804    // /**
805    //  * Load all (default) parameters. Environment variable must be defined.
806    //  *
807    //  */
808    // int TrkLevel1::LoadParams(){
809    
810    //     int result=0;
811        
812    //     result = result * LoadFieldParam();
813    //     result = result * LoadPfaParam();
814    //     result = result * LoadChargeParam();
815    //     result = result * LoadAlignmentParam();
816    //     result = result * LoadMipParam();
817    //     result = result * LoadVKMaskParam();
818    
819    //     return result;
820    // }
821    
822    
823    
824    int TrkLevel1::GetPfaNbinsAngle(){
825        TrkParams::Load(4);
826        if( !TrkParams::IsLoaded(4) ){
827            cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
828            return 0;
829        }
830        return pfa_.nangbin;
831    };
832    
833    int TrkLevel1::GetPfaNbinsETA(){
834        TrkParams::Load(4);
835        if( !TrkParams::IsLoaded(4) ){
836            cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
837            return 0;
838        }
839        return pfa_.netaval;
840    };
841    
842  /**  /**
843   * Load Position-Finding-Algorythm parameters (call the F77 routine).   *
844   *   *
845   */   */
846  int TrkLevel1::LoadPfaParam(TString path){  float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){
847            
848          if( strcmp(path_.path,path.Data()) ){      TrkParams::Load(4);
849                  cout <<"Loading p.f.a. parameters\n";      if( !TrkParams::IsLoaded(4) ){
850                  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_();  
         }        
851          return 0;          return 0;
852        }
853      
854        int nbins = GetPfaNbinsETA();
855        if(!nbins)return 0;
856    
857        float *fcorr = new float [nbins];
858    
859        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
860            for(int ib=0; ib<nbins; ib++){
861                fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
862                cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
863            }
864        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
865            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
866        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
867            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
868        }else{
869            cout << pfa<<" pfa parameters not implemented "<<endl;
870            return 0;
871        }    
872    
873        return fcorr;
874    
875    };
876    
877    float* TrkLevel1::GetPfaAbs(TString pfa, int nang){
878      
879        TrkParams::Load(4);
880        if( !TrkParams::IsLoaded(4) ){
881            cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
882            return 0;
883        }
884    
885        int nbins = GetPfaNbinsETA();
886        if(!nbins)return 0;
887    
888        float *fcorr = new float [nbins];
889    
890        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
891            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
892        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
893            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
894        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
895            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
896        }else{
897            cout << pfa<<" pfa parameters not implemented "<<endl;
898            return 0;
899        }    
900    
901        return fcorr;
902    
903    };
904    
905    /**
906     * Method to call the F77 routine that performs level1->level2 processing.
907     * The level2 output is stored in a common block, which can be retrieved
908     * by mean of the method TrkLevel2::SetFromLevel2Struct().
909     * NB If the TrkLevel1 object is readout from a tree, and the
910     * TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention
911     * should be payed to the fact that single clusters (clusters not associated
912     * with any track) might not be stored. Full reprocessing should be done starting
913     * from level0 data.
914     */
915    //int TrkLevel1::ProcessEvent(int pfa){
916    int TrkLevel1::ProcessEvent(){
917    
918    //    cout << "int TrkLevel1::ProcessEvent()" << endl;
919        TrkParams::Load( );
920        if( !TrkParams::IsLoaded() )return 0;
921    
922        GetLevel1Struct();
923    
924    //    analysisflight_(&pfa);
925    //    TrkParams::SetPFA(pfa);
926        analysisflight_();
927    
928        return 1;
929    
930  }  }
931    
932    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.23