/[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.15 by pam-fi, Fri Aug 31 15:00:10 2007 UTC revision 1.21 by pam-fi, Wed Mar 5 17:00:19 2008 UTC
# Line 35  int    TrkParams::init__mini_istepmin  = Line 35  int    TrkParams::init__mini_istepmin  =
35  double TrkParams::init__mini_fact      = 1.e4; //100.;  double TrkParams::init__mini_fact      = 1.e4; //100.;
36  float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};  float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};
37  float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};  float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};
38    double TrkParams::init__deltab_0       = 0.;
39    double TrkParams::init__deltab_1       = 0.;
40    double TrkParams::init__dlt            = 1.e-5;
41    // ------------------------------------------
42    // nominal z-coordinates to define acceptance
43    // ------------------------------------------
44    int   TrkParams::nGF   = NGF;
45    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};
46    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};
47    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};
48    // 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};
49    // 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};
50    // per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa
51    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};
52    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};
53    TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"};
54    
55  TrkParams::TrkParams(){  TrkParams::TrkParams(){
56    
# Line 54  float anint(float f){ Line 70  float anint(float f){
70      ret1=(float)ret;      ret1=(float)ret;
71      return ret1;              return ret1;        
72  }  }
73    
74    /**
75     * Static method to open a DB connection.
76     * HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST,
77     * $PAM_DBUSER and $PAM_DBPSW
78     * NB! The method create a new connection, which has to be closed by the user.
79     */
80    TSQLServer* TrkParams::SetDBConnection(){
81    
82        TString host = "mysql://localhost/pamelaprod";
83        TString user = "anonymous";
84        TString psw = "";
85        const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
86        const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
87        const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
88        if ( !pamdbhost ) pamdbhost = "";
89        if ( !pamdbuser ) pamdbuser = "";
90        if ( !pamdbpsw ) pamdbpsw = "";
91        if ( strcmp(pamdbhost,"") ) host = pamdbhost;
92        if ( strcmp(pamdbuser,"") ) user = pamdbuser;
93        if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
94        if(TrkParams::VerboseMode()){
95            cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
96            cout<<"Connecting to DB"<<endl;
97            cout<<"HOST "<<host<<endl;
98            cout<<"USER "<<user<<endl;
99            cout<<"PSW  "<<psw<<endl;
100        }
101        TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
102        if( !dbc )return NULL;
103        if( !dbc->IsConnected() )return NULL;    
104        stringstream myquery;  // EMILIANO
105        myquery.str("");  // EMILIANO
106        myquery << "SET time_zone='+0:00'";  // EMILIANO
107        dbc->Query(myquery.str().c_str());  // EMILIANO
108        if(TrkParams::VerboseMode()){
109            cout << " ...done"<<endl;
110            cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
111        }
112        
113        return dbc;
114    }
115  /**  /**
116   * \brief Static method to set the calibration to be loaded.   * \brief Static method to set the calibration to be loaded.
117    
# Line 73  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 131  Bool_t TrkParams::SetCalib( GL_RUN *glru
131          glrun->RUNHEADER_TIME > calib.TO_TIME     ||          glrun->RUNHEADER_TIME > calib.TO_TIME     ||
132          false ){          false ){
133    
 //      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;  
 //          }  
 //      }  
134    
135          GL_TRK_CALIB q2;          GL_TRK_CALIB q2;
136          GL_ROOT q3;          GL_ROOT q3;
137          GL_PARAM q4;          GL_PARAM q4;
138    
139    
140            bool LOCAL_CONNECTION = false;
141            if( !dbc || (dbc && !dbc->IsConnected()) ){
142    
143                if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
144                dbc = TrkParams::SetDBConnection();
145                if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
146    
147            }
148    
149                    
150          if(TrkParams::VerboseMode()){          if(TrkParams::VerboseMode()){
151              cout << "--------------------------------------"<<endl;              cout << "--------------------------------------"<<endl;
# Line 138  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 172  Bool_t TrkParams::SetCalib( GL_RUN *glru
172              calibpatht = q4.PATH + q4.NAME;              calibpatht = q4.PATH + q4.NAME;
173          }          }
174                    
175            if(LOCAL_CONNECTION){
176                dbc->Close();
177                delete dbc;
178            }
179    
180  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
181          return true;          return true;
# Line 576  Bool_t TrkParams::LoadCalib( ){ Line 614  Bool_t TrkParams::LoadCalib( ){
614          cout << " - full+truncated parameters "<<endl;          cout << " - full+truncated parameters "<<endl;
615      }      }
616      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
617      if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;      if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl;
618      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
619    
620      // =============================================================      // =============================================================
# Line 616  Int_t TrkParams::GetIndex( UInt_t type ) Line 654  Int_t TrkParams::GetIndex( UInt_t type )
654   * @param dbc   Database   * @param dbc   Database
655   * @param type  Parameter type   * @param type  Parameter type
656   * @return FALSE if parameter set fails.   * @return FALSE if parameter set fails.
657   * 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.
658   * If dbc==NULL, try to open a connection taking DB-connection   * If dbc==NULL, try to open a connection taking DB-connection
659   * parameters from PAMELA environment variables.   * parameters from PAMELA environment variables.
660   */   */
# Line 626  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 664  Bool_t TrkParams::Set( GL_RUN* glrun , T
664      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
665      if(index < 0)return false;      if(index < 0)return false;
666    
667        UInt_t runheadtime=0;
668        UInt_t runid=0;
669    //    UInt_t runheadtime = numeric_limits<UInt_t>::max();
670        if(glrun){
671            runheadtime = glrun->RUNHEADER_TIME;
672            runid       = glrun->ID;
673        }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
674    
675    //    if(TrkParams::VerboseMode())
676        if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
677    
678    
679      if( !TrkParams::IsLoaded(type) ||      if( !TrkParams::IsLoaded(type) ||
680          glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||          runheadtime < gl[index].FROM_TIME   ||
681          glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||                  runheadtime > gl[index].TO_TIME     ||  
682          false ){          false ){
683    
684            bool LOCAL_CONNECTION = false;
685          if( !dbc || (dbc && !dbc->IsConnected()) ){          if( !dbc || (dbc && !dbc->IsConnected()) ){
686    
687              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
688              TString host = "mysql://localhost/pamelaprod";              dbc = TrkParams::SetDBConnection();
689              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;  
             }  
         }  
690    
691            }
         UInt_t runheadtime = numeric_limits<UInt_t>::max();  
         if(glrun)runheadtime = glrun->RUNHEADER_TIME;  
         else cout <<"Missing run info -- taking last entry "<<endl;  
692    
693          GL_PARAM q4;          GL_PARAM q4;
694          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;      
695            if(LOCAL_CONNECTION){
696                dbc->Close();
697                delete dbc;
698            }
699          gl[index]     = q4;          gl[index]     = q4;
700          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
701          glload[index] = false;          glload[index] = false;
702          if(TrkParams::VerboseMode())  
             cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<glrun->ID<<endl;  
703          return true;          return true;
704    
705      }      }
# Line 711  Bool_t TrkParams::Set( TString path , UI Line 736  Bool_t TrkParams::Set( TString path , UI
736   */   */
737  Bool_t TrkParams::Set(UInt_t type){  Bool_t TrkParams::Set(UInt_t type){
738    
     UInt_t index = TrkParams::GetIndex( type );  
     if(index < 0)return false;  
739    
740      gl[index].TYPE= type;      return Set(0,0,type);
     glload[index] = false;  
741    
     // -----------------------------------------  
     // 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;  
742    
743  };  };
744  /**  /**
# Line 767  Bool_t TrkParams::Set(UInt_t type){ Line 749  Bool_t TrkParams::Set(UInt_t type){
749   */   */
750  Bool_t  TrkParams::Set( ){  Bool_t  TrkParams::Set( ){
751    
     Bool_t connected = false;  
752    
753  //    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;  
754    
755      return true;      return true;
756  }  }
# Line 940  float TrkParams::GetBZ(float* v){ Line 893  float TrkParams::GetBZ(float* v){
893  }  }
894    
895    
   
896  /**  /**
897   * \brief Set tracking mode (0=standard. 1=???)   * \brief Set tracking mode (0=standard. 1=???)
898   */   */
899  void TrkParams::SetTrackingMode(int trackmode) {  void TrkParams::SetTrackingMode(int trackmode) {
900      init__mini_trackmode = trackmode;      init__mini_trackmode = trackmode;
901      SetTrackingMode();      SetTrackingMode(); //fill F77 common
902  };  };
903  /**  /**
904   * \brief Set fit-precision factor (typical value fact=100.)   * \brief Set fit-precision factor (typical value fact=100.)
905   */   */
906  void TrkParams::SetPrecisionFactor(double fact){  void TrkParams::SetPrecisionFactor(double fact){
907      init__mini_fact      = fact;      init__mini_fact      = fact;
908      SetPrecisionFactor();      SetPrecisionFactor(); //fill F77 common
909  };  };
910  /**  /**
911   * \brief Set minimum number of step in track fitting   * \brief Set minimum number of step in track fitting
912   */   */
913  void TrkParams::SetStepMin(int istepmin){  void TrkParams::SetStepMin(int istepmin){
914      init__mini_istepmin  = istepmin;      init__mini_istepmin  = istepmin;
915      SetStepMin();      SetStepMin(); //fill F77 common
916    };
917    /**
918     * \brief Set deltaB parameters (id=0,1)
919     */
920    void TrkParams::SetDeltaB(int id,double db){
921        if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl;
922        if(id==0)init__deltab_0 = db;
923        if(id==1)init__deltab_1 = db;
924        SetDeltaB(); //fill F77 common
925    };
926    /**
927     * \brief Set DLT-grkuta precision factor (default 1.e-4)
928     */
929    void TrkParams::SetDLT(double fact){
930        init__dlt               = fact;
931        SetDLT(); //fill F77 common
932  };  };
933    
934  /**  /**
935   * Fill F77 commons with PFA settings   * \brief Fill F77 commons with PFA settings
936   */   */
937  void TrkParams::SetPFA(){  void TrkParams::SetPFA(){
938      sw_.pfaid = init__pfa;          sw_.pfaid = init__pfa;    
# Line 991  void TrkParams::SetPFA(){ Line 959  void TrkParams::SetPFA(){
959   */   */
960  void TrkParams::SetPFA(int pfaid){  void TrkParams::SetPFA(int pfaid){
961      init__pfa  = pfaid;      init__pfa  = pfaid;
962      SetPFA();      SetPFA(); //fill F77 common
963  };  };
964  /**  /**
965   * \brief Set p.f.a. angular intervals   * \brief Set p.f.a. angular intervals
966   *   *
967   * 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
968   * 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)).
969   * @param v Pointer to a vector of 12 components, which represent the   * @param v Pointer to a vector of 12 components, which represent the
970   * 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.
971   *   *
# Line 1007  void TrkParams::SetPFA(float *v){ Line 975  void TrkParams::SetPFA(float *v){
975          init__pfa_e234ax[i]  = v[i];          init__pfa_e234ax[i]  = v[i];
976          init__pfa_e234ay[i]  = v[i+6];          init__pfa_e234ay[i]  = v[i+6];
977      }      }
978      SetPFA();      SetPFA(); //fill F77 common
979  };  };
980    
981    

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.23