--- calo/flight/FQLOOK/macros/FCaloQLOOK.cxx 2006/07/17 08:51:11 1.12 +++ calo/flight/FQLOOK/macros/FCaloQLOOK.cxx 2006/09/22 13:38:58 1.15 @@ -1,12 +1,14 @@ // // Check for possible errors and shows raw distribution of variables coming from the DSP (no calibrations needed) - Emiliano Mocchiutti // -// FCaloQLOOK.c version 1.11 (2006-07-17) +// FCaloQLOOK.c version 1.12 (2006-09-22) // // The only input needed is the path to the directory created by YODA for the data file you want to analyze. // // Changelog: // +// 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. @@ -43,6 +45,7 @@ #include #include #include +#include // #include #include @@ -85,13 +88,32 @@ 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); + 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()); @@ -303,7 +325,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; @@ -313,8 +336,8 @@ 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; @@ -328,11 +351,11 @@ Int_t outdexy = 0; Int_t indexyc = 0; Int_t outdexyc = 0; - Int_t obt = 0; - Int_t minobt[4]; - Int_t maxobt[4]; - Int_t swminobt[4]; - Int_t swmaxobt[4]; + 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++){ @@ -343,7 +366,10 @@ firstobt[i] = true; swfirstobt[i] = true; }; + Bool_t evdone = false; + // while ( i < maxevent+1){ + evdone = false; tshit = 0; trshit = 0; tr->GetEntry(i); @@ -356,9 +382,6 @@ 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++; - // 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])); 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]))); @@ -373,40 +396,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++ ){ @@ -479,6 +510,8 @@ if ( obt > maxobt[se] ) maxobt[se] = obt; }; lver[se][2]++ ; + sighandler(headc,obt,i,se,nevents,evdone); + printf(" latch up (data) in DSP mode alldexy %i planebases %i \n",alldexy,planebases); }; } // @@ -522,7 +555,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; @@ -548,6 +585,8 @@ if ( obt > maxobt[se] ) maxobt[se] = obt; }; lver[se][2]++ ; + 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 ) { @@ -576,31 +615,106 @@ 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 << 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]++ ; + 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]++ ; - if ( cestw & (1 << 6) ) ver[k][0]++ ; + 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"); + }; }; + 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"); + }; }; for (Int_t kk = 0; kk < 11 ; kk++ ){ tshit += shit[k][kk]; @@ -633,10 +747,11 @@ 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; }; @@ -995,10 +1110,12 @@ 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); @@ -1034,10 +1151,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); @@ -1181,7 +1300,14 @@ pad2->Draw(); pad3->Draw(); pad4->Draw(); - + // + Bool_t redevent = true; + // + if ( ver[0][3]+ver[0][16]+ver[0][17] == ver[1][3]+ver[1][16]+ver[1][17] && ver[1][3]+ver[1][16]+ver[1][17] == ver[2][3]+ver[2][16]+ver[2][17] && ver[2][3]+ver[2][16]+ver[2][17] == ver[3][3]+ver[3][16]+ver[3][17] ){ + redevent = false; + }; + if ( redevent ) check = true; + // for (Int_t i = 0; i < 4; i++){ if (i == 2) { @@ -1268,7 +1394,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) { @@ -1352,14 +1478,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) { @@ -1505,5 +1631,11 @@ 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); + }; + }; }