/[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.20 by pam-fi, Tue Jan 15 14:29:46 2008 UTC revision 1.25 by pam-fi, Tue Nov 25 14:41:37 2008 UTC
# Line 1  Line 1 
1    
2  /**  /**
3   * \file TrkParams.cpp   * \file TrkParams.cpp
4   * \author Elena Vannuccini   * \author Elena Vannuccini
# Line 17  TString      TrkParams::calibpatht = ""; Line 18  TString      TrkParams::calibpatht = "";
18  TString      TrkParams::calibpathf = "";  TString      TrkParams::calibpathf = "";
19  Bool_t       TrkParams::calib104   = 0;  Bool_t       TrkParams::calib104   = 0;
20  Bool_t       TrkParams::calibload  = false;  Bool_t       TrkParams::calibload  = false;
21    TrkCalib*    TrkParams::calib1 = 0;
22    TrkCalib*    TrkParams::calib2 = 0;
23  // -------------------------  // -------------------------
24  // PARAMETERS loaded from DB  // PARAMETERS loaded from DB
25  // -------------------------  // -------------------------
# Line 38  float  TrkParams::init__pfa_e234ay[]   = Line 41  float  TrkParams::init__pfa_e234ay[]   =
41  double TrkParams::init__deltab_0       = 0.;  double TrkParams::init__deltab_0       = 0.;
42  double TrkParams::init__deltab_1       = 0.;  double TrkParams::init__deltab_1       = 0.;
43  double TrkParams::init__dlt            = 1.e-5;  double TrkParams::init__dlt            = 1.e-5;
44    // ------------------------------------------
45    // nominal z-coordinates to define acceptance
46    // ------------------------------------------
47    int   TrkParams::nGF   = NGF;
48    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};
49    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};
50    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};
51    // 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};
52    // 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};
53    // per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa
54    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};
55    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};
56    TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"};
57    
58  TrkParams::TrkParams(){  TrkParams::TrkParams(){
59    
# Line 78  TSQLServer* TrkParams::SetDBConnection() Line 94  TSQLServer* TrkParams::SetDBConnection()
94      if ( strcmp(pamdbhost,"") ) host = pamdbhost;      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
95      if ( strcmp(pamdbuser,"") ) user = pamdbuser;      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
96      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
97      if(TrkParams::VerboseMode()){      if(TrkParams::DebugMode()){
98          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
99          cout<<"Connecting to DB"<<endl;          cout<<"TrkParams::SetDBConnection() >> Connecting to DB"<<endl;
100          cout<<"HOST "<<host<<endl;          cout<<"HOST "<<host<<endl;
101          cout<<"USER "<<user<<endl;          cout<<"USER "<<user<<endl;
102          cout<<"PSW  "<<psw<<endl;          cout<<"PSW  "<<psw<<endl;
# Line 92  TSQLServer* TrkParams::SetDBConnection() Line 108  TSQLServer* TrkParams::SetDBConnection()
108      myquery.str("");  // EMILIANO      myquery.str("");  // EMILIANO
109      myquery << "SET time_zone='+0:00'";  // EMILIANO      myquery << "SET time_zone='+0:00'";  // EMILIANO
110      dbc->Query(myquery.str().c_str());  // EMILIANO      dbc->Query(myquery.str().c_str());  // EMILIANO
111      if(TrkParams::VerboseMode()){      if(TrkParams::DebugMode()){
112          cout << " ...done"<<endl;          cout << " ...done"<<endl;
113          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
114      }      }
# Line 127  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 143  Bool_t TrkParams::SetCalib( GL_RUN *glru
143          bool LOCAL_CONNECTION = false;          bool LOCAL_CONNECTION = false;
144          if( !dbc || (dbc && !dbc->IsConnected()) ){          if( !dbc || (dbc && !dbc->IsConnected()) ){
145    
146              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
147              dbc = TrkParams::SetDBConnection();              dbc = TrkParams::SetDBConnection();
148              if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;              if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
149    
# Line 159  Bool_t TrkParams::SetCalib( GL_RUN *glru Line 175  Bool_t TrkParams::SetCalib( GL_RUN *glru
175              calibpatht = q4.PATH + q4.NAME;              calibpatht = q4.PATH + q4.NAME;
176          }          }
177                    
178          if(LOCAL_CONNECTION){          if(LOCAL_CONNECTION&&dbc){
179              dbc->Close();              dbc->Close();
180              delete dbc;              if(TrkParams::DebugMode()){
181                    cout << " DB connection closed."<<endl;
182                }      
183          }          }
184    
185  //    return TrkParams::LoadCalib();  //    return TrkParams::LoadCalib();
# Line 319  void TrkParams::FillACalibFrom(TFile* f0 Line 337  void TrkParams::FillACalibFrom(TFile* f0
337      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");        TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
338      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
339    
340      CalibTrk1Event *calibdata1 = 0;      if(!calib1)calib1 = new TrkCalib();
341      CalibTrk2Event *calibdata2 = 0;      if(!calib2)calib2 = new TrkCalib();
342      tr1->SetBranchAddress("CalibTrk1",&calibdata1);  //     calibx->Set(calibdata1);
343      tr2->SetBranchAddress("CalibTrk2",&calibdata2);  //     caliby->Set(calibdata2);
344    
345    //     CalibTrk1Event *calibdata1 = 0;
346    //     CalibTrk2Event *calibdata2 = 0;
347    //     tr1->SetBranchAddress("CalibTrk1",&calibdata1);
348    //     tr2->SetBranchAddress("CalibTrk2",&calibdata2);
349        tr1->SetBranchAddress("CalibTrk1",calib1->GetPointerTo());
350        tr2->SetBranchAddress("CalibTrk2",calib2->GetPointerTo());
351      tr1->GetEntry(ev_reg1);      tr1->GetEntry(ev_reg1);
352      tr2->GetEntry(ev_reg2);      tr2->GetEntry(ev_reg2);
353      Int_t dspn1(0),dspn2(0);      Int_t dspn1(0),dspn2(0);
354    
355    
356      // --- TEST TEST TEST TEST --- //      // --- TEST TEST TEST TEST --- //
357  //    TrkParams::ValidateTrkCalib(calibdata1);  //    TrkParams::ValidateTrkCalib(calib1->Get());
358  //    TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //    TrkParams::ValidateTrkCalib((CalibTrk1Event*)calib2->Get());
359    
360      UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);      UInt_t test1 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib1->Get()));
361      UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);      UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib2->Get()));
362      if( !test1 || !test2 ){      if( !test1 || !test2 ){
363          if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;  //      if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
364          TrkParams::calib.VALIDATION = 0;          TrkParams::calib.VALIDATION = 0;
365      }      }
366      if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;  //    if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
367    
368      for(Int_t i=0;i<6;i++){      for(Int_t i=0;i<6;i++){
369          dspn1=calibdata1->DSPnumber[i]-1;  
370          dspn2=calibdata2->DSPnumber[i]-1;  
371            dspn1=calib1->Get()->DSPnumber[i]-1;
372            dspn2=calib2->Get()->DSPnumber[i]-1;
373  //      cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl;        //      cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl;      
374          for(Int_t ii=0;ii<3072;ii++){          for(Int_t ii=0;ii<3072;ii++){
375              Int_t j=(ii/128);              Int_t j=(ii/128);
376              Int_t jj=ii-j*128;              Int_t jj=ii-j*128;
377              if(dspn1>=0 && dspn1<12){              if(dspn1>=0 && dspn1<12){
378                  ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];                  ca->pedestal[jj][j][dspn1]=calib1->Get()->DSPped_par[i][ii];
379                  ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);                  ca->pedestal_t[jj][j][dspn1]=aint(calib1->Get()->DSPped_par[i][ii]);
380                  ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];                  ca->sigma[jj][j][dspn1]=calib1->Get()->DSPsig_par[i][ii];
381                  ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);                  ca->sigma_t[jj][j][dspn1]=anint(calib1->Get()->DSPsig_par[i][ii]);
382                  if(calibdata1->DSPbad_par[i][ii]==0)                  if(calib1->Get()->DSPbad_par[i][ii]==0)
383                      ca->bad[jj][j][dspn1]=1;                      ca->bad[jj][j][dspn1]=1;
384                  else if(calibdata1->DSPbad_par[i][ii]==1)                  else if(calib1->Get()->DSPbad_par[i][ii]==1)
385                      ca->bad[jj][j][dspn1]=0;                      ca->bad[jj][j][dspn1]=0;
386                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;
387                  //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;                  //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;
388              }              }
389    
390              if(dspn2>=0 && dspn2<12){              if(dspn2>=0 && dspn2<12){
391                  ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];                  ca->pedestal[jj][j][dspn2]=calib2->Get()->DSPped_par[i][ii];
392                  ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);                  ca->pedestal_t[jj][j][dspn2]=aint(calib2->Get()->DSPped_par[i][ii]);
393                  ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];                  ca->sigma[jj][j][dspn2]=calib2->Get()->DSPsig_par[i][ii];
394                  ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);                  ca->sigma_t[jj][j][dspn2]=anint(calib2->Get()->DSPsig_par[i][ii]);
395                  if(calibdata2->DSPbad_par[i][ii]==0)                  if(calib2->Get()->DSPbad_par[i][ii]==0)
396                      ca->bad[jj][j][dspn2]=1;                      ca->bad[jj][j][dspn2]=1;
397                  else if(calibdata2->DSPbad_par[i][ii]==1)                  else if(calib2->Get()->DSPbad_par[i][ii]==1)
398                      ca->bad[jj][j][dspn2]=0;                      ca->bad[jj][j][dspn2]=0;
399                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;
400                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;
# Line 380  void TrkParams::FillACalibFrom(TFile* f0 Line 408  void TrkParams::FillACalibFrom(TFile* f0
408  /**  /**
409   * Method to fill the tracker calibration-parameter struct from on-line calibrations   * Method to fill the tracker calibration-parameter struct from on-line calibrations
410   */   */
411  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){
   
     cTrkCalib *ca = &pedsigbad_;  
 //    ca->Reset();  
412    
413      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");    //     cTrkCalib *ca = &pedsigbad_;
414      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");  // //    ca->Reset();
415    
416      CalibTrk1Event *calibdata1 = 0;  //     TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
417      CalibTrk2Event *calibdata2 = 0;  //     TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
     tr1->SetBranchAddress("CalibTrk1",&calibdata1);  
     tr2->SetBranchAddress("CalibTrk2",&calibdata2);  
     tr1->GetEntry(ev_reg1);  
     tr2->GetEntry(ev_reg2);  
     Int_t dspn1(0),dspn2(0);  
418    
419      // --- TEST TEST TEST TEST --- //  //     CalibTrk1Event *calibdata1 = 0;
420  //     TrkParams::ValidateTrkCalib(calibdata1);  //     CalibTrk2Event *calibdata2 = 0;
421  //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     tr1->SetBranchAddress("CalibTrk1",&calibdata1);
422      UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);  //     tr2->SetBranchAddress("CalibTrk2",&calibdata2);
423      UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     tr1->GetEntry(ev_reg1);
424      if( !test1 || !test2 ){  //     tr2->GetEntry(ev_reg2);
425          if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;  //     Int_t dspn1(0),dspn2(0);
426          TrkParams::calib.VALIDATION = 0;  
427      }  //     // --- TEST TEST TEST TEST --- //
428      if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;  // //     TrkParams::ValidateTrkCalib(calibdata1);
429    // //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
430    //     UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
431    //     UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
432    //     if( !test1 || !test2 ){
433    //      if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
434    //      TrkParams::calib.VALIDATION = 0;
435    //     }
436    //     if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
437                    
438      for(Int_t i=0;i<6;i++){  //     for(Int_t i=0;i<6;i++){
439          dspn1=calibdata1->DSPnumber[i]-1;  //      dspn1=calibdata1->DSPnumber[i]-1;
440          dspn2=calibdata2->DSPnumber[i]-1;  //      dspn2=calibdata2->DSPnumber[i]-1;
441          /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */  //      /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */
442          for(Int_t ii=0;ii<3072;ii++){  //      for(Int_t ii=0;ii<3072;ii++){
443              Int_t j=(ii/128);  //          Int_t j=(ii/128);
444              Int_t jj=ii-j*128;  //          Int_t jj=ii-j*128;
445              if(dspn1>=0 && dspn1<12){  //          if(dspn1>=0 && dspn1<12){
446                  ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];  //              ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii];
447                  ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];  //              ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii];
448                  if(calibdata1->DSPbad_par[i][ii]==0)  //              if(calibdata1->DSPbad_par[i][ii]==0)
449                      ca->bad[jj][j][dspn1]=1;  //                  ca->bad[jj][j][dspn1]=1;
450                  else if(calibdata1->DSPbad_par[i][ii]==1)  //              else if(calibdata1->DSPbad_par[i][ii]==1)
451                      ca->bad[jj][j][dspn1]=0;  //                  ca->bad[jj][j][dspn1]=0;
452                  //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;  //              //            cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl;
453                  //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;  //              //        cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl;
454              }  //          }
455              if(dspn2>=0 && dspn2<12){  //          if(dspn2>=0 && dspn2<12){
456                  ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];  //              ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii];
457                  ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];  //              ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii];
458                  if(calibdata2->DSPbad_par[i][ii]==0)  //              if(calibdata2->DSPbad_par[i][ii]==0)
459                      ca->bad[jj][j][dspn2]=1;  //                  ca->bad[jj][j][dspn2]=1;
460                  else if(calibdata2->DSPbad_par[i][ii]==1)  //              else if(calibdata2->DSPbad_par[i][ii]==1)
461                      ca->bad[jj][j][dspn2]=0;  //                  ca->bad[jj][j][dspn2]=0;
462                  //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;  //              //        cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl;
463                  //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;  //              //        cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl;
464              }  //          }
465          };  //      };
466      };  //     };
467                    
468      tr1->Delete();  //     tr1->Delete();
469      tr2->Delete();  //     tr2->Delete();
470  };  // };
471  /**  /**
472   * Method to fill the tracker calibration-parameter struct from on-line calibrations   * Method to fill the tracker calibration-parameter struct from on-line calibrations
473   */   */
474  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){
475    
476      cTrkCalib *ca = &pedsigbad_;  //     cTrkCalib *ca = &pedsigbad_;
477  //    ca->Reset();  // //    ca->Reset();
478    
479      TTree *tr1 = (TTree*)f0->Get("CalibTrk1");    //     TTree *tr1 = (TTree*)f0->Get("CalibTrk1");  
480      TTree *tr2 = (TTree*)f0->Get("CalibTrk2");  //     TTree *tr2 = (TTree*)f0->Get("CalibTrk2");
481    
482      CalibTrk1Event *calibdata1 = 0;  //     CalibTrk1Event *calibdata1 = 0;
483      CalibTrk2Event *calibdata2 = 0;  //     CalibTrk2Event *calibdata2 = 0;
484      tr1->SetBranchAddress("CalibTrk1",&calibdata1);  //     tr1->SetBranchAddress("CalibTrk1",&calibdata1);
485      tr2->SetBranchAddress("CalibTrk2",&calibdata2);  //     tr2->SetBranchAddress("CalibTrk2",&calibdata2);
486      tr1->GetEntry(ev_reg1);  //     tr1->GetEntry(ev_reg1);
487      tr2->GetEntry(ev_reg2);  //     tr2->GetEntry(ev_reg2);
488      Int_t dspn1(0),dspn2(0);  //     Int_t dspn1(0),dspn2(0);
489                    
490      // --- TEST TEST TEST TEST --- //  //     // --- TEST TEST TEST TEST --- //
491  //     TrkParams::ValidateTrkCalib(calibdata1);  // //     TrkParams::ValidateTrkCalib(calibdata1);
492  //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  // //     TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
493      UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);  //     UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1);
494      UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);  //     UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2);
495      if( !test1 || !test2 ){  //     if( !test1 || !test2 ){
496          if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;  //      if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl;
497          TrkParams::calib.VALIDATION = 0;  //      TrkParams::calib.VALIDATION = 0;
498      }  //     }
499      if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;  //     if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl;
500    
501      for(Int_t i=0;i<6;i++){  //     for(Int_t i=0;i<6;i++){
502          dspn1=calibdata1->DSPnumber[i]-1;  //      dspn1=calibdata1->DSPnumber[i]-1;
503          dspn2=calibdata2->DSPnumber[i]-1;  //      dspn2=calibdata2->DSPnumber[i]-1;
504          /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */  //      /*     cout<<"dspn1= "<<dspn1<<"   dspn2= "<<dspn2<<endl; */
505          for(Int_t ii=0;ii<3072;ii++){  //      for(Int_t ii=0;ii<3072;ii++){
506              Int_t j=(ii/128);  //          Int_t j=(ii/128);
507              Int_t jj=ii-j*128;  //          Int_t jj=ii-j*128;
508              if(dspn1>=0 && dspn1<12){  //          if(dspn1>=0 && dspn1<12){
509                  ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);  //              ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]);
510                  ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);  //              ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]);
511              }  //          }
512              if(dspn2>=0 && dspn2<12){  //          if(dspn2>=0 && dspn2<12){
513                  ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);  //              ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]);
514                  ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);  //              ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]);
515              }    //          }  
516          };  //      };
517      };  //     };
518                    
519      tr1->Delete();  //     tr1->Delete();
520      tr2->Delete();  //     tr2->Delete();
521  };  // };
522  /**  /**
523   * Method to fill the tracker calibration-parameter struct from default calibration   * Method to fill the tracker calibration-parameter struct from default calibration
524   */   */
# Line 601  Bool_t TrkParams::LoadCalib( ){ Line 629  Bool_t TrkParams::LoadCalib( ){
629          cout << " - full+truncated parameters "<<endl;          cout << " - full+truncated parameters "<<endl;
630      }      }
631      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
632      if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl;      if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl;
633      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);      TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2);
634    
635      // =============================================================      // =============================================================
# Line 651  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 679  Bool_t TrkParams::Set( GL_RUN* glrun , T
679      UInt_t index = TrkParams::GetIndex( type );      UInt_t index = TrkParams::GetIndex( type );
680      if(index < 0)return false;      if(index < 0)return false;
681    
682      UInt_t runheadtime=0;  
683        UInt_t runheadtime=1;
684      UInt_t runid=0;      UInt_t runid=0;
685  //    UInt_t runheadtime = numeric_limits<UInt_t>::max();  //    UInt_t runheadtime = numeric_limits<UInt_t>::max();
686      if(glrun){      if(glrun){
687          runheadtime = glrun->RUNHEADER_TIME;          runheadtime = glrun->RUNHEADER_TIME;
688          runid       = glrun->ID;          runid       = glrun->ID;
689      }else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl;      }else
690            cout <<"Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ) >> GL_RUN==NULL -- taking first entry (**WARNING** check that this is ok!! )"<<endl;
 //    if(TrkParams::VerboseMode())  
     cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;  
691    
692    
693      if( !TrkParams::IsLoaded(type) ||      if( !TrkParams::IsLoaded(type) ||
# Line 668  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 695  Bool_t TrkParams::Set( GL_RUN* glrun , T
695          runheadtime > gl[index].TO_TIME     ||            runheadtime > gl[index].TO_TIME     ||  
696          false ){          false ){
697    
698    //    if(TrkParams::VerboseMode())
699            if(TrkParams::DebugMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl;
700    
701          bool LOCAL_CONNECTION = false;          bool LOCAL_CONNECTION = false;
702          if( !dbc || (dbc && !dbc->IsConnected()) ){          if( !dbc || (dbc && !dbc->IsConnected()) ){
703    
704              if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;  //          if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl;
705              dbc = TrkParams::SetDBConnection();              dbc = TrkParams::SetDBConnection();
706              if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;              if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true;
707    
# Line 682  Bool_t TrkParams::Set( GL_RUN* glrun , T Line 712  Bool_t TrkParams::Set( GL_RUN* glrun , T
712          if(LOCAL_CONNECTION){          if(LOCAL_CONNECTION){
713              dbc->Close();              dbc->Close();
714              delete dbc;              delete dbc;
715                if(TrkParams::DebugMode()){
716                    cout << " DB connection closed."<<endl;
717                }      
718          }          }
719          gl[index]     = q4;          gl[index]     = q4;
720          glpath[index] = q4.PATH+q4.NAME;          glpath[index] = q4.PATH+q4.NAME;
# Line 751  Bool_t TrkParams::Load(UInt_t type){ Line 784  Bool_t TrkParams::Load(UInt_t type){
784            
785      Int_t index = TrkParams::GetIndex( type );      Int_t index = TrkParams::GetIndex( type );
786      if( index<0 )return false;      if( index<0 )return false;
787      if( glload[index] )return true;      if( glload[index] )return false;
   
788      if( glpath[index].IsNull() )TrkParams::Set(type);      if( glpath[index].IsNull() )TrkParams::Set(type);
789    
790      switch( type ){      switch( type ){
# Line 981  void TrkParams::SetPFA(float *v){ Line 1013  void TrkParams::SetPFA(float *v){
1013   */   */
1014  float TrkParams::GetResolution(int view, float angle){  float TrkParams::GetResolution(int view, float angle){
1015      float res = 1000;      float res = 1000;
1016      if( init__pfa == 0 )res = riseta_(&view,&angle);      if     ( init__pfa == 0 )res = riseta_(&view,&angle);
1017        else if( init__pfa == 5 )res = riseta_(&view,&angle);
1018      else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl;      else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl;
1019      return res;      return res;
1020  }  }
1021    
1022    /**
1023     * Returns the number of angular bins for p.f.a. parameters
1024     */
1025    int TrkParams::GetPFA_NbinsAngle(){
1026        TrkParams::Load(4);
1027        if( !TrkParams::IsLoaded(4) ){
1028            cout << "int TrkParams::GetPFA_NbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1029            return 0;
1030        }
1031        return pfa_.nangbin;
1032    };
1033    /**
1034     * Returns the number of eta bins for p.f.a. parameters
1035     */
1036    int TrkParams::GetPFA_NbinsETA(){
1037        TrkParams::Load(4);
1038        if( !TrkParams::IsLoaded(4) ){
1039            cout << "int TrkParams::GetPFA_NbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1040            return 0;
1041        }
1042        return pfa_.netaval;
1043    };
1044    
1045    /**
1046     * Returns the pointer to a vector ( of size TrkParams::GetPFA_NbinsETA() ),
1047     * with eta-correction values for each eta bin.
1048     * Bin extremes are given by float* TrkParams::GetPFA_ETAabs(pfa,int).
1049     *
1050     * @param pfa "ETA2","ETA3" or "ETA4"
1051     * @param nview View number (0-11)
1052     * @param nladder Ladder number (0-2)
1053     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1054     *
1055     * NB! the vector must be deallocated!
1056     * delete [] vname;
1057     */
1058    float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang){
1059    
1060        TrkParams::Load(4);
1061        if( !TrkParams::IsLoaded(4) ){
1062            cout << "float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1063            return 0;
1064        }
1065      
1066        int nbins = GetPFA_NbinsETA();
1067        if(!nbins)return 0;
1068    
1069        if( nview   <   0 ||
1070            nview   >= 12 ||
1071            nladder <   0 ||
1072            nladder >=  3 ||
1073            nang    <   0 ||
1074            nang    >=  GetPFA_NbinsAngle() ||
1075            false)return 0;
1076    
1077         float *fcorr = new float [nbins];
1078    //    float fcorr[nbins];
1079    
1080        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
1081            for(int ib=0; ib<nbins; ib++){
1082                fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
1083    //          cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
1084            }
1085        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
1086            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
1087        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
1088            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
1089        }else{
1090            cout << "float* TrkParams::GetPFA_ETAcorr("<<pfa<<",...) ---  pfa parameters not implemented "<<endl;
1091            return 0;
1092        }    
1093    
1094        return fcorr;
1095    
1096    };
1097    
1098    /**
1099     * Returns the pointer to a vector with eta-bin extremes (@see float* TrkParams::GetPFA_ETAcorr(TString,int,int,int)).
1100     *
1101     * @param pfa "ETA2","ETA3" or "ETA4"
1102     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1103     *
1104     * NB the vector must be deallocated
1105     * delete [] vname;
1106     */
1107    float* TrkParams::GetPFA_ETAabs(TString pfa, int nang){
1108      
1109        TrkParams::Load(4);
1110        if( !TrkParams::IsLoaded(4) ){
1111            cout << "float* TrkParams::GetPFA_ETAabs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1112            return 0;
1113        }
1114    
1115        int nbins = GetPFA_NbinsETA();
1116        if(!nbins)return 0;
1117    
1118        float *fcorr = new float [nbins];
1119    //    float fcorr[nbins];
1120        if( nang    <   0 ||
1121            nang    >=  GetPFA_NbinsAngle() ||
1122            false)return 0;
1123    
1124        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
1125            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
1126        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
1127            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
1128        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
1129            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
1130        }else{
1131            cout << "float* TrkParams::GetPFA_ETAabs("<<pfa<<",...) ---  pfa parameters not implemented "<<endl;
1132            return 0;
1133        }    
1134    
1135        return fcorr;
1136    
1137    };
1138    /**
1139     * Returns the "Landi-correction".
1140     *
1141     * @param nview View number (0-11)
1142     * @param nladder Ladder number (0-2)
1143     * @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()).
1144     */
1145    float TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang){
1146    
1147    //     TrkParams::Load(4);
1148    //     if( !TrkParams::IsLoaded(4) ){
1149    //      cout << "float* TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
1150    //      return 0;
1151    //     }
1152        int nbins = GetPFA_NbinsAngle();
1153        if(!nbins)return 0;
1154    
1155        if( nview   <   0 ||
1156            nview   >= 12 ||
1157            nladder <   0 ||
1158            nladder >=  3 ||
1159            nang    <   0 ||
1160            nang    >=  nbins ||
1161            false)return 0;
1162      
1163    
1164        return pfa_.fcorr[nang][nladder][nview];
1165    
1166    };
1167    
1168    /**
1169     * Returns the index (0, n.bin-1) of the angular bin for pfa parameters
1170     * @param angle Effective angle (deg)
1171     */
1172    int TrkParams::GetPFA_AngleBin(float angle){
1173        
1174        int nangbin = TrkParams::GetPFA_NbinsAngle();
1175        int istart = (int)(nangbin/2);
1176        int idbin = -1;
1177    //    cout << angle <<" ??" << endl;
1178        if( angle > pfa_.angR[istart] ){
1179            idbin = nangbin-1;
1180            for(int id=istart+1; id<nangbin; id++ ){
1181    //          cout << id << endl;
1182                if( pfa_.angR[id] >= angle ){
1183                    idbin = id;
1184                    break;
1185                }
1186            }
1187        }else{
1188            idbin = 0;
1189            for(int id=istart; id>=0; id-- ){
1190    //          cout << id << endl;
1191                if( pfa_.angL[id] < angle ){
1192                    idbin = id;
1193                    break;
1194                }
1195            }
1196    
1197        }
1198    //    cout << ">>> "<<idbin<<" "<<pfa_.angL[idbin]<<" "<<pfa_.angR[idbin]<<endl;
1199        return idbin;
1200    }
1201    
1202    
1203    

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.23