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

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

  ViewVC Help
Powered by ViewVC 1.1.23