5 |
|
|
6 |
#include <TrkParams.h> |
#include <TrkParams.h> |
7 |
#include <iostream> |
#include <iostream> |
8 |
|
#include <iomanip> |
9 |
using namespace std; |
using namespace std; |
10 |
|
|
11 |
|
|
17 |
TString TrkParams::calibpathf = ""; |
TString TrkParams::calibpathf = ""; |
18 |
Bool_t TrkParams::calib104 = 0; |
Bool_t TrkParams::calib104 = 0; |
19 |
Bool_t TrkParams::calibload = false; |
Bool_t TrkParams::calibload = false; |
20 |
|
// ------------------------- |
21 |
|
// PARAMETERS loaded from DB |
22 |
|
// ------------------------- |
23 |
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
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()}; |
GL_PARAM TrkParams::gl[] = {GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM(),GL_PARAM()}; |
25 |
TString TrkParams::glpath[] = {"","","","","","",""}; |
TString TrkParams::glpath[] = {"","","","","","",""}; |
26 |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
27 |
|
// ---------------- |
28 |
|
// other parameters |
29 |
|
// ---------------- |
30 |
|
cDbg TrkParams::init__dbg_mode = {0,0,0}; |
31 |
|
//int TrkParams::init__pfa = 14;//COG4 |
32 |
|
int TrkParams::init__pfa = 5;//ETAL |
33 |
|
int TrkParams::init__mini_trackmode = 0; |
34 |
|
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 |
|
|
39 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
40 |
|
|
54 |
ret1=(float)ret; |
ret1=(float)ret; |
55 |
return ret1; |
return ret1; |
56 |
} |
} |
57 |
|
|
58 |
|
/** |
59 |
|
* Static method to open a DB connection. |
60 |
|
* HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, |
61 |
|
* $PAM_DBUSER and $PAM_DBPSW |
62 |
|
* NB! The method create a new connection, which has to be closed by the user. |
63 |
|
*/ |
64 |
|
TSQLServer* TrkParams::SetDBConnection(){ |
65 |
|
|
66 |
|
TString host = "mysql://localhost/pamelaprod"; |
67 |
|
TString user = "anonymous"; |
68 |
|
TString psw = ""; |
69 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
70 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
71 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
72 |
|
if ( !pamdbhost ) pamdbhost = ""; |
73 |
|
if ( !pamdbuser ) pamdbuser = ""; |
74 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
75 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
76 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
77 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
78 |
|
if(TrkParams::VerboseMode()){ |
79 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
80 |
|
cout<<"Connecting to DB"<<endl; |
81 |
|
cout<<"HOST "<<host<<endl; |
82 |
|
cout<<"USER "<<user<<endl; |
83 |
|
cout<<"PSW "<<psw<<endl; |
84 |
|
} |
85 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
86 |
|
if( !dbc )return NULL; |
87 |
|
if( !dbc->IsConnected() )return NULL; |
88 |
|
stringstream myquery; // EMILIANO |
89 |
|
myquery.str(""); // EMILIANO |
90 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
91 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
92 |
|
if(TrkParams::VerboseMode()){ |
93 |
|
cout << " ...done"<<endl; |
94 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
95 |
|
} |
96 |
|
|
97 |
|
return dbc; |
98 |
|
} |
99 |
/** |
/** |
100 |
* Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
101 |
|
|
102 |
* It retrieves the calibration associated to a given run, from |
* It retrieves the calibration associated to a given run, from |
103 |
* a given DB. It fills the F77 common. |
* a given DB. It fills the F77 common. |
106 |
*/ |
*/ |
107 |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
108 |
|
|
109 |
|
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
110 |
|
|
111 |
if( !CalibIsLoaded() || |
if( !CalibIsLoaded() || |
112 |
(glrun->TRK_CALIB_USED==104 && !calib104) || |
(glrun->TRK_CALIB_USED==104 && !calib104) || |
113 |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
115 |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
116 |
false ){ |
false ){ |
117 |
|
|
118 |
|
|
119 |
GL_TRK_CALIB q2; |
GL_TRK_CALIB q2; |
120 |
GL_ROOT q3; |
GL_ROOT q3; |
121 |
GL_PARAM q4; |
GL_PARAM q4; |
122 |
|
|
123 |
|
|
124 |
|
bool LOCAL_CONNECTION = false; |
125 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
126 |
|
|
127 |
|
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
128 |
|
dbc = TrkParams::SetDBConnection(); |
129 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
130 |
|
|
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
cout << " UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
if(TrkParams::VerboseMode()){ |
135 |
|
cout << "--------------------------------------"<<endl; |
136 |
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
137 |
|
} |
138 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
139 |
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; |
140 |
return false; |
return false; |
141 |
} |
} |
142 |
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
143 |
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); |
144 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
145 |
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; |
146 |
return false; |
return false; |
147 |
} |
} |
148 |
|
|
149 |
// 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; |
150 |
calib = q2; |
calib = q2; |
151 |
calibpathf = q3.PATH + q3.NAME; |
calibpathf = q3.PATH + q3.NAME; |
152 |
calib104 = (glrun->TRK_CALIB_USED==104); |
calib104 = (glrun->TRK_CALIB_USED==104); |
156 |
calibpatht = q4.PATH + q4.NAME; |
calibpatht = q4.PATH + q4.NAME; |
157 |
} |
} |
158 |
|
|
159 |
|
if(LOCAL_CONNECTION){ |
160 |
|
dbc->Close(); |
161 |
|
delete dbc; |
162 |
|
} |
163 |
|
|
164 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
165 |
return true; |
return true; |
169 |
}; |
}; |
170 |
|
|
171 |
/** |
/** |
172 |
|
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
173 |
|
* in YodaProfiler. |
174 |
|
*/ |
175 |
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
176 |
|
|
177 |
|
UInt_t validate = 1; |
178 |
|
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
179 |
|
// UInt_t timeaftercalib=120000; //2000; |
180 |
|
TString classname = caltrk->GetName(); |
181 |
|
// ---------- |
182 |
|
// Check CRCs |
183 |
|
// ---------- |
184 |
|
if(TrkParams::VerboseMode())cout << " DSP: "; |
185 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
186 |
|
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
187 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
188 |
|
if( caltrk->crc_hcal[ipkt] ){ |
189 |
|
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
190 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
191 |
|
// return 0; // :-( |
192 |
|
validate = 0; |
193 |
|
} |
194 |
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
195 |
|
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
196 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
197 |
|
// return 0; // :-( |
198 |
|
validate = 0; |
199 |
|
} |
200 |
|
} |
201 |
|
} |
202 |
|
if(TrkParams::VerboseMode())cout << endl;; |
203 |
|
// ----------------------- |
204 |
|
// Check missing packets: |
205 |
|
// ----------------------- |
206 |
|
// Readout order: |
207 |
|
// ------------------ |
208 |
|
// DSP packet board |
209 |
|
// ------------------ |
210 |
|
// 12 0 1 |
211 |
|
// 10 1 1 |
212 |
|
// 8 2 1 |
213 |
|
// 4 3 1 |
214 |
|
// 6 4 1 |
215 |
|
// 2 5 1 |
216 |
|
// ------------------ |
217 |
|
// 11 0 2 |
218 |
|
// 9 1 2 |
219 |
|
// 7 2 2 |
220 |
|
// 3 3 2 |
221 |
|
// 5 4 2 |
222 |
|
// 1 5 2 |
223 |
|
// ------------------ |
224 |
|
// ------------------------------------------------- |
225 |
|
// Check if it is first or second calibration packet |
226 |
|
// ------------------------------------------------- |
227 |
|
UInt_t build=0; |
228 |
|
UInt_t base=0; |
229 |
|
UInt_t mask=0; |
230 |
|
if(classname.Contains("CalibTrk1Event")){ |
231 |
|
base=12; |
232 |
|
mask=0x03F000; |
233 |
|
} |
234 |
|
if(classname.Contains("CalibTrk2Event")){ |
235 |
|
base=18; |
236 |
|
mask=0xFC0000; |
237 |
|
} |
238 |
|
// ------------------------------------------------- |
239 |
|
// Count number of packets and set build variable |
240 |
|
// ------------------------------------------------- |
241 |
|
Int_t npkts=0; |
242 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
243 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
244 |
|
npkts++; |
245 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
246 |
|
}; |
247 |
|
} |
248 |
|
if( npkts==6 ){}//return 1; // :-) |
249 |
|
else { |
250 |
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
251 |
|
validate = 0; |
252 |
|
} |
253 |
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
254 |
|
|
255 |
|
// ----------------------------------------------- |
256 |
|
// If missing packets: check the acq configuration |
257 |
|
// (some DSPs might be excluded from acquisition) |
258 |
|
// ----------------------------------------------- |
259 |
|
|
260 |
|
// ----------------------------------------------- |
261 |
|
// retrieve the first run header after calib |
262 |
|
// ----------------------------------------------- |
263 |
|
// PacketType *pctp; |
264 |
|
// EventCounter *cod; |
265 |
|
// cod = eh->GetCounter(); |
266 |
|
// Int_t irun = cod->Get(pctp->RunHeader); |
267 |
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
268 |
|
// if ( !rh || rh->IsZombie() ) throw -17; |
269 |
|
// if( rh->GetEntries() == irun ){ |
270 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
271 |
|
// return 0; // :-( |
272 |
|
// } |
273 |
|
|
274 |
|
// RunHeaderEvent *run = 0; |
275 |
|
// EventHeader *hrun = 0; |
276 |
|
// rh->SetBranchAddress("RunHeader", &run); |
277 |
|
// rh->SetBranchAddress("Header", &hrun); |
278 |
|
// rh->GetEntry(irun); |
279 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
280 |
|
|
281 |
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
282 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
283 |
|
// return 0; // :-( |
284 |
|
// } |
285 |
|
|
286 |
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
287 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
288 |
|
// return 0; // :-( |
289 |
|
// } |
290 |
|
|
291 |
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
292 |
|
// if( dtime > timeaftercalib ){ |
293 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
294 |
|
// return 0; // :-( |
295 |
|
// } |
296 |
|
|
297 |
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
298 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
299 |
|
// return 0; // :-( |
300 |
|
// } |
301 |
|
|
302 |
|
// return 1; // :-) |
303 |
|
|
304 |
|
// cout << validate << endl; |
305 |
|
return validate; |
306 |
|
|
307 |
|
} |
308 |
|
/** |
309 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
310 |
*/ |
*/ |
311 |
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){ |
312 |
|
|
313 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
314 |
|
ca->Reset(); |
315 |
|
|
316 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
317 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
323 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
324 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
325 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
326 |
|
|
327 |
|
// --- TEST TEST TEST TEST --- // |
328 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
329 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
330 |
|
|
331 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
332 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
333 |
|
if( !test1 || !test2 ){ |
334 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
335 |
|
TrkParams::calib.VALIDATION = 0; |
336 |
|
} |
337 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
338 |
|
|
339 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
340 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
341 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
342 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
343 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
344 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
345 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
346 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
347 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
348 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
349 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
350 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
351 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
352 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->bad[jj][j][dspn1]=1; |
353 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
else if(calibdata1->DSPbad_par[i][ii]==1) |
354 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=0; |
355 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
356 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
357 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
} |
358 |
|
|
359 |
// |
if(dspn2>=0 && dspn2<12){ |
360 |
// invert the bad |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
361 |
// |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
362 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
363 |
ca->bad[jj][j][dspn1]=1; |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
364 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
if(calibdata2->DSPbad_par[i][ii]==0) |
365 |
ca->bad[jj][j][dspn1]=0; |
ca->bad[jj][j][dspn2]=1; |
366 |
if(calibdata2->DSPbad_par[i][ii]==0) |
else if(calibdata2->DSPbad_par[i][ii]==1) |
367 |
ca->bad[jj][j][dspn2]=1; |
ca->bad[jj][j][dspn2]=0; |
368 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
369 |
ca->bad[jj][j][dspn2]=0; |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
370 |
|
} |
371 |
}; |
}; |
372 |
}; |
}; |
373 |
|
|
380 |
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){ |
381 |
|
|
382 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
383 |
|
// ca->Reset(); |
384 |
|
|
385 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
386 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
392 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
393 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
394 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
395 |
|
|
396 |
|
// --- TEST TEST TEST TEST --- // |
397 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
398 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
399 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
400 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
401 |
|
if( !test1 || !test2 ){ |
402 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
403 |
|
TrkParams::calib.VALIDATION = 0; |
404 |
|
} |
405 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
406 |
|
|
407 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
408 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
411 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
412 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
413 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
414 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
415 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
416 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
417 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
418 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=1; |
419 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
else if(calibdata1->DSPbad_par[i][ii]==1) |
420 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
ca->bad[jj][j][dspn1]=0; |
421 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
422 |
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
423 |
// |
} |
424 |
// invert the bad |
if(dspn2>=0 && dspn2<12){ |
425 |
// |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
426 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
427 |
ca->bad[jj][j][dspn1]=1; |
if(calibdata2->DSPbad_par[i][ii]==0) |
428 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
ca->bad[jj][j][dspn2]=1; |
429 |
ca->bad[jj][j][dspn1]=0; |
else if(calibdata2->DSPbad_par[i][ii]==1) |
430 |
if(calibdata2->DSPbad_par[i][ii]==0) |
ca->bad[jj][j][dspn2]=0; |
431 |
ca->bad[jj][j][dspn2]=1; |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
432 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
433 |
ca->bad[jj][j][dspn2]=0; |
} |
434 |
}; |
}; |
435 |
}; |
}; |
436 |
|
|
443 |
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){ |
444 |
|
|
445 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
446 |
|
// ca->Reset(); |
447 |
|
|
448 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
449 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
456 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
457 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
458 |
|
|
459 |
|
// --- TEST TEST TEST TEST --- // |
460 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
461 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
462 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
463 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
464 |
|
if( !test1 || !test2 ){ |
465 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
466 |
|
TrkParams::calib.VALIDATION = 0; |
467 |
|
} |
468 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
469 |
|
|
470 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
471 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
472 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
474 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
475 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
476 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
477 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
if(dspn1>=0 && dspn1<12){ |
478 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
479 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
480 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
} |
481 |
|
if(dspn2>=0 && dspn2<12){ |
482 |
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
483 |
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
484 |
|
} |
485 |
}; |
}; |
486 |
}; |
}; |
487 |
|
|
504 |
void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
505 |
|
|
506 |
cTrkMask *ma = &mask_; |
cTrkMask *ma = &mask_; |
507 |
|
ma->Reset(); |
508 |
|
|
509 |
TrkCalib *calib = new TrkCalib(); |
TrkCalib *calib = new TrkCalib(); |
510 |
|
|
527 |
tr->GetEntry(ev_reg2); |
tr->GetEntry(ev_reg2); |
528 |
} |
} |
529 |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
530 |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
Int_t view = calib->GetView(ipkt); |
531 |
Int_t view = calib->GetView(ipkt); |
if( (view-1)>= 0 && (view-1)<12 ){ |
532 |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
533 |
Float_t sigmin = 0.; |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
534 |
if(view%2)sigmin = 6.5; |
Float_t sigmin = 0.; |
535 |
else sigmin = 2.5; |
if(view%2)sigmin = 6.5; |
536 |
Int_t mask = 1; |
else sigmin = 2.5; |
537 |
if( sigm<sigmin )mask = 0; |
Int_t mask = 1; |
538 |
|
if( sigm<sigmin )mask = 0; |
539 |
ma->mask_vk_run[ivk][view-1] = mask; |
ma->mask_vk_run[ivk][view-1] = mask; |
540 |
|
} |
541 |
// if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl; |
} |
|
} |
|
542 |
} |
} |
543 |
if(tr)tr->Delete(); |
if(tr)tr->Delete(); |
544 |
} |
} |
545 |
|
|
546 |
|
if(TrkParams::VerboseMode()){ |
547 |
|
for(Int_t iv=0; iv<NVIEW; iv++){ |
548 |
|
cout<<"view "<<setw(3)<<iv<<": "; |
549 |
|
for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv]; |
550 |
|
cout << endl; |
551 |
|
} |
552 |
|
} |
553 |
|
|
554 |
if(calib)calib->Delete(); |
if(calib)calib->Delete(); |
555 |
|
|
556 |
}; |
}; |
563 |
|
|
564 |
|
|
565 |
/** |
/** |
566 |
* Static method to load calibration. |
* \brief Static method to load calibration. |
567 |
* Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens the |
* Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens after the method TrkParams::SetCalib(***) is called. |
|
* first time the method is called (but it does not work becouse I didn't set any |
|
|
* default calibration for the moment) or after the method TrkParams::SetCalib(***) is called. |
|
568 |
*/ |
*/ |
569 |
Bool_t TrkParams::LoadCalib( ){ |
Bool_t TrkParams::LoadCalib( ){ |
570 |
|
|
571 |
if( TrkParams::CalibIsLoaded() )return false; |
if( TrkParams::CalibIsLoaded() )return false; |
572 |
|
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
|
|
|
|
|
// extern cTrkCalib pedsigbad_; |
|
|
// extern cTrkMask mask_; |
|
|
|
|
|
cout << "--------------------------------------"<<endl; |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
|
573 |
// ============================================================= |
// ============================================================= |
574 |
// retrieve calibration file needed to reduce data |
// retrieve calibration file needed to reduce data |
575 |
// ============================================================= |
// ============================================================= |
576 |
// if run OBT is > last calibration "expiration date" |
// if run OBT is > last calibration "expiration date" |
577 |
// - search for new calibration packet |
// - search for new calibration packet |
578 |
// - load calibration parameters (full + truncated) |
// - load calibration parameters (full + truncated) |
579 |
cout << "Full pedestals for cluster finding:"; |
if(TrkParams::VerboseMode()){ |
580 |
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
cout << "--------------------------------------"<<endl; |
581 |
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
582 |
|
cout << " Full pedestals for cluster finding:"; |
583 |
|
cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; |
584 |
|
} |
585 |
FileStat_t t; |
FileStat_t t; |
586 |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
587 |
|
|
588 |
TFile *f0_c = new TFile(calibpathf); |
bool alreadyopened = false; |
589 |
|
TFile *f0_c=0; |
590 |
|
f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); |
591 |
|
if(f0_c)alreadyopened=true; |
592 |
|
else f0_c = new TFile(calibpathf); |
593 |
if ( !f0_c ) return false; |
if ( !f0_c ) return false; |
594 |
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
|
595 |
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
if(TrkParams::VerboseMode()){ |
596 |
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
597 |
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
598 |
|
cout << " - full+truncated parameters "<<endl; |
599 |
|
} |
600 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
601 |
|
if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl; |
602 |
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; |
|
603 |
|
|
|
// }; |
|
604 |
// ============================================================= |
// ============================================================= |
605 |
// retrieve calibration file needed to uncompress data |
// retrieve calibration file needed to uncompress data |
606 |
// ============================================================= |
// ============================================================= |
607 |
// if the run was compressed using default calib |
// if the run was compressed using default calib |
608 |
// load truncated pedestals from default |
// load truncated pedestals from default |
609 |
// otherwise reload them from on-line calibration |
// otherwise reload them from on-line calibration |
610 |
cout << "Truncated pedestals for uncompression:"; |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
611 |
if( calib104 ){ |
if( calib104 ){ |
612 |
|
|
613 |
cout << " >> Loading default calibration: "<< calibpatht << endl; |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
|
// ca->FillTCalibFrom(calibpatht); |
|
614 |
TrkParams::FillTCalibFrom(calibpatht); |
TrkParams::FillTCalibFrom(calibpatht); |
615 |
|
|
616 |
}else{ |
}else{ |
617 |
|
|
618 |
if ( !f0_c ) return false; |
// if ( !f0_c ) return false; |
619 |
cout << ">> Loading on-line calibration " << endl; |
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
620 |
// 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); |
|
621 |
}; |
}; |
622 |
// for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
if(!alreadyopened)f0_c->Close(); |
623 |
f0_c->Close(); |
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
|
// delete f0_c; |
|
|
cout << "--------------------------------------"<<endl; |
|
624 |
|
|
625 |
calibload = kTRUE; |
calibload = kTRUE; |
626 |
return true; |
return true; |
638 |
* @param dbc Database |
* @param dbc Database |
639 |
* @param type Parameter type |
* @param type Parameter type |
640 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
641 |
* 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. |
642 |
* If dbc==NULL, try to open a connection taking DB-connection |
* If dbc==NULL, try to open a connection taking DB-connection |
643 |
* parameters from PAMELA environment variables. |
* parameters from PAMELA environment variables. |
644 |
*/ |
*/ |
645 |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
646 |
|
|
|
// if( !dbc )return false; |
|
647 |
|
|
648 |
|
UInt_t index = TrkParams::GetIndex( type ); |
649 |
|
if(index < 0)return false; |
650 |
|
|
651 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
UInt_t runheadtime=0; |
652 |
|
UInt_t runid=0; |
653 |
|
// UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
654 |
|
if(glrun){ |
655 |
|
runheadtime = glrun->RUNHEADER_TIME; |
656 |
|
runid = glrun->ID; |
657 |
|
}else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl; |
658 |
|
|
659 |
|
// if(TrkParams::VerboseMode()) |
660 |
|
cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; |
661 |
|
|
|
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; |
|
|
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; |
|
662 |
|
|
663 |
} |
if( !TrkParams::IsLoaded(type) || |
664 |
|
runheadtime < gl[index].FROM_TIME || |
665 |
|
runheadtime > gl[index].TO_TIME || |
666 |
|
false ){ |
667 |
|
|
668 |
UInt_t index = TrkParams::GetIndex( type ); |
bool LOCAL_CONNECTION = false; |
669 |
if(index < 0)return false; |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
670 |
|
|
671 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
672 |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
dbc = TrkParams::SetDBConnection(); |
673 |
else cout <<"Missing run info -- taking last entry "<<endl; |
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
674 |
|
|
675 |
GL_PARAM q4; |
} |
|
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
|
676 |
|
|
677 |
gl[index] = q4; |
GL_PARAM q4; |
678 |
glpath[index] = q4.PATH+q4.NAME; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
679 |
glload[index] = false; |
if(LOCAL_CONNECTION){ |
680 |
cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
dbc->Close(); |
681 |
return true; |
delete dbc; |
682 |
// return TrkParams::Load(type); |
} |
683 |
|
gl[index] = q4; |
684 |
|
glpath[index] = q4.PATH+q4.NAME; |
685 |
|
glload[index] = false; |
686 |
|
|
687 |
|
return true; |
688 |
|
|
689 |
|
} |
690 |
|
return false; |
691 |
|
|
692 |
}; |
}; |
693 |
/** |
/** |
703 |
|
|
704 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
705 |
glpath[index] = path; |
glpath[index] = path; |
706 |
cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode()) |
707 |
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
708 |
glload[index] = false; |
glload[index] = false; |
709 |
|
|
710 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
720 |
*/ |
*/ |
721 |
Bool_t TrkParams::Set(UInt_t type){ |
Bool_t TrkParams::Set(UInt_t type){ |
722 |
|
|
|
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"); |
|
723 |
|
|
724 |
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; |
|
|
|
|
|
} |
|
725 |
|
|
|
cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
|
|
// return TrkParams::Load(type); |
|
|
return true; |
|
726 |
|
|
727 |
}; |
}; |
728 |
/** |
/** |
733 |
*/ |
*/ |
734 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
735 |
|
|
|
Bool_t connected = false; |
|
736 |
|
|
737 |
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; |
|
|
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 << " >> FAILED!!!"<<endl; |
|
|
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; |
|
738 |
|
|
739 |
return true; |
return true; |
740 |
} |
} |
755 |
switch( type ){ |
switch( type ){ |
756 |
//------------------------------------------ |
//------------------------------------------ |
757 |
case 1: |
case 1: |
758 |
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
759 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
760 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
761 |
path_.error = 0; |
path_.error = 0; |
765 |
break; |
break; |
766 |
//------------------------------------------ |
//------------------------------------------ |
767 |
case 2: |
case 2: |
768 |
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; |
769 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
770 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
771 |
path_.error = 0; |
path_.error = 0; |
775 |
break; |
break; |
776 |
//------------------------------------------ |
//------------------------------------------ |
777 |
case 3: |
case 3: |
778 |
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
779 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
780 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
781 |
path_.error = 0; |
path_.error = 0; |
785 |
break; |
break; |
786 |
//------------------------------------------ |
//------------------------------------------ |
787 |
case 4: |
case 4: |
788 |
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
789 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
790 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
791 |
path_.error = 0; |
path_.error = 0; |
795 |
break; |
break; |
796 |
//------------------------------------------ |
//------------------------------------------ |
797 |
case 5: |
case 5: |
798 |
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
799 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
800 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
801 |
path_.error = 0; |
path_.error = 0; |
805 |
break; |
break; |
806 |
//------------------------------------------ |
//------------------------------------------ |
807 |
case 6: |
case 6: |
808 |
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
809 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
810 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
811 |
path_.error = 0; |
path_.error = 0; |
815 |
break; |
break; |
816 |
//------------------------------------------ |
//------------------------------------------ |
817 |
case 7: |
case 7: |
818 |
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
819 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
820 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
821 |
path_.error = 0; |
path_.error = 0; |
822 |
// fillpedsigfromdefault_(); |
// fillpedsigfromdefault_(); |
823 |
cout << ">> not implemented <<"<<endl; |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
824 |
if(path_.error) return false; |
if(path_.error) return false; |
825 |
glload[index]=true; |
glload[index]=true; |
826 |
break; |
break; |
827 |
default: |
default: |
828 |
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; |
829 |
return false; |
return false; |
830 |
}; |
}; |
831 |
|
|
841 |
return true; |
return true; |
842 |
}; |
}; |
843 |
|
|
844 |
|
|
845 |
|
/** |
846 |
|
* Get BY (kGauss) |
847 |
|
* @param v (x,y,z) coordinates in cm |
848 |
|
*/ |
849 |
|
float TrkParams::GetBX(float* v){ |
850 |
|
TrkParams::Load(1); |
851 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
852 |
|
float b[3]; |
853 |
|
gufld_(v,b); |
854 |
|
return b[0]/10.; |
855 |
|
} |
856 |
|
/** |
857 |
|
* Get BY (kGauss) |
858 |
|
* @param v (x,y,z) coordinates in cm |
859 |
|
*/ |
860 |
|
float TrkParams::GetBY(float* v){ |
861 |
|
TrkParams::Load(1); |
862 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
863 |
|
float b[3]; |
864 |
|
gufld_(v,b); |
865 |
|
return b[1]/10.; |
866 |
|
} |
867 |
|
/** |
868 |
|
* Get BY (kGauss) |
869 |
|
* @param v (x,y,z) coordinates in cm |
870 |
|
*/ |
871 |
|
float TrkParams::GetBZ(float* v){ |
872 |
|
TrkParams::Load(1); |
873 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
874 |
|
float b[3]; |
875 |
|
gufld_(v,b); |
876 |
|
return b[2]/10.; |
877 |
|
} |
878 |
|
|
879 |
|
|
880 |
|
|
881 |
|
/** |
882 |
|
* \brief Set tracking mode (0=standard. 1=???) |
883 |
|
*/ |
884 |
|
void TrkParams::SetTrackingMode(int trackmode) { |
885 |
|
init__mini_trackmode = trackmode; |
886 |
|
SetTrackingMode(); |
887 |
|
}; |
888 |
|
/** |
889 |
|
* \brief Set fit-precision factor (typical value fact=100.) |
890 |
|
*/ |
891 |
|
void TrkParams::SetPrecisionFactor(double fact){ |
892 |
|
init__mini_fact = fact; |
893 |
|
SetPrecisionFactor(); |
894 |
|
}; |
895 |
|
/** |
896 |
|
* \brief Set minimum number of step in track fitting |
897 |
|
*/ |
898 |
|
void TrkParams::SetStepMin(int istepmin){ |
899 |
|
init__mini_istepmin = istepmin; |
900 |
|
SetStepMin(); |
901 |
|
}; |
902 |
|
|
903 |
|
/** |
904 |
|
* Fill F77 commons with PFA settings |
905 |
|
*/ |
906 |
|
void TrkParams::SetPFA(){ |
907 |
|
sw_.pfaid = init__pfa; |
908 |
|
for(int i=0; i<6; i++){ |
909 |
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
910 |
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
911 |
|
} |
912 |
|
}; |
913 |
|
/** |
914 |
|
* \brief Set p.f.a. |
915 |
|
* |
916 |
|
* Implemented algorythms: |
917 |
|
* 0 ETA |
918 |
|
* 1 --- |
919 |
|
* 2 ETA2 |
920 |
|
* 3 ETA3 |
921 |
|
* 4 ETA4 |
922 |
|
* 5 ETAL ==> ETA+LANDI |
923 |
|
* 10 COG |
924 |
|
* 11 COG1 |
925 |
|
* 12 COG2 |
926 |
|
* 13 COG3 |
927 |
|
* 14 COG4 |
928 |
|
*/ |
929 |
|
void TrkParams::SetPFA(int pfaid){ |
930 |
|
init__pfa = pfaid; |
931 |
|
SetPFA(); |
932 |
|
}; |
933 |
|
/** |
934 |
|
* \brief Set p.f.a. angular intervals |
935 |
|
* |
936 |
|
* This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4 |
937 |
|
* algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)). |
938 |
|
* @param v Pointer to a vector of 12 components, which represent the |
939 |
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
940 |
|
* |
941 |
|
*/ |
942 |
|
void TrkParams::SetPFA(float *v){ |
943 |
|
for(int i=0; i<6; i++){ |
944 |
|
init__pfa_e234ax[i] = v[i]; |
945 |
|
init__pfa_e234ay[i] = v[i+6]; |
946 |
|
} |
947 |
|
SetPFA(); |
948 |
|
}; |
949 |
|
|
950 |
|
|
951 |
|
/** |
952 |
|
* \brief Get spatial resolution. |
953 |
|
* |
954 |
|
* Method to retrieve the spatial resolution associated with the |
955 |
|
* adopted p.f.a. |
956 |
|
* @param view Tracker view (1-12) |
957 |
|
* @param angle Track projected angle |
958 |
|
* |
959 |
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
960 |
|
* |
961 |
|
* TrkParams::SetPFA(0) // ETA |
962 |
|
* |
963 |
|
*/ |
964 |
|
float TrkParams::GetResolution(int view, float angle){ |
965 |
|
float res = 1000; |
966 |
|
if( init__pfa == 0 )res = riseta_(&view,&angle); |
967 |
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
968 |
|
return res; |
969 |
|
} |
970 |
|
|
971 |
|
|
972 |
|
|
973 |
|
|
974 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |