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 |
|
double TrkParams::init__deltab_0 = 0.; |
39 |
|
double TrkParams::init__deltab_1 = 0.; |
40 |
|
double TrkParams::init__dlt = 1.e-5; |
41 |
|
// ------------------------------------------ |
42 |
|
// nominal z-coordinates to define acceptance |
43 |
|
// ------------------------------------------ |
44 |
|
int TrkParams::nGF = NGF; |
45 |
|
float TrkParams::zGF[] = {+53.74,+53.04,+23.94,+23.44,+22.29,+21.83,+13.39,+4.49,-4.41,-13.31,-21.83,-22.22,-23.49,-24.34}; |
46 |
|
float TrkParams::xGF_min[] = {-20.40,-20.40,-9.00,-9.00,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-8.07,-9.00,-9.00}; |
47 |
|
float TrkParams::xGF_max[] = {+20.40,+20.40,+9.00,+9.00,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+8.07,+9.00,+9.00}; |
48 |
|
// float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-7.25,-7.25,-7.25,-7.25,-6.57,-6.75,-7.50,-7.50}; |
49 |
|
// float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.75,+6.75,+6.75,+6.75,+6.57,+7.25,+7.50,+7.50}; |
50 |
|
// per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa |
51 |
|
float TrkParams::yGF_min[] = {-16.50,-16.50,-7.50,-7.50,-7.25,-6.57,-6.57,-6.57,-6.57,-6.57,-6.57,-6.75,-7.50,-7.50}; |
52 |
|
float TrkParams::yGF_max[] = {+16.50,+16.50,+7.50,+7.50,+6.75,+6.57,+6.57,+6.57,+6.57,+6.57,+6.57,+7.25,+7.50,+7.50}; |
53 |
|
TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"}; |
54 |
|
|
55 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
56 |
|
|
70 |
ret1=(float)ret; |
ret1=(float)ret; |
71 |
return ret1; |
return ret1; |
72 |
} |
} |
73 |
|
|
74 |
|
/** |
75 |
|
* Static method to open a DB connection. |
76 |
|
* HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, |
77 |
|
* $PAM_DBUSER and $PAM_DBPSW |
78 |
|
* NB! The method create a new connection, which has to be closed by the user. |
79 |
|
*/ |
80 |
|
TSQLServer* TrkParams::SetDBConnection(){ |
81 |
|
|
82 |
|
TString host = "mysql://localhost/pamelaprod"; |
83 |
|
TString user = "anonymous"; |
84 |
|
TString psw = ""; |
85 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
86 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
87 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
88 |
|
if ( !pamdbhost ) pamdbhost = ""; |
89 |
|
if ( !pamdbuser ) pamdbuser = ""; |
90 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
91 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
92 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
93 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
94 |
|
if(TrkParams::VerboseMode()){ |
95 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
96 |
|
cout<<"Connecting to DB"<<endl; |
97 |
|
cout<<"HOST "<<host<<endl; |
98 |
|
cout<<"USER "<<user<<endl; |
99 |
|
cout<<"PSW "<<psw<<endl; |
100 |
|
} |
101 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
102 |
|
if( !dbc )return NULL; |
103 |
|
if( !dbc->IsConnected() )return NULL; |
104 |
|
stringstream myquery; // EMILIANO |
105 |
|
myquery.str(""); // EMILIANO |
106 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
107 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
108 |
|
if(TrkParams::VerboseMode()){ |
109 |
|
cout << " ...done"<<endl; |
110 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
111 |
|
} |
112 |
|
|
113 |
|
return dbc; |
114 |
|
} |
115 |
/** |
/** |
116 |
* Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
117 |
|
|
118 |
* It retrieves the calibration associated to a given run, from |
* It retrieves the calibration associated to a given run, from |
119 |
* a given DB. It fills the F77 common. |
* a given DB. It fills the F77 common. |
122 |
*/ |
*/ |
123 |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
124 |
|
|
125 |
GL_TRK_CALIB q2; |
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
126 |
GL_ROOT q3; |
|
127 |
GL_PARAM q4; |
if( !CalibIsLoaded() || |
128 |
|
(glrun->TRK_CALIB_USED==104 && !calib104) || |
129 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) )return false; |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
130 |
if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2) |
glrun->RUNHEADER_TIME < calib.FROM_TIME || |
131 |
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 || |
132 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )return false; |
false ){ |
133 |
|
|
134 |
calib = q2; |
|
135 |
calibpathf = q3.PATH + q3.NAME; |
GL_TRK_CALIB q2; |
136 |
calib104 = (glrun->TRK_CALIB_USED==104); |
GL_ROOT q3; |
137 |
calibload = kFALSE; |
GL_PARAM q4; |
138 |
if(calib104){ |
|
139 |
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
|
140 |
calibpatht = q4.PATH + q4.NAME; |
bool LOCAL_CONNECTION = false; |
141 |
} |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
142 |
|
|
143 |
|
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
144 |
|
dbc = TrkParams::SetDBConnection(); |
145 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
146 |
|
|
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
if(TrkParams::VerboseMode()){ |
151 |
|
cout << "--------------------------------------"<<endl; |
152 |
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
153 |
|
} |
154 |
|
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
155 |
|
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
156 |
|
return false; |
157 |
|
} |
158 |
|
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
159 |
|
printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
160 |
|
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
161 |
|
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
162 |
|
return false; |
163 |
|
} |
164 |
|
|
165 |
|
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
166 |
|
calib = q2; |
167 |
|
calibpathf = q3.PATH + q3.NAME; |
168 |
|
calib104 = (glrun->TRK_CALIB_USED==104); |
169 |
|
calibload = kFALSE; |
170 |
|
if(calib104){ |
171 |
|
if (q4.Query_GL_PARAM(glrun->RUNHEADER_TIME,7,dbc) )return false; |
172 |
|
calibpatht = q4.PATH + q4.NAME; |
173 |
|
} |
174 |
|
|
175 |
|
if(LOCAL_CONNECTION){ |
176 |
|
dbc->Close(); |
177 |
|
delete dbc; |
178 |
|
} |
179 |
|
|
180 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
181 |
return true; |
return true; |
182 |
|
} |
183 |
|
|
184 |
|
return false; |
185 |
}; |
}; |
186 |
|
|
187 |
/** |
/** |
188 |
|
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
189 |
|
* in YodaProfiler. |
190 |
|
*/ |
191 |
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
192 |
|
|
193 |
|
UInt_t validate = 1; |
194 |
|
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
195 |
|
// UInt_t timeaftercalib=120000; //2000; |
196 |
|
TString classname = caltrk->GetName(); |
197 |
|
// ---------- |
198 |
|
// Check CRCs |
199 |
|
// ---------- |
200 |
|
if(TrkParams::VerboseMode())cout << " DSP: "; |
201 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
202 |
|
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
203 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
204 |
|
if( caltrk->crc_hcal[ipkt] ){ |
205 |
|
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
206 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
207 |
|
// return 0; // :-( |
208 |
|
validate = 0; |
209 |
|
} |
210 |
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
211 |
|
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
212 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
213 |
|
// return 0; // :-( |
214 |
|
validate = 0; |
215 |
|
} |
216 |
|
} |
217 |
|
} |
218 |
|
if(TrkParams::VerboseMode())cout << endl;; |
219 |
|
// ----------------------- |
220 |
|
// Check missing packets: |
221 |
|
// ----------------------- |
222 |
|
// Readout order: |
223 |
|
// ------------------ |
224 |
|
// DSP packet board |
225 |
|
// ------------------ |
226 |
|
// 12 0 1 |
227 |
|
// 10 1 1 |
228 |
|
// 8 2 1 |
229 |
|
// 4 3 1 |
230 |
|
// 6 4 1 |
231 |
|
// 2 5 1 |
232 |
|
// ------------------ |
233 |
|
// 11 0 2 |
234 |
|
// 9 1 2 |
235 |
|
// 7 2 2 |
236 |
|
// 3 3 2 |
237 |
|
// 5 4 2 |
238 |
|
// 1 5 2 |
239 |
|
// ------------------ |
240 |
|
// ------------------------------------------------- |
241 |
|
// Check if it is first or second calibration packet |
242 |
|
// ------------------------------------------------- |
243 |
|
UInt_t build=0; |
244 |
|
UInt_t base=0; |
245 |
|
UInt_t mask=0; |
246 |
|
if(classname.Contains("CalibTrk1Event")){ |
247 |
|
base=12; |
248 |
|
mask=0x03F000; |
249 |
|
} |
250 |
|
if(classname.Contains("CalibTrk2Event")){ |
251 |
|
base=18; |
252 |
|
mask=0xFC0000; |
253 |
|
} |
254 |
|
// ------------------------------------------------- |
255 |
|
// Count number of packets and set build variable |
256 |
|
// ------------------------------------------------- |
257 |
|
Int_t npkts=0; |
258 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
259 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
260 |
|
npkts++; |
261 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
262 |
|
}; |
263 |
|
} |
264 |
|
if( npkts==6 ){}//return 1; // :-) |
265 |
|
else { |
266 |
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
267 |
|
validate = 0; |
268 |
|
} |
269 |
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
270 |
|
|
271 |
|
// ----------------------------------------------- |
272 |
|
// If missing packets: check the acq configuration |
273 |
|
// (some DSPs might be excluded from acquisition) |
274 |
|
// ----------------------------------------------- |
275 |
|
|
276 |
|
// ----------------------------------------------- |
277 |
|
// retrieve the first run header after calib |
278 |
|
// ----------------------------------------------- |
279 |
|
// PacketType *pctp; |
280 |
|
// EventCounter *cod; |
281 |
|
// cod = eh->GetCounter(); |
282 |
|
// Int_t irun = cod->Get(pctp->RunHeader); |
283 |
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
284 |
|
// if ( !rh || rh->IsZombie() ) throw -17; |
285 |
|
// if( rh->GetEntries() == irun ){ |
286 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
287 |
|
// return 0; // :-( |
288 |
|
// } |
289 |
|
|
290 |
|
// RunHeaderEvent *run = 0; |
291 |
|
// EventHeader *hrun = 0; |
292 |
|
// rh->SetBranchAddress("RunHeader", &run); |
293 |
|
// rh->SetBranchAddress("Header", &hrun); |
294 |
|
// rh->GetEntry(irun); |
295 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
296 |
|
|
297 |
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
298 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
299 |
|
// return 0; // :-( |
300 |
|
// } |
301 |
|
|
302 |
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
303 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
304 |
|
// return 0; // :-( |
305 |
|
// } |
306 |
|
|
307 |
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
308 |
|
// if( dtime > timeaftercalib ){ |
309 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
310 |
|
// return 0; // :-( |
311 |
|
// } |
312 |
|
|
313 |
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
314 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
315 |
|
// return 0; // :-( |
316 |
|
// } |
317 |
|
|
318 |
|
// return 1; // :-) |
319 |
|
|
320 |
|
// cout << validate << endl; |
321 |
|
return validate; |
322 |
|
|
323 |
|
} |
324 |
|
/** |
325 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
326 |
*/ |
*/ |
327 |
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){ |
328 |
|
|
329 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
330 |
|
ca->Reset(); |
331 |
|
|
332 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
333 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
339 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
340 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
341 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
342 |
|
|
343 |
|
// --- TEST TEST TEST TEST --- // |
344 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
345 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
346 |
|
|
347 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
348 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
349 |
|
if( !test1 || !test2 ){ |
350 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
351 |
|
TrkParams::calib.VALIDATION = 0; |
352 |
|
} |
353 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
354 |
|
|
355 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
356 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
357 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
358 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
359 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
360 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
361 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
362 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
363 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
364 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
365 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
366 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
367 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
368 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->bad[jj][j][dspn1]=1; |
369 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
else if(calibdata1->DSPbad_par[i][ii]==1) |
370 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=0; |
371 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
372 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
373 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
} |
374 |
|
|
375 |
// |
if(dspn2>=0 && dspn2<12){ |
376 |
// invert the bad |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
377 |
// |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
378 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
379 |
ca->bad[jj][j][dspn1]=1; |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
380 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
if(calibdata2->DSPbad_par[i][ii]==0) |
381 |
ca->bad[jj][j][dspn1]=0; |
ca->bad[jj][j][dspn2]=1; |
382 |
if(calibdata2->DSPbad_par[i][ii]==0) |
else if(calibdata2->DSPbad_par[i][ii]==1) |
383 |
ca->bad[jj][j][dspn2]=1; |
ca->bad[jj][j][dspn2]=0; |
384 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
385 |
ca->bad[jj][j][dspn2]=0; |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
386 |
|
} |
387 |
}; |
}; |
388 |
}; |
}; |
389 |
|
|
396 |
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){ |
397 |
|
|
398 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
399 |
|
// ca->Reset(); |
400 |
|
|
401 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
402 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
408 |
tr1->GetEntry(ev_reg1); |
tr1->GetEntry(ev_reg1); |
409 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
410 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
411 |
|
|
412 |
|
// --- TEST TEST TEST TEST --- // |
413 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
414 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
415 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
416 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
417 |
|
if( !test1 || !test2 ){ |
418 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
419 |
|
TrkParams::calib.VALIDATION = 0; |
420 |
|
} |
421 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
422 |
|
|
423 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
424 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
427 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
428 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
429 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
430 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
431 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
432 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
433 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calibdata1->DSPbad_par[i][ii]==0) |
434 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=1; |
435 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
else if(calibdata1->DSPbad_par[i][ii]==1) |
436 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
ca->bad[jj][j][dspn1]=0; |
437 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
438 |
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
439 |
// |
} |
440 |
// invert the bad |
if(dspn2>=0 && dspn2<12){ |
441 |
// |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
442 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
443 |
ca->bad[jj][j][dspn1]=1; |
if(calibdata2->DSPbad_par[i][ii]==0) |
444 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
ca->bad[jj][j][dspn2]=1; |
445 |
ca->bad[jj][j][dspn1]=0; |
else if(calibdata2->DSPbad_par[i][ii]==1) |
446 |
if(calibdata2->DSPbad_par[i][ii]==0) |
ca->bad[jj][j][dspn2]=0; |
447 |
ca->bad[jj][j][dspn2]=1; |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
448 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
449 |
ca->bad[jj][j][dspn2]=0; |
} |
450 |
}; |
}; |
451 |
}; |
}; |
452 |
|
|
459 |
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){ |
460 |
|
|
461 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
462 |
|
// ca->Reset(); |
463 |
|
|
464 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
465 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
472 |
tr2->GetEntry(ev_reg2); |
tr2->GetEntry(ev_reg2); |
473 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
474 |
|
|
475 |
|
// --- TEST TEST TEST TEST --- // |
476 |
|
// TrkParams::ValidateTrkCalib(calibdata1); |
477 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
478 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
479 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
480 |
|
if( !test1 || !test2 ){ |
481 |
|
if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
482 |
|
TrkParams::calib.VALIDATION = 0; |
483 |
|
} |
484 |
|
if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
485 |
|
|
486 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
487 |
dspn1=calibdata1->DSPnumber[i]-1; |
dspn1=calibdata1->DSPnumber[i]-1; |
488 |
dspn2=calibdata2->DSPnumber[i]-1; |
dspn2=calibdata2->DSPnumber[i]-1; |
490 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
491 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
492 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
493 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
if(dspn1>=0 && dspn1<12){ |
494 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
495 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
496 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
} |
497 |
|
if(dspn2>=0 && dspn2<12){ |
498 |
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
499 |
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
500 |
|
} |
501 |
}; |
}; |
502 |
}; |
}; |
503 |
|
|
520 |
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){ |
521 |
|
|
522 |
cTrkMask *ma = &mask_; |
cTrkMask *ma = &mask_; |
523 |
|
ma->Reset(); |
524 |
|
|
525 |
TrkCalib *calib = new TrkCalib(); |
TrkCalib *calib = new TrkCalib(); |
526 |
|
|
543 |
tr->GetEntry(ev_reg2); |
tr->GetEntry(ev_reg2); |
544 |
} |
} |
545 |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
546 |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
Int_t view = calib->GetView(ipkt); |
547 |
Int_t view = calib->GetView(ipkt); |
if( (view-1)>= 0 && (view-1)<12 ){ |
548 |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
549 |
Float_t sigmin = 0.; |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
550 |
if(view%2)sigmin = 6.5; |
Float_t sigmin = 0.; |
551 |
else sigmin = 2.5; |
if(view%2)sigmin = 6.5; |
552 |
Int_t mask = 1; |
else sigmin = 2.5; |
553 |
if( sigm<sigmin )mask = 0; |
Int_t mask = 1; |
554 |
|
if( sigm<sigmin )mask = 0; |
555 |
ma->mask_vk_run[ivk][view-1] = mask; |
ma->mask_vk_run[ivk][view-1] = mask; |
556 |
|
} |
557 |
// if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl; |
} |
|
} |
|
558 |
} |
} |
559 |
if(tr)tr->Delete(); |
if(tr)tr->Delete(); |
560 |
} |
} |
561 |
|
|
562 |
|
if(TrkParams::VerboseMode()){ |
563 |
|
for(Int_t iv=0; iv<NVIEW; iv++){ |
564 |
|
cout<<"view "<<setw(3)<<iv<<": "; |
565 |
|
for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv]; |
566 |
|
cout << endl; |
567 |
|
} |
568 |
|
} |
569 |
|
|
570 |
if(calib)calib->Delete(); |
if(calib)calib->Delete(); |
571 |
|
|
572 |
}; |
}; |
573 |
|
|
574 |
|
// Bool_t TrkParams::CalibIsLoaded(UInt_t time){ |
575 |
|
|
576 |
|
// if( !calibload ) return false; |
577 |
|
|
578 |
|
// }; |
579 |
|
|
580 |
|
|
581 |
/** |
/** |
582 |
* Static method to load calibration. |
* \brief Static method to load calibration. |
583 |
* 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. |
|
584 |
*/ |
*/ |
585 |
Bool_t TrkParams::LoadCalib( ){ |
Bool_t TrkParams::LoadCalib( ){ |
586 |
|
|
587 |
if( TrkParams::CalibIsLoaded() )return false; |
if( TrkParams::CalibIsLoaded() )return false; |
588 |
|
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
|
|
|
|
|
// extern cTrkCalib pedsigbad_; |
|
|
// extern cTrkMask mask_; |
|
|
|
|
|
cout << "--------------------------------------"<<endl; |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
|
589 |
// ============================================================= |
// ============================================================= |
590 |
// retrieve calibration file needed to reduce data |
// retrieve calibration file needed to reduce data |
591 |
// ============================================================= |
// ============================================================= |
592 |
// if run OBT is > last calibration "expiration date" |
// if run OBT is > last calibration "expiration date" |
593 |
// - search for new calibration packet |
// - search for new calibration packet |
594 |
// - load calibration parameters (full + truncated) |
// - load calibration parameters (full + truncated) |
595 |
cout << "Full pedestals for cluster finding:"; |
if(TrkParams::VerboseMode()){ |
596 |
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
cout << "--------------------------------------"<<endl; |
597 |
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
598 |
|
cout << " Full pedestals for cluster finding:"; |
599 |
|
cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; |
600 |
|
} |
601 |
FileStat_t t; |
FileStat_t t; |
602 |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
603 |
|
|
604 |
TFile *f0_c = new TFile(calibpathf); |
bool alreadyopened = false; |
605 |
|
TFile *f0_c=0; |
606 |
|
f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); |
607 |
|
if(f0_c)alreadyopened=true; |
608 |
|
else f0_c = new TFile(calibpathf); |
609 |
if ( !f0_c ) return false; |
if ( !f0_c ) return false; |
610 |
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
|
611 |
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
if(TrkParams::VerboseMode()){ |
612 |
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
613 |
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
614 |
|
cout << " - full+truncated parameters "<<endl; |
615 |
|
} |
616 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
617 |
|
if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl; |
618 |
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; |
|
619 |
|
|
|
// }; |
|
620 |
// ============================================================= |
// ============================================================= |
621 |
// retrieve calibration file needed to uncompress data |
// retrieve calibration file needed to uncompress data |
622 |
// ============================================================= |
// ============================================================= |
623 |
// if the run was compressed using default calib |
// if the run was compressed using default calib |
624 |
// load truncated pedestals from default |
// load truncated pedestals from default |
625 |
// otherwise reload them from on-line calibration |
// otherwise reload them from on-line calibration |
626 |
cout << "Truncated pedestals for uncompression:"; |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
627 |
if( calib104 ){ |
if( calib104 ){ |
628 |
|
|
629 |
cout << " >> Loading default calibration: "<< calibpatht << endl; |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
|
// ca->FillTCalibFrom(calibpatht); |
|
630 |
TrkParams::FillTCalibFrom(calibpatht); |
TrkParams::FillTCalibFrom(calibpatht); |
631 |
|
|
632 |
}else{ |
}else{ |
633 |
|
|
634 |
if ( !f0_c ) return false; |
// if ( !f0_c ) return false; |
635 |
cout << ">> Loading on-line calibration " << endl; |
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
636 |
// 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); |
|
637 |
}; |
}; |
638 |
for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
if(!alreadyopened)f0_c->Close(); |
639 |
f0_c->Close(); |
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
|
// delete f0_c; |
|
|
cout << "--------------------------------------"<<endl; |
|
640 |
|
|
641 |
calibload = kTRUE; |
calibload = kTRUE; |
642 |
return true; |
return true; |
654 |
* @param dbc Database |
* @param dbc Database |
655 |
* @param type Parameter type |
* @param type Parameter type |
656 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
657 |
* If glrun==NULL the last parameter entry from GL_PARAM table is set. |
* If glrun==NULL the first parameter entry from GL_PARAM table is set. |
658 |
* If dbc==NULL, try to open a connection taking DB-connection |
* If dbc==NULL, try to open a connection taking DB-connection |
659 |
* parameters from PAMELA environment variables. |
* parameters from PAMELA environment variables. |
660 |
*/ |
*/ |
661 |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
662 |
|
|
|
// 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; |
|
|
|
|
|
} |
|
663 |
|
|
664 |
UInt_t index = TrkParams::GetIndex( type ); |
UInt_t index = TrkParams::GetIndex( type ); |
665 |
if(index < 0)return false; |
if(index < 0)return false; |
666 |
|
|
667 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
UInt_t runheadtime=0; |
668 |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
UInt_t runid=0; |
669 |
else cout <<"Missing run info -- taking last entry "<<endl; |
// UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
670 |
|
if(glrun){ |
671 |
|
runheadtime = glrun->RUNHEADER_TIME; |
672 |
|
runid = glrun->ID; |
673 |
|
}else cout <<"Bool_t TrkParams::Set(GL_RUN*,TSQLServer*,UInt_t) >> Missing run info -- taking first entry (**WARNING** check that this is ok!! )"<<endl; |
674 |
|
|
675 |
|
// if(TrkParams::VerboseMode()) |
676 |
|
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; |
677 |
|
|
678 |
|
|
679 |
|
if( !TrkParams::IsLoaded(type) || |
680 |
|
runheadtime < gl[index].FROM_TIME || |
681 |
|
runheadtime > gl[index].TO_TIME || |
682 |
|
false ){ |
683 |
|
|
684 |
|
bool LOCAL_CONNECTION = false; |
685 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
686 |
|
|
687 |
|
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
688 |
|
dbc = TrkParams::SetDBConnection(); |
689 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
690 |
|
|
691 |
GL_PARAM q4; |
} |
|
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
|
692 |
|
|
693 |
gl[index] = q4; |
GL_PARAM q4; |
694 |
glpath[index] = q4.PATH+q4.NAME; |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
695 |
glload[index] = false; |
if(LOCAL_CONNECTION){ |
696 |
cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
dbc->Close(); |
697 |
return true; |
delete dbc; |
698 |
// return TrkParams::Load(type); |
} |
699 |
|
gl[index] = q4; |
700 |
|
glpath[index] = q4.PATH+q4.NAME; |
701 |
|
glload[index] = false; |
702 |
|
|
703 |
|
return true; |
704 |
|
|
705 |
|
} |
706 |
|
return false; |
707 |
|
|
708 |
}; |
}; |
709 |
/** |
/** |
719 |
|
|
720 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
721 |
glpath[index] = path; |
glpath[index] = path; |
722 |
cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode()) |
723 |
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
724 |
glload[index] = false; |
glload[index] = false; |
725 |
|
|
726 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
736 |
*/ |
*/ |
737 |
Bool_t TrkParams::Set(UInt_t type){ |
Bool_t TrkParams::Set(UInt_t type){ |
738 |
|
|
|
UInt_t index = TrkParams::GetIndex( type ); |
|
|
if(index < 0)return false; |
|
|
|
|
|
gl[index].TYPE= type; |
|
|
glload[index] = false; |
|
|
|
|
|
// ----------------------------------------- |
|
|
// check if enviroment variables are defined |
|
|
// ----------------------------------------- |
|
|
glpath[index] = gSystem->Getenv("PAM_CALIB"); |
|
739 |
|
|
740 |
if( !glpath[index].IsNull() ){ |
return Set(0,0,type); |
|
|
|
|
switch(type){ |
|
|
case 1: |
|
|
glpath[index].Append("/trk-param/field_param-0/"); |
|
|
break; |
|
|
case 2: |
|
|
glpath[index].Append("/trk-param/mip_param-0/"); |
|
|
break; |
|
|
case 3: |
|
|
glpath[index].Append("/trk-param/charge_param-1/"); |
|
|
break; |
|
|
case 4: |
|
|
glpath[index].Append("/trk-param/eta_param-0/"); |
|
|
break; |
|
|
case 5: |
|
|
glpath[index].Append("/trk-param/align_param-0/"); |
|
|
break; |
|
|
case 6: |
|
|
glpath[index].Append("/trk-param/mask_param-1/"); |
|
|
break; |
|
|
case 7: |
|
|
glpath[index].Append("/trk-param/default_calib/"); |
|
|
break; |
|
|
} |
|
|
|
|
|
}else{ |
|
|
cout << " TrkParams::Set( UInt_t type) ==> No PAMELA environment variables defined "<<endl; |
|
|
return false; |
|
|
|
|
|
} |
|
741 |
|
|
|
cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
|
|
// return TrkParams::Load(type); |
|
|
return true; |
|
742 |
|
|
743 |
}; |
}; |
744 |
/** |
/** |
749 |
*/ |
*/ |
750 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
751 |
|
|
|
Bool_t connected = false; |
|
752 |
|
|
753 |
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
754 |
TString host = "mysql://localhost/pamelaprod"; |
|
755 |
TString user = "anonymous"; |
return true; |
|
TString psw = ""; |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
cout<<"Connecting to DB"<<endl; |
|
|
cout<<"HOST "<<host<<endl; |
|
|
cout<<"USER "<<user<<endl; |
|
|
cout<<"PSW "<<psw<<endl; |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if( dbc || dbc->IsConnected() )connected = true; |
|
|
else cout << " >> FAILED!!!"<<endl; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
|
|
|
if(connected){ |
|
|
if ( !TrkParams::Set(0,dbc) )return false; |
|
|
dbc->Close(); |
|
|
}else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
|
756 |
} |
} |
757 |
|
|
758 |
/** |
/** |
771 |
switch( type ){ |
switch( type ){ |
772 |
//------------------------------------------ |
//------------------------------------------ |
773 |
case 1: |
case 1: |
774 |
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
775 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
776 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
777 |
path_.error = 0; |
path_.error = 0; |
781 |
break; |
break; |
782 |
//------------------------------------------ |
//------------------------------------------ |
783 |
case 2: |
case 2: |
784 |
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; |
785 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
786 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
787 |
path_.error = 0; |
path_.error = 0; |
791 |
break; |
break; |
792 |
//------------------------------------------ |
//------------------------------------------ |
793 |
case 3: |
case 3: |
794 |
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
795 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
796 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
797 |
path_.error = 0; |
path_.error = 0; |
801 |
break; |
break; |
802 |
//------------------------------------------ |
//------------------------------------------ |
803 |
case 4: |
case 4: |
804 |
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
805 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
806 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
807 |
path_.error = 0; |
path_.error = 0; |
811 |
break; |
break; |
812 |
//------------------------------------------ |
//------------------------------------------ |
813 |
case 5: |
case 5: |
814 |
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
815 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
816 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
817 |
path_.error = 0; |
path_.error = 0; |
821 |
break; |
break; |
822 |
//------------------------------------------ |
//------------------------------------------ |
823 |
case 6: |
case 6: |
824 |
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
825 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
826 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
827 |
path_.error = 0; |
path_.error = 0; |
831 |
break; |
break; |
832 |
//------------------------------------------ |
//------------------------------------------ |
833 |
case 7: |
case 7: |
834 |
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
835 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
836 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
837 |
path_.error = 0; |
path_.error = 0; |
838 |
// fillpedsigfromdefault_(); |
// fillpedsigfromdefault_(); |
839 |
cout << ">> not implemented <<"<<endl; |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
840 |
if(path_.error) return false; |
if(path_.error) return false; |
841 |
glload[index]=true; |
glload[index]=true; |
842 |
break; |
break; |
843 |
default: |
default: |
844 |
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; |
845 |
return false; |
return false; |
846 |
}; |
}; |
847 |
|
|
857 |
return true; |
return true; |
858 |
}; |
}; |
859 |
|
|
860 |
|
|
861 |
|
/** |
862 |
|
* Get BY (kGauss) |
863 |
|
* @param v (x,y,z) coordinates in cm |
864 |
|
*/ |
865 |
|
float TrkParams::GetBX(float* v){ |
866 |
|
TrkParams::Load(1); |
867 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
868 |
|
float b[3]; |
869 |
|
gufld_(v,b); |
870 |
|
return b[0]/10.; |
871 |
|
} |
872 |
|
/** |
873 |
|
* Get BY (kGauss) |
874 |
|
* @param v (x,y,z) coordinates in cm |
875 |
|
*/ |
876 |
|
float TrkParams::GetBY(float* v){ |
877 |
|
TrkParams::Load(1); |
878 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
879 |
|
float b[3]; |
880 |
|
gufld_(v,b); |
881 |
|
return b[1]/10.; |
882 |
|
} |
883 |
|
/** |
884 |
|
* Get BY (kGauss) |
885 |
|
* @param v (x,y,z) coordinates in cm |
886 |
|
*/ |
887 |
|
float TrkParams::GetBZ(float* v){ |
888 |
|
TrkParams::Load(1); |
889 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
890 |
|
float b[3]; |
891 |
|
gufld_(v,b); |
892 |
|
return b[2]/10.; |
893 |
|
} |
894 |
|
|
895 |
|
|
896 |
|
/** |
897 |
|
* \brief Set tracking mode (0=standard. 1=???) |
898 |
|
*/ |
899 |
|
void TrkParams::SetTrackingMode(int trackmode) { |
900 |
|
init__mini_trackmode = trackmode; |
901 |
|
SetTrackingMode(); //fill F77 common |
902 |
|
}; |
903 |
|
/** |
904 |
|
* \brief Set fit-precision factor (typical value fact=100.) |
905 |
|
*/ |
906 |
|
void TrkParams::SetPrecisionFactor(double fact){ |
907 |
|
init__mini_fact = fact; |
908 |
|
SetPrecisionFactor(); //fill F77 common |
909 |
|
}; |
910 |
|
/** |
911 |
|
* \brief Set minimum number of step in track fitting |
912 |
|
*/ |
913 |
|
void TrkParams::SetStepMin(int istepmin){ |
914 |
|
init__mini_istepmin = istepmin; |
915 |
|
SetStepMin(); //fill F77 common |
916 |
|
}; |
917 |
|
/** |
918 |
|
* \brief Set deltaB parameters (id=0,1) |
919 |
|
*/ |
920 |
|
void TrkParams::SetDeltaB(int id,double db){ |
921 |
|
if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
922 |
|
if(id==0)init__deltab_0 = db; |
923 |
|
if(id==1)init__deltab_1 = db; |
924 |
|
SetDeltaB(); //fill F77 common |
925 |
|
}; |
926 |
|
/** |
927 |
|
* \brief Set DLT-grkuta precision factor (default 1.e-4) |
928 |
|
*/ |
929 |
|
void TrkParams::SetDLT(double fact){ |
930 |
|
init__dlt = fact; |
931 |
|
SetDLT(); //fill F77 common |
932 |
|
}; |
933 |
|
|
934 |
|
/** |
935 |
|
* \brief Fill F77 commons with PFA settings |
936 |
|
*/ |
937 |
|
void TrkParams::SetPFA(){ |
938 |
|
sw_.pfaid = init__pfa; |
939 |
|
for(int i=0; i<6; i++){ |
940 |
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
941 |
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
942 |
|
} |
943 |
|
}; |
944 |
|
/** |
945 |
|
* \brief Set p.f.a. |
946 |
|
* |
947 |
|
* Implemented algorythms: |
948 |
|
* 0 ETA |
949 |
|
* 1 --- |
950 |
|
* 2 ETA2 |
951 |
|
* 3 ETA3 |
952 |
|
* 4 ETA4 |
953 |
|
* 5 ETAL ==> ETA+LANDI |
954 |
|
* 10 COG |
955 |
|
* 11 COG1 |
956 |
|
* 12 COG2 |
957 |
|
* 13 COG3 |
958 |
|
* 14 COG4 |
959 |
|
*/ |
960 |
|
void TrkParams::SetPFA(int pfaid){ |
961 |
|
init__pfa = pfaid; |
962 |
|
SetPFA(); //fill F77 common |
963 |
|
}; |
964 |
|
/** |
965 |
|
* \brief Set p.f.a. angular intervals |
966 |
|
* |
967 |
|
* This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4 |
968 |
|
* algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)). |
969 |
|
* @param v Pointer to a vector of 12 components, which represent the |
970 |
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
971 |
|
* |
972 |
|
*/ |
973 |
|
void TrkParams::SetPFA(float *v){ |
974 |
|
for(int i=0; i<6; i++){ |
975 |
|
init__pfa_e234ax[i] = v[i]; |
976 |
|
init__pfa_e234ay[i] = v[i+6]; |
977 |
|
} |
978 |
|
SetPFA(); //fill F77 common |
979 |
|
}; |
980 |
|
|
981 |
|
|
982 |
|
/** |
983 |
|
* \brief Get spatial resolution. |
984 |
|
* |
985 |
|
* Method to retrieve the spatial resolution associated with the |
986 |
|
* adopted p.f.a. |
987 |
|
* @param view Tracker view (1-12) |
988 |
|
* @param angle Track projected angle |
989 |
|
* |
990 |
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
991 |
|
* |
992 |
|
* TrkParams::SetPFA(0) // ETA |
993 |
|
* |
994 |
|
*/ |
995 |
|
float TrkParams::GetResolution(int view, float angle){ |
996 |
|
float res = 1000; |
997 |
|
if( init__pfa == 0 )res = riseta_(&view,&angle); |
998 |
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
999 |
|
return res; |
1000 |
|
} |
1001 |
|
|
1002 |
|
|
1003 |
|
|
1004 |
|
|
1005 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |