/** * \file TrkParams.cpp * \author Elena Vannuccini */ #include #include using namespace std; // ------------------------- // CALIBRATION (PED,SIG,BAD) // ------------------------- GL_TRK_CALIB TrkParams::calib = GL_TRK_CALIB(); TString TrkParams::calibpatht = ""; TString TrkParams::calibpathf = ""; Bool_t TrkParams::calib104 = 0; Bool_t TrkParams::calibload = false; UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; GL_PARAM TrkParams::gl[] = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()}; TString TrkParams::glpath[] = {"","","","","","",""}; Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; TrkParams::TrkParams(){ cout<<"TrkParams::TrkParams()"<RUNHEADER_TIME,dbc) )return false; if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2) printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false; calib = q2; calibpathf = q3.PATH + q3.NAME; calib104 = (glrun->TRK_CALIB_USED==104); calibload = kFALSE; if(calib104){ if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; calibpatht = q4.PATH + q4.NAME; } // return TrkParams::LoadCalib(); return true; }; /** * Method to fill the tracker calibration-parameter struct from on-line calibrations */ void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ cTrkCalib *ca = &pedsigbad_; TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); CalibTrk1Event *calibdata1 = 0; CalibTrk2Event *calibdata2 = 0; tr1->SetBranchAddress("CalibTrk1",&calibdata1); tr2->SetBranchAddress("CalibTrk2",&calibdata2); tr1->GetEntry(ev_reg1); tr2->GetEntry(ev_reg2); Int_t dspn1(0),dspn2(0); for(Int_t i=0;i<6;i++){ dspn1=calibdata1->DSPnumber[i]-1; dspn2=calibdata2->DSPnumber[i]-1; /* cout<<"dspn1= "<Get("CalibTrk2"); CalibTrk1Event *calibdata1 = 0; CalibTrk2Event *calibdata2 = 0; tr1->SetBranchAddress("CalibTrk1",&calibdata1); tr2->SetBranchAddress("CalibTrk2",&calibdata2); tr1->GetEntry(ev_reg1); tr2->GetEntry(ev_reg2); Int_t dspn1(0),dspn2(0); for(Int_t i=0;i<6;i++){ dspn1=calibdata1->DSPnumber[i]-1; dspn2=calibdata2->DSPnumber[i]-1; /* cout<<"dspn1= "<Get("CalibTrk2"); CalibTrk1Event *calibdata1 = 0; CalibTrk2Event *calibdata2 = 0; tr1->SetBranchAddress("CalibTrk1",&calibdata1); tr2->SetBranchAddress("CalibTrk2",&calibdata2); tr1->GetEntry(ev_reg1); tr2->GetEntry(ev_reg2); Int_t dspn1(0),dspn2(0); for(Int_t i=0;i<6;i++){ dspn1=calibdata1->DSPnumber[i]-1; dspn2=calibdata2->DSPnumber[i]-1; /* cout<<"dspn1= "<SetBranchAddress("CalibTrk1",calib->GetPointerTo()); tr->GetEntry(ev_reg1); } if(i==1){ //------------------------- //read calibration packet 2 //------------------------- tr = (TTree*)f0->Get("CalibTrk2"); tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); tr->GetEntry(ev_reg2); } for(Int_t ipkt=0; ipktGetView(ipkt); Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); Float_t sigmin = 0.; if(view%2)sigmin = 6.5; else sigmin = 2.5; Int_t mask = 1; if( sigmmask_vk_run[ivk][view-1] = mask; // if(mask==0)cout<< " VIEW "< "< MASKED!"<Delete(); } if(calib)calib->Delete(); }; /** * Static method to load calibration. * Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens the * 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. */ Bool_t TrkParams::LoadCalib( ){ if( TrkParams::CalibIsLoaded() )return false; // cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; // extern cTrkCalib pedsigbad_; // extern cTrkMask mask_; cout << "--------------------------------------"< last calibration "expiration date" // - search for new calibration packet // - load calibration parameters (full + truncated) cout << "Full pedestals for cluster finding:"; cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; FileStat_t t; if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; TFile *f0_c = new TFile(calibpathf); if ( !f0_c ) return false; cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); TrkParams::FillACalibFrom(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); // }; // ============================================================= // retrieve calibration file needed to uncompress data // ============================================================= // if the run was compressed using default calib // load truncated pedestals from default // otherwise reload them from on-line calibration cout << "Truncated pedestals for uncompression:"; if( calib104 ){ cout << " >> Loading default calibration: "<< calibpatht << endl; // ca->FillTCalibFrom(calibpatht); TrkParams::FillTCalibFrom(calibpatht); }else{ if ( !f0_c ) return false; cout << ">> Loading on-line calibration " << endl; // ca->FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); }; f0_c->Close(); // delete f0_c; cout << "--------------------------------------"<IsConnected()) ){ cout <<" Missing DB connection -- check PAMELA environment variables "<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<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<IsConnected() )return false; cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<::max(); if(glrun)runheadtime = glrun->RUNHEADER_TIME; else cout <<"Missing run info -- taking last entry "<>"<>"<Getenv("PAM_CALIB"); if( !glpath[index].IsNull() ){ 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 "<>"<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<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<IsConnected() )connected = true; else cout << " >> FAILED!!!"<Close(); }else for(Int_t i=0; i> not implemented <<"<0 )if( !TrkParams::Load(trkparamtype[i]) )return false; return true; }; Bool_t TrkParams::IsLoaded( ){ for(Int_t i=0 ; i0 )return false; return true; }; ClassImp(TrkParams);