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

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

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

revision 1.18 by pam-fi, Wed Nov 7 10:38:52 2007 UTC revision 1.23 by pam-fi, Fri Apr 11 13:44:38 2008 UTC
# Line 1  Line 1 
1    
2  /**  /**
3   * \file TrkParams.cpp   * \file TrkParams.cpp
4   * \author Elena Vannuccini   * \author Elena Vannuccini
# Line 35  int    TrkParams::init__mini_istepmin  = Line 36  int    TrkParams::init__mini_istepmin  =
36  double TrkParams::init__mini_fact      = 1.e4; //100.;  double TrkParams::init__mini_fact      = 1.e4; //100.;
37  float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};  float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};
38  float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};  float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};
39    double TrkParams::init__deltab_0       = 0.;
40    double TrkParams::init__deltab_1       = 0.;
41    double TrkParams::init__dlt            = 1.e-5;
42    // ------------------------------------------
43    // nominal z-coordinates to define acceptance
44    // ------------------------------------------
45    int   TrkParams::nGF   = NGF;
46    float TrkParams::zGF[] = {+53.74,+53.04,+23.94,+23.44,+22.29,+21.83,+13.39,+4.49,-4.41,-13.31,-21.83,-22.22,-23.49,-24.34};
47    float TrkParams::xGF_min[] = {-20.40,-20.40,-9.00,-9.00,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-9.00,-9.00};
48    float TrkParams::xGF_max[] = {+20.40,+20.40,+9.00,+9.00,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+9.00,+9.00};
49    // float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-7.25,-7.25,-7.25,-7.25,-6.57,-6.75,-7.50,-7.50};
50    // float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.75,+6.75,+6.75,+6.75,+6.57,+7.25,+7.50,+7.50};
51    // per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa
52    float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-6.57,-6.57,-6.57,-6.57,-6.57,-6.75,-7.50,-7.50};
53    float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.57,+6.57,+6.57,+6.57,+6.57,+7.25,+7.50,+7.50};
54    TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"};
55    
56  TrkParams::TrkParams(){  TrkParams::TrkParams(){
57    
# Line 75  TSQLServer* TrkParams::SetDBConnection() Line 92  TSQLServer* TrkParams::SetDBConnection()
92      if ( strcmp(pamdbhost,"") ) host = pamdbhost;      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
93      if ( strcmp(pamdbuser,"") ) user = pamdbuser;      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
94      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
95      if(TrkParams::VerboseMode()){      if(TrkParams::DebugMode()){
96          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
97          cout<<"Connecting to DB"<<endl;          cout<<"TrkParams::SetDBConnection() >> Connecting to DB"<<endl;
98          cout<<"HOST "<<host<<endl;          cout<<"HOST "<<host<<endl;
99          cout<<"USER "<<user<<endl;          cout<<"USER "<<user<<endl;
100          cout<<"PSW  "<<psw<<endl;          cout<<"PSW  "<<psw<<endl;
# Line 89  TSQLServer* TrkParams::SetDBConnection() Line 106  TSQLServer* TrkParams::SetDBConnection()
106      myquery.str("");  // EMILIANO      myquery.str("");  // EMILIANO
107      myquery << "SET time_zone='+0:00'";  // EMILIANO      myquery << "SET time_zone='+0:00'";  // EMILIANO
108      dbc->Query(myquery.str().c_str());  // EMILIANO      dbc->Query(myquery.str().c_str());  // EMILIANO
109      if(TrkParams::VerboseMode()){      if(TrkParams::DebugMode()){
110          cout << " ...done"<<endl;          cout << " ...done"<<endl;
111          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
112      }      }
# Line 157  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 174  Bool_t TrkParams::SetCalib( GL_RUN *glru
174          }          }
175                    
176          if(LOCAL_CONNECTION){          if(LOCAL_CONNECTION){
             dbc->Close();  
177              delete dbc;              delete dbc;
178                dbc->Close();
179                if(TrkParams::DebugMode()){
180                    cout << " DB connection closed."<<endl;
181                }      
182          }          }
183    
184  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
# Line 598  Bool_t TrkParams::LoadCalib( ){ Line 618  Bool_t TrkParams::LoadCalib( ){
618          cout << " - full+truncated parameters "<<endl;          cout << " - full+truncated parameters "<<endl;
619      }      }
620      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
621      if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;      if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl;
622      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
623    
624      // =============================================================      // =============================================================
# Line 657  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 677  Bool_t TrkParams::Set( GL_RUN* glrun , T
677      }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;      }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
678    
679  //    if(TrkParams::VerboseMode())  //    if(TrkParams::VerboseMode())
680      cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
681    
682    
683      if( !TrkParams::IsLoaded(type) ||      if( !TrkParams::IsLoaded(type) ||
# Line 679  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 699  Bool_t TrkParams::Set( GL_RUN* glrun , T
699          if(LOCAL_CONNECTION){          if(LOCAL_CONNECTION){
700              dbc->Close();              dbc->Close();
701              delete dbc;              delete dbc;
702                if(TrkParams::DebugMode()){
703                    cout << " DB connection closed."<<endl;
704                }      
705          }          }
706          gl[index]     = q4;          gl[index]     = q4;
707          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
# Line 877  float TrkParams::GetBZ(float* v){ Line 900  float TrkParams::GetBZ(float* v){
900  }  }
901    
902    
   
903  /**  /**
904   * \brief Set tracking mode (0=standard. 1=???)   * \brief Set tracking mode (0=standard. 1=???)
905   */   */
906  void TrkParams::SetTrackingMode(int trackmode) {  void TrkParams::SetTrackingMode(int trackmode) {
907      init__mini_trackmode = trackmode;      init__mini_trackmode = trackmode;
908      SetTrackingMode();      SetTrackingMode(); //fill F77 common
909  };  };
910  /**  /**
911   * \brief Set fit-precision factor (typical value fact=100.)   * \brief Set fit-precision factor (typical value fact=100.)
912   */   */
913  void TrkParams::SetPrecisionFactor(double fact){  void TrkParams::SetPrecisionFactor(double fact){
914      init__mini_fact      = fact;      init__mini_fact      = fact;
915      SetPrecisionFactor();      SetPrecisionFactor(); //fill F77 common
916  };  };
917  /**  /**
918   * \brief Set minimum number of step in track fitting   * \brief Set minimum number of step in track fitting
919   */   */
920  void TrkParams::SetStepMin(int istepmin){  void TrkParams::SetStepMin(int istepmin){
921      init__mini_istepmin  = istepmin;      init__mini_istepmin  = istepmin;
922      SetStepMin();      SetStepMin(); //fill F77 common
923    };
924    /**
925     * \brief Set deltaB parameters (id=0,1)
926     */
927    void TrkParams::SetDeltaB(int id,double db){
928        if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl;
929        if(id==0)init__deltab_0 = db;
930        if(id==1)init__deltab_1 = db;
931        SetDeltaB(); //fill F77 common
932    };
933    /**
934     * \brief Set DLT-grkuta precision factor (default 1.e-4)
935     */
936    void TrkParams::SetDLT(double fact){
937        init__dlt               = fact;
938        SetDLT(); //fill F77 common
939  };  };
940    
941  /**  /**
942   * Fill F77 commons with PFA settings   * \brief Fill F77 commons with PFA settings
943   */   */
944  void TrkParams::SetPFA(){  void TrkParams::SetPFA(){
945      sw_.pfaid = init__pfa;          sw_.pfaid = init__pfa;    
# Line 928  void TrkParams::SetPFA(){ Line 966  void TrkParams::SetPFA(){
966   */   */
967  void TrkParams::SetPFA(int pfaid){  void TrkParams::SetPFA(int pfaid){
968      init__pfa  = pfaid;      init__pfa  = pfaid;
969      SetPFA();      SetPFA(); //fill F77 common
970  };  };
971  /**  /**
972   * \brief Set p.f.a. angular intervals   * \brief Set p.f.a. angular intervals
973   *   *
974   * This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4   * This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4
975   * algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)).   * algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)).
976   * @param v Pointer to a vector of 12 components, which represent the   * @param v Pointer to a vector of 12 components, which represent the
977   * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly.   * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly.
978   *   *
# Line 944  void TrkParams::SetPFA(float *v){ Line 982  void TrkParams::SetPFA(float *v){
982          init__pfa_e234ax[i]  = v[i];          init__pfa_e234ax[i]  = v[i];
983          init__pfa_e234ay[i]  = v[i+6];          init__pfa_e234ay[i]  = v[i+6];
984      }      }
985      SetPFA();      SetPFA(); //fill F77 common
986  };  };
987    
988    
# Line 963  void TrkParams::SetPFA(float *v){ Line 1001  void TrkParams::SetPFA(float *v){
1001   */   */
1002  float TrkParams::GetResolution(int view, float angle){  float TrkParams::GetResolution(int view, float angle){
1003      float res = 1000;      float res = 1000;
1004      if( init__pfa == 0 )res = riseta_(&view,&angle);      if     ( init__pfa == 0 )res = riseta_(&view,&angle);
1005        else if( init__pfa == 5 )res = riseta_(&view,&angle);
1006      else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl;      else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl;
1007      return res;      return res;
1008  }  }
1009    
1010    /**
1011     * Returns the number of angular bins for p.f.a. parameters
1012     */
1013    int TrkParams::GetPFA_NbinsAngle(){
1014        TrkParams::Load(4);
1015        if( !TrkParams::IsLoaded(4) ){
1016            cout << "int TrkParams::GetPFA_NbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1017            return 0;
1018        }
1019        return pfa_.nangbin;
1020    };
1021    /**
1022     * Returns the number of eta bins for p.f.a. parameters
1023     */
1024    int TrkParams::GetPFA_NbinsETA(){
1025        TrkParams::Load(4);
1026        if( !TrkParams::IsLoaded(4) ){
1027            cout << "int TrkParams::GetPFA_NbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1028            return 0;
1029        }
1030        return pfa_.netaval;
1031    };
1032    
1033    /**
1034     * Returns the pointer to a vector ( of size TrkParams::GetPFA_NbinsETA() ),
1035     * with eta-correction values for each eta bin.
1036     * Bin extremes are given by float* TrkParams::GetPFA_ETAabs(pfa,int).
1037     *
1038     * @param pfa "ETA2","ETA3" or "ETA4"
1039     * @param nview View number (0-11)
1040     * @param nladder Ladder number (0-2)
1041     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1042     *
1043     * NB! the vector must be deallocated!
1044     * delete [] vname;
1045     */
1046    float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang){
1047    
1048        TrkParams::Load(4);
1049        if( !TrkParams::IsLoaded(4) ){
1050            cout << "float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1051            return 0;
1052        }
1053      
1054        int nbins = GetPFA_NbinsETA();
1055        if(!nbins)return 0;
1056    
1057        if( nview   <   0 ||
1058            nview   >= 12 ||
1059            nladder <   0 ||
1060            nladder >=  3 ||
1061            nang    <   0 ||
1062            nang    >=  GetPFA_NbinsAngle() ||
1063            false)return 0;
1064    
1065         float *fcorr = new float [nbins];
1066    //    float fcorr[nbins];
1067    
1068        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
1069            for(int ib=0; ib<nbins; ib++){
1070                fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
1071    //          cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
1072            }
1073        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
1074            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
1075        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
1076            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
1077        }else{
1078            cout << "float* TrkParams::GetPFA_ETAcorr("<<pfa<<",...) ---  pfa parameters not implemented "<<endl;
1079            return 0;
1080        }    
1081    
1082        return fcorr;
1083    
1084    };
1085    
1086    /**
1087     * Returns the pointer to a vector with eta-bin extremes (@see float* TrkParams::GetPFA_ETAcorr(TString,int,int,int)).
1088     *
1089     * @param pfa "ETA2","ETA3" or "ETA4"
1090     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1091     *
1092     * NB the vector must be deallocated
1093     * delete [] vname;
1094     */
1095    float* TrkParams::GetPFA_ETAabs(TString pfa, int nang){
1096      
1097        TrkParams::Load(4);
1098        if( !TrkParams::IsLoaded(4) ){
1099            cout << "float* TrkParams::GetPFA_ETAabs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1100            return 0;
1101        }
1102    
1103        int nbins = GetPFA_NbinsETA();
1104        if(!nbins)return 0;
1105    
1106        float *fcorr = new float [nbins];
1107    //    float fcorr[nbins];
1108        if( nang    <   0 ||
1109            nang    >=  GetPFA_NbinsAngle() ||
1110            false)return 0;
1111    
1112        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
1113            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
1114        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
1115            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
1116        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
1117            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
1118        }else{
1119            cout << "float* TrkParams::GetPFA_ETAabs("<<pfa<<",...) ---  pfa parameters not implemented "<<endl;
1120            return 0;
1121        }    
1122    
1123        return fcorr;
1124    
1125    };
1126    /**
1127     * Returns the "Landi-correction".
1128     *
1129     * @param nview View number (0-11)
1130     * @param nladder Ladder number (0-2)
1131     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1132     */
1133    float TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang){
1134    
1135    //     TrkParams::Load(4);
1136    //     if( !TrkParams::IsLoaded(4) ){
1137    //      cout << "float* TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1138    //      return 0;
1139    //     }
1140        int nbins = GetPFA_NbinsAngle();
1141        if(!nbins)return 0;
1142    
1143        if( nview   <   0 ||
1144            nview   >= 12 ||
1145            nladder <   0 ||
1146            nladder >=  3 ||
1147            nang    <   0 ||
1148            nang    >=  nbins ||
1149            false)return 0;
1150      
1151    
1152        return pfa_.fcorr[nang][nladder][nview];
1153    
1154    };
1155    
1156    /**
1157     * Returns the index (0, n.bin-1) of the angular bin for pfa parameters
1158     * @param angle Effective angle (deg)
1159     */
1160    int TrkParams::GetPFA_AngleBin(float angle){
1161        
1162        int nangbin = TrkParams::GetPFA_NbinsAngle();
1163        int istart = (int)(nangbin/2);
1164        int idbin = -1;
1165    //    cout << angle <<" ??" << endl;
1166        if( angle > pfa_.angR[istart] ){
1167            idbin = nangbin-1;
1168            for(int id=istart+1; id<nangbin; id++ ){
1169    //          cout << id << endl;
1170                if( pfa_.angR[id] >= angle ){
1171                    idbin = id;
1172                    break;
1173                }
1174            }
1175        }else{
1176            idbin = 0;
1177            for(int id=istart; id>=0; id-- ){
1178    //          cout << id << endl;
1179                if( pfa_.angL[id] < angle ){
1180                    idbin = id;
1181                    break;
1182                }
1183            }
1184    
1185        }
1186    //    cout << ">>> "<<idbin<<" "<<pfa_.angL[idbin]<<" "<<pfa_.angR[idbin]<<endl;
1187        return idbin;
1188    }
1189    
1190    
1191    

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

  ViewVC Help
Powered by ViewVC 1.1.23