1 |
|
|
2 |
/** |
/** |
3 |
* \file TrkParams.cpp |
* \file TrkParams.cpp |
4 |
* \author Elena Vannuccini |
* \author Elena Vannuccini |
18 |
TString TrkParams::calibpathf = ""; |
TString TrkParams::calibpathf = ""; |
19 |
Bool_t TrkParams::calib104 = 0; |
Bool_t TrkParams::calib104 = 0; |
20 |
Bool_t TrkParams::calibload = false; |
Bool_t TrkParams::calibload = false; |
21 |
|
TrkCalib* TrkParams::calib1 = 0; |
22 |
|
TrkCalib* TrkParams::calib2 = 0; |
23 |
// ------------------------- |
// ------------------------- |
24 |
// PARAMETERS loaded from DB |
// PARAMETERS loaded from DB |
25 |
// ------------------------- |
// ------------------------- |
27 |
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()}; |
28 |
TString TrkParams::glpath[] = {"","","","","","",""}; |
TString TrkParams::glpath[] = {"","","","","","",""}; |
29 |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
|
cDbg TrkParams::dbg_mode = {0,0,0}; |
|
30 |
// ---------------- |
// ---------------- |
31 |
// other parameters |
// other parameters |
32 |
// ---------------- |
// ---------------- |
33 |
int TrkParams::init__pfa = 14;//COG4 |
cDbg TrkParams::init__dbg_mode = {0,0,0}; |
34 |
|
//int TrkParams::init__pfa = 14;//COG4 |
35 |
|
int TrkParams::init__pfa = 5;//ETAL |
36 |
int TrkParams::init__mini_trackmode = 0; |
int TrkParams::init__mini_trackmode = 0; |
37 |
int TrkParams::init__mini_istepmin = 3; |
int TrkParams::init__mini_istepmin = 5; //3; |
38 |
double TrkParams::init__mini_fact = 100.; |
double TrkParams::init__mini_fact = 1.e4; //100.; |
39 |
|
float TrkParams::init__pfa_e234ax[] = {0.,10.,10.,15.,15.,90.}; |
40 |
|
float TrkParams::init__pfa_e234ay[] = {0.,20.,90.,90.,90.,90.}; |
41 |
|
double TrkParams::init__deltab_0 = 0.; |
42 |
|
double TrkParams::init__deltab_1 = 0.; |
43 |
|
double TrkParams::init__dlt = 1.e-5; |
44 |
|
// ------------------------------------------ |
45 |
|
// nominal z-coordinates to define acceptance |
46 |
|
// ------------------------------------------ |
47 |
|
int TrkParams::nGF = NGF; |
48 |
|
float TrkParams::zGF[] = {+53.74,+53.04,+23.94,+23.44,+22.29,+21.83,+13.39,+4.49,-4.41,-13.31,-21.83,-22.22,-23.49,-24.34}; |
49 |
|
float TrkParams::xGF_min[] = {-20.40,-20.40,-9.00,-9.00,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-9.00,-9.00}; |
50 |
|
float TrkParams::xGF_max[] = {+20.40,+20.40,+9.00,+9.00,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+9.00,+9.00}; |
51 |
|
// float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-7.25,-7.25,-7.25,-7.25,-6.57,-6.75,-7.50,-7.50}; |
52 |
|
// float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.75,+6.75,+6.75,+6.75,+6.57,+7.25,+7.50,+7.50}; |
53 |
|
// per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa |
54 |
|
float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-6.57,-6.57,-6.57,-6.57,-6.57,-6.75,-7.50,-7.50}; |
55 |
|
float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.57,+6.57,+6.57,+6.57,+6.57,+7.25,+7.50,+7.50}; |
56 |
|
TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"}; |
57 |
|
|
58 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
59 |
|
|
73 |
ret1=(float)ret; |
ret1=(float)ret; |
74 |
return ret1; |
return ret1; |
75 |
} |
} |
76 |
|
|
77 |
|
/** |
78 |
|
* Static method to open a DB connection. |
79 |
|
* HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, |
80 |
|
* $PAM_DBUSER and $PAM_DBPSW |
81 |
|
* NB! The method create a new connection, which has to be closed by the user. |
82 |
|
*/ |
83 |
|
TSQLServer* TrkParams::SetDBConnection(){ |
84 |
|
|
85 |
|
TString host = "mysql://localhost/pamelaprod"; |
86 |
|
TString user = "anonymous"; |
87 |
|
TString psw = ""; |
88 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
89 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
90 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
91 |
|
if ( !pamdbhost ) pamdbhost = ""; |
92 |
|
if ( !pamdbuser ) pamdbuser = ""; |
93 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
94 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
95 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
96 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
97 |
|
if(TrkParams::DebugMode()){ |
98 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
99 |
|
cout<<"TrkParams::SetDBConnection() >> Connecting to DB"<<endl; |
100 |
|
cout<<"HOST "<<host<<endl; |
101 |
|
cout<<"USER "<<user<<endl; |
102 |
|
cout<<"PSW "<<psw<<endl; |
103 |
|
} |
104 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
105 |
|
if( !dbc )return NULL; |
106 |
|
if( !dbc->IsConnected() )return NULL; |
107 |
|
stringstream myquery; // EMILIANO |
108 |
|
myquery.str(""); // EMILIANO |
109 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
110 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
111 |
|
if(TrkParams::DebugMode()){ |
112 |
|
cout << " ...done"<<endl; |
113 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
114 |
|
} |
115 |
|
|
116 |
|
return dbc; |
117 |
|
} |
118 |
/** |
/** |
119 |
* \brief Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
120 |
|
|
134 |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
135 |
false ){ |
false ){ |
136 |
|
|
|
// cout <<">>> isloaded? "<< CalibIsLoaded() << endl; |
|
|
// cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl; |
|
|
// cout <<">>> 104 loaded? "<< calib104 <<endl; |
|
|
// cout <<">>> from time "<< calib.FROM_TIME<<endl; |
|
|
// cout <<">>> to time "<< calib.TO_TIME<<endl; |
|
|
// if( !dbc || (dbc && !dbc->IsConnected()) ){ |
|
|
|
|
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
|
|
// 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; |
|
|
// if(TrkParams::VerboseMode()){ |
|
|
// 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; |
|
|
// if(TrkParams::VerboseMode()){ |
|
|
// cout << " ...done"<<endl; |
|
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
// } |
|
|
// } |
|
137 |
|
|
138 |
GL_TRK_CALIB q2; |
GL_TRK_CALIB q2; |
139 |
GL_ROOT q3; |
GL_ROOT q3; |
140 |
GL_PARAM q4; |
GL_PARAM q4; |
141 |
|
|
142 |
|
|
143 |
|
bool LOCAL_CONNECTION = false; |
144 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
145 |
|
|
146 |
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
147 |
|
dbc = TrkParams::SetDBConnection(); |
148 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
149 |
|
|
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
if(TrkParams::VerboseMode()){ |
if(TrkParams::VerboseMode()){ |
154 |
cout << "--------------------------------------"<<endl; |
cout << "--------------------------------------"<<endl; |
175 |
calibpatht = q4.PATH + q4.NAME; |
calibpatht = q4.PATH + q4.NAME; |
176 |
} |
} |
177 |
|
|
178 |
|
if(LOCAL_CONNECTION){ |
179 |
|
delete dbc; |
180 |
|
dbc->Close(); |
181 |
|
if(TrkParams::DebugMode()){ |
182 |
|
cout << " DB connection closed."<<endl; |
183 |
|
} |
184 |
|
} |
185 |
|
|
186 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
187 |
return true; |
return true; |
338 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
339 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
340 |
|
|
341 |
CalibTrk1Event *calibdata1 = 0; |
if(!calib1)calib1 = new TrkCalib(); |
342 |
CalibTrk2Event *calibdata2 = 0; |
if(!calib2)calib2 = new TrkCalib(); |
343 |
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
// calibx->Set(calibdata1); |
344 |
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
// caliby->Set(calibdata2); |
345 |
|
|
346 |
|
// CalibTrk1Event *calibdata1 = 0; |
347 |
|
// CalibTrk2Event *calibdata2 = 0; |
348 |
|
// tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
349 |
|
// tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
350 |
|
tr1->SetBranchAddress("CalibTrk1",calib1->GetPointerTo()); |
351 |
|
tr2->SetBranchAddress("CalibTrk2",calib2->GetPointerTo()); |
352 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
353 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
354 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
355 |
|
|
356 |
|
|
357 |
// --- TEST TEST TEST TEST --- // |
// --- TEST TEST TEST TEST --- // |
358 |
// TrkParams::ValidateTrkCalib(calibdata1); |
// TrkParams::ValidateTrkCalib(calib1->Get()); |
359 |
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calib2->Get()); |
360 |
|
|
361 |
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
UInt_t test1 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib1->Get())); |
362 |
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib2->Get())); |
363 |
if( !test1 || !test2 ){ |
if( !test1 || !test2 ){ |
364 |
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
// if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
365 |
TrkParams::calib.VALIDATION = 0; |
TrkParams::calib.VALIDATION = 0; |
366 |
} |
} |
367 |
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
// if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
368 |
|
|
369 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
370 |
dspn1=calibdata1->DSPnumber[i]-1; |
|
371 |
dspn2=calibdata2->DSPnumber[i]-1; |
|
372 |
|
dspn1=calib1->Get()->DSPnumber[i]-1; |
373 |
|
dspn2=calib2->Get()->DSPnumber[i]-1; |
374 |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
375 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
376 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
377 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
378 |
if(dspn1>=0 && dspn1<12){ |
if(dspn1>=0 && dspn1<12){ |
379 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calib1->Get()->DSPped_par[i][ii]; |
380 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calib1->Get()->DSPped_par[i][ii]); |
381 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma[jj][j][dspn1]=calib1->Get()->DSPsig_par[i][ii]; |
382 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->sigma_t[jj][j][dspn1]=anint(calib1->Get()->DSPsig_par[i][ii]); |
383 |
if(calibdata1->DSPbad_par[i][ii]==0) |
if(calib1->Get()->DSPbad_par[i][ii]==0) |
384 |
ca->bad[jj][j][dspn1]=1; |
ca->bad[jj][j][dspn1]=1; |
385 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
else if(calib1->Get()->DSPbad_par[i][ii]==1) |
386 |
ca->bad[jj][j][dspn1]=0; |
ca->bad[jj][j][dspn1]=0; |
387 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
388 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
389 |
} |
} |
390 |
|
|
391 |
if(dspn2>=0 && dspn2<12){ |
if(dspn2>=0 && dspn2<12){ |
392 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn2]=calib2->Get()->DSPped_par[i][ii]; |
393 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn2]=aint(calib2->Get()->DSPped_par[i][ii]); |
394 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
ca->sigma[jj][j][dspn2]=calib2->Get()->DSPsig_par[i][ii]; |
395 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
ca->sigma_t[jj][j][dspn2]=anint(calib2->Get()->DSPsig_par[i][ii]); |
396 |
if(calibdata2->DSPbad_par[i][ii]==0) |
if(calib2->Get()->DSPbad_par[i][ii]==0) |
397 |
ca->bad[jj][j][dspn2]=1; |
ca->bad[jj][j][dspn2]=1; |
398 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
else if(calib2->Get()->DSPbad_par[i][ii]==1) |
399 |
ca->bad[jj][j][dspn2]=0; |
ca->bad[jj][j][dspn2]=0; |
400 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
401 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
409 |
/** |
/** |
410 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
411 |
*/ |
*/ |
412 |
void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
// void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
413 |
|
|
414 |
cTrkCalib *ca = &pedsigbad_; |
// cTrkCalib *ca = &pedsigbad_; |
415 |
// ca->Reset(); |
// // ca->Reset(); |
416 |
|
|
417 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
// TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
418 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
// TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
419 |
|
|
420 |
CalibTrk1Event *calibdata1 = 0; |
// CalibTrk1Event *calibdata1 = 0; |
421 |
CalibTrk2Event *calibdata2 = 0; |
// CalibTrk2Event *calibdata2 = 0; |
422 |
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
// tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
423 |
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
// tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
424 |
tr1->GetEntry(ev_reg1); |
// tr1->GetEntry(ev_reg1); |
425 |
tr2->GetEntry(ev_reg2); |
// tr2->GetEntry(ev_reg2); |
426 |
Int_t dspn1(0),dspn2(0); |
// Int_t dspn1(0),dspn2(0); |
427 |
|
|
428 |
// --- TEST TEST TEST TEST --- // |
// // --- TEST TEST TEST TEST --- // |
429 |
// TrkParams::ValidateTrkCalib(calibdata1); |
// // TrkParams::ValidateTrkCalib(calibdata1); |
430 |
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
// // TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
431 |
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
// UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
432 |
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
// UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
433 |
if( !test1 || !test2 ){ |
// if( !test1 || !test2 ){ |
434 |
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
// if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
435 |
TrkParams::calib.VALIDATION = 0; |
// TrkParams::calib.VALIDATION = 0; |
436 |
} |
// } |
437 |
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
// if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
438 |
|
|
439 |
for(Int_t i=0;i<6;i++){ |
// for(Int_t i=0;i<6;i++){ |
440 |
dspn1=calibdata1->DSPnumber[i]-1; |
// dspn1=calibdata1->DSPnumber[i]-1; |
441 |
dspn2=calibdata2->DSPnumber[i]-1; |
// dspn2=calibdata2->DSPnumber[i]-1; |
442 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// /* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
443 |
for(Int_t ii=0;ii<3072;ii++){ |
// for(Int_t ii=0;ii<3072;ii++){ |
444 |
Int_t j=(ii/128); |
// Int_t j=(ii/128); |
445 |
Int_t jj=ii-j*128; |
// Int_t jj=ii-j*128; |
446 |
if(dspn1>=0 && dspn1<12){ |
// if(dspn1>=0 && dspn1<12){ |
447 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
// ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
448 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
// ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
449 |
if(calibdata1->DSPbad_par[i][ii]==0) |
// if(calibdata1->DSPbad_par[i][ii]==0) |
450 |
ca->bad[jj][j][dspn1]=1; |
// ca->bad[jj][j][dspn1]=1; |
451 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
// else if(calibdata1->DSPbad_par[i][ii]==1) |
452 |
ca->bad[jj][j][dspn1]=0; |
// ca->bad[jj][j][dspn1]=0; |
453 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
// // cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
454 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// // cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
455 |
} |
// } |
456 |
if(dspn2>=0 && dspn2<12){ |
// if(dspn2>=0 && dspn2<12){ |
457 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
// ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
458 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
// ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
459 |
if(calibdata2->DSPbad_par[i][ii]==0) |
// if(calibdata2->DSPbad_par[i][ii]==0) |
460 |
ca->bad[jj][j][dspn2]=1; |
// ca->bad[jj][j][dspn2]=1; |
461 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// else if(calibdata2->DSPbad_par[i][ii]==1) |
462 |
ca->bad[jj][j][dspn2]=0; |
// ca->bad[jj][j][dspn2]=0; |
463 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// // cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
464 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
// // cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
465 |
} |
// } |
466 |
}; |
// }; |
467 |
}; |
// }; |
468 |
|
|
469 |
tr1->Delete(); |
// tr1->Delete(); |
470 |
tr2->Delete(); |
// tr2->Delete(); |
471 |
}; |
// }; |
472 |
/** |
/** |
473 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
474 |
*/ |
*/ |
475 |
void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
// void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
476 |
|
|
477 |
cTrkCalib *ca = &pedsigbad_; |
// cTrkCalib *ca = &pedsigbad_; |
478 |
// ca->Reset(); |
// // ca->Reset(); |
479 |
|
|
480 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
// TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
481 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
// TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
482 |
|
|
483 |
CalibTrk1Event *calibdata1 = 0; |
// CalibTrk1Event *calibdata1 = 0; |
484 |
CalibTrk2Event *calibdata2 = 0; |
// CalibTrk2Event *calibdata2 = 0; |
485 |
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
// tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
486 |
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
// tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
487 |
tr1->GetEntry(ev_reg1); |
// tr1->GetEntry(ev_reg1); |
488 |
tr2->GetEntry(ev_reg2); |
// tr2->GetEntry(ev_reg2); |
489 |
Int_t dspn1(0),dspn2(0); |
// Int_t dspn1(0),dspn2(0); |
490 |
|
|
491 |
// --- TEST TEST TEST TEST --- // |
// // --- TEST TEST TEST TEST --- // |
492 |
// TrkParams::ValidateTrkCalib(calibdata1); |
// // TrkParams::ValidateTrkCalib(calibdata1); |
493 |
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
// // TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
494 |
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
// UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
495 |
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
// UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
496 |
if( !test1 || !test2 ){ |
// if( !test1 || !test2 ){ |
497 |
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
// if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
498 |
TrkParams::calib.VALIDATION = 0; |
// TrkParams::calib.VALIDATION = 0; |
499 |
} |
// } |
500 |
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
// if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
501 |
|
|
502 |
for(Int_t i=0;i<6;i++){ |
// for(Int_t i=0;i<6;i++){ |
503 |
dspn1=calibdata1->DSPnumber[i]-1; |
// dspn1=calibdata1->DSPnumber[i]-1; |
504 |
dspn2=calibdata2->DSPnumber[i]-1; |
// dspn2=calibdata2->DSPnumber[i]-1; |
505 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// /* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
506 |
for(Int_t ii=0;ii<3072;ii++){ |
// for(Int_t ii=0;ii<3072;ii++){ |
507 |
Int_t j=(ii/128); |
// Int_t j=(ii/128); |
508 |
Int_t jj=ii-j*128; |
// Int_t jj=ii-j*128; |
509 |
if(dspn1>=0 && dspn1<12){ |
// if(dspn1>=0 && dspn1<12){ |
510 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
// ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
511 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
// ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
512 |
} |
// } |
513 |
if(dspn2>=0 && dspn2<12){ |
// if(dspn2>=0 && dspn2<12){ |
514 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
// ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
515 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
// ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
516 |
} |
// } |
517 |
}; |
// }; |
518 |
}; |
// }; |
519 |
|
|
520 |
tr1->Delete(); |
// tr1->Delete(); |
521 |
tr2->Delete(); |
// tr2->Delete(); |
522 |
}; |
// }; |
523 |
/** |
/** |
524 |
* Method to fill the tracker calibration-parameter struct from default calibration |
* Method to fill the tracker calibration-parameter struct from default calibration |
525 |
*/ |
*/ |
630 |
cout << " - full+truncated parameters "<<endl; |
cout << " - full+truncated parameters "<<endl; |
631 |
} |
} |
632 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
633 |
if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl; |
if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl; |
634 |
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
635 |
|
|
636 |
// ============================================================= |
// ============================================================= |
670 |
* @param dbc Database |
* @param dbc Database |
671 |
* @param type Parameter type |
* @param type Parameter type |
672 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
673 |
* If glrun==NULL the last parameter entry from GL_PARAM table is set. |
* If glrun==NULL the first parameter entry from GL_PARAM table is set. |
674 |
* If dbc==NULL, try to open a connection taking DB-connection |
* If dbc==NULL, try to open a connection taking DB-connection |
675 |
* parameters from PAMELA environment variables. |
* parameters from PAMELA environment variables. |
676 |
*/ |
*/ |
680 |
UInt_t index = TrkParams::GetIndex( type ); |
UInt_t index = TrkParams::GetIndex( type ); |
681 |
if(index < 0)return false; |
if(index < 0)return false; |
682 |
|
|
683 |
|
|
684 |
|
UInt_t runheadtime=1; |
685 |
|
UInt_t runid=0; |
686 |
|
// UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
687 |
|
if(glrun){ |
688 |
|
runheadtime = glrun->RUNHEADER_TIME; |
689 |
|
runid = glrun->ID; |
690 |
|
}else |
691 |
|
cout <<"Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ) >> GL_RUN==NULL -- taking first entry (**WARNING** check that this is ok!! )"<<endl; |
692 |
|
|
693 |
|
|
694 |
if( !TrkParams::IsLoaded(type) || |
if( !TrkParams::IsLoaded(type) || |
695 |
glrun->RUNHEADER_TIME < gl[index].FROM_TIME || |
runheadtime < gl[index].FROM_TIME || |
696 |
glrun->RUNHEADER_TIME > gl[index].TO_TIME || |
runheadtime > gl[index].TO_TIME || |
697 |
false ){ |
false ){ |
698 |
|
|
699 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
// if(TrkParams::VerboseMode()) |
700 |
|
if(TrkParams::DebugMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; |
701 |
|
|
702 |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
bool LOCAL_CONNECTION = false; |
703 |
TString host = "mysql://localhost/pamelaprod"; |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
|
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; |
|
|
if(TrkParams::VerboseMode()){ |
|
|
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; |
|
|
if(TrkParams::VerboseMode()){ |
|
|
cout << " ...done"<<endl; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
} |
|
|
} |
|
704 |
|
|
705 |
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
706 |
|
dbc = TrkParams::SetDBConnection(); |
707 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
708 |
|
|
709 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
} |
|
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
|
|
else cout <<"Missing run info -- taking last entry "<<endl; |
|
710 |
|
|
711 |
GL_PARAM q4; |
GL_PARAM q4; |
712 |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
713 |
|
if(LOCAL_CONNECTION){ |
714 |
|
dbc->Close(); |
715 |
|
delete dbc; |
716 |
|
if(TrkParams::DebugMode()){ |
717 |
|
cout << " DB connection closed."<<endl; |
718 |
|
} |
719 |
|
} |
720 |
gl[index] = q4; |
gl[index] = q4; |
721 |
glpath[index] = q4.PATH+q4.NAME; |
glpath[index] = q4.PATH+q4.NAME; |
722 |
glload[index] = false; |
glload[index] = false; |
723 |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
|
724 |
return true; |
return true; |
725 |
|
|
726 |
} |
} |
740 |
|
|
741 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
742 |
glpath[index] = path; |
glpath[index] = path; |
743 |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode()) |
744 |
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
745 |
glload[index] = false; |
glload[index] = false; |
746 |
|
|
747 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
757 |
*/ |
*/ |
758 |
Bool_t TrkParams::Set(UInt_t type){ |
Bool_t TrkParams::Set(UInt_t type){ |
759 |
|
|
|
UInt_t index = TrkParams::GetIndex( type ); |
|
|
if(index < 0)return false; |
|
|
|
|
|
gl[index].TYPE= type; |
|
|
glload[index] = false; |
|
|
|
|
|
// ----------------------------------------- |
|
|
// check if enviroment variables are defined |
|
|
// ----------------------------------------- |
|
|
glpath[index] = gSystem->Getenv("PAM_CALIB"); |
|
760 |
|
|
761 |
if( !glpath[index].IsNull() ){ |
return Set(0,0,type); |
|
|
|
|
switch(type){ |
|
|
case 1: |
|
|
glpath[index].Append("/trk-param/field_param-0/"); |
|
|
break; |
|
|
case 2: |
|
|
glpath[index].Append("/trk-param/mip_param-0/"); |
|
|
break; |
|
|
case 3: |
|
|
glpath[index].Append("/trk-param/charge_param-1/"); |
|
|
break; |
|
|
case 4: |
|
|
glpath[index].Append("/trk-param/eta_param-0/"); |
|
|
break; |
|
|
case 5: |
|
|
glpath[index].Append("/trk-param/align_param-0/"); |
|
|
break; |
|
|
case 6: |
|
|
glpath[index].Append("/trk-param/mask_param-1/"); |
|
|
break; |
|
|
case 7: |
|
|
glpath[index].Append("/trk-param/default_calib/"); |
|
|
break; |
|
|
} |
|
|
|
|
|
}else{ |
|
|
cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
|
|
return false; |
|
|
|
|
|
} |
|
762 |
|
|
|
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
|
|
// return TrkParams::Load(type); |
|
|
return true; |
|
763 |
|
|
764 |
}; |
}; |
765 |
/** |
/** |
770 |
*/ |
*/ |
771 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
772 |
|
|
|
Bool_t connected = false; |
|
773 |
|
|
774 |
// cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
|
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; |
|
|
if(TrkParams::VerboseMode()){ |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
cout<<"Connecting to DB"<<endl; |
|
|
cout<<"HOST "<<host<<endl; |
|
|
cout<<"USER "<<user<<endl; |
|
|
cout<<"PSW "<<psw<<endl; |
|
|
} |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if( dbc || dbc->IsConnected() )connected = true; |
|
|
else cout << " >> DB connection FAILED!!!"<<endl; |
|
|
if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
|
|
|
if(connected){ |
|
|
if ( !TrkParams::Set(0,dbc) )return false; |
|
|
dbc->Close(); |
|
|
}else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
|
775 |
|
|
776 |
return true; |
return true; |
777 |
} |
} |
785 |
|
|
786 |
Int_t index = TrkParams::GetIndex( type ); |
Int_t index = TrkParams::GetIndex( type ); |
787 |
if( index<0 )return false; |
if( index<0 )return false; |
788 |
if( glload[index] )return true; |
if( glload[index] )return false; |
|
|
|
789 |
if( glpath[index].IsNull() )TrkParams::Set(type); |
if( glpath[index].IsNull() )TrkParams::Set(type); |
790 |
|
|
791 |
switch( type ){ |
switch( type ){ |
913 |
} |
} |
914 |
|
|
915 |
|
|
|
|
|
916 |
/** |
/** |
917 |
* \brief Set tracking mode (0=standard. 1=???) |
* \brief Set tracking mode (0=standard. 1=???) |
918 |
*/ |
*/ |
919 |
void TrkParams::SetTrackingMode(int trackmode) { |
void TrkParams::SetTrackingMode(int trackmode) { |
920 |
init__mini_trackmode = trackmode; |
init__mini_trackmode = trackmode; |
921 |
SetTrackingMode(); |
SetTrackingMode(); //fill F77 common |
922 |
}; |
}; |
923 |
/** |
/** |
924 |
* \brief Set fit-precision factor (typical value fact=100.) |
* \brief Set fit-precision factor (typical value fact=100.) |
925 |
*/ |
*/ |
926 |
void TrkParams::SetPrecisionFactor(double fact){ |
void TrkParams::SetPrecisionFactor(double fact){ |
927 |
init__mini_fact = fact; |
init__mini_fact = fact; |
928 |
SetPrecisionFactor(); |
SetPrecisionFactor(); //fill F77 common |
929 |
}; |
}; |
930 |
/** |
/** |
931 |
* \brief Set minimum number of step in track fitting |
* \brief Set minimum number of step in track fitting |
932 |
*/ |
*/ |
933 |
void TrkParams::SetStepMin(int istepmin){ |
void TrkParams::SetStepMin(int istepmin){ |
934 |
init__mini_istepmin = istepmin; |
init__mini_istepmin = istepmin; |
935 |
SetStepMin(); |
SetStepMin(); //fill F77 common |
936 |
|
}; |
937 |
|
/** |
938 |
|
* \brief Set deltaB parameters (id=0,1) |
939 |
|
*/ |
940 |
|
void TrkParams::SetDeltaB(int id,double db){ |
941 |
|
if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
942 |
|
if(id==0)init__deltab_0 = db; |
943 |
|
if(id==1)init__deltab_1 = db; |
944 |
|
SetDeltaB(); //fill F77 common |
945 |
|
}; |
946 |
|
/** |
947 |
|
* \brief Set DLT-grkuta precision factor (default 1.e-4) |
948 |
|
*/ |
949 |
|
void TrkParams::SetDLT(double fact){ |
950 |
|
init__dlt = fact; |
951 |
|
SetDLT(); //fill F77 common |
952 |
}; |
}; |
953 |
|
|
954 |
/** |
/** |
955 |
|
* \brief Fill F77 commons with PFA settings |
956 |
|
*/ |
957 |
|
void TrkParams::SetPFA(){ |
958 |
|
sw_.pfaid = init__pfa; |
959 |
|
for(int i=0; i<6; i++){ |
960 |
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
961 |
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
962 |
|
} |
963 |
|
}; |
964 |
|
/** |
965 |
* \brief Set p.f.a. |
* \brief Set p.f.a. |
966 |
* |
* |
967 |
* Implemented algorythms: |
* Implemented algorythms: |
979 |
*/ |
*/ |
980 |
void TrkParams::SetPFA(int pfaid){ |
void TrkParams::SetPFA(int pfaid){ |
981 |
init__pfa = pfaid; |
init__pfa = pfaid; |
982 |
SetPFA(); |
SetPFA(); //fill F77 common |
983 |
}; |
}; |
984 |
/** |
/** |
985 |
|
* \brief Set p.f.a. angular intervals |
986 |
|
* |
987 |
|
* This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4 |
988 |
|
* algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)). |
989 |
|
* @param v Pointer to a vector of 12 components, which represent the |
990 |
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
991 |
|
* |
992 |
|
*/ |
993 |
|
void TrkParams::SetPFA(float *v){ |
994 |
|
for(int i=0; i<6; i++){ |
995 |
|
init__pfa_e234ax[i] = v[i]; |
996 |
|
init__pfa_e234ay[i] = v[i+6]; |
997 |
|
} |
998 |
|
SetPFA(); //fill F77 common |
999 |
|
}; |
1000 |
|
|
1001 |
|
|
1002 |
|
/** |
1003 |
* \brief Get spatial resolution. |
* \brief Get spatial resolution. |
1004 |
* |
* |
1005 |
* Method to retrieve the spatial resolution associated with the |
* Method to retrieve the spatial resolution associated with the |
1014 |
*/ |
*/ |
1015 |
float TrkParams::GetResolution(int view, float angle){ |
float TrkParams::GetResolution(int view, float angle){ |
1016 |
float res = 1000; |
float res = 1000; |
1017 |
if( init__pfa == 0 )res = riseta_(&view,&angle); |
if ( init__pfa == 0 )res = riseta_(&view,&angle); |
1018 |
|
else if( init__pfa == 5 )res = riseta_(&view,&angle); |
1019 |
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
1020 |
return res; |
return res; |
1021 |
} |
} |
1022 |
|
|
1023 |
|
/** |
1024 |
|
* Returns the number of angular bins for p.f.a. parameters |
1025 |
|
*/ |
1026 |
|
int TrkParams::GetPFA_NbinsAngle(){ |
1027 |
|
TrkParams::Load(4); |
1028 |
|
if( !TrkParams::IsLoaded(4) ){ |
1029 |
|
cout << "int TrkParams::GetPFA_NbinsAngle() --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1030 |
|
return 0; |
1031 |
|
} |
1032 |
|
return pfa_.nangbin; |
1033 |
|
}; |
1034 |
|
/** |
1035 |
|
* Returns the number of eta bins for p.f.a. parameters |
1036 |
|
*/ |
1037 |
|
int TrkParams::GetPFA_NbinsETA(){ |
1038 |
|
TrkParams::Load(4); |
1039 |
|
if( !TrkParams::IsLoaded(4) ){ |
1040 |
|
cout << "int TrkParams::GetPFA_NbinsETA() --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1041 |
|
return 0; |
1042 |
|
} |
1043 |
|
return pfa_.netaval; |
1044 |
|
}; |
1045 |
|
|
1046 |
|
/** |
1047 |
|
* Returns the pointer to a vector ( of size TrkParams::GetPFA_NbinsETA() ), |
1048 |
|
* with eta-correction values for each eta bin. |
1049 |
|
* Bin extremes are given by float* TrkParams::GetPFA_ETAabs(pfa,int). |
1050 |
|
* |
1051 |
|
* @param pfa "ETA2","ETA3" or "ETA4" |
1052 |
|
* @param nview View number (0-11) |
1053 |
|
* @param nladder Ladder number (0-2) |
1054 |
|
* @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). |
1055 |
|
* |
1056 |
|
* NB! the vector must be deallocated! |
1057 |
|
* delete [] vname; |
1058 |
|
*/ |
1059 |
|
float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang){ |
1060 |
|
|
1061 |
|
TrkParams::Load(4); |
1062 |
|
if( !TrkParams::IsLoaded(4) ){ |
1063 |
|
cout << "float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1064 |
|
return 0; |
1065 |
|
} |
1066 |
|
|
1067 |
|
int nbins = GetPFA_NbinsETA(); |
1068 |
|
if(!nbins)return 0; |
1069 |
|
|
1070 |
|
if( nview < 0 || |
1071 |
|
nview >= 12 || |
1072 |
|
nladder < 0 || |
1073 |
|
nladder >= 3 || |
1074 |
|
nang < 0 || |
1075 |
|
nang >= GetPFA_NbinsAngle() || |
1076 |
|
false)return 0; |
1077 |
|
|
1078 |
|
float *fcorr = new float [nbins]; |
1079 |
|
// float fcorr[nbins]; |
1080 |
|
|
1081 |
|
if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ |
1082 |
|
for(int ib=0; ib<nbins; ib++){ |
1083 |
|
fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib]; |
1084 |
|
// cout << pfa_.eta2[nang][ib] << " - " << pfa_.feta2[nang][nladder][nview][ib]<<endl;; |
1085 |
|
} |
1086 |
|
}else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ |
1087 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib]; |
1088 |
|
}else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ |
1089 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib]; |
1090 |
|
}else{ |
1091 |
|
cout << "float* TrkParams::GetPFA_ETAcorr("<<pfa<<",...) --- pfa parameters not implemented "<<endl; |
1092 |
|
return 0; |
1093 |
|
} |
1094 |
|
|
1095 |
|
return fcorr; |
1096 |
|
|
1097 |
|
}; |
1098 |
|
|
1099 |
|
/** |
1100 |
|
* Returns the pointer to a vector with eta-bin extremes (@see float* TrkParams::GetPFA_ETAcorr(TString,int,int,int)). |
1101 |
|
* |
1102 |
|
* @param pfa "ETA2","ETA3" or "ETA4" |
1103 |
|
* @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). |
1104 |
|
* |
1105 |
|
* NB the vector must be deallocated |
1106 |
|
* delete [] vname; |
1107 |
|
*/ |
1108 |
|
float* TrkParams::GetPFA_ETAabs(TString pfa, int nang){ |
1109 |
|
|
1110 |
|
TrkParams::Load(4); |
1111 |
|
if( !TrkParams::IsLoaded(4) ){ |
1112 |
|
cout << "float* TrkParams::GetPFA_ETAabs(TString pfa, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1113 |
|
return 0; |
1114 |
|
} |
1115 |
|
|
1116 |
|
int nbins = GetPFA_NbinsETA(); |
1117 |
|
if(!nbins)return 0; |
1118 |
|
|
1119 |
|
float *fcorr = new float [nbins]; |
1120 |
|
// float fcorr[nbins]; |
1121 |
|
if( nang < 0 || |
1122 |
|
nang >= GetPFA_NbinsAngle() || |
1123 |
|
false)return 0; |
1124 |
|
|
1125 |
|
if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ |
1126 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib]; |
1127 |
|
}else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ |
1128 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib]; |
1129 |
|
}else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ |
1130 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib]; |
1131 |
|
}else{ |
1132 |
|
cout << "float* TrkParams::GetPFA_ETAabs("<<pfa<<",...) --- pfa parameters not implemented "<<endl; |
1133 |
|
return 0; |
1134 |
|
} |
1135 |
|
|
1136 |
|
return fcorr; |
1137 |
|
|
1138 |
|
}; |
1139 |
|
/** |
1140 |
|
* Returns the "Landi-correction". |
1141 |
|
* |
1142 |
|
* @param nview View number (0-11) |
1143 |
|
* @param nladder Ladder number (0-2) |
1144 |
|
* @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). |
1145 |
|
*/ |
1146 |
|
float TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang){ |
1147 |
|
|
1148 |
|
// TrkParams::Load(4); |
1149 |
|
// if( !TrkParams::IsLoaded(4) ){ |
1150 |
|
// cout << "float* TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1151 |
|
// return 0; |
1152 |
|
// } |
1153 |
|
int nbins = GetPFA_NbinsAngle(); |
1154 |
|
if(!nbins)return 0; |
1155 |
|
|
1156 |
|
if( nview < 0 || |
1157 |
|
nview >= 12 || |
1158 |
|
nladder < 0 || |
1159 |
|
nladder >= 3 || |
1160 |
|
nang < 0 || |
1161 |
|
nang >= nbins || |
1162 |
|
false)return 0; |
1163 |
|
|
1164 |
|
|
1165 |
|
return pfa_.fcorr[nang][nladder][nview]; |
1166 |
|
|
1167 |
|
}; |
1168 |
|
|
1169 |
|
/** |
1170 |
|
* Returns the index (0, n.bin-1) of the angular bin for pfa parameters |
1171 |
|
* @param angle Effective angle (deg) |
1172 |
|
*/ |
1173 |
|
int TrkParams::GetPFA_AngleBin(float angle){ |
1174 |
|
|
1175 |
|
int nangbin = TrkParams::GetPFA_NbinsAngle(); |
1176 |
|
int istart = (int)(nangbin/2); |
1177 |
|
int idbin = -1; |
1178 |
|
// cout << angle <<" ??" << endl; |
1179 |
|
if( angle > pfa_.angR[istart] ){ |
1180 |
|
idbin = nangbin-1; |
1181 |
|
for(int id=istart+1; id<nangbin; id++ ){ |
1182 |
|
// cout << id << endl; |
1183 |
|
if( pfa_.angR[id] >= angle ){ |
1184 |
|
idbin = id; |
1185 |
|
break; |
1186 |
|
} |
1187 |
|
} |
1188 |
|
}else{ |
1189 |
|
idbin = 0; |
1190 |
|
for(int id=istart; id>=0; id-- ){ |
1191 |
|
// cout << id << endl; |
1192 |
|
if( pfa_.angL[id] < angle ){ |
1193 |
|
idbin = id; |
1194 |
|
break; |
1195 |
|
} |
1196 |
|
} |
1197 |
|
|
1198 |
|
} |
1199 |
|
// cout << ">>> "<<idbin<<" "<<pfa_.angL[idbin]<<" "<<pfa_.angR[idbin]<<endl; |
1200 |
|
return idbin; |
1201 |
|
} |
1202 |
|
|
1203 |
|
|
1204 |
|
|
1205 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |