/[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.16 by pam-fi, Tue Oct 9 15:54:37 2007 UTC
# Line 626  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 662  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 674  Bool_t TrkParams::Set( GL_RUN* glrun , T
674              }              }
675          }          }
676    
   
         UInt_t runheadtime = numeric_limits<UInt_t>::max();  
         if(glrun)runheadtime = glrun->RUNHEADER_TIME;  
         else cout <<"Missing run info -- taking last entry "<<endl;  
   
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    
680          gl[index]     = q4;          gl[index]     = q4;
681          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
682          glload[index] = false;          glload[index] = false;
683          if(TrkParams::VerboseMode())  
             cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<glrun->ID<<endl;  
684          return true;          return true;
685    
686      }      }
# Line 711  Bool_t TrkParams::Set( TString path , UI Line 717  Bool_t TrkParams::Set( TString path , UI
717   */   */
718  Bool_t TrkParams::Set(UInt_t type){  Bool_t TrkParams::Set(UInt_t type){
719    
     UInt_t index = TrkParams::GetIndex( type );  
     if(index < 0)return false;  
720    
721      gl[index].TYPE= type;      return Set(0,0,type);
     glload[index] = false;  
722    
723      // -----------------------------------------  //     UInt_t index = TrkParams::GetIndex( type );
724      // check if enviroment variables are defined  //     if(index < 0)return false;
     // -----------------------------------------  
     glpath[index] = gSystem->Getenv("PAM_CALIB");  
725    
726      if( !glpath[index].IsNull() ){  //     gl[index].TYPE= type;
727    //     glload[index] = false;
728    
729    //     // -----------------------------------------
730    //     // check if enviroment variables are defined
731    //     // -----------------------------------------
732    //     glpath[index] = gSystem->Getenv("PAM_CALIB");
733    
734    //     if( !glpath[index].IsNull() ){
735            
736          switch(type){  //      switch(type){
737          case 1:  //      case 1:
738              glpath[index].Append("/trk-param/field_param-0/");  //          glpath[index].Append("/trk-param/field_param-0/");
739              break;  //          break;
740          case 2:  //      case 2:
741              glpath[index].Append("/trk-param/mip_param-0/");  //          glpath[index].Append("/trk-param/mip_param-0/");
742              break;  //          break;
743          case 3:  //      case 3:
744              glpath[index].Append("/trk-param/charge_param-1/");  //          glpath[index].Append("/trk-param/charge_param-1/");
745              break;  //          break;
746          case 4:  //      case 4:
747              glpath[index].Append("/trk-param/eta_param-0/");  //          glpath[index].Append("/trk-param/eta_param-2/");
748              break;  //          break;
749          case 5:  //      case 5:
750              glpath[index].Append("/trk-param/align_param-0/");  //          glpath[index].Append("/trk-param/align_param-Q.A/");
751              break;  //          break;
752          case 6:  //      case 6:
753              glpath[index].Append("/trk-param/mask_param-1/");  //          glpath[index].Append("/trk-param/mask_param-1/");
754              break;  //          break;
755          case 7:  //      case 7:
756              glpath[index].Append("/trk-param/default_calib/");  //          glpath[index].Append("/trk-param/default_calib/");
757              break;  //          break;
758          }  //      }
759                    
760      }else{  //     }else{
761          cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl;  //      cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl;
762          return false;  //      return false;
763                    
764      }  //     }
765    
766      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;
767  //    return TrkParams::Load(type);  //     cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >>  **WARNING** does not use DB info !!!!"<<endl;
768      return true;  
769    // //    return TrkParams::Load(type);
770    //     return true;
771    
772  };  };
773  /**  /**
# Line 767  Bool_t TrkParams::Set(UInt_t type){ Line 778  Bool_t TrkParams::Set(UInt_t type){
778   */   */
779  Bool_t  TrkParams::Set( ){  Bool_t  TrkParams::Set( ){
780    
781      Bool_t connected = false;  //    Bool_t connected = false;
   
782  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
783      TString host = "mysql://localhost/pamelaprod";  //     TString host = "mysql://localhost/pamelaprod";
784      TString user = "anonymous";  //     TString user = "anonymous";
785      TString psw = "";  //     TString psw = "";
786      const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");  //     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
787      const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");  //     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
788      const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");  //     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
789      if ( !pamdbhost ) pamdbhost = "";  //     if ( !pamdbhost ) pamdbhost = "";
790      if ( !pamdbuser ) pamdbuser = "";  //     if ( !pamdbuser ) pamdbuser = "";
791      if ( !pamdbpsw ) pamdbpsw = "";  //     if ( !pamdbpsw ) pamdbpsw = "";
792      if ( strcmp(pamdbhost,"") ) host = pamdbhost;  //     if ( strcmp(pamdbhost,"") ) host = pamdbhost;
793      if ( strcmp(pamdbuser,"") ) user = pamdbuser;  //     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
794      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;  //     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
795      if(TrkParams::VerboseMode()){  //     if(TrkParams::VerboseMode()){
796          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  //      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
797          cout<<"Connecting to DB"<<endl;  //      cout<<"Connecting to DB"<<endl;
798          cout<<"HOST "<<host<<endl;  //      cout<<"HOST "<<host<<endl;
799          cout<<"USER "<<user<<endl;  //      cout<<"USER "<<user<<endl;
800          cout<<"PSW  "<<psw<<endl;  //      cout<<"PSW  "<<psw<<endl;
801      }  //     }
802      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  //     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
803      if( dbc || dbc->IsConnected() )connected = true;  //     if( dbc || dbc->IsConnected() )connected = true;
804      else cout << " >> DB connection FAILED!!!"<<endl;  //     else cout << " >> DB connection FAILED!!!"<<endl;
805      if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  //     if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
806            
807      if(connected){  //     if(connected){
808          if ( !TrkParams::Set(0,dbc) )return false;  //      if ( !TrkParams::Set(0,dbc) )return false;
809          dbc->Close();  //      dbc->Close();
810      }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;
811    
812        for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;
813    
814      return true;      return true;
815  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.23