--- quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx 2007/01/26 11:57:58 1.12 +++ quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx 2007/02/26 08:50:59 1.13 @@ -196,10 +196,22 @@ cpuhe->SetBranchAddress("Header",&ch); // Long64_t ncalibs = tr->GetEntries();//cerca il ramo Entries (calibrazioni) - if ( ncalibs == 0 ){ + if ( ncalibs == 0 || cpuhe->GetEntries() == 0){ printf(" No calibrations in this files! \n Exiting... \n"); return; }; + // + UInt_t cpuhead[1000]; + memset(cpuhead, 0, 1000*sizeof(UInt_t)); + for (Int_t i=0; iGetEntries(); i++){ + cpuhe->GetEntry(i); + if ( i < 1000 ) cpuhead[i]=ch->GetPscuHeader()->GetOrbitalTime(); + if ( i > 1000 ){ + printf(" ERROR: too many calibrations in this file, cannot handle it \n Exiting... \n"); + return; + }; + }; + // printf("\n This file contains %i entries which corrispond to %i calibrations \n\n",(int)ncalibs,(int)ncalibs/4); Long64_t minev = 0; Long64_t maxev = ncalibs; @@ -240,6 +252,13 @@ stringstream figsave; //definisco stringhe i/o stringstream figsave1; stringstream figsave2; + if ( !strcmp(format,"ps") ) { + figsave.str(""); + figsave << outdir << "/" ; + figsave << figrec << "_CaloCHKCALIB."; + figsave << format; + figsave << "("; + }; // //-----------------inizio CHECK per ricerca errori dal calorimetro------------------- @@ -248,8 +267,11 @@ Bool_t check = false;//azzera flag presenza errori // + Int_t hi = (minev/4)-1; //inizio loop su tutti gli header degli eventi di calibrazione - for (Int_t ci = minev; ci < maxev ; ci+=4){ + // for (Int_t ci = minev; ci < maxev ; ci+=4){ + Int_t ci = minev; + while ( ci < maxev ){ //scorre i pacchetti di 4 in 4 (cioe scorre le calibrazioni) Int_t incalrms = 0; Int_t outcalrms = 0; @@ -263,111 +285,144 @@ Int_t incalbas = 0; Int_t outcalbas = 0; //dall'albero calibheader, cerco obt dell cpu - cpuhe->GetEntry(ci/4); - cpuobt=ch->GetPscuHeader()->GetOrbitalTime(); + // cpuhe->GetEntry(ci/4); + hi++; + // cpuobt=ch->GetPscuHeader()->GetOrbitalTime(); + cpuobt=cpuhead[hi]; obt0=0; obt1=0; obt2=0; obt3=0; - + // + calib.iev=0; + memset(calib.cstwerr,0,4*sizeof(Int_t)); + memset(calib.cperror,0,4*sizeof(Float_t)); + memset(calib.calped,0,2*22*96*sizeof(Float_t)); + memset(calib.calgood,0,2*22*96*sizeof(Float_t)); + memset(calib.calrms,0,2*22*96*sizeof(Float_t)); + memset(calib.calpuls,0,2*22*96*sizeof(Float_t)); + memset(calib.calthr,0,2*22*6*sizeof(Float_t)); + memset(calib.calvar,0,2*22*6*sizeof(Float_t)); + memset(calib.calbase,0,2*22*6*sizeof(Float_t)); + // //inizio loop su i 4 pacchetti per ogni calibrazione (scorre 4 successivi) - for ( Int_t s=0 ; s<4 ;s++ ){ + // for ( Int_t s=0 ; s<4 ;s++ ){ + Int_t s = 0; + obt = cpuhead[hi]; + // printf(" qui cpu header : %i hi %i entry %i \n",obt,hi,ci); + while ( labs((Int_t)(obt-cpuhead[hi])) < 100000 && ci < maxev){ - 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 + // tr->GetEntry(ci+s);//sceglie la entry (calibrazione)del tree in cui ho tutte le sottostrutture - -//trovo l'OBT della entry (pacchetto) + //trovo l'OBT della entry (pacchetto) obt=eh->GetPscuHeader()->GetOrbitalTime();//cerca orbitaltime all'interno di Pscu -/// + // + //printf(" qui pkt header : %i \n",obt); + ci++; + + if ( labs((Int_t)(obt-cpuhead[hi])) < 100000 ){ - calib.iev = ce->iev; - cestw = 0; - //cstwerr e' tutto l'header della sezione, mi interessano gli ultimi 2 Byte(errori del calorimetro) - if ( ce->cstwerr[s] ){ - cestw = ce->cstwerr[s] & cmask ; //confronto con la maschera per tenere solo gli - ver[s][16]++;// ultimi 2 Byte (assegnati a cestw) - }; - if ( cestw ){//errori dal calorimetro - if ( cestw & (1 << 0) ) ver[s][6]++ ;//spostati di uno e confronto se diverso 0 - if ( cestw & (1 << 1) ) ver[s][5]++ ; - if ( cestw & (1 << 2) ) ver[s][4]++ ; - if ( cestw & (1 << 3) ) ver[s][3]++ ; - if ( cestw & (1 << 4) ) ver[s][2]++ ; - 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]--; + // s++; + if ( ce->cstwerr[0] ) s = 0; + if ( ce->cstwerr[1] ) s = 1; + if ( ce->cstwerr[2] ) s = 2; + if ( ce->cstwerr[3] ) s = 3; + //printf(" qua pkt header : %i s = %i hi %i \n",obt,s,hi); + // + calib.iev = ce->iev; + cestw = 0; + //cstwerr e' tutto l'header della sezione, mi interessano gli ultimi 2 Byte(errori del calorimetro) + if ( ce->cstwerr[s] ){ + cestw = ce->cstwerr[s] & cmask ; //confronto con la maschera per tenere solo gli + ver[s][16]++;// ultimi 2 Byte (assegnati a cestw) }; - if (ce->cperror[s] == 132) ver[s][11]++ ; - if (ce->cperror[s] == 140) ver[s][19]++ ; - if (ce->cperror[s] == 141) ver[s][20]++ ; - if (ce->cperror[s] == 142) ver[s][22]++ ; - }; - //lato oscuro :p - for ( Int_t d=0 ; d<11 ;d++ ){ - Int_t pre = -1; - for ( Int_t j=0; j<96 ;j++){ - if ( j%16 == 0 ) pre++; - if ( s == 2 ){ - //aggiungo obt del pacchetto che sta leggendo(obt) - obt2=obt; - calib.calped[0][2*d+1][j] = ce->calped[3][d][j]; - calib.cstwerr[3] = ce->cstwerr[3]; - 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]; + if ( cestw ){//errori dal calorimetro + if ( cestw & (1 << 0) ) ver[s][6]++ ;//spostati di uno e confronto se diverso 0 + if ( cestw & (1 << 1) ) ver[s][5]++ ; + if ( cestw & (1 << 2) ) ver[s][4]++ ; + if ( cestw & (1 << 3) ) ver[s][3]++ ; + if ( cestw & (1 << 4) ) ver[s][2]++ ; + 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]--; }; + if (ce->cperror[s] == 132) ver[s][11]++ ; + if (ce->cperror[s] == 140) ver[s][19]++ ; + if (ce->cperror[s] == 141) ver[s][20]++ ; + if (ce->cperror[s] == 142) ver[s][22]++ ; }; - };//chiuso for su si(sezioni) + //lato oscuro :p + for ( Int_t d=0 ; d<11 ;d++ ){ + Int_t pre = -1; + for ( Int_t j=0; j<96 ;j++){ + if ( j%16 == 0 ) pre++; + if ( s == 2 ){ + //aggiungo obt del pacchetto che sta leggendo(obt) + obt2=obt; + calib.calped[0][2*d+1][j] = ce->calped[3][d][j]; + calib.cstwerr[3] = ce->cstwerr[3]; + 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]; + }; + + }; + };//chiuso for su si(sezioni) + } else { + ci--; + }; };//chiuso for su ci(eventi) // - //fine CHECK + //fine CHECK // // Book the histograms: - Int_t i = (ci-minev)/4; + // Int_t i = (ci-minev)/4; + Int_t i = hi; xviewev.str(""); xviewev << "x-view event " << (i+1); yviewev.str(""); @@ -900,13 +955,6 @@ // //file output if ( !strcmp(format,"ps") ) { - if ( ci == minev ) { - figsave.str(""); - figsave << outdir << "/" ; - figsave << figrec << "_CaloCHKCALIB."; - figsave << format; - figsave << "("; - }; if ( figmatra ) { figura2->Print(figsave.str().c_str(),"Portrait"); if ( ci == minev ) {