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