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