/[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.12 by pam-fi, Mon Aug 20 16:07:15 2007 UTC revision 1.17 by mocchiut, Wed Oct 10 16:01:34 2007 UTC
# Line 28  Bool_t       TrkParams::glload[]       = Line 28  Bool_t       TrkParams::glload[]       =
28  // other parameters  // other parameters
29  // ----------------  // ----------------
30  cDbg   TrkParams::init__dbg_mode       = {0,0,0};  cDbg   TrkParams::init__dbg_mode       = {0,0,0};
31  int    TrkParams::init__pfa            = 14;//COG4  //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 623  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 626  Bool_t TrkParams::Set( GL_RUN* glrun , T
626      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
627      if(index < 0)return false;      if(index < 0)return false;
628    
629        UInt_t runheadtime=0;
630        UInt_t runid=0;
631    //    UInt_t runheadtime = numeric_limits<UInt_t>::max();
632        if(glrun){
633            runheadtime = glrun->RUNHEADER_TIME;
634            runid       = glrun->ID;
635        }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
636    
637    //    if(TrkParams::VerboseMode())
638        cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
639    
640    
641      if( !TrkParams::IsLoaded(type) ||      if( !TrkParams::IsLoaded(type) ||
642          glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||          runheadtime < gl[index].FROM_TIME   ||
643          glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||                  runheadtime > gl[index].TO_TIME     ||  
644          false ){          false ){
645    
646          if( !dbc || (dbc && !dbc->IsConnected()) ){          if( !dbc || (dbc && !dbc->IsConnected()) ){
# Line 653  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 668  Bool_t TrkParams::Set( GL_RUN* glrun , T
668              dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());              dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
669              if( !dbc )return false;              if( !dbc )return false;
670              if( !dbc->IsConnected() )return false;                  if( !dbc->IsConnected() )return false;    
671                stringstream myquery;  // EMILIANO
672                myquery.str("");  // EMILIANO
673                myquery << "SET time_zone='+0:00'";  // EMILIANO
674                dbc->Query(myquery.str().c_str());  // EMILIANO
675              if(TrkParams::VerboseMode()){              if(TrkParams::VerboseMode()){
676                  cout << " ...done"<<endl;                  cout << " ...done"<<endl;
677                  cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;                  cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
678              }              }
679          }          }
680    
   
         UInt_t runheadtime = numeric_limits<UInt_t>::max();  
         if(glrun)runheadtime = glrun->RUNHEADER_TIME;  
         else cout <<"Missing run info -- taking last entry "<<endl;  
   
681          GL_PARAM q4;          GL_PARAM q4;
682          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;
683    
684          gl[index]     = q4;          gl[index]     = q4;
685          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
686          glload[index] = false;          glload[index] = false;
687          if(TrkParams::VerboseMode())  
             cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<glrun->ID<<endl;  
688          return true;          return true;
689    
690      }      }
# Line 708  Bool_t TrkParams::Set( TString path , UI Line 721  Bool_t TrkParams::Set( TString path , UI
721   */   */
722  Bool_t TrkParams::Set(UInt_t type){  Bool_t TrkParams::Set(UInt_t type){
723    
     UInt_t index = TrkParams::GetIndex( type );  
     if(index < 0)return false;  
724    
725      gl[index].TYPE= type;      return Set(0,0,type);
726      glload[index] = false;  
727    //     UInt_t index = TrkParams::GetIndex( type );
728    //     if(index < 0)return false;
729    
730    //     gl[index].TYPE= type;
731    //     glload[index] = false;
732    
733      // -----------------------------------------  //     // -----------------------------------------
734      // check if enviroment variables are defined  //     // check if enviroment variables are defined
735      // -----------------------------------------  //     // -----------------------------------------
736      glpath[index] = gSystem->Getenv("PAM_CALIB");  //     glpath[index] = gSystem->Getenv("PAM_CALIB");
737    
738      if( !glpath[index].IsNull() ){  //     if( !glpath[index].IsNull() ){
739            
740          switch(type){  //      switch(type){
741          case 1:  //      case 1:
742              glpath[index].Append("/trk-param/field_param-0/");  //          glpath[index].Append("/trk-param/field_param-0/");
743              break;  //          break;
744          case 2:  //      case 2:
745              glpath[index].Append("/trk-param/mip_param-0/");  //          glpath[index].Append("/trk-param/mip_param-0/");
746              break;  //          break;
747          case 3:  //      case 3:
748              glpath[index].Append("/trk-param/charge_param-1/");  //          glpath[index].Append("/trk-param/charge_param-1/");
749              break;  //          break;
750          case 4:  //      case 4:
751              glpath[index].Append("/trk-param/eta_param-0/");  //          glpath[index].Append("/trk-param/eta_param-2/");
752              break;  //          break;
753          case 5:  //      case 5:
754              glpath[index].Append("/trk-param/align_param-0/");  //          glpath[index].Append("/trk-param/align_param-Q.A/");
755              break;  //          break;
756          case 6:  //      case 6:
757              glpath[index].Append("/trk-param/mask_param-1/");  //          glpath[index].Append("/trk-param/mask_param-1/");
758              break;  //          break;
759          case 7:  //      case 7:
760              glpath[index].Append("/trk-param/default_calib/");  //          glpath[index].Append("/trk-param/default_calib/");
761              break;  //          break;
762          }  //      }
763                    
764      }else{  //     }else{
765          cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl;  //      cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl;
766          return false;  //      return false;
767                    
768      }  //     }
769    
770      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl;  // //    if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >>"<<endl;
771  //    return TrkParams::Load(type);  //     cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >>  **WARNING** does not use DB info !!!!"<<endl;
772      return true;  
773    // //    return TrkParams::Load(type);
774    //     return true;
775    
776  };  };
777  /**  /**
# Line 764  Bool_t TrkParams::Set(UInt_t type){ Line 782  Bool_t TrkParams::Set(UInt_t type){
782   */   */
783  Bool_t  TrkParams::Set( ){  Bool_t  TrkParams::Set( ){
784    
785      Bool_t connected = false;  //    Bool_t connected = false;
   
786  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
787      TString host = "mysql://localhost/pamelaprod";  //     TString host = "mysql://localhost/pamelaprod";
788      TString user = "anonymous";  //     TString user = "anonymous";
789      TString psw = "";  //     TString psw = "";
790      const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");  //     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
791      const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");  //     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
792      const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");  //     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
793      if ( !pamdbhost ) pamdbhost = "";  //     if ( !pamdbhost ) pamdbhost = "";
794      if ( !pamdbuser ) pamdbuser = "";  //     if ( !pamdbuser ) pamdbuser = "";
795      if ( !pamdbpsw ) pamdbpsw = "";  //     if ( !pamdbpsw ) pamdbpsw = "";
796      if ( strcmp(pamdbhost,"") ) host = pamdbhost;  //     if ( strcmp(pamdbhost,"") ) host = pamdbhost;
797      if ( strcmp(pamdbuser,"") ) user = pamdbuser;  //     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
798      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;  //     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
799      if(TrkParams::VerboseMode()){  //     if(TrkParams::VerboseMode()){
800          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  //      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
801          cout<<"Connecting to DB"<<endl;  //      cout<<"Connecting to DB"<<endl;
802          cout<<"HOST "<<host<<endl;  //      cout<<"HOST "<<host<<endl;
803          cout<<"USER "<<user<<endl;  //      cout<<"USER "<<user<<endl;
804          cout<<"PSW  "<<psw<<endl;  //      cout<<"PSW  "<<psw<<endl;
805      }  //     }
806      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  //     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
807      if( dbc || dbc->IsConnected() )connected = true;  //     if( dbc || dbc->IsConnected() )connected = true;
808      else cout << " >> DB connection FAILED!!!"<<endl;  //     else cout << " >> DB connection FAILED!!!"<<endl;
809      if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  //     if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
810            
811      if(connected){  //     if(connected){
812          if ( !TrkParams::Set(0,dbc) )return false;  //      if ( !TrkParams::Set(0,dbc) )return false;
813          dbc->Close();  //      dbc->Close();
814      }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;  //     }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;
815    
816        for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;
817    
818      return true;      return true;
819  }  }
# Line 961  void TrkParams::SetStepMin(int istepmin) Line 980  void TrkParams::SetStepMin(int istepmin)
980  };  };
981    
982  /**  /**
983     * Fill F77 commons with PFA settings
984     */
985    void TrkParams::SetPFA(){
986        sw_.pfaid = init__pfa;    
987        for(int i=0; i<6; i++){
988            pfa_.e234ax[i] = init__pfa_e234ax[i];
989            pfa_.e234ay[i] = init__pfa_e234ay[i];
990        }
991    };
992    /**
993   * \brief Set p.f.a.   * \brief Set p.f.a.
994   *   *
995   * Implemented algorythms:   * Implemented algorythms:
# Line 981  void TrkParams::SetPFA(int pfaid){ Line 1010  void TrkParams::SetPFA(int pfaid){
1010      SetPFA();      SetPFA();
1011  };  };
1012  /**  /**
1013     * \brief Set p.f.a. angular intervals
1014     *
1015     * This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4
1016     * algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)).
1017     * @param v Pointer to a vector of 12 components, which represent the
1018     * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly.
1019     *
1020     */
1021    void TrkParams::SetPFA(float *v){
1022        for(int i=0; i<6; i++){
1023            init__pfa_e234ax[i]  = v[i];
1024            init__pfa_e234ay[i]  = v[i+6];
1025        }
1026        SetPFA();
1027    };
1028    
1029    
1030    /**
1031   * \brief Get spatial resolution.   * \brief Get spatial resolution.
1032   *   *
1033   * Method to retrieve the spatial resolution associated with the   * Method to retrieve the spatial resolution associated with the
# Line 1002  float TrkParams::GetResolution(int view, Line 1049  float TrkParams::GetResolution(int view,
1049    
1050    
1051    
1052    
1053  ClassImp(TrkParams);  ClassImp(TrkParams);

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.23