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__mini_trackmode = 0; |
33 |
|
int TrkParams::init__mini_istepmin = 5; //3; |
34 |
|
double TrkParams::init__mini_fact = 1.e4; //100.; |
35 |
|
float TrkParams::init__pfa_e234ax[] = {0.,10.,10.,15.,15.,90.}; |
36 |
|
float TrkParams::init__pfa_e234ay[] = {0.,20.,90.,90.,90.,90.}; |
37 |
|
|
38 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
39 |
|
|
54 |
return ret1; |
return ret1; |
55 |
} |
} |
56 |
/** |
/** |
57 |
* Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
58 |
|
|
59 |
* It retrieves the calibration associated to a given run, from |
* It retrieves the calibration associated to a given run, from |
60 |
* a given DB. It fills the F77 common. |
* a given DB. It fills the F77 common. |
63 |
*/ |
*/ |
64 |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
65 |
|
|
66 |
GL_TRK_CALIB q2; |
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
|
GL_ROOT q3; |
|
|
GL_PARAM q4; |
|
|
|
|
|
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) )return false; |
|
|
if(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); |
|
|
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false; |
|
|
|
|
|
calib = q2; |
|
|
calibpathf = q3.PATH + q3.NAME; |
|
|
calib104 = (glrun->TRK_CALIB_USED==104); |
|
|
calibload = kFALSE; |
|
|
if(calib104){ |
|
|
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
|
|
calibpatht = q4.PATH + q4.NAME; |
|
|
} |
|
67 |
|
|
68 |
|
if( !CalibIsLoaded() || |
69 |
|
(glrun->TRK_CALIB_USED==104 && !calib104) || |
70 |
|
(glrun->TRK_CALIB_USED!=104 && calib104) || |
71 |
|
glrun->RUNHEADER_TIME < calib.FROM_TIME || |
72 |
|
glrun->RUNHEADER_TIME > calib.TO_TIME || |
73 |
|
false ){ |
74 |
|
|
75 |
|
// cout <<">>> isloaded? "<< CalibIsLoaded() << endl; |
76 |
|
// cout <<">>> trk_calib_used "<< glrun->TRK_CALIB_USED<<endl; |
77 |
|
// cout <<">>> 104 loaded? "<< calib104 <<endl; |
78 |
|
// cout <<">>> from time "<< calib.FROM_TIME<<endl; |
79 |
|
// cout <<">>> to time "<< calib.TO_TIME<<endl; |
80 |
|
// if( !dbc || (dbc && !dbc->IsConnected()) ){ |
81 |
|
|
82 |
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
83 |
|
// TString host = "mysql://localhost/pamelaprod"; |
84 |
|
// TString user = "anonymous"; |
85 |
|
// TString psw = ""; |
86 |
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
87 |
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
88 |
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
89 |
|
// if ( !pamdbhost ) pamdbhost = ""; |
90 |
|
// if ( !pamdbuser ) pamdbuser = ""; |
91 |
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
92 |
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
93 |
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
94 |
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
95 |
|
// if(TrkParams::VerboseMode()){ |
96 |
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
97 |
|
// cout<<"Connecting to DB"<<endl; |
98 |
|
// cout<<"HOST "<<host<<endl; |
99 |
|
// cout<<"USER "<<user<<endl; |
100 |
|
// cout<<"PSW "<<psw<<endl; |
101 |
|
// } |
102 |
|
// dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
103 |
|
// if( !dbc )return false; |
104 |
|
// if( !dbc->IsConnected() )return false; |
105 |
|
// if(TrkParams::VerboseMode()){ |
106 |
|
// cout << " ...done"<<endl; |
107 |
|
// cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
108 |
|
// } |
109 |
|
// } |
110 |
|
|
111 |
|
GL_TRK_CALIB q2; |
112 |
|
GL_ROOT q3; |
113 |
|
GL_PARAM q4; |
114 |
|
|
115 |
|
if(TrkParams::VerboseMode()){ |
116 |
|
cout << "--------------------------------------"<<endl; |
117 |
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
118 |
|
} |
119 |
|
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
120 |
|
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
121 |
|
return false; |
122 |
|
} |
123 |
|
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
124 |
|
printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
125 |
|
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
126 |
|
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
127 |
|
return false; |
128 |
|
} |
129 |
|
|
130 |
|
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
131 |
|
calib = q2; |
132 |
|
calibpathf = q3.PATH + q3.NAME; |
133 |
|
calib104 = (glrun->TRK_CALIB_USED==104); |
134 |
|
calibload = kFALSE; |
135 |
|
if(calib104){ |
136 |
|
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
137 |
|
calibpatht = q4.PATH + q4.NAME; |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
142 |
return true; |
return true; |
143 |
|
} |
144 |
|
|
145 |
|
return false; |
146 |
}; |
}; |
147 |
|
|
148 |
/** |
/** |
149 |
|
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
150 |
|
* in YodaProfiler. |
151 |
|
*/ |
152 |
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
153 |
|
|
154 |
|
UInt_t validate = 1; |
155 |
|
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
156 |
|
// UInt_t timeaftercalib=120000; //2000; |
157 |
|
TString classname = caltrk->GetName(); |
158 |
|
// ---------- |
159 |
|
// Check CRCs |
160 |
|
// ---------- |
161 |
|
if(TrkParams::VerboseMode())cout << " DSP: "; |
162 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
163 |
|
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
164 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
165 |
|
if( caltrk->crc_hcal[ipkt] ){ |
166 |
|
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
167 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
168 |
|
// return 0; // :-( |
169 |
|
validate = 0; |
170 |
|
} |
171 |
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
172 |
|
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
173 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
174 |
|
// return 0; // :-( |
175 |
|
validate = 0; |
176 |
|
} |
177 |
|
} |
178 |
|
} |
179 |
|
if(TrkParams::VerboseMode())cout << endl;; |
180 |
|
// ----------------------- |
181 |
|
// Check missing packets: |
182 |
|
// ----------------------- |
183 |
|
// Readout order: |
184 |
|
// ------------------ |
185 |
|
// DSP packet board |
186 |
|
// ------------------ |
187 |
|
// 12 0 1 |
188 |
|
// 10 1 1 |
189 |
|
// 8 2 1 |
190 |
|
// 4 3 1 |
191 |
|
// 6 4 1 |
192 |
|
// 2 5 1 |
193 |
|
// ------------------ |
194 |
|
// 11 0 2 |
195 |
|
// 9 1 2 |
196 |
|
// 7 2 2 |
197 |
|
// 3 3 2 |
198 |
|
// 5 4 2 |
199 |
|
// 1 5 2 |
200 |
|
// ------------------ |
201 |
|
// ------------------------------------------------- |
202 |
|
// Check if it is first or second calibration packet |
203 |
|
// ------------------------------------------------- |
204 |
|
UInt_t build=0; |
205 |
|
UInt_t base=0; |
206 |
|
UInt_t mask=0; |
207 |
|
if(classname.Contains("CalibTrk1Event")){ |
208 |
|
base=12; |
209 |
|
mask=0x03F000; |
210 |
|
} |
211 |
|
if(classname.Contains("CalibTrk2Event")){ |
212 |
|
base=18; |
213 |
|
mask=0xFC0000; |
214 |
|
} |
215 |
|
// ------------------------------------------------- |
216 |
|
// Count number of packets and set build variable |
217 |
|
// ------------------------------------------------- |
218 |
|
Int_t npkts=0; |
219 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
220 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
221 |
|
npkts++; |
222 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
223 |
|
}; |
224 |
|
} |
225 |
|
if( npkts==6 ){}//return 1; // :-) |
226 |
|
else { |
227 |
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
228 |
|
validate = 0; |
229 |
|
} |
230 |
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
231 |
|
|
232 |
|
// ----------------------------------------------- |
233 |
|
// If missing packets: check the acq configuration |
234 |
|
// (some DSPs might be excluded from acquisition) |
235 |
|
// ----------------------------------------------- |
236 |
|
|
237 |
|
// ----------------------------------------------- |
238 |
|
// retrieve the first run header after calib |
239 |
|
// ----------------------------------------------- |
240 |
|
// PacketType *pctp; |
241 |
|
// EventCounter *cod; |
242 |
|
// cod = eh->GetCounter(); |
243 |
|
// Int_t irun = cod->Get(pctp->RunHeader); |
244 |
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
245 |
|
// if ( !rh || rh->IsZombie() ) throw -17; |
246 |
|
// if( rh->GetEntries() == irun ){ |
247 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
248 |
|
// return 0; // :-( |
249 |
|
// } |
250 |
|
|
251 |
|
// RunHeaderEvent *run = 0; |
252 |
|
// EventHeader *hrun = 0; |
253 |
|
// rh->SetBranchAddress("RunHeader", &run); |
254 |
|
// rh->SetBranchAddress("Header", &hrun); |
255 |
|
// rh->GetEntry(irun); |
256 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
257 |
|
|
258 |
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
259 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
260 |
|
// return 0; // :-( |
261 |
|
// } |
262 |
|
|
263 |
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
264 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
265 |
|
// return 0; // :-( |
266 |
|
// } |
267 |
|
|
268 |
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
269 |
|
// if( dtime > timeaftercalib ){ |
270 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
271 |
|
// return 0; // :-( |
272 |
|
// } |
273 |
|
|
274 |
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
275 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
276 |
|
// return 0; // :-( |
277 |
|
// } |
278 |
|
|
279 |
|
// return 1; // :-) |
280 |
|
|
281 |
|
// cout << validate << endl; |
282 |
|
return validate; |
283 |
|
|
284 |
|
} |
285 |
|
/** |
286 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
287 |
*/ |
*/ |
288 |
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){ |
289 |
|
|
290 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
291 |
|
ca->Reset(); |
292 |
|
|
293 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
294 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
300 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
301 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
302 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
303 |
|
|
304 |
|
// --- TEST TEST TEST TEST --- // |
305 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
306 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
307 |
|
|
308 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
309 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
310 |
|
if( !test1 || !test2 ){ |
311 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
312 |
|
TrkParams::calib.VALIDATION = 0; |
313 |
|
} |
314 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
315 |
|
|
316 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
317 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
318 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
319 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
320 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
321 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
322 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
323 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
324 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
325 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
326 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
327 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
328 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
329 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->bad[jj][j][dspn1]=1; |
330 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
else if(calibdata1->DSPbad_par[i][ii]==1) |
331 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=0; |
332 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
333 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
334 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
} |
335 |
|
|
336 |
// |
if(dspn2>=0 && dspn2<12){ |
337 |
// invert the bad |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
338 |
// |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
339 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
340 |
ca->bad[jj][j][dspn1]=1; |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
341 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
if(calibdata2->DSPbad_par[i][ii]==0) |
342 |
ca->bad[jj][j][dspn1]=0; |
ca->bad[jj][j][dspn2]=1; |
343 |
if(calibdata2->DSPbad_par[i][ii]==0) |
else if(calibdata2->DSPbad_par[i][ii]==1) |
344 |
ca->bad[jj][j][dspn2]=1; |
ca->bad[jj][j][dspn2]=0; |
345 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
346 |
ca->bad[jj][j][dspn2]=0; |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
347 |
|
} |
348 |
}; |
}; |
349 |
}; |
}; |
350 |
|
|
357 |
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){ |
358 |
|
|
359 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
360 |
|
// ca->Reset(); |
361 |
|
|
362 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
363 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
369 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
370 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
371 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
372 |
|
|
373 |
|
// --- TEST TEST TEST TEST --- // |
374 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
375 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
376 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
377 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
378 |
|
if( !test1 || !test2 ){ |
379 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
380 |
|
TrkParams::calib.VALIDATION = 0; |
381 |
|
} |
382 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
383 |
|
|
384 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
385 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
388 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
389 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
390 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
391 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
392 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
393 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
394 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
395 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=1; |
396 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
else if(calibdata1->DSPbad_par[i][ii]==1) |
397 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
ca->bad[jj][j][dspn1]=0; |
398 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
399 |
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
400 |
// |
} |
401 |
// invert the bad |
if(dspn2>=0 && dspn2<12){ |
402 |
// |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
403 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
404 |
ca->bad[jj][j][dspn1]=1; |
if(calibdata2->DSPbad_par[i][ii]==0) |
405 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
ca->bad[jj][j][dspn2]=1; |
406 |
ca->bad[jj][j][dspn1]=0; |
else if(calibdata2->DSPbad_par[i][ii]==1) |
407 |
if(calibdata2->DSPbad_par[i][ii]==0) |
ca->bad[jj][j][dspn2]=0; |
408 |
ca->bad[jj][j][dspn2]=1; |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
409 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
410 |
ca->bad[jj][j][dspn2]=0; |
} |
411 |
}; |
}; |
412 |
}; |
}; |
413 |
|
|
420 |
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){ |
421 |
|
|
422 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
423 |
|
// ca->Reset(); |
424 |
|
|
425 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
426 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
433 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
434 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
435 |
|
|
436 |
|
// --- TEST TEST TEST TEST --- // |
437 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
438 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
439 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
440 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
441 |
|
if( !test1 || !test2 ){ |
442 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
443 |
|
TrkParams::calib.VALIDATION = 0; |
444 |
|
} |
445 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
446 |
|
|
447 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
448 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
449 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
451 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
452 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
453 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
454 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
if(dspn1>=0 && dspn1<12){ |
455 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
456 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
457 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
} |
458 |
|
if(dspn2>=0 && dspn2<12){ |
459 |
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
460 |
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
461 |
|
} |
462 |
}; |
}; |
463 |
}; |
}; |
464 |
|
|
481 |
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){ |
482 |
|
|
483 |
cTrkMask *ma = &mask_; |
cTrkMask *ma = &mask_; |
484 |
|
ma->Reset(); |
485 |
|
|
486 |
TrkCalib *calib = new TrkCalib(); |
TrkCalib *calib = new TrkCalib(); |
487 |
|
|
504 |
tr->GetEntry(ev_reg2); |
tr->GetEntry(ev_reg2); |
505 |
} |
} |
506 |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
507 |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
Int_t view = calib->GetView(ipkt); |
508 |
Int_t view = calib->GetView(ipkt); |
if( (view-1)>= 0 && (view-1)<12 ){ |
509 |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
510 |
Float_t sigmin = 0.; |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
511 |
if(view%2)sigmin = 6.5; |
Float_t sigmin = 0.; |
512 |
else sigmin = 2.5; |
if(view%2)sigmin = 6.5; |
513 |
Int_t mask = 1; |
else sigmin = 2.5; |
514 |
if( sigm<sigmin )mask = 0; |
Int_t mask = 1; |
515 |
|
if( sigm<sigmin )mask = 0; |
516 |
ma->mask_vk_run[ivk][view-1] = mask; |
ma->mask_vk_run[ivk][view-1] = mask; |
517 |
|
} |
518 |
// if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl; |
} |
|
} |
|
519 |
} |
} |
520 |
if(tr)tr->Delete(); |
if(tr)tr->Delete(); |
521 |
} |
} |
522 |
|
|
523 |
|
if(TrkParams::VerboseMode()){ |
524 |
|
for(Int_t iv=0; iv<NVIEW; iv++){ |
525 |
|
cout<<"view "<<setw(3)<<iv<<": "; |
526 |
|
for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv]; |
527 |
|
cout << endl; |
528 |
|
} |
529 |
|
} |
530 |
|
|
531 |
if(calib)calib->Delete(); |
if(calib)calib->Delete(); |
532 |
|
|
533 |
}; |
}; |
534 |
|
|
535 |
|
// Bool_t TrkParams::CalibIsLoaded(UInt_t time){ |
536 |
|
|
537 |
|
// if( !calibload ) return false; |
538 |
|
|
539 |
|
// }; |
540 |
|
|
541 |
|
|
542 |
/** |
/** |
543 |
* Static method to load calibration. |
* \brief Static method to load calibration. |
544 |
* 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. |
|
545 |
*/ |
*/ |
546 |
Bool_t TrkParams::LoadCalib( ){ |
Bool_t TrkParams::LoadCalib( ){ |
547 |
|
|
548 |
if( TrkParams::CalibIsLoaded() )return false; |
if( TrkParams::CalibIsLoaded() )return false; |
549 |
|
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
|
|
|
|
|
// extern cTrkCalib pedsigbad_; |
|
|
// extern cTrkMask mask_; |
|
|
|
|
|
cout << "--------------------------------------"<<endl; |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
|
550 |
// ============================================================= |
// ============================================================= |
551 |
// retrieve calibration file needed to reduce data |
// retrieve calibration file needed to reduce data |
552 |
// ============================================================= |
// ============================================================= |
553 |
// if run OBT is > last calibration "expiration date" |
// if run OBT is > last calibration "expiration date" |
554 |
// - search for new calibration packet |
// - search for new calibration packet |
555 |
// - load calibration parameters (full + truncated) |
// - load calibration parameters (full + truncated) |
556 |
cout << "Full pedestals for cluster finding:"; |
if(TrkParams::VerboseMode()){ |
557 |
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
cout << "--------------------------------------"<<endl; |
558 |
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
559 |
|
cout << " Full pedestals for cluster finding:"; |
560 |
|
cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; |
561 |
|
} |
562 |
FileStat_t t; |
FileStat_t t; |
563 |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
564 |
|
|
565 |
TFile *f0_c = new TFile(calibpathf); |
bool alreadyopened = false; |
566 |
|
TFile *f0_c=0; |
567 |
|
f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); |
568 |
|
if(f0_c)alreadyopened=true; |
569 |
|
else f0_c = new TFile(calibpathf); |
570 |
if ( !f0_c ) return false; |
if ( !f0_c ) return false; |
571 |
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
|
572 |
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
if(TrkParams::VerboseMode()){ |
573 |
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
574 |
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
575 |
|
cout << " - full+truncated parameters "<<endl; |
576 |
|
} |
577 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
578 |
|
if(TrkParams::VerboseMode())cout << " - VK-mask "<<endl; |
579 |
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; |
|
580 |
|
|
|
// }; |
|
581 |
// ============================================================= |
// ============================================================= |
582 |
// retrieve calibration file needed to uncompress data |
// retrieve calibration file needed to uncompress data |
583 |
// ============================================================= |
// ============================================================= |
584 |
// if the run was compressed using default calib |
// if the run was compressed using default calib |
585 |
// load truncated pedestals from default |
// load truncated pedestals from default |
586 |
// otherwise reload them from on-line calibration |
// otherwise reload them from on-line calibration |
587 |
cout << "Truncated pedestals for uncompression:"; |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
588 |
if( calib104 ){ |
if( calib104 ){ |
589 |
|
|
590 |
cout << " >> Loading default calibration: "<< calibpatht << endl; |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
|
// ca->FillTCalibFrom(calibpatht); |
|
591 |
TrkParams::FillTCalibFrom(calibpatht); |
TrkParams::FillTCalibFrom(calibpatht); |
592 |
|
|
593 |
}else{ |
}else{ |
594 |
|
|
595 |
if ( !f0_c ) return false; |
// if ( !f0_c ) return false; |
596 |
cout << ">> Loading on-line calibration " << endl; |
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
597 |
// 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); |
|
598 |
}; |
}; |
599 |
for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
if(!alreadyopened)f0_c->Close(); |
600 |
f0_c->Close(); |
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
|
// delete f0_c; |
|
|
cout << "--------------------------------------"<<endl; |
|
601 |
|
|
602 |
calibload = kTRUE; |
calibload = kTRUE; |
603 |
return true; |
return true; |
621 |
*/ |
*/ |
622 |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
623 |
|
|
|
// 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; |
|
|
|
|
|
} |
|
624 |
|
|
625 |
UInt_t index = TrkParams::GetIndex( type ); |
UInt_t index = TrkParams::GetIndex( type ); |
626 |
if(index < 0)return false; |
if(index < 0)return false; |
627 |
|
|
628 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
if( !TrkParams::IsLoaded(type) || |
629 |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
glrun->RUNHEADER_TIME < gl[index].FROM_TIME || |
630 |
else cout <<"Missing run info -- taking last entry "<<endl; |
glrun->RUNHEADER_TIME > gl[index].TO_TIME || |
631 |
|
false ){ |
632 |
|
|
633 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
634 |
|
|
635 |
|
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
636 |
|
TString host = "mysql://localhost/pamelaprod"; |
637 |
|
TString user = "anonymous"; |
638 |
|
TString psw = ""; |
639 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
640 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
641 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
642 |
|
if ( !pamdbhost ) pamdbhost = ""; |
643 |
|
if ( !pamdbuser ) pamdbuser = ""; |
644 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
645 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
646 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
647 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
648 |
|
if(TrkParams::VerboseMode()){ |
649 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
650 |
|
cout<<"Connecting to DB"<<endl; |
651 |
|
cout<<"HOST "<<host<<endl; |
652 |
|
cout<<"USER "<<user<<endl; |
653 |
|
cout<<"PSW "<<psw<<endl; |
654 |
|
} |
655 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
656 |
|
if( !dbc )return false; |
657 |
|
if( !dbc->IsConnected() )return false; |
658 |
|
if(TrkParams::VerboseMode()){ |
659 |
|
cout << " ...done"<<endl; |
660 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
661 |
|
} |
662 |
|
} |
663 |
|
|
|
GL_PARAM q4; |
|
|
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
|
664 |
|
|
665 |
gl[index] = q4; |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
666 |
glpath[index] = q4.PATH+q4.NAME; |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
667 |
glload[index] = false; |
else cout <<"Missing run info -- taking last entry "<<endl; |
668 |
cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
|
669 |
return true; |
GL_PARAM q4; |
670 |
// return TrkParams::Load(type); |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
671 |
|
|
672 |
|
gl[index] = q4; |
673 |
|
glpath[index] = q4.PATH+q4.NAME; |
674 |
|
glload[index] = false; |
675 |
|
if(TrkParams::VerboseMode()) |
676 |
|
cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<glrun->ID<<endl; |
677 |
|
return true; |
678 |
|
|
679 |
|
} |
680 |
|
return false; |
681 |
|
|
682 |
}; |
}; |
683 |
/** |
/** |
693 |
|
|
694 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
695 |
glpath[index] = path; |
glpath[index] = path; |
696 |
cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode()) |
697 |
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
698 |
glload[index] = false; |
glload[index] = false; |
699 |
|
|
700 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
753 |
|
|
754 |
} |
} |
755 |
|
|
756 |
cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
757 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
758 |
return true; |
return true; |
759 |
|
|
768 |
|
|
769 |
Bool_t connected = false; |
Bool_t connected = false; |
770 |
|
|
771 |
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
// cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
772 |
TString host = "mysql://localhost/pamelaprod"; |
TString host = "mysql://localhost/pamelaprod"; |
773 |
TString user = "anonymous"; |
TString user = "anonymous"; |
774 |
TString psw = ""; |
TString psw = ""; |
781 |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
782 |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
783 |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
784 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
if(TrkParams::VerboseMode()){ |
785 |
cout<<"Connecting to DB"<<endl; |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
786 |
cout<<"HOST "<<host<<endl; |
cout<<"Connecting to DB"<<endl; |
787 |
cout<<"USER "<<user<<endl; |
cout<<"HOST "<<host<<endl; |
788 |
cout<<"PSW "<<psw<<endl; |
cout<<"USER "<<user<<endl; |
789 |
|
cout<<"PSW "<<psw<<endl; |
790 |
|
} |
791 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
792 |
if( dbc || dbc->IsConnected() )connected = true; |
if( dbc || dbc->IsConnected() )connected = true; |
793 |
else cout << " >> FAILED!!!"<<endl; |
else cout << " >> DB connection FAILED!!!"<<endl; |
794 |
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
if(TrkParams::VerboseMode())cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
795 |
|
|
796 |
if(connected){ |
if(connected){ |
797 |
if ( !TrkParams::Set(0,dbc) )return false; |
if ( !TrkParams::Set(0,dbc) )return false; |
798 |
dbc->Close(); |
dbc->Close(); |
799 |
}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; |
800 |
|
|
801 |
|
return true; |
802 |
} |
} |
803 |
|
|
804 |
/** |
/** |
817 |
switch( type ){ |
switch( type ){ |
818 |
//------------------------------------------ |
//------------------------------------------ |
819 |
case 1: |
case 1: |
820 |
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
821 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
822 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
823 |
path_.error = 0; |
path_.error = 0; |
827 |
break; |
break; |
828 |
//------------------------------------------ |
//------------------------------------------ |
829 |
case 2: |
case 2: |
830 |
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; |
831 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
832 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
833 |
path_.error = 0; |
path_.error = 0; |
837 |
break; |
break; |
838 |
//------------------------------------------ |
//------------------------------------------ |
839 |
case 3: |
case 3: |
840 |
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
841 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
842 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
843 |
path_.error = 0; |
path_.error = 0; |
847 |
break; |
break; |
848 |
//------------------------------------------ |
//------------------------------------------ |
849 |
case 4: |
case 4: |
850 |
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
851 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
852 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
853 |
path_.error = 0; |
path_.error = 0; |
857 |
break; |
break; |
858 |
//------------------------------------------ |
//------------------------------------------ |
859 |
case 5: |
case 5: |
860 |
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
861 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
862 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
863 |
path_.error = 0; |
path_.error = 0; |
867 |
break; |
break; |
868 |
//------------------------------------------ |
//------------------------------------------ |
869 |
case 6: |
case 6: |
870 |
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
871 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
872 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
873 |
path_.error = 0; |
path_.error = 0; |
877 |
break; |
break; |
878 |
//------------------------------------------ |
//------------------------------------------ |
879 |
case 7: |
case 7: |
880 |
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
881 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
882 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
883 |
path_.error = 0; |
path_.error = 0; |
884 |
// fillpedsigfromdefault_(); |
// fillpedsigfromdefault_(); |
885 |
cout << ">> not implemented <<"<<endl; |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
886 |
if(path_.error) return false; |
if(path_.error) return false; |
887 |
glload[index]=true; |
glload[index]=true; |
888 |
break; |
break; |
889 |
default: |
default: |
890 |
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; |
891 |
return false; |
return false; |
892 |
}; |
}; |
893 |
|
|
903 |
return true; |
return true; |
904 |
}; |
}; |
905 |
|
|
906 |
|
|
907 |
|
/** |
908 |
|
* Get BY (kGauss) |
909 |
|
* @param v (x,y,z) coordinates in cm |
910 |
|
*/ |
911 |
|
float TrkParams::GetBX(float* v){ |
912 |
|
TrkParams::Load(1); |
913 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
914 |
|
float b[3]; |
915 |
|
gufld_(v,b); |
916 |
|
return b[0]/10.; |
917 |
|
} |
918 |
|
/** |
919 |
|
* Get BY (kGauss) |
920 |
|
* @param v (x,y,z) coordinates in cm |
921 |
|
*/ |
922 |
|
float TrkParams::GetBY(float* v){ |
923 |
|
TrkParams::Load(1); |
924 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
925 |
|
float b[3]; |
926 |
|
gufld_(v,b); |
927 |
|
return b[1]/10.; |
928 |
|
} |
929 |
|
/** |
930 |
|
* Get BY (kGauss) |
931 |
|
* @param v (x,y,z) coordinates in cm |
932 |
|
*/ |
933 |
|
float TrkParams::GetBZ(float* v){ |
934 |
|
TrkParams::Load(1); |
935 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
936 |
|
float b[3]; |
937 |
|
gufld_(v,b); |
938 |
|
return b[2]/10.; |
939 |
|
} |
940 |
|
|
941 |
|
|
942 |
|
|
943 |
|
/** |
944 |
|
* \brief Set tracking mode (0=standard. 1=???) |
945 |
|
*/ |
946 |
|
void TrkParams::SetTrackingMode(int trackmode) { |
947 |
|
init__mini_trackmode = trackmode; |
948 |
|
SetTrackingMode(); |
949 |
|
}; |
950 |
|
/** |
951 |
|
* \brief Set fit-precision factor (typical value fact=100.) |
952 |
|
*/ |
953 |
|
void TrkParams::SetPrecisionFactor(double fact){ |
954 |
|
init__mini_fact = fact; |
955 |
|
SetPrecisionFactor(); |
956 |
|
}; |
957 |
|
/** |
958 |
|
* \brief Set minimum number of step in track fitting |
959 |
|
*/ |
960 |
|
void TrkParams::SetStepMin(int istepmin){ |
961 |
|
init__mini_istepmin = istepmin; |
962 |
|
SetStepMin(); |
963 |
|
}; |
964 |
|
|
965 |
|
/** |
966 |
|
* Fill F77 commons with PFA settings |
967 |
|
*/ |
968 |
|
void TrkParams::SetPFA(){ |
969 |
|
sw_.pfaid = init__pfa; |
970 |
|
for(int i=0; i<6; i++){ |
971 |
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
972 |
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
973 |
|
} |
974 |
|
}; |
975 |
|
/** |
976 |
|
* \brief Set p.f.a. |
977 |
|
* |
978 |
|
* Implemented algorythms: |
979 |
|
* 0 ETA |
980 |
|
* 1 --- |
981 |
|
* 2 ETA2 |
982 |
|
* 3 ETA3 |
983 |
|
* 4 ETA4 |
984 |
|
* 5 ETAL ==> ETA+LANDI |
985 |
|
* 10 COG |
986 |
|
* 11 COG1 |
987 |
|
* 12 COG2 |
988 |
|
* 13 COG3 |
989 |
|
* 14 COG4 |
990 |
|
*/ |
991 |
|
void TrkParams::SetPFA(int pfaid){ |
992 |
|
init__pfa = pfaid; |
993 |
|
SetPFA(); |
994 |
|
}; |
995 |
|
/** |
996 |
|
* \brief Set p.f.a. angular intervals |
997 |
|
* |
998 |
|
* This methods allows to set these amgular intervals to apply ETA2,ETA3 or ETA4 |
999 |
|
* algorythm, in case ETA or ETAL is chosen (see TrkParams::SetPFA(int pfaid)). |
1000 |
|
* @param v Pointer to a vector of 12 components, which represent the |
1001 |
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
1002 |
|
* |
1003 |
|
*/ |
1004 |
|
void TrkParams::SetPFA(float *v){ |
1005 |
|
for(int i=0; i<6; i++){ |
1006 |
|
init__pfa_e234ax[i] = v[i]; |
1007 |
|
init__pfa_e234ay[i] = v[i+6]; |
1008 |
|
} |
1009 |
|
SetPFA(); |
1010 |
|
}; |
1011 |
|
/** |
1012 |
|
* \brief Get spatial resolution. |
1013 |
|
* |
1014 |
|
* Method to retrieve the spatial resolution associated with the |
1015 |
|
* adopted p.f.a. |
1016 |
|
* @param view Tracker view (1-12) |
1017 |
|
* @param angle Track projected angle |
1018 |
|
* |
1019 |
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
1020 |
|
* |
1021 |
|
* TrkParams::SetPFA(0) // ETA |
1022 |
|
* |
1023 |
|
*/ |
1024 |
|
float TrkParams::GetResolution(int view, float angle){ |
1025 |
|
float res = 1000; |
1026 |
|
if( init__pfa == 0 )res = riseta_(&view,&angle); |
1027 |
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
1028 |
|
return res; |
1029 |
|
} |
1030 |
|
|
1031 |
|
|
1032 |
|
|
1033 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |