1 |
|
|
2 |
/** |
/** |
3 |
* \file TrkParams.cpp |
* \file TrkParams.cpp |
4 |
* \author Elena Vannuccini |
* \author Elena Vannuccini |
6 |
|
|
7 |
#include <TrkParams.h> |
#include <TrkParams.h> |
8 |
#include <iostream> |
#include <iostream> |
9 |
|
#include <iomanip> |
10 |
using namespace std; |
using namespace std; |
11 |
|
|
12 |
|
|
13 |
|
Bool_t TrkParams::simuflag = kFALSE; |
14 |
// ------------------------- |
// ------------------------- |
15 |
// CALIBRATION (PED,SIG,BAD) |
// CALIBRATION (PED,SIG,BAD) |
16 |
// ------------------------- |
// ------------------------- |
19 |
TString TrkParams::calibpathf = ""; |
TString TrkParams::calibpathf = ""; |
20 |
Bool_t TrkParams::calib104 = 0; |
Bool_t TrkParams::calib104 = 0; |
21 |
Bool_t TrkParams::calibload = false; |
Bool_t TrkParams::calibload = false; |
22 |
|
TrkCalib* TrkParams::calib1 = 0; |
23 |
|
TrkCalib* TrkParams::calib2 = 0; |
24 |
|
// ------------------------- |
25 |
|
// PARAMETERS loaded from DB |
26 |
|
// ------------------------- |
27 |
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
UInt_t TrkParams::trkparamtype[] = {1,2,3,4,5,6,7}; |
28 |
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()}; |
29 |
TString TrkParams::glpath[] = {"","","","","","",""}; |
TString TrkParams::glpath[] = {"","","","","","",""}; |
30 |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
31 |
|
// ---------------- |
32 |
|
// other parameters |
33 |
|
// ---------------- |
34 |
|
cDbg TrkParams::init__dbg_mode = {0,0,0}; |
35 |
|
//int TrkParams::init__pfa = 14;//COG4 |
36 |
|
int TrkParams::init__pfa = 5;//ETAL |
37 |
|
int TrkParams::init__mini_trackmode = 0; |
38 |
|
int TrkParams::init__mini_istepmin = 5; //3; |
39 |
|
double TrkParams::init__mini_fact = 1.e4; //100.; |
40 |
|
float TrkParams::init__pfa_e234ax[] = {0.,10.,10.,15.,15.,90.}; |
41 |
|
float TrkParams::init__pfa_e234ay[] = {0.,20.,90.,90.,90.,90.}; |
42 |
|
double TrkParams::init__deltab_0 = 0.; |
43 |
|
double TrkParams::init__deltab_1 = 0.; |
44 |
|
double TrkParams::init__dlt = 1.e-5; |
45 |
|
// ------------------------------------------ |
46 |
|
// nominal z-coordinates to define acceptance |
47 |
|
// ------------------------------------------ |
48 |
|
int TrkParams::nGF = NGF; |
49 |
|
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}; |
50 |
|
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}; |
51 |
|
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}; |
52 |
|
// 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}; |
53 |
|
// 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}; |
54 |
|
// per i piani interni alla cavita`, gli estremi sono dati dalla cavita` stessa |
55 |
|
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}; |
56 |
|
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}; |
57 |
|
TString TrkParams::GF_element[] = {"S11","S12","S21","S22","T1","CUF","T2","T3","T4","T5","CLF","T6","S31","S32"}; |
58 |
|
|
59 |
TrkParams::TrkParams(){ |
TrkParams::TrkParams(){ |
60 |
|
|
74 |
ret1=(float)ret; |
ret1=(float)ret; |
75 |
return ret1; |
return ret1; |
76 |
} |
} |
77 |
|
|
78 |
|
void TrkParams::SetSimuFlag(Bool_t flag){ |
79 |
|
simuflag = flag; |
80 |
|
} |
81 |
|
|
82 |
|
Bool_t TrkParams::GetSimuFlag(){ |
83 |
|
return simuflag; |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
|
/** |
88 |
|
* Static method to open a DB connection. |
89 |
|
* HOST, USER and PASSWORD are taken from enviroment variables $PAM_DBHOST, |
90 |
|
* $PAM_DBUSER and $PAM_DBPSW |
91 |
|
* NB! The method create a new connection, which has to be closed by the user. |
92 |
|
*/ |
93 |
|
TSQLServer* TrkParams::SetDBConnection(){ |
94 |
|
|
95 |
|
TString host = "mysql://localhost/pamelaprod"; |
96 |
|
TString user = "anonymous"; |
97 |
|
TString psw = ""; |
98 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
99 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
100 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
101 |
|
if ( !pamdbhost ) pamdbhost = ""; |
102 |
|
if ( !pamdbuser ) pamdbuser = ""; |
103 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
104 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
105 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
106 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
107 |
|
if(TrkParams::DebugMode()){ |
108 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
109 |
|
cout<<"TrkParams::SetDBConnection() >> Connecting to DB"<<endl; |
110 |
|
cout<<"HOST "<<host<<endl; |
111 |
|
cout<<"USER "<<user<<endl; |
112 |
|
cout<<"PSW "<<psw<<endl; |
113 |
|
} |
114 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
115 |
|
if( !dbc )return NULL; |
116 |
|
if( !dbc->IsConnected() )return NULL; |
117 |
|
stringstream myquery; // EMILIANO |
118 |
|
myquery.str(""); // EMILIANO |
119 |
|
myquery << "SET time_zone='+0:00'"; // EMILIANO |
120 |
|
dbc->Query(myquery.str().c_str()); // EMILIANO |
121 |
|
if(TrkParams::DebugMode()){ |
122 |
|
cout << " ...done"<<endl; |
123 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
124 |
|
} |
125 |
|
|
126 |
|
return dbc; |
127 |
|
} |
128 |
/** |
/** |
129 |
* Static method to set the calibration to be loaded. |
* \brief Static method to set the calibration to be loaded. |
130 |
|
|
131 |
* It retrieves the calibration associated to a given run, from |
* It retrieves the calibration associated to a given run, from |
132 |
* a given DB. It fills the F77 common. |
* a given DB. It fills the F77 common. |
135 |
*/ |
*/ |
136 |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
137 |
|
|
138 |
|
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
139 |
|
|
140 |
if( !CalibIsLoaded() || |
if( !CalibIsLoaded() || |
141 |
(glrun->TRK_CALIB_USED==104 && !calib104) || |
(glrun->TRK_CALIB_USED==104 && !calib104) || |
142 |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
(glrun->TRK_CALIB_USED!=104 && calib104) || |
144 |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
glrun->RUNHEADER_TIME > calib.TO_TIME || |
145 |
false ){ |
false ){ |
146 |
|
|
147 |
|
|
148 |
GL_TRK_CALIB q2; |
GL_TRK_CALIB q2; |
149 |
GL_ROOT q3; |
GL_ROOT q3; |
150 |
GL_PARAM q4; |
GL_PARAM q4; |
151 |
|
|
152 |
|
|
153 |
|
bool LOCAL_CONNECTION = false; |
154 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
155 |
|
|
156 |
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
157 |
|
dbc = TrkParams::SetDBConnection(); |
158 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
159 |
|
|
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
cout << " UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
if(TrkParams::VerboseMode()){ |
164 |
|
cout << "--------------------------------------"<<endl; |
165 |
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
166 |
|
} |
167 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
168 |
cout << "Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
169 |
return false; |
return false; |
170 |
} |
} |
171 |
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
172 |
printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
printf(" WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2); |
173 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
174 |
cout << "Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
175 |
return false; |
return false; |
176 |
} |
} |
177 |
|
|
178 |
// cout << "selected "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<endl; |
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
179 |
calib = q2; |
calib = q2; |
180 |
calibpathf = q3.PATH + q3.NAME; |
calibpathf = q3.PATH + q3.NAME; |
181 |
calib104 = (glrun->TRK_CALIB_USED==104); |
calib104 = (glrun->TRK_CALIB_USED==104); |
185 |
calibpatht = q4.PATH + q4.NAME; |
calibpatht = q4.PATH + q4.NAME; |
186 |
} |
} |
187 |
|
|
188 |
|
if(LOCAL_CONNECTION&&dbc){ |
189 |
|
dbc->Close(); |
190 |
|
delete dbc; |
191 |
|
if(TrkParams::DebugMode()){ |
192 |
|
cout << " DB connection closed."<<endl; |
193 |
|
} |
194 |
|
} |
195 |
|
|
196 |
// return TrkParams::LoadCalib(); |
// return TrkParams::LoadCalib(); |
197 |
return true; |
return true; |
201 |
}; |
}; |
202 |
|
|
203 |
/** |
/** |
204 |
|
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
205 |
|
* in YodaProfiler. |
206 |
|
*/ |
207 |
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
208 |
|
|
209 |
|
UInt_t validate = 1; |
210 |
|
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
211 |
|
// UInt_t timeaftercalib=120000; //2000; |
212 |
|
TString classname = caltrk->GetName(); |
213 |
|
// ---------- |
214 |
|
// Check CRCs |
215 |
|
// ---------- |
216 |
|
if(TrkParams::VerboseMode())cout << " DSP: "; |
217 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
218 |
|
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
219 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
220 |
|
if( caltrk->crc_hcal[ipkt] ){ |
221 |
|
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
222 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
223 |
|
// return 0; // :-( |
224 |
|
validate = 0; |
225 |
|
} |
226 |
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
227 |
|
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
228 |
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
229 |
|
// return 0; // :-( |
230 |
|
validate = 0; |
231 |
|
} |
232 |
|
} |
233 |
|
} |
234 |
|
if(TrkParams::VerboseMode())cout << endl;; |
235 |
|
// ----------------------- |
236 |
|
// Check missing packets: |
237 |
|
// ----------------------- |
238 |
|
// Readout order: |
239 |
|
// ------------------ |
240 |
|
// DSP packet board |
241 |
|
// ------------------ |
242 |
|
// 12 0 1 |
243 |
|
// 10 1 1 |
244 |
|
// 8 2 1 |
245 |
|
// 4 3 1 |
246 |
|
// 6 4 1 |
247 |
|
// 2 5 1 |
248 |
|
// ------------------ |
249 |
|
// 11 0 2 |
250 |
|
// 9 1 2 |
251 |
|
// 7 2 2 |
252 |
|
// 3 3 2 |
253 |
|
// 5 4 2 |
254 |
|
// 1 5 2 |
255 |
|
// ------------------ |
256 |
|
// ------------------------------------------------- |
257 |
|
// Check if it is first or second calibration packet |
258 |
|
// ------------------------------------------------- |
259 |
|
UInt_t build=0; |
260 |
|
UInt_t base=0; |
261 |
|
UInt_t mask=0; |
262 |
|
if(classname.Contains("CalibTrk1Event")){ |
263 |
|
base=12; |
264 |
|
mask=0x03F000; |
265 |
|
} |
266 |
|
if(classname.Contains("CalibTrk2Event")){ |
267 |
|
base=18; |
268 |
|
mask=0xFC0000; |
269 |
|
} |
270 |
|
// ------------------------------------------------- |
271 |
|
// Count number of packets and set build variable |
272 |
|
// ------------------------------------------------- |
273 |
|
Int_t npkts=0; |
274 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
275 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
276 |
|
npkts++; |
277 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
278 |
|
}; |
279 |
|
} |
280 |
|
if( npkts==6 ){}//return 1; // :-) |
281 |
|
else { |
282 |
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
283 |
|
validate = 0; |
284 |
|
} |
285 |
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
286 |
|
|
287 |
|
// ----------------------------------------------- |
288 |
|
// If missing packets: check the acq configuration |
289 |
|
// (some DSPs might be excluded from acquisition) |
290 |
|
// ----------------------------------------------- |
291 |
|
|
292 |
|
// ----------------------------------------------- |
293 |
|
// retrieve the first run header after calib |
294 |
|
// ----------------------------------------------- |
295 |
|
// PacketType *pctp; |
296 |
|
// EventCounter *cod; |
297 |
|
// cod = eh->GetCounter(); |
298 |
|
// Int_t irun = cod->Get(pctp->RunHeader); |
299 |
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
300 |
|
// if ( !rh || rh->IsZombie() ) throw -17; |
301 |
|
// if( rh->GetEntries() == irun ){ |
302 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
303 |
|
// return 0; // :-( |
304 |
|
// } |
305 |
|
|
306 |
|
// RunHeaderEvent *run = 0; |
307 |
|
// EventHeader *hrun = 0; |
308 |
|
// rh->SetBranchAddress("RunHeader", &run); |
309 |
|
// rh->SetBranchAddress("Header", &hrun); |
310 |
|
// rh->GetEntry(irun); |
311 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
312 |
|
|
313 |
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
314 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
315 |
|
// return 0; // :-( |
316 |
|
// } |
317 |
|
|
318 |
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
319 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
320 |
|
// return 0; // :-( |
321 |
|
// } |
322 |
|
|
323 |
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
324 |
|
// if( dtime > timeaftercalib ){ |
325 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
326 |
|
// return 0; // :-( |
327 |
|
// } |
328 |
|
|
329 |
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
330 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
331 |
|
// return 0; // :-( |
332 |
|
// } |
333 |
|
|
334 |
|
// return 1; // :-) |
335 |
|
|
336 |
|
// cout << validate << endl; |
337 |
|
return validate; |
338 |
|
|
339 |
|
} |
340 |
|
/** |
341 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
342 |
*/ |
*/ |
343 |
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){ |
344 |
|
|
345 |
cTrkCalib *ca = &pedsigbad_; |
cTrkCalib *ca = &pedsigbad_; |
346 |
|
ca->Reset(); |
347 |
|
|
348 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
349 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
350 |
|
|
351 |
CalibTrk1Event *calibdata1 = 0; |
if(!calib1)calib1 = new TrkCalib(); |
352 |
CalibTrk2Event *calibdata2 = 0; |
if(!calib2)calib2 = new TrkCalib(); |
353 |
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
// calibx->Set(calibdata1); |
354 |
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
// caliby->Set(calibdata2); |
355 |
tr1->GetEntry(ev_reg1); |
|
356 |
tr2->GetEntry(ev_reg2); |
// CalibTrk1Event *calibdata1 = 0; |
357 |
|
// CalibTrk2Event *calibdata2 = 0; |
358 |
|
// tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
359 |
|
// tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
360 |
|
tr1->SetBranchAddress("CalibTrk1",calib1->GetPointerTo()); |
361 |
|
tr2->SetBranchAddress("CalibTrk2",calib2->GetPointerTo()); |
362 |
|
if ( tr1->GetEntry(ev_reg1) <= 0 ) throw -36;//EM |
363 |
|
if ( tr2->GetEntry(ev_reg2) <= 0 ) throw -36;//EM |
364 |
Int_t dspn1(0),dspn2(0); |
Int_t dspn1(0),dspn2(0); |
365 |
|
|
366 |
|
|
367 |
|
// --- TEST TEST TEST TEST --- // |
368 |
|
// TrkParams::ValidateTrkCalib(calib1->Get()); |
369 |
|
// TrkParams::ValidateTrkCalib((CalibTrk1Event*)calib2->Get()); |
370 |
|
|
371 |
|
UInt_t test1 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib1->Get())); |
372 |
|
UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)(calib2->Get())); |
373 |
|
if( !test1 || !test2 ){ |
374 |
|
// if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
375 |
|
TrkParams::calib.VALIDATION = 0; |
376 |
|
} |
377 |
|
// if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
378 |
|
|
379 |
for(Int_t i=0;i<6;i++){ |
for(Int_t i=0;i<6;i++){ |
380 |
dspn1=calibdata1->DSPnumber[i]-1; |
|
381 |
dspn2=calibdata2->DSPnumber[i]-1; |
|
382 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
dspn1=calib1->Get()->DSPnumber[i]-1; |
383 |
|
dspn2=calib2->Get()->DSPnumber[i]-1; |
384 |
|
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
385 |
for(Int_t ii=0;ii<3072;ii++){ |
for(Int_t ii=0;ii<3072;ii++){ |
386 |
Int_t j=(ii/128); |
Int_t j=(ii/128); |
387 |
Int_t jj=ii-j*128; |
Int_t jj=ii-j*128; |
388 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
if(dspn1>=0 && dspn1<12){ |
389 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
ca->pedestal[jj][j][dspn1]=calib1->Get()->DSPped_par[i][ii]; |
390 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
ca->pedestal_t[jj][j][dspn1]=aint(calib1->Get()->DSPped_par[i][ii]); |
391 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
ca->sigma[jj][j][dspn1]=calib1->Get()->DSPsig_par[i][ii]; |
392 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
ca->sigma_t[jj][j][dspn1]=anint(calib1->Get()->DSPsig_par[i][ii]); |
393 |
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
if(calib1->Get()->DSPbad_par[i][ii]==0) |
394 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
ca->bad[jj][j][dspn1]=1; |
395 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
else if(calib1->Get()->DSPbad_par[i][ii]==1) |
396 |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
ca->bad[jj][j][dspn1]=0; |
397 |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
398 |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
399 |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
} |
400 |
|
|
401 |
// |
if(dspn2>=0 && dspn2<12){ |
402 |
// invert the bad |
ca->pedestal[jj][j][dspn2]=calib2->Get()->DSPped_par[i][ii]; |
403 |
// |
ca->pedestal_t[jj][j][dspn2]=aint(calib2->Get()->DSPped_par[i][ii]); |
404 |
if(calibdata1->DSPbad_par[i][ii]==0) |
ca->sigma[jj][j][dspn2]=calib2->Get()->DSPsig_par[i][ii]; |
405 |
ca->bad[jj][j][dspn1]=1; |
ca->sigma_t[jj][j][dspn2]=anint(calib2->Get()->DSPsig_par[i][ii]); |
406 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
if(calib2->Get()->DSPbad_par[i][ii]==0) |
407 |
ca->bad[jj][j][dspn1]=0; |
ca->bad[jj][j][dspn2]=1; |
408 |
if(calibdata2->DSPbad_par[i][ii]==0) |
else if(calib2->Get()->DSPbad_par[i][ii]==1) |
409 |
ca->bad[jj][j][dspn2]=1; |
ca->bad[jj][j][dspn2]=0; |
410 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
411 |
ca->bad[jj][j][dspn2]=0; |
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
412 |
|
} |
413 |
}; |
}; |
414 |
}; |
}; |
415 |
|
|
419 |
/** |
/** |
420 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
421 |
*/ |
*/ |
422 |
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){ |
423 |
|
|
424 |
cTrkCalib *ca = &pedsigbad_; |
// cTrkCalib *ca = &pedsigbad_; |
425 |
|
// // ca->Reset(); |
426 |
|
|
427 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
// TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
428 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
// TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
429 |
|
|
430 |
CalibTrk1Event *calibdata1 = 0; |
// CalibTrk1Event *calibdata1 = 0; |
431 |
CalibTrk2Event *calibdata2 = 0; |
// CalibTrk2Event *calibdata2 = 0; |
432 |
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
// tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
433 |
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
// tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
434 |
tr1->GetEntry(ev_reg1); |
// tr1->GetEntry(ev_reg1); |
435 |
tr2->GetEntry(ev_reg2); |
// tr2->GetEntry(ev_reg2); |
436 |
Int_t dspn1(0),dspn2(0); |
// Int_t dspn1(0),dspn2(0); |
437 |
|
|
438 |
for(Int_t i=0;i<6;i++){ |
// // --- TEST TEST TEST TEST --- // |
439 |
dspn1=calibdata1->DSPnumber[i]-1; |
// // TrkParams::ValidateTrkCalib(calibdata1); |
440 |
dspn2=calibdata2->DSPnumber[i]-1; |
// // TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
441 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
442 |
for(Int_t ii=0;ii<3072;ii++){ |
// UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
443 |
Int_t j=(ii/128); |
// if( !test1 || !test2 ){ |
444 |
Int_t jj=ii-j*128; |
// if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
445 |
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
// TrkParams::calib.VALIDATION = 0; |
446 |
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
// } |
447 |
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
// if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
|
448 |
|
|
449 |
// |
// for(Int_t i=0;i<6;i++){ |
450 |
// invert the bad |
// dspn1=calibdata1->DSPnumber[i]-1; |
451 |
// |
// dspn2=calibdata2->DSPnumber[i]-1; |
452 |
if(calibdata1->DSPbad_par[i][ii]==0) |
// /* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
453 |
ca->bad[jj][j][dspn1]=1; |
// for(Int_t ii=0;ii<3072;ii++){ |
454 |
else if(calibdata1->DSPbad_par[i][ii]==1) |
// Int_t j=(ii/128); |
455 |
ca->bad[jj][j][dspn1]=0; |
// Int_t jj=ii-j*128; |
456 |
if(calibdata2->DSPbad_par[i][ii]==0) |
// if(dspn1>=0 && dspn1<12){ |
457 |
ca->bad[jj][j][dspn2]=1; |
// ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
458 |
else if(calibdata2->DSPbad_par[i][ii]==1) |
// ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
459 |
ca->bad[jj][j][dspn2]=0; |
// if(calibdata1->DSPbad_par[i][ii]==0) |
460 |
}; |
// ca->bad[jj][j][dspn1]=1; |
461 |
}; |
// else if(calibdata1->DSPbad_par[i][ii]==1) |
462 |
|
// ca->bad[jj][j][dspn1]=0; |
463 |
|
// // cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
464 |
|
// // cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
465 |
|
// } |
466 |
|
// if(dspn2>=0 && dspn2<12){ |
467 |
|
// ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
468 |
|
// ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
469 |
|
// if(calibdata2->DSPbad_par[i][ii]==0) |
470 |
|
// ca->bad[jj][j][dspn2]=1; |
471 |
|
// else if(calibdata2->DSPbad_par[i][ii]==1) |
472 |
|
// ca->bad[jj][j][dspn2]=0; |
473 |
|
// // cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
474 |
|
// // cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
475 |
|
// } |
476 |
|
// }; |
477 |
|
// }; |
478 |
|
|
479 |
tr1->Delete(); |
// tr1->Delete(); |
480 |
tr2->Delete(); |
// tr2->Delete(); |
481 |
}; |
// }; |
482 |
/** |
/** |
483 |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
484 |
*/ |
*/ |
485 |
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){ |
486 |
|
|
487 |
cTrkCalib *ca = &pedsigbad_; |
// cTrkCalib *ca = &pedsigbad_; |
488 |
|
// // ca->Reset(); |
489 |
|
|
490 |
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
// TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
491 |
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
// TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
492 |
|
|
493 |
CalibTrk1Event *calibdata1 = 0; |
// CalibTrk1Event *calibdata1 = 0; |
494 |
CalibTrk2Event *calibdata2 = 0; |
// CalibTrk2Event *calibdata2 = 0; |
495 |
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
// tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
496 |
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
// tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
497 |
tr1->GetEntry(ev_reg1); |
// tr1->GetEntry(ev_reg1); |
498 |
tr2->GetEntry(ev_reg2); |
// tr2->GetEntry(ev_reg2); |
499 |
Int_t dspn1(0),dspn2(0); |
// Int_t dspn1(0),dspn2(0); |
500 |
|
|
501 |
for(Int_t i=0;i<6;i++){ |
// // --- TEST TEST TEST TEST --- // |
502 |
dspn1=calibdata1->DSPnumber[i]-1; |
// // TrkParams::ValidateTrkCalib(calibdata1); |
503 |
dspn2=calibdata2->DSPnumber[i]-1; |
// // TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
504 |
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
// UInt_t test1 = TrkParams::ValidateTrkCalib(calibdata1); |
505 |
for(Int_t ii=0;ii<3072;ii++){ |
// UInt_t test2 = TrkParams::ValidateTrkCalib((CalibTrk1Event*)calibdata2); |
506 |
Int_t j=(ii/128); |
// if( !test1 || !test2 ){ |
507 |
Int_t jj=ii-j*128; |
// if(TrkParams::calib.VALIDATION==1)cout << "--> modify DB info "<<endl; |
508 |
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
// TrkParams::calib.VALIDATION = 0; |
509 |
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
// } |
510 |
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
// if(TrkParams::calib.VALIDATION==0)cout << " ** WARNING ** Calibration not validated "<<endl; |
511 |
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
|
512 |
}; |
// for(Int_t i=0;i<6;i++){ |
513 |
}; |
// dspn1=calibdata1->DSPnumber[i]-1; |
514 |
|
// dspn2=calibdata2->DSPnumber[i]-1; |
515 |
|
// /* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
516 |
|
// for(Int_t ii=0;ii<3072;ii++){ |
517 |
|
// Int_t j=(ii/128); |
518 |
|
// Int_t jj=ii-j*128; |
519 |
|
// if(dspn1>=0 && dspn1<12){ |
520 |
|
// ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
521 |
|
// ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
522 |
|
// } |
523 |
|
// if(dspn2>=0 && dspn2<12){ |
524 |
|
// ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
525 |
|
// ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
526 |
|
// } |
527 |
|
// }; |
528 |
|
// }; |
529 |
|
|
530 |
tr1->Delete(); |
// tr1->Delete(); |
531 |
tr2->Delete(); |
// tr2->Delete(); |
532 |
}; |
// }; |
533 |
/** |
/** |
534 |
* Method to fill the tracker calibration-parameter struct from default calibration |
* Method to fill the tracker calibration-parameter struct from default calibration |
535 |
*/ |
*/ |
546 |
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){ |
547 |
|
|
548 |
cTrkMask *ma = &mask_; |
cTrkMask *ma = &mask_; |
549 |
|
ma->Reset(); |
550 |
|
|
551 |
TrkCalib *calib = new TrkCalib(); |
TrkCalib *calib = new TrkCalib(); |
552 |
|
|
558 |
//------------------------- |
//------------------------- |
559 |
tr = (TTree*)f0->Get("CalibTrk1"); |
tr = (TTree*)f0->Get("CalibTrk1"); |
560 |
tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo()); |
tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo()); |
561 |
tr->GetEntry(ev_reg1); |
if ( tr->GetEntry(ev_reg1) <= 0 ) throw -36;//EM |
562 |
} |
} |
563 |
if(i==1){ |
if(i==1){ |
564 |
//------------------------- |
//------------------------- |
566 |
//------------------------- |
//------------------------- |
567 |
tr = (TTree*)f0->Get("CalibTrk2"); |
tr = (TTree*)f0->Get("CalibTrk2"); |
568 |
tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); |
tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); |
569 |
tr->GetEntry(ev_reg2); |
if ( tr->GetEntry(ev_reg2) <= 0 ) throw -36; |
570 |
} |
} |
571 |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
572 |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
Int_t view = calib->GetView(ipkt); |
573 |
Int_t view = calib->GetView(ipkt); |
if( (view-1)>= 0 && (view-1)<12 ){ |
574 |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
for(Int_t ivk=0; ivk<NVK; ivk++){ |
575 |
Float_t sigmin = 0.; |
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
576 |
if(view%2)sigmin = 6.5; |
Float_t sigmin = 0.; |
577 |
else sigmin = 2.5; |
if(view%2)sigmin = 6.5; |
578 |
Int_t mask = 1; |
else sigmin = 2.5; |
579 |
if( sigm<sigmin )mask = 0; |
Int_t mask = 1; |
580 |
|
if( sigm<sigmin )mask = 0; |
581 |
ma->mask_vk_run[ivk][view-1] = mask; |
ma->mask_vk_run[ivk][view-1] = mask; |
582 |
|
} |
583 |
// if(mask==0)cout<< " VIEW "<<view<<" VK "<<ivk+1<<" -- <SIG> "<<sigm<<" ---> MASKED!"<<endl; |
} |
|
} |
|
584 |
} |
} |
585 |
if(tr)tr->Delete(); |
if(tr)tr->Delete(); |
586 |
} |
} |
587 |
|
|
588 |
|
if(TrkParams::VerboseMode()){ |
589 |
|
for(Int_t iv=0; iv<NVIEW; iv++){ |
590 |
|
cout<<"view "<<setw(3)<<iv<<": "; |
591 |
|
for(Int_t ivk=0; ivk<NVK; ivk++)cout<<ma->mask_vk_run[ivk][iv]; |
592 |
|
cout << endl; |
593 |
|
} |
594 |
|
} |
595 |
|
|
596 |
if(calib)calib->Delete(); |
if(calib)calib->Delete(); |
597 |
|
|
598 |
}; |
}; |
605 |
|
|
606 |
|
|
607 |
/** |
/** |
608 |
* Static method to load calibration. |
* \brief Static method to load calibration. |
609 |
* 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. |
|
610 |
*/ |
*/ |
611 |
Bool_t TrkParams::LoadCalib( ){ |
Bool_t TrkParams::LoadCalib( ){ |
612 |
|
|
613 |
if( TrkParams::CalibIsLoaded() )return false; |
if( TrkParams::CalibIsLoaded() )return false; |
614 |
|
|
|
// cTrkCalib *ca = new cTrkCalib; //&pedsigbad_; |
|
|
|
|
|
// extern cTrkCalib pedsigbad_; |
|
|
// extern cTrkMask mask_; |
|
|
|
|
|
cout << "--------------------------------------"<<endl; |
|
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
|
615 |
// ============================================================= |
// ============================================================= |
616 |
// retrieve calibration file needed to reduce data |
// retrieve calibration file needed to reduce data |
617 |
// ============================================================= |
// ============================================================= |
618 |
// if run OBT is > last calibration "expiration date" |
// if run OBT is > last calibration "expiration date" |
619 |
// - search for new calibration packet |
// - search for new calibration packet |
620 |
// - load calibration parameters (full + truncated) |
// - load calibration parameters (full + truncated) |
621 |
cout << "Full pedestals for cluster finding:"; |
if(TrkParams::VerboseMode()){ |
622 |
cout << " >> Loading from LEVEL0 file: "<< calibpathf << endl; |
cout << "--------------------------------------"<<endl; |
623 |
|
cout << "Retrieve calibration (PED-SIG-BAD) ..."<<endl; |
624 |
|
cout << " Full pedestals for cluster finding:"; |
625 |
|
cout << " >> loading from LEVEL0 file: "<< calibpathf << endl; |
626 |
|
} |
627 |
FileStat_t t; |
FileStat_t t; |
628 |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
629 |
|
|
630 |
TFile *f0_c = new TFile(calibpathf); |
bool alreadyopened = false; |
631 |
|
TFile *f0_c=0; |
632 |
|
f0_c = (TFile*)gROOT->GetListOfFiles()->FindObject(calibpathf); |
633 |
|
if(f0_c)alreadyopened=true; |
634 |
|
else f0_c = new TFile(calibpathf); |
635 |
if ( !f0_c ) return false; |
if ( !f0_c ) return false; |
636 |
cout << " calibration entries "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
|
637 |
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
if(TrkParams::VerboseMode()){ |
638 |
// ca->FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
cout << " calibration entry "<< calib.EV_ROOT_CALIBTRK1 << " " << calib.EV_ROOT_CALIBTRK2; |
639 |
|
cout << " (from time "<< calib.FROM_TIME <<" to time "<< calib.TO_TIME <<")"<<endl; |
640 |
|
cout << " - full+truncated parameters "<<endl; |
641 |
|
} |
642 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
643 |
|
if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl; |
644 |
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; |
|
645 |
|
|
|
// }; |
|
646 |
// ============================================================= |
// ============================================================= |
647 |
// retrieve calibration file needed to uncompress data |
// retrieve calibration file needed to uncompress data |
648 |
// ============================================================= |
// ============================================================= |
649 |
// if the run was compressed using default calib |
// if the run was compressed using default calib |
650 |
// load truncated pedestals from default |
// load truncated pedestals from default |
651 |
// otherwise reload them from on-line calibration |
// otherwise reload them from on-line calibration |
652 |
cout << "Truncated pedestals for uncompression:"; |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
653 |
if( calib104 ){ |
if( calib104 ){ |
654 |
|
|
655 |
cout << " >> Loading default calibration: "<< calibpatht << endl; |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
|
// ca->FillTCalibFrom(calibpatht); |
|
656 |
TrkParams::FillTCalibFrom(calibpatht); |
TrkParams::FillTCalibFrom(calibpatht); |
657 |
|
|
658 |
}else{ |
}else{ |
659 |
|
|
660 |
if ( !f0_c ) return false; |
// if ( !f0_c ) return false; |
661 |
cout << ">> Loading on-line calibration " << endl; |
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
662 |
// 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); |
|
663 |
}; |
}; |
664 |
// for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl; |
if(!alreadyopened)f0_c->Close(); |
665 |
f0_c->Close(); |
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
|
// delete f0_c; |
|
|
cout << "--------------------------------------"<<endl; |
|
666 |
|
|
667 |
calibload = kTRUE; |
calibload = kTRUE; |
668 |
return true; |
return true; |
680 |
* @param dbc Database |
* @param dbc Database |
681 |
* @param type Parameter type |
* @param type Parameter type |
682 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
683 |
* 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. |
684 |
* If dbc==NULL, try to open a connection taking DB-connection |
* If dbc==NULL, try to open a connection taking DB-connection |
685 |
* parameters from PAMELA environment variables. |
* parameters from PAMELA environment variables. |
686 |
*/ |
*/ |
687 |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type, UInt_t abstime){ |
|
|
|
|
// if( !dbc )return false; |
|
688 |
|
|
689 |
|
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
690 |
UInt_t index = TrkParams::GetIndex( type ); |
UInt_t index = TrkParams::GetIndex( type ); |
691 |
if(index < 0)return false; |
if(index < 0)return false; |
692 |
|
|
693 |
UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
if(TrkParams::VerboseMode()) |
694 |
if(glrun)runheadtime = glrun->RUNHEADER_TIME; |
cout <<"Calling Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ,UInt_t " <<abstime << " ) >> (**WARNING** check that this is all ok!! )"<<endl; |
|
else cout <<"Missing run info -- taking last entry "<<endl; |
|
|
|
|
|
GL_PARAM q4; |
|
|
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
|
695 |
|
|
696 |
gl[index] = q4; |
UInt_t runheadtime=1; |
697 |
glpath[index] = q4.PATH+q4.NAME; |
UInt_t runid=0; |
698 |
glload[index] = false; |
// UInt_t runheadtime = numeric_limits<UInt_t>::max(); |
699 |
cout << "<< set TrkParams type "<<type<<" >> (from DB) "<<endl; |
if(glrun){ |
700 |
|
runheadtime = glrun->RUNHEADER_TIME; |
701 |
|
runid = glrun->ID; |
702 |
|
}else |
703 |
|
cout <<"Bool_t TrkParams::Set(GL_RUN* "<<glrun<<" ,TSQLServer* "<<dbc<<" ,UInt_t "<<type<<" ,UInt_t " <<abstime << " ) >> GL_RUN==NULL -- taking first entry (**WARNING** check that this is ok!! )"<<endl; |
704 |
|
|
705 |
|
|
706 |
|
if( !abstime || !simuflag ) abstime = runheadtime;// EM: if simu? |
707 |
|
|
708 |
|
if(TrkParams::VerboseMode()) |
709 |
|
cout << "TrkParams::IsLoaded(type)=" << TrkParams::IsLoaded(type) << " abstime=" << abstime << " runheadtime=" << runheadtime << " gl[index].FROM_TIME=" << gl[index].FROM_TIME << " gl[index].TO_TIME=" << gl[index].TO_TIME << endl; |
710 |
|
|
711 |
|
if( !TrkParams::IsLoaded(type) || |
712 |
|
abstime < gl[index].FROM_TIME || |
713 |
|
abstime > gl[index].TO_TIME || |
714 |
|
false ){ |
715 |
|
|
716 |
|
if(TrkParams::VerboseMode()) |
717 |
|
cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; |
718 |
|
|
719 |
|
bool LOCAL_CONNECTION = false; |
720 |
|
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
721 |
|
|
722 |
|
// if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
723 |
|
dbc = TrkParams::SetDBConnection(); |
724 |
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
725 |
|
|
726 |
|
} |
727 |
|
|
728 |
|
GL_PARAM q4; |
729 |
|
// if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
730 |
|
if( q4.Query_GL_PARAM(abstime,type,dbc) )return false; //VALERIO |
731 |
|
if(LOCAL_CONNECTION){ |
732 |
|
dbc->Close(); |
733 |
|
delete dbc; |
734 |
|
if(TrkParams::DebugMode()){ |
735 |
|
cout << " DB connection closed."<<endl; |
736 |
|
} |
737 |
|
} |
738 |
|
gl[index] = q4; |
739 |
|
glpath[index] = q4.PATH+q4.NAME; |
740 |
|
glload[index] = false; |
741 |
|
|
742 |
|
//return true; |
743 |
|
|
744 |
|
} |
745 |
return true; |
return true; |
746 |
// return TrkParams::Load(type); |
|
|
|
|
747 |
}; |
}; |
748 |
/** |
/** |
749 |
* Set tracker parameters proper for the run, from input. |
* Set tracker parameters proper for the run, from input. |
758 |
|
|
759 |
gl[index].TYPE= type; |
gl[index].TYPE= type; |
760 |
glpath[index] = path; |
glpath[index] = path; |
761 |
cout << "<< set TrkParams type "<<type<<" >> (from input) "<<endl; |
if(TrkParams::VerboseMode()) |
762 |
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
763 |
glload[index] = false; |
glload[index] = false; |
764 |
|
|
765 |
// return TrkParams::Load(type); |
// return TrkParams::Load(type); |
775 |
*/ |
*/ |
776 |
Bool_t TrkParams::Set(UInt_t type){ |
Bool_t TrkParams::Set(UInt_t type){ |
777 |
|
|
|
UInt_t index = TrkParams::GetIndex( type ); |
|
|
if(index < 0)return false; |
|
778 |
|
|
779 |
gl[index].TYPE= type; |
return Set(0,0,type); |
|
glload[index] = false; |
|
|
|
|
|
// ----------------------------------------- |
|
|
// check if enviroment variables are defined |
|
|
// ----------------------------------------- |
|
|
glpath[index] = gSystem->Getenv("PAM_CALIB"); |
|
|
|
|
|
if( !glpath[index].IsNull() ){ |
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
780 |
|
|
|
cout << "<< set TrkParams type "<<type<<" (from env var PAM_CALIB) >>"<<endl; |
|
|
// return TrkParams::Load(type); |
|
|
return true; |
|
781 |
|
|
782 |
}; |
}; |
783 |
/** |
/** |
786 |
* otherwise it set a default path. |
* otherwise it set a default path. |
787 |
* @return FALSE if parameter set fails. |
* @return FALSE if parameter set fails. |
788 |
*/ |
*/ |
789 |
|
|
790 |
Bool_t TrkParams::Set( ){ |
Bool_t TrkParams::Set( ){ |
791 |
|
|
|
Bool_t connected = false; |
|
792 |
|
|
793 |
cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
|
TString host = "mysql://localhost/pamelaprod"; |
|
|
TString user = "anonymous"; |
|
|
TString psw = ""; |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
cout<<"Connecting to DB"<<endl; |
|
|
cout<<"HOST "<<host<<endl; |
|
|
cout<<"USER "<<user<<endl; |
|
|
cout<<"PSW "<<psw<<endl; |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if( dbc || dbc->IsConnected() )connected = true; |
|
|
else cout << " >> FAILED!!!"<<endl; |
|
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
|
|
|
|
|
if(connected){ |
|
|
if ( !TrkParams::Set(0,dbc) )return false; |
|
|
dbc->Close(); |
|
|
}else for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
|
794 |
|
|
795 |
return true; |
return true; |
796 |
} |
} |
804 |
|
|
805 |
Int_t index = TrkParams::GetIndex( type ); |
Int_t index = TrkParams::GetIndex( type ); |
806 |
if( index<0 )return false; |
if( index<0 )return false; |
807 |
if( glload[index] )return true; |
if( glload[index] )return false; |
|
|
|
808 |
if( glpath[index].IsNull() )TrkParams::Set(type); |
if( glpath[index].IsNull() )TrkParams::Set(type); |
809 |
|
|
810 |
switch( type ){ |
switch( type ){ |
811 |
//------------------------------------------ |
//------------------------------------------ |
812 |
case 1: |
case 1: |
813 |
cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
814 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
815 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
816 |
path_.error = 0; |
path_.error = 0; |
820 |
break; |
break; |
821 |
//------------------------------------------ |
//------------------------------------------ |
822 |
case 2: |
case 2: |
823 |
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; |
824 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
825 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
826 |
path_.error = 0; |
path_.error = 0; |
830 |
break; |
break; |
831 |
//------------------------------------------ |
//------------------------------------------ |
832 |
case 3: |
case 3: |
833 |
cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
834 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
835 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
836 |
path_.error = 0; |
path_.error = 0; |
840 |
break; |
break; |
841 |
//------------------------------------------ |
//------------------------------------------ |
842 |
case 4: |
case 4: |
843 |
cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
844 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
845 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
846 |
path_.error = 0; |
path_.error = 0; |
850 |
break; |
break; |
851 |
//------------------------------------------ |
//------------------------------------------ |
852 |
case 5: |
case 5: |
853 |
cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
854 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
855 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
856 |
path_.error = 0; |
path_.error = 0; |
860 |
break; |
break; |
861 |
//------------------------------------------ |
//------------------------------------------ |
862 |
case 6: |
case 6: |
863 |
cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
864 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
865 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
866 |
path_.error = 0; |
path_.error = 0; |
870 |
break; |
break; |
871 |
//------------------------------------------ |
//------------------------------------------ |
872 |
case 7: |
case 7: |
873 |
cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
874 |
strcpy(path_.path,glpath[index].Data()); |
strcpy(path_.path,glpath[index].Data()); |
875 |
path_.pathlen = glpath[index].Length(); |
path_.pathlen = glpath[index].Length(); |
876 |
path_.error = 0; |
path_.error = 0; |
877 |
// fillpedsigfromdefault_(); |
// fillpedsigfromdefault_(); |
878 |
cout << ">> not implemented <<"<<endl; |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
879 |
if(path_.error) return false; |
if(path_.error) return false; |
880 |
glload[index]=true; |
glload[index]=true; |
881 |
break; |
break; |
882 |
default: |
default: |
883 |
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; |
884 |
return false; |
return false; |
885 |
}; |
}; |
886 |
|
|
888 |
} |
} |
889 |
|
|
890 |
Bool_t TrkParams::Load( ){ |
Bool_t TrkParams::Load( ){ |
891 |
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )if( !TrkParams::Load(trkparamtype[i]) )return false; |
Bool_t result = true; |
892 |
return true; |
for(Int_t i=0 ; i<NTYPES; i++) |
893 |
|
if(!glload[i] && trkparamtype[i]>0 ) |
894 |
|
if( !TrkParams::Load(trkparamtype[i]) ) |
895 |
|
result = false; |
896 |
|
return result; |
897 |
}; |
}; |
898 |
Bool_t TrkParams::IsLoaded( ){ |
Bool_t TrkParams::IsLoaded( ){ |
899 |
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false; |
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false; |
900 |
return true; |
return true; |
901 |
}; |
}; |
902 |
|
|
903 |
|
|
904 |
|
/** |
905 |
|
* Get BY (kGauss) |
906 |
|
* @param v (x,y,z) coordinates in cm |
907 |
|
*/ |
908 |
|
float TrkParams::GetBX(float* v){ |
909 |
|
TrkParams::Load(1); |
910 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
911 |
|
float b[3]; |
912 |
|
gufld_(v,b); |
913 |
|
return b[0]/10.; |
914 |
|
} |
915 |
|
/** |
916 |
|
* Get BY (kGauss) |
917 |
|
* @param v (x,y,z) coordinates in cm |
918 |
|
*/ |
919 |
|
float TrkParams::GetBY(float* v){ |
920 |
|
TrkParams::Load(1); |
921 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
922 |
|
float b[3]; |
923 |
|
gufld_(v,b); |
924 |
|
return b[1]/10.; |
925 |
|
} |
926 |
|
/** |
927 |
|
* Get BY (kGauss) |
928 |
|
* @param v (x,y,z) coordinates in cm |
929 |
|
*/ |
930 |
|
float TrkParams::GetBZ(float* v){ |
931 |
|
TrkParams::Load(1); |
932 |
|
if( !TrkParams::IsLoaded(1) )return 0.; |
933 |
|
float b[3]; |
934 |
|
gufld_(v,b); |
935 |
|
return b[2]/10.; |
936 |
|
} |
937 |
|
|
938 |
|
|
939 |
|
/** |
940 |
|
* \brief Set tracking mode (0=standard. 1=???) |
941 |
|
*/ |
942 |
|
void TrkParams::SetTrackingMode(int trackmode) { |
943 |
|
init__mini_trackmode = trackmode; |
944 |
|
SetTrackingMode(); //fill F77 common |
945 |
|
}; |
946 |
|
/** |
947 |
|
* \brief Set fit-precision factor (typical value fact=100.) |
948 |
|
*/ |
949 |
|
void TrkParams::SetPrecisionFactor(double fact){ |
950 |
|
init__mini_fact = fact; |
951 |
|
SetPrecisionFactor(); //fill F77 common |
952 |
|
}; |
953 |
|
/** |
954 |
|
* \brief Set minimum number of step in track fitting |
955 |
|
*/ |
956 |
|
void TrkParams::SetStepMin(int istepmin){ |
957 |
|
init__mini_istepmin = istepmin; |
958 |
|
SetStepMin(); //fill F77 common |
959 |
|
}; |
960 |
|
/** |
961 |
|
* \brief Set deltaB parameters (id=0,1) |
962 |
|
*/ |
963 |
|
void TrkParams::SetDeltaB(int id,double db){ |
964 |
|
if(id!=0 && id!=1)cout << "void TrkParams::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
965 |
|
if(id==0)init__deltab_0 = db; |
966 |
|
if(id==1)init__deltab_1 = db; |
967 |
|
SetDeltaB(); //fill F77 common |
968 |
|
}; |
969 |
|
/** |
970 |
|
* \brief Set DLT-grkuta precision factor (default 1.e-4) |
971 |
|
*/ |
972 |
|
void TrkParams::SetDLT(double fact){ |
973 |
|
init__dlt = fact; |
974 |
|
SetDLT(); //fill F77 common |
975 |
|
}; |
976 |
|
|
977 |
|
/** |
978 |
|
* \brief Fill F77 commons with PFA settings |
979 |
|
*/ |
980 |
|
void TrkParams::SetPFA(){ |
981 |
|
sw_.pfaid = init__pfa; |
982 |
|
for(int i=0; i<6; i++){ |
983 |
|
pfa_.e234ax[i] = init__pfa_e234ax[i]; |
984 |
|
pfa_.e234ay[i] = init__pfa_e234ay[i]; |
985 |
|
} |
986 |
|
}; |
987 |
|
/** |
988 |
|
* \brief Set p.f.a. |
989 |
|
* |
990 |
|
* Implemented algorythms: |
991 |
|
* 0 ETA |
992 |
|
* 1 --- |
993 |
|
* 2 ETA2 |
994 |
|
* 3 ETA3 |
995 |
|
* 4 ETA4 |
996 |
|
* 5 ETAL ==> ETA+LANDI |
997 |
|
* 10 COG |
998 |
|
* 11 COG1 |
999 |
|
* 12 COG2 |
1000 |
|
* 13 COG3 |
1001 |
|
* 14 COG4 |
1002 |
|
*/ |
1003 |
|
void TrkParams::SetPFA(int pfaid){ |
1004 |
|
init__pfa = pfaid; |
1005 |
|
SetPFA(); //fill F77 common |
1006 |
|
}; |
1007 |
|
/** |
1008 |
|
* \brief Set p.f.a. angular intervals |
1009 |
|
* |
1010 |
|
* This methods allows to set amgular intervals to apply ETA2,ETA3 or ETA4 |
1011 |
|
* algorythm, in case ETA or ETAL is set (see TrkParams::SetPFA(int pfaid)). |
1012 |
|
* @param v Pointer to a vector of 12 components, which represent the |
1013 |
|
* angular limits for ETA2,ETA3 and ETA4, for x and y views, respectivelly. |
1014 |
|
* |
1015 |
|
*/ |
1016 |
|
void TrkParams::SetPFA(float *v){ |
1017 |
|
for(int i=0; i<6; i++){ |
1018 |
|
init__pfa_e234ax[i] = v[i]; |
1019 |
|
init__pfa_e234ay[i] = v[i+6]; |
1020 |
|
} |
1021 |
|
SetPFA(); //fill F77 common |
1022 |
|
}; |
1023 |
|
|
1024 |
|
|
1025 |
|
/** |
1026 |
|
* \brief Get spatial resolution. |
1027 |
|
* |
1028 |
|
* Method to retrieve the spatial resolution associated with the |
1029 |
|
* adopted p.f.a. |
1030 |
|
* @param view Tracker view (1-12) |
1031 |
|
* @param angle Track projected angle |
1032 |
|
* |
1033 |
|
* In order to change p.f.a. use the SetPFA(int pfaid) method, eg.: |
1034 |
|
* |
1035 |
|
* TrkParams::SetPFA(0) // ETA |
1036 |
|
* |
1037 |
|
*/ |
1038 |
|
float TrkParams::GetResolution(int view, float angle){ |
1039 |
|
float res = 1000; |
1040 |
|
if ( init__pfa == 0 )res = riseta_(&view,&angle); |
1041 |
|
else if( init__pfa == 5 )res = riseta_(&view,&angle); |
1042 |
|
else cout << "float TrkParams::GetResolution(int view, float angle) -- PFA "<<init__pfa<<" not yet implemented"<<endl; |
1043 |
|
return res; |
1044 |
|
} |
1045 |
|
|
1046 |
|
/** |
1047 |
|
* Returns the number of angular bins for p.f.a. parameters |
1048 |
|
*/ |
1049 |
|
int TrkParams::GetPFA_NbinsAngle(){ |
1050 |
|
TrkParams::Load(4); |
1051 |
|
if( !TrkParams::IsLoaded(4) ){ |
1052 |
|
cout << "int TrkParams::GetPFA_NbinsAngle() --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1053 |
|
return 0; |
1054 |
|
} |
1055 |
|
return pfa_.nangbin; |
1056 |
|
}; |
1057 |
|
/** |
1058 |
|
* Returns the number of eta bins for p.f.a. parameters |
1059 |
|
*/ |
1060 |
|
int TrkParams::GetPFA_NbinsETA(){ |
1061 |
|
TrkParams::Load(4); |
1062 |
|
if( !TrkParams::IsLoaded(4) ){ |
1063 |
|
cout << "int TrkParams::GetPFA_NbinsETA() --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1064 |
|
return 0; |
1065 |
|
} |
1066 |
|
return pfa_.netaval; |
1067 |
|
}; |
1068 |
|
|
1069 |
|
/** |
1070 |
|
* Returns the pointer to a vector ( of size TrkParams::GetPFA_NbinsETA() ), |
1071 |
|
* with eta-correction values for each eta bin. |
1072 |
|
* Bin extremes are given by float* TrkParams::GetPFA_ETAabs(pfa,int). |
1073 |
|
* |
1074 |
|
* @param pfa "ETA2","ETA3" or "ETA4" |
1075 |
|
* @param nview View number (0-11) |
1076 |
|
* @param nladder Ladder number (0-2) |
1077 |
|
* @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). |
1078 |
|
* |
1079 |
|
* NB! the vector must be deallocated! |
1080 |
|
* delete [] vname; |
1081 |
|
*/ |
1082 |
|
float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang){ |
1083 |
|
|
1084 |
|
TrkParams::Load(4); |
1085 |
|
if( !TrkParams::IsLoaded(4) ){ |
1086 |
|
cout << "float* TrkParams::GetPFA_ETAcorr(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1087 |
|
return 0; |
1088 |
|
} |
1089 |
|
|
1090 |
|
int nbins = GetPFA_NbinsETA(); |
1091 |
|
if(!nbins)return 0; |
1092 |
|
|
1093 |
|
if( nview < 0 || |
1094 |
|
nview >= 12 || |
1095 |
|
nladder < 0 || |
1096 |
|
nladder >= 3 || |
1097 |
|
nang < 0 || |
1098 |
|
nang >= GetPFA_NbinsAngle() || |
1099 |
|
false)return 0; |
1100 |
|
|
1101 |
|
float *fcorr = new float [nbins]; |
1102 |
|
// float fcorr[nbins]; |
1103 |
|
|
1104 |
|
if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ |
1105 |
|
for(int ib=0; ib<nbins; ib++){ |
1106 |
|
fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib]; |
1107 |
|
// cout << pfa_.eta2[nang][ib] << " - " << pfa_.feta2[nang][nladder][nview][ib]<<endl;; |
1108 |
|
} |
1109 |
|
}else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ |
1110 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib]; |
1111 |
|
}else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ |
1112 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib]; |
1113 |
|
}else{ |
1114 |
|
cout << "float* TrkParams::GetPFA_ETAcorr("<<pfa<<",...) --- pfa parameters not implemented "<<endl; |
1115 |
|
return 0; |
1116 |
|
} |
1117 |
|
|
1118 |
|
return fcorr; |
1119 |
|
|
1120 |
|
}; |
1121 |
|
|
1122 |
|
/** |
1123 |
|
* Returns the pointer to a vector with eta-bin extremes (@see float* TrkParams::GetPFA_ETAcorr(TString,int,int,int)). |
1124 |
|
* |
1125 |
|
* @param pfa "ETA2","ETA3" or "ETA4" |
1126 |
|
* @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). |
1127 |
|
* |
1128 |
|
* NB the vector must be deallocated |
1129 |
|
* delete [] vname; |
1130 |
|
*/ |
1131 |
|
float* TrkParams::GetPFA_ETAabs(TString pfa, int nang){ |
1132 |
|
|
1133 |
|
TrkParams::Load(4); |
1134 |
|
if( !TrkParams::IsLoaded(4) ){ |
1135 |
|
cout << "float* TrkParams::GetPFA_ETAabs(TString pfa, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1136 |
|
return 0; |
1137 |
|
} |
1138 |
|
|
1139 |
|
int nbins = GetPFA_NbinsETA(); |
1140 |
|
if(!nbins)return 0; |
1141 |
|
|
1142 |
|
float *fcorr = new float [nbins]; |
1143 |
|
// float fcorr[nbins]; |
1144 |
|
if( nang < 0 || |
1145 |
|
nang >= GetPFA_NbinsAngle() || |
1146 |
|
false)return 0; |
1147 |
|
|
1148 |
|
if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){ |
1149 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib]; |
1150 |
|
}else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){ |
1151 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib]; |
1152 |
|
}else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){ |
1153 |
|
for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib]; |
1154 |
|
}else{ |
1155 |
|
cout << "float* TrkParams::GetPFA_ETAabs("<<pfa<<",...) --- pfa parameters not implemented "<<endl; |
1156 |
|
return 0; |
1157 |
|
} |
1158 |
|
|
1159 |
|
return fcorr; |
1160 |
|
|
1161 |
|
}; |
1162 |
|
/** |
1163 |
|
* Returns the "Landi-correction". |
1164 |
|
* |
1165 |
|
* @param nview View number (0-11) |
1166 |
|
* @param nladder Ladder number (0-2) |
1167 |
|
* @param nang Angular bin (@see int TrkParams::GetPFA_NbinsAngle()). |
1168 |
|
*/ |
1169 |
|
float TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang){ |
1170 |
|
|
1171 |
|
// TrkParams::Load(4); |
1172 |
|
// if( !TrkParams::IsLoaded(4) ){ |
1173 |
|
// cout << "float* TrkParams::GetPFA_ETAlandi(int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl; |
1174 |
|
// return 0; |
1175 |
|
// } |
1176 |
|
int nbins = GetPFA_NbinsAngle(); |
1177 |
|
if(!nbins)return 0; |
1178 |
|
|
1179 |
|
if( nview < 0 || |
1180 |
|
nview >= 12 || |
1181 |
|
nladder < 0 || |
1182 |
|
nladder >= 3 || |
1183 |
|
nang < 0 || |
1184 |
|
nang >= nbins || |
1185 |
|
false)return 0; |
1186 |
|
|
1187 |
|
|
1188 |
|
return pfa_.fcorr[nang][nladder][nview]; |
1189 |
|
|
1190 |
|
}; |
1191 |
|
|
1192 |
|
/** |
1193 |
|
* Returns the index (0, n.bin-1) of the angular bin for pfa parameters |
1194 |
|
* @param angle Effective angle (deg) |
1195 |
|
*/ |
1196 |
|
int TrkParams::GetPFA_AngleBin(float angle){ |
1197 |
|
|
1198 |
|
int nangbin = TrkParams::GetPFA_NbinsAngle(); |
1199 |
|
int istart = (int)(nangbin/2); |
1200 |
|
int idbin = -1; |
1201 |
|
// cout << angle <<" ??" << endl; |
1202 |
|
if( angle > pfa_.angR[istart] ){ |
1203 |
|
idbin = nangbin-1; |
1204 |
|
for(int id=istart+1; id<nangbin; id++ ){ |
1205 |
|
// cout << id << endl; |
1206 |
|
if( pfa_.angR[id] >= angle ){ |
1207 |
|
idbin = id; |
1208 |
|
break; |
1209 |
|
} |
1210 |
|
} |
1211 |
|
}else{ |
1212 |
|
idbin = 0; |
1213 |
|
for(int id=istart; id>=0; id-- ){ |
1214 |
|
// cout << id << endl; |
1215 |
|
if( pfa_.angL[id] < angle ){ |
1216 |
|
idbin = id; |
1217 |
|
break; |
1218 |
|
} |
1219 |
|
} |
1220 |
|
|
1221 |
|
} |
1222 |
|
// cout << ">>> "<<idbin<<" "<<pfa_.angL[idbin]<<" "<<pfa_.angR[idbin]<<endl; |
1223 |
|
return idbin; |
1224 |
|
} |
1225 |
|
|
1226 |
|
|
1227 |
|
|
1228 |
ClassImp(TrkParams); |
ClassImp(TrkParams); |