/[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.1 by pam-fi, Fri Feb 16 14:56:01 2007 UTC revision 1.8 by pam-fi, Mon May 14 11:03:05 2007 UTC
# Line 16  TString      TrkParams::calibpatht = ""; Line 16  TString      TrkParams::calibpatht = "";
16  TString      TrkParams::calibpathf = "";  TString      TrkParams::calibpathf = "";
17  Bool_t       TrkParams::calib104   = 0;  Bool_t       TrkParams::calib104   = 0;
18  Bool_t       TrkParams::calibload  = false;  Bool_t       TrkParams::calibload  = false;
19    // -------------------------
20    // PARAMETERS loaded from DB
21    // -------------------------
22  UInt_t       TrkParams::trkparamtype[] = {1,2,3,4,5,6,7};  UInt_t       TrkParams::trkparamtype[] = {1,2,3,4,5,6,7};
23  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()};
24  TString      TrkParams::glpath[]       = {"","","","","","",""};  TString      TrkParams::glpath[]       = {"","","","","","",""};
25  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};
26    cDbg         TrkParams::dbg_mode       = {0,0,0};
27    // ----------------
28    // other parameters
29    // ----------------
30    int    TrkParams::init__pfa            = 14;//COG4
31    int    TrkParams::init__mini_trackmode = 0;
32    int    TrkParams::init__mini_istepmin  = 3;
33    double TrkParams::init__mini_fact      = 100.;
34    
35  TrkParams::TrkParams(){  TrkParams::TrkParams(){
36    
# Line 49  float anint(float f){ Line 60  float anint(float f){
60   */   */
61  Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){  Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){
62    
63      GL_TRK_CALIB q2;  //    cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl;
     GL_ROOT q3;  
     GL_PARAM q4;  
   
     if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) )return false;  
     if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2)  
         printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);    
     if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false;  
   
     calib      = q2;  
     calibpathf = q3.PATH + q3.NAME;  
     calib104   = (glrun->TRK_CALIB_USED==104);  
     calibload  = kFALSE;  
     if(calib104){  
         if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false;  
         calibpatht = q4.PATH + q4.NAME;  
     }  
64    
65        if( !CalibIsLoaded()                          ||
66            (glrun->TRK_CALIB_USED==104 && !calib104) ||
67            (glrun->TRK_CALIB_USED!=104 && calib104)  ||
68            glrun->RUNHEADER_TIME < calib.FROM_TIME   ||
69            glrun->RUNHEADER_TIME > calib.TO_TIME     ||
70            false ){
71    
72            GL_TRK_CALIB q2;
73            GL_ROOT q3;
74            GL_PARAM q4;
75            
76            if(TrkParams::VerboseMode()){
77                cout << "--------------------------------------"<<endl;
78                cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl;
79            }
80            if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){
81                cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl;
82                return false;
83            }
84            if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 )
85                printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);    
86            if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){
87                cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl;
88                return false;
89            }
90    
91            if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl;
92            calib      = q2;
93            calibpathf = q3.PATH + q3.NAME;
94            calib104   = (glrun->TRK_CALIB_USED==104);
95            calibload  = kFALSE;
96            if(calib104){
97                if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false;
98                calibpatht = q4.PATH + q4.NAME;
99            }
100            
101    
102  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
103      return true;          return true;
104        }
105    
106        return false;
107  };  };
108    
109  /**  /**
110     * Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation
111     * in YodaProfiler.
112     */
113    UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){
114    
115        Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0};
116    //    UInt_t timeaftercalib=120000; //2000;
117        TString classname = caltrk->GetName();
118    //  ----------
119    //  Check CRCs
120    //  ----------
121        if(TrkParams::VerboseMode())cout << " DSP: ";
122        for(Int_t ipkt=0; ipkt<6; ipkt++){
123            if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt];
124            if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
125                if( caltrk->crc_hcal[ipkt] ){
126                    if(TrkParams::WarningMode())cout<<"(CRC Header)";
127    //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl;    
128    //              return 0; // :-(
129                }
130                for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){
131                    if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")";
132    //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl;    
133    //              return 0; // :-(
134                }
135            }
136        }
137        if(TrkParams::VerboseMode())cout << endl;;
138    //  -----------------------
139    //  Check missing packets:
140    //  -----------------------
141    //    Readout order:
142    //    ------------------
143    //    DSP   packet board
144    //    ------------------
145    //    12    0      1
146    //    10    1      1
147    //     8    2      1
148    //     4    3      1
149    //     6    4      1
150    //     2    5      1
151    //    ------------------
152    //    11    0      2
153    //     9    1      2
154    //     7    2      2
155    //     3    3      2
156    //     5    4      2
157    //     1    5      2
158    //    ------------------
159    //  -------------------------------------------------
160    //  Check if it is first or second calibration packet
161    //  -------------------------------------------------
162        UInt_t build=0;
163        UInt_t base=0;
164        UInt_t mask=0;
165        if(classname.Contains("CalibTrk1Event")){
166            base=12;
167            mask=0x03F000;
168        }
169        if(classname.Contains("CalibTrk2Event")){
170            base=18;
171            mask=0xFC0000;
172        }
173    //  -------------------------------------------------
174    //  Count number of packets and set build variable
175    //  -------------------------------------------------
176        Int_t  npkts=0;
177        for(Int_t ipkt=0; ipkt<6; ipkt++){
178            if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
179                npkts++;
180                build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );
181            };
182        }
183        if( npkts==6 )return 1; // :-)
184        else {
185            if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl;    
186        }
187    //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;
188    
189    //  -----------------------------------------------
190    //  If missing packets: check the acq configuration
191    //  (some DSPs might be excluded from acquisition)
192    //  -----------------------------------------------
193    
194    //  -----------------------------------------------
195    //  retrieve the first run header after calib
196    //  -----------------------------------------------
197    //      PacketType *pctp;
198    //      EventCounter *cod;
199    //      cod = eh->GetCounter();
200    //      Int_t irun = cod->Get(pctp->RunHeader);
201    //      TTree *rh=(TTree*)file->Get("RunHeader");
202    //      if ( !rh || rh->IsZombie() ) throw -17;
203    //      if( rh->GetEntries() == irun ){
204    //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1)  -- cannot validate :-( "<<endl;
205    //       return 0; // :-(
206    //      }
207    
208    //      RunHeaderEvent *run  = 0;
209    //      EventHeader    *hrun = 0;
210    //      rh->SetBranchAddress("RunHeader", &run);
211    //      rh->SetBranchAddress("Header", &hrun);
212    //      rh->GetEntry(irun);
213    // //     cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl;
214    
215    //      if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){
216    //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl;
217    //       return 0; // :-(
218    //      }
219        
220    //      if( !run->RM_ACQ_AFTER_CALIB ){
221    //        if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0    -- cannot validate :-( "<<endl;
222    //       return 0; // :-(
223    //      }
224    
225    //      UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime());
226    //      if( dtime > timeaftercalib ){
227    //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl;
228    //       return 0; // :-(
229    //      }
230        
231    //      if( (run->ACQ_BUILD_INFO & mask) != build ){
232    //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl;
233    //       return 0; // :-(
234    //      }
235          return 1; // :-)
236    
237    }
238    /**
239   * Method to fill the tracker calibration-parameter struct from on-line calibrations   * Method to fill the tracker calibration-parameter struct from on-line calibrations
240   */   */
241  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 252  void TrkParams::FillACalibFrom(TFile* f0
252      tr1->GetEntry(ev_reg1);      tr1->GetEntry(ev_reg1);
253      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
254      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
255    
256        // --- TEST TEST TEST TEST --- //
257        TrkParams::ValidateTrkCalib(calibdata1);
258        TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
259                    
260      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
261          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 144  void TrkParams::FillFCalibFrom(TFile* f0 Line 311  void TrkParams::FillFCalibFrom(TFile* f0
311      tr1->GetEntry(ev_reg1);      tr1->GetEntry(ev_reg1);
312      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
313      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
314    
315        // --- TEST TEST TEST TEST --- //
316        TrkParams::ValidateTrkCalib(calibdata1);
317        TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
318                    
319      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
320          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 196  void TrkParams::FillTCalibFrom(TFile* f0 Line 367  void TrkParams::FillTCalibFrom(TFile* f0
367      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
368      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
369                    
370        // --- TEST TEST TEST TEST --- //
371        TrkParams::ValidateTrkCalib(calibdata1);
372        TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
373    
374      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
375          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
376          dspn2=calibdata2->DSPnumber[i]-1;          dspn2=calibdata2->DSPnumber[i]-1;
# Line 272  void TrkParams::FillMask(TFile* f0, Int_ Line 447  void TrkParams::FillMask(TFile* f0, Int_
447    
448  };  };
449    
450    // Bool_t TrkParams::CalibIsLoaded(UInt_t time){
451    
452    //     if( !calibload ) return false;
453    
454    // };
455    
456    
457  /**  /**
458   * Static method to load calibration.   * Static method to load calibration.
459   * 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 464  Bool_t TrkParams::LoadCalib( ){
464    
465      if( TrkParams::CalibIsLoaded() )return false;      if( TrkParams::CalibIsLoaded() )return false;
466    
 //    cTrkCalib *ca = new cTrkCalib; //&pedsigbad_;  
   
 //     extern cTrkCalib   pedsigbad_;  
 //     extern cTrkMask    mask_;  
   
     cout << "--------------------------------------"<<endl;  
     cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl;  
467      // =============================================================      // =============================================================
468      // retrieve calibration file needed to reduce data      // retrieve calibration file needed to reduce data
469      // =============================================================      // =============================================================
470      // if run OBT is > last calibration "expiration date"      // if run OBT is > last calibration "expiration date"
471      //  - search for new calibration packet      //  - search for new calibration packet
472      //  - load calibration parameters (full + truncated)          //  - load calibration parameters (full + truncated)    
473      cout << "Full pedestals for cluster finding:";      if(TrkParams::VerboseMode()){
474      cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl;          cout << "--------------------------------------"<<endl;
475            cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl;
476            cout << " Full pedestals for cluster finding:";
477            cout << " >> loading from LEVEL0 file: "<< calibpathf << endl;
478        }
479      FileStat_t t;      FileStat_t t;
480      if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false;      if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false;
481        
482      TFile *f0_c = new TFile(calibpathf);      bool alreadyopened = false;
483        TFile *f0_c=0;
484        f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf);
485        if(f0_c)alreadyopened=true;
486        else f0_c = new TFile(calibpathf);
487      if ( !f0_c ) return false;      if ( !f0_c ) return false;
488      cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2;  
489      cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl;      if(TrkParams::VerboseMode()){
490  //    ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);          cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2;
491            cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl;
492            cout << " - full+truncated parameters "<<endl;
493        }
494      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
495        if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;
496      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);  
497    
 //    };  
498      // =============================================================      // =============================================================
499      // retrieve calibration file needed to uncompress data      // retrieve calibration file needed to uncompress data
500      // =============================================================      // =============================================================
501      // if the run was compressed using default calib      // if the run was compressed using default calib
502      // load truncated pedestals from default      // load truncated pedestals from default
503      // otherwise reload them from on-line calibration      // otherwise reload them from on-line calibration
504      cout << "Truncated pedestals for uncompression:";      if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:";
505      if( calib104 ){      if( calib104 ){
506    
507          cout << " >> Loading default calibration: "<< calibpatht << endl;          if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl;
 //      ca->FillTCalibFrom(calibpatht);  
508          TrkParams::FillTCalibFrom(calibpatht);          TrkParams::FillTCalibFrom(calibpatht);
509                            
510      }else{      }else{
511    
512          if ( !f0_c ) return false;  //      if ( !f0_c ) return false;
513          cout << ">> Loading on-line calibration " << endl;          if(TrkParams::VerboseMode())cout << ">> already loaded " << endl;
514  //      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);  
515      };      };
516      f0_c->Close();      if(!alreadyopened)f0_c->Close();
517  //    delete f0_c;      if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl;
     cout << "--------------------------------------"<<endl;  
518            
519      calibload = kTRUE;      calibload = kTRUE;
520      return true;      return true;
# Line 356  Int_t TrkParams::GetIndex( UInt_t type ) Line 538  Int_t TrkParams::GetIndex( UInt_t type )
538   */   */
539  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){
540    
 //    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;  
   
     }  
541    
542      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
543      if(index < 0)return false;      if(index < 0)return false;
544    
545      UInt_t runheadtime = numeric_limits<UInt_t>::max();      if( !TrkParams::IsLoaded(type) ||
546      if(glrun)runheadtime = glrun->RUNHEADER_TIME;          glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||
547      else cout <<"Missing run info -- taking last entry "<<endl;          glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||        
548            false ){
549    
550            if( !dbc || (dbc && !dbc->IsConnected()) ){
551    
552                if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
553                TString host = "mysql://localhost/pamelaprod";
554                TString user = "anonymous";
555                TString psw = "";
556                const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
557                const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
558                const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
559                if ( !pamdbhost ) pamdbhost = "";
560                if ( !pamdbuser ) pamdbuser = "";
561                if ( !pamdbpsw ) pamdbpsw = "";
562                if ( strcmp(pamdbhost,"") ) host = pamdbhost;
563                if ( strcmp(pamdbuser,"") ) user = pamdbuser;
564                if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
565                if(TrkParams::VerboseMode()){
566                    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
567                    cout<<"Connecting to DB"<<endl;
568                    cout<<"HOST "<<host<<endl;
569                    cout<<"USER "<<user<<endl;
570                    cout<<"PSW  "<<psw<<endl;
571                }
572                dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
573                if( !dbc )return false;
574                if( !dbc->IsConnected() )return false;    
575                if(TrkParams::VerboseMode()){
576                    cout << " ...done"<<endl;
577                    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
578                }
579            }
580    
     GL_PARAM q4;  
     if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;  
581    
582      gl[index]     = q4;          UInt_t runheadtime = numeric_limits<UInt_t>::max();
583      glpath[index] = q4.PATH+q4.NAME;          if(glrun)runheadtime = glrun->RUNHEADER_TIME;
584      glload[index] = false;          else cout <<"Missing run info -- taking last entry "<<endl;
585      cout << "<< set TrkParams type "<<type<<" >>"<<endl;  
586      return true;          GL_PARAM q4;
587  //    return TrkParams::Load(type);          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;
588    
589            gl[index]     = q4;
590            glpath[index] = q4.PATH+q4.NAME;
591            glload[index] = false;
592            if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl;
593            return true;
594    
595        }
596        return false;
597    
598  };  };
599  /**  /**
600   * Set tracker parameters proper for the run, from the from input.   * Set tracker parameters proper for the run, from input.
601   * @param path  Path to parameters directory   * @param path  Path to parameters directory
602   * @param type  Parameter type   * @param type  Parameter type
603   * @return FALSE if parameter set fails.   * @return FALSE if parameter set fails.
# Line 417  Bool_t TrkParams::Set( TString path , UI Line 609  Bool_t TrkParams::Set( TString path , UI
609    
610      gl[index].TYPE= type;      gl[index].TYPE= type;
611      glpath[index] = path;      glpath[index] = path;
612      cout << "<< set TrkParams type "<<type<<" >>"<<endl;      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl;
613      glload[index] = false;      glload[index] = false;
614    
615  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
# Line 476  Bool_t TrkParams::Set(UInt_t type){ Line 668  Bool_t TrkParams::Set(UInt_t type){
668                    
669      }      }
670    
671      cout << "<< set TrkParams type "<<type<<" >>"<<endl;      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl;
672  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
673      return true;      return true;
674    
# Line 491  Bool_t  TrkParams::Set( ){ Line 683  Bool_t  TrkParams::Set( ){
683    
684      Bool_t connected = false;      Bool_t connected = false;
685    
686      cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
687      TString host = "mysql://localhost/pamelaprod";      TString host = "mysql://localhost/pamelaprod";
688      TString user = "anonymous";      TString user = "anonymous";
689      TString psw = "";      TString psw = "";
# Line 504  Bool_t  TrkParams::Set( ){ Line 696  Bool_t  TrkParams::Set( ){
696      if ( strcmp(pamdbhost,"") ) host = pamdbhost;      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
697      if ( strcmp(pamdbuser,"") ) user = pamdbuser;      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
698      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
699      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(TrkParams::VerboseMode()){
700      cout<<"Connecting to DB"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
701      cout<<"HOST "<<host<<endl;          cout<<"Connecting to DB"<<endl;
702      cout<<"USER "<<user<<endl;          cout<<"HOST "<<host<<endl;
703      cout<<"PSW  "<<psw<<endl;          cout<<"USER "<<user<<endl;
704            cout<<"PSW  "<<psw<<endl;
705        }
706      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
707      if( dbc || dbc->IsConnected() )connected = true;      if( dbc || dbc->IsConnected() )connected = true;
708      else cout << " >> FAILED!!!"<<endl;      else cout << " >> DB connection FAILED!!!"<<endl;
709      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
710            
711      if(connected){      if(connected){
712          if ( !TrkParams::Set(0,dbc) )return false;          if ( !TrkParams::Set(0,dbc) )return false;
713          dbc->Close();          dbc->Close();
714      }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;
715    
716        return true;
717  }  }
718    
719  /**  /**
# Line 536  Bool_t TrkParams::Load(UInt_t type){ Line 732  Bool_t TrkParams::Load(UInt_t type){
732      switch( type ){      switch( type ){
733      //------------------------------------------      //------------------------------------------
734      case 1:          case 1:    
735          cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<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 546  Bool_t TrkParams::Load(UInt_t type){ Line 742  Bool_t TrkParams::Load(UInt_t type){
742          break;          break;
743      //------------------------------------------      //------------------------------------------
744      case 2:          case 2:    
745          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;
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 556  Bool_t TrkParams::Load(UInt_t type){ Line 752  Bool_t TrkParams::Load(UInt_t type){
752          break;          break;
753      //------------------------------------------      //------------------------------------------
754      case 3:          case 3:    
755          cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation 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 566  Bool_t TrkParams::Load(UInt_t type){ Line 762  Bool_t TrkParams::Load(UInt_t type){
762          break;          break;
763      //------------------------------------------      //------------------------------------------
764      case 4:          case 4:    
765          cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. 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 576  Bool_t TrkParams::Load(UInt_t type){ Line 772  Bool_t TrkParams::Load(UInt_t type){
772          break;          break;
773      //------------------------------------------      //------------------------------------------
774      case 5:          case 5:    
775          cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment 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 586  Bool_t TrkParams::Load(UInt_t type){ Line 782  Bool_t TrkParams::Load(UInt_t type){
782          break;          break;
783      //------------------------------------------      //------------------------------------------
784      case 6:          case 6:    
785          cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<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;
# Line 596  Bool_t TrkParams::Load(UInt_t type){ Line 792  Bool_t TrkParams::Load(UInt_t type){
792          break;          break;
793      //------------------------------------------      //------------------------------------------
794      case 7:          case 7:    
795          cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl;
796          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
797          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
798          path_.error   = 0;          path_.error   = 0;
799  //      fillpedsigfromdefault_();  //      fillpedsigfromdefault_();
800          cout << ">> not implemented <<"<<endl;          if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl;
801          if(path_.error) return false;          if(path_.error) return false;
802          glload[index]=true;          glload[index]=true;
803          break;          break;
804      default:      default:
805          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;
806          return false;          return false;
807      };      };
808    
# Line 622  Bool_t TrkParams::IsLoaded( ){ Line 818  Bool_t TrkParams::IsLoaded( ){
818      return true;      return true;
819  };  };
820    
821    
822    /**
823     * Get BY (kGauss)
824     * @param v (x,y,z) coordinates in cm
825     */
826    float TrkParams::GetBX(float* v){
827        TrkParams::Load(1);
828        if( !TrkParams::IsLoaded(1) )return 0.;
829        float b[3];
830        gufld_(v,b);
831        return b[0]/10.;
832    }
833    /**
834     * Get BY (kGauss)
835     * @param v (x,y,z) coordinates in cm
836     */
837    float TrkParams::GetBY(float* v){
838        TrkParams::Load(1);
839        if( !TrkParams::IsLoaded(1) )return 0.;
840        float b[3];
841        gufld_(v,b);
842        return b[1]/10.;
843    }
844    /**
845     * Get BY (kGauss)
846     * @param v (x,y,z) coordinates in cm
847     */
848    float TrkParams::GetBZ(float* v){
849        TrkParams::Load(1);
850        if( !TrkParams::IsLoaded(1) )return 0.;
851        float b[3];
852        gufld_(v,b);
853        return b[2]/10.;
854    }
855    
856    /**
857     * \brief Set tracking mode (0=standard. 1=???)
858     */
859    void TrkParams::SetTrackingMode(int trackmode) {
860        init__mini_trackmode = trackmode;
861        SetTrackingMode();
862    };
863    /**
864     * \brief Set fit-precision factor (typical value fact=100.)
865     */
866    void TrkParams::SetPrecisionFactor(double fact){
867        init__mini_fact      = fact;
868        SetPrecisionFactor();
869    };
870    /**
871     * \brief Set minimum number of step in track fitting
872     */
873    void TrkParams::SetStepMin(int istepmin){
874        init__mini_istepmin  = istepmin;
875        SetStepMin();
876    };
877    
878    /**
879     * \brief Set p.f.a.
880     *
881     * Implemented algorythms:
882     * 0  ETA (default)
883     * 1  ---
884     * 2  ETA2
885     * 3  ETA3
886     * 4  ETA4
887     * 10 COG
888     * 11 COG1
889     * 12 COG2
890     * 13 COG3
891     * 14 COG4
892     */
893    void TrkParams::SetPFA(int pfaid){
894        init__pfa  = pfaid;
895        SetStepMin();
896    };
897    
898    
899    
900  ClassImp(TrkParams);  ClassImp(TrkParams);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23