/[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.22 by pam-fi, Mon Aug 27 12:57:15 2007 UTC revision 1.27 by pam-fi, Thu Feb 27 11:24:43 2014 UTC
# Line 17  extern "C" { Line 17  extern "C" {
17      float pfaeta3_(int*,float*);      float pfaeta3_(int*,float*);
18      float pfaeta4_(int*,float*);      float pfaeta4_(int*,float*);
19      float pfaetal_(int*,float*);      float pfaetal_(int*,float*);
20        float digsat_(int*);
21      int   npfastrips_(int*,float*);      int   npfastrips_(int*,float*);
22                    
23  }  }
# Line 407  void TrkCluster::GetLevel1Struct(cTrkLev Line 408  void TrkCluster::GetLevel1Struct(cTrkLev
408   *      @param ncog Number of strips to evaluate COG.     *      @param ncog Number of strips to evaluate COG.  
409   * If ncog=0, the COG of the cluster is evaluated according to the cluster multiplicity (defined by the inclusion cut).   * If ncog=0, the COG of the cluster is evaluated according to the cluster multiplicity (defined by the inclusion cut).
410   * If ncog>0, the COG is evaluated using ncog strips, even if they have a negative signal (according to G.Landi)   * If ncog>0, the COG is evaluated using ncog strips, even if they have a negative signal (according to G.Landi)
411     *
412     * (NB TrkCluster::GetLevel1Struct() showld be called first, in order to fill the F77 level1 common with this single cluster)
413   */   */
414  Float_t TrkCluster::GetCOG(Int_t ncog){  Float_t TrkCluster::GetCOG(Int_t ncog){
415                    
416      int ic = 1;      int ic = 1;
417      GetLevel1Struct();      //    GetLevel1Struct(); //Elena: dangerous...
418      return cog_(&ncog,&ic);      return cog_(&ncog,&ic);
419                    
420  };  };
# Line 448  Float_t TrkCluster::GetCOG(Float_t angle Line 451  Float_t TrkCluster::GetCOG(Float_t angle
451  //  //
452  //--------------------------------------  //--------------------------------------
453  /**  /**
454   * Evaluates the cluster position, in pitch units, 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
455     *  with the maximum signal (TrkCluster::maxs), by applying the non-linear
456     *  ETA-algorythm.
457   *  @param neta  Number of strips to evaluate ETA.   *  @param neta  Number of strips to evaluate ETA.
458   *  @param angle Projected (effective) angle between particle track and detector plane.   *  @param angle Projected (effective) angle between particle track and detector plane.
459     *  @landi flag to apply Landi correction
460   * 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.
461     * (NB TrkCluster::GetLevel1Struct() showld be called first, in order to fill the F77 level1 common with this single cluster)
462   */   */
463  Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi){  Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi){
464                    
# Line 466  Float_t TrkCluster::GetETA(Int_t neta, f Line 473  Float_t TrkCluster::GetETA(Int_t neta, f
473    
474      float ax = angle;      float ax = angle;
475      int ic = 1;      int ic = 1;
476      GetLevel1Struct();      //GetLevel1Struct(); //Elena: dangerous...
477      if(     neta == 0 && !landi) return pfaeta_(&ic,&ax);      if(     neta == 0 && !landi) return pfaeta_(&ic,&ax);
478      else if(neta == 0 && landi ) return pfaetal_(&ic,&ax);      else if(neta == 0 && landi ) return pfaetal_(&ic,&ax);
479      else if(neta == 2          ) return pfaeta2_(&ic,&ax);      else if(neta == 2          ) return pfaeta2_(&ic,&ax);
# Line 478  Float_t TrkCluster::GetETA(Int_t neta, f Line 485  Float_t TrkCluster::GetETA(Int_t neta, f
485  };  };
486    
487  /**  /**
488     * Evaluates the cluster position, in pitch units, relative to the strip
489     *  with the maximum signal (TrkCluster::maxs), by applying the digital
490     *  algorithm for saturated clusters.
491     *
492     *  @return The cluster position (0 also if if no saturated strip is found).
493     *
494     * (NB TrkCluster::GetLevel1Struct() showld be called first, in order to fill the F77 level1 common with this single cluster)
495     */
496    Float_t TrkCluster::GetDigSat() {
497    
498      //  GetLevel1Struct(); //Elena: dangerous...
499      int ic = 1;
500      return digsat_(&ic);
501    
502    }
503    
504    /**
505   * Evaluates the cluster position, in pitch unit, relative to the strip with   * Evaluates the cluster position, in pitch unit, relative to the strip with
506   * the maximum signal (TrkCluster::maxs), by applying the PFA set as default (see TrkParams).   * the maximum signal (TrkCluster::maxs), by applying the PFA set as default (see TrkParams).
507   *  @param angle Projected (effective) angle between particle track and detector plane.   *  @param angle Projected (effective) angle between particle track and detector plane.
# Line 505  Float_t TrkCluster::GetPositionPU(float Line 529  Float_t TrkCluster::GetPositionPU(float
529   * according to the p.f.a.   * according to the p.f.a.
530   * It returns 0 when the COG is used (in this case the number of strip used   * It returns 0 when the COG is used (in this case the number of strip used
531   * equals the multiplicity).   * equals the multiplicity).
532     * (NB TrkCluster::GetLevel1Struct() showld be called first, in order to fill the F77 level1 common with this single cluster)
533   */   */
534  Int_t TrkCluster::GetPFAstrips(float angle){  Int_t TrkCluster::GetPFAstrips(float angle){
535    
536      float ax = angle;      float ax = angle;
537      int ic = 1;      int ic = 1;
538      GetLevel1Struct();      //    GetLevel1Struct(); //Elena: dangerous...
539      return npfastrips_(&ic,&ax);      return npfastrips_(&ic,&ax);
540    
541  }  }
# Line 531  TrkLevel1::TrkLevel1(){ Line 556  TrkLevel1::TrkLevel1(){
556              cnn[j][i]=0;              cnn[j][i]=0;
557          };          };
558      };      };
559      TrkParams::SetTrackingMode();  //     TrkParams::SetTrackingMode();
560      TrkParams::SetPrecisionFactor();  //     TrkParams::SetPrecisionFactor();
561      TrkParams::SetStepMin();  //     TrkParams::SetStepMin();
562        TrkParams::SetMiniDefault();
563      TrkParams::SetPFA();      TrkParams::SetPFA();
564  }  }
565  //--------------------------------------  //--------------------------------------
# Line 758  TrkCluster *TrkLevel1::GetCluster(int is Line 784  TrkCluster *TrkLevel1::GetCluster(int is
784      TrkCluster *cluster = (TrkCluster*)t[is];      TrkCluster *cluster = (TrkCluster*)t[is];
785      return cluster;      return cluster;
786  }  }
 //--------------------------------------  
 //  
 //  
 //--------------------------------------  
 // /**  
 //  * Load Position-Finding-Algorythm parameters (call the F77 routine).  
 //  *  
 //  */  
 // int TrkLevel1::LoadPfaParam(TString path){  
           
 //     if( path.IsNull() ){  
 //      path = gSystem->Getenv("PAM_CALIB");  
 //      if(path.IsNull()){  
 //          cout << " TrkLevel1::LoadPfaParam() ==> No PAMELA environment variables defined "<<endl;  
 //          return 0;  
 //      }  
 //      path.Append("/trk-param/eta_param-0/");  
 //     }  
787    
 //     strcpy(path_.path,path.Data());  
 //     path_.pathlen = path.Length();  
 //     path_.error   = 0;  
 //     cout <<"Loading p.f.a. parameters: "<<path<<endl;  
 //     return readetaparam_();  
 // }  
788    
789  // /**  // int TrkLevel1::GetPfaNbinsAngle(){
790  //  * Load magnetic field parameters (call the F77 routine).  //     TrkParams::Load(4);
791  //  *  //     if( !TrkParams::IsLoaded(4) ){
792  //  */  //      cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
793  // int TrkLevel1::LoadFieldParam(TString path){  //      return 0;
           
 // //    if( strcmp(path_.path,path.Data()) ){  
 //     if( path.IsNull() ){  
 //      path = gSystem->Getenv("PAM_CALIB");  
 //      if(path.IsNull()){  
 //          cout << " TrkLevel1::LoadFieldParam() ==> No PAMELA environment variables defined "<<endl;  
 //          return 0;  
 //      }  
 //      path.Append("/trk-param/field_param-0/");  
 //     }  
 //     cout <<"Loading magnetic field "<<path<<endl;  
 //     strcpy(path_.path,path.Data());  
 //     path_.pathlen = path.Length();  
 //     path_.error   = 0;  
 //     return readb_();  
 // //    }        
 // //    return 0;  
 // }  
 // /**  
 //  * Load magnetic field parameters (call the F77 routine).  
 //  *  
 //  */  
 // int TrkLevel1::LoadChargeParam(TString path){  
           
 // //    if( strcmp(path_.path,path.Data()) ){  
 //     if( path.IsNull() ){  
 //      path = gSystem->Getenv("PAM_CALIB");  
 //      if(path.IsNull()){  
 //          cout << " TrkLevel1::LoadChargeParam() ==> No PAMELA environment variables defined "<<endl;  
 //          return 0;  
 //      }  
 //      path.Append("/trk-param/charge_param-1/");  
794  //     }  //     }
795  //     cout <<"Loading charge-correlation parameters: "<<path<<endl;  //     return pfa_.nangbin;
796  //     strcpy(path_.path,path.Data());  // };
797  //     path_.pathlen = path.Length();  
798  //     path_.error   = 0;  // int TrkLevel1::GetPfaNbinsETA(){
799  //     return readchargeparam_();  //     TrkParams::Load(4);
800  // //    }        //     if( !TrkParams::IsLoaded(4) ){
801  // //    return 0;  //      cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
802  // }  //      return 0;
 // /**  
 //  * Load magnetic field parameters (call the F77 routine).  
 //  *  
 //  */  
 // int TrkLevel1::LoadAlignmentParam(TString path){  
           
 // //    if( strcmp(path_.path,path.Data()) ){  
 //     if( path.IsNull() ){  
 //      path = gSystem->Getenv("PAM_CALIB");  
 //      if(path.IsNull()){  
 //          cout << " TrkLevel1::LoadAlignmentParam() ==> No PAMELA environment variables defined "<<endl;  
 //          return 0;  
 //      }  
 //      path.Append("/trk-param/align_param-0/");  
 //     }  
 //     cout <<"Loading alignment parameters: "<<path<<endl;  
 //     strcpy(path_.path,path.Data());  
 //     path_.pathlen = path.Length();  
 //     path_.error   = 0;  
 //     return readalignparam_();  
 // //    }        
 // //    return 0;  
 // }  
 // /**  
 //  * Load magnetic field parameters (call the F77 routine).  
 //  *  
 //  */  
 // int TrkLevel1::LoadMipParam(TString path){  
           
 // //    if( strcmp(path_.path,path.Data()) ){  
 //     if( path.IsNull() ){  
 //      path = gSystem->Getenv("PAM_CALIB");  
 //      if(path.IsNull()){  
 //          cout << " TrkLevel1::LoadMipParam() ==> No PAMELA environment variables defined "<<endl;  
 //          return 0;  
 //      }  
 //      path.Append("/trk-param/mip_param-0/");  
 //     }  
 //     cout <<"Loading ADC-to-MIP conversion parameters: "<<path<<endl;  
 //     strcpy(path_.path,path.Data());  
 //     path_.pathlen = path.Length();  
 //     path_.error   = 0;  
 //     return readmipparam_();  
 // //    }        
 // //    return 0;  
 // }  
 // /**  
 //  * Load magnetic field parameters (call the F77 routine).  
 //  *  
 //  */  
 // int TrkLevel1::LoadVKMaskParam(TString path){  
           
 // //    if( strcmp(path_.path,path.Data()) ){  
 //     if( path.IsNull() ){  
 //      path = gSystem->Getenv("PAM_CALIB");  
 //      if(path.IsNull()){  
 //          cout << " TrkLevel1::LoadVKMaskParam() ==> No PAMELA environment variables defined "<<endl;  
 //          return 0;  
 //      }  
 //      path.Append("/trk-param/mask_param-1/");  
803  //     }  //     }
804  //     cout <<"Loading VK-mask parameters: "<<path<<endl;  //     return pfa_.netaval;
805  //     strcpy(path_.path,path.Data());  // };
 //     path_.pathlen = path.Length();  
 //     path_.error   = 0;  
 //     return readvkmask_();  
 // //    }        
 // //    return 0;  
 // }  
806    
807  // /**  // /**
808  //  * Load all (default) parameters. Environment variable must be defined.  //  *
809  //  *  //  *
810  //  */  //  */
811  // int TrkLevel1::LoadParams(){  // float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){
   
 //     int result=0;  
       
 //     result = result * LoadFieldParam();  
 //     result = result * LoadPfaParam();  
 //     result = result * LoadChargeParam();  
 //     result = result * LoadAlignmentParam();  
 //     result = result * LoadMipParam();  
 //     result = result * LoadVKMaskParam();  
   
 //     return result;  
 // }  
   
   
   
 int TrkLevel1::GetPfaNbinsAngle(){  
     TrkParams::Load(4);  
     if( !TrkParams::IsLoaded(4) ){  
         cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;  
         return 0;  
     }  
     return pfa_.nangbin;  
 };  
   
 int TrkLevel1::GetPfaNbinsETA(){  
     TrkParams::Load(4);  
     if( !TrkParams::IsLoaded(4) ){  
         cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;  
         return 0;  
     }  
     return pfa_.netaval;  
 };  
812    
813  /**  //     TrkParams::Load(4);
814   *  //     if( !TrkParams::IsLoaded(4) ){
815   *  //      cout << "float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
816   */  //      return 0;
817  float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){  //     }
   
     TrkParams::Load(4);  
     if( !TrkParams::IsLoaded(4) ){  
         cout << "float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;  
         return 0;  
     }  
818        
819      int nbins = GetPfaNbinsETA();  //     int nbins = GetPfaNbinsETA();
820      if(!nbins)return 0;  //     if(!nbins)return 0;
821    
822      float *fcorr = new float [nbins];  //     float *fcorr = new float [nbins];
823    
824      if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){  //     if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
825          for(int ib=0; ib<nbins; ib++){  //      for(int ib=0; ib<nbins; ib++){
826              fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];  //          fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
827              cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;  //          cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
828          }  //      }
829      }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){  //     }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
830          for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];  //      for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
831      }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){  //     }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
832          for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];  //      for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
833      }else{  //     }else{
834          cout << pfa<<" pfa parameters not implemented "<<endl;  //      cout << pfa<<" pfa parameters not implemented "<<endl;
835          return 0;  //      return 0;
836      }      //     }    
837    
838      return fcorr;  //     return fcorr;
839    
840  };  // };
841    
842  float* TrkLevel1::GetPfaAbs(TString pfa, int nang){  // float* TrkLevel1::GetPfaAbs(TString pfa, int nang){
843        
844      TrkParams::Load(4);  //     TrkParams::Load(4);
845      if( !TrkParams::IsLoaded(4) ){  //     if( !TrkParams::IsLoaded(4) ){
846          cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;  //      cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
847          return 0;  //      return 0;
848      }  //     }
849    
850      int nbins = GetPfaNbinsETA();  //     int nbins = GetPfaNbinsETA();
851      if(!nbins)return 0;  //     if(!nbins)return 0;
852    
853      float *fcorr = new float [nbins];  //     float *fcorr = new float [nbins];
854    
855      if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){  //     if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
856          for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];  //      for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
857      }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){  //     }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
858          for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];  //      for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
859      }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){  //     }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
860          for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];  //      for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
861      }else{  //     }else{
862          cout << pfa<<" pfa parameters not implemented "<<endl;  //      cout << pfa<<" pfa parameters not implemented "<<endl;
863          return 0;  //      return 0;
864      }      //     }    
865    
866      return fcorr;  //     return fcorr;
867    
868  };  // };
869    
870  /**  /**
871   * Method to call the F77 routine that performs level1->level2 processing.   * Method to call the F77 routine that performs level1->level2 processing.

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.23