| 16 |
TString TrkParams::calibpathf = ""; |
TString TrkParams::calibpathf = ""; |
| 17 |
Bool_t TrkParams::calib104 = 0; |
Bool_t TrkParams::calib104 = 0; |
| 18 |
Bool_t TrkParams::calibload = false; |
Bool_t TrkParams::calibload = false; |
| 19 |
|
// ------------------------- |
| 20 |
|
// PARAMETERS loaded from DB |
| 21 |
|
// ------------------------- |
| 22 |
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
| 23 |
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()}; |
| 24 |
TString TrkParams::glpath[] = {"","","","","","",""}; |
TString TrkParams::glpath[] = {"","","","","","",""}; |
| 25 |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
| 26 |
|
cDbg TrkParams::dbg_mode = {0,0,0}; |
| 27 |
|
// ---------------- |
| 28 |
|
// other parameters |
| 29 |
|
// ---------------- |
| 30 |
|
int TrkParams::init__pfa = 14;//COG4 |
| 31 |
|
int TrkParams::init__mini_trackmode = 0; |
| 32 |
|
int TrkParams::init__mini_istepmin = 3; |
| 33 |
|
double TrkParams::init__mini_fact = 100.; |
| 34 |
|
|
| 35 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
| 36 |
|
|
| 60 |
*/ |
*/ |
| 61 |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
| 62 |
|
|
| 63 |
|
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
| 64 |
|
|
| 65 |
if( !CalibIsLoaded() || |
if( !CalibIsLoaded() || |
| 66 |
(glrun->TRK_CALIB_USED==104 && !calib104) || |
(glrun->TRK_CALIB_USED==104 && !calib104) || |
| 67 |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
| 73 |
GL_ROOT q3; |
GL_ROOT q3; |
| 74 |
GL_PARAM q4; |
GL_PARAM q4; |
| 75 |
|
|
| 76 |
cout << " UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
if(TrkParams::VerboseMode()){ |
| 77 |
|
cout << "--------------------------------------"<<endl; |
| 78 |
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
| 79 |
|
} |
| 80 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
| 81 |
cout << "Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
| 82 |
return false; |
return false; |
| 83 |
} |
} |
| 84 |
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
| 85 |
printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
| 86 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
| 87 |
cout << "Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
| 88 |
return false; |
return false; |
| 89 |
} |
} |
| 90 |
|
|
| 91 |
// cout << "selected "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<endl; |
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
| 92 |
calib = q2; |
calib = q2; |
| 93 |
calibpathf = q3.PATH + q3.NAME; |
calibpathf = q3.PATH + q3.NAME; |
| 94 |
calib104 = (glrun->TRK_CALIB_USED==104); |
calib104 = (glrun->TRK_CALIB_USED==104); |
| 107 |
}; |
}; |
| 108 |
|
|
| 109 |
/** |
/** |
| 110 |
|
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
| 111 |
|
* in YodaProfiler. |
| 112 |
|
*/ |
| 113 |
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
| 114 |
|
|
| 115 |
|
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
| 116 |
|
// UInt_t timeaftercalib=120000; //2000; |
| 117 |
|
TString classname = caltrk->GetName(); |
| 118 |
|
// ---------- |
| 119 |
|
// Check CRCs |
| 120 |
|
// ---------- |
| 121 |
|
if(TrkParams::VerboseMode())cout << " DSP: "; |
| 122 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
| 123 |
|
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
| 124 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
| 125 |
|
if( caltrk->crc_hcal[ipkt] ){ |
| 126 |
|
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
| 127 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
| 128 |
|
// return 0; // :-( |
| 129 |
|
} |
| 130 |
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
| 131 |
|
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
| 132 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
| 133 |
|
// return 0; // :-( |
| 134 |
|
} |
| 135 |
|
} |
| 136 |
|
} |
| 137 |
|
if(TrkParams::VerboseMode())cout << endl;; |
| 138 |
|
// ----------------------- |
| 139 |
|
// Check missing packets: |
| 140 |
|
// ----------------------- |
| 141 |
|
// Readout order: |
| 142 |
|
// ------------------ |
| 143 |
|
// DSP packet board |
| 144 |
|
// ------------------ |
| 145 |
|
// 12 0 1 |
| 146 |
|
// 10 1 1 |
| 147 |
|
// 8 2 1 |
| 148 |
|
// 4 3 1 |
| 149 |
|
// 6 4 1 |
| 150 |
|
// 2 5 1 |
| 151 |
|
// ------------------ |
| 152 |
|
// 11 0 2 |
| 153 |
|
// 9 1 2 |
| 154 |
|
// 7 2 2 |
| 155 |
|
// 3 3 2 |
| 156 |
|
// 5 4 2 |
| 157 |
|
// 1 5 2 |
| 158 |
|
// ------------------ |
| 159 |
|
// ------------------------------------------------- |
| 160 |
|
// Check if it is first or second calibration packet |
| 161 |
|
// ------------------------------------------------- |
| 162 |
|
UInt_t build=0; |
| 163 |
|
UInt_t base=0; |
| 164 |
|
UInt_t mask=0; |
| 165 |
|
if(classname.Contains("CalibTrk1Event")){ |
| 166 |
|
base=12; |
| 167 |
|
mask=0x03F000; |
| 168 |
|
} |
| 169 |
|
if(classname.Contains("CalibTrk2Event")){ |
| 170 |
|
base=18; |
| 171 |
|
mask=0xFC0000; |
| 172 |
|
} |
| 173 |
|
// ------------------------------------------------- |
| 174 |
|
// Count number of packets and set build variable |
| 175 |
|
// ------------------------------------------------- |
| 176 |
|
Int_t npkts=0; |
| 177 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
| 178 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
| 179 |
|
npkts++; |
| 180 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
| 181 |
|
}; |
| 182 |
|
} |
| 183 |
|
if( npkts==6 )return 1; // :-) |
| 184 |
|
else { |
| 185 |
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
| 186 |
|
} |
| 187 |
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
| 188 |
|
|
| 189 |
|
// ----------------------------------------------- |
| 190 |
|
// If missing packets: check the acq configuration |
| 191 |
|
// (some DSPs might be excluded from acquisition) |
| 192 |
|
// ----------------------------------------------- |
| 193 |
|
|
| 194 |
|
// ----------------------------------------------- |
| 195 |
|
// retrieve the first run header after calib |
| 196 |
|
// ----------------------------------------------- |
| 197 |
|
// PacketType *pctp; |
| 198 |
|
// EventCounter *cod; |
| 199 |
|
// cod = eh->GetCounter(); |
| 200 |
|
// Int_t irun = cod->Get(pctp->RunHeader); |
| 201 |
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
| 202 |
|
// if ( !rh || rh->IsZombie() ) throw -17; |
| 203 |
|
// if( rh->GetEntries() == irun ){ |
| 204 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
| 205 |
|
// return 0; // :-( |
| 206 |
|
// } |
| 207 |
|
|
| 208 |
|
// RunHeaderEvent *run = 0; |
| 209 |
|
// EventHeader *hrun = 0; |
| 210 |
|
// rh->SetBranchAddress("RunHeader", &run); |
| 211 |
|
// rh->SetBranchAddress("Header", &hrun); |
| 212 |
|
// rh->GetEntry(irun); |
| 213 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
| 214 |
|
|
| 215 |
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
| 216 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
| 217 |
|
// return 0; // :-( |
| 218 |
|
// } |
| 219 |
|
|
| 220 |
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
| 221 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
| 222 |
|
// return 0; // :-( |
| 223 |
|
// } |
| 224 |
|
|
| 225 |
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
| 226 |
|
// if( dtime > timeaftercalib ){ |
| 227 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
| 228 |
|
// return 0; // :-( |
| 229 |
|
// } |
| 230 |
|
|
| 231 |
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
| 232 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
| 233 |
|
// return 0; // :-( |
| 234 |
|
// } |
| 235 |
|
return 1; // :-) |
| 236 |
|
|
| 237 |
|
} |
| 238 |
|
/** |
| 239 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 240 |
*/ |
*/ |
| 241 |
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){ |
| 252 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
| 253 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
| 254 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
| 255 |
|
|
| 256 |
|
// --- TEST TEST TEST TEST --- // |
| 257 |
|
TrkParams::ValidateTrkCalib(calibdata1); |
| 258 |
|
TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 259 |
|
|
| 260 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
| 261 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
| 311 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
| 312 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
| 313 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
| 314 |
|
|
| 315 |
|
// --- TEST TEST TEST TEST --- // |
| 316 |
|
TrkParams::ValidateTrkCalib(calibdata1); |
| 317 |
|
TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 318 |
|
|
| 319 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
| 320 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
| 367 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
| 368 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
| 369 |
|
|
| 370 |
|
// --- TEST TEST TEST TEST --- // |
| 371 |
|
TrkParams::ValidateTrkCalib(calibdata1); |
| 372 |
|
TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 373 |
|
|
| 374 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
| 375 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
| 376 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
| 464 |
|
|
| 465 |
if( TrkParams::CalibIsLoaded() )return false; |
if( TrkParams::CalibIsLoaded() )return false; |
| 466 |
|
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
|
|
|
|
|
// extern cTrkCalib pedsigbad_; |
|
|
// extern cTrkMask mask_; |
|
|
|
|
|
cout << "--------------------------------------"<<endl; |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
|
| 467 |
// ============================================================= |
// ============================================================= |
| 468 |
// retrieve calibration file needed to reduce data |
// retrieve calibration file needed to reduce data |
| 469 |
// ============================================================= |
// ============================================================= |
| 470 |
// if run OBT is > last calibration "expiration date" |
// if run OBT is > last calibration "expiration date" |
| 471 |
// - search for new calibration packet |
// - search for new calibration packet |
| 472 |
// - load calibration parameters (full + truncated) |
// - load calibration parameters (full + truncated) |
| 473 |
cout << "Full pedestals for cluster finding:"; |
if(TrkParams::VerboseMode()){ |
| 474 |
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
cout << "--------------------------------------"<<endl; |
| 475 |
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
| 476 |
|
cout << " Full pedestals for cluster finding:"; |
| 477 |
|
cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; |
| 478 |
|
} |
| 479 |
FileStat_t t; |
FileStat_t t; |
| 480 |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
| 481 |
|
|
| 482 |
TFile *f0_c = new TFile(calibpathf); |
bool alreadyopened = false; |
| 483 |
|
TFile *f0_c=0; |
| 484 |
|
f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); |
| 485 |
|
if(f0_c)alreadyopened=true; |
| 486 |
|
else f0_c = new TFile(calibpathf); |
| 487 |
if ( !f0_c ) return false; |
if ( !f0_c ) return false; |
| 488 |
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
|
| 489 |
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
if(TrkParams::VerboseMode()){ |
| 490 |
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
| 491 |
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
| 492 |
|
cout << " - full+truncated parameters "<<endl; |
| 493 |
|
} |
| 494 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 495 |
|
if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl; |
| 496 |
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
|
// mask_.Set(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
|
|
// for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal[64][12][i] << endl; |
|
| 497 |
|
|
|
// }; |
|
| 498 |
// ============================================================= |
// ============================================================= |
| 499 |
// retrieve calibration file needed to uncompress data |
// retrieve calibration file needed to uncompress data |
| 500 |
// ============================================================= |
// ============================================================= |
| 501 |
// if the run was compressed using default calib |
// if the run was compressed using default calib |
| 502 |
// load truncated pedestals from default |
// load truncated pedestals from default |
| 503 |
// otherwise reload them from on-line calibration |
// otherwise reload them from on-line calibration |
| 504 |
cout << "Truncated pedestals for uncompression:"; |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
| 505 |
if( calib104 ){ |
if( calib104 ){ |
| 506 |
|
|
| 507 |
cout << " >> Loading default calibration: "<< calibpatht << endl; |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
|
// ca->FillTCalibFrom(calibpatht); |
|
| 508 |
TrkParams::FillTCalibFrom(calibpatht); |
TrkParams::FillTCalibFrom(calibpatht); |
| 509 |
|
|
| 510 |
}else{ |
}else{ |
| 511 |
|
|
| 512 |
if ( !f0_c ) return false; |
// if ( !f0_c ) return false; |
| 513 |
cout << ">> Loading on-line calibration " << endl; |
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
| 514 |
// ca->FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
// TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
|
TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
|
| 515 |
}; |
}; |
| 516 |
// for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
if(!alreadyopened)f0_c->Close(); |
| 517 |
f0_c->Close(); |
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
|
// delete f0_c; |
|
|
cout << "--------------------------------------"<<endl; |
|
| 518 |
|
|
| 519 |
calibload = kTRUE; |
calibload = kTRUE; |
| 520 |
return true; |
return true; |
| 538 |
*/ |
*/ |
| 539 |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
| 540 |
|
|
|
// if( !dbc )return false; |
|
| 541 |
|
|
| 542 |
|
UInt_t index = TrkParams::GetIndex( type ); |
| 543 |
|
if(index < 0)return false; |
| 544 |
|
|
| 545 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
if( !TrkParams::IsLoaded(type) || |
| 546 |
|
glrun->RUNHEADER_TIME < gl[index].FROM_TIME || |
| 547 |
|
glrun->RUNHEADER_TIME > gl[index].TO_TIME || |
| 548 |
|
false ){ |
| 549 |
|
|
| 550 |
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
|
TString host = "mysql://localhost/pamelaprod"; |
|
|
TString user = "anonymous"; |
|
|
TString psw = ""; |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
cout<<"Connecting to DB"<<endl; |
|
|
cout<<"HOST "<<host<<endl; |
|
|
cout<<"USER "<<user<<endl; |
|
|
cout<<"PSW "<<psw<<endl; |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if( !dbc )return false; |
|
|
if( !dbc->IsConnected() )return false; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
| 551 |
|
|
| 552 |
} |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 553 |
|
TString host = "mysql://localhost/pamelaprod"; |
| 554 |
|
TString user = "anonymous"; |
| 555 |
|
TString psw = ""; |
| 556 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 557 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 558 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 559 |
|
if ( !pamdbhost ) pamdbhost = ""; |
| 560 |
|
if ( !pamdbuser ) pamdbuser = ""; |
| 561 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 562 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 563 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 564 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 565 |
|
if(TrkParams::VerboseMode()){ |
| 566 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 567 |
|
cout<<"Connecting to DB"<<endl; |
| 568 |
|
cout<<"HOST "<<host<<endl; |
| 569 |
|
cout<<"USER "<<user<<endl; |
| 570 |
|
cout<<"PSW "<<psw<<endl; |
| 571 |
|
} |
| 572 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 573 |
|
if( !dbc )return false; |
| 574 |
|
if( !dbc->IsConnected() )return false; |
| 575 |
|
if(TrkParams::VerboseMode()){ |
| 576 |
|
cout << " ...done"<<endl; |
| 577 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 578 |
|
} |
| 579 |
|
} |
| 580 |
|
|
|
UInt_t index = TrkParams::GetIndex( type ); |
|
|
if(index < 0)return false; |
|
| 581 |
|
|
| 582 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
| 583 |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
| 584 |
else cout <<"Missing run info -- taking last entry "<<endl; |
else cout <<"Missing run info -- taking last entry "<<endl; |
| 585 |
|
|
| 586 |
GL_PARAM q4; |
GL_PARAM q4; |
| 587 |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
| 588 |
|
|
| 589 |
gl[index] = q4; |
gl[index] = q4; |
| 590 |
glpath[index] = q4.PATH+q4.NAME; |
glpath[index] = q4.PATH+q4.NAME; |
| 591 |
glload[index] = false; |
glload[index] = false; |
| 592 |
cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
| 593 |
return true; |
return true; |
| 594 |
// return TrkParams::Load(type); |
|
| 595 |
|
} |
| 596 |
|
return false; |
| 597 |
|
|
| 598 |
}; |
}; |
| 599 |
/** |
/** |
| 609 |
|
|
| 610 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
| 611 |
glpath[index] = path; |
glpath[index] = path; |
| 612 |
cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
| 613 |
glload[index] = false; |
glload[index] = false; |
| 614 |
|
|
| 615 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
| 668 |
|
|
| 669 |
} |
} |
| 670 |
|
|
| 671 |
cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
| 672 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
| 673 |
return true; |
return true; |
| 674 |
|
|
| 683 |
|
|
| 684 |
Bool_t connected = false; |
Bool_t connected = false; |
| 685 |
|
|
| 686 |
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
// cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 687 |
TString host = "mysql://localhost/pamelaprod"; |
TString host = "mysql://localhost/pamelaprod"; |
| 688 |
TString user = "anonymous"; |
TString user = "anonymous"; |
| 689 |
TString psw = ""; |
TString psw = ""; |
| 696 |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 697 |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 698 |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 699 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
if(TrkParams::VerboseMode()){ |
| 700 |
cout<<"Connecting to DB"<<endl; |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 701 |
cout<<"HOST "<<host<<endl; |
cout<<"Connecting to DB"<<endl; |
| 702 |
cout<<"USER "<<user<<endl; |
cout<<"HOST "<<host<<endl; |
| 703 |
cout<<"PSW "<<psw<<endl; |
cout<<"USER "<<user<<endl; |
| 704 |
|
cout<<"PSW "<<psw<<endl; |
| 705 |
|
} |
| 706 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 707 |
if( dbc || dbc->IsConnected() )connected = true; |
if( dbc || dbc->IsConnected() )connected = true; |
| 708 |
else cout << " >> FAILED!!!"<<endl; |
else cout << " >> DB connection FAILED!!!"<<endl; |
| 709 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 710 |
|
|
| 711 |
if(connected){ |
if(connected){ |
| 712 |
if ( !TrkParams::Set(0,dbc) )return false; |
if ( !TrkParams::Set(0,dbc) )return false; |
| 732 |
switch( type ){ |
switch( type ){ |
| 733 |
//------------------------------------------ |
//------------------------------------------ |
| 734 |
case 1: |
case 1: |
| 735 |
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
| 736 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 737 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 738 |
path_.error = 0; |
path_.error = 0; |
| 742 |
break; |
break; |
| 743 |
//------------------------------------------ |
//------------------------------------------ |
| 744 |
case 2: |
case 2: |
| 745 |
cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl; |
| 746 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 747 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 748 |
path_.error = 0; |
path_.error = 0; |
| 752 |
break; |
break; |
| 753 |
//------------------------------------------ |
//------------------------------------------ |
| 754 |
case 3: |
case 3: |
| 755 |
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
| 756 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 757 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 758 |
path_.error = 0; |
path_.error = 0; |
| 762 |
break; |
break; |
| 763 |
//------------------------------------------ |
//------------------------------------------ |
| 764 |
case 4: |
case 4: |
| 765 |
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
| 766 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 767 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 768 |
path_.error = 0; |
path_.error = 0; |
| 772 |
break; |
break; |
| 773 |
//------------------------------------------ |
//------------------------------------------ |
| 774 |
case 5: |
case 5: |
| 775 |
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
| 776 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 777 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 778 |
path_.error = 0; |
path_.error = 0; |
| 782 |
break; |
break; |
| 783 |
//------------------------------------------ |
//------------------------------------------ |
| 784 |
case 6: |
case 6: |
| 785 |
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
| 786 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 787 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 788 |
path_.error = 0; |
path_.error = 0; |
| 792 |
break; |
break; |
| 793 |
//------------------------------------------ |
//------------------------------------------ |
| 794 |
case 7: |
case 7: |
| 795 |
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
| 796 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
| 797 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
| 798 |
path_.error = 0; |
path_.error = 0; |
| 799 |
// fillpedsigfromdefault_(); |
// fillpedsigfromdefault_(); |
| 800 |
cout << ">> not implemented <<"<<endl; |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
| 801 |
if(path_.error) return false; |
if(path_.error) return false; |
| 802 |
glload[index]=true; |
glload[index]=true; |
| 803 |
break; |
break; |
| 804 |
default: |
default: |
| 805 |
cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl; |
if(TrkParams::VerboseMode())cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl; |
| 806 |
return false; |
return false; |
| 807 |
}; |
}; |
| 808 |
|
|
| 818 |
return true; |
return true; |
| 819 |
}; |
}; |
| 820 |
|
|
| 821 |
|
|
| 822 |
|
/** |
| 823 |
|
* Get BY (kGauss) |
| 824 |
|
* @param v (x,y,z) coordinates in cm |
| 825 |
|
*/ |
| 826 |
|
float TrkParams::GetBX(float* v){ |
| 827 |
|
TrkParams::Load(1); |
| 828 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
| 829 |
|
float b[3]; |
| 830 |
|
gufld_(v,b); |
| 831 |
|
return b[0]/10.; |
| 832 |
|
} |
| 833 |
|
/** |
| 834 |
|
* Get BY (kGauss) |
| 835 |
|
* @param v (x,y,z) coordinates in cm |
| 836 |
|
*/ |
| 837 |
|
float TrkParams::GetBY(float* v){ |
| 838 |
|
TrkParams::Load(1); |
| 839 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
| 840 |
|
float b[3]; |
| 841 |
|
gufld_(v,b); |
| 842 |
|
return b[1]/10.; |
| 843 |
|
} |
| 844 |
|
/** |
| 845 |
|
* Get BY (kGauss) |
| 846 |
|
* @param v (x,y,z) coordinates in cm |
| 847 |
|
*/ |
| 848 |
|
float TrkParams::GetBZ(float* v){ |
| 849 |
|
TrkParams::Load(1); |
| 850 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
| 851 |
|
float b[3]; |
| 852 |
|
gufld_(v,b); |
| 853 |
|
return b[2]/10.; |
| 854 |
|
} |
| 855 |
|
|
| 856 |
|
|
| 857 |
|
|
| 858 |
|
/** |
| 859 |
|
* \brief Set tracking mode (0=standard. 1=???) |
| 860 |
|
*/ |
| 861 |
|
void TrkParams::SetTrackingMode(int trackmode) { |
| 862 |
|
init__mini_trackmode = trackmode; |
| 863 |
|
SetTrackingMode(); |
| 864 |
|
}; |
| 865 |
|
/** |
| 866 |
|
* \brief Set fit-precision factor (typical value fact=100.) |
| 867 |
|
*/ |
| 868 |
|
void TrkParams::SetPrecisionFactor(double fact){ |
| 869 |
|
init__mini_fact = fact; |
| 870 |
|
SetPrecisionFactor(); |
| 871 |
|
}; |
| 872 |
|
/** |
| 873 |
|
* \brief Set minimum number of step in track fitting |
| 874 |
|
*/ |
| 875 |
|
void TrkParams::SetStepMin(int istepmin){ |
| 876 |
|
init__mini_istepmin = istepmin; |
| 877 |
|
SetStepMin(); |
| 878 |
|
}; |
| 879 |
|
|
| 880 |
|
/** |
| 881 |
|
* \brief Set p.f.a. |
| 882 |
|
* |
| 883 |
|
* Implemented algorythms: |
| 884 |
|
* 0 ETA (default) |
| 885 |
|
* 1 --- |
| 886 |
|
* 2 ETA2 |
| 887 |
|
* 3 ETA3 |
| 888 |
|
* 4 ETA4 |
| 889 |
|
* 10 COG |
| 890 |
|
* 11 COG1 |
| 891 |
|
* 12 COG2 |
| 892 |
|
* 13 COG3 |
| 893 |
|
* 14 COG4 |
| 894 |
|
*/ |
| 895 |
|
void TrkParams::SetPFA(int pfaid){ |
| 896 |
|
init__pfa = pfaid; |
| 897 |
|
SetPFA(); |
| 898 |
|
}; |
| 899 |
|
/** |
| 900 |
|
* \brief Get spatial resolution. |
| 901 |
|
* |
| 902 |
|
* Method to retrieve the spatial resolution associated with the |
| 903 |
|
* adopted p.f.a. |
| 904 |
|
* @param view Tracker view (1-12) |
| 905 |
|
* @param angle Track projected angle |
| 906 |
|
* |
| 907 |
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
| 908 |
|
* |
| 909 |
|
* TrkParams::SetPFA(0) // ETA |
| 910 |
|
* |
| 911 |
|
*/ |
| 912 |
|
float TrkParams::GetResolution(int view, float angle){ |
| 913 |
|
float res = 1000; |
| 914 |
|
if( init__pfa == 0 )res = riseta_(&view,&angle); |
| 915 |
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
| 916 |
|
return res; |
| 917 |
|
} |
| 918 |
|
|
| 919 |
|
|
| 920 |
|
|
| 921 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |