| 1 |
pam-fi |
1.1 |
/** |
| 2 |
|
|
* \file TrkParams.cpp |
| 3 |
|
|
* \author Elena Vannuccini |
| 4 |
|
|
*/ |
| 5 |
|
|
|
| 6 |
|
|
#include <TrkParams.h> |
| 7 |
|
|
#include <iostream> |
| 8 |
|
|
using namespace std; |
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
// ------------------------- |
| 12 |
|
|
// CALIBRATION (PED,SIG,BAD) |
| 13 |
|
|
// ------------------------- |
| 14 |
|
|
GL_TRK_CALIB TrkParams::calib = GL_TRK_CALIB(); |
| 15 |
|
|
TString TrkParams::calibpatht = ""; |
| 16 |
|
|
TString TrkParams::calibpathf = ""; |
| 17 |
|
|
Bool_t TrkParams::calib104 = 0; |
| 18 |
|
|
Bool_t TrkParams::calibload = false; |
| 19 |
|
|
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
| 20 |
|
|
GL_PARAM TrkParams::gl[] = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()}; |
| 21 |
|
|
TString TrkParams::glpath[] = {"","","","","","",""}; |
| 22 |
|
|
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
| 23 |
|
|
|
| 24 |
|
|
TrkParams::TrkParams(){ |
| 25 |
|
|
|
| 26 |
|
|
cout<<"TrkParams::TrkParams()"<<endl; |
| 27 |
|
|
|
| 28 |
|
|
} |
| 29 |
|
|
float aint(float f){ |
| 30 |
|
|
int ret = (int)f; |
| 31 |
|
|
float ret1 = 0; |
| 32 |
|
|
ret1=(float)ret; |
| 33 |
|
|
return ret1; |
| 34 |
|
|
} |
| 35 |
|
|
|
| 36 |
|
|
float anint(float f){ |
| 37 |
|
|
int ret = (int)(f+0.5); |
| 38 |
|
|
float ret1 = 0; |
| 39 |
|
|
ret1=(float)ret; |
| 40 |
|
|
return ret1; |
| 41 |
|
|
} |
| 42 |
|
|
/** |
| 43 |
|
|
* Static method to set the calibration to be loaded. |
| 44 |
|
|
|
| 45 |
|
|
* It retrieves the calibration associated to a given run, from |
| 46 |
|
|
* a given DB. It fills the F77 common. |
| 47 |
|
|
* @param glrun Pointer to a GL_RUN row |
| 48 |
|
|
* @param dbc Pointer to a DB connection |
| 49 |
|
|
*/ |
| 50 |
|
|
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
| 51 |
|
|
|
| 52 |
|
|
GL_TRK_CALIB q2; |
| 53 |
|
|
GL_ROOT q3; |
| 54 |
|
|
GL_PARAM q4; |
| 55 |
|
|
|
| 56 |
|
|
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) )return false; |
| 57 |
|
|
if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2) |
| 58 |
|
|
printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
| 59 |
|
|
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false; |
| 60 |
|
|
|
| 61 |
|
|
calib = q2; |
| 62 |
|
|
calibpathf = q3.PATH + q3.NAME; |
| 63 |
|
|
calib104 = (glrun->TRK_CALIB_USED==104); |
| 64 |
|
|
calibload = kFALSE; |
| 65 |
|
|
if(calib104){ |
| 66 |
|
|
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
| 67 |
|
|
calibpatht = q4.PATH + q4.NAME; |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
|
|
| 71 |
|
|
// return TrkParams::LoadCalib(); |
| 72 |
|
|
return true; |
| 73 |
|
|
}; |
| 74 |
|
|
|
| 75 |
|
|
/** |
| 76 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 77 |
|
|
*/ |
| 78 |
|
|
void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 79 |
|
|
|
| 80 |
|
|
cTrkCalib *ca = &pedsigbad_; |
| 81 |
|
|
|
| 82 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
| 83 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
| 84 |
|
|
|
| 85 |
|
|
CalibTrk1Event *calibdata1 = 0; |
| 86 |
|
|
CalibTrk2Event *calibdata2 = 0; |
| 87 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
| 88 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
| 89 |
|
|
tr1->GetEntry(ev_reg1); |
| 90 |
|
|
tr2->GetEntry(ev_reg2); |
| 91 |
|
|
Int_t dspn1(0),dspn2(0); |
| 92 |
|
|
|
| 93 |
|
|
for(Int_t i=0;i<6;i++){ |
| 94 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
| 95 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
| 96 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
| 97 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
| 98 |
|
|
Int_t j=(ii/128); |
| 99 |
|
|
Int_t jj=ii-j*128; |
| 100 |
|
|
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
| 101 |
|
|
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
| 102 |
|
|
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
| 103 |
|
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
| 104 |
|
|
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
| 105 |
|
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
| 106 |
|
|
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
| 107 |
|
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
| 108 |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
| 109 |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
| 110 |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
| 111 |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
| 112 |
|
|
|
| 113 |
|
|
// |
| 114 |
|
|
// invert the bad |
| 115 |
|
|
// |
| 116 |
|
|
if(calibdata1->DSPbad_par[i][ii]==0) |
| 117 |
|
|
ca->bad[jj][j][dspn1]=1; |
| 118 |
|
|
else if(calibdata1->DSPbad_par[i][ii]==1) |
| 119 |
|
|
ca->bad[jj][j][dspn1]=0; |
| 120 |
|
|
if(calibdata2->DSPbad_par[i][ii]==0) |
| 121 |
|
|
ca->bad[jj][j][dspn2]=1; |
| 122 |
|
|
else if(calibdata2->DSPbad_par[i][ii]==1) |
| 123 |
|
|
ca->bad[jj][j][dspn2]=0; |
| 124 |
|
|
}; |
| 125 |
|
|
}; |
| 126 |
|
|
|
| 127 |
|
|
tr1->Delete(); |
| 128 |
|
|
tr2->Delete(); |
| 129 |
|
|
}; |
| 130 |
|
|
/** |
| 131 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 132 |
|
|
*/ |
| 133 |
|
|
void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 134 |
|
|
|
| 135 |
|
|
cTrkCalib *ca = &pedsigbad_; |
| 136 |
|
|
|
| 137 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
| 138 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
| 139 |
|
|
|
| 140 |
|
|
CalibTrk1Event *calibdata1 = 0; |
| 141 |
|
|
CalibTrk2Event *calibdata2 = 0; |
| 142 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
| 143 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
| 144 |
|
|
tr1->GetEntry(ev_reg1); |
| 145 |
|
|
tr2->GetEntry(ev_reg2); |
| 146 |
|
|
Int_t dspn1(0),dspn2(0); |
| 147 |
|
|
|
| 148 |
|
|
for(Int_t i=0;i<6;i++){ |
| 149 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
| 150 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
| 151 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
| 152 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
| 153 |
|
|
Int_t j=(ii/128); |
| 154 |
|
|
Int_t jj=ii-j*128; |
| 155 |
|
|
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
| 156 |
|
|
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
| 157 |
|
|
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
| 158 |
|
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
| 159 |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
| 160 |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
| 161 |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
| 162 |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
| 163 |
|
|
|
| 164 |
|
|
// |
| 165 |
|
|
// invert the bad |
| 166 |
|
|
// |
| 167 |
|
|
if(calibdata1->DSPbad_par[i][ii]==0) |
| 168 |
|
|
ca->bad[jj][j][dspn1]=1; |
| 169 |
|
|
else if(calibdata1->DSPbad_par[i][ii]==1) |
| 170 |
|
|
ca->bad[jj][j][dspn1]=0; |
| 171 |
|
|
if(calibdata2->DSPbad_par[i][ii]==0) |
| 172 |
|
|
ca->bad[jj][j][dspn2]=1; |
| 173 |
|
|
else if(calibdata2->DSPbad_par[i][ii]==1) |
| 174 |
|
|
ca->bad[jj][j][dspn2]=0; |
| 175 |
|
|
}; |
| 176 |
|
|
}; |
| 177 |
|
|
|
| 178 |
|
|
tr1->Delete(); |
| 179 |
|
|
tr2->Delete(); |
| 180 |
|
|
}; |
| 181 |
|
|
/** |
| 182 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 183 |
|
|
*/ |
| 184 |
|
|
void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 185 |
|
|
|
| 186 |
|
|
cTrkCalib *ca = &pedsigbad_; |
| 187 |
|
|
|
| 188 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
| 189 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
| 190 |
|
|
|
| 191 |
|
|
CalibTrk1Event *calibdata1 = 0; |
| 192 |
|
|
CalibTrk2Event *calibdata2 = 0; |
| 193 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
| 194 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
| 195 |
|
|
tr1->GetEntry(ev_reg1); |
| 196 |
|
|
tr2->GetEntry(ev_reg2); |
| 197 |
|
|
Int_t dspn1(0),dspn2(0); |
| 198 |
|
|
|
| 199 |
|
|
for(Int_t i=0;i<6;i++){ |
| 200 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
| 201 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
| 202 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
| 203 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
| 204 |
|
|
Int_t j=(ii/128); |
| 205 |
|
|
Int_t jj=ii-j*128; |
| 206 |
|
|
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
| 207 |
|
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
| 208 |
|
|
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
| 209 |
|
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
| 210 |
|
|
}; |
| 211 |
|
|
}; |
| 212 |
|
|
|
| 213 |
|
|
tr1->Delete(); |
| 214 |
|
|
tr2->Delete(); |
| 215 |
|
|
}; |
| 216 |
|
|
/** |
| 217 |
|
|
* Method to fill the tracker calibration-parameter struct from default calibration |
| 218 |
|
|
*/ |
| 219 |
|
|
void TrkParams::FillTCalibFrom(TString path){ |
| 220 |
|
|
|
| 221 |
|
|
path_.FillWith(path); |
| 222 |
|
|
fillpedsigfromdefault_(); |
| 223 |
|
|
if(path_.error) throw -216; |
| 224 |
|
|
|
| 225 |
|
|
}; |
| 226 |
|
|
/** |
| 227 |
|
|
* Method to fill the tracker VA1-mask struct from calibration |
| 228 |
|
|
*/ |
| 229 |
|
|
void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 230 |
|
|
|
| 231 |
|
|
cTrkMask *ma = &mask_; |
| 232 |
|
|
|
| 233 |
|
|
TrkCalib *calib = new TrkCalib(); |
| 234 |
|
|
|
| 235 |
|
|
for(Int_t i=0; i<2; i++){ |
| 236 |
|
|
TTree *tr=0; |
| 237 |
|
|
if(i==0){ |
| 238 |
|
|
//------------------------- |
| 239 |
|
|
//read calibration packet 1 |
| 240 |
|
|
//------------------------- |
| 241 |
|
|
tr = (TTree*)f0->Get("CalibTrk1"); |
| 242 |
|
|
tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo()); |
| 243 |
|
|
tr->GetEntry(ev_reg1); |
| 244 |
|
|
} |
| 245 |
|
|
if(i==1){ |
| 246 |
|
|
//------------------------- |
| 247 |
|
|
//read calibration packet 2 |
| 248 |
|
|
//------------------------- |
| 249 |
|
|
tr = (TTree*)f0->Get("CalibTrk2"); |
| 250 |
|
|
tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); |
| 251 |
|
|
tr->GetEntry(ev_reg2); |
| 252 |
|
|
} |
| 253 |
|
|
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
| 254 |
|
|
for(Int_t ivk=0; ivk<NVK; ivk++){ |
| 255 |
|
|
Int_t view = calib->GetView(ipkt); |
| 256 |
|
|
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
| 257 |
|
|
Float_t sigmin = 0.; |
| 258 |
|
|
if(view%2)sigmin = 6.5; |
| 259 |
|
|
else sigmin = 2.5; |
| 260 |
|
|
Int_t mask = 1; |
| 261 |
|
|
if( sigm<sigmin )mask = 0; |
| 262 |
|
|
|
| 263 |
|
|
ma->mask_vk_run[ivk][view-1] = mask; |
| 264 |
|
|
|
| 265 |
|
|
// if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl; |
| 266 |
|
|
} |
| 267 |
|
|
} |
| 268 |
|
|
if(tr)tr->Delete(); |
| 269 |
|
|
} |
| 270 |
|
|
|
| 271 |
|
|
if(calib)calib->Delete(); |
| 272 |
|
|
|
| 273 |
|
|
}; |
| 274 |
|
|
|
| 275 |
|
|
/** |
| 276 |
|
|
* Static method to load calibration. |
| 277 |
|
|
* Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens the |
| 278 |
|
|
* first time the method is called (but it does not work becouse I didn't set any |
| 279 |
|
|
* default calibration for the moment) or after the method TrkParams::SetCalib(***) is called. |
| 280 |
|
|
*/ |
| 281 |
|
|
Bool_t TrkParams::LoadCalib( ){ |
| 282 |
|
|
|
| 283 |
|
|
if( TrkParams::CalibIsLoaded() )return false; |
| 284 |
|
|
|
| 285 |
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
| 286 |
|
|
|
| 287 |
|
|
// extern cTrkCalib pedsigbad_; |
| 288 |
|
|
// extern cTrkMask mask_; |
| 289 |
|
|
|
| 290 |
|
|
cout << "--------------------------------------"<<endl; |
| 291 |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
| 292 |
|
|
// ============================================================= |
| 293 |
|
|
// retrieve calibration file needed to reduce data |
| 294 |
|
|
// ============================================================= |
| 295 |
|
|
// if run OBT is > last calibration "expiration date" |
| 296 |
|
|
// - search for new calibration packet |
| 297 |
|
|
// - load calibration parameters (full + truncated) |
| 298 |
|
|
cout << "Full pedestals for cluster finding:"; |
| 299 |
|
|
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
| 300 |
|
|
FileStat_t t; |
| 301 |
|
|
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
| 302 |
|
|
|
| 303 |
|
|
TFile *f0_c = new TFile(calibpathf); |
| 304 |
|
|
if ( !f0_c ) return false; |
| 305 |
|
|
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
| 306 |
|
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
| 307 |
|
|
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 308 |
|
|
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 309 |
|
|
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 310 |
|
|
// mask_.Set(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 311 |
|
|
|
| 312 |
|
|
// }; |
| 313 |
|
|
// ============================================================= |
| 314 |
|
|
// retrieve calibration file needed to uncompress data |
| 315 |
|
|
// ============================================================= |
| 316 |
|
|
// if the run was compressed using default calib |
| 317 |
|
|
// load truncated pedestals from default |
| 318 |
|
|
// otherwise reload them from on-line calibration |
| 319 |
|
|
cout << "Truncated pedestals for uncompression:"; |
| 320 |
|
|
if( calib104 ){ |
| 321 |
|
|
|
| 322 |
|
|
cout << " >> Loading default calibration: "<< calibpatht << endl; |
| 323 |
|
|
// ca->FillTCalibFrom(calibpatht); |
| 324 |
|
|
TrkParams::FillTCalibFrom(calibpatht); |
| 325 |
|
|
|
| 326 |
|
|
}else{ |
| 327 |
|
|
|
| 328 |
|
|
if ( !f0_c ) return false; |
| 329 |
|
|
cout << ">> Loading on-line calibration " << endl; |
| 330 |
|
|
// ca->FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 331 |
|
|
TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 332 |
|
|
}; |
| 333 |
|
|
f0_c->Close(); |
| 334 |
|
|
// delete f0_c; |
| 335 |
|
|
cout << "--------------------------------------"<<endl; |
| 336 |
|
|
|
| 337 |
|
|
calibload = kTRUE; |
| 338 |
|
|
return true; |
| 339 |
|
|
}; |
| 340 |
|
|
|
| 341 |
|
|
Int_t TrkParams::GetIndex( UInt_t type ){ |
| 342 |
|
|
Int_t index = -1; |
| 343 |
|
|
for (Int_t i=0; i< NTYPES; i++)if( type == trkparamtype[i] )index=i; |
| 344 |
|
|
return index; |
| 345 |
|
|
}; |
| 346 |
|
|
|
| 347 |
|
|
/** |
| 348 |
|
|
* Set tracker parameters proper for a run querying the DB. |
| 349 |
|
|
* @param glrun Input run info |
| 350 |
|
|
* @param dbc Database |
| 351 |
|
|
* @param type Parameter type |
| 352 |
|
|
* @return FALSE if parameter set fails. |
| 353 |
|
|
* If glrun==NULL the last parameter entry from GL_PARAM table is set. |
| 354 |
|
|
* If dbc==NULL, try to open a connection taking DB-connection |
| 355 |
|
|
* parameters from PAMELA environment variables. |
| 356 |
|
|
*/ |
| 357 |
|
|
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
| 358 |
|
|
|
| 359 |
|
|
// if( !dbc )return false; |
| 360 |
|
|
|
| 361 |
|
|
|
| 362 |
|
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
| 363 |
|
|
|
| 364 |
|
|
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 365 |
|
|
TString host = "mysql://localhost/pamelaprod"; |
| 366 |
|
|
TString user = "anonymous"; |
| 367 |
|
|
TString psw = ""; |
| 368 |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 369 |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 370 |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 371 |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
| 372 |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
| 373 |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 374 |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 375 |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 376 |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 377 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 378 |
|
|
cout<<"Connecting to DB"<<endl; |
| 379 |
|
|
cout<<"HOST "<<host<<endl; |
| 380 |
|
|
cout<<"USER "<<user<<endl; |
| 381 |
|
|
cout<<"PSW "<<psw<<endl; |
| 382 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 383 |
|
|
if( !dbc )return false; |
| 384 |
|
|
if( !dbc->IsConnected() )return false; |
| 385 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 386 |
|
|
|
| 387 |
|
|
} |
| 388 |
|
|
|
| 389 |
|
|
UInt_t index = TrkParams::GetIndex( type ); |
| 390 |
|
|
if(index < 0)return false; |
| 391 |
|
|
|
| 392 |
|
|
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
| 393 |
|
|
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
| 394 |
|
|
else cout <<"Missing run info -- taking last entry "<<endl; |
| 395 |
|
|
|
| 396 |
|
|
GL_PARAM q4; |
| 397 |
|
|
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
| 398 |
|
|
|
| 399 |
|
|
gl[index] = q4; |
| 400 |
|
|
glpath[index] = q4.PATH+q4.NAME; |
| 401 |
|
|
glload[index] = false; |
| 402 |
|
|
cout << "<< set TrkParams type "<<type<<" >>"<<endl; |
| 403 |
|
|
return true; |
| 404 |
|
|
// return TrkParams::Load(type); |
| 405 |
|
|
|
| 406 |
|
|
}; |
| 407 |
|
|
/** |
| 408 |
|
|
* Set tracker parameters proper for the run, from the from input. |
| 409 |
|
|
* @param path Path to parameters directory |
| 410 |
|
|
* @param type Parameter type |
| 411 |
|
|
* @return FALSE if parameter set fails. |
| 412 |
|
|
*/ |
| 413 |
|
|
Bool_t TrkParams::Set( TString path , UInt_t type){ |
| 414 |
|
|
|
| 415 |
|
|
UInt_t index = TrkParams::GetIndex( type ); |
| 416 |
|
|
if(index < 0)return false; |
| 417 |
|
|
|
| 418 |
|
|
gl[index].TYPE= type; |
| 419 |
|
|
glpath[index] = path; |
| 420 |
|
|
cout << "<< set TrkParams type "<<type<<" >>"<<endl; |
| 421 |
|
|
glload[index] = false; |
| 422 |
|
|
|
| 423 |
|
|
// return TrkParams::Load(type); |
| 424 |
|
|
return true; |
| 425 |
|
|
|
| 426 |
|
|
}; |
| 427 |
|
|
|
| 428 |
|
|
/** |
| 429 |
|
|
* Set and load tracker parameters. |
| 430 |
|
|
* @param type Parameter type |
| 431 |
|
|
* If no path as been yet specified, it set a default path. |
| 432 |
|
|
* @return FALSE if parameter set fails. |
| 433 |
|
|
*/ |
| 434 |
|
|
Bool_t TrkParams::Set(UInt_t type){ |
| 435 |
|
|
|
| 436 |
|
|
UInt_t index = TrkParams::GetIndex( type ); |
| 437 |
|
|
if(index < 0)return false; |
| 438 |
|
|
|
| 439 |
|
|
gl[index].TYPE= type; |
| 440 |
|
|
glload[index] = false; |
| 441 |
|
|
|
| 442 |
|
|
// ----------------------------------------- |
| 443 |
|
|
// check if enviroment variables are defined |
| 444 |
|
|
// ----------------------------------------- |
| 445 |
|
|
glpath[index] = gSystem->Getenv("PAM_CALIB"); |
| 446 |
|
|
|
| 447 |
|
|
if( !glpath[index].IsNull() ){ |
| 448 |
|
|
|
| 449 |
|
|
switch(type){ |
| 450 |
|
|
case 1: |
| 451 |
|
|
glpath[index].Append("/trk-param/field_param-0/"); |
| 452 |
|
|
break; |
| 453 |
|
|
case 2: |
| 454 |
|
|
glpath[index].Append("/trk-param/mip_param-0/"); |
| 455 |
|
|
break; |
| 456 |
|
|
case 3: |
| 457 |
|
|
glpath[index].Append("/trk-param/charge_param-1/"); |
| 458 |
|
|
break; |
| 459 |
|
|
case 4: |
| 460 |
|
|
glpath[index].Append("/trk-param/eta_param-0/"); |
| 461 |
|
|
break; |
| 462 |
|
|
case 5: |
| 463 |
|
|
glpath[index].Append("/trk-param/align_param-0/"); |
| 464 |
|
|
break; |
| 465 |
|
|
case 6: |
| 466 |
|
|
glpath[index].Append("/trk-param/mask_param-1/"); |
| 467 |
|
|
break; |
| 468 |
|
|
case 7: |
| 469 |
|
|
glpath[index].Append("/trk-param/default_calib/"); |
| 470 |
|
|
break; |
| 471 |
|
|
} |
| 472 |
|
|
|
| 473 |
|
|
}else{ |
| 474 |
|
|
cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
| 475 |
|
|
return false; |
| 476 |
|
|
|
| 477 |
|
|
} |
| 478 |
|
|
|
| 479 |
|
|
cout << "<< set TrkParams type "<<type<<" >>"<<endl; |
| 480 |
|
|
// return TrkParams::Load(type); |
| 481 |
|
|
return true; |
| 482 |
|
|
|
| 483 |
|
|
}; |
| 484 |
|
|
/** |
| 485 |
|
|
* Set tracker parameters. |
| 486 |
|
|
* If no path as been yet specified, try to read from DB |
| 487 |
|
|
* otherwise it set a default path. |
| 488 |
|
|
* @return FALSE if parameter set fails. |
| 489 |
|
|
*/ |
| 490 |
|
|
Bool_t TrkParams::Set( ){ |
| 491 |
|
|
|
| 492 |
|
|
Bool_t connected = false; |
| 493 |
|
|
|
| 494 |
|
|
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 495 |
|
|
TString host = "mysql://localhost/pamelaprod"; |
| 496 |
|
|
TString user = "anonymous"; |
| 497 |
|
|
TString psw = ""; |
| 498 |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 499 |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 500 |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 501 |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
| 502 |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
| 503 |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 504 |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 505 |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 506 |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 507 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 508 |
|
|
cout<<"Connecting to DB"<<endl; |
| 509 |
|
|
cout<<"HOST "<<host<<endl; |
| 510 |
|
|
cout<<"USER "<<user<<endl; |
| 511 |
|
|
cout<<"PSW "<<psw<<endl; |
| 512 |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 513 |
|
|
if( dbc || dbc->IsConnected() )connected = true; |
| 514 |
|
|
else cout << " >> FAILED!!!"<<endl; |
| 515 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 516 |
|
|
|
| 517 |
|
|
if(connected){ |
| 518 |
|
|
if ( !TrkParams::Set(0,dbc) )return false; |
| 519 |
|
|
dbc->Close(); |
| 520 |
|
|
}else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
| 521 |
|
|
} |
| 522 |
|
|
|
| 523 |
|
|
/** |
| 524 |
|
|
* Load tracker parameter, if not already loaded. |
| 525 |
|
|
* @param type Parameter type |
| 526 |
|
|
* ( Any call to TrkParams::Set(...) forces reloading ) |
| 527 |
|
|
*/ |
| 528 |
|
|
Bool_t TrkParams::Load(UInt_t type){ |
| 529 |
|
|
|
| 530 |
|
|
Int_t index = TrkParams::GetIndex( type ); |
| 531 |
|
|
if( index<0 )return false; |
| 532 |
|
|
if( glload[index] )return true; |
| 533 |
|
|
|
| 534 |
|
|
if( glpath[index].IsNull() )TrkParams::Set(type); |
| 535 |
|
|
|
| 536 |
|
|
switch( type ){ |
| 537 |
|
|
//------------------------------------------ |
| 538 |
|
|
case 1: |
| 539 |
|
|
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
| 540 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 541 |
|
|
path_.pathlen = glpath[index].Length(); |
| 542 |
|
|
path_.error = 0; |
| 543 |
|
|
readb_(); |
| 544 |
|
|
if(path_.error) return false; |
| 545 |
|
|
glload[index]=true; |
| 546 |
|
|
break; |
| 547 |
|
|
//------------------------------------------ |
| 548 |
|
|
case 2: |
| 549 |
|
|
cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl; |
| 550 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 551 |
|
|
path_.pathlen = glpath[index].Length(); |
| 552 |
|
|
path_.error = 0; |
| 553 |
|
|
readmipparam_(); |
| 554 |
|
|
if(path_.error) return false; |
| 555 |
|
|
glload[index]=true; |
| 556 |
|
|
break; |
| 557 |
|
|
//------------------------------------------ |
| 558 |
|
|
case 3: |
| 559 |
|
|
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
| 560 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 561 |
|
|
path_.pathlen = glpath[index].Length(); |
| 562 |
|
|
path_.error = 0; |
| 563 |
|
|
readchargeparam_(); |
| 564 |
|
|
if(path_.error) return false; |
| 565 |
|
|
glload[index]=true; |
| 566 |
|
|
break; |
| 567 |
|
|
//------------------------------------------ |
| 568 |
|
|
case 4: |
| 569 |
|
|
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
| 570 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 571 |
|
|
path_.pathlen = glpath[index].Length(); |
| 572 |
|
|
path_.error = 0; |
| 573 |
|
|
readetaparam_(); |
| 574 |
|
|
if(path_.error) return false; |
| 575 |
|
|
glload[index]=true; |
| 576 |
|
|
break; |
| 577 |
|
|
//------------------------------------------ |
| 578 |
|
|
case 5: |
| 579 |
|
|
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
| 580 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 581 |
|
|
path_.pathlen = glpath[index].Length(); |
| 582 |
|
|
path_.error = 0; |
| 583 |
|
|
readalignparam_(); |
| 584 |
|
|
if(path_.error) return false; |
| 585 |
|
|
glload[index]=true; |
| 586 |
|
|
break; |
| 587 |
|
|
//------------------------------------------ |
| 588 |
|
|
case 6: |
| 589 |
|
|
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
| 590 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 591 |
|
|
path_.pathlen = glpath[index].Length(); |
| 592 |
|
|
path_.error = 0; |
| 593 |
|
|
readvkmask_(); |
| 594 |
|
|
if(path_.error) return false; |
| 595 |
|
|
glload[index]=true; |
| 596 |
|
|
break; |
| 597 |
|
|
//------------------------------------------ |
| 598 |
|
|
case 7: |
| 599 |
|
|
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
| 600 |
|
|
strcpy(path_.path,glpath[index].Data()); |
| 601 |
|
|
path_.pathlen = glpath[index].Length(); |
| 602 |
|
|
path_.error = 0; |
| 603 |
|
|
// fillpedsigfromdefault_(); |
| 604 |
|
|
cout << ">> not implemented <<"<<endl; |
| 605 |
|
|
if(path_.error) return false; |
| 606 |
|
|
glload[index]=true; |
| 607 |
|
|
break; |
| 608 |
|
|
default: |
| 609 |
|
|
cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl; |
| 610 |
|
|
return false; |
| 611 |
|
|
}; |
| 612 |
|
|
|
| 613 |
|
|
return true; |
| 614 |
|
|
} |
| 615 |
|
|
|
| 616 |
|
|
Bool_t TrkParams::Load( ){ |
| 617 |
|
|
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )if( !TrkParams::Load(trkparamtype[i]) )return false; |
| 618 |
|
|
return true; |
| 619 |
|
|
}; |
| 620 |
|
|
Bool_t TrkParams::IsLoaded( ){ |
| 621 |
|
|
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false; |
| 622 |
|
|
return true; |
| 623 |
|
|
}; |
| 624 |
|
|
|
| 625 |
|
|
ClassImp(TrkParams); |