--- quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx 2006/03/09 16:14:32 1.1 +++ quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx 2006/07/17 08:51:11 1.9 @@ -1,12 +1,26 @@ // // Check the calorimter calibrations - Emiliano Mocchiutti // -// FCaloCHKCALIB.c version 1.01 (2006-03-02) +// FCaloCHKCALIB.c version 1.11 (2006-07-17) // // 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.11 (2006-07-17): Adapted to flight conditions. +// +// 1.06 - 1.07 (2006-05-29): Fixed bug in output filename when input is not in the form DW_YYMMDD_NNN. Changed threshold for bad strip warning (from 0.005 to 0.03). +// +// 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 (for example 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-03-02): Works on YODA v6 output (single file), does not require anymore calocommon package. // // 0.00 - 1.00 (2006-03-02): Clone of CaloCHKCALIB.c @@ -27,8 +41,9 @@ #include #include #include +#include // -#include +#include // using namespace std; // @@ -50,16 +65,20 @@ } 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; - 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); TString pdat(".dat"); - stringappend(file2,pdat); - return file2; + stringappend(file2,pdat); + }; + return file2; } typedef struct Calib { @@ -81,7 +100,7 @@ // Float_t ccalrmsthr=0.99; Float_t ccalpedthr=0.99; - Float_t ccalbadthr=0.005; + Float_t ccalbadthr=0.03;// 0.005 Float_t ccalthrthr=0.98; Float_t ccalvarthr=0.99; Float_t ccalbasthr=0.99; @@ -106,14 +125,19 @@ ifstream myfile; myfile.open(filename.Data()); if ( !myfile ){ - printf(" No such file, exiting...\n"); - return; + printf(" %s :no such file, exiting...\n\n",filename.Data()); + return; }; myfile.close(); // TFile *File = new TFile(filename.Data()); // TTree *tr = (TTree*)File->Get("CalibCalPed"); + if ( !tr ) { + printf(" CalibCalPed : no such tree in %s \n",filename.Data()); + printf(" Exiting, are you sure this is a LEVEL0 not corrupted file? \n\n"); + return; + }; pamela::CalibCalPedEvent *ce = 0; // UInt_t found; @@ -163,14 +187,18 @@ }; // // - 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; const char *format = saveas; stringstream figsave; @@ -292,8 +320,11 @@ gDirectory->Delete("C14"); gDirectory->Delete("C15"); gDirectory->Delete("C16"); - TH1F *calped = new TH1F("C14","calped",4230,-3.5,4227.5); - TH1F *calrms = new TH1F("C15","calrms",4230,-3.5,4228.5); + //TH1F *calped = new TH1F("C14","calped",4230,-3.5,4227.5); + // TH1F *calrms = new TH1F("C15","calrms",4230,-3.5,4228.5); + TH1F *calped = new TH1F("C14","calped",2112,-3.5,4227.5); + // TH1F *calrms = new TH1F("C15","calrms",264,-2.,4226.); + TH1F *calrms = new TH1F("C15","calrms",2112,-3.5,4228.5); TH1F *calbad = new TH1F("C16","calgood",4230,-3.5,4228.5); // gDirectory->Delete("C17"); @@ -413,7 +444,7 @@ incalped++; }; calrms->Fill((float)j,(calib.calrms[l][m][n]/4.)); - if ( (calib.calrms[l][m][n]/4.) > 7. || (calib.calrms[l][m][n]/4.) < 1. ){ + if ( (((calib.calrms[l][m][n]/4.) > 7. || (calib.calrms[l][m][n]/4.) < 1.) && (j < 3440 && j > 3550)) || ( (j > 3439 && j < 3551) && ((calib.calrms[l][m][n]/4.) > 150. || (calib.calrms[l][m][n]/4.) < 1.)) ){ outcalrms++; } else { incalrms++; @@ -423,13 +454,13 @@ // if ( n < 6 ){ calthr->Fill((float)g,(float)calib.calthr[l][m][n]); - if ( calib.calthr[l][m][n] > 21. || calib.calthr[l][m][n] < 12. ){ + if ( (calib.calthr[l][m][n] > 21. || calib.calthr[l][m][n] < 12.) && (g < 215 && g > 221) ){ outcalthr++; } else { incalthr++; }; calvar->Fill((float)g,(float)calib.calvar[l][m][n]); - if ( calib.calvar[l][m][n] > 8. || calib.calvar[l][m][n] < 1. ){ + if ( (calib.calvar[l][m][n] > 8. || calib.calvar[l][m][n] < 1. ) && (g < 215 && g > 221) ){ outcalvar++; } else { incalvar++; @@ -616,6 +647,8 @@ calped->GetXaxis()->SetNdivisions(322); calped->SetXTitle("strip"); calped->SetYTitle("ADC channels"); + calped->SetMaximum(3000.); + calped->SetMinimum(-3000.); calped->Draw(); TPolyLine *banda1; Double_t xc[4] = {0.,4224.,4224.,0.}; @@ -627,7 +660,8 @@ banda1->Draw("fSAME"); TPolyLine *banda2; Double_t xc2[4] = {4031.5,4047.5,4047.5,4031.5}; - Double_t yc2[4] = {-2500.,-2500.,28000.,28000.}; + // Double_t yc2[4] = {-2500.,-2500.,28000.,28000.}; + Double_t yc2[4] = {-3000.,-3000.,3000.,3000.}; banda2 = new TPolyLine(4,xc2,yc2); banda2->SetLineColor(5); banda2->SetFillColor(5); @@ -645,6 +679,15 @@ banda1->SetFillColor(5); banda1->SetLineWidth(1); banda1->Draw("fSAME"); + Float_t minrm = calrms->GetMinimum(); + Float_t maxrm = calrms->GetMaximum(); + Double_t xrm2[4] = {3449.,3551.,3551.,3449.}; + Double_t yrm2[4] = {minrm,minrm,maxrm,maxrm}; + banda2 = new TPolyLine(4,xrm2,yrm2); + banda2->SetLineColor(5); + banda2->SetFillColor(5); + banda2->SetLineWidth(1); + banda2->Draw("fSAME"); calrms->SetXTitle("strip"); calrms->SetYTitle("ADC channels"); calrms->Draw("SAME"); @@ -686,8 +729,20 @@ banda1->SetFillColor(5); banda1->SetLineWidth(1); banda1->Draw("fSAME"); + // + minrm = calthr->GetMinimum(); + maxrm = 1.05*calthr->GetMaximum(); + Double_t xth2[4] = {215.,221.,221.,215.}; + Double_t yth2[4] = {minrm,minrm,maxrm,maxrm}; + banda2 = new TPolyLine(4,xth2,yth2); + banda2->SetLineColor(5); + banda2->SetFillColor(5); + banda2->SetLineWidth(1); + banda2->Draw("fSAME"); + // calthr->Draw("SAME"); f3pd2->cd(); + // gPad->SetLogy(); calvar->GetXaxis()->SetNdivisions(644); calvar->SetXTitle("pre-amplifier"); calvar->SetYTitle("ADC channels"); @@ -699,6 +754,17 @@ banda1->SetFillColor(5); banda1->SetLineWidth(1); banda1->Draw("fSAME"); + // + minrm = calvar->GetMinimum(); + maxrm = 1.05*calvar->GetMaximum(); + Double_t xva2[4] = {215.,221.,221.,215.}; + Double_t yva2[4] = {minrm,minrm,maxrm,maxrm}; + banda2 = new TPolyLine(4,xva2,yva2); + banda2->SetLineColor(5); + banda2->SetFillColor(5); + banda2->SetLineWidth(1); + banda2->Draw("fSAME"); + // calvar->Draw("SAME"); f3pd3->cd(); calbase->GetXaxis()->SetNdivisions(644); @@ -919,7 +985,7 @@ if ( ci == minev ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_chkcalib."; + figsave << figrec << "_CaloCHKCALIB."; figsave << format; figsave << "("; }; @@ -928,7 +994,7 @@ if ( ci == minev ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_chkcalib."; + figsave << figrec << "_CaloCHKCALIB."; figsave << format; }; }; @@ -937,7 +1003,7 @@ if ( ci == minev ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_chkcalib."; + figsave << figrec << "_CaloCHKCALIB."; figsave << format; }; // @@ -946,7 +1012,7 @@ if ( ci == maxev-4 ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_chkcalib."; + figsave << figrec << "_CaloCHKCALIB."; figsave << format; figsave << ")"; rapporto->Print(figsave.str().c_str(),"Portrait"); @@ -955,7 +1021,7 @@ if ( figmatra ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_chkcalib1_"; + figsave << figrec << "_CaloCHKCALIB1_"; figsave << (i+1) << "."; figsave << format; figura2->SaveAs(figsave.str().c_str()); @@ -963,14 +1029,14 @@ // figsave1.str(""); figsave1 << outdir << "/" ; - figsave1 << figrec << "_chkcalib2_"; + figsave1 << figrec << "_CaloCHKCALIB2_"; figsave1 << (i+1) << "."; figsave1 << format; figura1->SaveAs(figsave1.str().c_str()); // figsave2.str(""); figsave2 << outdir << "/" ; - figsave2 << figrec << "_chkcalib3_"; + figsave2 << figrec << "_CaloCHKCALIB3_"; figsave2 << (i+1) << "."; figsave2 << format; figura3->SaveAs(figsave2.str().c_str()); @@ -978,7 +1044,7 @@ if ( ci == maxev-4 ) { figsave.str(""); figsave << outdir << "/" ; - figsave << figrec << "_chkcalib_report."; + figsave << figrec << "_CaloCHKCALIB_report."; figsave << format; rapporto->SaveAs(figsave.str().c_str()); };