/[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.2 by pam-fi, Thu Mar 15 12:17:10 2007 UTC revision 1.6 by pam-fi, Fri Apr 27 10:39:57 2007 UTC
# Line 20  UInt_t       TrkParams::trkparamtype[] = Line 20  UInt_t       TrkParams::trkparamtype[] =
20  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()};
21  TString      TrkParams::glpath[]       = {"","","","","","",""};  TString      TrkParams::glpath[]       = {"","","","","","",""};
22  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};
23    cDbg         TrkParams::dbg_mode       = {0,0,0};
24    
25  TrkParams::TrkParams(){  TrkParams::TrkParams(){
26    
27      cout<<"TrkParams::TrkParams()"<<endl;  //    cout<<"TrkParams::TrkParams()"<<endl;
28    
29  }  }
30  float aint(float f){  float aint(float f){
# Line 49  float anint(float f){ Line 50  float anint(float f){
50   */   */
51  Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){  Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){
52    
53      GL_TRK_CALIB q2;  //    cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl;
54      GL_ROOT q3;  
55      GL_PARAM q4;      if( !CalibIsLoaded()                          ||
56            (glrun->TRK_CALIB_USED==104 && !calib104) ||
57      if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) )return false;          (glrun->TRK_CALIB_USED!=104 && calib104)  ||
58      if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2)          glrun->RUNHEADER_TIME < calib.FROM_TIME   ||
59          printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);            glrun->RUNHEADER_TIME > calib.TO_TIME     ||
60      if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false;          false ){
61    
62      calib      = q2;          GL_TRK_CALIB q2;
63      calibpathf = q3.PATH + q3.NAME;          GL_ROOT q3;
64      calib104   = (glrun->TRK_CALIB_USED==104);          GL_PARAM q4;
65      calibload  = kFALSE;          
66      if(calib104){          if(TrkParams::VerboseMode()){
67          if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false;              cout << "--------------------------------------"<<endl;
68          calibpatht = q4.PATH + q4.NAME;              cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl;
69      }          }
70            if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){
71                cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl;
72                return false;
73            }
74            if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 )
75                printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);    
76            if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){
77                cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl;
78                return false;
79            }
80    
81            if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl;
82            calib      = q2;
83            calibpathf = q3.PATH + q3.NAME;
84            calib104   = (glrun->TRK_CALIB_USED==104);
85            calibload  = kFALSE;
86            if(calib104){
87                if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false;
88                calibpatht = q4.PATH + q4.NAME;
89            }
90            
91    
92  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
93      return true;          return true;
94        }
95    
96        return false;
97  };  };
98    
99  /**  /**
100     * Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation
101     * in YodaProfiler.
102     */
103    UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){
104    
105        Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0};
106    //    UInt_t timeaftercalib=120000; //2000;
107        TString classname = caltrk->GetName();
108    //  ----------
109    //  Check CRCs
110    //  ----------
111        if(TrkParams::VerboseMode())cout << " DSP: ";
112        for(Int_t ipkt=0; ipkt<6; ipkt++){
113            cout <<" "<<caltrk->DSPnumber[ipkt];
114            if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
115                if( caltrk->crc_hcal[ipkt] ){
116                    if(TrkParams::WarningMode())cout<<"(CRC Header)";
117    //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl;    
118    //              return 0; // :-(
119                }
120                for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){
121                    if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")";
122    //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl;    
123    //              return 0; // :-(
124                }
125            }
126        }
127        if(TrkParams::VerboseMode())cout << endl;;
128    //  -----------------------
129    //  Check missing packets:
130    //  -----------------------
131    //    Readout order:
132    //    ------------------
133    //    DSP   packet board
134    //    ------------------
135    //    12    0      1
136    //    10    1      1
137    //     8    2      1
138    //     4    3      1
139    //     6    4      1
140    //     2    5      1
141    //    ------------------
142    //    11    0      2
143    //     9    1      2
144    //     7    2      2
145    //     3    3      2
146    //     5    4      2
147    //     1    5      2
148    //    ------------------
149    //  -------------------------------------------------
150    //  Check if it is first or second calibration packet
151    //  -------------------------------------------------
152        UInt_t build=0;
153        UInt_t base=0;
154        UInt_t mask=0;
155        if(classname.Contains("CalibTrk1Event")){
156            base=12;
157            mask=0x03F000;
158        }
159        if(classname.Contains("CalibTrk2Event")){
160            base=18;
161            mask=0xFC0000;
162        }
163    //  -------------------------------------------------
164    //  Count number of packets and set build variable
165    //  -------------------------------------------------
166        Int_t  npkts=0;
167        for(Int_t ipkt=0; ipkt<6; ipkt++){
168            if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
169                npkts++;
170                build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );
171            };
172        }
173        if( npkts==6 )return 1; // :-)
174        else {
175            if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl;    
176        }
177    //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;
178    
179    //  -----------------------------------------------
180    //  If missing packets: check the acq configuration
181    //  (some DSPs might be excluded from acquisition)
182    //  -----------------------------------------------
183    
184    //  -----------------------------------------------
185    //  retrieve the first run header after calib
186    //  -----------------------------------------------
187    //      PacketType *pctp;
188    //      EventCounter *cod;
189    //      cod = eh->GetCounter();
190    //      Int_t irun = cod->Get(pctp->RunHeader);
191    //      TTree *rh=(TTree*)file->Get("RunHeader");
192    //      if ( !rh || rh->IsZombie() ) throw -17;
193    //      if( rh->GetEntries() == irun ){
194    //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1)  -- cannot validate :-( "<<endl;
195    //       return 0; // :-(
196    //      }
197    
198    //      RunHeaderEvent *run  = 0;
199    //      EventHeader    *hrun = 0;
200    //      rh->SetBranchAddress("RunHeader", &run);
201    //      rh->SetBranchAddress("Header", &hrun);
202    //      rh->GetEntry(irun);
203    // //     cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl;
204    
205    //      if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){
206    //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl;
207    //       return 0; // :-(
208    //      }
209        
210    //      if( !run->RM_ACQ_AFTER_CALIB ){
211    //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0    -- cannot validate :-( "<<endl;
212    //       return 0; // :-(
213    //      }
214    
215    //      UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime());
216    //      if( dtime > timeaftercalib ){
217    //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl;
218    //       return 0; // :-(
219    //      }
220        
221    //      if( (run->ACQ_BUILD_INFO & mask) != build ){
222    //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl;
223    //       return 0; // :-(
224    //      }
225          return 1; // :-)
226    
227    }
228    /**
229   * Method to fill the tracker calibration-parameter struct from on-line calibrations   * Method to fill the tracker calibration-parameter struct from on-line calibrations
230   */   */
231  void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){  void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){
# Line 89  void TrkParams::FillACalibFrom(TFile* f0 Line 242  void TrkParams::FillACalibFrom(TFile* f0
242      tr1->GetEntry(ev_reg1);      tr1->GetEntry(ev_reg1);
243      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
244      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
245    
246        // --- TEST TEST TEST TEST --- //
247        TrkParams::ValidateTrkCalib(calibdata1);
248        TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
249                    
250      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
251          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 144  void TrkParams::FillFCalibFrom(TFile* f0 Line 301  void TrkParams::FillFCalibFrom(TFile* f0
301      tr1->GetEntry(ev_reg1);      tr1->GetEntry(ev_reg1);
302      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
303      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
304    
305        // --- TEST TEST TEST TEST --- //
306        TrkParams::ValidateTrkCalib(calibdata1);
307        TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
308                    
309      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
310          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 196  void TrkParams::FillTCalibFrom(TFile* f0 Line 357  void TrkParams::FillTCalibFrom(TFile* f0
357      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
358      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
359                    
360        // --- TEST TEST TEST TEST --- //
361        TrkParams::ValidateTrkCalib(calibdata1);
362        TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
363    
364      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
365          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
366          dspn2=calibdata2->DSPnumber[i]-1;          dspn2=calibdata2->DSPnumber[i]-1;
# Line 272  void TrkParams::FillMask(TFile* f0, Int_ Line 437  void TrkParams::FillMask(TFile* f0, Int_
437    
438  };  };
439    
440    // Bool_t TrkParams::CalibIsLoaded(UInt_t time){
441    
442    //     if( !calibload ) return false;
443    
444    // };
445    
446    
447  /**  /**
448   * Static method to load calibration.   * Static method to load calibration.
449   * Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens the   * Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens the
# Line 282  Bool_t TrkParams::LoadCalib( ){ Line 454  Bool_t TrkParams::LoadCalib( ){
454    
455      if( TrkParams::CalibIsLoaded() )return false;      if( TrkParams::CalibIsLoaded() )return false;
456    
 //    cTrkCalib *ca = new cTrkCalib; //&pedsigbad_;  
   
 //     extern cTrkCalib   pedsigbad_;  
 //     extern cTrkMask    mask_;  
   
     cout << "--------------------------------------"<<endl;  
     cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl;  
457      // =============================================================      // =============================================================
458      // retrieve calibration file needed to reduce data      // retrieve calibration file needed to reduce data
459      // =============================================================      // =============================================================
460      // if run OBT is > last calibration "expiration date"      // if run OBT is > last calibration "expiration date"
461      //  - search for new calibration packet      //  - search for new calibration packet
462      //  - load calibration parameters (full + truncated)          //  - load calibration parameters (full + truncated)    
463      cout << "Full pedestals for cluster finding:";      if(TrkParams::VerboseMode()){
464      cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl;          cout << "--------------------------------------"<<endl;
465            cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl;
466            cout << " Full pedestals for cluster finding:";
467            cout << " >> loading from LEVEL0 file: "<< calibpathf << endl;
468        }
469      FileStat_t t;      FileStat_t t;
470      if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false;      if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false;
471        
472      TFile *f0_c = new TFile(calibpathf);      bool alreadyopened = false;
473        TFile *f0_c=0;
474        f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf);
475        if(f0_c)alreadyopened=true;
476        else f0_c = new TFile(calibpathf);
477      if ( !f0_c ) return false;      if ( !f0_c ) return false;
478      cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2;  
479      cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl;      if(TrkParams::VerboseMode()){
480  //    ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);          cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2;
481            cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl;
482            cout << " - full+truncated parameters "<<endl;
483        }
484      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
485        if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;
486      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
 //    mask_.Set(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);  
 //    for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal[64][12][i] << endl;  
487    
 //    };  
488      // =============================================================      // =============================================================
489      // retrieve calibration file needed to uncompress data      // retrieve calibration file needed to uncompress data
490      // =============================================================      // =============================================================
491      // if the run was compressed using default calib      // if the run was compressed using default calib
492      // load truncated pedestals from default      // load truncated pedestals from default
493      // otherwise reload them from on-line calibration      // otherwise reload them from on-line calibration
494      cout << "Truncated pedestals for uncompression:";      if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:";
495      if( calib104 ){      if( calib104 ){
496    
497          cout << " >> Loading default calibration: "<< calibpatht << endl;          if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl;
 //      ca->FillTCalibFrom(calibpatht);  
498          TrkParams::FillTCalibFrom(calibpatht);          TrkParams::FillTCalibFrom(calibpatht);
499                            
500      }else{      }else{
501    
502          if ( !f0_c ) return false;  //      if ( !f0_c ) return false;
503          cout << ">> Loading on-line calibration " << endl;          if(TrkParams::VerboseMode())cout << ">> already loaded " << endl;
504  //      ca->FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);  //      TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
         TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);  
505      };      };
506      for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl;      if(!alreadyopened)f0_c->Close();
507      f0_c->Close();      if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl;
 //    delete f0_c;  
     cout << "--------------------------------------"<<endl;  
508            
509      calibload = kTRUE;      calibload = kTRUE;
510      return true;      return true;
# Line 358  Int_t TrkParams::GetIndex( UInt_t type ) Line 528  Int_t TrkParams::GetIndex( UInt_t type )
528   */   */
529  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){
530    
 //    if( !dbc )return false;  
   
   
     if( !dbc || (dbc && !dbc->IsConnected()) ){  
   
         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;  
         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;      
         cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
   
     }  
531    
532      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
533      if(index < 0)return false;      if(index < 0)return false;
534    
535      UInt_t runheadtime = numeric_limits<UInt_t>::max();      if( !TrkParams::IsLoaded(type) ||
536      if(glrun)runheadtime = glrun->RUNHEADER_TIME;          glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||
537      else cout <<"Missing run info -- taking last entry "<<endl;          glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||        
538            false ){
539    
540            if( !dbc || (dbc && !dbc->IsConnected()) ){
541    
542                if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
543                TString host = "mysql://localhost/pamelaprod";
544                TString user = "anonymous";
545                TString psw = "";
546                const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
547                const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
548                const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
549                if ( !pamdbhost ) pamdbhost = "";
550                if ( !pamdbuser ) pamdbuser = "";
551                if ( !pamdbpsw ) pamdbpsw = "";
552                if ( strcmp(pamdbhost,"") ) host = pamdbhost;
553                if ( strcmp(pamdbuser,"") ) user = pamdbuser;
554                if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
555                if(TrkParams::VerboseMode()){
556                    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
557                    cout<<"Connecting to DB"<<endl;
558                    cout<<"HOST "<<host<<endl;
559                    cout<<"USER "<<user<<endl;
560                    cout<<"PSW  "<<psw<<endl;
561                }
562                dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
563                if( !dbc )return false;
564                if( !dbc->IsConnected() )return false;    
565                if(TrkParams::VerboseMode()){
566                    cout << " ...done"<<endl;
567                    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
568                }
569            }
570    
     GL_PARAM q4;  
     if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;  
571    
572      gl[index]     = q4;          UInt_t runheadtime = numeric_limits<UInt_t>::max();
573      glpath[index] = q4.PATH+q4.NAME;          if(glrun)runheadtime = glrun->RUNHEADER_TIME;
574      glload[index] = false;          else cout <<"Missing run info -- taking last entry "<<endl;
575      cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl;  
576      return true;          GL_PARAM q4;
577  //    return TrkParams::Load(type);          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;
578    
579            gl[index]     = q4;
580            glpath[index] = q4.PATH+q4.NAME;
581            glload[index] = false;
582            if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl;
583            return true;
584    
585        }
586        return false;
587    
588  };  };
589  /**  /**
# Line 419  Bool_t TrkParams::Set( TString path , UI Line 599  Bool_t TrkParams::Set( TString path , UI
599    
600      gl[index].TYPE= type;      gl[index].TYPE= type;
601      glpath[index] = path;      glpath[index] = path;
602      cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl;      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl;
603      glload[index] = false;      glload[index] = false;
604    
605  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
# Line 478  Bool_t TrkParams::Set(UInt_t type){ Line 658  Bool_t TrkParams::Set(UInt_t type){
658                    
659      }      }
660    
661      cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl;      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl;
662  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
663      return true;      return true;
664    
# Line 493  Bool_t  TrkParams::Set( ){ Line 673  Bool_t  TrkParams::Set( ){
673    
674      Bool_t connected = false;      Bool_t connected = false;
675    
676      cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
677      TString host = "mysql://localhost/pamelaprod";      TString host = "mysql://localhost/pamelaprod";
678      TString user = "anonymous";      TString user = "anonymous";
679      TString psw = "";      TString psw = "";
# Line 506  Bool_t  TrkParams::Set( ){ Line 686  Bool_t  TrkParams::Set( ){
686      if ( strcmp(pamdbhost,"") ) host = pamdbhost;      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
687      if ( strcmp(pamdbuser,"") ) user = pamdbuser;      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
688      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
689      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(TrkParams::VerboseMode()){
690      cout<<"Connecting to DB"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
691      cout<<"HOST "<<host<<endl;          cout<<"Connecting to DB"<<endl;
692      cout<<"USER "<<user<<endl;          cout<<"HOST "<<host<<endl;
693      cout<<"PSW  "<<psw<<endl;          cout<<"USER "<<user<<endl;
694            cout<<"PSW  "<<psw<<endl;
695        }
696      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
697      if( dbc || dbc->IsConnected() )connected = true;      if( dbc || dbc->IsConnected() )connected = true;
698      else cout << " >> FAILED!!!"<<endl;      else cout << " >> DB connection FAILED!!!"<<endl;
699      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
700            
701      if(connected){      if(connected){
702          if ( !TrkParams::Set(0,dbc) )return false;          if ( !TrkParams::Set(0,dbc) )return false;
703          dbc->Close();          dbc->Close();
704      }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;
705    
706        return true;
707  }  }
708    
709  /**  /**
# Line 538  Bool_t TrkParams::Load(UInt_t type){ Line 722  Bool_t TrkParams::Load(UInt_t type){
722      switch( type ){      switch( type ){
723      //------------------------------------------      //------------------------------------------
724      case 1:          case 1:    
725          cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl;
726          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
727          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
728          path_.error   = 0;          path_.error   = 0;
# Line 548  Bool_t TrkParams::Load(UInt_t type){ Line 732  Bool_t TrkParams::Load(UInt_t type){
732          break;          break;
733      //------------------------------------------      //------------------------------------------
734      case 2:          case 2:    
735          cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl;
736          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
737          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
738          path_.error   = 0;          path_.error   = 0;
# Line 558  Bool_t TrkParams::Load(UInt_t type){ Line 742  Bool_t TrkParams::Load(UInt_t type){
742          break;          break;
743      //------------------------------------------      //------------------------------------------
744      case 3:          case 3:    
745          cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl;
746          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
747          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
748          path_.error   = 0;          path_.error   = 0;
# Line 568  Bool_t TrkParams::Load(UInt_t type){ Line 752  Bool_t TrkParams::Load(UInt_t type){
752          break;          break;
753      //------------------------------------------      //------------------------------------------
754      case 4:          case 4:    
755          cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl;
756          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
757          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
758          path_.error   = 0;          path_.error   = 0;
# Line 578  Bool_t TrkParams::Load(UInt_t type){ Line 762  Bool_t TrkParams::Load(UInt_t type){
762          break;          break;
763      //------------------------------------------      //------------------------------------------
764      case 5:          case 5:    
765          cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl;
766          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
767          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
768          path_.error   = 0;          path_.error   = 0;
# Line 588  Bool_t TrkParams::Load(UInt_t type){ Line 772  Bool_t TrkParams::Load(UInt_t type){
772          break;          break;
773      //------------------------------------------      //------------------------------------------
774      case 6:          case 6:    
775          cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl;
776          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
777          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
778          path_.error   = 0;          path_.error   = 0;
# Line 598  Bool_t TrkParams::Load(UInt_t type){ Line 782  Bool_t TrkParams::Load(UInt_t type){
782          break;          break;
783      //------------------------------------------      //------------------------------------------
784      case 7:          case 7:    
785          cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl;
786          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
787          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
788          path_.error   = 0;          path_.error   = 0;
789  //      fillpedsigfromdefault_();  //      fillpedsigfromdefault_();
790          cout << ">> not implemented <<"<<endl;          if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl;
791          if(path_.error) return false;          if(path_.error) return false;
792          glload[index]=true;          glload[index]=true;
793          break;          break;
794      default:      default:
795          cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl;          if(TrkParams::VerboseMode())cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl;
796          return false;          return false;
797      };      };
798    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23