/[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.11 by pam-fi, Thu Jan 11 10:20:58 2007 UTC revision 1.23 by pam-fi, Fri Aug 31 14:56:51 2007 UTC
# Line 16  extern "C" { Line 16  extern "C" {
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        float pfaetal_(int*,float*);
20        int   npfastrips_(int*,float*);
21                    
22  }  }
23  //--------------------------------------  //--------------------------------------
# Line 94  void TrkCluster::Clear(){ Line 96  void TrkCluster::Clear(){
96   * strips, around maxs, having a significant signal.   * strips, around maxs, having a significant signal.
97   * @param nstrip   Maximum number of strips.   * @param nstrip   Maximum number of strips.
98   * @param cut      Inclusion cut ( s > cut*sigma ).   * @param cut      Inclusion cut ( s > cut*sigma ).
99     * @param force    Falg to force the PFA strip-inclusion pattern (nstrip>0)
100   * If nstrip<=0 only the inclusion cut is used to determine the cluster size.   * If nstrip<=0 only the inclusion cut is used to determine the cluster size.
101   */   */
102  Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut){  Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut, Bool_t force){
103            
104      if(CLlength<=0)return 0;      if(CLlength<=0)return 0;
105    
106      Float_t s = 0;      Float_t s = 0;
107            
108        //-----------------------------------
109        // inlcude strips with s > cut*sigma
110        //-----------------------------------
111    
112      if( nstrip<=0 ){      if( nstrip<=0 ){
113  //          for(Int_t is = 0; is < CLlength; is++){  //          for(Int_t is = 0; is < CLlength; is++){
114  //              Float_t scut = cut*clsigma[is];  //              Float_t scut = cut*clsigma[is];
# Line 120  Float_t TrkCluster::GetSignal(Int_t nstr Line 127  Float_t TrkCluster::GetSignal(Int_t nstr
127          return s;          return s;
128      };      };
129            
130        //---------------------------------------------------
131        // inlcude strips with s > cut*sigma, up to nstrip.
132        // strips are included in order of decreasing signal
133        //---------------------------------------------------
134        if( !force ){
135    
136            Int_t il = indmax;
137            Int_t ir = indmax;
138            Int_t inc = 0;
139            
140            if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;
141            
142            while ( inc < nstrip ){
143                Float_t sl = -100000;
144                Float_t sr = -100000;
145                if( il >= 0       ) sl = clsignal[il];
146                if( ir < CLlength ) sr = clsignal[ir];
147                if( sl == sr && inc == 0 ){
148                    s += clsignal[il]; //cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;
149                    il--;
150                    ir++;
151                }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){
152                    s += sl;//cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;
153                    il--;
154                }else if ( sl < sr && sr > cut*clsigma[ir] ){
155                    s += sr;//cout << inc<<" - " << clsignal[ir]<<" "<<s<<endl;
156                    ir++;
157                }else break;
158                
159                inc++;
160            }
161            return s;
162    
163        }else{
164        //---------------------------------------------------
165        // evaluate signal using a fixed number of strips,
166        // following the PFA inclusion patters
167        //---------------------------------------------------
168    //     --> signal of the central strip
169            Float_t sc = clsignal[indmax];
170    //     signal of adjacent strips
171            Float_t sl1 = -9999.;
172            Float_t sl2 = -9999.;
173            Float_t sr1 = -9999.;
174            Float_t sr2 = -9999.;
175            if(indmax-1>=0) sl1 = clsignal[indmax-1];
176            if(indmax-2>=0) sl2 = clsignal[indmax-2];
177            if(indmax+1<CLlength) sr1 = clsignal[indmax+1];
178            if(indmax+2<CLlength) sr2 = clsignal[indmax+2];
179    
180            if(nstrip==1){
181                s = sc;
182            }else if(nstrip==2){
183                if( sl1>sr1 && sl1+sc!=0 )s = (sl1+sc);
184                if( sl1<sr1 && sr1+sc!=0 )s = (sc+sr1);
185                if( sl1==sr1 && sl1 != -9999.){
186                    if( clsigma[indmax-1] < clsigma[indmax+1] &&  sl1+sc!=0 )s = (sl1+sc);
187                    if( clsigma[indmax-1] > clsigma[indmax+1] &&  sc+sr1!=0 )s = (sc+sr1);
188                }
189            }else if(nstrip==3){
190                s = (sl1+sc+sr1);
191            }else if(nstrip==4){
192                if( sl2>sr2 && sl2+sl1+sc+sr1!=0 )s = (sl2+sl1+sc+sr1);
193                if( sl2<sr2 && sl1+sc+sr1+sr2!=0 )s = (sl1+sc+sr1+sr2);
194                if( sl2==sr2 && sl2 != -9999.){
195                    if( clsigma[indmax-2] < clsigma[indmax+2] &&  sl2+sl1+sc+sr1!=0 )s = (sl2+sl1+sc+sr1);
196                    if( clsigma[indmax-2] > clsigma[indmax+2] &&  sl1+sc+sr1+sr2!=0 )s = (sl1+sc+sr1+sr2);
197                }
198            }else if(nstrip==5){
199                s = (sl1+sc+sr1);
200                if(sl2 != -9999.)s += sl2;
201                if(sr2 != -9999.)s += sr2;
202            }else{
203                cout << "Float_t TrkCluster::GetSignal("<<nstrip<<","<<cut<<","<<force<<")- not implemented"<<endl;  
204            }
205            
206      Int_t il = indmax;      }
     Int_t ir = indmax;  
     Int_t inc = 0;  
207    
208      if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;      return 0.;
209    
     while ( inc < nstrip ){  
         Float_t sl = -100000;  
         Float_t sr = -100000;  
         if( il >= 0       ) sl = clsignal[il];  
         if( ir < CLlength ) sr = clsignal[ir];  
         if( sl == sr && inc == 0 ){  
             s += clsignal[il]; //cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;  
             il--;  
             ir++;  
         }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){  
             s += sl;//cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;  
             il--;  
         }else if ( sl < sr && sr > cut*clsigma[ir] ){  
             s += sr;//cout << inc<<" - " << clsignal[ir]<<" "<<s<<endl;  
             ir++;  
         }else break;  
           
         inc++;  
     }  
     return s;  
210  };  };
211    
212    
# Line 239  Bool_t TrkCluster::IsBad(Int_t nbad){ Line 299  Bool_t TrkCluster::IsBad(Int_t nbad){
299      il = indmax;      il = indmax;
300      ir = indmax;      ir = indmax;
301      for(Int_t i=1; i<nbad; i++){      for(Int_t i=1; i<nbad; i++){
302          if (ir == CLlength && il == 0)break;          if (ir == CLlength-1 && il == 0)break;
303          else if (ir == CLlength && il != 0)il--;          else if (ir == CLlength-1 && il != 0)il--;
304          else if (ir != CLlength && il == 0)ir++;          else if (ir != CLlength-1 && il == 0)ir++;
305          else{          else{
306              if(clsignal[il-1] > clsignal[ir+1])il--;              if(clsignal[il-1] > clsignal[ir+1])il--;
307              else ir++;              else ir++;
# Line 264  Bool_t TrkCluster::IsSaturated(Int_t nba Line 324  Bool_t TrkCluster::IsSaturated(Int_t nba
324      il = indmax;      il = indmax;
325      ir = indmax;      ir = indmax;
326      for(Int_t i=1; i<nbad; i++){      for(Int_t i=1; i<nbad; i++){
327          if (ir == CLlength && il == 0)break;          if (ir == CLlength-1 && il == 0)break;
328          else if (ir == CLlength && il != 0)il--;          else if (ir == CLlength-1 && il != 0)il--;
329          else if (ir != CLlength && il == 0)ir++;          else if (ir != CLlength-1 && il == 0)ir++;
330          else{          else{
331              if(clsignal[il-1] > clsignal[ir+1])il--;              if(clsignal[il-1] > clsignal[ir+1])il--;
332              else ir++;              else ir++;
# Line 291  void TrkCluster::Dump(){ Line 351  void TrkCluster::Dump(){
351      cout << "Position of maximun "<< maxs <<endl;      cout << "Position of maximun "<< maxs <<endl;
352      cout << "Multiplicity        "<< GetMultiplicity() <<endl;      cout << "Multiplicity        "<< GetMultiplicity() <<endl;
353      cout << "Tot signal          "<< GetSignal() << " (ADC channels)"<<endl ;      cout << "Tot signal          "<< GetSignal() << " (ADC channels)"<<endl ;
354      cout << "Signal/Noise        "<< GetSignalToNoise();      cout << "Signal/Noise        "<< GetSignalToNoise()<<endl;
355      cout <<endl<< "Strip signals       ";      cout << "COG                 "<< GetCOG(0)<<endl;;
356        cout << "Strip signals       ";
357      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];
358      cout <<endl<< "Strip sigmas        ";      cout <<endl<< "Strip sigmas        ";
359      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];
# Line 313  void TrkCluster::Dump(){ Line 374  void TrkCluster::Dump(){
374  /**  /**
375   * 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).
376   */   */
377  cTrkLevel1* TrkCluster::GetLevel1Struct(){  void TrkCluster::GetLevel1Struct(cTrkLevel1* l1){
378                                    
379  //    cTrkLevel1* l1 = new cTrkLevel1;  //    cTrkLevel1* l1 = new cTrkLevel1;
380    
381      cTrkLevel1* l1 = &level1event_ ;  //    cTrkLevel1* l1 = &level1event_ ;
382                    
383      l1->nclstr1 = 1;      l1->nclstr1 = 1;
384      l1->view[0] = view;      l1->view[0] = view;
# Line 335  cTrkLevel1* TrkCluster::GetLevel1Struct( Line 396  cTrkLevel1* TrkCluster::GetLevel1Struct(
396          l1->clbad[i] = clbad[i];          l1->clbad[i] = clbad[i];
397      };      };
398            
399      return l1;  //    return l1;
400  };  };
401  //--------------------------------------  //--------------------------------------
402  //  //
# Line 387  Float_t TrkCluster::GetCOG(Float_t angle Line 448  Float_t TrkCluster::GetCOG(Float_t angle
448  //  //
449  //--------------------------------------  //--------------------------------------
450  /**  /**
451   * Evaluates the cluster position, in strips, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm.   * Evaluates the cluster position, in pitch units, relative to the strip
452     *  with the maximum signal (TrkCluster::maxs), by applying the non-linear
453     *  ETA-algorythm.
454   *  @param neta  Number of strips to evaluate ETA.   *  @param neta  Number of strips to evaluate ETA.
455   *  @param angle Projected angle between particle track and detector plane.   *  @param angle Projected (effective) angle between particle track and detector plane.
456     *  @landi flag to apply Landi correction
457   * Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle.   * Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle.
458   */   */
459  Float_t TrkCluster::GetETA(Int_t neta, float angle){  Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi){
460                    
461  //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;  //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;
462  //      LoadPfaParam();  //      LoadPfaParam();
463    
464        TrkParams::Load(4);
465        if( !TrkParams::IsLoaded(4) ){
466            cout << "Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
467            return 0;
468        }
469    
470      float ax = angle;      float ax = angle;
471      int ic = 1;      int ic = 1;
472      GetLevel1Struct();      GetLevel1Struct();
473      if(neta == 0)      return pfaeta_(&ic,&ax);      if(     neta == 0 && !landi) return pfaeta_(&ic,&ax);
474      else if(neta == 2) return pfaeta2_(&ic,&ax);      else if(neta == 0 && landi ) return pfaetal_(&ic,&ax);
475      else if(neta == 3) return pfaeta3_(&ic,&ax);      else if(neta == 2          ) return pfaeta2_(&ic,&ax);
476      else if(neta == 4) return pfaeta4_(&ic,&ax);      else if(neta == 3          ) return pfaeta3_(&ic,&ax);
477      else cout << "ETA"<<neta<<" not implemented\n";      else if(neta == 4          ) return pfaeta4_(&ic,&ax);
478        else cout << "TrkCluster::GetETA("<<neta<<","<<angle<<","<<landi<<") not implemented\n";
479      return 0;      return 0;
480            
481  };  };
482    
483    /**
484     * Evaluates the cluster position, in pitch unit, relative to the strip with
485     * the maximum signal (TrkCluster::maxs), by applying the PFA set as default (see TrkParams).
486     *  @param angle Projected (effective) angle between particle track and detector plane.
487     */
488    Float_t TrkCluster::GetPositionPU(float angle){
489    
490        if     ( TrkParams::GetPFA() == 0  )return GetETA(0,angle,false);
491        else if( TrkParams::GetPFA() == 2  )return GetETA(2,angle,false);
492        else if( TrkParams::GetPFA() == 3  )return GetETA(3,angle,false);
493        else if( TrkParams::GetPFA() == 4  )return GetETA(4,angle,false);
494        else if( TrkParams::GetPFA() == 5  )return GetETA(0,angle,true);
495        else if( TrkParams::GetPFA() == 10 )return GetCOG(0);
496        else if( TrkParams::GetPFA() == 11 )return GetCOG(1);
497        else if( TrkParams::GetPFA() == 12 )return GetCOG(2);
498        else if( TrkParams::GetPFA() == 13 )return GetCOG(3);
499        else if( TrkParams::GetPFA() == 14 )return GetCOG(4);
500        else cout << "  TrkCluster::GetPositionPU(float "<<angle<<") -- WARNING -- PFA="<<TrkParams::GetPFA()<<" not implemented"<<endl;
501        
502        return 0.;
503        
504    }
505    
506    /**
507     * Give the number of strip used to evaluate the cluster coordinate
508     * according to the p.f.a.
509     * It returns 0 when the COG is used (in this case the number of strip used
510     * equals the multiplicity).
511     */
512    Int_t TrkCluster::GetPFAstrips(float angle){
513    
514        float ax = angle;
515        int ic = 1;
516        GetLevel1Struct();
517        return npfastrips_(&ic,&ax);
518    
519    }
520    
521  //--------------------------------------  //--------------------------------------
522  //  //
523  //  //
# Line 425  TrkLevel1::TrkLevel1(){ Line 534  TrkLevel1::TrkLevel1(){
534              cnn[j][i]=0;              cnn[j][i]=0;
535          };          };
536      };      };
537        TrkParams::SetTrackingMode();
538        TrkParams::SetPrecisionFactor();
539        TrkParams::SetStepMin();
540        TrkParams::SetPFA();
541    }
542    //--------------------------------------
543    //
544    //
545    //--------------------------------------
546    void TrkLevel1::Set(){
547        if(!Cluster)Cluster = new TClonesArray("TrkCluster");
548  }  }
549  //--------------------------------------  //--------------------------------------
550  //  //
# Line 450  void TrkLevel1::Dump(){ Line 570  void TrkLevel1::Dump(){
570      for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();      for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();
571            
572  }  }
573    /**
574     * \brief Dump processing status
575     */
576    void TrkLevel1::StatusDump(int view){
577        cout << "DSP n. "<<view+1<<" (level1-)status: "<<hex<<showbase<<good[view]<<dec<<endl;    
578    };
579    /**
580     * \brief Check event status
581     *
582     * Check the event status, according to a flag-mask given as input.
583     * Return true if the view passes the check.
584     *
585     * @param view View number (0-11)
586     * @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet,
587     *  no crc error, no software alarm)
588     *
589     * @see TrkLevel2 class definition to know how the status flag is defined
590     *
591     */
592    Bool_t TrkLevel1::StatusCheck(int view, int flagmask){
593    
594        if( view<0 || view >= 12)return false;
595        return !(good[view]&flagmask);
596    
597    };
598    
599    
600  //--------------------------------------  //--------------------------------------
601  //  //
602  //  //
# Line 459  void TrkLevel1::Dump(){ Line 606  void TrkLevel1::Dump(){
606   */   */
607  void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){  void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){
608    
609    //    cout << "void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full)"<<endl;
610        
611        Clear();
612      //  ---------------      //  ---------------
613      //  *** CLUSTER ***      //  *** CLUSTER ***
614      //  ---------------      //  ---------------
# Line 484  void TrkLevel1::SetFromLevel1Struct(cTrk Line 634  void TrkLevel1::SetFromLevel1Struct(cTrk
634              t_cl->clsigma  = new Float_t[t_cl->CLlength];              t_cl->clsigma  = new Float_t[t_cl->CLlength];
635              t_cl->cladc    = new Int_t[t_cl->CLlength];              t_cl->cladc    = new Int_t[t_cl->CLlength];
636              t_cl->clbad    = new Bool_t[t_cl->CLlength];              t_cl->clbad    = new Bool_t[t_cl->CLlength];
637    
638              Int_t index = 0;              Int_t index = 0;
639              for(Int_t is = from; is < to; is++ ){              for(Int_t is = from; is < to; is++ ){
640                  t_cl->clsignal[index] = (Float_t) l1->clsignal[is];                  t_cl->clsignal[index] = (Float_t) l1->clsignal[is];
# Line 515  void TrkLevel1::SetFromLevel1Struct(cTrk Line 666  void TrkLevel1::SetFromLevel1Struct(cTrk
666   * 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).
667   */   */
668    
669  cTrkLevel1* TrkLevel1::GetLevel1Struct() {  void TrkLevel1::GetLevel1Struct(cTrkLevel1* l1) {
670            
671      cTrkLevel1 *l1=0;  //    cTrkLevel1* l1 = &level1event_ ;
672      //      
673      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
674          l1->good[i] = good[i];          l1->good[i] = good[i];
675          for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
676              l1->cnev[j][i]    = cn[j][i];              l1->cnev[j][i]    = cn[j][i]  ;
677  //          l1->cnrmsev[j][i] = cnrms[j][i];              l1->cnnev[j][i]   = cnn[j][i] ;
678              l1->cnnev[j][i]   = cnn[j][i];              l1->cnrmsev[j][i] = 0. ;
679          };          };
680            l1->fshower[i] = 0;
681      };      };
682        
683  //  *** CLUSTERS ***      l1->nclstr1=0;
684        l1->totCLlength=0;
685        Int_t index=0;
686      if(Cluster){      if(Cluster){
687          l1->nclstr1 =  Cluster->GetEntries();          Int_t i=0;
688          for(Int_t i=0;i<l1->nclstr1;i++){          for(Int_t ii=0;ii<Cluster->GetEntries();ii++){
689                        TrkCluster *clu = GetCluster(ii);
690              l1->view[i]     = ((TrkCluster *)Cluster->At(i))->view;              // ----------------------------------------
691              l1->maxs[i]     = ((TrkCluster *)Cluster->At(i))->maxs;              // attenzione!!
692              // COMPLETARE //              // se il cluster non e` salvato (view = 0)
693              // COMPLETARE //              // DEVE essere escluso dal common F77
694              // COMPLETARE //              // ----------------------------------------
695              // COMPLETARE //              if(clu->view != 0 ){
696              // COMPLETARE //                  l1->view[i]     = clu->view;
697              // COMPLETARE //                  l1->ladder[i]   = clu->GetLadder();
698                            l1->maxs[i]     = clu->maxs;
699                    l1->mult[i]     = clu->GetMultiplicity();
700                    l1->dedx[i]     = clu->GetSignal();
701                    l1->indstart[i] = index+1;
702                    l1->indmax[i]   = l1->indstart[i] + clu->indmax;
703                    l1->totCLlength += clu->CLlength;
704                    for(Int_t iw=0; iw < clu->CLlength; iw++){
705                        l1->clsignal[index] = clu->clsignal[iw];
706                        l1->clsigma[index]  = clu->clsigma[iw];
707                        l1->cladc[index]    = clu->cladc[iw];
708                        l1->clbad[index]    = clu->clbad[iw];
709                        index++;
710                    }
711                    i++;
712                }
713          }          }
714          // COMPLETARE //          l1->nclstr1 =  i;      
         // COMPLETARE //  
         // COMPLETARE //  
         // COMPLETARE //  
         // COMPLETARE //  
         // COMPLETARE //  
715      }      }
716      return l1;  
717    //    return l1;
718  }  }
719  //--------------------------------------  //--------------------------------------
720  //  //
# Line 601  TrkCluster *TrkLevel1::GetCluster(int is Line 765  TrkCluster *TrkLevel1::GetCluster(int is
765  //  //
766  //  //
767  //--------------------------------------  //--------------------------------------
768    // /**
769    //  * Load Position-Finding-Algorythm parameters (call the F77 routine).
770    //  *
771    //  */
772    // int TrkLevel1::LoadPfaParam(TString path){
773            
774    //     if( path.IsNull() ){
775    //      path = gSystem->Getenv("PAM_CALIB");
776    //      if(path.IsNull()){
777    //          cout << " TrkLevel1::LoadPfaParam() ==> No PAMELA environment variables defined "<<endl;
778    //          return 0;
779    //      }
780    //      path.Append("/trk-param/eta_param-0/");
781    //     }
782    
783    //     strcpy(path_.path,path.Data());
784    //     path_.pathlen = path.Length();
785    //     path_.error   = 0;
786    //     cout <<"Loading p.f.a. parameters: "<<path<<endl;
787    //     return readetaparam_();
788    // }
789    
790    // /**
791    //  * Load magnetic field parameters (call the F77 routine).
792    //  *
793    //  */
794    // int TrkLevel1::LoadFieldParam(TString path){
795            
796    // //    if( strcmp(path_.path,path.Data()) ){
797    //     if( path.IsNull() ){
798    //      path = gSystem->Getenv("PAM_CALIB");
799    //      if(path.IsNull()){
800    //          cout << " TrkLevel1::LoadFieldParam() ==> No PAMELA environment variables defined "<<endl;
801    //          return 0;
802    //      }
803    //      path.Append("/trk-param/field_param-0/");
804    //     }
805    //     cout <<"Loading magnetic field "<<path<<endl;
806    //     strcpy(path_.path,path.Data());
807    //     path_.pathlen = path.Length();
808    //     path_.error   = 0;
809    //     return readb_();
810    // //    }      
811    // //    return 0;
812    // }
813    // /**
814    //  * Load magnetic field parameters (call the F77 routine).
815    //  *
816    //  */
817    // int TrkLevel1::LoadChargeParam(TString path){
818            
819    // //    if( strcmp(path_.path,path.Data()) ){
820    //     if( path.IsNull() ){
821    //      path = gSystem->Getenv("PAM_CALIB");
822    //      if(path.IsNull()){
823    //          cout << " TrkLevel1::LoadChargeParam() ==> No PAMELA environment variables defined "<<endl;
824    //          return 0;
825    //      }
826    //      path.Append("/trk-param/charge_param-1/");
827    //     }
828    //     cout <<"Loading charge-correlation parameters: "<<path<<endl;
829    //     strcpy(path_.path,path.Data());
830    //     path_.pathlen = path.Length();
831    //     path_.error   = 0;
832    //     return readchargeparam_();
833    // //    }      
834    // //    return 0;
835    // }
836    // /**
837    //  * Load magnetic field parameters (call the F77 routine).
838    //  *
839    //  */
840    // int TrkLevel1::LoadAlignmentParam(TString path){
841            
842    // //    if( strcmp(path_.path,path.Data()) ){
843    //     if( path.IsNull() ){
844    //      path = gSystem->Getenv("PAM_CALIB");
845    //      if(path.IsNull()){
846    //          cout << " TrkLevel1::LoadAlignmentParam() ==> No PAMELA environment variables defined "<<endl;
847    //          return 0;
848    //      }
849    //      path.Append("/trk-param/align_param-0/");
850    //     }
851    //     cout <<"Loading alignment parameters: "<<path<<endl;
852    //     strcpy(path_.path,path.Data());
853    //     path_.pathlen = path.Length();
854    //     path_.error   = 0;
855    //     return readalignparam_();
856    // //    }      
857    // //    return 0;
858    // }
859    // /**
860    //  * Load magnetic field parameters (call the F77 routine).
861    //  *
862    //  */
863    // int TrkLevel1::LoadMipParam(TString path){
864            
865    // //    if( strcmp(path_.path,path.Data()) ){
866    //     if( path.IsNull() ){
867    //      path = gSystem->Getenv("PAM_CALIB");
868    //      if(path.IsNull()){
869    //          cout << " TrkLevel1::LoadMipParam() ==> No PAMELA environment variables defined "<<endl;
870    //          return 0;
871    //      }
872    //      path.Append("/trk-param/mip_param-0/");
873    //     }
874    //     cout <<"Loading ADC-to-MIP conversion parameters: "<<path<<endl;
875    //     strcpy(path_.path,path.Data());
876    //     path_.pathlen = path.Length();
877    //     path_.error   = 0;
878    //     return readmipparam_();
879    // //    }      
880    // //    return 0;
881    // }
882    // /**
883    //  * Load magnetic field parameters (call the F77 routine).
884    //  *
885    //  */
886    // int TrkLevel1::LoadVKMaskParam(TString path){
887            
888    // //    if( strcmp(path_.path,path.Data()) ){
889    //     if( path.IsNull() ){
890    //      path = gSystem->Getenv("PAM_CALIB");
891    //      if(path.IsNull()){
892    //          cout << " TrkLevel1::LoadVKMaskParam() ==> No PAMELA environment variables defined "<<endl;
893    //          return 0;
894    //      }
895    //      path.Append("/trk-param/mask_param-1/");
896    //     }
897    //     cout <<"Loading VK-mask parameters: "<<path<<endl;
898    //     strcpy(path_.path,path.Data());
899    //     path_.pathlen = path.Length();
900    //     path_.error   = 0;
901    //     return readvkmask_();
902    // //    }      
903    // //    return 0;
904    // }
905    
906    // /**
907    //  * Load all (default) parameters. Environment variable must be defined.
908    //  *
909    //  */
910    // int TrkLevel1::LoadParams(){
911    
912    //     int result=0;
913        
914    //     result = result * LoadFieldParam();
915    //     result = result * LoadPfaParam();
916    //     result = result * LoadChargeParam();
917    //     result = result * LoadAlignmentParam();
918    //     result = result * LoadMipParam();
919    //     result = result * LoadVKMaskParam();
920    
921    //     return result;
922    // }
923    
924    
925    
926    int TrkLevel1::GetPfaNbinsAngle(){
927        TrkParams::Load(4);
928        if( !TrkParams::IsLoaded(4) ){
929            cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
930            return 0;
931        }
932        return pfa_.nangbin;
933    };
934    
935    int TrkLevel1::GetPfaNbinsETA(){
936        TrkParams::Load(4);
937        if( !TrkParams::IsLoaded(4) ){
938            cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
939            return 0;
940        }
941        return pfa_.netaval;
942    };
943    
944  /**  /**
945   * Load Position-Finding-Algorythm parameters (call the F77 routine).   *
946   *   *
947   */   */
948  int TrkLevel1::LoadPfaParam(TString path){  float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){
949            
950      if( strcmp(path_.path,path.Data()) ){      TrkParams::Load(4);
951          cout <<"Loading p.f.a. param::eters\n";      if( !TrkParams::IsLoaded(4) ){
952          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;
953          path_.pathlen = path.Length();          return 0;
954          path_.error   = 0;      }
955          return readetaparam_();    
956      }        int nbins = GetPfaNbinsETA();
957      return 0;      if(!nbins)return 0;
958    
959        float *fcorr = new float [nbins];
960    
961        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
962            for(int ib=0; ib<nbins; ib++){
963                fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
964                cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
965            }
966        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
967            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
968        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
969            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
970        }else{
971            cout << pfa<<" pfa parameters not implemented "<<endl;
972            return 0;
973        }    
974    
975        return fcorr;
976    
977    };
978    
979    float* TrkLevel1::GetPfaAbs(TString pfa, int nang){
980      
981        TrkParams::Load(4);
982        if( !TrkParams::IsLoaded(4) ){
983            cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
984            return 0;
985        }
986    
987        int nbins = GetPfaNbinsETA();
988        if(!nbins)return 0;
989    
990        float *fcorr = new float [nbins];
991    
992        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
993            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
994        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
995            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
996        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
997            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
998        }else{
999            cout << pfa<<" pfa parameters not implemented "<<endl;
1000            return 0;
1001        }    
1002    
1003        return fcorr;
1004    
1005    };
1006    
1007    /**
1008     * Method to call the F77 routine that performs level1->level2 processing.
1009     * The level2 output is stored in a common block, which can be retrieved
1010     * by mean of the method TrkLevel2::SetFromLevel2Struct().
1011     * NB If the TrkLevel1 object is readout from a tree, and the
1012     * TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention
1013     * should be payed to the fact that single clusters (clusters not associated
1014     * with any track) might not be stored. Full reprocessing should be done starting
1015     * from level0 data.
1016     */
1017    //int TrkLevel1::ProcessEvent(int pfa){
1018    int TrkLevel1::ProcessEvent(){
1019    
1020    //    cout << "int TrkLevel1::ProcessEvent()" << endl;
1021        TrkParams::Load( );
1022        if( !TrkParams::IsLoaded() )return 0;
1023    
1024        GetLevel1Struct();
1025    
1026    //    analysisflight_(&pfa);
1027    //    TrkParams::SetPFA(pfa);
1028        analysisflight_();
1029    
1030        return 1;
1031    
1032  }  }
1033    
1034    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.23