--- calo/flight/FQLOOK/macros/FCaloQLOOK.cxx 2006/03/09 16:14:32 1.1.1.1 +++ calo/flight/FQLOOK/macros/FCaloQLOOK.cxx 2006/05/29 13:15:49 1.11 @@ -1,12 +1,27 @@ // // 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.09 (2006-05-29) // // The only input needed is the path to the directory created by YODA for the data file you want to analyze. // // Changelog: // +// 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). @@ -25,9 +40,10 @@ #include #include #include +#include // -#include -#include +#include +#include // #include // @@ -51,34 +67,45 @@ } 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(".dat"); + stringappend(file2,pdat); + }; return file2; } void FCaloQLOOK(TString filename, Int_t fromevent=0, Int_t toevent=0, TString outDir="", TString saveas = "ps"){ 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; // // ifstream myfile; myfile.open(filename.Data()); if ( !myfile ){ - printf(" No such file, exiting...\n"); + printf(" %s :no such file, exiting...\n\n",filename.Data()); return; }; myfile.close(); // TFile *File = new TFile(filename.Data()); TTree *tr = (TTree*)File->Get("Physics"); + if ( !tr ) { + printf(" Physics : no such tree in %s \n",filename.Data()); + printf(" Exiting, are you sure this is a LEVEL0 not corrupted file? \n\n"); + return; + }; // // Define variables // @@ -160,6 +187,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.); @@ -182,7 +211,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 // @@ -235,7 +281,8 @@ bool isRAW = 0; 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 ; @@ -273,6 +320,21 @@ 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]; + 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; + }; while ( i < maxevent+1){ tshit = 0; trshit = 0; @@ -282,6 +344,7 @@ ph = eh->GetPscuHeader(); headco = headc; headc = ph->GetCounter(); + obt = ph->GetOrbitalTime(); 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])); @@ -370,23 +433,41 @@ 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]++ ; }; } // @@ -445,10 +526,16 @@ // } 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]++ ; }; }; @@ -482,7 +569,12 @@ 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 << 4) ){ + ver[k][2]++ ; + 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]++ ; }; @@ -547,6 +639,8 @@ t->DrawLatex(2.,99.,errore.str().c_str()); TPad *pd5; TPad *pd6; + TPad *pd7; + TPad *pd8; TPad *pad1; TPad *pad2; TPad *pad3; @@ -933,6 +1027,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); @@ -1009,12 +1206,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(""); @@ -1212,14 +1410,25 @@ t->DrawLatex(60.,95.," OK! "); }; // - 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; @@ -1228,33 +1437,50 @@ 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()); };