/[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.5 by pam-fi, Wed Mar 21 11:05:39 2007 UTC revision 1.14 by pam-fi, Mon Aug 27 12:57:15 2007 UTC
# Line 5  Line 5 
5    
6  #include <TrkParams.h>  #include <TrkParams.h>
7  #include <iostream>  #include <iostream>
8    #include <iomanip>
9  using namespace std;  using namespace std;
10    
11    
# Line 16  TString      TrkParams::calibpatht = ""; Line 17  TString      TrkParams::calibpatht = "";
17  TString      TrkParams::calibpathf = "";  TString      TrkParams::calibpathf = "";
18  Bool_t       TrkParams::calib104   = 0;  Bool_t       TrkParams::calib104   = 0;
19  Bool_t       TrkParams::calibload  = false;  Bool_t       TrkParams::calibload  = false;
20    // -------------------------
21    // PARAMETERS loaded from DB
22    // -------------------------
23  UInt_t       TrkParams::trkparamtype[] = {1,2,3,4,5,6,7};  UInt_t       TrkParams::trkparamtype[] = {1,2,3,4,5,6,7};
24  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()};
25  TString      TrkParams::glpath[]       = {"","","","","","",""};  TString      TrkParams::glpath[]       = {"","","","","","",""};
26  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};
27    // ----------------
28    // other parameters
29    // ----------------
30    cDbg   TrkParams::init__dbg_mode       = {0,0,0};
31    int    TrkParams::init__pfa            = 14;//COG4
32    int    TrkParams::init__mini_trackmode = 0;
33    int    TrkParams::init__mini_istepmin  = 5; //3;
34    double TrkParams::init__mini_fact      = 1.e4; //100.;
35    float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};
36    float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};
37    
38  TrkParams::TrkParams(){  TrkParams::TrkParams(){
39    
# Line 40  float anint(float f){ Line 54  float anint(float f){
54      return ret1;              return ret1;        
55  }  }
56  /**  /**
57   * Static method to set the calibration to be loaded.   * \brief Static method to set the calibration to be loaded.
58    
59   * It retrieves the calibration associated to a given run, from   * It retrieves the calibration associated to a given run, from
60   * a given DB. It fills the F77 common.   * a given DB. It fills the F77 common.
# Line 49  float anint(float f){ Line 63  float anint(float f){
63   */   */
64  Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){  Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){
65    
66    //    cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl;
67    
68      if( !CalibIsLoaded()                          ||      if( !CalibIsLoaded()                          ||
69          (glrun->TRK_CALIB_USED==104 && !calib104) ||          (glrun->TRK_CALIB_USED==104 && !calib104) ||
70          (glrun->TRK_CALIB_USED!=104 && calib104)  ||          (glrun->TRK_CALIB_USED!=104 && calib104)  ||
# Line 56  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 72  Bool_t TrkParams::SetCalib( GL_RUN *glru
72          glrun->RUNHEADER_TIME > calib.TO_TIME     ||          glrun->RUNHEADER_TIME > calib.TO_TIME     ||
73          false ){          false ){
74    
75    //      cout <<">>> isloaded?      "<< CalibIsLoaded() << endl;
76    //      cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl;
77    //      cout <<">>> 104 loaded?    "<< calib104 <<endl;
78    //      cout <<">>> from time      "<< calib.FROM_TIME<<endl;
79    //      cout <<">>> to time        "<< calib.TO_TIME<<endl;
80    //      if( !dbc || (dbc && !dbc->IsConnected()) ){
81    
82    //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
83    //          TString host = "mysql://localhost/pamelaprod";
84    //          TString user = "anonymous";
85    //          TString psw = "";
86    //          const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
87    //          const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
88    //          const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
89    //          if ( !pamdbhost ) pamdbhost = "";
90    //          if ( !pamdbuser ) pamdbuser = "";
91    //          if ( !pamdbpsw ) pamdbpsw = "";
92    //          if ( strcmp(pamdbhost,"") ) host = pamdbhost;
93    //          if ( strcmp(pamdbuser,"") ) user = pamdbuser;
94    //          if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
95    //          if(TrkParams::VerboseMode()){
96    //              cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
97    //              cout<<"Connecting to DB"<<endl;
98    //              cout<<"HOST "<<host<<endl;
99    //              cout<<"USER "<<user<<endl;
100    //              cout<<"PSW  "<<psw<<endl;
101    //          }
102    //          dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
103    //          if( !dbc )return false;
104    //          if( !dbc->IsConnected() )return false;    
105    //          if(TrkParams::VerboseMode()){
106    //              cout << " ...done"<<endl;
107    //              cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
108    //          }
109    //      }
110    
111          GL_TRK_CALIB q2;          GL_TRK_CALIB q2;
112          GL_ROOT q3;          GL_ROOT q3;
113          GL_PARAM q4;          GL_PARAM q4;
114                    
115          cout << " UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl;          if(TrkParams::VerboseMode()){
116                cout << "--------------------------------------"<<endl;
117                cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl;
118            }
119          if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){          if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){
120              cout << "Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl;              cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl;
121              return false;              return false;
122          }          }
123          if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 )          if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 )
124              printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",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);    
125          if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){          if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){
126              cout << "Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl;              cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl;
127              return false;              return false;
128          }          }
129    
130          cout << "selected "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl;          if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl;
131          calib      = q2;          calib      = q2;
132          calibpathf = q3.PATH + q3.NAME;          calibpathf = q3.PATH + q3.NAME;
133          calib104   = (glrun->TRK_CALIB_USED==104);          calib104   = (glrun->TRK_CALIB_USED==104);
# Line 96  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 151  Bool_t TrkParams::SetCalib( GL_RUN *glru
151   */   */
152  UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){  UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){
153    
154        UInt_t validate = 1;
155      Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0};      Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0};
156  //    UInt_t timeaftercalib=120000; //2000;  //    UInt_t timeaftercalib=120000; //2000;
157      TString classname = caltrk->GetName();      TString classname = caltrk->GetName();
158  //  ----------  //  ----------
159  //  Check CRCs  //  Check CRCs
160  //  ----------  //  ----------
161        if(TrkParams::VerboseMode())cout << " DSP: ";
162      for(Int_t ipkt=0; ipkt<6; ipkt++){      for(Int_t ipkt=0; ipkt<6; ipkt++){
163          cout << "DSP n. "<<caltrk->DSPnumber[ipkt]<<endl;          if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt];
164          if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){          if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
165              if( caltrk->crc_hcal[ipkt] ){              if( caltrk->crc_hcal[ipkt] ){
166                  cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl;                      if(TrkParams::WarningMode())cout<<"(CRC Header)";
167    //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl;    
168  //              return 0; // :-(  //              return 0; // :-(
169                    validate = 0;
170              }              }
171              for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){              for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){
172                  cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl;                      if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")";
173    //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl;    
174  //              return 0; // :-(  //              return 0; // :-(
175                    validate = 0;
176              }              }
177          }          }
178      }      }
179        if(TrkParams::VerboseMode())cout << endl;;
180  //  -----------------------  //  -----------------------
181  //  Check missing packets:  //  Check missing packets:
182  //  -----------------------  //  -----------------------
# Line 160  UInt_t TrkParams::ValidateTrkCalib( Cali Line 222  UInt_t TrkParams::ValidateTrkCalib( Cali
222              build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );              build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );
223          };          };
224      }      }
225      if( npkts==6 )return 1; // :-)      if( npkts==6 ){}//return 1; // :-)
226      else cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl;          else {
227            if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl;    
228            validate = 0;
229        }
230  //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;  //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;
231    
232  //  -----------------------------------------------  //  -----------------------------------------------
# Line 211  UInt_t TrkParams::ValidateTrkCalib( Cali Line 275  UInt_t TrkParams::ValidateTrkCalib( Cali
275  //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl;  //       if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl;
276  //       return 0; // :-(  //       return 0; // :-(
277  //      }  //      }
278        return 1; // :-)  
279    //      return 1; // :-)
280    
281    //    cout << validate << endl;
282        return validate;
283    
284  }  }
285  /**  /**
# Line 220  UInt_t TrkParams::ValidateTrkCalib( Cali Line 288  UInt_t TrkParams::ValidateTrkCalib( Cali
288  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){
289    
290      cTrkCalib *ca = &pedsigbad_;      cTrkCalib *ca = &pedsigbad_;
291        ca->Reset();
292    
293      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
294      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
# Line 233  void TrkParams::FillACalibFrom(TFile* f0 Line 302  void TrkParams::FillACalibFrom(TFile* f0
302      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
303    
304      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
305      TrkParams::ValidateTrkCalib(calibdata1);  //    TrkParams::ValidateTrkCalib(calibdata1);
306      TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //    TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
307            
308        UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
309        UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
310        if( !test1 || !test2 ){
311            if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
312            TrkParams::calib.VALIDATION = 0;
313        }
314        if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
315    
316      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
317          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
318          dspn2=calibdata2->DSPnumber[i]-1;          dspn2=calibdata2->DSPnumber[i]-1;
319          /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */  //      cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl;      
320          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
321              Int_t j=(ii/128);              Int_t j=(ii/128);
322              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
323              ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];              if(dspn1>=0 && dspn1<12){
324              ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];                  ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];
325              ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);                  ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);
326              ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);                  ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];
327              ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];                  ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);
328              ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];                  if(calibdata1->DSPbad_par[i][ii]==0)
329              ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);                      ca->bad[jj][j][dspn1]=1;
330              ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);                  else if(calibdata1->DSPbad_par[i][ii]==1)
331              //        cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;                      ca->bad[jj][j][dspn1]=0;
332              //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;
333              //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;                  //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;
334              //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;              }
335            
336              //              if(dspn2>=0 && dspn2<12){
337              // invert the bad                  ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];
338              //                  ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);
339              if(calibdata1->DSPbad_par[i][ii]==0)                  ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];
340                  ca->bad[jj][j][dspn1]=1;                  ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);
341              else if(calibdata1->DSPbad_par[i][ii]==1)                  if(calibdata2->DSPbad_par[i][ii]==0)
342                  ca->bad[jj][j][dspn1]=0;                      ca->bad[jj][j][dspn2]=1;
343              if(calibdata2->DSPbad_par[i][ii]==0)                  else if(calibdata2->DSPbad_par[i][ii]==1)
344                  ca->bad[jj][j][dspn2]=1;                      ca->bad[jj][j][dspn2]=0;
345              else if(calibdata2->DSPbad_par[i][ii]==1)                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;
346                  ca->bad[jj][j][dspn2]=0;                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;
347                }
348          };          };
349      };      };
350                    
# Line 279  void TrkParams::FillACalibFrom(TFile* f0 Line 357  void TrkParams::FillACalibFrom(TFile* f0
357  void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){  void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){
358    
359      cTrkCalib *ca = &pedsigbad_;      cTrkCalib *ca = &pedsigbad_;
360    //    ca->Reset();
361    
362      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
363      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
# Line 292  void TrkParams::FillFCalibFrom(TFile* f0 Line 371  void TrkParams::FillFCalibFrom(TFile* f0
371      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
372    
373      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
374      TrkParams::ValidateTrkCalib(calibdata1);  //     TrkParams::ValidateTrkCalib(calibdata1);
375      TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
376        UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
377        UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
378        if( !test1 || !test2 ){
379            if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
380            TrkParams::calib.VALIDATION = 0;
381        }
382        if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
383                    
384      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
385          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 302  void TrkParams::FillFCalibFrom(TFile* f0 Line 388  void TrkParams::FillFCalibFrom(TFile* f0
388          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
389              Int_t j=(ii/128);              Int_t j=(ii/128);
390              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
391              ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];              if(dspn1>=0 && dspn1<12){
392              ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];                  ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];
393              ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];                  ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];
394              ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];                  if(calibdata1->DSPbad_par[i][ii]==0)
395              //        cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;                      ca->bad[jj][j][dspn1]=1;
396              //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;                  else if(calibdata1->DSPbad_par[i][ii]==1)
397              //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;                      ca->bad[jj][j][dspn1]=0;
398              //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;
399                            //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;
400              //              }
401              // invert the bad              if(dspn2>=0 && dspn2<12){
402              //                  ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];
403              if(calibdata1->DSPbad_par[i][ii]==0)                  ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];
404                  ca->bad[jj][j][dspn1]=1;                  if(calibdata2->DSPbad_par[i][ii]==0)
405              else if(calibdata1->DSPbad_par[i][ii]==1)                      ca->bad[jj][j][dspn2]=1;
406                  ca->bad[jj][j][dspn1]=0;                  else if(calibdata2->DSPbad_par[i][ii]==1)
407              if(calibdata2->DSPbad_par[i][ii]==0)                      ca->bad[jj][j][dspn2]=0;
408                  ca->bad[jj][j][dspn2]=1;                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;
409              else if(calibdata2->DSPbad_par[i][ii]==1)                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;
410                  ca->bad[jj][j][dspn2]=0;              }
411          };          };
412      };      };
413                    
# Line 334  void TrkParams::FillFCalibFrom(TFile* f0 Line 420  void TrkParams::FillFCalibFrom(TFile* f0
420  void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){  void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){
421    
422      cTrkCalib *ca = &pedsigbad_;      cTrkCalib *ca = &pedsigbad_;
423    //    ca->Reset();
424    
425      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
426      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
# Line 347  void TrkParams::FillTCalibFrom(TFile* f0 Line 434  void TrkParams::FillTCalibFrom(TFile* f0
434      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
435                    
436      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
437      TrkParams::ValidateTrkCalib(calibdata1);  //     TrkParams::ValidateTrkCalib(calibdata1);
438      TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
439        UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
440        UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
441        if( !test1 || !test2 ){
442            if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
443            TrkParams::calib.VALIDATION = 0;
444        }
445        if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
446    
447      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
448          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 357  void TrkParams::FillTCalibFrom(TFile* f0 Line 451  void TrkParams::FillTCalibFrom(TFile* f0
451          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
452              Int_t j=(ii/128);              Int_t j=(ii/128);
453              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
454              ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);              if(dspn1>=0 && dspn1<12){
455              ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);                  ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);
456              ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);                  ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);
457              ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);                  }
458                if(dspn2>=0 && dspn2<12){
459                    ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);
460                    ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);
461                }  
462          };          };
463      };      };
464                    
# Line 383  void TrkParams::FillTCalibFrom(TString p Line 481  void TrkParams::FillTCalibFrom(TString p
481  void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){  void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){
482            
483      cTrkMask *ma = &mask_;      cTrkMask *ma = &mask_;
484        ma->Reset();
485    
486      TrkCalib *calib = new TrkCalib();      TrkCalib *calib = new TrkCalib();
487    
# Line 405  void TrkParams::FillMask(TFile* f0, Int_ Line 504  void TrkParams::FillMask(TFile* f0, Int_
504              tr->GetEntry(ev_reg2);              tr->GetEntry(ev_reg2);
505          }          }
506          for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){          for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){
507              for(Int_t ivk=0; ivk<NVK; ivk++){              Int_t view   = calib->GetView(ipkt);
508                  Int_t view   = calib->GetView(ipkt);              if( (view-1)>= 0 && (view-1)<12 ){
509                  Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1);                  for(Int_t ivk=0; ivk<NVK; ivk++){
510                  Float_t sigmin = 0.;                      Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1);
511                  if(view%2)sigmin = 6.5;                      Float_t sigmin = 0.;
512                  else      sigmin = 2.5;                      if(view%2)sigmin = 6.5;
513                  Int_t mask = 1;                      else      sigmin = 2.5;
514                  if( sigm<sigmin )mask = 0;                      Int_t mask = 1;
515                                    if( sigm<sigmin )mask = 0;              
516                  ma->mask_vk_run[ivk][view-1] = mask;                      ma->mask_vk_run[ivk][view-1] = mask;                    
517                                }      
518  //              if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl;              }
             }    
519          }          }
520          if(tr)tr->Delete();          if(tr)tr->Delete();
521      }      }
522    
523        if(TrkParams::VerboseMode()){
524            for(Int_t iv=0; iv<NVIEW; iv++){
525                cout<<"view "<<setw(3)<<iv<<": ";
526                for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv];
527                cout << endl;
528            }
529        }
530    
531      if(calib)calib->Delete();      if(calib)calib->Delete();
532    
533  };  };
# Line 434  void TrkParams::FillMask(TFile* f0, Int_ Line 540  void TrkParams::FillMask(TFile* f0, Int_
540    
541    
542  /**  /**
543   * Static method to load calibration.   * \brief Static method to load calibration.
544   * Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens the   * Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens after the method TrkParams::SetCalib(***) is called.
  * first time the method is called (but it does not work becouse I didn't set any  
  * default calibration for the moment) or  after the method TrkParams::SetCalib(***) is called.  
545   */   */
546  Bool_t TrkParams::LoadCalib( ){  Bool_t TrkParams::LoadCalib( ){
547    
548      if( TrkParams::CalibIsLoaded() )return false;      if( TrkParams::CalibIsLoaded() )return false;
549    
 //    cTrkCalib *ca = new cTrkCalib; //&pedsigbad_;  
   
 //     extern cTrkCalib   pedsigbad_;  
 //     extern cTrkMask    mask_;  
   
     cout << "--------------------------------------"<<endl;  
     cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl;  
550      // =============================================================      // =============================================================
551      // retrieve calibration file needed to reduce data      // retrieve calibration file needed to reduce data
552      // =============================================================      // =============================================================
553      // if run OBT is > last calibration "expiration date"      // if run OBT is > last calibration "expiration date"
554      //  - search for new calibration packet      //  - search for new calibration packet
555      //  - load calibration parameters (full + truncated)          //  - load calibration parameters (full + truncated)    
556      cout << "Full pedestals for cluster finding:";      if(TrkParams::VerboseMode()){
557      cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl;          cout << "--------------------------------------"<<endl;
558            cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl;
559            cout << " Full pedestals for cluster finding:";
560            cout << " >> loading from LEVEL0 file: "<< calibpathf << endl;
561        }
562      FileStat_t t;      FileStat_t t;
563      if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false;      if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false;
564        
565      TFile *f0_c = new TFile(calibpathf);      bool alreadyopened = false;
566        TFile *f0_c=0;
567        f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf);
568        if(f0_c)alreadyopened=true;
569        else f0_c = new TFile(calibpathf);
570      if ( !f0_c ) return false;      if ( !f0_c ) return false;
571      cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2;  
572      cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl;      if(TrkParams::VerboseMode()){
573  //    ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);          cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2;
574            cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl;
575            cout << " - full+truncated parameters "<<endl;
576        }
577      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
578        if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;
579      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;  
580    
 //    };  
581      // =============================================================      // =============================================================
582      // retrieve calibration file needed to uncompress data      // retrieve calibration file needed to uncompress data
583      // =============================================================      // =============================================================
584      // if the run was compressed using default calib      // if the run was compressed using default calib
585      // load truncated pedestals from default      // load truncated pedestals from default
586      // otherwise reload them from on-line calibration      // otherwise reload them from on-line calibration
587      cout << "Truncated pedestals for uncompression:";      if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:";
588      if( calib104 ){      if( calib104 ){
589    
590          cout << " >> Loading default calibration: "<< calibpatht << endl;          if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl;
 //      ca->FillTCalibFrom(calibpatht);  
591          TrkParams::FillTCalibFrom(calibpatht);          TrkParams::FillTCalibFrom(calibpatht);
592                            
593      }else{      }else{
594    
595          if ( !f0_c ) return false;  //      if ( !f0_c ) return false;
596          cout << ">> Loading on-line calibration " << endl;          if(TrkParams::VerboseMode())cout << ">> already loaded " << endl;
597  //      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);  
598      };      };
599  //    for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl;      if(!alreadyopened)f0_c->Close();
600      f0_c->Close();      if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl;
 //    delete f0_c;  
     cout << "--------------------------------------"<<endl;  
601            
602      calibload = kTRUE;      calibload = kTRUE;
603      return true;      return true;
# Line 519  Int_t TrkParams::GetIndex( UInt_t type ) Line 621  Int_t TrkParams::GetIndex( UInt_t type )
621   */   */
622  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){  Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){
623    
 //    if( !dbc )return false;  
624    
625        UInt_t index = TrkParams::GetIndex( type );
626        if(index < 0)return false;
627    
628      if( !dbc || (dbc && !dbc->IsConnected()) ){      if( !TrkParams::IsLoaded(type) ||
629            glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||
630            glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||        
631            false ){
632    
633          cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;          if( !dbc || (dbc && !dbc->IsConnected()) ){
         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;  
634    
635      }              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
636                TString host = "mysql://localhost/pamelaprod";
637                TString user = "anonymous";
638                TString psw = "";
639                const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
640                const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
641                const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
642                if ( !pamdbhost ) pamdbhost = "";
643                if ( !pamdbuser ) pamdbuser = "";
644                if ( !pamdbpsw ) pamdbpsw = "";
645                if ( strcmp(pamdbhost,"") ) host = pamdbhost;
646                if ( strcmp(pamdbuser,"") ) user = pamdbuser;
647                if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
648                if(TrkParams::VerboseMode()){
649                    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
650                    cout<<"Connecting to DB"<<endl;
651                    cout<<"HOST "<<host<<endl;
652                    cout<<"USER "<<user<<endl;
653                    cout<<"PSW  "<<psw<<endl;
654                }
655                dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
656                if( !dbc )return false;
657                if( !dbc->IsConnected() )return false;    
658                if(TrkParams::VerboseMode()){
659                    cout << " ...done"<<endl;
660                    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
661                }
662            }
663    
     UInt_t index = TrkParams::GetIndex( type );  
     if(index < 0)return false;  
664    
665      UInt_t runheadtime = numeric_limits<UInt_t>::max();          UInt_t runheadtime = numeric_limits<UInt_t>::max();
666      if(glrun)runheadtime = glrun->RUNHEADER_TIME;          if(glrun)runheadtime = glrun->RUNHEADER_TIME;
667      else cout <<"Missing run info -- taking last entry "<<endl;          else cout <<"Missing run info -- taking last entry "<<endl;
668    
669      GL_PARAM q4;          GL_PARAM q4;
670      if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;
671    
672      gl[index]     = q4;          gl[index]     = q4;
673      glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
674      glload[index] = false;          glload[index] = false;
675      cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl;          if(TrkParams::VerboseMode())
676      return true;              cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<glrun->ID<<endl;
677  //    return TrkParams::Load(type);          return true;
678    
679        }
680        return false;
681    
682  };  };
683  /**  /**
# Line 580  Bool_t TrkParams::Set( TString path , UI Line 693  Bool_t TrkParams::Set( TString path , UI
693    
694      gl[index].TYPE= type;      gl[index].TYPE= type;
695      glpath[index] = path;      glpath[index] = path;
696      cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl;      if(TrkParams::VerboseMode())
697            cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl;
698      glload[index] = false;      glload[index] = false;
699    
700  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
# Line 639  Bool_t TrkParams::Set(UInt_t type){ Line 753  Bool_t TrkParams::Set(UInt_t type){
753                    
754      }      }
755    
756      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;
757  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
758      return true;      return true;
759    
# Line 654  Bool_t  TrkParams::Set( ){ Line 768  Bool_t  TrkParams::Set( ){
768    
769      Bool_t connected = false;      Bool_t connected = false;
770    
771      cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
772      TString host = "mysql://localhost/pamelaprod";      TString host = "mysql://localhost/pamelaprod";
773      TString user = "anonymous";      TString user = "anonymous";
774      TString psw = "";      TString psw = "";
# Line 667  Bool_t  TrkParams::Set( ){ Line 781  Bool_t  TrkParams::Set( ){
781      if ( strcmp(pamdbhost,"") ) host = pamdbhost;      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
782      if ( strcmp(pamdbuser,"") ) user = pamdbuser;      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
783      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
784      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(TrkParams::VerboseMode()){
785      cout<<"Connecting to DB"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
786      cout<<"HOST "<<host<<endl;          cout<<"Connecting to DB"<<endl;
787      cout<<"USER "<<user<<endl;          cout<<"HOST "<<host<<endl;
788      cout<<"PSW  "<<psw<<endl;          cout<<"USER "<<user<<endl;
789            cout<<"PSW  "<<psw<<endl;
790        }
791      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
792      if( dbc || dbc->IsConnected() )connected = true;      if( dbc || dbc->IsConnected() )connected = true;
793      else cout << " >> FAILED!!!"<<endl;      else cout << " >> DB connection FAILED!!!"<<endl;
794      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
795            
796      if(connected){      if(connected){
797          if ( !TrkParams::Set(0,dbc) )return false;          if ( !TrkParams::Set(0,dbc) )return false;
# Line 701  Bool_t TrkParams::Load(UInt_t type){ Line 817  Bool_t TrkParams::Load(UInt_t type){
817      switch( type ){      switch( type ){
818      //------------------------------------------      //------------------------------------------
819      case 1:          case 1:    
820          cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl;
821          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
822          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
823          path_.error   = 0;          path_.error   = 0;
# Line 711  Bool_t TrkParams::Load(UInt_t type){ Line 827  Bool_t TrkParams::Load(UInt_t type){
827          break;          break;
828      //------------------------------------------      //------------------------------------------
829      case 2:          case 2:    
830          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;
831          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
832          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
833          path_.error   = 0;          path_.error   = 0;
# Line 721  Bool_t TrkParams::Load(UInt_t type){ Line 837  Bool_t TrkParams::Load(UInt_t type){
837          break;          break;
838      //------------------------------------------      //------------------------------------------
839      case 3:          case 3:    
840          cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl;
841          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
842          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
843          path_.error   = 0;          path_.error   = 0;
# Line 731  Bool_t TrkParams::Load(UInt_t type){ Line 847  Bool_t TrkParams::Load(UInt_t type){
847          break;          break;
848      //------------------------------------------      //------------------------------------------
849      case 4:          case 4:    
850          cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl;
851          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
852          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
853          path_.error   = 0;          path_.error   = 0;
# Line 741  Bool_t TrkParams::Load(UInt_t type){ Line 857  Bool_t TrkParams::Load(UInt_t type){
857          break;          break;
858      //------------------------------------------      //------------------------------------------
859      case 5:          case 5:    
860          cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl;
861          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
862          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
863          path_.error   = 0;          path_.error   = 0;
# Line 751  Bool_t TrkParams::Load(UInt_t type){ Line 867  Bool_t TrkParams::Load(UInt_t type){
867          break;          break;
868      //------------------------------------------      //------------------------------------------
869      case 6:          case 6:    
870          cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl;
871          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
872          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
873          path_.error   = 0;          path_.error   = 0;
# Line 761  Bool_t TrkParams::Load(UInt_t type){ Line 877  Bool_t TrkParams::Load(UInt_t type){
877          break;          break;
878      //------------------------------------------      //------------------------------------------
879      case 7:          case 7:    
880          cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl;          if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl;
881          strcpy(path_.path,glpath[index].Data());          strcpy(path_.path,glpath[index].Data());
882          path_.pathlen = glpath[index].Length();          path_.pathlen = glpath[index].Length();
883          path_.error   = 0;          path_.error   = 0;
884  //      fillpedsigfromdefault_();  //      fillpedsigfromdefault_();
885          cout << ">> not implemented <<"<<endl;          if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl;
886          if(path_.error) return false;          if(path_.error) return false;
887          glload[index]=true;          glload[index]=true;
888          break;          break;
889      default:      default:
890          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;
891          return false;          return false;
892      };      };
893    
# Line 787  Bool_t TrkParams::IsLoaded( ){ Line 903  Bool_t TrkParams::IsLoaded( ){
903      return true;      return true;
904  };  };
905    
906    
907    /**
908     * Get BY (kGauss)
909     * @param v (x,y,z) coordinates in cm
910     */
911    float TrkParams::GetBX(float* v){
912        TrkParams::Load(1);
913        if( !TrkParams::IsLoaded(1) )return 0.;
914        float b[3];
915        gufld_(v,b);
916        return b[0]/10.;
917    }
918    /**
919     * Get BY (kGauss)
920     * @param v (x,y,z) coordinates in cm
921     */
922    float TrkParams::GetBY(float* v){
923        TrkParams::Load(1);
924        if( !TrkParams::IsLoaded(1) )return 0.;
925        float b[3];
926        gufld_(v,b);
927        return b[1]/10.;
928    }
929    /**
930     * Get BY (kGauss)
931     * @param v (x,y,z) coordinates in cm
932     */
933    float TrkParams::GetBZ(float* v){
934        TrkParams::Load(1);
935        if( !TrkParams::IsLoaded(1) )return 0.;
936        float b[3];
937        gufld_(v,b);
938        return b[2]/10.;
939    }
940    
941    
942    
943    /**
944     * \brief Set tracking mode (0=standard. 1=???)
945     */
946    void TrkParams::SetTrackingMode(int trackmode) {
947        init__mini_trackmode = trackmode;
948        SetTrackingMode();
949    };
950    /**
951     * \brief Set fit-precision factor (typical value fact=100.)
952     */
953    void TrkParams::SetPrecisionFactor(double fact){
954        init__mini_fact      = fact;
955        SetPrecisionFactor();
956    };
957    /**
958     * \brief Set minimum number of step in track fitting
959     */
960    void TrkParams::SetStepMin(int istepmin){
961        init__mini_istepmin  = istepmin;
962        SetStepMin();
963    };
964    
965    /**
966     * Fill F77 commons with PFA settings
967     */
968    void TrkParams::SetPFA(){
969        sw_.pfaid = init__pfa;    
970        for(int i=0; i<6; i++){
971            pfa_.e234ax[i] = init__pfa_e234ax[i];
972            pfa_.e234ay[i] = init__pfa_e234ay[i];
973        }
974    };
975    /**
976     * \brief Set p.f.a.
977     *
978     * Implemented algorythms:
979     * 0  ETA
980     * 1  ---
981     * 2  ETA2
982     * 3  ETA3
983     * 4  ETA4
984     * 5  ETAL ==> ETA+LANDI
985     * 10 COG
986     * 11 COG1
987     * 12 COG2
988     * 13 COG3
989     * 14 COG4
990     */
991    void TrkParams::SetPFA(int pfaid){
992        init__pfa  = pfaid;
993        SetPFA();
994    };
995    /**
996     * \brief Set p.f.a. angular intervals
997     *
998     * This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4
999     * algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)).
1000     * @param v Pointer to a vector of 12 components, which represent the
1001     * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly.
1002     *
1003     */
1004    void TrkParams::SetPFA(float *v){
1005        for(int i=0; i<6; i++){
1006            init__pfa_e234ax[i]  = v[i];
1007            init__pfa_e234ay[i]  = v[i+6];
1008        }
1009        SetPFA();
1010    };
1011    
1012    
1013    /**
1014     * \brief Get spatial resolution.
1015     *
1016     * Method to retrieve the spatial resolution associated with the
1017     * adopted p.f.a.
1018     * @param view Tracker view (1-12)
1019     * @param angle Track projected angle
1020     *
1021     * In order to change p.f.a. use the SetPFA(int pfaid) method, eg.:
1022     *
1023     *  TrkParams::SetPFA(0)  // ETA
1024     *
1025     */
1026    float TrkParams::GetResolution(int view, float angle){
1027        float res = 1000;
1028        if( init__pfa == 0 )res = riseta_(&view,&angle);
1029        else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl;
1030        return res;
1031    }
1032    
1033    
1034    
1035    
1036  ClassImp(TrkParams);  ClassImp(TrkParams);

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.23