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 |
|
|
55 |
return ret1; |
return ret1; |
56 |
} |
} |
57 |
/** |
/** |
58 |
* Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
59 |
|
|
60 |
* It retrieves the calibration associated to a given run, from |
* It retrieves the calibration associated to a given run, from |
61 |
* a given DB. It fills the F77 common. |
* a given DB. It fills the F77 common. |
64 |
*/ |
*/ |
65 |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
66 |
|
|
67 |
GL_TRK_CALIB q2; |
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
68 |
GL_ROOT q3; |
|
69 |
GL_PARAM q4; |
if( !CalibIsLoaded() || |
70 |
|
(glrun->TRK_CALIB_USED==104 && !calib104) || |
71 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) )return false; |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
72 |
if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2) |
glrun->RUNHEADER_TIME < calib.FROM_TIME || |
73 |
printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
74 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false; |
false ){ |
75 |
|
|
76 |
calib = q2; |
// cout <<">>> isloaded? "<< CalibIsLoaded() << endl; |
77 |
calibpathf = q3.PATH + q3.NAME; |
// cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl; |
78 |
calib104 = (glrun->TRK_CALIB_USED==104); |
// cout <<">>> 104 loaded? "<< calib104 <<endl; |
79 |
calibload = kFALSE; |
// cout <<">>> from time "<< calib.FROM_TIME<<endl; |
80 |
if(calib104){ |
// cout <<">>> to time "<< calib.TO_TIME<<endl; |
81 |
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
// if( !dbc || (dbc && !dbc->IsConnected()) ){ |
82 |
calibpatht = q4.PATH + q4.NAME; |
|
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 |
|
GL_TRK_CALIB q2; |
113 |
|
GL_ROOT q3; |
114 |
|
GL_PARAM q4; |
115 |
|
|
116 |
|
if(TrkParams::VerboseMode()){ |
117 |
|
cout << "--------------------------------------"<<endl; |
118 |
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
119 |
|
} |
120 |
|
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
121 |
|
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
122 |
|
return false; |
123 |
|
} |
124 |
|
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
125 |
|
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 |
|
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
127 |
|
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
128 |
|
return false; |
129 |
|
} |
130 |
|
|
131 |
|
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
132 |
|
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 |
|
|
142 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
143 |
return true; |
return true; |
144 |
|
} |
145 |
|
|
146 |
|
return false; |
147 |
}; |
}; |
148 |
|
|
149 |
/** |
/** |
150 |
|
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
151 |
|
* in YodaProfiler. |
152 |
|
*/ |
153 |
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
154 |
|
|
155 |
|
UInt_t validate = 1; |
156 |
|
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 |
|
if(TrkParams::VerboseMode())cout << " DSP: "; |
163 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
164 |
|
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
165 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
166 |
|
if( caltrk->crc_hcal[ipkt] ){ |
167 |
|
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
168 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
169 |
|
// return 0; // :-( |
170 |
|
validate = 0; |
171 |
|
} |
172 |
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
173 |
|
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
174 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
175 |
|
// return 0; // :-( |
176 |
|
validate = 0; |
177 |
|
} |
178 |
|
} |
179 |
|
} |
180 |
|
if(TrkParams::VerboseMode())cout << endl;; |
181 |
|
// ----------------------- |
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 |
|
if( npkts==6 ){}//return 1; // :-) |
227 |
|
else { |
228 |
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
229 |
|
validate = 0; |
230 |
|
} |
231 |
|
// 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 |
|
|
280 |
|
// return 1; // :-) |
281 |
|
|
282 |
|
// cout << validate << endl; |
283 |
|
return validate; |
284 |
|
|
285 |
|
} |
286 |
|
/** |
287 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* 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){ |
void TrkParams::FillACalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
290 |
|
|
291 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
292 |
|
ca->Reset(); |
293 |
|
|
294 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
295 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
301 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
302 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
303 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
304 |
|
|
305 |
|
// --- TEST TEST TEST TEST --- // |
306 |
|
// 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 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
318 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
319 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
320 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
321 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
322 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
323 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
324 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
325 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
326 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
327 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
328 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
329 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
330 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->bad[jj][j][dspn1]=1; |
331 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
else if(calibdata1->DSPbad_par[i][ii]==1) |
332 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=0; |
333 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
334 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
335 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
} |
336 |
|
|
337 |
// |
if(dspn2>=0 && dspn2<12){ |
338 |
// invert the bad |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
339 |
// |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
340 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
341 |
ca->bad[jj][j][dspn1]=1; |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
342 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
if(calibdata2->DSPbad_par[i][ii]==0) |
343 |
ca->bad[jj][j][dspn1]=0; |
ca->bad[jj][j][dspn2]=1; |
344 |
if(calibdata2->DSPbad_par[i][ii]==0) |
else if(calibdata2->DSPbad_par[i][ii]==1) |
345 |
ca->bad[jj][j][dspn2]=1; |
ca->bad[jj][j][dspn2]=0; |
346 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
347 |
ca->bad[jj][j][dspn2]=0; |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
348 |
|
} |
349 |
}; |
}; |
350 |
}; |
}; |
351 |
|
|
358 |
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){ |
359 |
|
|
360 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
361 |
|
// ca->Reset(); |
362 |
|
|
363 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
364 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
370 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
371 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
372 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
373 |
|
|
374 |
|
// --- TEST TEST TEST TEST --- // |
375 |
|
// 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 |
|
|
385 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
386 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
389 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
390 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
391 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
392 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
393 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
394 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
395 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
396 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=1; |
397 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
else if(calibdata1->DSPbad_par[i][ii]==1) |
398 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
ca->bad[jj][j][dspn1]=0; |
399 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
400 |
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
401 |
// |
} |
402 |
// invert the bad |
if(dspn2>=0 && dspn2<12){ |
403 |
// |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
404 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
405 |
ca->bad[jj][j][dspn1]=1; |
if(calibdata2->DSPbad_par[i][ii]==0) |
406 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
ca->bad[jj][j][dspn2]=1; |
407 |
ca->bad[jj][j][dspn1]=0; |
else if(calibdata2->DSPbad_par[i][ii]==1) |
408 |
if(calibdata2->DSPbad_par[i][ii]==0) |
ca->bad[jj][j][dspn2]=0; |
409 |
ca->bad[jj][j][dspn2]=1; |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
410 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
411 |
ca->bad[jj][j][dspn2]=0; |
} |
412 |
}; |
}; |
413 |
}; |
}; |
414 |
|
|
421 |
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){ |
422 |
|
|
423 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
424 |
|
// ca->Reset(); |
425 |
|
|
426 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
427 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
434 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
435 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
436 |
|
|
437 |
|
// --- TEST TEST TEST TEST --- // |
438 |
|
// 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 |
|
|
448 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
449 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
450 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
452 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
453 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
454 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
455 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
if(dspn1>=0 && dspn1<12){ |
456 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
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]); |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
458 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
} |
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 |
}; |
}; |
464 |
}; |
}; |
465 |
|
|
482 |
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){ |
483 |
|
|
484 |
cTrkMask *ma = &mask_; |
cTrkMask *ma = &mask_; |
485 |
|
ma->Reset(); |
486 |
|
|
487 |
TrkCalib *calib = new TrkCalib(); |
TrkCalib *calib = new TrkCalib(); |
488 |
|
|
505 |
tr->GetEntry(ev_reg2); |
tr->GetEntry(ev_reg2); |
506 |
} |
} |
507 |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
508 |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
Int_t view = calib->GetView(ipkt); |
509 |
Int_t view = calib->GetView(ipkt); |
if( (view-1)>= 0 && (view-1)<12 ){ |
510 |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
511 |
Float_t sigmin = 0.; |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
512 |
if(view%2)sigmin = 6.5; |
Float_t sigmin = 0.; |
513 |
else sigmin = 2.5; |
if(view%2)sigmin = 6.5; |
514 |
Int_t mask = 1; |
else sigmin = 2.5; |
515 |
if( sigm<sigmin )mask = 0; |
Int_t mask = 1; |
516 |
|
if( sigm<sigmin )mask = 0; |
517 |
ma->mask_vk_run[ivk][view-1] = mask; |
ma->mask_vk_run[ivk][view-1] = mask; |
518 |
|
} |
519 |
// if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl; |
} |
|
} |
|
520 |
} |
} |
521 |
if(tr)tr->Delete(); |
if(tr)tr->Delete(); |
522 |
} |
} |
523 |
|
|
524 |
|
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 |
if(calib)calib->Delete(); |
if(calib)calib->Delete(); |
533 |
|
|
534 |
}; |
}; |
535 |
|
|
536 |
|
// Bool_t TrkParams::CalibIsLoaded(UInt_t time){ |
537 |
|
|
538 |
|
// if( !calibload ) return false; |
539 |
|
|
540 |
|
// }; |
541 |
|
|
542 |
|
|
543 |
/** |
/** |
544 |
* Static method to load calibration. |
* \brief Static method to load calibration. |
545 |
* 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. |
|
546 |
*/ |
*/ |
547 |
Bool_t TrkParams::LoadCalib( ){ |
Bool_t TrkParams::LoadCalib( ){ |
548 |
|
|
549 |
if( TrkParams::CalibIsLoaded() )return false; |
if( TrkParams::CalibIsLoaded() )return false; |
550 |
|
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
|
|
|
|
|
// extern cTrkCalib pedsigbad_; |
|
|
// extern cTrkMask mask_; |
|
|
|
|
|
cout << "--------------------------------------"<<endl; |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
|
551 |
// ============================================================= |
// ============================================================= |
552 |
// retrieve calibration file needed to reduce data |
// retrieve calibration file needed to reduce data |
553 |
// ============================================================= |
// ============================================================= |
554 |
// if run OBT is > last calibration "expiration date" |
// if run OBT is > last calibration "expiration date" |
555 |
// - search for new calibration packet |
// - search for new calibration packet |
556 |
// - load calibration parameters (full + truncated) |
// - load calibration parameters (full + truncated) |
557 |
cout << "Full pedestals for cluster finding:"; |
if(TrkParams::VerboseMode()){ |
558 |
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
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 |
FileStat_t t; |
FileStat_t t; |
564 |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
565 |
|
|
566 |
TFile *f0_c = new TFile(calibpathf); |
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 |
if ( !f0_c ) return false; |
if ( !f0_c ) return false; |
572 |
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
|
573 |
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
if(TrkParams::VerboseMode()){ |
574 |
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
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 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
579 |
|
if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl; |
580 |
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; |
|
581 |
|
|
|
// }; |
|
582 |
// ============================================================= |
// ============================================================= |
583 |
// retrieve calibration file needed to uncompress data |
// retrieve calibration file needed to uncompress data |
584 |
// ============================================================= |
// ============================================================= |
585 |
// if the run was compressed using default calib |
// if the run was compressed using default calib |
586 |
// load truncated pedestals from default |
// load truncated pedestals from default |
587 |
// otherwise reload them from on-line calibration |
// otherwise reload them from on-line calibration |
588 |
cout << "Truncated pedestals for uncompression:"; |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
589 |
if( calib104 ){ |
if( calib104 ){ |
590 |
|
|
591 |
cout << " >> Loading default calibration: "<< calibpatht << endl; |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
|
// ca->FillTCalibFrom(calibpatht); |
|
592 |
TrkParams::FillTCalibFrom(calibpatht); |
TrkParams::FillTCalibFrom(calibpatht); |
593 |
|
|
594 |
}else{ |
}else{ |
595 |
|
|
596 |
if ( !f0_c ) return false; |
// if ( !f0_c ) return false; |
597 |
cout << ">> Loading on-line calibration " << endl; |
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
598 |
// 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); |
|
599 |
}; |
}; |
600 |
for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
if(!alreadyopened)f0_c->Close(); |
601 |
f0_c->Close(); |
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
|
// delete f0_c; |
|
|
cout << "--------------------------------------"<<endl; |
|
602 |
|
|
603 |
calibload = kTRUE; |
calibload = kTRUE; |
604 |
return true; |
return true; |
622 |
*/ |
*/ |
623 |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
624 |
|
|
|
// if( !dbc )return false; |
|
|
|
|
|
|
|
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
625 |
|
|
626 |
UInt_t index = TrkParams::GetIndex( type ); |
UInt_t index = TrkParams::GetIndex( type ); |
627 |
if(index < 0)return false; |
if(index < 0)return false; |
628 |
|
|
629 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
UInt_t runheadtime=0; |
630 |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
UInt_t runid=0; |
631 |
else cout <<"Missing run info -- taking last entry "<<endl; |
// 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 |
|
if( !TrkParams::IsLoaded(type) || |
642 |
|
runheadtime < gl[index].FROM_TIME || |
643 |
|
runheadtime > gl[index].TO_TIME || |
644 |
|
false ){ |
645 |
|
|
646 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
647 |
|
|
648 |
|
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 |
|
stringstream myquery; // EMILIANO |
672 |
|
myquery.str(""); // EMILIANO |
673 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
674 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
675 |
|
if(TrkParams::VerboseMode()){ |
676 |
|
cout << " ...done"<<endl; |
677 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
678 |
|
} |
679 |
|
} |
680 |
|
|
681 |
GL_PARAM q4; |
GL_PARAM q4; |
682 |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
683 |
|
|
684 |
gl[index] = q4; |
gl[index] = q4; |
685 |
glpath[index] = q4.PATH+q4.NAME; |
glpath[index] = q4.PATH+q4.NAME; |
686 |
glload[index] = false; |
glload[index] = false; |
687 |
cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
|
688 |
return true; |
return true; |
689 |
// return TrkParams::Load(type); |
|
690 |
|
} |
691 |
|
return false; |
692 |
|
|
693 |
}; |
}; |
694 |
/** |
/** |
704 |
|
|
705 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
706 |
glpath[index] = path; |
glpath[index] = path; |
707 |
cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode()) |
708 |
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
709 |
glload[index] = false; |
glload[index] = false; |
710 |
|
|
711 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
721 |
*/ |
*/ |
722 |
Bool_t TrkParams::Set(UInt_t type){ |
Bool_t TrkParams::Set(UInt_t type){ |
723 |
|
|
|
UInt_t index = TrkParams::GetIndex( type ); |
|
|
if(index < 0)return false; |
|
724 |
|
|
725 |
gl[index].TYPE= type; |
return Set(0,0,type); |
|
glload[index] = false; |
|
726 |
|
|
727 |
// ----------------------------------------- |
// UInt_t index = TrkParams::GetIndex( type ); |
728 |
// check if enviroment variables are defined |
// if(index < 0)return false; |
|
// ----------------------------------------- |
|
|
glpath[index] = gSystem->Getenv("PAM_CALIB"); |
|
729 |
|
|
730 |
if( !glpath[index].IsNull() ){ |
// gl[index].TYPE= type; |
731 |
|
// glload[index] = false; |
732 |
|
|
733 |
|
// // ----------------------------------------- |
734 |
|
// // check if enviroment variables are defined |
735 |
|
// // ----------------------------------------- |
736 |
|
// glpath[index] = gSystem->Getenv("PAM_CALIB"); |
737 |
|
|
738 |
|
// if( !glpath[index].IsNull() ){ |
739 |
|
|
740 |
switch(type){ |
// switch(type){ |
741 |
case 1: |
// case 1: |
742 |
glpath[index].Append("/trk-param/field_param-0/"); |
// glpath[index].Append("/trk-param/field_param-0/"); |
743 |
break; |
// break; |
744 |
case 2: |
// case 2: |
745 |
glpath[index].Append("/trk-param/mip_param-0/"); |
// glpath[index].Append("/trk-param/mip_param-0/"); |
746 |
break; |
// break; |
747 |
case 3: |
// case 3: |
748 |
glpath[index].Append("/trk-param/charge_param-1/"); |
// glpath[index].Append("/trk-param/charge_param-1/"); |
749 |
break; |
// break; |
750 |
case 4: |
// case 4: |
751 |
glpath[index].Append("/trk-param/eta_param-0/"); |
// glpath[index].Append("/trk-param/eta_param-2/"); |
752 |
break; |
// break; |
753 |
case 5: |
// case 5: |
754 |
glpath[index].Append("/trk-param/align_param-0/"); |
// glpath[index].Append("/trk-param/align_param-Q.A/"); |
755 |
break; |
// break; |
756 |
case 6: |
// case 6: |
757 |
glpath[index].Append("/trk-param/mask_param-1/"); |
// glpath[index].Append("/trk-param/mask_param-1/"); |
758 |
break; |
// break; |
759 |
case 7: |
// case 7: |
760 |
glpath[index].Append("/trk-param/default_calib/"); |
// glpath[index].Append("/trk-param/default_calib/"); |
761 |
break; |
// break; |
762 |
} |
// } |
763 |
|
|
764 |
}else{ |
// }else{ |
765 |
cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
// cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
766 |
return false; |
// return false; |
767 |
|
|
768 |
} |
// } |
769 |
|
|
770 |
cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
// // if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >>"<<endl; |
771 |
// return TrkParams::Load(type); |
// cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB + default path) >> **WARNING** does not use DB info !!!!"<<endl; |
772 |
return true; |
|
773 |
|
// // return TrkParams::Load(type); |
774 |
|
// return true; |
775 |
|
|
776 |
}; |
}; |
777 |
/** |
/** |
782 |
*/ |
*/ |
783 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
784 |
|
|
785 |
Bool_t connected = false; |
// Bool_t connected = false; |
786 |
|
// cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
787 |
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
// TString host = "mysql://localhost/pamelaprod"; |
788 |
TString host = "mysql://localhost/pamelaprod"; |
// TString user = "anonymous"; |
789 |
TString user = "anonymous"; |
// TString psw = ""; |
790 |
TString psw = ""; |
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
791 |
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
792 |
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
793 |
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
// if ( !pamdbhost ) pamdbhost = ""; |
794 |
if ( !pamdbhost ) pamdbhost = ""; |
// if ( !pamdbuser ) pamdbuser = ""; |
795 |
if ( !pamdbuser ) pamdbuser = ""; |
// if ( !pamdbpsw ) pamdbpsw = ""; |
796 |
if ( !pamdbpsw ) pamdbpsw = ""; |
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
797 |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
798 |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
799 |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
// if(TrkParams::VerboseMode()){ |
800 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
801 |
cout<<"Connecting to DB"<<endl; |
// cout<<"Connecting to DB"<<endl; |
802 |
cout<<"HOST "<<host<<endl; |
// cout<<"HOST "<<host<<endl; |
803 |
cout<<"USER "<<user<<endl; |
// cout<<"USER "<<user<<endl; |
804 |
cout<<"PSW "<<psw<<endl; |
// cout<<"PSW "<<psw<<endl; |
805 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
// } |
806 |
if( dbc || dbc->IsConnected() )connected = true; |
// TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
807 |
else cout << " >> FAILED!!!"<<endl; |
// if( dbc || dbc->IsConnected() )connected = true; |
808 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
// else cout << " >> DB connection FAILED!!!"<<endl; |
809 |
|
// if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
810 |
|
|
811 |
if(connected){ |
// if(connected){ |
812 |
if ( !TrkParams::Set(0,dbc) )return false; |
// if ( !TrkParams::Set(0,dbc) )return false; |
813 |
dbc->Close(); |
// dbc->Close(); |
814 |
}else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
// }else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
815 |
|
|
816 |
|
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
817 |
|
|
818 |
|
return true; |
819 |
} |
} |
820 |
|
|
821 |
/** |
/** |
834 |
switch( type ){ |
switch( type ){ |
835 |
//------------------------------------------ |
//------------------------------------------ |
836 |
case 1: |
case 1: |
837 |
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
838 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
839 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
840 |
path_.error = 0; |
path_.error = 0; |
844 |
break; |
break; |
845 |
//------------------------------------------ |
//------------------------------------------ |
846 |
case 2: |
case 2: |
847 |
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; |
848 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
849 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
850 |
path_.error = 0; |
path_.error = 0; |
854 |
break; |
break; |
855 |
//------------------------------------------ |
//------------------------------------------ |
856 |
case 3: |
case 3: |
857 |
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
858 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
859 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
860 |
path_.error = 0; |
path_.error = 0; |
864 |
break; |
break; |
865 |
//------------------------------------------ |
//------------------------------------------ |
866 |
case 4: |
case 4: |
867 |
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
868 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
869 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
870 |
path_.error = 0; |
path_.error = 0; |
874 |
break; |
break; |
875 |
//------------------------------------------ |
//------------------------------------------ |
876 |
case 5: |
case 5: |
877 |
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
878 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
879 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
880 |
path_.error = 0; |
path_.error = 0; |
884 |
break; |
break; |
885 |
//------------------------------------------ |
//------------------------------------------ |
886 |
case 6: |
case 6: |
887 |
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
888 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
889 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
890 |
path_.error = 0; |
path_.error = 0; |
894 |
break; |
break; |
895 |
//------------------------------------------ |
//------------------------------------------ |
896 |
case 7: |
case 7: |
897 |
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
898 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
899 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
900 |
path_.error = 0; |
path_.error = 0; |
901 |
// fillpedsigfromdefault_(); |
// fillpedsigfromdefault_(); |
902 |
cout << ">> not implemented <<"<<endl; |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
903 |
if(path_.error) return false; |
if(path_.error) return false; |
904 |
glload[index]=true; |
glload[index]=true; |
905 |
break; |
break; |
906 |
default: |
default: |
907 |
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; |
908 |
return false; |
return false; |
909 |
}; |
}; |
910 |
|
|
920 |
return true; |
return true; |
921 |
}; |
}; |
922 |
|
|
923 |
|
|
924 |
|
/** |
925 |
|
* Get BY (kGauss) |
926 |
|
* @param v (x,y,z) coordinates in cm |
927 |
|
*/ |
928 |
|
float TrkParams::GetBX(float* v){ |
929 |
|
TrkParams::Load(1); |
930 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
931 |
|
float b[3]; |
932 |
|
gufld_(v,b); |
933 |
|
return b[0]/10.; |
934 |
|
} |
935 |
|
/** |
936 |
|
* Get BY (kGauss) |
937 |
|
* @param v (x,y,z) coordinates in cm |
938 |
|
*/ |
939 |
|
float TrkParams::GetBY(float* v){ |
940 |
|
TrkParams::Load(1); |
941 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
942 |
|
float b[3]; |
943 |
|
gufld_(v,b); |
944 |
|
return b[1]/10.; |
945 |
|
} |
946 |
|
/** |
947 |
|
* Get BY (kGauss) |
948 |
|
* @param v (x,y,z) coordinates in cm |
949 |
|
*/ |
950 |
|
float TrkParams::GetBZ(float* v){ |
951 |
|
TrkParams::Load(1); |
952 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
953 |
|
float b[3]; |
954 |
|
gufld_(v,b); |
955 |
|
return b[2]/10.; |
956 |
|
} |
957 |
|
|
958 |
|
|
959 |
|
|
960 |
|
/** |
961 |
|
* \brief Set tracking mode (0=standard. 1=???) |
962 |
|
*/ |
963 |
|
void TrkParams::SetTrackingMode(int trackmode) { |
964 |
|
init__mini_trackmode = trackmode; |
965 |
|
SetTrackingMode(); |
966 |
|
}; |
967 |
|
/** |
968 |
|
* \brief Set fit-precision factor (typical value fact=100.) |
969 |
|
*/ |
970 |
|
void TrkParams::SetPrecisionFactor(double fact){ |
971 |
|
init__mini_fact = fact; |
972 |
|
SetPrecisionFactor(); |
973 |
|
}; |
974 |
|
/** |
975 |
|
* \brief Set minimum number of step in track fitting |
976 |
|
*/ |
977 |
|
void TrkParams::SetStepMin(int istepmin){ |
978 |
|
init__mini_istepmin = istepmin; |
979 |
|
SetStepMin(); |
980 |
|
}; |
981 |
|
|
982 |
|
/** |
983 |
|
* Fill F77 commons with PFA settings |
984 |
|
*/ |
985 |
|
void TrkParams::SetPFA(){ |
986 |
|
sw_.pfaid = init__pfa; |
987 |
|
for(int i=0; i<6; i++){ |
988 |
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
989 |
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
990 |
|
} |
991 |
|
}; |
992 |
|
/** |
993 |
|
* \brief Set p.f.a. |
994 |
|
* |
995 |
|
* Implemented algorythms: |
996 |
|
* 0 ETA |
997 |
|
* 1 --- |
998 |
|
* 2 ETA2 |
999 |
|
* 3 ETA3 |
1000 |
|
* 4 ETA4 |
1001 |
|
* 5 ETAL ==> ETA+LANDI |
1002 |
|
* 10 COG |
1003 |
|
* 11 COG1 |
1004 |
|
* 12 COG2 |
1005 |
|
* 13 COG3 |
1006 |
|
* 14 COG4 |
1007 |
|
*/ |
1008 |
|
void TrkParams::SetPFA(int pfaid){ |
1009 |
|
init__pfa = pfaid; |
1010 |
|
SetPFA(); |
1011 |
|
}; |
1012 |
|
/** |
1013 |
|
* \brief Set p.f.a. angular intervals |
1014 |
|
* |
1015 |
|
* This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4 |
1016 |
|
* algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)). |
1017 |
|
* @param v Pointer to a vector of 12 components, which represent the |
1018 |
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
1019 |
|
* |
1020 |
|
*/ |
1021 |
|
void TrkParams::SetPFA(float *v){ |
1022 |
|
for(int i=0; i<6; i++){ |
1023 |
|
init__pfa_e234ax[i] = v[i]; |
1024 |
|
init__pfa_e234ay[i] = v[i+6]; |
1025 |
|
} |
1026 |
|
SetPFA(); |
1027 |
|
}; |
1028 |
|
|
1029 |
|
|
1030 |
|
/** |
1031 |
|
* \brief Get spatial resolution. |
1032 |
|
* |
1033 |
|
* Method to retrieve the spatial resolution associated with the |
1034 |
|
* adopted p.f.a. |
1035 |
|
* @param view Tracker view (1-12) |
1036 |
|
* @param angle Track projected angle |
1037 |
|
* |
1038 |
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
1039 |
|
* |
1040 |
|
* TrkParams::SetPFA(0) // ETA |
1041 |
|
* |
1042 |
|
*/ |
1043 |
|
float TrkParams::GetResolution(int view, float angle){ |
1044 |
|
float res = 1000; |
1045 |
|
if( init__pfa == 0 )res = riseta_(&view,&angle); |
1046 |
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
1047 |
|
return res; |
1048 |
|
} |
1049 |
|
|
1050 |
|
|
1051 |
|
|
1052 |
|
|
1053 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |