| 1 |
pam-fi |
1.1 |
/** |
| 2 |
|
|
* \file TrkParams.cpp |
| 3 |
|
|
* \author Elena Vannuccini |
| 4 |
|
|
*/ |
| 5 |
|
|
|
| 6 |
|
|
#include <TrkParams.h> |
| 7 |
|
|
#include <iostream> |
| 8 |
pam-fi |
1.10 |
#include <iomanip> |
| 9 |
pam-fi |
1.1 |
using namespace std; |
| 10 |
|
|
|
| 11 |
|
|
|
| 12 |
|
|
// ------------------------- |
| 13 |
|
|
// CALIBRATION (PED,SIG,BAD) |
| 14 |
|
|
// ------------------------- |
| 15 |
|
|
GL_TRK_CALIB TrkParams::calib = GL_TRK_CALIB(); |
| 16 |
|
|
TString TrkParams::calibpatht = ""; |
| 17 |
|
|
TString TrkParams::calibpathf = ""; |
| 18 |
|
|
Bool_t TrkParams::calib104 = 0; |
| 19 |
|
|
Bool_t TrkParams::calibload = false; |
| 20 |
pam-fi |
1.8 |
// ------------------------- |
| 21 |
|
|
// PARAMETERS loaded from DB |
| 22 |
|
|
// ------------------------- |
| 23 |
pam-fi |
1.1 |
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
| 24 |
|
|
GL_PARAM TrkParams::gl[] = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()}; |
| 25 |
|
|
TString TrkParams::glpath[] = {"","","","","","",""}; |
| 26 |
|
|
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
| 27 |
pam-fi |
1.8 |
// ---------------- |
| 28 |
|
|
// other parameters |
| 29 |
|
|
// ---------------- |
| 30 |
pam-fi |
1.12 |
cDbg TrkParams::init__dbg_mode = {0,0,0}; |
| 31 |
pam-fi |
1.15 |
//int TrkParams::init__pfa = 14;//COG4 |
| 32 |
|
|
int TrkParams::init__pfa = 5;//ETAL |
| 33 |
pam-fi |
1.8 |
int TrkParams::init__mini_trackmode = 0; |
| 34 |
pam-fi |
1.13 |
int TrkParams::init__mini_istepmin = 5; //3; |
| 35 |
|
|
double TrkParams::init__mini_fact = 1.e4; //100.; |
| 36 |
|
|
float TrkParams::init__pfa_e234ax[] = {0.,10.,10.,15.,15.,90.}; |
| 37 |
|
|
float TrkParams::init__pfa_e234ay[] = {0.,20.,90.,90.,90.,90.}; |
| 38 |
pam-fi |
1.1 |
|
| 39 |
|
|
TrkParams::TrkParams(){ |
| 40 |
|
|
|
| 41 |
pam-fi |
1.8 |
cout<<"TrkParams::TrkParams()"<<endl; |
| 42 |
pam-fi |
1.1 |
|
| 43 |
|
|
} |
| 44 |
|
|
float aint(float f){ |
| 45 |
|
|
int ret = (int)f; |
| 46 |
|
|
float ret1 = 0; |
| 47 |
|
|
ret1=(float)ret; |
| 48 |
|
|
return ret1; |
| 49 |
|
|
} |
| 50 |
|
|
|
| 51 |
|
|
float anint(float f){ |
| 52 |
|
|
int ret = (int)(f+0.5); |
| 53 |
|
|
float ret1 = 0; |
| 54 |
|
|
ret1=(float)ret; |
| 55 |
|
|
return ret1; |
| 56 |
|
|
} |
| 57 |
|
|
/** |
| 58 |
pam-fi |
1.10 |
* \brief Static method to set the calibration to be loaded. |
| 59 |
pam-fi |
1.1 |
|
| 60 |
|
|
* It retrieves the calibration associated to a given run, from |
| 61 |
|
|
* a given DB. It fills the F77 common. |
| 62 |
|
|
* @param glrun Pointer to a GL_RUN row |
| 63 |
|
|
* @param dbc Pointer to a DB connection |
| 64 |
|
|
*/ |
| 65 |
|
|
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
| 66 |
|
|
|
| 67 |
pam-fi |
1.6 |
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
| 68 |
|
|
|
| 69 |
pam-fi |
1.3 |
if( !CalibIsLoaded() || |
| 70 |
|
|
(glrun->TRK_CALIB_USED==104 && !calib104) || |
| 71 |
|
|
(glrun->TRK_CALIB_USED!=104 && calib104) || |
| 72 |
|
|
glrun->RUNHEADER_TIME < calib.FROM_TIME || |
| 73 |
|
|
glrun->RUNHEADER_TIME > calib.TO_TIME || |
| 74 |
|
|
false ){ |
| 75 |
|
|
|
| 76 |
pam-fi |
1.10 |
// cout <<">>> isloaded? "<< CalibIsLoaded() << endl; |
| 77 |
|
|
// cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl; |
| 78 |
|
|
// cout <<">>> 104 loaded? "<< calib104 <<endl; |
| 79 |
|
|
// cout <<">>> from time "<< calib.FROM_TIME<<endl; |
| 80 |
|
|
// cout <<">>> to time "<< calib.TO_TIME<<endl; |
| 81 |
|
|
// if( !dbc || (dbc && !dbc->IsConnected()) ){ |
| 82 |
|
|
|
| 83 |
|
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 84 |
|
|
// TString host = "mysql://localhost/pamelaprod"; |
| 85 |
|
|
// TString user = "anonymous"; |
| 86 |
|
|
// TString psw = ""; |
| 87 |
|
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 88 |
|
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 89 |
|
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 90 |
|
|
// if ( !pamdbhost ) pamdbhost = ""; |
| 91 |
|
|
// if ( !pamdbuser ) pamdbuser = ""; |
| 92 |
|
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
| 93 |
|
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 94 |
|
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 95 |
|
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 96 |
|
|
// if(TrkParams::VerboseMode()){ |
| 97 |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 98 |
|
|
// cout<<"Connecting to DB"<<endl; |
| 99 |
|
|
// cout<<"HOST "<<host<<endl; |
| 100 |
|
|
// cout<<"USER "<<user<<endl; |
| 101 |
|
|
// cout<<"PSW "<<psw<<endl; |
| 102 |
|
|
// } |
| 103 |
|
|
// dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 104 |
|
|
// if( !dbc )return false; |
| 105 |
|
|
// if( !dbc->IsConnected() )return false; |
| 106 |
|
|
// if(TrkParams::VerboseMode()){ |
| 107 |
|
|
// cout << " ...done"<<endl; |
| 108 |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 109 |
|
|
// } |
| 110 |
|
|
// } |
| 111 |
|
|
|
| 112 |
pam-fi |
1.3 |
GL_TRK_CALIB q2; |
| 113 |
|
|
GL_ROOT q3; |
| 114 |
|
|
GL_PARAM q4; |
| 115 |
|
|
|
| 116 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode()){ |
| 117 |
|
|
cout << "--------------------------------------"<<endl; |
| 118 |
|
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
| 119 |
|
|
} |
| 120 |
pam-fi |
1.3 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
| 121 |
pam-fi |
1.6 |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
| 122 |
pam-fi |
1.3 |
return false; |
| 123 |
|
|
} |
| 124 |
|
|
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
| 125 |
pam-fi |
1.6 |
printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
| 126 |
pam-fi |
1.3 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
| 127 |
pam-fi |
1.6 |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
| 128 |
pam-fi |
1.3 |
return false; |
| 129 |
|
|
} |
| 130 |
|
|
|
| 131 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
| 132 |
pam-fi |
1.3 |
calib = q2; |
| 133 |
|
|
calibpathf = q3.PATH + q3.NAME; |
| 134 |
|
|
calib104 = (glrun->TRK_CALIB_USED==104); |
| 135 |
|
|
calibload = kFALSE; |
| 136 |
|
|
if(calib104){ |
| 137 |
|
|
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
| 138 |
|
|
calibpatht = q4.PATH + q4.NAME; |
| 139 |
|
|
} |
| 140 |
|
|
|
| 141 |
pam-fi |
1.1 |
|
| 142 |
pam-fi |
1.3 |
// return TrkParams::LoadCalib(); |
| 143 |
|
|
return true; |
| 144 |
pam-fi |
1.1 |
} |
| 145 |
|
|
|
| 146 |
pam-fi |
1.3 |
return false; |
| 147 |
pam-fi |
1.1 |
}; |
| 148 |
|
|
|
| 149 |
|
|
/** |
| 150 |
pam-fi |
1.4 |
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
| 151 |
|
|
* in YodaProfiler. |
| 152 |
|
|
*/ |
| 153 |
|
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
| 154 |
|
|
|
| 155 |
pam-fi |
1.10 |
UInt_t validate = 1; |
| 156 |
pam-fi |
1.4 |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
| 157 |
|
|
// UInt_t timeaftercalib=120000; //2000; |
| 158 |
|
|
TString classname = caltrk->GetName(); |
| 159 |
|
|
// ---------- |
| 160 |
|
|
// Check CRCs |
| 161 |
|
|
// ---------- |
| 162 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " DSP: "; |
| 163 |
pam-fi |
1.4 |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
| 164 |
pam-fi |
1.7 |
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
| 165 |
pam-fi |
1.5 |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
| 166 |
|
|
if( caltrk->crc_hcal[ipkt] ){ |
| 167 |
pam-fi |
1.6 |
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
| 168 |
|
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
| 169 |
pam-fi |
1.5 |
// return 0; // :-( |
| 170 |
pam-fi |
1.10 |
validate = 0; |
| 171 |
pam-fi |
1.5 |
} |
| 172 |
|
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
| 173 |
pam-fi |
1.6 |
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
| 174 |
|
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
| 175 |
pam-fi |
1.5 |
// return 0; // :-( |
| 176 |
pam-fi |
1.10 |
validate = 0; |
| 177 |
pam-fi |
1.5 |
} |
| 178 |
pam-fi |
1.4 |
} |
| 179 |
|
|
} |
| 180 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << endl;; |
| 181 |
pam-fi |
1.4 |
// ----------------------- |
| 182 |
|
|
// Check missing packets: |
| 183 |
|
|
// ----------------------- |
| 184 |
|
|
// Readout order: |
| 185 |
|
|
// ------------------ |
| 186 |
|
|
// DSP packet board |
| 187 |
|
|
// ------------------ |
| 188 |
|
|
// 12 0 1 |
| 189 |
|
|
// 10 1 1 |
| 190 |
|
|
// 8 2 1 |
| 191 |
|
|
// 4 3 1 |
| 192 |
|
|
// 6 4 1 |
| 193 |
|
|
// 2 5 1 |
| 194 |
|
|
// ------------------ |
| 195 |
|
|
// 11 0 2 |
| 196 |
|
|
// 9 1 2 |
| 197 |
|
|
// 7 2 2 |
| 198 |
|
|
// 3 3 2 |
| 199 |
|
|
// 5 4 2 |
| 200 |
|
|
// 1 5 2 |
| 201 |
|
|
// ------------------ |
| 202 |
|
|
// ------------------------------------------------- |
| 203 |
|
|
// Check if it is first or second calibration packet |
| 204 |
|
|
// ------------------------------------------------- |
| 205 |
|
|
UInt_t build=0; |
| 206 |
|
|
UInt_t base=0; |
| 207 |
|
|
UInt_t mask=0; |
| 208 |
|
|
if(classname.Contains("CalibTrk1Event")){ |
| 209 |
|
|
base=12; |
| 210 |
|
|
mask=0x03F000; |
| 211 |
|
|
} |
| 212 |
|
|
if(classname.Contains("CalibTrk2Event")){ |
| 213 |
|
|
base=18; |
| 214 |
|
|
mask=0xFC0000; |
| 215 |
|
|
} |
| 216 |
|
|
// ------------------------------------------------- |
| 217 |
|
|
// Count number of packets and set build variable |
| 218 |
|
|
// ------------------------------------------------- |
| 219 |
|
|
Int_t npkts=0; |
| 220 |
|
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
| 221 |
|
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
| 222 |
|
|
npkts++; |
| 223 |
|
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
| 224 |
|
|
}; |
| 225 |
|
|
} |
| 226 |
pam-fi |
1.10 |
if( npkts==6 ){}//return 1; // :-) |
| 227 |
pam-fi |
1.6 |
else { |
| 228 |
|
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
| 229 |
pam-fi |
1.10 |
validate = 0; |
| 230 |
pam-fi |
1.6 |
} |
| 231 |
pam-fi |
1.4 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
| 232 |
|
|
|
| 233 |
|
|
// ----------------------------------------------- |
| 234 |
|
|
// If missing packets: check the acq configuration |
| 235 |
|
|
// (some DSPs might be excluded from acquisition) |
| 236 |
|
|
// ----------------------------------------------- |
| 237 |
|
|
|
| 238 |
|
|
// ----------------------------------------------- |
| 239 |
|
|
// retrieve the first run header after calib |
| 240 |
|
|
// ----------------------------------------------- |
| 241 |
|
|
// PacketType *pctp; |
| 242 |
|
|
// EventCounter *cod; |
| 243 |
|
|
// cod = eh->GetCounter(); |
| 244 |
|
|
// Int_t irun = cod->Get(pctp->RunHeader); |
| 245 |
|
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
| 246 |
|
|
// if ( !rh || rh->IsZombie() ) throw -17; |
| 247 |
|
|
// if( rh->GetEntries() == irun ){ |
| 248 |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
| 249 |
|
|
// return 0; // :-( |
| 250 |
|
|
// } |
| 251 |
|
|
|
| 252 |
|
|
// RunHeaderEvent *run = 0; |
| 253 |
|
|
// EventHeader *hrun = 0; |
| 254 |
|
|
// rh->SetBranchAddress("RunHeader", &run); |
| 255 |
|
|
// rh->SetBranchAddress("Header", &hrun); |
| 256 |
|
|
// rh->GetEntry(irun); |
| 257 |
|
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
| 258 |
|
|
|
| 259 |
|
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
| 260 |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
| 261 |
|
|
// return 0; // :-( |
| 262 |
|
|
// } |
| 263 |
|
|
|
| 264 |
|
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
| 265 |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
| 266 |
|
|
// return 0; // :-( |
| 267 |
|
|
// } |
| 268 |
|
|
|
| 269 |
|
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
| 270 |
|
|
// if( dtime > timeaftercalib ){ |
| 271 |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
| 272 |
|
|
// return 0; // :-( |
| 273 |
|
|
// } |
| 274 |
|
|
|
| 275 |
|
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
| 276 |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
| 277 |
|
|
// return 0; // :-( |
| 278 |
|
|
// } |
| 279 |
pam-fi |
1.10 |
|
| 280 |
|
|
// return 1; // :-) |
| 281 |
|
|
|
| 282 |
|
|
// cout << validate << endl; |
| 283 |
|
|
return validate; |
| 284 |
pam-fi |
1.4 |
|
| 285 |
|
|
} |
| 286 |
|
|
/** |
| 287 |
pam-fi |
1.1 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 288 |
|
|
*/ |
| 289 |
|
|
void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 290 |
|
|
|
| 291 |
|
|
cTrkCalib *ca = &pedsigbad_; |
| 292 |
pam-fi |
1.10 |
ca->Reset(); |
| 293 |
pam-fi |
1.1 |
|
| 294 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
| 295 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
| 296 |
|
|
|
| 297 |
|
|
CalibTrk1Event *calibdata1 = 0; |
| 298 |
|
|
CalibTrk2Event *calibdata2 = 0; |
| 299 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
| 300 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
| 301 |
|
|
tr1->GetEntry(ev_reg1); |
| 302 |
|
|
tr2->GetEntry(ev_reg2); |
| 303 |
|
|
Int_t dspn1(0),dspn2(0); |
| 304 |
pam-fi |
1.4 |
|
| 305 |
|
|
// --- TEST TEST TEST TEST --- // |
| 306 |
pam-fi |
1.10 |
// TrkParams::ValidateTrkCalib(calibdata1); |
| 307 |
|
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 308 |
|
|
|
| 309 |
|
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
| 310 |
|
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 311 |
|
|
if( !test1 || !test2 ){ |
| 312 |
|
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
| 313 |
|
|
TrkParams::calib.VALIDATION = 0; |
| 314 |
|
|
} |
| 315 |
|
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
| 316 |
|
|
|
| 317 |
pam-fi |
1.1 |
for(Int_t i=0;i<6;i++){ |
| 318 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
| 319 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
| 320 |
pam-fi |
1.10 |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
| 321 |
pam-fi |
1.1 |
for(Int_t ii=0;ii<3072;ii++){ |
| 322 |
|
|
Int_t j=(ii/128); |
| 323 |
|
|
Int_t jj=ii-j*128; |
| 324 |
pam-fi |
1.10 |
if(dspn1>=0 && dspn1<12){ |
| 325 |
|
|
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
| 326 |
|
|
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
| 327 |
|
|
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
| 328 |
|
|
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
| 329 |
|
|
if(calibdata1->DSPbad_par[i][ii]==0) |
| 330 |
|
|
ca->bad[jj][j][dspn1]=1; |
| 331 |
|
|
else if(calibdata1->DSPbad_par[i][ii]==1) |
| 332 |
|
|
ca->bad[jj][j][dspn1]=0; |
| 333 |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
| 334 |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
| 335 |
|
|
} |
| 336 |
|
|
|
| 337 |
|
|
if(dspn2>=0 && dspn2<12){ |
| 338 |
|
|
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
| 339 |
|
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
| 340 |
|
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
| 341 |
|
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
| 342 |
|
|
if(calibdata2->DSPbad_par[i][ii]==0) |
| 343 |
|
|
ca->bad[jj][j][dspn2]=1; |
| 344 |
|
|
else if(calibdata2->DSPbad_par[i][ii]==1) |
| 345 |
|
|
ca->bad[jj][j][dspn2]=0; |
| 346 |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
| 347 |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
| 348 |
|
|
} |
| 349 |
pam-fi |
1.1 |
}; |
| 350 |
|
|
}; |
| 351 |
|
|
|
| 352 |
|
|
tr1->Delete(); |
| 353 |
|
|
tr2->Delete(); |
| 354 |
|
|
}; |
| 355 |
|
|
/** |
| 356 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 357 |
|
|
*/ |
| 358 |
|
|
void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 359 |
|
|
|
| 360 |
|
|
cTrkCalib *ca = &pedsigbad_; |
| 361 |
pam-fi |
1.10 |
// ca->Reset(); |
| 362 |
pam-fi |
1.1 |
|
| 363 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
| 364 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
| 365 |
|
|
|
| 366 |
|
|
CalibTrk1Event *calibdata1 = 0; |
| 367 |
|
|
CalibTrk2Event *calibdata2 = 0; |
| 368 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
| 369 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
| 370 |
|
|
tr1->GetEntry(ev_reg1); |
| 371 |
|
|
tr2->GetEntry(ev_reg2); |
| 372 |
|
|
Int_t dspn1(0),dspn2(0); |
| 373 |
pam-fi |
1.4 |
|
| 374 |
|
|
// --- TEST TEST TEST TEST --- // |
| 375 |
pam-fi |
1.10 |
// TrkParams::ValidateTrkCalib(calibdata1); |
| 376 |
|
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 377 |
|
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
| 378 |
|
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 379 |
|
|
if( !test1 || !test2 ){ |
| 380 |
|
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
| 381 |
|
|
TrkParams::calib.VALIDATION = 0; |
| 382 |
|
|
} |
| 383 |
|
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
| 384 |
pam-fi |
1.1 |
|
| 385 |
|
|
for(Int_t i=0;i<6;i++){ |
| 386 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
| 387 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
| 388 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
| 389 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
| 390 |
|
|
Int_t j=(ii/128); |
| 391 |
|
|
Int_t jj=ii-j*128; |
| 392 |
pam-fi |
1.10 |
if(dspn1>=0 && dspn1<12){ |
| 393 |
|
|
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
| 394 |
|
|
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
| 395 |
|
|
if(calibdata1->DSPbad_par[i][ii]==0) |
| 396 |
|
|
ca->bad[jj][j][dspn1]=1; |
| 397 |
|
|
else if(calibdata1->DSPbad_par[i][ii]==1) |
| 398 |
|
|
ca->bad[jj][j][dspn1]=0; |
| 399 |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
| 400 |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
| 401 |
|
|
} |
| 402 |
|
|
if(dspn2>=0 && dspn2<12){ |
| 403 |
|
|
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
| 404 |
|
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
| 405 |
|
|
if(calibdata2->DSPbad_par[i][ii]==0) |
| 406 |
|
|
ca->bad[jj][j][dspn2]=1; |
| 407 |
|
|
else if(calibdata2->DSPbad_par[i][ii]==1) |
| 408 |
|
|
ca->bad[jj][j][dspn2]=0; |
| 409 |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
| 410 |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
| 411 |
|
|
} |
| 412 |
pam-fi |
1.1 |
}; |
| 413 |
|
|
}; |
| 414 |
|
|
|
| 415 |
|
|
tr1->Delete(); |
| 416 |
|
|
tr2->Delete(); |
| 417 |
|
|
}; |
| 418 |
|
|
/** |
| 419 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
| 420 |
|
|
*/ |
| 421 |
|
|
void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 422 |
|
|
|
| 423 |
|
|
cTrkCalib *ca = &pedsigbad_; |
| 424 |
pam-fi |
1.10 |
// ca->Reset(); |
| 425 |
pam-fi |
1.1 |
|
| 426 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
| 427 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
| 428 |
|
|
|
| 429 |
|
|
CalibTrk1Event *calibdata1 = 0; |
| 430 |
|
|
CalibTrk2Event *calibdata2 = 0; |
| 431 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
| 432 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
| 433 |
|
|
tr1->GetEntry(ev_reg1); |
| 434 |
|
|
tr2->GetEntry(ev_reg2); |
| 435 |
|
|
Int_t dspn1(0),dspn2(0); |
| 436 |
|
|
|
| 437 |
pam-fi |
1.4 |
// --- TEST TEST TEST TEST --- // |
| 438 |
pam-fi |
1.10 |
// TrkParams::ValidateTrkCalib(calibdata1); |
| 439 |
|
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 440 |
|
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
| 441 |
|
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
| 442 |
|
|
if( !test1 || !test2 ){ |
| 443 |
|
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
| 444 |
|
|
TrkParams::calib.VALIDATION = 0; |
| 445 |
|
|
} |
| 446 |
|
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
| 447 |
pam-fi |
1.4 |
|
| 448 |
pam-fi |
1.1 |
for(Int_t i=0;i<6;i++){ |
| 449 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
| 450 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
| 451 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
| 452 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
| 453 |
|
|
Int_t j=(ii/128); |
| 454 |
|
|
Int_t jj=ii-j*128; |
| 455 |
pam-fi |
1.10 |
if(dspn1>=0 && dspn1<12){ |
| 456 |
|
|
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
| 457 |
|
|
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
| 458 |
|
|
} |
| 459 |
|
|
if(dspn2>=0 && dspn2<12){ |
| 460 |
|
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
| 461 |
|
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
| 462 |
|
|
} |
| 463 |
pam-fi |
1.1 |
}; |
| 464 |
|
|
}; |
| 465 |
|
|
|
| 466 |
|
|
tr1->Delete(); |
| 467 |
|
|
tr2->Delete(); |
| 468 |
|
|
}; |
| 469 |
|
|
/** |
| 470 |
|
|
* Method to fill the tracker calibration-parameter struct from default calibration |
| 471 |
|
|
*/ |
| 472 |
|
|
void TrkParams::FillTCalibFrom(TString path){ |
| 473 |
|
|
|
| 474 |
|
|
path_.FillWith(path); |
| 475 |
|
|
fillpedsigfromdefault_(); |
| 476 |
|
|
if(path_.error) throw -216; |
| 477 |
|
|
|
| 478 |
|
|
}; |
| 479 |
|
|
/** |
| 480 |
|
|
* Method to fill the tracker VA1-mask struct from calibration |
| 481 |
|
|
*/ |
| 482 |
|
|
void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
| 483 |
|
|
|
| 484 |
|
|
cTrkMask *ma = &mask_; |
| 485 |
pam-fi |
1.10 |
ma->Reset(); |
| 486 |
pam-fi |
1.1 |
|
| 487 |
|
|
TrkCalib *calib = new TrkCalib(); |
| 488 |
|
|
|
| 489 |
|
|
for(Int_t i=0; i<2; i++){ |
| 490 |
|
|
TTree *tr=0; |
| 491 |
|
|
if(i==0){ |
| 492 |
|
|
//------------------------- |
| 493 |
|
|
//read calibration packet 1 |
| 494 |
|
|
//------------------------- |
| 495 |
|
|
tr = (TTree*)f0->Get("CalibTrk1"); |
| 496 |
|
|
tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo()); |
| 497 |
|
|
tr->GetEntry(ev_reg1); |
| 498 |
|
|
} |
| 499 |
|
|
if(i==1){ |
| 500 |
|
|
//------------------------- |
| 501 |
|
|
//read calibration packet 2 |
| 502 |
|
|
//------------------------- |
| 503 |
|
|
tr = (TTree*)f0->Get("CalibTrk2"); |
| 504 |
|
|
tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); |
| 505 |
|
|
tr->GetEntry(ev_reg2); |
| 506 |
|
|
} |
| 507 |
|
|
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
| 508 |
pam-fi |
1.10 |
Int_t view = calib->GetView(ipkt); |
| 509 |
|
|
if( (view-1)>= 0 && (view-1)<12 ){ |
| 510 |
|
|
for(Int_t ivk=0; ivk<NVK; ivk++){ |
| 511 |
|
|
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
| 512 |
|
|
Float_t sigmin = 0.; |
| 513 |
|
|
if(view%2)sigmin = 6.5; |
| 514 |
|
|
else sigmin = 2.5; |
| 515 |
|
|
Int_t mask = 1; |
| 516 |
|
|
if( sigm<sigmin )mask = 0; |
| 517 |
|
|
ma->mask_vk_run[ivk][view-1] = mask; |
| 518 |
|
|
} |
| 519 |
|
|
} |
| 520 |
pam-fi |
1.1 |
} |
| 521 |
|
|
if(tr)tr->Delete(); |
| 522 |
|
|
} |
| 523 |
|
|
|
| 524 |
pam-fi |
1.10 |
if(TrkParams::VerboseMode()){ |
| 525 |
|
|
for(Int_t iv=0; iv<NVIEW; iv++){ |
| 526 |
|
|
cout<<"view "<<setw(3)<<iv<<": "; |
| 527 |
|
|
for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv]; |
| 528 |
|
|
cout << endl; |
| 529 |
|
|
} |
| 530 |
|
|
} |
| 531 |
|
|
|
| 532 |
pam-fi |
1.1 |
if(calib)calib->Delete(); |
| 533 |
|
|
|
| 534 |
|
|
}; |
| 535 |
|
|
|
| 536 |
pam-fi |
1.3 |
// Bool_t TrkParams::CalibIsLoaded(UInt_t time){ |
| 537 |
|
|
|
| 538 |
|
|
// if( !calibload ) return false; |
| 539 |
|
|
|
| 540 |
|
|
// }; |
| 541 |
|
|
|
| 542 |
|
|
|
| 543 |
pam-fi |
1.1 |
/** |
| 544 |
pam-fi |
1.10 |
* \brief Static method to load calibration. |
| 545 |
|
|
* Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens after the method TrkParams::SetCalib(***) is called. |
| 546 |
pam-fi |
1.1 |
*/ |
| 547 |
|
|
Bool_t TrkParams::LoadCalib( ){ |
| 548 |
|
|
|
| 549 |
|
|
if( TrkParams::CalibIsLoaded() )return false; |
| 550 |
|
|
|
| 551 |
|
|
// ============================================================= |
| 552 |
|
|
// retrieve calibration file needed to reduce data |
| 553 |
|
|
// ============================================================= |
| 554 |
|
|
// if run OBT is > last calibration "expiration date" |
| 555 |
|
|
// - search for new calibration packet |
| 556 |
|
|
// - load calibration parameters (full + truncated) |
| 557 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode()){ |
| 558 |
|
|
cout << "--------------------------------------"<<endl; |
| 559 |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
| 560 |
|
|
cout << " Full pedestals for cluster finding:"; |
| 561 |
|
|
cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; |
| 562 |
|
|
} |
| 563 |
pam-fi |
1.1 |
FileStat_t t; |
| 564 |
|
|
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
| 565 |
|
|
|
| 566 |
pam-fi |
1.6 |
bool alreadyopened = false; |
| 567 |
|
|
TFile *f0_c=0; |
| 568 |
|
|
f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); |
| 569 |
|
|
if(f0_c)alreadyopened=true; |
| 570 |
|
|
else f0_c = new TFile(calibpathf); |
| 571 |
pam-fi |
1.1 |
if ( !f0_c ) return false; |
| 572 |
pam-fi |
1.6 |
|
| 573 |
|
|
if(TrkParams::VerboseMode()){ |
| 574 |
|
|
cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
| 575 |
|
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
| 576 |
|
|
cout << " - full+truncated parameters "<<endl; |
| 577 |
|
|
} |
| 578 |
pam-fi |
1.1 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 579 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl; |
| 580 |
pam-fi |
1.1 |
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 581 |
|
|
|
| 582 |
|
|
// ============================================================= |
| 583 |
|
|
// retrieve calibration file needed to uncompress data |
| 584 |
|
|
// ============================================================= |
| 585 |
|
|
// if the run was compressed using default calib |
| 586 |
|
|
// load truncated pedestals from default |
| 587 |
|
|
// otherwise reload them from on-line calibration |
| 588 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
| 589 |
pam-fi |
1.1 |
if( calib104 ){ |
| 590 |
|
|
|
| 591 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
| 592 |
pam-fi |
1.1 |
TrkParams::FillTCalibFrom(calibpatht); |
| 593 |
|
|
|
| 594 |
|
|
}else{ |
| 595 |
|
|
|
| 596 |
pam-fi |
1.6 |
// if ( !f0_c ) return false; |
| 597 |
|
|
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
| 598 |
|
|
// TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
| 599 |
pam-fi |
1.1 |
}; |
| 600 |
pam-fi |
1.6 |
if(!alreadyopened)f0_c->Close(); |
| 601 |
|
|
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
| 602 |
pam-fi |
1.1 |
|
| 603 |
|
|
calibload = kTRUE; |
| 604 |
|
|
return true; |
| 605 |
|
|
}; |
| 606 |
|
|
|
| 607 |
|
|
Int_t TrkParams::GetIndex( UInt_t type ){ |
| 608 |
|
|
Int_t index = -1; |
| 609 |
|
|
for (Int_t i=0; i< NTYPES; i++)if( type == trkparamtype[i] )index=i; |
| 610 |
|
|
return index; |
| 611 |
|
|
}; |
| 612 |
|
|
|
| 613 |
|
|
/** |
| 614 |
|
|
* Set tracker parameters proper for a run querying the DB. |
| 615 |
|
|
* @param glrun Input run info |
| 616 |
|
|
* @param dbc Database |
| 617 |
|
|
* @param type Parameter type |
| 618 |
|
|
* @return FALSE if parameter set fails. |
| 619 |
|
|
* If glrun==NULL the last parameter entry from GL_PARAM table is set. |
| 620 |
|
|
* If dbc==NULL, try to open a connection taking DB-connection |
| 621 |
|
|
* parameters from PAMELA environment variables. |
| 622 |
|
|
*/ |
| 623 |
|
|
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
| 624 |
|
|
|
| 625 |
|
|
|
| 626 |
pam-fi |
1.6 |
UInt_t index = TrkParams::GetIndex( type ); |
| 627 |
|
|
if(index < 0)return false; |
| 628 |
|
|
|
| 629 |
pam-fi |
1.16 |
UInt_t runheadtime=0; |
| 630 |
|
|
UInt_t runid=0; |
| 631 |
|
|
// UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
| 632 |
|
|
if(glrun){ |
| 633 |
|
|
runheadtime = glrun->RUNHEADER_TIME; |
| 634 |
|
|
runid = glrun->ID; |
| 635 |
|
|
}else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl; |
| 636 |
|
|
|
| 637 |
|
|
// if(TrkParams::VerboseMode()) |
| 638 |
|
|
cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; |
| 639 |
|
|
|
| 640 |
|
|
|
| 641 |
pam-fi |
1.6 |
if( !TrkParams::IsLoaded(type) || |
| 642 |
pam-fi |
1.16 |
runheadtime < gl[index].FROM_TIME || |
| 643 |
|
|
runheadtime > gl[index].TO_TIME || |
| 644 |
pam-fi |
1.6 |
false ){ |
| 645 |
pam-fi |
1.1 |
|
| 646 |
pam-fi |
1.6 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
| 647 |
pam-fi |
1.1 |
|
| 648 |
pam-fi |
1.6 |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 649 |
|
|
TString host = "mysql://localhost/pamelaprod"; |
| 650 |
|
|
TString user = "anonymous"; |
| 651 |
|
|
TString psw = ""; |
| 652 |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 653 |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 654 |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 655 |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
| 656 |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
| 657 |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 658 |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 659 |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 660 |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 661 |
|
|
if(TrkParams::VerboseMode()){ |
| 662 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 663 |
|
|
cout<<"Connecting to DB"<<endl; |
| 664 |
|
|
cout<<"HOST "<<host<<endl; |
| 665 |
|
|
cout<<"USER "<<user<<endl; |
| 666 |
|
|
cout<<"PSW "<<psw<<endl; |
| 667 |
|
|
} |
| 668 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 669 |
|
|
if( !dbc )return false; |
| 670 |
|
|
if( !dbc->IsConnected() )return false; |
| 671 |
|
|
if(TrkParams::VerboseMode()){ |
| 672 |
|
|
cout << " ...done"<<endl; |
| 673 |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 674 |
|
|
} |
| 675 |
|
|
} |
| 676 |
pam-fi |
1.1 |
|
| 677 |
pam-fi |
1.6 |
GL_PARAM q4; |
| 678 |
|
|
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
| 679 |
pam-fi |
1.1 |
|
| 680 |
pam-fi |
1.6 |
gl[index] = q4; |
| 681 |
|
|
glpath[index] = q4.PATH+q4.NAME; |
| 682 |
|
|
glload[index] = false; |
| 683 |
pam-fi |
1.16 |
|
| 684 |
pam-fi |
1.6 |
return true; |
| 685 |
pam-fi |
1.1 |
|
| 686 |
pam-fi |
1.6 |
} |
| 687 |
|
|
return false; |
| 688 |
pam-fi |
1.1 |
|
| 689 |
|
|
}; |
| 690 |
|
|
/** |
| 691 |
pam-fi |
1.2 |
* Set tracker parameters proper for the run, from input. |
| 692 |
pam-fi |
1.1 |
* @param path Path to parameters directory |
| 693 |
|
|
* @param type Parameter type |
| 694 |
|
|
* @return FALSE if parameter set fails. |
| 695 |
|
|
*/ |
| 696 |
|
|
Bool_t TrkParams::Set( TString path , UInt_t type){ |
| 697 |
|
|
|
| 698 |
|
|
UInt_t index = TrkParams::GetIndex( type ); |
| 699 |
|
|
if(index < 0)return false; |
| 700 |
|
|
|
| 701 |
|
|
gl[index].TYPE= type; |
| 702 |
|
|
glpath[index] = path; |
| 703 |
pam-fi |
1.12 |
if(TrkParams::VerboseMode()) |
| 704 |
|
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
| 705 |
pam-fi |
1.1 |
glload[index] = false; |
| 706 |
|
|
|
| 707 |
|
|
// return TrkParams::Load(type); |
| 708 |
|
|
return true; |
| 709 |
|
|
|
| 710 |
|
|
}; |
| 711 |
|
|
|
| 712 |
|
|
/** |
| 713 |
|
|
* Set and load tracker parameters. |
| 714 |
|
|
* @param type Parameter type |
| 715 |
|
|
* If no path as been yet specified, it set a default path. |
| 716 |
|
|
* @return FALSE if parameter set fails. |
| 717 |
|
|
*/ |
| 718 |
|
|
Bool_t TrkParams::Set(UInt_t type){ |
| 719 |
|
|
|
| 720 |
|
|
|
| 721 |
pam-fi |
1.16 |
return Set(0,0,type); |
| 722 |
|
|
|
| 723 |
|
|
// UInt_t index = TrkParams::GetIndex( type ); |
| 724 |
|
|
// if(index < 0)return false; |
| 725 |
|
|
|
| 726 |
|
|
// gl[index].TYPE= type; |
| 727 |
|
|
// glload[index] = false; |
| 728 |
pam-fi |
1.1 |
|
| 729 |
pam-fi |
1.16 |
// // ----------------------------------------- |
| 730 |
|
|
// // check if enviroment variables are defined |
| 731 |
|
|
// // ----------------------------------------- |
| 732 |
|
|
// glpath[index] = gSystem->Getenv("PAM_CALIB"); |
| 733 |
pam-fi |
1.1 |
|
| 734 |
pam-fi |
1.16 |
// if( !glpath[index].IsNull() ){ |
| 735 |
pam-fi |
1.1 |
|
| 736 |
pam-fi |
1.16 |
// switch(type){ |
| 737 |
|
|
// case 1: |
| 738 |
|
|
// glpath[index].Append("/trk-param/field_param-0/"); |
| 739 |
|
|
// break; |
| 740 |
|
|
// case 2: |
| 741 |
|
|
// glpath[index].Append("/trk-param/mip_param-0/"); |
| 742 |
|
|
// break; |
| 743 |
|
|
// case 3: |
| 744 |
|
|
// glpath[index].Append("/trk-param/charge_param-1/"); |
| 745 |
|
|
// break; |
| 746 |
|
|
// case 4: |
| 747 |
|
|
// glpath[index].Append("/trk-param/eta_param-2/"); |
| 748 |
|
|
// break; |
| 749 |
|
|
// case 5: |
| 750 |
|
|
// glpath[index].Append("/trk-param/align_param-Q.A/"); |
| 751 |
|
|
// break; |
| 752 |
|
|
// case 6: |
| 753 |
|
|
// glpath[index].Append("/trk-param/mask_param-1/"); |
| 754 |
|
|
// break; |
| 755 |
|
|
// case 7: |
| 756 |
|
|
// glpath[index].Append("/trk-param/default_calib/"); |
| 757 |
|
|
// break; |
| 758 |
|
|
// } |
| 759 |
pam-fi |
1.1 |
|
| 760 |
pam-fi |
1.16 |
// }else{ |
| 761 |
|
|
// cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
| 762 |
|
|
// return false; |
| 763 |
pam-fi |
1.1 |
|
| 764 |
pam-fi |
1.16 |
// } |
| 765 |
pam-fi |
1.1 |
|
| 766 |
pam-fi |
1.16 |
// // if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >>"<<endl; |
| 767 |
|
|
// cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >> **WARNING** does not use DB info !!!!"<<endl; |
| 768 |
|
|
|
| 769 |
|
|
// // return TrkParams::Load(type); |
| 770 |
|
|
// return true; |
| 771 |
pam-fi |
1.1 |
|
| 772 |
|
|
}; |
| 773 |
|
|
/** |
| 774 |
|
|
* Set tracker parameters. |
| 775 |
|
|
* If no path as been yet specified, try to read from DB |
| 776 |
|
|
* otherwise it set a default path. |
| 777 |
|
|
* @return FALSE if parameter set fails. |
| 778 |
|
|
*/ |
| 779 |
|
|
Bool_t TrkParams::Set( ){ |
| 780 |
|
|
|
| 781 |
pam-fi |
1.16 |
// Bool_t connected = false; |
| 782 |
pam-fi |
1.6 |
// cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
| 783 |
pam-fi |
1.16 |
// TString host = "mysql://localhost/pamelaprod"; |
| 784 |
|
|
// TString user = "anonymous"; |
| 785 |
|
|
// TString psw = ""; |
| 786 |
|
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 787 |
|
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 788 |
|
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 789 |
|
|
// if ( !pamdbhost ) pamdbhost = ""; |
| 790 |
|
|
// if ( !pamdbuser ) pamdbuser = ""; |
| 791 |
|
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
| 792 |
|
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 793 |
|
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 794 |
|
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 795 |
|
|
// if(TrkParams::VerboseMode()){ |
| 796 |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 797 |
|
|
// cout<<"Connecting to DB"<<endl; |
| 798 |
|
|
// cout<<"HOST "<<host<<endl; |
| 799 |
|
|
// cout<<"USER "<<user<<endl; |
| 800 |
|
|
// cout<<"PSW "<<psw<<endl; |
| 801 |
|
|
// } |
| 802 |
|
|
// TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 803 |
|
|
// if( dbc || dbc->IsConnected() )connected = true; |
| 804 |
|
|
// else cout << " >> DB connection FAILED!!!"<<endl; |
| 805 |
|
|
// if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 806 |
pam-fi |
1.1 |
|
| 807 |
pam-fi |
1.16 |
// if(connected){ |
| 808 |
|
|
// if ( !TrkParams::Set(0,dbc) )return false; |
| 809 |
|
|
// dbc->Close(); |
| 810 |
|
|
// }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
| 811 |
|
|
|
| 812 |
|
|
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
| 813 |
pam-fi |
1.3 |
|
| 814 |
|
|
return true; |
| 815 |
pam-fi |
1.1 |
} |
| 816 |
|
|
|
| 817 |
|
|
/** |
| 818 |
|
|
* Load tracker parameter, if not already loaded. |
| 819 |
|
|
* @param type Parameter type |
| 820 |
|
|
* ( Any call to TrkParams::Set(...) forces reloading ) |
| 821 |
|
|
*/ |
| 822 |
|
|
Bool_t TrkParams::Load(UInt_t type){ |
| 823 |
|
|
|
| 824 |
|
|
Int_t index = TrkParams::GetIndex( type ); |
| 825 |
|
|
if( index<0 )return false; |
| 826 |
|
|
if( glload[index] )return true; |
| 827 |
|
|
|
| 828 |
|
|
if( glpath[index].IsNull() )TrkParams::Set(type); |
| 829 |
|
|
|
| 830 |
|
|
switch( type ){ |
| 831 |
|
|
//------------------------------------------ |
| 832 |
|
|
case 1: |
| 833 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
| 834 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 835 |
|
|
path_.pathlen = glpath[index].Length(); |
| 836 |
|
|
path_.error = 0; |
| 837 |
|
|
readb_(); |
| 838 |
|
|
if(path_.error) return false; |
| 839 |
|
|
glload[index]=true; |
| 840 |
|
|
break; |
| 841 |
|
|
//------------------------------------------ |
| 842 |
|
|
case 2: |
| 843 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl; |
| 844 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 845 |
|
|
path_.pathlen = glpath[index].Length(); |
| 846 |
|
|
path_.error = 0; |
| 847 |
|
|
readmipparam_(); |
| 848 |
|
|
if(path_.error) return false; |
| 849 |
|
|
glload[index]=true; |
| 850 |
|
|
break; |
| 851 |
|
|
//------------------------------------------ |
| 852 |
|
|
case 3: |
| 853 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
| 854 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 855 |
|
|
path_.pathlen = glpath[index].Length(); |
| 856 |
|
|
path_.error = 0; |
| 857 |
|
|
readchargeparam_(); |
| 858 |
|
|
if(path_.error) return false; |
| 859 |
|
|
glload[index]=true; |
| 860 |
|
|
break; |
| 861 |
|
|
//------------------------------------------ |
| 862 |
|
|
case 4: |
| 863 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
| 864 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 865 |
|
|
path_.pathlen = glpath[index].Length(); |
| 866 |
|
|
path_.error = 0; |
| 867 |
|
|
readetaparam_(); |
| 868 |
|
|
if(path_.error) return false; |
| 869 |
|
|
glload[index]=true; |
| 870 |
|
|
break; |
| 871 |
|
|
//------------------------------------------ |
| 872 |
|
|
case 5: |
| 873 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
| 874 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 875 |
|
|
path_.pathlen = glpath[index].Length(); |
| 876 |
|
|
path_.error = 0; |
| 877 |
|
|
readalignparam_(); |
| 878 |
|
|
if(path_.error) return false; |
| 879 |
|
|
glload[index]=true; |
| 880 |
|
|
break; |
| 881 |
|
|
//------------------------------------------ |
| 882 |
|
|
case 6: |
| 883 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
| 884 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 885 |
|
|
path_.pathlen = glpath[index].Length(); |
| 886 |
|
|
path_.error = 0; |
| 887 |
|
|
readvkmask_(); |
| 888 |
|
|
if(path_.error) return false; |
| 889 |
|
|
glload[index]=true; |
| 890 |
|
|
break; |
| 891 |
|
|
//------------------------------------------ |
| 892 |
|
|
case 7: |
| 893 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
| 894 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
| 895 |
|
|
path_.pathlen = glpath[index].Length(); |
| 896 |
|
|
path_.error = 0; |
| 897 |
|
|
// fillpedsigfromdefault_(); |
| 898 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
| 899 |
pam-fi |
1.1 |
if(path_.error) return false; |
| 900 |
|
|
glload[index]=true; |
| 901 |
|
|
break; |
| 902 |
|
|
default: |
| 903 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl; |
| 904 |
pam-fi |
1.1 |
return false; |
| 905 |
|
|
}; |
| 906 |
|
|
|
| 907 |
|
|
return true; |
| 908 |
|
|
} |
| 909 |
|
|
|
| 910 |
|
|
Bool_t TrkParams::Load( ){ |
| 911 |
|
|
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )if( !TrkParams::Load(trkparamtype[i]) )return false; |
| 912 |
|
|
return true; |
| 913 |
|
|
}; |
| 914 |
|
|
Bool_t TrkParams::IsLoaded( ){ |
| 915 |
|
|
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false; |
| 916 |
|
|
return true; |
| 917 |
|
|
}; |
| 918 |
|
|
|
| 919 |
pam-fi |
1.8 |
|
| 920 |
|
|
/** |
| 921 |
|
|
* Get BY (kGauss) |
| 922 |
|
|
* @param v (x,y,z) coordinates in cm |
| 923 |
|
|
*/ |
| 924 |
|
|
float TrkParams::GetBX(float* v){ |
| 925 |
|
|
TrkParams::Load(1); |
| 926 |
|
|
if( !TrkParams::IsLoaded(1) )return 0.; |
| 927 |
|
|
float b[3]; |
| 928 |
|
|
gufld_(v,b); |
| 929 |
|
|
return b[0]/10.; |
| 930 |
|
|
} |
| 931 |
|
|
/** |
| 932 |
|
|
* Get BY (kGauss) |
| 933 |
|
|
* @param v (x,y,z) coordinates in cm |
| 934 |
|
|
*/ |
| 935 |
|
|
float TrkParams::GetBY(float* v){ |
| 936 |
|
|
TrkParams::Load(1); |
| 937 |
|
|
if( !TrkParams::IsLoaded(1) )return 0.; |
| 938 |
|
|
float b[3]; |
| 939 |
|
|
gufld_(v,b); |
| 940 |
|
|
return b[1]/10.; |
| 941 |
|
|
} |
| 942 |
|
|
/** |
| 943 |
|
|
* Get BY (kGauss) |
| 944 |
|
|
* @param v (x,y,z) coordinates in cm |
| 945 |
|
|
*/ |
| 946 |
|
|
float TrkParams::GetBZ(float* v){ |
| 947 |
|
|
TrkParams::Load(1); |
| 948 |
|
|
if( !TrkParams::IsLoaded(1) )return 0.; |
| 949 |
|
|
float b[3]; |
| 950 |
|
|
gufld_(v,b); |
| 951 |
|
|
return b[2]/10.; |
| 952 |
|
|
} |
| 953 |
|
|
|
| 954 |
pam-fi |
1.9 |
|
| 955 |
|
|
|
| 956 |
pam-fi |
1.8 |
/** |
| 957 |
|
|
* \brief Set tracking mode (0=standard. 1=???) |
| 958 |
|
|
*/ |
| 959 |
|
|
void TrkParams::SetTrackingMode(int trackmode) { |
| 960 |
|
|
init__mini_trackmode = trackmode; |
| 961 |
|
|
SetTrackingMode(); |
| 962 |
|
|
}; |
| 963 |
|
|
/** |
| 964 |
|
|
* \brief Set fit-precision factor (typical value fact=100.) |
| 965 |
|
|
*/ |
| 966 |
|
|
void TrkParams::SetPrecisionFactor(double fact){ |
| 967 |
|
|
init__mini_fact = fact; |
| 968 |
|
|
SetPrecisionFactor(); |
| 969 |
|
|
}; |
| 970 |
|
|
/** |
| 971 |
|
|
* \brief Set minimum number of step in track fitting |
| 972 |
|
|
*/ |
| 973 |
|
|
void TrkParams::SetStepMin(int istepmin){ |
| 974 |
|
|
init__mini_istepmin = istepmin; |
| 975 |
|
|
SetStepMin(); |
| 976 |
|
|
}; |
| 977 |
|
|
|
| 978 |
|
|
/** |
| 979 |
pam-fi |
1.13 |
* Fill F77 commons with PFA settings |
| 980 |
|
|
*/ |
| 981 |
|
|
void TrkParams::SetPFA(){ |
| 982 |
|
|
sw_.pfaid = init__pfa; |
| 983 |
|
|
for(int i=0; i<6; i++){ |
| 984 |
|
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
| 985 |
|
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
| 986 |
|
|
} |
| 987 |
|
|
}; |
| 988 |
|
|
/** |
| 989 |
pam-fi |
1.8 |
* \brief Set p.f.a. |
| 990 |
|
|
* |
| 991 |
|
|
* Implemented algorythms: |
| 992 |
pam-fi |
1.11 |
* 0 ETA |
| 993 |
pam-fi |
1.8 |
* 1 --- |
| 994 |
|
|
* 2 ETA2 |
| 995 |
|
|
* 3 ETA3 |
| 996 |
|
|
* 4 ETA4 |
| 997 |
pam-fi |
1.11 |
* 5 ETAL ==> ETA+LANDI |
| 998 |
pam-fi |
1.8 |
* 10 COG |
| 999 |
|
|
* 11 COG1 |
| 1000 |
|
|
* 12 COG2 |
| 1001 |
|
|
* 13 COG3 |
| 1002 |
|
|
* 14 COG4 |
| 1003 |
|
|
*/ |
| 1004 |
|
|
void TrkParams::SetPFA(int pfaid){ |
| 1005 |
|
|
init__pfa = pfaid; |
| 1006 |
pam-fi |
1.9 |
SetPFA(); |
| 1007 |
pam-fi |
1.8 |
}; |
| 1008 |
pam-fi |
1.9 |
/** |
| 1009 |
pam-fi |
1.13 |
* \brief Set p.f.a. angular intervals |
| 1010 |
|
|
* |
| 1011 |
|
|
* This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4 |
| 1012 |
|
|
* algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)). |
| 1013 |
|
|
* @param v Pointer to a vector of 12 components, which represent the |
| 1014 |
|
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
| 1015 |
|
|
* |
| 1016 |
|
|
*/ |
| 1017 |
|
|
void TrkParams::SetPFA(float *v){ |
| 1018 |
|
|
for(int i=0; i<6; i++){ |
| 1019 |
|
|
init__pfa_e234ax[i] = v[i]; |
| 1020 |
|
|
init__pfa_e234ay[i] = v[i+6]; |
| 1021 |
|
|
} |
| 1022 |
|
|
SetPFA(); |
| 1023 |
|
|
}; |
| 1024 |
pam-fi |
1.14 |
|
| 1025 |
|
|
|
| 1026 |
pam-fi |
1.13 |
/** |
| 1027 |
pam-fi |
1.9 |
* \brief Get spatial resolution. |
| 1028 |
|
|
* |
| 1029 |
|
|
* Method to retrieve the spatial resolution associated with the |
| 1030 |
|
|
* adopted p.f.a. |
| 1031 |
|
|
* @param view Tracker view (1-12) |
| 1032 |
|
|
* @param angle Track projected angle |
| 1033 |
|
|
* |
| 1034 |
|
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
| 1035 |
|
|
* |
| 1036 |
|
|
* TrkParams::SetPFA(0) // ETA |
| 1037 |
|
|
* |
| 1038 |
|
|
*/ |
| 1039 |
|
|
float TrkParams::GetResolution(int view, float angle){ |
| 1040 |
|
|
float res = 1000; |
| 1041 |
|
|
if( init__pfa == 0 )res = riseta_(&view,&angle); |
| 1042 |
|
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
| 1043 |
|
|
return res; |
| 1044 |
|
|
} |
| 1045 |
pam-fi |
1.8 |
|
| 1046 |
|
|
|
| 1047 |
|
|
|
| 1048 |
pam-fi |
1.14 |
|
| 1049 |
pam-fi |
1.1 |
ClassImp(TrkParams); |