/[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.8 by pam-fi, Mon May 14 11:03:05 2007 UTC revision 1.22 by pam-fi, Sat Mar 22 08:32:50 2008 UTC
# Line 1  Line 1 
1    
2  /**  /**
3   * \file TrkParams.cpp   * \file TrkParams.cpp
4   * \author Elena Vannuccini   * \author Elena Vannuccini
# Line 5  Line 6 
6    
7  #include <TrkParams.h>  #include <TrkParams.h>
8  #include <iostream>  #include <iostream>
9    #include <iomanip>
10  using namespace std;  using namespace std;
11    
12    
# Line 23  UInt_t       TrkParams::trkparamtype[] = Line 25  UInt_t       TrkParams::trkparamtype[] =
25  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()};
26  TString      TrkParams::glpath[]       = {"","","","","","",""};  TString      TrkParams::glpath[]       = {"","","","","","",""};
27  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};  Bool_t       TrkParams::glload[]       = {false,false,false,false,false,false,false};
 cDbg         TrkParams::dbg_mode       = {0,0,0};  
28  // ----------------  // ----------------
29  // other parameters  // other parameters
30  // ----------------  // ----------------
31  int    TrkParams::init__pfa            = 14;//COG4  cDbg   TrkParams::init__dbg_mode       = {0,0,0};
32    //int    TrkParams::init__pfa            = 14;//COG4
33    int    TrkParams::init__pfa            = 5;//ETAL
34  int    TrkParams::init__mini_trackmode = 0;  int    TrkParams::init__mini_trackmode = 0;
35  int    TrkParams::init__mini_istepmin  = 3;  int    TrkParams::init__mini_istepmin  = 5; //3;
36  double TrkParams::init__mini_fact      = 100.;  double TrkParams::init__mini_fact      = 1.e4; //100.;
37    float  TrkParams::init__pfa_e234ax[]   = {0.,10.,10.,15.,15.,90.};
38    float  TrkParams::init__pfa_e234ay[]   = {0.,20.,90.,90.,90.,90.};
39    double TrkParams::init__deltab_0       = 0.;
40    double TrkParams::init__deltab_1       = 0.;
41    double TrkParams::init__dlt            = 1.e-5;
42    // ------------------------------------------
43    // nominal z-coordinates to define acceptance
44    // ------------------------------------------
45    int   TrkParams::nGF   = NGF;
46    float TrkParams::zGF[] = {+53.74,+53.04,+23.94,+23.44,+22.29,+21.83,+13.39,+4.49,-4.41,-13.31,-21.83,-22.22,-23.49,-24.34};
47    float TrkParams::xGF_min[] = {-20.40,-20.40,-9.00,-9.00,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-9.00,-9.00};
48    float TrkParams::xGF_max[] = {+20.40,+20.40,+9.00,+9.00,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+9.00,+9.00};
49    // float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-7.25,-7.25,-7.25,-7.25,-6.57,-6.75,-7.50,-7.50};
50    // float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.75,+6.75,+6.75,+6.75,+6.57,+7.25,+7.50,+7.50};
51    // per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa
52    float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-6.57,-6.57,-6.57,-6.57,-6.57,-6.75,-7.50,-7.50};
53    float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.57,+6.57,+6.57,+6.57,+6.57,+7.25,+7.50,+7.50};
54    TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"};
55    
56  TrkParams::TrkParams(){  TrkParams::TrkParams(){
57    
# Line 50  float anint(float f){ Line 71  float anint(float f){
71      ret1=(float)ret;      ret1=(float)ret;
72      return ret1;              return ret1;        
73  }  }
74    
75    /**
76     * Static method to open a DB connection.
77     * HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST,
78     * $PAM_DBUSER and $PAM_DBPSW
79     * NB! The method create a new connection, which has to be closed by the user.
80     */
81    TSQLServer* TrkParams::SetDBConnection(){
82    
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::DebugMode()){
96            cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
97            cout<<"TrkParams::SetDBConnection() >> Connecting to DB"<<endl;
98            cout<<"HOST "<<host<<endl;
99            cout<<"USER "<<user<<endl;
100            cout<<"PSW  "<<psw<<endl;
101        }
102        TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
103        if( !dbc )return NULL;
104        if( !dbc->IsConnected() )return NULL;    
105        stringstream myquery;  // EMILIANO
106        myquery.str("");  // EMILIANO
107        myquery << "SET time_zone='+0:00'";  // EMILIANO
108        dbc->Query(myquery.str().c_str());  // EMILIANO
109        if(TrkParams::DebugMode()){
110            cout << " ...done"<<endl;
111            cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
112        }
113        
114        return dbc;
115    }
116  /**  /**
117   * Static method to set the calibration to be loaded.   * \brief Static method to set the calibration to be loaded.
118    
119   * It retrieves the calibration associated to a given run, from   * It retrieves the calibration associated to a given run, from
120   * a given DB. It fills the F77 common.   * a given DB. It fills the F77 common.
# Line 69  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 132  Bool_t TrkParams::SetCalib( GL_RUN *glru
132          glrun->RUNHEADER_TIME > calib.TO_TIME     ||          glrun->RUNHEADER_TIME > calib.TO_TIME     ||
133          false ){          false ){
134    
135    
136          GL_TRK_CALIB q2;          GL_TRK_CALIB q2;
137          GL_ROOT q3;          GL_ROOT q3;
138          GL_PARAM q4;          GL_PARAM q4;
139    
140    
141            bool LOCAL_CONNECTION = false;
142            if( !dbc || (dbc && !dbc->IsConnected()) ){
143    
144                if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
145                dbc = TrkParams::SetDBConnection();
146                if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
147    
148            }
149    
150                    
151          if(TrkParams::VerboseMode()){          if(TrkParams::VerboseMode()){
152              cout << "--------------------------------------"<<endl;              cout << "--------------------------------------"<<endl;
# Line 98  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 173  Bool_t TrkParams::SetCalib( GL_RUN *glru
173              calibpatht = q4.PATH + q4.NAME;              calibpatht = q4.PATH + q4.NAME;
174          }          }
175                    
176            if(LOCAL_CONNECTION){
177                delete dbc;
178                dbc->Close();
179                if(TrkParams::DebugMode()){
180                    cout << " DB connection closed."<<endl;
181                }      
182            }
183    
184  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
185          return true;          return true;
# Line 112  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 194  Bool_t TrkParams::SetCalib( GL_RUN *glru
194   */   */
195  UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){  UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){
196    
197        UInt_t validate = 1;
198      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};
199  //    UInt_t timeaftercalib=120000; //2000;  //    UInt_t timeaftercalib=120000; //2000;
200      TString classname = caltrk->GetName();      TString classname = caltrk->GetName();
# Line 126  UInt_t TrkParams::ValidateTrkCalib( Cali Line 209  UInt_t TrkParams::ValidateTrkCalib( Cali
209                  if(TrkParams::WarningMode())cout<<"(CRC Header)";                  if(TrkParams::WarningMode())cout<<"(CRC Header)";
210  //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl;      //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl;    
211  //              return 0; // :-(  //              return 0; // :-(
212                    validate = 0;
213              }              }
214              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] ){
215                  if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")";                  if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")";
216  //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl;      //              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl;    
217  //              return 0; // :-(  //              return 0; // :-(
218                    validate = 0;
219              }              }
220          }          }
221      }      }
# Line 180  UInt_t TrkParams::ValidateTrkCalib( Cali Line 265  UInt_t TrkParams::ValidateTrkCalib( Cali
265              build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );              build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );
266          };          };
267      }      }
268      if( npkts==6 )return 1; // :-)      if( npkts==6 ){}//return 1; // :-)
269      else {      else {
270          if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl;              if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-(  ( "<<npkts<<" instead of 6 ) --> "<<endl;    
271            validate = 0;
272      }      }
273  //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;  //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;
274    
# Line 232  UInt_t TrkParams::ValidateTrkCalib( Cali Line 318  UInt_t TrkParams::ValidateTrkCalib( Cali
318  //       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;
319  //       return 0; // :-(  //       return 0; // :-(
320  //      }  //      }
321        return 1; // :-)  
322    //      return 1; // :-)
323    
324    //    cout << validate << endl;
325        return validate;
326    
327  }  }
328  /**  /**
# Line 241  UInt_t TrkParams::ValidateTrkCalib( Cali Line 331  UInt_t TrkParams::ValidateTrkCalib( Cali
331  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){
332    
333      cTrkCalib *ca = &pedsigbad_;      cTrkCalib *ca = &pedsigbad_;
334        ca->Reset();
335    
336      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
337      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
# Line 254  void TrkParams::FillACalibFrom(TFile* f0 Line 345  void TrkParams::FillACalibFrom(TFile* f0
345      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
346    
347      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
348      TrkParams::ValidateTrkCalib(calibdata1);  //    TrkParams::ValidateTrkCalib(calibdata1);
349      TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //    TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
350            
351        UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
352        UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
353        if( !test1 || !test2 ){
354            if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
355            TrkParams::calib.VALIDATION = 0;
356        }
357        if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
358    
359      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
360          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
361          dspn2=calibdata2->DSPnumber[i]-1;          dspn2=calibdata2->DSPnumber[i]-1;
362          /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */  //      cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl;      
363          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
364              Int_t j=(ii/128);              Int_t j=(ii/128);
365              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
366              ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];              if(dspn1>=0 && dspn1<12){
367              ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];                  ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];
368              ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);                  ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);
369              ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);                  ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];
370              ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];                  ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);
371              ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];                  if(calibdata1->DSPbad_par[i][ii]==0)
372              ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);                      ca->bad[jj][j][dspn1]=1;
373              ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);                  else if(calibdata1->DSPbad_par[i][ii]==1)
374              //        cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;                      ca->bad[jj][j][dspn1]=0;
375              //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;
376              //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;                  //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;
377              //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;              }
378            
379              //              if(dspn2>=0 && dspn2<12){
380              // invert the bad                  ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];
381              //                  ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);
382              if(calibdata1->DSPbad_par[i][ii]==0)                  ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];
383                  ca->bad[jj][j][dspn1]=1;                  ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);
384              else if(calibdata1->DSPbad_par[i][ii]==1)                  if(calibdata2->DSPbad_par[i][ii]==0)
385                  ca->bad[jj][j][dspn1]=0;                      ca->bad[jj][j][dspn2]=1;
386              if(calibdata2->DSPbad_par[i][ii]==0)                  else if(calibdata2->DSPbad_par[i][ii]==1)
387                  ca->bad[jj][j][dspn2]=1;                      ca->bad[jj][j][dspn2]=0;
388              else if(calibdata2->DSPbad_par[i][ii]==1)                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;
389                  ca->bad[jj][j][dspn2]=0;                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;
390                }
391          };          };
392      };      };
393                    
# Line 300  void TrkParams::FillACalibFrom(TFile* f0 Line 400  void TrkParams::FillACalibFrom(TFile* f0
400  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){
401    
402      cTrkCalib *ca = &pedsigbad_;      cTrkCalib *ca = &pedsigbad_;
403    //    ca->Reset();
404    
405      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
406      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
# Line 313  void TrkParams::FillFCalibFrom(TFile* f0 Line 414  void TrkParams::FillFCalibFrom(TFile* f0
414      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
415    
416      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
417      TrkParams::ValidateTrkCalib(calibdata1);  //     TrkParams::ValidateTrkCalib(calibdata1);
418      TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
419        UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
420        UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
421        if( !test1 || !test2 ){
422            if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
423            TrkParams::calib.VALIDATION = 0;
424        }
425        if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
426                    
427      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
428          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 323  void TrkParams::FillFCalibFrom(TFile* f0 Line 431  void TrkParams::FillFCalibFrom(TFile* f0
431          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
432              Int_t j=(ii/128);              Int_t j=(ii/128);
433              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
434              ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];              if(dspn1>=0 && dspn1<12){
435              ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];                  ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];
436              ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];                  ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];
437              ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];                  if(calibdata1->DSPbad_par[i][ii]==0)
438              //        cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;                      ca->bad[jj][j][dspn1]=1;
439              //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;                  else if(calibdata1->DSPbad_par[i][ii]==1)
440              //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;                      ca->bad[jj][j][dspn1]=0;
441              //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;
442                            //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;
443              //              }
444              // invert the bad              if(dspn2>=0 && dspn2<12){
445              //                  ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];
446              if(calibdata1->DSPbad_par[i][ii]==0)                  ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];
447                  ca->bad[jj][j][dspn1]=1;                  if(calibdata2->DSPbad_par[i][ii]==0)
448              else if(calibdata1->DSPbad_par[i][ii]==1)                      ca->bad[jj][j][dspn2]=1;
449                  ca->bad[jj][j][dspn1]=0;                  else if(calibdata2->DSPbad_par[i][ii]==1)
450              if(calibdata2->DSPbad_par[i][ii]==0)                      ca->bad[jj][j][dspn2]=0;
451                  ca->bad[jj][j][dspn2]=1;                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;
452              else if(calibdata2->DSPbad_par[i][ii]==1)                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;
453                  ca->bad[jj][j][dspn2]=0;              }
454          };          };
455      };      };
456                    
# Line 355  void TrkParams::FillFCalibFrom(TFile* f0 Line 463  void TrkParams::FillFCalibFrom(TFile* f0
463  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){
464    
465      cTrkCalib *ca = &pedsigbad_;      cTrkCalib *ca = &pedsigbad_;
466    //    ca->Reset();
467    
468      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
469      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
# Line 368  void TrkParams::FillTCalibFrom(TFile* f0 Line 477  void TrkParams::FillTCalibFrom(TFile* f0
477      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
478                    
479      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
480      TrkParams::ValidateTrkCalib(calibdata1);  //     TrkParams::ValidateTrkCalib(calibdata1);
481      TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
482        UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
483        UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
484        if( !test1 || !test2 ){
485            if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
486            TrkParams::calib.VALIDATION = 0;
487        }
488        if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
489    
490      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
491          dspn1=calibdata1->DSPnumber[i]-1;          dspn1=calibdata1->DSPnumber[i]-1;
# Line 378  void TrkParams::FillTCalibFrom(TFile* f0 Line 494  void TrkParams::FillTCalibFrom(TFile* f0
494          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
495              Int_t j=(ii/128);              Int_t j=(ii/128);
496              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
497              ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);              if(dspn1>=0 && dspn1<12){
498              ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);                  ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);
499              ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);                  ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);
500              ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);                  }
501                if(dspn2>=0 && dspn2<12){
502                    ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);
503                    ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);
504                }  
505          };          };
506      };      };
507                    
# Line 404  void TrkParams::FillTCalibFrom(TString p Line 524  void TrkParams::FillTCalibFrom(TString p
524  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){
525            
526      cTrkMask *ma = &mask_;      cTrkMask *ma = &mask_;
527        ma->Reset();
528    
529      TrkCalib *calib = new TrkCalib();      TrkCalib *calib = new TrkCalib();
530    
# Line 426  void TrkParams::FillMask(TFile* f0, Int_ Line 547  void TrkParams::FillMask(TFile* f0, Int_
547              tr->GetEntry(ev_reg2);              tr->GetEntry(ev_reg2);
548          }          }
549          for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){          for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){
550              for(Int_t ivk=0; ivk<NVK; ivk++){              Int_t view   = calib->GetView(ipkt);
551                  Int_t view   = calib->GetView(ipkt);              if( (view-1)>= 0 && (view-1)<12 ){
552                  Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1);                  for(Int_t ivk=0; ivk<NVK; ivk++){
553                  Float_t sigmin = 0.;                      Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1);
554                  if(view%2)sigmin = 6.5;                      Float_t sigmin = 0.;
555                  else      sigmin = 2.5;                      if(view%2)sigmin = 6.5;
556                  Int_t mask = 1;                      else      sigmin = 2.5;
557                  if( sigm<sigmin )mask = 0;                      Int_t mask = 1;
558                                    if( sigm<sigmin )mask = 0;              
559                  ma->mask_vk_run[ivk][view-1] = mask;                      ma->mask_vk_run[ivk][view-1] = mask;                    
560                                }      
561  //              if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl;              }
             }    
562          }          }
563          if(tr)tr->Delete();          if(tr)tr->Delete();
564      }      }
565    
566        if(TrkParams::VerboseMode()){
567            for(Int_t iv=0; iv<NVIEW; iv++){
568                cout<<"view "<<setw(3)<<iv<<": ";
569                for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv];
570                cout << endl;
571            }
572        }
573    
574      if(calib)calib->Delete();      if(calib)calib->Delete();
575    
576  };  };
# Line 455  void TrkParams::FillMask(TFile* f0, Int_ Line 583  void TrkParams::FillMask(TFile* f0, Int_
583    
584    
585  /**  /**
586   * Static method to load calibration.   * \brief Static method to load calibration.
587   * 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.  
588   */   */
589  Bool_t TrkParams::LoadCalib( ){  Bool_t TrkParams::LoadCalib( ){
590    
# Line 492  Bool_t TrkParams::LoadCalib( ){ Line 618  Bool_t TrkParams::LoadCalib( ){
618          cout << " - full+truncated parameters "<<endl;          cout << " - full+truncated parameters "<<endl;
619      }      }
620      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
621      if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;      if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl;
622      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
623    
624      // =============================================================      // =============================================================
# Line 532  Int_t TrkParams::GetIndex( UInt_t type ) Line 658  Int_t TrkParams::GetIndex( UInt_t type )
658   * @param dbc   Database   * @param dbc   Database
659   * @param type  Parameter type   * @param type  Parameter type
660   * @return FALSE if parameter set fails.   * @return FALSE if parameter set fails.
661   * If glrun==NULL the last parameter entry from GL_PARAM table is set.   * If glrun==NULL the first parameter entry from GL_PARAM table is set.
662   * If dbc==NULL, try to open a connection taking DB-connection   * If dbc==NULL, try to open a connection taking DB-connection
663   * parameters from PAMELA environment variables.   * parameters from PAMELA environment variables.
664   */   */
# Line 542  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 668  Bool_t TrkParams::Set( GL_RUN* glrun , T
668      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
669      if(index < 0)return false;      if(index < 0)return false;
670    
671        UInt_t runheadtime=0;
672        UInt_t runid=0;
673    //    UInt_t runheadtime = numeric_limits<UInt_t>::max();
674        if(glrun){
675            runheadtime = glrun->RUNHEADER_TIME;
676            runid       = glrun->ID;
677        }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
678    
679    //    if(TrkParams::VerboseMode())
680        if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
681    
682    
683      if( !TrkParams::IsLoaded(type) ||      if( !TrkParams::IsLoaded(type) ||
684          glrun->RUNHEADER_TIME < gl[index].FROM_TIME   ||          runheadtime < gl[index].FROM_TIME   ||
685          glrun->RUNHEADER_TIME > gl[index].TO_TIME     ||                  runheadtime > gl[index].TO_TIME     ||  
686          false ){          false ){
687    
688            bool LOCAL_CONNECTION = false;
689          if( !dbc || (dbc && !dbc->IsConnected()) ){          if( !dbc || (dbc && !dbc->IsConnected()) ){
690    
691              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
692              TString host = "mysql://localhost/pamelaprod";              dbc = TrkParams::SetDBConnection();
693              TString user = "anonymous";              if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
             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;  
             if(TrkParams::VerboseMode()){  
                 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;      
             if(TrkParams::VerboseMode()){  
                 cout << " ...done"<<endl;  
                 cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
             }  
         }  
694    
695            }
         UInt_t runheadtime = numeric_limits<UInt_t>::max();  
         if(glrun)runheadtime = glrun->RUNHEADER_TIME;  
         else cout <<"Missing run info -- taking last entry "<<endl;  
696    
697          GL_PARAM q4;          GL_PARAM q4;
698          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;          if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false;      
699            if(LOCAL_CONNECTION){
700                dbc->Close();
701                delete dbc;
702                if(TrkParams::DebugMode()){
703                    cout << " DB connection closed."<<endl;
704                }      
705            }
706          gl[index]     = q4;          gl[index]     = q4;
707          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
708          glload[index] = false;          glload[index] = false;
709          if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl;  
710          return true;          return true;
711    
712      }      }
# Line 609  Bool_t TrkParams::Set( TString path , UI Line 726  Bool_t TrkParams::Set( TString path , UI
726    
727      gl[index].TYPE= type;      gl[index].TYPE= type;
728      glpath[index] = path;      glpath[index] = path;
729      if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl;      if(TrkParams::VerboseMode())
730            cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl;
731      glload[index] = false;      glload[index] = false;
732    
733  //    return TrkParams::Load(type);  //    return TrkParams::Load(type);
# Line 625  Bool_t TrkParams::Set( TString path , UI Line 743  Bool_t TrkParams::Set( TString path , UI
743   */   */
744  Bool_t TrkParams::Set(UInt_t type){  Bool_t TrkParams::Set(UInt_t type){
745    
     UInt_t index = TrkParams::GetIndex( type );  
     if(index < 0)return false;  
   
     gl[index].TYPE= type;  
     glload[index] = false;  
   
     // -----------------------------------------  
     // check if enviroment variables are defined  
     // -----------------------------------------  
     glpath[index] = gSystem->Getenv("PAM_CALIB");  
746    
747      if( !glpath[index].IsNull() ){      return Set(0,0,type);
       
         switch(type){  
         case 1:  
             glpath[index].Append("/trk-param/field_param-0/");  
             break;  
         case 2:  
             glpath[index].Append("/trk-param/mip_param-0/");  
             break;  
         case 3:  
             glpath[index].Append("/trk-param/charge_param-1/");  
             break;  
         case 4:  
             glpath[index].Append("/trk-param/eta_param-0/");  
             break;  
         case 5:  
             glpath[index].Append("/trk-param/align_param-0/");  
             break;  
         case 6:  
             glpath[index].Append("/trk-param/mask_param-1/");  
             break;  
         case 7:  
             glpath[index].Append("/trk-param/default_calib/");  
             break;  
         }  
           
     }else{  
         cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl;  
         return false;  
           
     }  
748    
     if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl;  
 //    return TrkParams::Load(type);  
     return true;  
749    
750  };  };
751  /**  /**
# Line 681  Bool_t TrkParams::Set(UInt_t type){ Line 756  Bool_t TrkParams::Set(UInt_t type){
756   */   */
757  Bool_t  TrkParams::Set( ){  Bool_t  TrkParams::Set( ){
758    
     Bool_t connected = false;  
759    
760  //    cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;      for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;
     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;  
     if(TrkParams::VerboseMode()){  
         cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
         cout<<"Connecting to DB"<<endl;  
         cout<<"HOST "<<host<<endl;  
         cout<<"USER "<<user<<endl;  
         cout<<"PSW  "<<psw<<endl;  
     }  
     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  
     if( dbc || dbc->IsConnected() )connected = true;  
     else cout << " >> DB connection FAILED!!!"<<endl;  
     if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  
       
     if(connected){  
         if ( !TrkParams::Set(0,dbc) )return false;  
         dbc->Close();  
     }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false;  
761    
762      return true;      return true;
763  }  }
# Line 853  float TrkParams::GetBZ(float* v){ Line 899  float TrkParams::GetBZ(float* v){
899      return b[2]/10.;      return b[2]/10.;
900  }  }
901    
902    
903  /**  /**
904   * \brief Set tracking mode (0=standard. 1=???)   * \brief Set tracking mode (0=standard. 1=???)
905   */   */
906  void TrkParams::SetTrackingMode(int trackmode) {  void TrkParams::SetTrackingMode(int trackmode) {
907      init__mini_trackmode = trackmode;      init__mini_trackmode = trackmode;
908      SetTrackingMode();      SetTrackingMode(); //fill F77 common
909  };  };
910  /**  /**
911   * \brief Set fit-precision factor (typical value fact=100.)   * \brief Set fit-precision factor (typical value fact=100.)
912   */   */
913  void TrkParams::SetPrecisionFactor(double fact){  void TrkParams::SetPrecisionFactor(double fact){
914      init__mini_fact      = fact;      init__mini_fact      = fact;
915      SetPrecisionFactor();      SetPrecisionFactor(); //fill F77 common
916  };  };
917  /**  /**
918   * \brief Set minimum number of step in track fitting   * \brief Set minimum number of step in track fitting
919   */   */
920  void TrkParams::SetStepMin(int istepmin){  void TrkParams::SetStepMin(int istepmin){
921      init__mini_istepmin  = istepmin;      init__mini_istepmin  = istepmin;
922      SetStepMin();      SetStepMin(); //fill F77 common
923    };
924    /**
925     * \brief Set deltaB parameters (id=0,1)
926     */
927    void TrkParams::SetDeltaB(int id,double db){
928        if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl;
929        if(id==0)init__deltab_0 = db;
930        if(id==1)init__deltab_1 = db;
931        SetDeltaB(); //fill F77 common
932    };
933    /**
934     * \brief Set DLT-grkuta precision factor (default 1.e-4)
935     */
936    void TrkParams::SetDLT(double fact){
937        init__dlt               = fact;
938        SetDLT(); //fill F77 common
939  };  };
940    
941  /**  /**
942     * \brief Fill F77 commons with PFA settings
943     */
944    void TrkParams::SetPFA(){
945        sw_.pfaid = init__pfa;    
946        for(int i=0; i<6; i++){
947            pfa_.e234ax[i] = init__pfa_e234ax[i];
948            pfa_.e234ay[i] = init__pfa_e234ay[i];
949        }
950    };
951    /**
952   * \brief Set p.f.a.   * \brief Set p.f.a.
953   *   *
954   * Implemented algorythms:   * Implemented algorythms:
955   * 0  ETA (default)   * 0  ETA
956   * 1  ---   * 1  ---
957   * 2  ETA2   * 2  ETA2
958   * 3  ETA3   * 3  ETA3
959   * 4  ETA4   * 4  ETA4
960     * 5  ETAL ==> ETA+LANDI
961   * 10 COG   * 10 COG
962   * 11 COG1   * 11 COG1
963   * 12 COG2   * 12 COG2
# Line 892  void TrkParams::SetStepMin(int istepmin) Line 966  void TrkParams::SetStepMin(int istepmin)
966   */   */
967  void TrkParams::SetPFA(int pfaid){  void TrkParams::SetPFA(int pfaid){
968      init__pfa  = pfaid;      init__pfa  = pfaid;
969      SetStepMin();      SetPFA(); //fill F77 common
970    };
971    /**
972     * \brief Set p.f.a. angular intervals
973     *
974     * This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4
975     * algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)).
976     * @param v Pointer to a vector of 12 components, which represent the
977     * angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly.
978     *
979     */
980    void TrkParams::SetPFA(float *v){
981        for(int i=0; i<6; i++){
982            init__pfa_e234ax[i]  = v[i];
983            init__pfa_e234ay[i]  = v[i+6];
984        }
985        SetPFA(); //fill F77 common
986    };
987    
988    
989    /**
990     * \brief Get spatial resolution.
991     *
992     * Method to retrieve the spatial resolution associated with the
993     * adopted p.f.a.
994     * @param view Tracker view (1-12)
995     * @param angle Track projected angle
996     *
997     * In order to change p.f.a. use the SetPFA(int pfaid) method, eg.:
998     *
999     *  TrkParams::SetPFA(0)  // ETA
1000     *
1001     */
1002    float TrkParams::GetResolution(int view, float angle){
1003        float res = 1000;
1004        if     ( init__pfa == 0 )res = riseta_(&view,&angle);
1005        else if( init__pfa == 5 )res = riseta_(&view,&angle);
1006        else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl;
1007        return res;
1008    }
1009    
1010    /**
1011     * Returns the number of angular bins for p.f.a. parameters
1012     */
1013    int TrkParams::GetPFA_NbinsAngle(){
1014        TrkParams::Load(4);
1015        if( !TrkParams::IsLoaded(4) ){
1016            cout << "int TrkParams::GetPFA_NbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1017            return 0;
1018        }
1019        return pfa_.nangbin;
1020  };  };
1021    /**
1022     * Returns the number of eta bins for p.f.a. parameters
1023     */
1024    int TrkParams::GetPFA_NbinsETA(){
1025        TrkParams::Load(4);
1026        if( !TrkParams::IsLoaded(4) ){
1027            cout << "int TrkParams::GetPFA_NbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1028            return 0;
1029        }
1030        return pfa_.netaval;
1031    };
1032    
1033    /**
1034     * Returns the pointer to a vector ( of size TrkParams::GetPFA_NbinsETA() ),
1035     * with eta-correction values for each eta bin.
1036     * Bin extremes are given by float* TrkParams::GetPFA_ETAabs(pfa,int).
1037     *
1038     * @param pfa "ETA2","ETA3" or "ETA4"
1039     * @param nview View number (0-11)
1040     * @param nladder Ladder number (0-2)
1041     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1042     *
1043     * NB! the vector must be deallocated!
1044     * delete [] vname;
1045     */
1046    float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang){
1047    
1048        TrkParams::Load(4);
1049        if( !TrkParams::IsLoaded(4) ){
1050            cout << "float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1051            return 0;
1052        }
1053      
1054        int nbins = GetPFA_NbinsETA();
1055        if(!nbins)return 0;
1056    
1057        if( nview   <   0 ||
1058            nview   >= 12 ||
1059            nladder <   0 ||
1060            nladder >=  3 ||
1061            nang    <   0 ||
1062            nang    >=  GetPFA_NbinsAngle() ||
1063            false)return 0;
1064    
1065         float *fcorr = new float [nbins];
1066    //    float fcorr[nbins];
1067    
1068        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
1069            for(int ib=0; ib<nbins; ib++){
1070                fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
1071    //          cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
1072            }
1073        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
1074            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
1075        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
1076            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
1077        }else{
1078            cout << "float* TrkParams::GetPFA_ETAcorr("<<pfa<<",...) ---  pfa parameters not implemented "<<endl;
1079            return 0;
1080        }    
1081    
1082        return fcorr;
1083    
1084    };
1085    
1086    /**
1087     * Returns the pointer to a vector with eta-bin extremes (@see float* TrkParams::GetPFA_ETAcorr(TString,int,int,int)).
1088     *
1089     * @param pfa "ETA2","ETA3" or "ETA4"
1090     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1091     *
1092     * NB the vector must be deallocated
1093     * delete [] vname;
1094     */
1095    float* TrkParams::GetPFA_ETAabs(TString pfa, int nang){
1096      
1097        TrkParams::Load(4);
1098        if( !TrkParams::IsLoaded(4) ){
1099            cout << "float* TrkParams::GetPFA_ETAabs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1100            return 0;
1101        }
1102    
1103        int nbins = GetPFA_NbinsETA();
1104        if(!nbins)return 0;
1105    
1106        float *fcorr = new float [nbins];
1107    //    float fcorr[nbins];
1108        if( nang    <   0 ||
1109            nang    >=  GetPFA_NbinsAngle() ||
1110            false)return 0;
1111    
1112        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
1113            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
1114        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
1115            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
1116        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
1117            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
1118        }else{
1119            cout << "float* TrkParams::GetPFA_ETAabs("<<pfa<<",...) ---  pfa parameters not implemented "<<endl;
1120            return 0;
1121        }    
1122    
1123        return fcorr;
1124    
1125    };
1126    /**
1127     * Returns the "Landi-correction".
1128     *
1129     * @param nview View number (0-11)
1130     * @param nladder Ladder number (0-2)
1131     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1132     */
1133    float TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang){
1134    
1135    //     TrkParams::Load(4);
1136    //     if( !TrkParams::IsLoaded(4) ){
1137    //      cout << "float* TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1138    //      return 0;
1139    //     }
1140        int nbins = GetPFA_NbinsAngle();
1141        if(!nbins)return 0;
1142    
1143        if( nview   <   0 ||
1144            nview   >= 12 ||
1145            nladder <   0 ||
1146            nladder >=  3 ||
1147            nang    <   0 ||
1148            nang    >=  nbins ||
1149            false)return 0;
1150      
1151    
1152        return pfa_.fcorr[nang][nladder][nview];
1153    
1154    };
1155    
1156    /**
1157     * Returns the index (0, n.bin-1) of the angular bin for pfa parameters
1158     * @param angle Effective angle (deg)
1159     */
1160    int TrkParams::GetPFA_AngleBin(float angle){
1161        
1162        int nangbin = TrkParams::GetPFA_NbinsAngle();
1163        int istart = (int)(nangbin/2);
1164        int idbin = -1;
1165        if( angle > pfa_.angR[istart] ){
1166            idbin = nangbin-1;
1167            for(int id=istart+1; id<nangbin; id++ ){
1168                if( pfa_.angR[id] >= angle ){
1169                    idbin = id;
1170                    break;
1171                }
1172            }
1173        }else{
1174            idbin = 0;
1175            for(int id=istart; id>=0; id-- ){
1176                if( pfa_.angL[id] < angle ){
1177                    idbin = id;
1178                    break;
1179                }
1180            }
1181    
1182        }
1183        return idbin;
1184    }
1185    
1186    
1187    

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

  ViewVC Help
Powered by ViewVC 1.1.23