/[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.11 by pam-fi, Fri Aug 17 14:36:05 2007 UTC revision 1.18 by pam-fi, Wed Nov 7 10:38:52 2007 UTC
# Line 24  UInt_t       TrkParams::trkparamtype[] = Line 24  UInt_t       TrkParams::trkparamtype[] =
24  GL_PARAM     TrkParams::gl[]           = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()};  GL_PARAM     TrkParams::gl[]           = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()};
25  TString      TrkParams::glpath[]       = {"","","","","","",""};  TString      TrkParams::glpath[]       = {"","","","","","",""};
26  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};
 cDbg         TrkParams::dbg_mode       = {0,0,0};  
27  // ----------------  // ----------------
28  // other parameters  // other parameters
29  // ----------------  // ----------------
30  int    TrkParams::init__pfa            = 14;//COG4  cDbg   TrkParams::init__dbg_mode       = {0,0,0};
31    //int    TrkParams::init__pfa            = 14;//COG4
32    int    TrkParams::init__pfa            = 5;//ETAL
33  int    TrkParams::init__mini_trackmode = 0;  int    TrkParams::init__mini_trackmode = 0;
34  int    TrkParams::init__mini_istepmin  = 3;  int    TrkParams::init__mini_istepmin  = 5; //3;
35  double TrkParams::init__mini_fact      = 100.;  double TrkParams::init__mini_fact      = 1.e4; //100.;
36    float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};
37    float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};
38    
39  TrkParams::TrkParams(){  TrkParams::TrkParams(){
40    
# Line 51  float anint(float f){ Line 54  float anint(float f){
54      ret1=(float)ret;      ret1=(float)ret;
55      return ret1;              return ret1;        
56  }  }
57    
58    /**
59     * Static method to open a DB connection.
60     * HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST,
61     * $PAM_DBUSER and $PAM_DBPSW
62     * NB! The method create a new connection, which has to be closed by the user.
63     */
64    TSQLServer* TrkParams::SetDBConnection(){
65    
66        TString host = "mysql://localhost/pamelaprod";
67        TString user = "anonymous";
68        TString psw = "";
69        const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
70        const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
71        const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
72        if ( !pamdbhost ) pamdbhost = "";
73        if ( !pamdbuser ) pamdbuser = "";
74        if ( !pamdbpsw ) pamdbpsw = "";
75        if ( strcmp(pamdbhost,"") ) host = pamdbhost;
76        if ( strcmp(pamdbuser,"") ) user = pamdbuser;
77        if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
78        if(TrkParams::VerboseMode()){
79            cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
80            cout<<"Connecting to DB"<<endl;
81            cout<<"HOST "<<host<<endl;
82            cout<<"USER "<<user<<endl;
83            cout<<"PSW  "<<psw<<endl;
84        }
85        TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
86        if( !dbc )return NULL;
87        if( !dbc->IsConnected() )return NULL;    
88        stringstream myquery;  // EMILIANO
89        myquery.str("");  // EMILIANO
90        myquery << "SET time_zone='+0:00'";  // EMILIANO
91        dbc->Query(myquery.str().c_str());  // EMILIANO
92        if(TrkParams::VerboseMode()){
93            cout << " ...done"<<endl;
94            cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
95        }
96        
97        return dbc;
98    }
99  /**  /**
100   * \brief Static method to set the calibration to be loaded.   * \brief Static method to set the calibration to be loaded.
101    
# Line 70  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 115  Bool_t TrkParams::SetCalib( GL_RUN *glru
115          glrun->RUNHEADER_TIME > calib.TO_TIME     ||          glrun->RUNHEADER_TIME > calib.TO_TIME     ||
116          false ){          false ){
117    
 //      cout <<">>> isloaded?      "<< CalibIsLoaded() << endl;  
 //      cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl;  
 //      cout <<">>> 104 loaded?    "<< calib104 <<endl;  
 //      cout <<">>> from time      "<< calib.FROM_TIME<<endl;  
 //      cout <<">>> to time        "<< calib.TO_TIME<<endl;  
 //      if( !dbc || (dbc && !dbc->IsConnected()) ){  
   
 //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  
 //          TString host = "mysql://localhost/pamelaprod";  
 //          TString user = "anonymous";  
 //          TString psw = "";  
 //          const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");  
 //          const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");  
 //          const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");  
 //          if ( !pamdbhost ) pamdbhost = "";  
 //          if ( !pamdbuser ) pamdbuser = "";  
 //          if ( !pamdbpsw ) pamdbpsw = "";  
 //          if ( strcmp(pamdbhost,"") ) host = pamdbhost;  
 //          if ( strcmp(pamdbuser,"") ) user = pamdbuser;  
 //          if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;  
 //          if(TrkParams::VerboseMode()){  
 //              cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
 //              cout<<"Connecting to DB"<<endl;  
 //              cout<<"HOST "<<host<<endl;  
 //              cout<<"USER "<<user<<endl;  
 //              cout<<"PSW  "<<psw<<endl;  
 //          }  
 //          dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  
 //          if( !dbc )return false;  
 //          if( !dbc->IsConnected() )return false;      
 //          if(TrkParams::VerboseMode()){  
 //              cout << " ...done"<<endl;  
 //              cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
 //          }  
 //      }  
118    
119          GL_TRK_CALIB q2;          GL_TRK_CALIB q2;
120          GL_ROOT q3;          GL_ROOT q3;
121          GL_PARAM q4;          GL_PARAM q4;
122    
123    
124            bool LOCAL_CONNECTION = false;
125            if( !dbc || (dbc && !dbc->IsConnected()) ){
126    
127                if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
128                dbc = TrkParams::SetDBConnection();
129                if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
130    
131            }
132    
133                    
134          if(TrkParams::VerboseMode()){          if(TrkParams::VerboseMode()){
135              cout << "--------------------------------------"<<endl;              cout << "--------------------------------------"<<endl;
# Line 135  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 156  Bool_t TrkParams::SetCalib( GL_RUN *glru
156              calibpatht = q4.PATH + q4.NAME;              calibpatht = q4.PATH + q4.NAME;
157          }          }
158                    
159            if(LOCAL_CONNECTION){
160                dbc->Close();
161                delete dbc;
162            }
163    
164  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
165          return true;          return true;
# Line 613  Int_t TrkParams::GetIndex( UInt_t type ) Line 638  Int_t TrkParams::GetIndex( UInt_t type )
638   * @param dbc   Database   * @param dbc   Database
639   * @param type  Parameter type   * @param type  Parameter type
640   * @return FALSE if parameter set fails.   * @return FALSE if parameter set fails.
641   * If glrun==NULL the last parameter entry from GL_PARAM table is set.   * If glrun==NULL the first parameter entry from GL_PARAM table is set.
642   * If dbc==NULL, try to open a connection taking DB-connection   * If dbc==NULL, try to open a connection taking DB-connection
643   * parameters from PAMELA environment variables.   * parameters from PAMELA environment variables.
644   */   */
# Line 623  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 648  Bool_t TrkParams::Set( GL_RUN* glrun , T
648      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
649      if(index < 0)return false;      if(index < 0)return false;
650    
651        UInt_t runheadtime=0;
652        UInt_t runid=0;
653    //    UInt_t runheadtime = numeric_limits<UInt_t>::max();
654        if(glrun){
655            runheadtime = glrun->RUNHEADER_TIME;
656            runid       = glrun->ID;
657        }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
658    
659    //    if(TrkParams::VerboseMode())
660        cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
661    
662    
663      if( !TrkParams::IsLoaded(type) ||      if( !TrkParams::IsLoaded(type) ||
664          glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||          runheadtime < gl[index].FROM_TIME   ||
665          glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||                  runheadtime > gl[index].TO_TIME     ||  
666          false ){          false ){
667    
668            bool LOCAL_CONNECTION = false;
669          if( !dbc || (dbc && !dbc->IsConnected()) ){          if( !dbc || (dbc && !dbc->IsConnected()) ){
670    
671              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
672              TString host = "mysql://localhost/pamelaprod";              dbc = TrkParams::SetDBConnection();
673              TString user = "anonymous";              if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
             TString psw = "";  
             const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");  
             const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");  
             const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");  
             if ( !pamdbhost ) pamdbhost = "";  
             if ( !pamdbuser ) pamdbuser = "";  
             if ( !pamdbpsw ) pamdbpsw = "";  
             if ( strcmp(pamdbhost,"") ) host = pamdbhost;  
             if ( strcmp(pamdbuser,"") ) user = pamdbuser;  
             if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;  
             if(TrkParams::VerboseMode()){  
                 cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
                 cout<<"Connecting to DB"<<endl;  
                 cout<<"HOST "<<host<<endl;  
                 cout<<"USER "<<user<<endl;  
                 cout<<"PSW  "<<psw<<endl;  
             }  
             dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  
             if( !dbc )return false;  
             if( !dbc->IsConnected() )return false;      
             if(TrkParams::VerboseMode()){  
                 cout << " ...done"<<endl;  
                 cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
             }  
         }  
674    
675            }
         UInt_t runheadtime = numeric_limits<UInt_t>::max();  
         if(glrun)runheadtime = glrun->RUNHEADER_TIME;  
         else cout <<"Missing run info -- taking last entry "<<endl;  
676    
677          GL_PARAM q4;          GL_PARAM q4;
678          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;      
679            if(LOCAL_CONNECTION){
680                dbc->Close();
681                delete dbc;
682            }
683          gl[index]     = q4;          gl[index]     = q4;
684          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
685          glload[index] = false;          glload[index] = false;
686          if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl;  
687          return true;          return true;
688    
689      }      }
# Line 690  Bool_t TrkParams::Set( TString path , UI Line 703  Bool_t TrkParams::Set( TString path , UI
703    
704      gl[index].TYPE= type;      gl[index].TYPE= type;
705      glpath[index] = path;      glpath[index] = path;
706      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl;      if(TrkParams::VerboseMode())
707            cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl;
708      glload[index] = false;      glload[index] = false;
709    
710  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
# Line 706  Bool_t TrkParams::Set( TString path , UI Line 720  Bool_t TrkParams::Set( TString path , UI
720   */   */
721  Bool_t TrkParams::Set(UInt_t type){  Bool_t TrkParams::Set(UInt_t type){
722    
     UInt_t index = TrkParams::GetIndex( type );  
     if(index < 0)return false;  
723    
724      gl[index].TYPE= type;      return Set(0,0,type);
     glload[index] = false;  
725    
     // -----------------------------------------  
     // check if enviroment variables are defined  
     // -----------------------------------------  
     glpath[index] = gSystem->Getenv("PAM_CALIB");  
   
     if( !glpath[index].IsNull() ){  
       
         switch(type){  
         case 1:  
             glpath[index].Append("/trk-param/field_param-0/");  
             break;  
         case 2:  
             glpath[index].Append("/trk-param/mip_param-0/");  
             break;  
         case 3:  
             glpath[index].Append("/trk-param/charge_param-1/");  
             break;  
         case 4:  
             glpath[index].Append("/trk-param/eta_param-0/");  
             break;  
         case 5:  
             glpath[index].Append("/trk-param/align_param-0/");  
             break;  
         case 6:  
             glpath[index].Append("/trk-param/mask_param-1/");  
             break;  
         case 7:  
             glpath[index].Append("/trk-param/default_calib/");  
             break;  
         }  
           
     }else{  
         cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl;  
         return false;  
           
     }  
   
     if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl;  
 //    return TrkParams::Load(type);  
     return true;  
726    
727  };  };
728  /**  /**
# Line 762  Bool_t TrkParams::Set(UInt_t type){ Line 733  Bool_t TrkParams::Set(UInt_t type){
733   */   */
734  Bool_t  TrkParams::Set( ){  Bool_t  TrkParams::Set( ){
735    
     Bool_t connected = false;  
736    
737  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;      for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;
     TString host = "mysql://localhost/pamelaprod";  
     TString user = "anonymous";  
     TString psw = "";  
     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");  
     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");  
     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");  
     if ( !pamdbhost ) pamdbhost = "";  
     if ( !pamdbuser ) pamdbuser = "";  
     if ( !pamdbpsw ) pamdbpsw = "";  
     if ( strcmp(pamdbhost,"") ) host = pamdbhost;  
     if ( strcmp(pamdbuser,"") ) user = pamdbuser;  
     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;  
     if(TrkParams::VerboseMode()){  
         cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
         cout<<"Connecting to DB"<<endl;  
         cout<<"HOST "<<host<<endl;  
         cout<<"USER "<<user<<endl;  
         cout<<"PSW  "<<psw<<endl;  
     }  
     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  
     if( dbc || dbc->IsConnected() )connected = true;  
     else cout << " >> DB connection FAILED!!!"<<endl;  
     if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
       
     if(connected){  
         if ( !TrkParams::Set(0,dbc) )return false;  
         dbc->Close();  
     }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;  
738    
739      return true;      return true;
740  }  }
# Line 959  void TrkParams::SetStepMin(int istepmin) Line 901  void TrkParams::SetStepMin(int istepmin)
901  };  };
902    
903  /**  /**
904     * Fill F77 commons with PFA settings
905     */
906    void TrkParams::SetPFA(){
907        sw_.pfaid = init__pfa;    
908        for(int i=0; i<6; i++){
909            pfa_.e234ax[i] = init__pfa_e234ax[i];
910            pfa_.e234ay[i] = init__pfa_e234ay[i];
911        }
912    };
913    /**
914   * \brief Set p.f.a.   * \brief Set p.f.a.
915   *   *
916   * Implemented algorythms:   * Implemented algorythms:
# Line 979  void TrkParams::SetPFA(int pfaid){ Line 931  void TrkParams::SetPFA(int pfaid){
931      SetPFA();      SetPFA();
932  };  };
933  /**  /**
934     * \brief Set p.f.a. angular intervals
935     *
936     * This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4
937     * algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)).
938     * @param v Pointer to a vector of 12 components, which represent the
939     * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly.
940     *
941     */
942    void TrkParams::SetPFA(float *v){
943        for(int i=0; i<6; i++){
944            init__pfa_e234ax[i]  = v[i];
945            init__pfa_e234ay[i]  = v[i+6];
946        }
947        SetPFA();
948    };
949    
950    
951    /**
952   * \brief Get spatial resolution.   * \brief Get spatial resolution.
953   *   *
954   * Method to retrieve the spatial resolution associated with the   * Method to retrieve the spatial resolution associated with the
# Line 1000  float TrkParams::GetResolution(int view, Line 970  float TrkParams::GetResolution(int view,
970    
971    
972    
973    
974  ClassImp(TrkParams);  ClassImp(TrkParams);

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

  ViewVC Help
Powered by ViewVC 1.1.23