/[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.25 by pam-fi, Tue Nov 25 14:41:37 2008 UTC revision 1.30 by pam-fi, Thu Feb 27 11:24:43 2014 UTC
# Line 10  Line 10 
10  using namespace std;  using namespace std;
11    
12    
13    Bool_t TrkParams::simuflag = kFALSE;
14  // -------------------------  // -------------------------
15  // CALIBRATION (PED,SIG,BAD)  // CALIBRATION (PED,SIG,BAD)
16  // -------------------------  // -------------------------
# Line 74  float anint(float f){ Line 75  float anint(float f){
75      return ret1;              return ret1;        
76  }  }
77    
78    void TrkParams::SetSimuFlag(Bool_t flag){
79      simuflag = flag;
80    }
81    
82    Bool_t TrkParams::GetSimuFlag(){
83      return simuflag;
84    }
85    
86    
87  /**  /**
88   * Static method to open a DB connection.   * Static method to open a DB connection.
89   * HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST,   * HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST,
# Line 177  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 187  Bool_t TrkParams::SetCalib( GL_RUN *glru
187                    
188          if(LOCAL_CONNECTION&&dbc){          if(LOCAL_CONNECTION&&dbc){
189              dbc->Close();              dbc->Close();
190                delete dbc;
191              if(TrkParams::DebugMode()){              if(TrkParams::DebugMode()){
192                  cout << " DB connection closed."<<endl;                  cout << " DB connection closed."<<endl;
193              }                    }      
# Line 247  UInt_t TrkParams::ValidateTrkCalib( Cali Line 258  UInt_t TrkParams::ValidateTrkCalib( Cali
258  //  -------------------------------------------------  //  -------------------------------------------------
259      UInt_t build=0;      UInt_t build=0;
260      UInt_t base=0;      UInt_t base=0;
261      UInt_t mask=0;      //    UInt_t mask=0;// EM GCC 4.7
262      if(classname.Contains("CalibTrk1Event")){      if(classname.Contains("CalibTrk1Event")){
263          base=12;          base=12;
264          mask=0x03F000;          //      mask=0x03F000; // EM GCC 4.7
265      }      }
266      if(classname.Contains("CalibTrk2Event")){      if(classname.Contains("CalibTrk2Event")){
267          base=18;          base=18;
268          mask=0xFC0000;          //      mask=0xFC0000;  // EM GCC 4.7
269      }      }
270  //  -------------------------------------------------  //  -------------------------------------------------
271  //  Count number of packets and set build variable  //  Count number of packets and set build variable
# Line 348  void TrkParams::FillACalibFrom(TFile* f0 Line 359  void TrkParams::FillACalibFrom(TFile* f0
359  //     tr2->SetBranchAddress("CalibTrk2",&calibdata2);  //     tr2->SetBranchAddress("CalibTrk2",&calibdata2);
360      tr1->SetBranchAddress("CalibTrk1",calib1->GetPointerTo());      tr1->SetBranchAddress("CalibTrk1",calib1->GetPointerTo());
361      tr2->SetBranchAddress("CalibTrk2",calib2->GetPointerTo());      tr2->SetBranchAddress("CalibTrk2",calib2->GetPointerTo());
362      tr1->GetEntry(ev_reg1);      if ( tr1->GetEntry(ev_reg1) <= 0 ) throw -36;//EM
363      tr2->GetEntry(ev_reg2);      if ( tr2->GetEntry(ev_reg2) <= 0 ) throw -36;//EM
364      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
365    
366    
# Line 547  void TrkParams::FillMask(TFile* f0, Int_ Line 558  void TrkParams::FillMask(TFile* f0, Int_
558              //-------------------------              //-------------------------
559              tr = (TTree*)f0->Get("CalibTrk1");                tr = (TTree*)f0->Get("CalibTrk1");  
560              tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo());              tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo());
561              tr->GetEntry(ev_reg1);              if ( tr->GetEntry(ev_reg1) <= 0 ) throw -36;//EM
562          }          }
563          if(i==1){          if(i==1){
564              //-------------------------              //-------------------------
# Line 555  void TrkParams::FillMask(TFile* f0, Int_ Line 566  void TrkParams::FillMask(TFile* f0, Int_
566              //-------------------------              //-------------------------
567              tr = (TTree*)f0->Get("CalibTrk2");              tr = (TTree*)f0->Get("CalibTrk2");
568              tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo());              tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo());
569              tr->GetEntry(ev_reg2);              if ( tr->GetEntry(ev_reg2) <= 0 ) throw -36;
570          }          }
571          for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){          for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){
572              Int_t view   = calib->GetView(ipkt);              Int_t view   = calib->GetView(ipkt);
# Line 673  Int_t TrkParams::GetIndex( UInt_t type ) Line 684  Int_t TrkParams::GetIndex( UInt_t type )
684   * If dbc==NULL, try to open a connection taking DB-connection   * If dbc==NULL, try to open a connection taking DB-connection
685   * parameters from PAMELA environment variables.   * parameters from PAMELA environment variables.
686   */   */
687  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type, UInt_t abstime){
688    
689    
690      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
691      if(index < 0)return false;      if(index < 0)return false;
692    
693        if(TrkParams::VerboseMode())
694          cout <<"Calling Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ,UInt_t " <<abstime << " ) >> (**WARNING** check that this is all ok!! )"<<endl;
695    
696      UInt_t runheadtime=1;      UInt_t runheadtime=1;
697      UInt_t runid=0;      UInt_t runid=0;
# Line 687  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 700  Bool_t TrkParams::Set( GL_RUN* glrun , T
700          runheadtime = glrun->RUNHEADER_TIME;          runheadtime = glrun->RUNHEADER_TIME;
701          runid       = glrun->ID;          runid       = glrun->ID;
702      }else      }else
703          cout <<"Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ) >> GL_RUN==NULL -- taking first entry (**WARNING** check that this is ok!! )"<<endl;        cout <<"Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ,UInt_t " <<abstime << " ) >> GL_RUN==NULL -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
   
   
     if( !TrkParams::IsLoaded(type) ||  
         runheadtime < gl[index].FROM_TIME   ||  
         runheadtime > gl[index].TO_TIME     ||    
         false ){  
   
 //    if(TrkParams::VerboseMode())  
         if(TrkParams::DebugMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;  
   
         bool LOCAL_CONNECTION = false;  
         if( !dbc || (dbc && !dbc->IsConnected()) ){  
704    
 //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  
             dbc = TrkParams::SetDBConnection();  
             if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;  
   
         }  
705    
706          GL_PARAM q4;      if( !abstime || !simuflag ) abstime = runheadtime;// EM: if simu?
         if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;        
         if(LOCAL_CONNECTION){  
             dbc->Close();  
             delete dbc;  
             if(TrkParams::DebugMode()){  
                 cout << " DB connection closed."<<endl;  
             }        
         }  
         gl[index]     = q4;  
         glpath[index] = q4.PATH+q4.NAME;  
         glload[index] = false;  
707    
708          return true;      if(TrkParams::VerboseMode())
709          cout << "TrkParams::IsLoaded(type)=" << TrkParams::IsLoaded(type) << " abstime=" << abstime << " runheadtime=" << runheadtime << " gl[index].FROM_TIME=" << gl[index].FROM_TIME << " gl[index].TO_TIME=" << gl[index].TO_TIME << endl;
710    
711        if( !TrkParams::IsLoaded(type) ||
712            abstime < gl[index].FROM_TIME   ||
713            abstime > gl[index].TO_TIME     ||      
714            false ){
715          
716          if(TrkParams::VerboseMode())
717            cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
718          
719          bool LOCAL_CONNECTION = false;
720          if( !dbc || (dbc && !dbc->IsConnected()) ){
721            
722            //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
723            dbc = TrkParams::SetDBConnection();
724            if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
725            
726          }
727          
728          GL_PARAM q4;
729          //        if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;      
730          if( q4.Query_GL_PARAM(abstime,type,dbc) )return false;     //VALERIO  
731          if(LOCAL_CONNECTION){
732            dbc->Close();
733            delete dbc;
734            if(TrkParams::DebugMode()){
735              cout << " DB connection closed."<<endl;
736            }          
737          }
738          gl[index]     = q4;
739          glpath[index] = q4.PATH+q4.NAME;
740          glload[index] = false;
741          
742          //return true;
743          
744      }      }
745      return false;      return true;
746        
747  };  };
748  /**  /**
749   * Set tracker parameters proper for the run, from input.   * Set tracker parameters proper for the run, from input.
# Line 767  Bool_t TrkParams::Set(UInt_t type){ Line 786  Bool_t TrkParams::Set(UInt_t type){
786   * otherwise it set a default path.   * otherwise it set a default path.
787   * @return FALSE if parameter set fails.   * @return FALSE if parameter set fails.
788   */   */
789    
790  Bool_t  TrkParams::Set( ){  Bool_t  TrkParams::Set( ){
791    
792    
# Line 868  Bool_t TrkParams::Load(UInt_t type){ Line 888  Bool_t TrkParams::Load(UInt_t type){
888  }  }
889    
890  Bool_t TrkParams::Load( ){  Bool_t TrkParams::Load( ){
891      for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )if( !TrkParams::Load(trkparamtype[i]) )return false;          Bool_t result = true;
892      return true;      for(Int_t i=0 ; i<NTYPES; i++)
893          if(!glload[i] && trkparamtype[i]>0 )
894            if( !TrkParams::Load(trkparamtype[i]) )
895              result = false;
896        return result;
897  };  };
898  Bool_t TrkParams::IsLoaded( ){  Bool_t TrkParams::IsLoaded( ){
899      for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false;      for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false;
900      return true;      return true;
901  };  };
902    
903    /**
904     * Get ADC-to-MIP conversion parameters
905     * @param nl ladder number (0-2)
906     * @param nv view number (0-11)
907     */
908    float TrkParams::GetMIP(int nl, int nv){
909        TrkParams::Load(2);
910        if( !TrkParams::IsLoaded(2) )return 0.;
911        return adc2mip_.mip[nl][nv];
912    }
913    
914  /**  /**
915   * Get BY (kGauss)   * Get BY (kGauss)

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.23