--- calo/flight/FQLOOK/macros/FCaloQLOOK.cxx 2006/03/13 09:01:23 1.2 +++ calo/flight/FQLOOK/macros/FCaloQLOOK.cxx 2007/07/23 09:34:07 1.22 @@ -1,12 +1,35 @@ // // Check for possible errors and shows raw distribution of variables coming from the DSP (no calibrations needed) - Emiliano Mocchiutti // -// FCaloQLOOK.c version 1.01 (2006-02-28) +// FCaloQLOOK.c version 1.14 (2006-09-29) // // The only input needed is the path to the directory created by YODA for the data file you want to analyze. // // Changelog: // +// 1.13 - 1.14 (2006-09-29): Flag the last entry in the txt file, count missing section when checking for DSP entries correspondence. +// +// 1.12 - 1.13 (2006-09-28): Give wrong number of events in compress mode, fixed. +// +// 1.11 - 1.12 (2006-09-22): Check for different number of events, put output in a file and write down errors for each event. Fixed jumpev bug. +// +// 1.09 - 1.11 (2006-07-17): Adapted to flight conditions. +// +// 1.07 - 1.09 (2006-05-29): Fixed bug in output filename when input is not in the form DW_YYMMDD_NNN. Bug in latchup alarm not coming from the status word, fixed. +// +// 1.06 - 1.07 (2006-05-23): Don't print warning in case of latchup not recognized from the status word, fixed. Added "expert" figures from 21 to 28 which appears only in the +// case of latchup alarm. +// +// 1.05 - 1.06 (2006-03-22): Add optimize flag in compiling the script! +// +// 1.04 - 1.05 (2006-03-22): Corrected wrong .C files. +// +// 1.03 - 1.04 (2006-03-20): Documentation updated. +// +// 1.02 - 1.03 (2006-03-20): Changed name of shared libraries (from FCaloQLOOK_cxx.so to libFCaloQLOOK.so). +// +// 1.01 - 1.02 (2006-03-13): Include files from YODA without "event" directory. +// // 1.00 - 1.01 (2006-02-28): Works on YODA v6 output (single file), does not require anymore calocommon package. // // 0.00 - 1.00 (2006-02-28): Clone of CaloQLOOK.c (ground software). @@ -26,9 +49,10 @@ #include #include #include +#include // -#include -#include +#include +#include // #include // @@ -52,23 +76,49 @@ } TString getFilename(const TString filename){ - const string fil = (const char*)filename; - Int_t posiz = fil.find("dw_"); - if ( posiz == -1 ) posiz = fil.find("DW_"); - if ( posiz == -1 ) return 0; - Int_t posiz2 = posiz+13; + // + const string fil = gSystem->BaseName(filename.Data()); + Int_t posiz = fil.find(".root"); + // TString file2; - stringcopy(file2,filename,posiz,posiz2); - TString pdat(".dat"); - stringappend(file2,pdat); + if ( posiz == -1 ){ + file2 = gSystem->BaseName(filename.Data()); + } else { + Int_t posiz2 = 0; + stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); + TString pdat(".pam"); + stringappend(file2,pdat); + }; return file2; } -void FCaloQLOOK(TString filename, Int_t fromevent=0, Int_t toevent=0, TString outDir="", TString saveas = "ps"){ +void sighandler(UInt_t pkt_num, UInt_t obt, UInt_t entry, UInt_t section, UInt_t totev, Bool_t &evdone){ + if ( !evdone ){ + printf("\n\n=================================================\n"); + printf("PSCU-Pkt N. %u - OBT %u ms\n",pkt_num,obt); + printf("Total events %u\n",totev); + printf("(ROOT-tree entry %u )\n",entry); + if ( (totev-1) == entry ) printf("NOTICE: this is last entry! \n"); + printf("=================================================\n"); + evdone = true; + }; + TString sec = "UNKNOWN"; + if ( section == 0 ) sec = "XE"; + if ( section == 1 ) sec = "XO"; + if ( section == 2 ) sec = "YE"; + if ( section == 3 ) sec = "YO"; + printf(" Section %s (DSP n. %i) message: ",sec.Data(),section); +}; + +void FCaloQLOOK(TString filename, Int_t fromevent=0, Int_t toevent=0, TString outDir="", TString saveas = "png", Bool_t iactive =false, Bool_t w4i=false){ gStyle->SetPaperSize(19.,25.); const char* startingdir = gSystem->WorkingDirectory(); + // printf(" basename is %s \n",gSystem->BaseName(filename.Data())); + // printf(" getfilename is %s \n",getFilename(filename).Data()); if ( !strcmp(outDir.Data(),"") ) outDir = startingdir; // + TApplication *app = 0; + if ( iactive ) app = new TApplication("app",0,0); // ifstream myfile; myfile.open(filename.Data()); @@ -90,8 +140,12 @@ // Float_t ctshitthr = 0.65; Float_t cbasethr = 0.95; - Float_t cdexythr = 0.995; + // Float_t cdexythr = 0.995; + Float_t cdexythr = 0.95; + //Float_t cdexythr = 0.90; Float_t cdexycthr = 0.95; + Float_t h1rth = 0.90; + Int_t calevnth = 13; // pamela::calorimeter::CalorimeterEvent *ce = 0; pamela::EventHeader *eh = 0; @@ -138,7 +192,8 @@ }; Int_t const size = nevents; Double_t iev2[size+1]; - Int_t ver[4][23], lver[4][23],shit[4][11], rshit[4][11], se,bl, pl, fulldiff[4],cshit, cpre[4],nullsh[4][11], lalarm[4]; + //aumentata la lunghezza di ver, prima era 23 + Int_t ver[4][24], lver[4][23],shit[4][11], rshit[4][11], se,bl, pl, fulldiff[4],cshit, cpre[4],nullsh[4][11], lalarm[4]; se = 0; pl = 0; Float_t allbase = 0.; @@ -166,6 +221,8 @@ TH1F *calev01; TH1F *calev23; TH1F *calev03; + TH1F *lupstw[4]; + TH1F *lup[4]; TH2D *calev2; h1 = new TH1F("C7","Strips hit, compress mode",100,0.,200.); @@ -175,9 +232,10 @@ hdiff->SetBit(TH1F::kCanRebin); Baseline = new TH1F("C9","baselines",100,0,3); Baseline->SetBit(TH1F::kCanRebin); - Dexy = new TH1F("C12","dexy",100,0.,37000.); - Dexyc = new TH1F("C10","dexyc",100,0,3); - Dexyc->SetBit(TH1F::kCanRebin); + Dexy = new TH1F("C12","dexy",100,0.,10000.); + Dexy->SetBit(TH1F::kCanRebin); + Dexyc = new TH1F("C10","dexyc",100,-100.,37000.); +// Dexyc->SetBit(TH1F::kCanRebin); Calstriphit = new TH1F("C11","calstriphit[1:4]",100,0.,200.); calev01 = new TH1F("C3","|calevnum(1)-calevnum(2)|",100,0,1); @@ -188,7 +246,24 @@ calev03->SetBit(TH1F::kCanRebin); calev2 = new TH2D("C2","calevnum(2)%iev",3000,0.,2.,100,0.,2.); calev2->SetBit(TH2D::kCanRebin); - + + stringstream oss; + stringstream noss; + for ( Int_t i=0; i<4; i++){ + oss.str(""); + oss << "OBT stw latch up section " << i; + noss.str(""); + noss << "C" << 21+i; + lupstw[i] = new TH1F(noss.str().c_str(),oss.str().c_str(),100,-1,1); + lupstw[i]->SetBit(TH1F::kCanRebin); + oss.str(""); + oss << "OBT no stw latch up section " << i; + noss.str(""); + noss << "C" << 25+i; + lup[i] = new TH1F(noss.str().c_str(),oss.str().c_str(),100,-1,1); + lup[i]->SetBit(TH1F::kCanRebin); + }; + // // run over each event and take out some variables // @@ -220,7 +295,7 @@ maxevent = fromevent - 1; }; }; - + //azzera i tipi di errore for (Int_t k = 0; k < 4; k++ ){ for (Int_t m = 0; m < 23 ; m++ ){ ver[k][m] = 0 ; @@ -232,16 +307,19 @@ }; lalarm[k] = 0; }; + //il 23 lo azzero cosi per non modificare le altre variabili + ver[k][23]=0; }; Int_t pdone, bdone; pdone = 0; bdone = 0; - bool isCOMP = 0; - bool isFULL = 0; - bool isRAW = 0; + bool isCOMP = false; + bool isFULL = false; + bool isRAW = false; Int_t alldexy=0; Int_t alldexy2=0; - Int_t stri=0; + Int_t planebases=0; + // Int_t stri=0; Int_t fcheck = 0; Int_t cestw=0; Int_t cmask = 127 ; @@ -256,7 +334,8 @@ fulldiff[1] = 0; fulldiff[2] = 0; fulldiff[3] = 0; - printf("\n Processed events: \n\n"); + // printf("\n Processed events: \n\n"); + printf("\n Start processing: \n\n"); unsigned short int calev0=0; unsigned short int oldcalev0; unsigned short int calev1=0; @@ -266,9 +345,11 @@ unsigned short int calev3=0; unsigned short int oldcalev3; Int_t i = minevent; - Float_t headc = 0.; - Float_t headco = 0.; + UInt_t headc = 0; + UInt_t headco = 0; Bool_t h1rcheck = false; + Int_t h1rin = 0; + Int_t h1rout = 0; Int_t intshit = 0; Int_t outtshit = 0; Int_t incshit = 0; @@ -279,18 +360,39 @@ Int_t outdexy = 0; Int_t indexyc = 0; Int_t outdexyc = 0; + UInt_t obt = 0; + UInt_t minobt[4]; + UInt_t maxobt[4]; + UInt_t swminobt[4]; + UInt_t swmaxobt[4]; + Bool_t firstobt[4]; + Bool_t swfirstobt[4]; + for ( Int_t i = 0; i<4; i++){ + minobt[i] = 0; + maxobt[i] = 0; + swminobt[i] = 0; + swmaxobt[i] = 0; + firstobt[i] = true; + swfirstobt[i] = true; + }; + Bool_t evdone = false; + // while ( i < maxevent+1){ + evdone = false; tshit = 0; trshit = 0; tr->GetEntry(i); + iev2[i] = ce->iev; // ph = eh->GetPscuHeader(); headco = headc; headc = ph->GetCounter(); - calevn1 += (int)abs((int)(ce->calevnum[0]-ce->calevnum[1])); - calevn2 += (int)abs((int)(ce->calevnum[2]-ce->calevnum[3])); - calevn3 += (int)abs((int)(ce->calevnum[0]-ce->calevnum[3])); + obt = ph->GetOrbitalTime(); + + if ( (int)abs((int)(ce->calevnum[0]-ce->calevnum[1])) ) calevn1++; + if ( (int)abs((int)(ce->calevnum[2]-ce->calevnum[3])) ) calevn2++; + if ( (int)abs((int)(ce->calevnum[0]-ce->calevnum[3])) ) calevn3++; calev01->Fill(abs((int)(ce->calevnum[0]-ce->calevnum[1]))); calev23->Fill(abs((int)(ce->calevnum[2]-ce->calevnum[3]))); calev03->Fill(abs((int)(ce->calevnum[0]-ce->calevnum[3]))); @@ -305,40 +407,48 @@ calevv2 = (int)ce->calevnum[2]; oldcalev3 = calev3; calev3 = (int)ce->calevnum[3]; - goto jumpprintout; - if ( (headc - headco -1.) == 0. && ((calev0 - oldcalev0 - 1) > 0 || (calev1 - oldcalev1 - 1) > 0 || (calevv2 - oldcalev2 - 1) > 0 || (calev3 - oldcalev3 - 1) > 0) ){ + // goto jumpprintout; + if ( (headc - headco -1) == 0. && ((calev0 - oldcalev0 - 1) > 0 || (calev1 - oldcalev1 - 1) > 0 || (calevv2 - oldcalev2 - 1) > 0 || (calev3 - oldcalev3 - 1) > 0) ){ if ( i != minevent ) { - printf(" %f 0 Event %i: %i\n",headco,i,oldcalev0); - printf(" %f 0 Event %i: %i\n",headc,i+1,calev0); - printf(" %f 1 Event %i: %i\n",headco,i,oldcalev1); - printf(" %f 1 Event %i: %i\n",headc,i+1,calev1); - printf(" %f 2 Event %i: %i\n",headco,i,oldcalev2); - printf(" %f 2 Event %i: %i\n",headc,i+1,calevv2); - printf(" %f 3 Event %i: %i\n",headco,i,oldcalev3); - printf(" %f 3 Event %i: %i\n",headc,i+1,calev3); +// printf(" %f 0 Event %i: %i\n",headco,i,oldcalev0); +// printf(" %f 0 Event %i: %i\n",headc,i+1,calev0); +// printf(" %f 1 Event %i: %i\n",headco,i,oldcalev1); +// printf(" %f 1 Event %i: %i\n",headc,i+1,calev1); +// printf(" %f 2 Event %i: %i\n",headco,i,oldcalev2); +// printf(" %f 2 Event %i: %i\n",headc,i+1,calevv2); +// printf(" %f 3 Event %i: %i\n",headco,i,oldcalev3); +// printf(" %f 3 Event %i: %i\n",headc,i+1,calev3); isRAW = 0; if ( ce->stwerr[0] & (1 << 3)) isRAW = 1; if ( (calev0 - oldcalev0 - 1) > 0 && !isRAW && ce->perror[0] != 129 && oldcalev0 != 0) { ver[0][10]++; + sighandler(headc,obt,i,0,nevents,evdone); + printf(" jump in the counter calev is %i oldcalev was %i \n",calev0,oldcalev0); }; isRAW = 0; if ( ce->stwerr[0] & (1 << 3)) isRAW = 1; if ( (calev1 - oldcalev1 - 1) > 0 && !isRAW && ce->perror[1] != 129 && oldcalev1 != 0 ){ ver[1][10]++; + sighandler(headc,obt,i,1,nevents,evdone); + printf(" jump in the counter calev is %i oldcalev was %i \n",calev1,oldcalev1); }; isRAW = 0; if ( ce->stwerr[0] & (1 << 3)) isRAW = 1; if ( (calevv2 - oldcalev2 - 1) > 0 && !isRAW && ce->perror[2] != 129 && oldcalev2 != 0 ){ ver[2][10]++; + sighandler(headc,obt,i,2,nevents,evdone); + printf(" jump in the counter calev is %i oldcalev was %i \n",calevv2,oldcalev2); }; isRAW = 0; if ( ce->stwerr[0] & (1 << 3)) isRAW = 1; if ( (calev3 - oldcalev3 - 1) > 0 && !isRAW && ce->perror[3] != 129 && oldcalev3 != 0 ){ ver[3][10]++; + sighandler(headc,obt,i,3,nevents,evdone); + printf(" jump in the counter calev is %i oldcalev was %i \n",calev3,oldcalev3); }; - } + }; }; - jumpprintout: + // jumpprintout: memcpy(shit, nullsh, sizeof(nullsh)); memcpy(rshit, nullsh, sizeof(nullsh)); for (Int_t l = 0; l < 2; l++ ){ @@ -362,43 +472,70 @@ se = 1; pl = (ii-1)/2; pdone = 0; - }; - - isCOMP = 0; - isFULL = 0; - isRAW = 0; - if ( ce->stwerr[se] & (1 << 16) ) isCOMP = 1; - if ( ce->stwerr[se] & (1 << 17) ) isFULL = 1; - if ( ce->stwerr[se] & (1 << 3) ) isRAW = 1; + }; + isCOMP = false; + isFULL = false; + isRAW = false; + if ( ce->stwerr[se] & (1 << 16) ) isCOMP = true; + if ( ce->stwerr[se] & (1 << 17) ) isFULL = true; + if ( ce->stwerr[se] & (1 << 3) ) isRAW = true; bl = -1; for (Int_t kk = 0; kk < 96 ; kk++ ){ if ( kk%16 == 0 ){ bdone = 0; bl++; allbase = ce->base[l][ii][bl]; + // alldexy=0; + // alldexy2=0; + // stri=0; + // for (Int_t e = 0; e < 16 ; e++ ){ + // stri = e + 16 * bl; + // alldexy += (int)ce->dexyc[l][ii][stri]; + // alldexy2 += (int)ce->dexy[l][ii][stri]; + // }; + }; + // + if ( kk == 0 ){ + planebases = 0; alldexy=0; alldexy2=0; - stri=0; - for (Int_t e = 0; e < 16 ; e++ ){ - stri = e + 16 * bl; - alldexy += (int)ce->dexyc[l][ii][stri]; - alldexy2 += (int)ce->dexy[l][ii][stri]; + for (Int_t e = 0; e < 96 ; e++ ){ + if ( e < 6 ) planebases += (int)ce->base[l][ii][e]; + alldexy += (int)ce->dexyc[l][ii][e]; + alldexy2 += (int)ce->dexy[l][ii][e]; }; }; + // if ( !isRAW ) { // if ( !pdone ){ - if ( (ce->base[l][ii][bl]>32000 || ce->base[l][ii][bl] == 0 ) && ( alldexy > 512000 || alldexy == 0) && ce->perror[se] == 0 ) { + // if ( (ce->base[l][ii][bl]>32000 || ce->base[l][ii][bl] == 0 ) && ( alldexy > 512000 || alldexy == 0) && ce->perror[se] == 0 ) { + if ( (planebases>192000 || planebases == 0 ) && ( alldexy > 3072000 || alldexy == 0) && ce->perror[se] == 0 ) { pdone = 1; pshit[se][pl]++ ; - if ( (ce->stwerr[se] & (1 << 4)) == 0 ) lalarm[se]++; - lver[se][2]++ ; + if ( (ce->stwerr[se] & (1 << 4)) == 0 ) { + lalarm[se]++; + lup[se]->Fill(obt); + if ( firstobt[se] ) minobt[se] = obt; + if ( obt > maxobt[se] ) maxobt[se] = obt; + }; + lver[se][2]++ ; + if ( lver[se][2] == 1000 ){ + sighandler(headc,obt,i,se,nevents,evdone); + printf(" latch up (data) in DSP mode alldexy %i planebases %i \n",alldexy,planebases); + printf(" WARNING TOO MANY LATCHUP ERRORS ON DATA FOR THIS SECTION \n"); + printf(" THEY WILL NOT BE DISPLAYED HERE ANYMORE FOR THIS FILE! \n"); + }; + if ( lver[se][2] < 1000 ){ + sighandler(headc,obt,i,se,nevents,evdone); + printf(" latch up (data) in DSP mode alldexy %i planebases %i \n",alldexy,planebases); + }; }; } // if ( !bdone ){ Baseline->Fill(ce->base[l][ii][bl]); - if ( ce->base[l][ii][bl] > 2000. && ce->base[l][ii][bl] < 4500. ){ + if ( ce->base[l][ii][bl] > 2000. && ce->base[l][ii][bl] < 5500. ){ inbase++; } else { outbase++; @@ -436,7 +573,11 @@ indexyc++; }; // - if (ce->dexyc[l][ii][kk] < 0 ) ver[se][21]++ ; + if (ce->dexyc[l][ii][kk] < 0 ){ + ver[se][21]++ ; + sighandler(headc,obt,i,se,nevents,evdone); + printf(" negative ADC values!! ce->dexyc[%i][%i][%i] = %f \n",l,ii,kk,ce->dexyc[l][ii][kk]); + }; // if ( allbase == 0. || allbase > 32000.) { fcheck = 0; @@ -451,11 +592,27 @@ // } else { if ( !pdone ){ - if ( (alldexy2>512000 || alldexy2 == 0) && ce->perror[se] == 0 ) { + if ( ( alldexy2 > 3072000 || alldexy2 == 0) && ce->perror[se] == 0 ) { + // if ( (alldexy2>512000 || alldexy2 == 0) && ce->perror[se] == 0 ) pdone = 1; pshit[se][pl]++ ; - if ( (ce->stwerr[se] & (1 << 4)) == 0 ) lalarm[se]++; + if ( (ce->stwerr[se] & (1 << 4)) == 0 ){ + lalarm[se]++; + lup[se]->Fill(obt); + if ( firstobt[se] ) minobt[se] = obt; + if ( obt > maxobt[se] ) maxobt[se] = obt; + }; lver[se][2]++ ; + if ( lver[se][2] == 1000 ){ + sighandler(headc,obt,i,se,nevents,evdone); + printf(" latch up (data) in RAW mode alldexy2 %i \n",alldexy2); + printf(" WARNING TOO MANY LATCHUP ERRORS ON DATA FOR THIS SECTION \n"); + printf(" THEY WILL NOT BE DISPLAYED HERE ANYMORE FOR THIS FILE! \n"); + }; + if ( lver[se][2] < 1000 ){ + sighandler(headc,obt,i,se,nevents,evdone); + printf(" latch up (data) in RAW mode alldexy2 %i \n",alldexy2); + }; }; }; if ( ce->dexy[l][ii][kk] > 0 && ce->dexy[l][ii][kk] < 32000 ) { @@ -474,66 +631,175 @@ }; cshit = 0; for (Int_t k = 0; k < 4 ; k++ ){ - isCOMP = 0; - isFULL = 0; - if ( ce->stwerr[se] & (1 << 16) ) isCOMP = 1; - if ( ce->stwerr[se] & (1 << 17) ) isFULL = 1; + isCOMP = false; + isFULL = false; + cestw=0;// queste righe qui + if ( ce->stwerr[k] ) cestw = ce->stwerr[k] & cmask ;// + if ( ce->stwerr[k] & (1 << 16) && !(cestw & (1 << 3)) ) isCOMP = true; + if ( ce->stwerr[k] & (1 << 17) && !(cestw & (1 << 3)) ) isFULL = true; + // if ( isCOMP ) ver[k][16]++; if ( isFULL ) ver[k][17]++; cshit += (int)ce->calstriphit[k]; - cestw=0; - if ( ce->stwerr[k] ) cestw = ce->stwerr[k] & cmask ; if ( cestw ){ - if ( cestw & (1 << 0) ) ver[k][6]++ ; - if ( cestw & (1 << 1) ) ver[k][5]++ ; - if ( cestw & (1 << 2) ) ver[k][4]++ ; - if ( cestw & (1 << 3) ) ver[k][3]++ ; - if ( cestw & (1 << 4) ) ver[k][2]++ ; - if ( cestw & (1 << 5) ) ver[k][1]++ ; - if ( cestw & (1 << 6) ) ver[k][0]++ ; - }; + if ( cestw & (1 << 0) ){ + ver[k][6]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" CRC error (st. word) \n"); + }; + if ( cestw & (1 << 1) ){ + ver[k][5]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" execution error \n"); + }; + if ( cestw & (1 << 2) ){ + ver[k][4]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" CMD length error \n"); + }; + if ( cestw & (1 << 3) ) ver[k][3]++ ; // raw mode + if ( cestw & (1 << 4) ){ + ver[k][2]++ ; + if ( ver[k][2] == 1000 ){ + sighandler(headc,obt,i,k,nevents,evdone); + printf(" latch up alarm (st. word)\n"); + printf(" WARNING TOO MANY LATCHUP ERRORS ON DATA FOR THIS SECTION \n"); + printf(" THEY WILL NOT BE DISPLAYED HERE ANYMORE FOR THIS FILE! \n"); + }; + if ( ver[k][2] < 1000 ){ + sighandler(headc,obt,i,k,nevents,evdone); + printf(" latch up alarm (st. word)\n"); + }; + lupstw[k]->Fill(obt); + if ( swfirstobt[k] ) swminobt[k] = obt; + if ( obt > swmaxobt[k] ) swmaxobt[k] = obt; + }; + if ( cestw & (1 << 5) ){ + ver[k][1]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" temperature alarm \n"); + }; + if ( cestw & (1 << 6) ){ + ver[k][0]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" DSP ack error \n"); + }; + };// controllo se ci sono errori crc se perr=0 ok! + if ( ce->stwerr[k] == 0 && ce->perror[k] == 0 ) ver[k][8]++ ; if ( ce->perror[k] != 0. ){ - if (ce->perror[k] == 128) ver[k][7]++ ; - if (ce->perror[k] == 129) ver[k][8]++ ; - if (ce->perror[k] == 132) ver[k][11]++ ; - if (ce->perror[k] == 133) ver[k][12]++ ; - if (ce->perror[k] == 134) ver[k][13]++ ; - if (ce->perror[k] == 135) ver[k][14]++ ; - if (ce->perror[k] == 136) ver[k][15]++ ; - if (ce->perror[k] == 139) ver[k][18]++ ; - if (ce->perror[k] == 140) ver[k][19]++ ; - if (ce->perror[k] == 141) ver[k][20]++ ; - if (ce->perror[k] == 142) ver[k][22]++ ; + if (ce->perror[k] == 128){ + ver[k][7]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" view or command not recognized \n"); + }; + if (ce->perror[k] == 129){ + ver[k][8]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" missing section \n"); + }; + if (ce->perror[k] == 132){ + ver[k][11]++ ; + if ( ver[k][11] < 30 ){ + sighandler(headc,obt,i,k,nevents,evdone); + printf(" CRC error (data) \n"); + }; + if ( ver[k][11] == 30 ){ + sighandler(headc,obt,i,k,nevents,evdone); + printf(" CRC error (data) \n"); + printf(" WARNING TOO MANY CRC ERRORS ON DATA FOR THIS SECTION \n"); + printf(" THEY WILL NOT BE DISPLAYED HERE ANYMORE FOR THIS FILE! \n"); + }; + }; + if (ce->perror[k] == 133){ + ver[k][12]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" length problems in RAW mode \n"); + }; + if (ce->perror[k] == 134){ + ver[k][13]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" length problems in COMPRESS mode \n"); + }; + if (ce->perror[k] == 135){ + ver[k][14]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" length problems in FULL mode \n"); + }; + if (ce->perror[k] == 136){ + ver[k][15]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" acquisition mode problems \n"); + }; + if (ce->perror[k] == 139){ + ver[k][18]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" problems with coding\n"); + }; + if (ce->perror[k] == 140){ + ver[k][19]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" pedestal checksum wrong\n"); + }; + if (ce->perror[k] == 141){ + ver[k][20]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" thresholds checksum wrong\n"); + }; + if (ce->perror[k] == 142){ + ver[k][22]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" packet length is zero (YODA input error), skipped\n"); + }; + //aggiunto questo errore + if (ce->perror[k] == 143){ + ver[k][23]++ ; + sighandler(headc,obt,i,k,nevents,evdone); + printf(" corrupted packet lenght \n"); + }; }; for (Int_t kk = 0; kk < 11 ; kk++ ){ tshit += shit[k][kk]; trshit += rshit[k][kk]; }; }; - Calstriphit->Fill(cshit); - if ( (cshit > 0 && cshit < 25) || (cshit > 40 && cshit < 80) ){ - incshit++; - } else { - outcshit++; - }; - if ( tshit>0 ) h1->Fill(tshit); - if ( (tshit > 0 && tshit < 25) || (tshit > 40 && tshit < 80) ){ - intshit++; - } else { - outtshit++; + if (isCOMP || isFULL){ + Calstriphit->Fill(cshit); + // if ( (cshit > 0 && cshit < 25) || (cshit > 40 && cshit < 80) ){ + // + //cambiata la banda di soglia ora 5 prima era 10 + // + if ( (cshit > 5 && cshit < 100) ){ + incshit++; + } else { + outcshit++; + }; + // + if ( tshit>0 ) h1->Fill(tshit); + // if ( (tshit > 0 && tshit < 25) || (tshit > 40 && tshit < 80) ){ + //cambiata la soglia ora 5 prima era 10 + if ( (tshit > 5 && tshit < 100) ){ + intshit++; + } else { + outtshit++; + }; }; if ( trshit>0 ) { h1r->Fill(trshit); if ( trshit < 4210 ){ - h1rcheck = true; + h1rout++; // printf("ma come... trshit %i \n",trshit); + } else { + h1rin++; }; }; - if ( i%1000 == 0 && i > 0 ) printf("%iK\n",i/1000); + // if ( i%1000 == 0 && i > 0 ) printf("%iK\n",i/1000); i++; }; printf("\n"); - + printf("\n end processing. \n\n"); + if ( (float)h1rout/((float)h1rin+(float)h1rout) > h1rth ){ + h1rcheck = true; + }; // // output figures, first sheet: // @@ -553,6 +819,8 @@ t->DrawLatex(2.,99.,errore.str().c_str()); TPad *pd5; TPad *pd6; + TPad *pd7; + TPad *pd8; TPad *pad1; TPad *pad2; TPad *pad3; @@ -597,20 +865,22 @@ h1->Draw(); // h1max = h1->GetMaximum()*1.05; - Double_t xc[4] = {0.,25.,25.,0.}; + + //cambiata banda prima era 10 ora 5 + Double_t xc[4] = {5.,100.,100.,5.}; Double_t yc[4] = {0.,0.,h1max,h1max}; banda1 = new TPolyLine(4,xc,yc); banda1->SetLineColor(5); banda1->SetFillColor(5); banda1->SetLineWidth(1); banda1->Draw("fSAME"); - Double_t xd[4] = {40.,80.,80.,40.}; - Double_t yd[4] = {0.,0.,h1max,h1max}; - banda2 = new TPolyLine(4,xd,yd); - banda2->SetLineColor(5); - banda2->SetFillColor(5); - banda2->SetLineWidth(1); - banda2->Draw("fSAME"); + // Double_t xd[4] = {40.,80.,80.,40.}; + // Double_t yd[4] = {0.,0.,h1max,h1max}; + // banda2 = new TPolyLine(4,xd,yd); + // banda2->SetLineColor(5); + // banda2->SetFillColor(5); + // banda2->SetLineWidth(1); + //banda2->Draw("fSAME"); h1->Draw("SAME"); // figura->cd(); @@ -647,20 +917,21 @@ h1->SetYTitle("Number of events"); h1->Draw(); h1max = h1->GetMaximum()*1.05; - Double_t xe[4] = {0.,25.,25.,0.}; + //cambiato banda, prima era 10,ora 5 + Double_t xe[4] = {5.,100.,100.,5.}; Double_t ye[4] = {0.,0.,h1max,h1max}; banda1 = new TPolyLine(4,xe,ye); banda1->SetLineColor(5); banda1->SetFillColor(5); banda1->SetLineWidth(1); banda1->Draw("fSAME"); - Double_t xf[4] = {40.,80.,80.,40.}; - Double_t yf[4] = {0.,0.,h1max,h1max}; - banda2 = new TPolyLine(4,xf,yf); - banda2->SetLineColor(5); - banda2->SetFillColor(5); - banda2->SetLineWidth(1); - banda2->Draw("fSAME"); + // Double_t xf[4] = {40.,80.,80.,40.}; + // Double_t yf[4] = {0.,0.,h1max,h1max}; + // banda2 = new TPolyLine(4,xf,yf); + // banda2->SetLineColor(5); + // banda2->SetFillColor(5); + // banda2->SetLineWidth(1); + // banda2->Draw("fSAME"); h1->Draw("SAME"); }; if ( trshit !=0 ) { @@ -690,7 +961,7 @@ }; }; if ( !errorfull ) { - if ( calevn1 || calevn2 || calevn3 ) { + if ( calevn1 > calevnth || calevn2 > calevnth || calevn3 > calevnth ) { pd1 = new TPad("pd1","This is pad1",0.02,0.51,0.24,0.98,45); pd2 = new TPad("pd2","This is pad2",0.26,0.51,0.49,0.98,45); pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.24,0.49,45); @@ -833,7 +1104,7 @@ Baseline->SetYTitle("Number of events"); Baseline->Draw(); h1max = Baseline->GetMaximum()*1.05; - Double_t xc[4] = {2000.,4500.,4500.,2000.}; + Double_t xc[4] = {2000.,5500.,5500.,2000.}; Double_t yc[4] = {0.,0.,h1max,h1max}; banda1 = new TPolyLine(4,xc,yc); banda1->SetLineColor(5); @@ -865,31 +1136,36 @@ Dexyc->Draw("SAME"); // pd3->cd(); +// gPad->SetLogy(); Calstriphit->SetXTitle("Number of hit"); Calstriphit->SetYTitle("Number of events"); Calstriphit->Draw(); h1max = Calstriphit->GetMaximum()*1.05; - Double_t xg[4] = {0.,25.,25.,0.}; + + //banda di sogla portata a 5, prima era a 10 + Double_t xg[4] = {5.,100.,100.,5.}; Double_t yg[4] = {0.,0.,h1max,h1max}; banda1 = new TPolyLine(4,xg,yg); banda1->SetLineColor(5); banda1->SetFillColor(5); banda1->SetLineWidth(1); banda1->Draw("fSAME"); - Double_t xh[4] = {40.,80.,80.,40.}; - Double_t yh[4] = {0.,0.,h1max,h1max}; - banda2 = new TPolyLine(4,xh,yh); - banda2->SetLineColor(5); - banda2->SetFillColor(5); - banda2->SetLineWidth(1); - banda2->Draw("fSAME"); + // Double_t xh[4] = {40.,80.,80.,40.}; + // Double_t yh[4] = {0.,0.,h1max,h1max}; + // banda2 = new TPolyLine(4,xh,yh); + // banda2->SetLineColor(5); + // banda2->SetFillColor(5); + // banda2->SetLineWidth(1); + // banda2->Draw("fSAME"); Calstriphit->Draw("SAME"); // pd4->cd(); + gPad->SetLogy(); Dexy->SetXTitle("ADC channels"); Dexy->SetYTitle("Number of events"); Dexy->Draw(); - h1max = Dexy->GetMaximum()*1.05; + // h1max = Dexy->GetMaximum()*1.05; + h1max = Dexy->GetMaximum()*2.05; Double_t xd[4] = {2000.,5000.,5000.,2000.}; Double_t yd[4] = {0.,0.,h1max,h1max}; banda1 = new TPolyLine(4,xd,yd); @@ -925,10 +1201,12 @@ pd4->Draw(); // pd4->cd(); + gPad->SetLogy(); Dexy->SetXTitle("ADC channels"); Dexy->SetYTitle("Number of events"); Dexy->Draw(); - h1max = Dexy->GetMaximum()*1.05; + // h1max = Dexy->GetMaximum()*1.05; + h1max = Dexy->GetMaximum()*2.05; Double_t xd[4] = {2000.,5000.,5000.,2000.}; Double_t yd[4] = {0.,0.,h1max,h1max}; banda1 = new TPolyLine(4,xd,yd); @@ -939,6 +1217,109 @@ Dexy->Draw("SAME"); }; // + TCanvas *figura3 = 0; + Bool_t printfigure3 = false; + for (Int_t i = 0; i<4; i++){ + if ( ver[i][2] || lver[i][2] ){ + printfigure3 = true; + break; + }; + }; + if ( printfigure3 ){ + figura3 = new TCanvas("Calorimeter_Detector_Report_2bis/3","Calorimeter_Detector_Report_2bis/3", 1100, 900); + figura3->SetFillColor(10); + figura3->Range(0,0,100,100); + errore.str(""); + errore << "EXPERT -- File: " << file; + errore << " "; + t=new TLatex(); + t->SetTextFont(32); + t->SetTextColor(1); + t->SetTextAlign(12); + t->SetTextSize(0.015); + t->DrawLatex(2.,99.,errore.str().c_str()); + pd1 = new TPad("pd1","This is pad1",0.02,0.51,0.49,0.73,45); + pd5 = new TPad("pd5","This is pad5",0.02,0.76,0.49,0.98,45); + pd2 = new TPad("pd2","This is pad2",0.51,0.51,0.98,0.73,45); + pd6 = new TPad("pd6","This is pad6",0.51,0.76,0.98,0.98,45); + pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.49,0.23,45); + pd7 = new TPad("pd7","This is pad7",0.02,0.26,0.49,0.49,45); + pd4 = new TPad("pd4","This is pad4",0.51,0.02,0.98,0.23,45); + pd8 = new TPad("pd8","This is pad8",0.51,0.26,0.98,0.49,45); + figura3->cd(); + pd1->Range(0,0,100,100); + pd2->Range(0,0,100,100); + pd3->Range(0,0,100,100); + pd4->Range(0,0,100,100); + pd1->SetTicks(); + pd2->SetTicks(); + pd3->SetTicks(); + pd4->SetTicks(); + pd1->Draw(); + pd2->Draw(); + pd3->Draw(); + pd4->Draw(); + pd5->Range(0,0,100,100); + pd6->Range(0,0,100,100); + pd7->Range(0,0,100,100); + pd8->Range(0,0,100,100); + pd5->SetTicks(); + pd6->SetTicks(); + pd7->SetTicks(); + pd8->SetTicks(); + pd5->Draw(); + pd6->Draw(); + pd7->Draw(); + pd8->Draw(); + pd1->cd(); + lup[0]->SetAxisRange((Double_t)min(minobt[0],swminobt[0])*0.9,(Double_t)max(maxobt[0],swmaxobt[0])*1.1,"X"); + lup[0]->SetXTitle("OBT"); + lup[0]->SetYTitle("Number of events"); + lup[0]->Draw(); + pd5->cd(); + lupstw[0]->SetAxisRange((Double_t)min(minobt[0],swminobt[0])*0.9,(Double_t)max(maxobt[0],swmaxobt[0])*1.1,"X"); + // lupstw[0]->SetAxisRange((Double_t)swminobt[0]*0.9,(Double_t)swmaxobt[0]*1.1,"X"); + lupstw[0]->SetXTitle("OBT"); + lupstw[0]->SetYTitle("Number of events"); + lupstw[0]->Draw(); + pd2->cd(); + lup[1]->SetAxisRange((Double_t)min(minobt[1],swminobt[1])*0.9,(Double_t)max(maxobt[1],swmaxobt[1])*1.1,"X"); + // lup[1]->SetAxisRange((Double_t)minobt[1]*0.9,(Double_t)maxobt[1]*1.1,"X"); + lup[1]->SetXTitle("OBT"); + lup[1]->SetYTitle("Number of events"); + lup[1]->Draw(); + pd6->cd(); + lupstw[1]->SetAxisRange((Double_t)min(minobt[1],swminobt[1])*0.9,(Double_t)max(maxobt[1],swmaxobt[1])*1.1,"X"); + // lupstw[1]->SetAxisRange((Double_t)swminobt[1]*0.9,(Double_t)swmaxobt[1]*1.1,"X"); + lupstw[1]->SetXTitle("OBT"); + lupstw[1]->SetYTitle("Number of events"); + lupstw[1]->Draw(); + pd3->cd(); + lup[2]->SetAxisRange((Double_t)min(minobt[2],swminobt[2])*0.9,(Double_t)max(maxobt[2],swmaxobt[2])*1.1,"X"); + // lup[2]->SetAxisRange((Double_t)minobt[2]*0.9,(Double_t)maxobt[2]*1.1,"X"); + lup[2]->SetXTitle("OBT"); + lup[2]->SetYTitle("Number of events"); + lup[2]->Draw(); + pd7->cd(); + lupstw[2]->SetAxisRange((Double_t)min(minobt[2],swminobt[2])*0.9,(Double_t)max(maxobt[2],swmaxobt[2])*1.1,"X"); + // lupstw[2]->SetAxisRange((Double_t)swminobt[2]*0.9,(Double_t)swmaxobt[2]*1.1,"X"); + lupstw[2]->SetXTitle("OBT"); + lupstw[2]->SetYTitle("Number of events"); + lupstw[2]->Draw(); + pd4->cd(); + lup[3]->SetAxisRange((Double_t)min(minobt[3],swminobt[3])*0.9,(Double_t)max(maxobt[3],swmaxobt[3])*1.1,"X"); + // lup[3]->SetAxisRange((Double_t)minobt[3]*0.9,(Double_t)maxobt[3]*1.1,"X"); + lup[3]->SetXTitle("OBT"); + lup[3]->SetYTitle("Number of events"); + lup[3]->Draw(); + pd8->cd(); + lupstw[3]->SetAxisRange((Double_t)min(minobt[3],swminobt[3])*0.9,(Double_t)max(maxobt[3],swmaxobt[3])*1.1,"X"); + // lupstw[3]->SetAxisRange((Double_t)swminobt[3]*0.9,(Double_t)swmaxobt[3]*1.1,"X"); + lupstw[3]->SetXTitle("OBT"); + lupstw[3]->SetYTitle("Number of events"); + lupstw[3]->Draw(); + }; + // // output figures, report sheet: // TCanvas *rapporto= new TCanvas("Calorimeter_Detector_Report_3/3", "Calorimeter_Detector_Report_3/3", 1100, 900); @@ -969,7 +1350,14 @@ pad2->Draw(); pad3->Draw(); pad4->Draw(); - + // + Bool_t redevent = true; + // + if ( ver[0][3]+ver[0][16]+ver[0][17]+ver[0][8] == ver[1][3]+ver[1][16]+ver[1][17]+ver[1][8] && ver[1][3]+ver[1][16]+ver[1][17]+ver[1][8] == ver[2][3]+ver[2][16]+ver[2][17]+ver[2][8] && ver[2][3]+ver[2][16]+ver[2][17]+ver[2][8] == ver[3][3]+ver[3][16]+ver[3][17]+ver[3][8] ){ + redevent = false; + }; + if ( redevent ) check = true; + // for (Int_t i = 0; i < 4; i++){ if (i == 2) { @@ -997,7 +1385,8 @@ t->SetTextAlign(12); t->DrawLatex(33.,97.,sezione); t->SetTextSize(0.05); - for (Int_t j = 0; j < 23; j++){ + //aggiunto un errore jmax=23 + for (Int_t j = 0; j < 24; j++){ if ( ver[i][j] || lver[i][j] ) { t->SetTextColor(50); if (j == 0) { @@ -1015,12 +1404,13 @@ check = true; } if (j == 2) { + // printf("boh! lalarm[%i] = %i \n",i,lalarm[i]); if ( lalarm[i] ){ errore.str(""); errore << "* Latch up: " << ver[i][j]; errore << " (" << lalarm[i]; errore << " NOT rec!): "; - t->DrawLatex(0.,70.,errore.str().c_str()); + t->DrawLatex(2.,70.,errore.str().c_str()); check = true; } else { errore.str(""); @@ -1055,7 +1445,7 @@ errore.str(""); errore << "RAW mode: " << ver[i][j]; errore << " time(s)"; - t->SetTextColor(32); + if ( !redevent ) t->SetTextColor(32); t->DrawLatex(2.,90.,errore.str().c_str()); } if (j == 4) { @@ -1091,21 +1481,21 @@ errore << "Missing section: " << ver[i][j]; errore << " time(s)"; t->DrawLatex(2.,50.,errore.str().c_str()); - check = true; + if ( ver[i][j] > 3 ) check = true; } if (j == 10) { errore.str(""); errore << "Calevnum jump: " << ver[i][j]; errore << " time(s)"; t->DrawLatex(2.,42.,errore.str().c_str()); - check = true; + if ( ver[i][j] > 3 ) check = true; } if (j == 11) { errore.str(""); errore << "CRC error (data): " << ver[i][j]; errore << " time(s)"; t->DrawLatex(2.,38.,errore.str().c_str()); - check = true; + if ( ver[i][j] > 10 ) check = true; } if (j == 12) { errore.str(""); @@ -1139,14 +1529,14 @@ errore.str(""); errore << "COMPRESS mode: " << ver[i][j]; errore << " time(s)"; - t->SetTextColor(32); + if ( !redevent ) t->SetTextColor(32); t->DrawLatex(2.,86.,errore.str().c_str()); } if (j == 17) { errore.str(""); errore << "FULL mode: " << ver[i][j]; errore << " time(s)"; - t->SetTextColor(32); + if ( !redevent ) t->SetTextColor(32); t->DrawLatex(2.,82.,errore.str().c_str()); } if (j == 18) { @@ -1184,8 +1574,16 @@ t->DrawLatex(2.,3.,errore.str().c_str()); check = true; }; - }; - }; + //aggiunto questo errore + if (j == 23) { + errore.str(""); + errore << "Corrupted packet lenght " << ver[i][j]; + errore << " time(s) "; + t->DrawLatex(2.,2.,errore.str().c_str()); + check = true; + }; + }; + }; t->SetTextColor(50); if ( fulldiff[i] !=0 ) { check = true; @@ -1212,20 +1610,31 @@ if ( check ){ t->SetTextColor(50); t->DrawLatex(60.,95.," WARNING, CHECK! "); - printf("cdexyc %f cdexy %f ctshit %f cbase %f \n",cdexyc,cdexy,ctshit,cbase); } else { t->SetTextColor(32); t->DrawLatex(60.,95.," OK! "); }; + printf("cdexyc %f cdexy %f ctshit %f cbase %f \n",cdexyc,cdexy,ctshit,cbase); // - const string fil = (const char*)filename; - Int_t posiz = fil.find("dw_"); - if ( posiz == -1 ) posiz = fil.find("DW_"); - Int_t posiz2 = posiz+13; - TString file2; - stringcopy(file2,filename,posiz,posiz2); + // const string fil = (const char*)filename; + // Int_t posiz = fil.find("dw_"); + // if ( posiz == -1 ) posiz = fil.find("DW_"); + // Int_t posiz2 = posiz+13; + // TString file2; + // stringcopy(file2,filename,posiz,posiz2); + // + const string fil = gSystem->BaseName(filename.Data()); + Int_t posiz = fil.find(".root"); // + TString file2; + if ( posiz == -1 ){ + file2 = gSystem->BaseName(filename.Data()); + } else { + Int_t posiz2 = 0; + stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); + }; const char *figrec = file2; + // const char *outdir = outDir; stringstream figsave; stringstream figsave1; @@ -1234,35 +1643,57 @@ if ( !strcmp(format,"ps") ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_qlook."; + figsave << figrec << "_CaloQLOOK."; figsave << format << "("; rapporto->Print(figsave.str().c_str(),"Landscape"); figsave1.str(""); figsave1 << outdir << "/" ; - figsave1 << figrec << "_qlook."; + figsave1 << figrec << "_CaloQLOOK."; figsave1 << format; figura->Print(figsave1.str().c_str(),"Landscape"); figsave2.str(""); figsave2 << outdir << "/" ; - figsave2 << figrec << "_qlook."; - figsave2 << format << ")"; - figura2->Print(figsave2.str().c_str(),"Landscape"); + figsave2 << figrec << "_CaloQLOOK."; + if ( printfigure3 ){ + figsave2 << format; + figura2->Print(figsave2.str().c_str(),"Landscape"); + figsave2.str(""); + figsave2 << outdir << "/" ; + figsave2 << figrec << "_CaloQLOOK."; + figsave2 << format << ")"; + figura3->Print(figsave2.str().c_str(),"Landscape"); + } else { + figsave2 << format << ")";; + figura2->Print(figsave2.str().c_str(),"Landscape"); + }; } else { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_qlook1."; + figsave << figrec << "_CaloQLOOK1."; figsave << format; figura->SaveAs(figsave.str().c_str()); figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_qlook2."; + figsave << figrec << "_CaloQLOOK2."; figsave << format; figura2->SaveAs(figsave.str().c_str()); + if ( printfigure3 ){ + figsave.str(""); + figsave << outdir << "/" ; + figsave << figrec << "_CaloQLOOK2bis."; + figsave << format; + figura3->SaveAs(figsave.str().c_str()); + }; figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_qlook3."; + figsave << figrec << "_CaloQLOOK3."; figsave << format; rapporto->SaveAs(figsave.str().c_str()); }; + if ( iactive && w4i ){ + while ( gROOT->GetListOfCanvases()->FindObject(rapporto) || gROOT->GetListOfCanvases()->FindObject(figura3) || gROOT->GetListOfCanvases()->FindObject(figura2) || gROOT->GetListOfCanvases()->FindObject(figura) ){ + gSystem->ProcessEvents(); + gSystem->Sleep(10); + }; + }; } -