196 |
cpuhe->SetBranchAddress("Header",&ch); |
cpuhe->SetBranchAddress("Header",&ch); |
197 |
// |
// |
198 |
Long64_t ncalibs = tr->GetEntries();//cerca il ramo Entries (calibrazioni) |
Long64_t ncalibs = tr->GetEntries();//cerca il ramo Entries (calibrazioni) |
199 |
if ( ncalibs == 0 ){ |
if ( ncalibs == 0 || cpuhe->GetEntries() == 0){ |
200 |
printf(" No calibrations in this files! \n Exiting... \n"); |
printf(" No calibrations in this files! \n Exiting... \n"); |
201 |
return; |
return; |
202 |
}; |
}; |
203 |
|
// |
204 |
|
UInt_t cpuhead[1000]; |
205 |
|
memset(cpuhead, 0, 1000*sizeof(UInt_t)); |
206 |
|
for (Int_t i=0; i<cpuhe->GetEntries(); i++){ |
207 |
|
cpuhe->GetEntry(i); |
208 |
|
if ( i < 1000 ) cpuhead[i]=ch->GetPscuHeader()->GetOrbitalTime(); |
209 |
|
if ( i > 1000 ){ |
210 |
|
printf(" ERROR: too many calibrations in this file, cannot handle it \n Exiting... \n"); |
211 |
|
return; |
212 |
|
}; |
213 |
|
}; |
214 |
|
// |
215 |
printf("\n This file contains %i entries which corrispond to %i calibrations \n\n",(int)ncalibs,(int)ncalibs/4); |
printf("\n This file contains %i entries which corrispond to %i calibrations \n\n",(int)ncalibs,(int)ncalibs/4); |
216 |
Long64_t minev = 0; |
Long64_t minev = 0; |
217 |
Long64_t maxev = ncalibs; |
Long64_t maxev = ncalibs; |
252 |
stringstream figsave; //definisco stringhe i/o |
stringstream figsave; //definisco stringhe i/o |
253 |
stringstream figsave1; |
stringstream figsave1; |
254 |
stringstream figsave2; |
stringstream figsave2; |
255 |
|
if ( !strcmp(format,"ps") ) { |
256 |
|
figsave.str(""); |
257 |
|
figsave << outdir << "/" ; |
258 |
|
figsave << figrec << "_CaloCHKCALIB."; |
259 |
|
figsave << format; |
260 |
|
figsave << "("; |
261 |
|
}; |
262 |
// |
// |
263 |
|
|
264 |
//-----------------inizio CHECK per ricerca errori dal calorimetro------------------- |
//-----------------inizio CHECK per ricerca errori dal calorimetro------------------- |
267 |
Bool_t check = false;//azzera flag presenza errori |
Bool_t check = false;//azzera flag presenza errori |
268 |
|
|
269 |
// |
// |
270 |
|
Int_t hi = (minev/4)-1; |
271 |
//inizio loop su tutti gli header degli eventi di calibrazione |
//inizio loop su tutti gli header degli eventi di calibrazione |
272 |
for (Int_t ci = minev; ci < maxev ; ci+=4){ |
// for (Int_t ci = minev; ci < maxev ; ci+=4){ |
273 |
|
Int_t ci = minev; |
274 |
|
while ( ci < maxev ){ |
275 |
//scorre i pacchetti di 4 in 4 (cioe scorre le calibrazioni) |
//scorre i pacchetti di 4 in 4 (cioe scorre le calibrazioni) |
276 |
Int_t incalrms = 0; |
Int_t incalrms = 0; |
277 |
Int_t outcalrms = 0; |
Int_t outcalrms = 0; |
285 |
Int_t incalbas = 0; |
Int_t incalbas = 0; |
286 |
Int_t outcalbas = 0; |
Int_t outcalbas = 0; |
287 |
//dall'albero calibheader, cerco obt dell cpu |
//dall'albero calibheader, cerco obt dell cpu |
288 |
cpuhe->GetEntry(ci/4); |
// cpuhe->GetEntry(ci/4); |
289 |
cpuobt=ch->GetPscuHeader()->GetOrbitalTime(); |
hi++; |
290 |
|
// cpuobt=ch->GetPscuHeader()->GetOrbitalTime(); |
291 |
|
cpuobt=cpuhead[hi]; |
292 |
obt0=0; |
obt0=0; |
293 |
obt1=0; |
obt1=0; |
294 |
obt2=0; |
obt2=0; |
295 |
obt3=0; |
obt3=0; |
296 |
|
// |
297 |
|
calib.iev=0; |
298 |
|
memset(calib.cstwerr,0,4*sizeof(Int_t)); |
299 |
|
memset(calib.cperror,0,4*sizeof(Float_t)); |
300 |
|
memset(calib.calped,0,2*22*96*sizeof(Float_t)); |
301 |
|
memset(calib.calgood,0,2*22*96*sizeof(Float_t)); |
302 |
|
memset(calib.calrms,0,2*22*96*sizeof(Float_t)); |
303 |
|
memset(calib.calpuls,0,2*22*96*sizeof(Float_t)); |
304 |
|
memset(calib.calthr,0,2*22*6*sizeof(Float_t)); |
305 |
|
memset(calib.calvar,0,2*22*6*sizeof(Float_t)); |
306 |
|
memset(calib.calbase,0,2*22*6*sizeof(Float_t)); |
307 |
|
// |
308 |
//inizio loop su i 4 pacchetti per ogni calibrazione (scorre 4 successivi) |
//inizio loop su i 4 pacchetti per ogni calibrazione (scorre 4 successivi) |
309 |
for ( Int_t s=0 ; s<4 ;s++ ){ |
// for ( Int_t s=0 ; s<4 ;s++ ){ |
310 |
|
Int_t s = 0; |
311 |
|
obt = cpuhead[hi]; |
312 |
|
// printf(" qui cpu header : %i hi %i entry %i \n",obt,hi,ci); |
313 |
|
while ( labs((Int_t)(obt-cpuhead[hi])) < 100000 && ci < maxev){ |
314 |
|
|
315 |
tr->GetEntry(ci+s);//sceglie la entry (calibrazione)del tree in cui ho tutte le sottostrutture |
tr->GetEntry(ci);//sceglie la entry (calibrazione)del tree in cui ho tutte le sottostrutture |
316 |
|
// tr->GetEntry(ci+s);//sceglie la entry (calibrazione)del tree in cui ho tutte le sottostrutture |
317 |
|
|
318 |
|
//trovo l'OBT della entry (pacchetto) |
|
//trovo l'OBT della entry (pacchetto) |
|
319 |
obt=eh->GetPscuHeader()->GetOrbitalTime();//cerca orbitaltime all'interno di Pscu |
obt=eh->GetPscuHeader()->GetOrbitalTime();//cerca orbitaltime all'interno di Pscu |
320 |
/// |
// |
321 |
|
//printf(" qui pkt header : %i \n",obt); |
322 |
|
|
323 |
|
ci++; |
324 |
|
|
325 |
|
if ( labs((Int_t)(obt-cpuhead[hi])) < 100000 ){ |
326 |
|
|
327 |
calib.iev = ce->iev; |
// s++; |
328 |
cestw = 0; |
if ( ce->cstwerr[0] ) s = 0; |
329 |
//cstwerr e' tutto l'header della sezione, mi interessano gli ultimi 2 Byte(errori del calorimetro) |
if ( ce->cstwerr[1] ) s = 1; |
330 |
if ( ce->cstwerr[s] ){ |
if ( ce->cstwerr[2] ) s = 2; |
331 |
cestw = ce->cstwerr[s] & cmask ; //confronto con la maschera per tenere solo gli |
if ( ce->cstwerr[3] ) s = 3; |
332 |
ver[s][16]++;// ultimi 2 Byte (assegnati a cestw) |
//printf(" qua pkt header : %i s = %i hi %i \n",obt,s,hi); |
333 |
}; |
// |
334 |
if ( cestw ){//errori dal calorimetro |
calib.iev = ce->iev; |
335 |
if ( cestw & (1 << 0) ) ver[s][6]++ ;//spostati di uno e confronto se diverso 0 |
cestw = 0; |
336 |
if ( cestw & (1 << 1) ) ver[s][5]++ ; |
//cstwerr e' tutto l'header della sezione, mi interessano gli ultimi 2 Byte(errori del calorimetro) |
337 |
if ( cestw & (1 << 2) ) ver[s][4]++ ; |
if ( ce->cstwerr[s] ){ |
338 |
if ( cestw & (1 << 3) ) ver[s][3]++ ; |
cestw = ce->cstwerr[s] & cmask ; //confronto con la maschera per tenere solo gli |
339 |
if ( cestw & (1 << 4) ) ver[s][2]++ ; |
ver[s][16]++;// ultimi 2 Byte (assegnati a cestw) |
|
if ( cestw & (1 << 5) ) ver[s][1]++ ; |
|
|
if ( cestw & (1 << 6) ) ver[s][0]++ ; |
|
|
}; |
|
|
if ( ce->cperror[s] != 0. ){//errori dallo spacchettamento |
|
|
if (ce->cperror[s] == 128) ver[s][7]++ ; |
|
|
if (ce->cperror[s] == 129) ver[s][8]++ ; |
|
|
if (ce->cperror[s] == 130) { |
|
|
ver[s][9]++ ; |
|
|
ver[s][16]--; |
|
340 |
}; |
}; |
341 |
if (ce->cperror[s] == 132) ver[s][11]++ ; |
if ( cestw ){//errori dal calorimetro |
342 |
if (ce->cperror[s] == 140) ver[s][19]++ ; |
if ( cestw & (1 << 0) ) ver[s][6]++ ;//spostati di uno e confronto se diverso 0 |
343 |
if (ce->cperror[s] == 141) ver[s][20]++ ; |
if ( cestw & (1 << 1) ) ver[s][5]++ ; |
344 |
if (ce->cperror[s] == 142) ver[s][22]++ ; |
if ( cestw & (1 << 2) ) ver[s][4]++ ; |
345 |
}; |
if ( cestw & (1 << 3) ) ver[s][3]++ ; |
346 |
//lato oscuro :p |
if ( cestw & (1 << 4) ) ver[s][2]++ ; |
347 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
if ( cestw & (1 << 5) ) ver[s][1]++ ; |
348 |
Int_t pre = -1; |
if ( cestw & (1 << 6) ) ver[s][0]++ ; |
349 |
for ( Int_t j=0; j<96 ;j++){ |
}; |
350 |
if ( j%16 == 0 ) pre++; |
if ( ce->cperror[s] != 0. ){//errori dallo spacchettamento |
351 |
if ( s == 2 ){ |
if (ce->cperror[s] == 128) ver[s][7]++ ; |
352 |
//aggiungo obt del pacchetto che sta leggendo(obt) |
if (ce->cperror[s] == 129) ver[s][8]++ ; |
353 |
obt2=obt; |
if (ce->cperror[s] == 130) { |
354 |
calib.calped[0][2*d+1][j] = ce->calped[3][d][j]; |
ver[s][9]++ ; |
355 |
calib.cstwerr[3] = ce->cstwerr[3]; |
ver[s][16]--; |
|
calib.cperror[3] = ce->cperror[3]; |
|
|
calib.calgood[0][2*d+1][j] = ce->calgood[3][d][j]; |
|
|
calib.calthr[0][2*d+1][pre] = ce->calthr[3][d][pre]; |
|
|
calib.calrms[0][2*d+1][j] = ce->calrms[3][d][j]; |
|
|
calib.calbase[0][2*d+1][pre] = ce->calbase[3][d][pre]; |
|
|
calib.calvar[0][2*d+1][pre] = ce->calvar[3][d][pre]; |
|
|
}; |
|
|
if ( s == 3 ){ |
|
|
obt3=obt; |
|
|
calib.calped[0][2*d][j] = ce->calped[1][d][j]; |
|
|
calib.cstwerr[1] = ce->cstwerr[1]; |
|
|
calib.cperror[1] = ce->cperror[1]; |
|
|
calib.calgood[0][2*d][j] = ce->calgood[1][d][j]; |
|
|
calib.calthr[0][2*d][pre] = ce->calthr[1][d][pre]; |
|
|
calib.calrms[0][2*d][j] = ce->calrms[1][d][j]; |
|
|
calib.calbase[0][2*d][pre] = ce->calbase[1][d][pre]; |
|
|
calib.calvar[0][2*d][pre] = ce->calvar[1][d][pre]; |
|
|
}; |
|
|
if ( s == 0 ){ |
|
|
obt0=obt; |
|
|
calib.calped[1][2*d][j] = ce->calped[0][d][j]; |
|
|
calib.cstwerr[0] = ce->cstwerr[0]; |
|
|
calib.cperror[0] = ce->cperror[0]; |
|
|
calib.calgood[1][2*d][j] = ce->calgood[0][d][j]; |
|
|
calib.calthr[1][2*d][pre] = ce->calthr[0][d][pre]; |
|
|
calib.calrms[1][2*d][j] = ce->calrms[0][d][j]; |
|
|
calib.calbase[1][2*d][pre] = ce->calbase[0][d][pre]; |
|
|
calib.calvar[1][2*d][pre] = ce->calvar[0][d][pre]; |
|
|
}; |
|
|
if ( s == 1 ){ |
|
|
obt1=obt; |
|
|
calib.calped[1][2*d+1][j] = ce->calped[2][d][j]; |
|
|
calib.cstwerr[2] = ce->cstwerr[2]; |
|
|
calib.cperror[2] = ce->cperror[2]; |
|
|
calib.calgood[1][2*d+1][j] = ce->calgood[2][d][j]; |
|
|
calib.calthr[1][2*d+1][pre] = ce->calthr[2][d][pre]; |
|
|
calib.calrms[1][2*d+1][j] = ce->calrms[2][d][j]; |
|
|
calib.calbase[1][2*d+1][pre] = ce->calbase[2][d][pre]; |
|
|
calib.calvar[1][2*d+1][pre] = ce->calvar[2][d][pre]; |
|
356 |
}; |
}; |
357 |
|
if (ce->cperror[s] == 132) ver[s][11]++ ; |
358 |
|
if (ce->cperror[s] == 140) ver[s][19]++ ; |
359 |
|
if (ce->cperror[s] == 141) ver[s][20]++ ; |
360 |
|
if (ce->cperror[s] == 142) ver[s][22]++ ; |
361 |
}; |
}; |
362 |
};//chiuso for su si(sezioni) |
//lato oscuro :p |
363 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
364 |
|
Int_t pre = -1; |
365 |
|
for ( Int_t j=0; j<96 ;j++){ |
366 |
|
if ( j%16 == 0 ) pre++; |
367 |
|
if ( s == 2 ){ |
368 |
|
//aggiungo obt del pacchetto che sta leggendo(obt) |
369 |
|
obt2=obt; |
370 |
|
calib.calped[0][2*d+1][j] = ce->calped[3][d][j]; |
371 |
|
calib.cstwerr[3] = ce->cstwerr[3]; |
372 |
|
calib.cperror[3] = ce->cperror[3]; |
373 |
|
calib.calgood[0][2*d+1][j] = ce->calgood[3][d][j]; |
374 |
|
calib.calthr[0][2*d+1][pre] = ce->calthr[3][d][pre]; |
375 |
|
calib.calrms[0][2*d+1][j] = ce->calrms[3][d][j]; |
376 |
|
calib.calbase[0][2*d+1][pre] = ce->calbase[3][d][pre]; |
377 |
|
calib.calvar[0][2*d+1][pre] = ce->calvar[3][d][pre]; |
378 |
|
}; |
379 |
|
if ( s == 3 ){ |
380 |
|
obt3=obt; |
381 |
|
calib.calped[0][2*d][j] = ce->calped[1][d][j]; |
382 |
|
calib.cstwerr[1] = ce->cstwerr[1]; |
383 |
|
calib.cperror[1] = ce->cperror[1]; |
384 |
|
calib.calgood[0][2*d][j] = ce->calgood[1][d][j]; |
385 |
|
calib.calthr[0][2*d][pre] = ce->calthr[1][d][pre]; |
386 |
|
calib.calrms[0][2*d][j] = ce->calrms[1][d][j]; |
387 |
|
calib.calbase[0][2*d][pre] = ce->calbase[1][d][pre]; |
388 |
|
calib.calvar[0][2*d][pre] = ce->calvar[1][d][pre]; |
389 |
|
}; |
390 |
|
if ( s == 0 ){ |
391 |
|
obt0=obt; |
392 |
|
calib.calped[1][2*d][j] = ce->calped[0][d][j]; |
393 |
|
calib.cstwerr[0] = ce->cstwerr[0]; |
394 |
|
calib.cperror[0] = ce->cperror[0]; |
395 |
|
calib.calgood[1][2*d][j] = ce->calgood[0][d][j]; |
396 |
|
calib.calthr[1][2*d][pre] = ce->calthr[0][d][pre]; |
397 |
|
calib.calrms[1][2*d][j] = ce->calrms[0][d][j]; |
398 |
|
calib.calbase[1][2*d][pre] = ce->calbase[0][d][pre]; |
399 |
|
calib.calvar[1][2*d][pre] = ce->calvar[0][d][pre]; |
400 |
|
}; |
401 |
|
if ( s == 1 ){ |
402 |
|
obt1=obt; |
403 |
|
calib.calped[1][2*d+1][j] = ce->calped[2][d][j]; |
404 |
|
calib.cstwerr[2] = ce->cstwerr[2]; |
405 |
|
calib.cperror[2] = ce->cperror[2]; |
406 |
|
calib.calgood[1][2*d+1][j] = ce->calgood[2][d][j]; |
407 |
|
calib.calthr[1][2*d+1][pre] = ce->calthr[2][d][pre]; |
408 |
|
calib.calrms[1][2*d+1][j] = ce->calrms[2][d][j]; |
409 |
|
calib.calbase[1][2*d+1][pre] = ce->calbase[2][d][pre]; |
410 |
|
calib.calvar[1][2*d+1][pre] = ce->calvar[2][d][pre]; |
411 |
|
}; |
412 |
|
|
413 |
|
}; |
414 |
|
};//chiuso for su si(sezioni) |
415 |
|
} else { |
416 |
|
ci--; |
417 |
|
}; |
418 |
};//chiuso for su ci(eventi) |
};//chiuso for su ci(eventi) |
419 |
// |
// |
420 |
//fine CHECK |
//fine CHECK |
421 |
|
|
422 |
// |
// |
423 |
// Book the histograms: |
// Book the histograms: |
424 |
Int_t i = (ci-minev)/4; |
// Int_t i = (ci-minev)/4; |
425 |
|
Int_t i = hi; |
426 |
xviewev.str(""); |
xviewev.str(""); |
427 |
xviewev << "x-view event " << (i+1); |
xviewev << "x-view event " << (i+1); |
428 |
yviewev.str(""); |
yviewev.str(""); |
955 |
// |
// |
956 |
//file output |
//file output |
957 |
if ( !strcmp(format,"ps") ) { |
if ( !strcmp(format,"ps") ) { |
|
if ( ci == minev ) { |
|
|
figsave.str(""); |
|
|
figsave << outdir << "/" ; |
|
|
figsave << figrec << "_CaloCHKCALIB."; |
|
|
figsave << format; |
|
|
figsave << "("; |
|
|
}; |
|
958 |
if ( figmatra ) { |
if ( figmatra ) { |
959 |
figura2->Print(figsave.str().c_str(),"Portrait"); |
figura2->Print(figsave.str().c_str(),"Portrait"); |
960 |
if ( ci == minev ) { |
if ( ci == minev ) { |