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