1 |
pam-fi |
1.1 |
/** |
2 |
|
|
* \file TrkParams.cpp |
3 |
|
|
* \author Elena Vannuccini |
4 |
|
|
*/ |
5 |
|
|
|
6 |
|
|
#include <TrkParams.h> |
7 |
|
|
#include <iostream> |
8 |
pam-fi |
1.10 |
#include <iomanip> |
9 |
pam-fi |
1.1 |
using namespace std; |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
// ------------------------- |
13 |
|
|
// CALIBRATION (PED,SIG,BAD) |
14 |
|
|
// ------------------------- |
15 |
|
|
GL_TRK_CALIB TrkParams::calib = GL_TRK_CALIB(); |
16 |
|
|
TString TrkParams::calibpatht = ""; |
17 |
|
|
TString TrkParams::calibpathf = ""; |
18 |
|
|
Bool_t TrkParams::calib104 = 0; |
19 |
|
|
Bool_t TrkParams::calibload = false; |
20 |
pam-fi |
1.8 |
// ------------------------- |
21 |
|
|
// PARAMETERS loaded from DB |
22 |
|
|
// ------------------------- |
23 |
pam-fi |
1.1 |
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()}; |
25 |
|
|
TString TrkParams::glpath[] = {"","","","","","",""}; |
26 |
|
|
Bool_t TrkParams::glload[] = {false,false,false,false,false,false,false}; |
27 |
pam-fi |
1.8 |
// ---------------- |
28 |
|
|
// other parameters |
29 |
|
|
// ---------------- |
30 |
pam-fi |
1.12 |
cDbg TrkParams::init__dbg_mode = {0,0,0}; |
31 |
pam-fi |
1.15 |
//int TrkParams::init__pfa = 14;//COG4 |
32 |
|
|
int TrkParams::init__pfa = 5;//ETAL |
33 |
pam-fi |
1.8 |
int TrkParams::init__mini_trackmode = 0; |
34 |
pam-fi |
1.13 |
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 |
pam-fi |
1.19 |
double TrkParams::init__deltab_0 = 0.; |
39 |
|
|
double TrkParams::init__deltab_1 = 0.; |
40 |
pam-fi |
1.20 |
double TrkParams::init__dlt = 1.e-5; |
41 |
pam-fi |
1.21 |
// ------------------------------------------ |
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 |
pam-fi |
1.1 |
|
55 |
|
|
TrkParams::TrkParams(){ |
56 |
|
|
|
57 |
pam-fi |
1.8 |
cout<<"TrkParams::TrkParams()"<<endl; |
58 |
pam-fi |
1.1 |
|
59 |
|
|
} |
60 |
|
|
float aint(float f){ |
61 |
|
|
int ret = (int)f; |
62 |
|
|
float ret1 = 0; |
63 |
|
|
ret1=(float)ret; |
64 |
|
|
return ret1; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
float anint(float f){ |
68 |
|
|
int ret = (int)(f+0.5); |
69 |
|
|
float ret1 = 0; |
70 |
|
|
ret1=(float)ret; |
71 |
|
|
return ret1; |
72 |
|
|
} |
73 |
pam-fi |
1.18 |
|
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 |
pam-fi |
1.1 |
/** |
116 |
pam-fi |
1.10 |
* \brief Static method to set the calibration to be loaded. |
117 |
pam-fi |
1.1 |
|
118 |
|
|
* It retrieves the calibration associated to a given run, from |
119 |
|
|
* a given DB. It fills the F77 common. |
120 |
|
|
* @param glrun Pointer to a GL_RUN row |
121 |
|
|
* @param dbc Pointer to a DB connection |
122 |
|
|
*/ |
123 |
|
|
Bool_t TrkParams::SetCalib( GL_RUN *glrun, TSQLServer* dbc ){ |
124 |
|
|
|
125 |
pam-fi |
1.6 |
// cout << "glrun-> RUNHEADER_TIME "<<glrun->RUNHEADER_TIME <<endl; |
126 |
|
|
|
127 |
pam-fi |
1.3 |
if( !CalibIsLoaded() || |
128 |
|
|
(glrun->TRK_CALIB_USED==104 && !calib104) || |
129 |
|
|
(glrun->TRK_CALIB_USED!=104 && calib104) || |
130 |
|
|
glrun->RUNHEADER_TIME < calib.FROM_TIME || |
131 |
|
|
glrun->RUNHEADER_TIME > calib.TO_TIME || |
132 |
|
|
false ){ |
133 |
|
|
|
134 |
pam-fi |
1.10 |
|
135 |
pam-fi |
1.3 |
GL_TRK_CALIB q2; |
136 |
|
|
GL_ROOT q3; |
137 |
|
|
GL_PARAM q4; |
138 |
pam-fi |
1.18 |
|
139 |
|
|
|
140 |
|
|
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 |
pam-fi |
1.3 |
|
150 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode()){ |
151 |
|
|
cout << "--------------------------------------"<<endl; |
152 |
|
|
cout << "UPDATING calibration -- run-header time "<< glrun->RUNHEADER_TIME <<endl; |
153 |
|
|
} |
154 |
pam-fi |
1.3 |
if( q2.Query_GL_TRK_CALIB(glrun->RUNHEADER_TIME,dbc) ){ |
155 |
pam-fi |
1.6 |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_TRK_CALIB "<<endl; |
156 |
pam-fi |
1.3 |
return false; |
157 |
|
|
} |
158 |
|
|
if( q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2 ) |
159 |
pam-fi |
1.6 |
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 |
pam-fi |
1.3 |
if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) ){ |
161 |
pam-fi |
1.6 |
cout << " Bool_t TrkParams::SetCalib( GL_RUN* , TSQLServer* ) -- ERROR -- failed query to GL_ROOT "<<endl; |
162 |
pam-fi |
1.3 |
return false; |
163 |
|
|
} |
164 |
|
|
|
165 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << "selected DB entry "<<q2.ID<<" from_time "<<q2.FROM_TIME<<" to time "<<q2.TO_TIME<<" --> VALIDATION "<<q2.VALIDATION<<endl; |
166 |
pam-fi |
1.3 |
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 |
pam-fi |
1.18 |
if(LOCAL_CONNECTION){ |
176 |
|
|
dbc->Close(); |
177 |
|
|
delete dbc; |
178 |
|
|
} |
179 |
pam-fi |
1.1 |
|
180 |
pam-fi |
1.3 |
// return TrkParams::LoadCalib(); |
181 |
|
|
return true; |
182 |
pam-fi |
1.1 |
} |
183 |
|
|
|
184 |
pam-fi |
1.3 |
return false; |
185 |
pam-fi |
1.1 |
}; |
186 |
|
|
|
187 |
|
|
/** |
188 |
pam-fi |
1.4 |
* Method to "validate" tracker calibration. Implemented for test purpose. Effective implementation |
189 |
|
|
* in YodaProfiler. |
190 |
|
|
*/ |
191 |
|
|
UInt_t TrkParams::ValidateTrkCalib( CalibTrk1Event* caltrk){ |
192 |
|
|
|
193 |
pam-fi |
1.10 |
UInt_t validate = 1; |
194 |
pam-fi |
1.4 |
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 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " DSP: "; |
201 |
pam-fi |
1.4 |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
202 |
pam-fi |
1.7 |
if(TrkParams::VerboseMode())cout <<" "<<caltrk->DSPnumber[ipkt]; |
203 |
pam-fi |
1.5 |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
204 |
|
|
if( caltrk->crc_hcal[ipkt] ){ |
205 |
pam-fi |
1.6 |
if(TrkParams::WarningMode())cout<<"(CRC Header)"; |
206 |
|
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration header: pkt "<<ipkt<<endl; |
207 |
pam-fi |
1.5 |
// return 0; // :-( |
208 |
pam-fi |
1.10 |
validate = 0; |
209 |
pam-fi |
1.5 |
} |
210 |
|
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
211 |
pam-fi |
1.6 |
if(TrkParams::WarningMode())cout<<"(CRC Pkt-"<<ilad<<")"; |
212 |
|
|
// if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- CRC error in calibration packet: pkt "<<ipkt<<endl; |
213 |
pam-fi |
1.5 |
// return 0; // :-( |
214 |
pam-fi |
1.10 |
validate = 0; |
215 |
pam-fi |
1.5 |
} |
216 |
pam-fi |
1.4 |
} |
217 |
|
|
} |
218 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << endl;; |
219 |
pam-fi |
1.4 |
// ----------------------- |
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 |
pam-fi |
1.10 |
if( npkts==6 ){}//return 1; // :-) |
265 |
pam-fi |
1.6 |
else { |
266 |
|
|
if(TrkParams::WarningMode())cout << "ValidateTrkCalib: "<<classname<<" --WARNING-- there might be some missing packets :-( ( "<<npkts<<" instead of 6 ) --> "<<endl; |
267 |
pam-fi |
1.10 |
validate = 0; |
268 |
pam-fi |
1.6 |
} |
269 |
pam-fi |
1.4 |
// 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 |
pam-fi |
1.10 |
|
318 |
|
|
// return 1; // :-) |
319 |
|
|
|
320 |
|
|
// cout << validate << endl; |
321 |
|
|
return validate; |
322 |
pam-fi |
1.4 |
|
323 |
|
|
} |
324 |
|
|
/** |
325 |
pam-fi |
1.1 |
* 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){ |
328 |
|
|
|
329 |
|
|
cTrkCalib *ca = &pedsigbad_; |
330 |
pam-fi |
1.10 |
ca->Reset(); |
331 |
pam-fi |
1.1 |
|
332 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
333 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
334 |
|
|
|
335 |
|
|
CalibTrk1Event *calibdata1 = 0; |
336 |
|
|
CalibTrk2Event *calibdata2 = 0; |
337 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
338 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
339 |
|
|
tr1->GetEntry(ev_reg1); |
340 |
|
|
tr2->GetEntry(ev_reg2); |
341 |
|
|
Int_t dspn1(0),dspn2(0); |
342 |
pam-fi |
1.4 |
|
343 |
|
|
// --- TEST TEST TEST TEST --- // |
344 |
pam-fi |
1.10 |
// 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 |
pam-fi |
1.1 |
for(Int_t i=0;i<6;i++){ |
356 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
357 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
358 |
pam-fi |
1.10 |
// cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; |
359 |
pam-fi |
1.1 |
for(Int_t ii=0;ii<3072;ii++){ |
360 |
|
|
Int_t j=(ii/128); |
361 |
|
|
Int_t jj=ii-j*128; |
362 |
pam-fi |
1.10 |
if(dspn1>=0 && dspn1<12){ |
363 |
|
|
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
364 |
|
|
ca->pedestal_t[jj][j][dspn1]=aint(calibdata1->DSPped_par[i][ii]); |
365 |
|
|
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
366 |
|
|
ca->sigma_t[jj][j][dspn1]=anint(calibdata1->DSPsig_par[i][ii]); |
367 |
|
|
if(calibdata1->DSPbad_par[i][ii]==0) |
368 |
|
|
ca->bad[jj][j][dspn1]=1; |
369 |
|
|
else if(calibdata1->DSPbad_par[i][ii]==1) |
370 |
|
|
ca->bad[jj][j][dspn1]=0; |
371 |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
372 |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
373 |
|
|
} |
374 |
|
|
|
375 |
|
|
if(dspn2>=0 && dspn2<12){ |
376 |
|
|
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
377 |
|
|
ca->pedestal_t[jj][j][dspn2]=aint(calibdata2->DSPped_par[i][ii]); |
378 |
|
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
379 |
|
|
ca->sigma_t[jj][j][dspn2]=anint(calibdata2->DSPsig_par[i][ii]); |
380 |
|
|
if(calibdata2->DSPbad_par[i][ii]==0) |
381 |
|
|
ca->bad[jj][j][dspn2]=1; |
382 |
|
|
else if(calibdata2->DSPbad_par[i][ii]==1) |
383 |
|
|
ca->bad[jj][j][dspn2]=0; |
384 |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
385 |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
386 |
|
|
} |
387 |
pam-fi |
1.1 |
}; |
388 |
|
|
}; |
389 |
|
|
|
390 |
|
|
tr1->Delete(); |
391 |
|
|
tr2->Delete(); |
392 |
|
|
}; |
393 |
|
|
/** |
394 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
395 |
|
|
*/ |
396 |
|
|
void TrkParams::FillFCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
397 |
|
|
|
398 |
|
|
cTrkCalib *ca = &pedsigbad_; |
399 |
pam-fi |
1.10 |
// ca->Reset(); |
400 |
pam-fi |
1.1 |
|
401 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
402 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
403 |
|
|
|
404 |
|
|
CalibTrk1Event *calibdata1 = 0; |
405 |
|
|
CalibTrk2Event *calibdata2 = 0; |
406 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
407 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
408 |
|
|
tr1->GetEntry(ev_reg1); |
409 |
|
|
tr2->GetEntry(ev_reg2); |
410 |
|
|
Int_t dspn1(0),dspn2(0); |
411 |
pam-fi |
1.4 |
|
412 |
|
|
// --- TEST TEST TEST TEST --- // |
413 |
pam-fi |
1.10 |
// 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 |
pam-fi |
1.1 |
|
423 |
|
|
for(Int_t i=0;i<6;i++){ |
424 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
425 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
426 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
427 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
428 |
|
|
Int_t j=(ii/128); |
429 |
|
|
Int_t jj=ii-j*128; |
430 |
pam-fi |
1.10 |
if(dspn1>=0 && dspn1<12){ |
431 |
|
|
ca->pedestal[jj][j][dspn1]=calibdata1->DSPped_par[i][ii]; |
432 |
|
|
ca->sigma[jj][j][dspn1]=calibdata1->DSPsig_par[i][ii]; |
433 |
|
|
if(calibdata1->DSPbad_par[i][ii]==0) |
434 |
|
|
ca->bad[jj][j][dspn1]=1; |
435 |
|
|
else if(calibdata1->DSPbad_par[i][ii]==1) |
436 |
|
|
ca->bad[jj][j][dspn1]=0; |
437 |
|
|
// cout<<"sigma trk1= "<<sigma[jj][j][dspn1]<<endl; |
438 |
|
|
// cout<<"sigma_t trk1= "<<sigma_t[jj][j][dspn1]<<endl; |
439 |
|
|
} |
440 |
|
|
if(dspn2>=0 && dspn2<12){ |
441 |
|
|
ca->pedestal[jj][j][dspn2]=calibdata2->DSPped_par[i][ii]; |
442 |
|
|
ca->sigma[jj][j][dspn2]=calibdata2->DSPsig_par[i][ii]; |
443 |
|
|
if(calibdata2->DSPbad_par[i][ii]==0) |
444 |
|
|
ca->bad[jj][j][dspn2]=1; |
445 |
|
|
else if(calibdata2->DSPbad_par[i][ii]==1) |
446 |
|
|
ca->bad[jj][j][dspn2]=0; |
447 |
|
|
// cout<<"sigma trk2= "<<sigma[jj][j][dspn2]<<endl; |
448 |
|
|
// cout<<"sigma_t trk2= "<<sigma_t[jj][j][dspn2]<<endl; |
449 |
|
|
} |
450 |
pam-fi |
1.1 |
}; |
451 |
|
|
}; |
452 |
|
|
|
453 |
|
|
tr1->Delete(); |
454 |
|
|
tr2->Delete(); |
455 |
|
|
}; |
456 |
|
|
/** |
457 |
|
|
* Method to fill the tracker calibration-parameter struct from on-line calibrations |
458 |
|
|
*/ |
459 |
|
|
void TrkParams::FillTCalibFrom(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
460 |
|
|
|
461 |
|
|
cTrkCalib *ca = &pedsigbad_; |
462 |
pam-fi |
1.10 |
// ca->Reset(); |
463 |
pam-fi |
1.1 |
|
464 |
|
|
TTree *tr1 = (TTree*)f0->Get("CalibTrk1"); |
465 |
|
|
TTree *tr2 = (TTree*)f0->Get("CalibTrk2"); |
466 |
|
|
|
467 |
|
|
CalibTrk1Event *calibdata1 = 0; |
468 |
|
|
CalibTrk2Event *calibdata2 = 0; |
469 |
|
|
tr1->SetBranchAddress("CalibTrk1",&calibdata1); |
470 |
|
|
tr2->SetBranchAddress("CalibTrk2",&calibdata2); |
471 |
|
|
tr1->GetEntry(ev_reg1); |
472 |
|
|
tr2->GetEntry(ev_reg2); |
473 |
|
|
Int_t dspn1(0),dspn2(0); |
474 |
|
|
|
475 |
pam-fi |
1.4 |
// --- TEST TEST TEST TEST --- // |
476 |
pam-fi |
1.10 |
// 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 |
pam-fi |
1.4 |
|
486 |
pam-fi |
1.1 |
for(Int_t i=0;i<6;i++){ |
487 |
|
|
dspn1=calibdata1->DSPnumber[i]-1; |
488 |
|
|
dspn2=calibdata2->DSPnumber[i]-1; |
489 |
|
|
/* cout<<"dspn1= "<<dspn1<<" dspn2= "<<dspn2<<endl; */ |
490 |
|
|
for(Int_t ii=0;ii<3072;ii++){ |
491 |
|
|
Int_t j=(ii/128); |
492 |
|
|
Int_t jj=ii-j*128; |
493 |
pam-fi |
1.10 |
if(dspn1>=0 && dspn1<12){ |
494 |
|
|
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]); |
496 |
|
|
} |
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 |
pam-fi |
1.1 |
}; |
502 |
|
|
}; |
503 |
|
|
|
504 |
|
|
tr1->Delete(); |
505 |
|
|
tr2->Delete(); |
506 |
|
|
}; |
507 |
|
|
/** |
508 |
|
|
* Method to fill the tracker calibration-parameter struct from default calibration |
509 |
|
|
*/ |
510 |
|
|
void TrkParams::FillTCalibFrom(TString path){ |
511 |
|
|
|
512 |
|
|
path_.FillWith(path); |
513 |
|
|
fillpedsigfromdefault_(); |
514 |
|
|
if(path_.error) throw -216; |
515 |
|
|
|
516 |
|
|
}; |
517 |
|
|
/** |
518 |
|
|
* Method to fill the tracker VA1-mask struct from calibration |
519 |
|
|
*/ |
520 |
|
|
void TrkParams::FillMask(TFile* f0, Int_t ev_reg1, Int_t ev_reg2){ |
521 |
|
|
|
522 |
|
|
cTrkMask *ma = &mask_; |
523 |
pam-fi |
1.10 |
ma->Reset(); |
524 |
pam-fi |
1.1 |
|
525 |
|
|
TrkCalib *calib = new TrkCalib(); |
526 |
|
|
|
527 |
|
|
for(Int_t i=0; i<2; i++){ |
528 |
|
|
TTree *tr=0; |
529 |
|
|
if(i==0){ |
530 |
|
|
//------------------------- |
531 |
|
|
//read calibration packet 1 |
532 |
|
|
//------------------------- |
533 |
|
|
tr = (TTree*)f0->Get("CalibTrk1"); |
534 |
|
|
tr->SetBranchAddress("CalibTrk1",calib->GetPointerTo()); |
535 |
|
|
tr->GetEntry(ev_reg1); |
536 |
|
|
} |
537 |
|
|
if(i==1){ |
538 |
|
|
//------------------------- |
539 |
|
|
//read calibration packet 2 |
540 |
|
|
//------------------------- |
541 |
|
|
tr = (TTree*)f0->Get("CalibTrk2"); |
542 |
|
|
tr->SetBranchAddress("CalibTrk2",calib->GetPointerTo()); |
543 |
|
|
tr->GetEntry(ev_reg2); |
544 |
|
|
} |
545 |
|
|
for(Int_t ipkt=0; ipkt<NPLANE; ipkt++){ |
546 |
pam-fi |
1.10 |
Int_t view = calib->GetView(ipkt); |
547 |
|
|
if( (view-1)>= 0 && (view-1)<12 ){ |
548 |
|
|
for(Int_t ivk=0; ivk<NVK; ivk++){ |
549 |
|
|
Float_t sigm = calib->GetMean("SIG-BAD",ipkt,ivk+1); |
550 |
|
|
Float_t sigmin = 0.; |
551 |
|
|
if(view%2)sigmin = 6.5; |
552 |
|
|
else sigmin = 2.5; |
553 |
|
|
Int_t mask = 1; |
554 |
|
|
if( sigm<sigmin )mask = 0; |
555 |
|
|
ma->mask_vk_run[ivk][view-1] = mask; |
556 |
|
|
} |
557 |
|
|
} |
558 |
pam-fi |
1.1 |
} |
559 |
|
|
if(tr)tr->Delete(); |
560 |
|
|
} |
561 |
|
|
|
562 |
pam-fi |
1.10 |
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 |
pam-fi |
1.1 |
if(calib)calib->Delete(); |
571 |
|
|
|
572 |
|
|
}; |
573 |
|
|
|
574 |
pam-fi |
1.3 |
// Bool_t TrkParams::CalibIsLoaded(UInt_t time){ |
575 |
|
|
|
576 |
|
|
// if( !calibload ) return false; |
577 |
|
|
|
578 |
|
|
// }; |
579 |
|
|
|
580 |
|
|
|
581 |
pam-fi |
1.1 |
/** |
582 |
pam-fi |
1.10 |
* \brief Static method to load calibration. |
583 |
|
|
* Calibration is loaded ONLY IF TrkParams::CalibLoaded()==kTRUE, which appens after the method TrkParams::SetCalib(***) is called. |
584 |
pam-fi |
1.1 |
*/ |
585 |
|
|
Bool_t TrkParams::LoadCalib( ){ |
586 |
|
|
|
587 |
|
|
if( TrkParams::CalibIsLoaded() )return false; |
588 |
|
|
|
589 |
|
|
// ============================================================= |
590 |
|
|
// retrieve calibration file needed to reduce data |
591 |
|
|
// ============================================================= |
592 |
|
|
// if run OBT is > last calibration "expiration date" |
593 |
|
|
// - search for new calibration packet |
594 |
|
|
// - load calibration parameters (full + truncated) |
595 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode()){ |
596 |
|
|
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 |
pam-fi |
1.1 |
FileStat_t t; |
602 |
|
|
if( gSystem->GetPathInfo(calibpathf.Data(),t) )return false; |
603 |
|
|
|
604 |
pam-fi |
1.6 |
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 |
pam-fi |
1.1 |
if ( !f0_c ) return false; |
610 |
pam-fi |
1.6 |
|
611 |
|
|
if(TrkParams::VerboseMode()){ |
612 |
|
|
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 |
pam-fi |
1.1 |
TrkParams::FillACalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
617 |
pam-fi |
1.21 |
if(TrkParams::VerboseMode())cout << " - VK-mask (RUN-by-RUN)"<<endl; |
618 |
pam-fi |
1.1 |
TrkParams::FillMask(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
619 |
|
|
|
620 |
|
|
// ============================================================= |
621 |
|
|
// retrieve calibration file needed to uncompress data |
622 |
|
|
// ============================================================= |
623 |
|
|
// if the run was compressed using default calib |
624 |
|
|
// load truncated pedestals from default |
625 |
|
|
// otherwise reload them from on-line calibration |
626 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " Truncated pedestals for uncompression:"; |
627 |
pam-fi |
1.1 |
if( calib104 ){ |
628 |
|
|
|
629 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " >> loading default calibration: "<< calibpatht << endl; |
630 |
pam-fi |
1.1 |
TrkParams::FillTCalibFrom(calibpatht); |
631 |
|
|
|
632 |
|
|
}else{ |
633 |
|
|
|
634 |
pam-fi |
1.6 |
// if ( !f0_c ) return false; |
635 |
|
|
if(TrkParams::VerboseMode())cout << ">> already loaded " << endl; |
636 |
|
|
// TrkParams::FillTCalibFrom(f0_c,calib.EV_ROOT_CALIBTRK1,calib.EV_ROOT_CALIBTRK2); |
637 |
pam-fi |
1.1 |
}; |
638 |
pam-fi |
1.6 |
if(!alreadyopened)f0_c->Close(); |
639 |
|
|
if(TrkParams::VerboseMode())cout << "--------------------------------------"<<endl; |
640 |
pam-fi |
1.1 |
|
641 |
|
|
calibload = kTRUE; |
642 |
|
|
return true; |
643 |
|
|
}; |
644 |
|
|
|
645 |
|
|
Int_t TrkParams::GetIndex( UInt_t type ){ |
646 |
|
|
Int_t index = -1; |
647 |
|
|
for (Int_t i=0; i< NTYPES; i++)if( type == trkparamtype[i] )index=i; |
648 |
|
|
return index; |
649 |
|
|
}; |
650 |
|
|
|
651 |
|
|
/** |
652 |
|
|
* Set tracker parameters proper for a run querying the DB. |
653 |
|
|
* @param glrun Input run info |
654 |
|
|
* @param dbc Database |
655 |
|
|
* @param type Parameter type |
656 |
|
|
* @return FALSE if parameter set fails. |
657 |
pam-fi |
1.18 |
* If glrun==NULL the first parameter entry from GL_PARAM table is set. |
658 |
pam-fi |
1.1 |
* If dbc==NULL, try to open a connection taking DB-connection |
659 |
|
|
* parameters from PAMELA environment variables. |
660 |
|
|
*/ |
661 |
|
|
Bool_t TrkParams::Set( GL_RUN* glrun , TSQLServer* dbc , UInt_t type){ |
662 |
|
|
|
663 |
|
|
|
664 |
pam-fi |
1.6 |
UInt_t index = TrkParams::GetIndex( type ); |
665 |
|
|
if(index < 0)return false; |
666 |
|
|
|
667 |
pam-fi |
1.16 |
UInt_t runheadtime=0; |
668 |
|
|
UInt_t runid=0; |
669 |
|
|
// 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 |
pam-fi |
1.21 |
if(TrkParams::VerboseMode())cout << "<< set TrkParams type "<<type<<" from DB << RUN "<<runid<<endl; |
677 |
pam-fi |
1.16 |
|
678 |
|
|
|
679 |
pam-fi |
1.6 |
if( !TrkParams::IsLoaded(type) || |
680 |
pam-fi |
1.16 |
runheadtime < gl[index].FROM_TIME || |
681 |
|
|
runheadtime > gl[index].TO_TIME || |
682 |
pam-fi |
1.6 |
false ){ |
683 |
pam-fi |
1.1 |
|
684 |
pam-fi |
1.18 |
bool LOCAL_CONNECTION = false; |
685 |
pam-fi |
1.6 |
if( !dbc || (dbc && !dbc->IsConnected()) ){ |
686 |
pam-fi |
1.1 |
|
687 |
pam-fi |
1.6 |
if(TrkParams::WarningMode())cout <<" Missing DB connection -- check PAMELA environment variables "<<endl; |
688 |
pam-fi |
1.18 |
dbc = TrkParams::SetDBConnection(); |
689 |
|
|
if(dbc && dbc->IsConnected())LOCAL_CONNECTION = true; |
690 |
|
|
|
691 |
pam-fi |
1.6 |
} |
692 |
pam-fi |
1.1 |
|
693 |
pam-fi |
1.6 |
GL_PARAM q4; |
694 |
pam-fi |
1.18 |
if( q4.Query_GL_PARAM(runheadtime,type,dbc) )return false; |
695 |
|
|
if(LOCAL_CONNECTION){ |
696 |
|
|
dbc->Close(); |
697 |
|
|
delete dbc; |
698 |
|
|
} |
699 |
pam-fi |
1.6 |
gl[index] = q4; |
700 |
|
|
glpath[index] = q4.PATH+q4.NAME; |
701 |
|
|
glload[index] = false; |
702 |
pam-fi |
1.16 |
|
703 |
pam-fi |
1.6 |
return true; |
704 |
pam-fi |
1.1 |
|
705 |
pam-fi |
1.6 |
} |
706 |
|
|
return false; |
707 |
pam-fi |
1.1 |
|
708 |
|
|
}; |
709 |
|
|
/** |
710 |
pam-fi |
1.2 |
* Set tracker parameters proper for the run, from input. |
711 |
pam-fi |
1.1 |
* @param path Path to parameters directory |
712 |
|
|
* @param type Parameter type |
713 |
|
|
* @return FALSE if parameter set fails. |
714 |
|
|
*/ |
715 |
|
|
Bool_t TrkParams::Set( TString path , UInt_t type){ |
716 |
|
|
|
717 |
|
|
UInt_t index = TrkParams::GetIndex( type ); |
718 |
|
|
if(index < 0)return false; |
719 |
|
|
|
720 |
|
|
gl[index].TYPE= type; |
721 |
|
|
glpath[index] = path; |
722 |
pam-fi |
1.12 |
if(TrkParams::VerboseMode()) |
723 |
|
|
cout << "<< set TrkParams type "<<type<<" from path << "<<path<<endl; |
724 |
pam-fi |
1.1 |
glload[index] = false; |
725 |
|
|
|
726 |
|
|
// return TrkParams::Load(type); |
727 |
|
|
return true; |
728 |
|
|
|
729 |
|
|
}; |
730 |
|
|
|
731 |
|
|
/** |
732 |
|
|
* Set and load tracker parameters. |
733 |
|
|
* @param type Parameter type |
734 |
|
|
* If no path as been yet specified, it set a default path. |
735 |
|
|
* @return FALSE if parameter set fails. |
736 |
|
|
*/ |
737 |
|
|
Bool_t TrkParams::Set(UInt_t type){ |
738 |
|
|
|
739 |
|
|
|
740 |
pam-fi |
1.16 |
return Set(0,0,type); |
741 |
|
|
|
742 |
pam-fi |
1.1 |
|
743 |
|
|
}; |
744 |
|
|
/** |
745 |
|
|
* Set tracker parameters. |
746 |
|
|
* If no path as been yet specified, try to read from DB |
747 |
|
|
* otherwise it set a default path. |
748 |
|
|
* @return FALSE if parameter set fails. |
749 |
|
|
*/ |
750 |
|
|
Bool_t TrkParams::Set( ){ |
751 |
|
|
|
752 |
pam-fi |
1.16 |
|
753 |
|
|
for(Int_t i=0; i<NTYPES; i++)if ( !TrkParams::Set(trkparamtype[i])) return false; |
754 |
pam-fi |
1.3 |
|
755 |
|
|
return true; |
756 |
pam-fi |
1.1 |
} |
757 |
|
|
|
758 |
|
|
/** |
759 |
|
|
* Load tracker parameter, if not already loaded. |
760 |
|
|
* @param type Parameter type |
761 |
|
|
* ( Any call to TrkParams::Set(...) forces reloading ) |
762 |
|
|
*/ |
763 |
|
|
Bool_t TrkParams::Load(UInt_t type){ |
764 |
|
|
|
765 |
|
|
Int_t index = TrkParams::GetIndex( type ); |
766 |
|
|
if( index<0 )return false; |
767 |
|
|
if( glload[index] )return true; |
768 |
|
|
|
769 |
|
|
if( glpath[index].IsNull() )TrkParams::Set(type); |
770 |
|
|
|
771 |
|
|
switch( type ){ |
772 |
|
|
//------------------------------------------ |
773 |
|
|
case 1: |
774 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading magnetic field "<<glpath[index]<<endl; |
775 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
776 |
|
|
path_.pathlen = glpath[index].Length(); |
777 |
|
|
path_.error = 0; |
778 |
|
|
readb_(); |
779 |
|
|
if(path_.error) return false; |
780 |
|
|
glload[index]=true; |
781 |
|
|
break; |
782 |
|
|
//------------------------------------------ |
783 |
|
|
case 2: |
784 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading ADC-to-MIP conversion parameters "<<glpath[index]<<endl; |
785 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
786 |
|
|
path_.pathlen = glpath[index].Length(); |
787 |
|
|
path_.error = 0; |
788 |
|
|
readmipparam_(); |
789 |
|
|
if(path_.error) return false; |
790 |
|
|
glload[index]=true; |
791 |
|
|
break; |
792 |
|
|
//------------------------------------------ |
793 |
|
|
case 3: |
794 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading charge-correlation parameters "<<glpath[index]<<endl; |
795 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
796 |
|
|
path_.pathlen = glpath[index].Length(); |
797 |
|
|
path_.error = 0; |
798 |
|
|
readchargeparam_(); |
799 |
|
|
if(path_.error) return false; |
800 |
|
|
glload[index]=true; |
801 |
|
|
break; |
802 |
|
|
//------------------------------------------ |
803 |
|
|
case 4: |
804 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading p.f.a. parameters "<<glpath[index]<<endl; |
805 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
806 |
|
|
path_.pathlen = glpath[index].Length(); |
807 |
|
|
path_.error = 0; |
808 |
|
|
readetaparam_(); |
809 |
|
|
if(path_.error) return false; |
810 |
|
|
glload[index]=true; |
811 |
|
|
break; |
812 |
|
|
//------------------------------------------ |
813 |
|
|
case 5: |
814 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading alignment parameters "<<glpath[index]<<endl; |
815 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
816 |
|
|
path_.pathlen = glpath[index].Length(); |
817 |
|
|
path_.error = 0; |
818 |
|
|
readalignparam_(); |
819 |
|
|
if(path_.error) return false; |
820 |
|
|
glload[index]=true; |
821 |
|
|
break; |
822 |
|
|
//------------------------------------------ |
823 |
|
|
case 6: |
824 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading VK-mask parameters "<<glpath[index]<<endl; |
825 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
826 |
|
|
path_.pathlen = glpath[index].Length(); |
827 |
|
|
path_.error = 0; |
828 |
|
|
readvkmask_(); |
829 |
|
|
if(path_.error) return false; |
830 |
|
|
glload[index]=true; |
831 |
|
|
break; |
832 |
|
|
//------------------------------------------ |
833 |
|
|
case 7: |
834 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout <<type<<" -- Loading default calibration "<<glpath[index]<<endl; |
835 |
pam-fi |
1.1 |
strcpy(path_.path,glpath[index].Data()); |
836 |
|
|
path_.pathlen = glpath[index].Length(); |
837 |
|
|
path_.error = 0; |
838 |
|
|
// fillpedsigfromdefault_(); |
839 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << ">> not implemented <<"<<endl; |
840 |
pam-fi |
1.1 |
if(path_.error) return false; |
841 |
|
|
glload[index]=true; |
842 |
|
|
break; |
843 |
|
|
default: |
844 |
pam-fi |
1.6 |
if(TrkParams::VerboseMode())cout << " Bool_t TrkParams::Load(UInt_t type) -- type "<< type << "not yet implemented"<<endl; |
845 |
pam-fi |
1.1 |
return false; |
846 |
|
|
}; |
847 |
|
|
|
848 |
|
|
return true; |
849 |
|
|
} |
850 |
|
|
|
851 |
|
|
Bool_t TrkParams::Load( ){ |
852 |
|
|
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )if( !TrkParams::Load(trkparamtype[i]) )return false; |
853 |
|
|
return true; |
854 |
|
|
}; |
855 |
|
|
Bool_t TrkParams::IsLoaded( ){ |
856 |
|
|
for(Int_t i=0 ; i<NTYPES; i++)if(!glload[i] && trkparamtype[i]>0 )return false; |
857 |
|
|
return true; |
858 |
|
|
}; |
859 |
|
|
|
860 |
pam-fi |
1.8 |
|
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 |
pam-fi |
1.9 |
|
896 |
pam-fi |
1.8 |
/** |
897 |
|
|
* \brief Set tracking mode (0=standard. 1=???) |
898 |
|
|
*/ |
899 |
|
|
void TrkParams::SetTrackingMode(int trackmode) { |
900 |
|
|
init__mini_trackmode = trackmode; |
901 |
pam-fi |
1.19 |
SetTrackingMode(); //fill F77 common |
902 |
pam-fi |
1.8 |
}; |
903 |
|
|
/** |
904 |
|
|
* \brief Set fit-precision factor (typical value fact=100.) |
905 |
|
|
*/ |
906 |
|
|
void TrkParams::SetPrecisionFactor(double fact){ |
907 |
|
|
init__mini_fact = fact; |
908 |
pam-fi |
1.19 |
SetPrecisionFactor(); //fill F77 common |
909 |
pam-fi |
1.8 |
}; |
910 |
|
|
/** |
911 |
|
|
* \brief Set minimum number of step in track fitting |
912 |
|
|
*/ |
913 |
|
|
void TrkParams::SetStepMin(int istepmin){ |
914 |
|
|
init__mini_istepmin = istepmin; |
915 |
pam-fi |
1.19 |
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 |
pam-fi |
1.8 |
}; |
926 |
pam-fi |
1.20 |
/** |
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 |
pam-fi |
1.8 |
|
934 |
|
|
/** |
935 |
pam-fi |
1.19 |
* \brief Fill F77 commons with PFA settings |
936 |
pam-fi |
1.13 |
*/ |
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 |
pam-fi |
1.8 |
* \brief Set p.f.a. |
946 |
|
|
* |
947 |
|
|
* Implemented algorythms: |
948 |
pam-fi |
1.11 |
* 0 ETA |
949 |
pam-fi |
1.8 |
* 1 --- |
950 |
|
|
* 2 ETA2 |
951 |
|
|
* 3 ETA3 |
952 |
|
|
* 4 ETA4 |
953 |
pam-fi |
1.11 |
* 5 ETAL ==> ETA+LANDI |
954 |
pam-fi |
1.8 |
* 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 |
pam-fi |
1.19 |
SetPFA(); //fill F77 common |
963 |
pam-fi |
1.8 |
}; |
964 |
pam-fi |
1.9 |
/** |
965 |
pam-fi |
1.13 |
* \brief Set p.f.a. angular intervals |
966 |
|
|
* |
967 |
pam-fi |
1.19 |
* 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 |
pam-fi |
1.13 |
* @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 |
pam-fi |
1.19 |
SetPFA(); //fill F77 common |
979 |
pam-fi |
1.13 |
}; |
980 |
pam-fi |
1.14 |
|
981 |
|
|
|
982 |
pam-fi |
1.13 |
/** |
983 |
pam-fi |
1.9 |
* \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 |
pam-fi |
1.8 |
|
1002 |
|
|
|
1003 |
|
|
|
1004 |
pam-fi |
1.14 |
|
1005 |
pam-fi |
1.1 |
ClassImp(TrkParams); |