From abbc7fb55ec4efdcd96b9b48237a529df024cdda Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 18 May 2020 09:14:22 +0200 Subject: [PATCH 1/2] Apply `clang-tidy` automated code changes Enabled checks: boost-use-to-string misc-uniqueptr-reset-release modernize-deprecated-headers modernize-make-shared modernize-use-bool-literals modernize-use-equals-delete modernize-use-nullptr modernize-use-override performance-unnecessary-copy-initialization readability-container-size-empty readability-redundant-string-cstr readability-static-definition-in-anonymous-namespace readability-uniqueptr-delete-release --- OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp b/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp index 3bf1d2f6fd32e..612b02e68d0fd 100644 --- a/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp +++ b/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp @@ -26,7 +26,7 @@ class RootPlot { RootPlot(string type, string format, string file, float hmin=0., float hmax=0.) { - m_isInit = 0; + m_isInit = false; m_type = type; m_outputFormat = format; m_outputFile = file+"."+format; @@ -57,7 +57,7 @@ class RootPlot { gROOT->SetStyle("Plain"); gStyle->SetOptStat(111111); gStyle->SetOptFit(); - gStyle->SetPalette(1,0); + gStyle->SetPalette(1, nullptr); int pCol[2] = { 2, 3 }; if((m_type == "Map" || m_type == "EBEEMap") && (TString(m_title).Contains("status")) ) { @@ -105,7 +105,7 @@ class RootPlot { { if (!m_isInit) { this->init(); - m_isInit = 1; + m_isInit = true; } if (str[0] == '#') { @@ -191,7 +191,7 @@ class RootPlot { this->drawEBEEMap(); } - m_isInit = 0; + m_isInit = false; }; void drawTH1F() From ae20c37d0f29745445bd9b1c4495be86d22a6e40 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 18 May 2020 10:47:56 +0200 Subject: [PATCH 2/2] Apply `clang-format` automated formattng changes --- OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp | 551 ++++++++++--------- 1 file changed, 282 insertions(+), 269 deletions(-) diff --git a/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp b/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp index 612b02e68d0fd..37817d8a22902 100644 --- a/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp +++ b/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp @@ -24,27 +24,25 @@ class RootPlot { static const int DEFAULT_AXIS = 111; static const int TIME_AXIS = 222; - RootPlot(string type, string format, string file, float hmin=0., float hmax=0.) - { + RootPlot(string type, string format, string file, float hmin = 0., float hmax = 0.) { m_isInit = false; m_type = type; m_outputFormat = format; - m_outputFile = file+"."+format; - m_outputRoot = file+".root"; + m_outputFile = file + "." + format; + m_outputRoot = file + ".root"; m_title = "rootplot Plot"; m_xtitle = "X"; m_ytitle = "Y"; m_xAxisType = DEFAULT_AXIS; m_debug = 1; - m_T0 = TDatime(2005,01,01,00,00,00); + m_T0 = TDatime(2005, 01, 01, 00, 00, 00); m_hmin = hmin; m_hmax = hmax; }; - ~RootPlot() {}; + ~RootPlot(){}; - void init() - { + void init() { m_nbins[0] = m_nbins[1] = 100; m_mins[0] = m_mins[1] = FLT_MAX; m_maxs[0] = m_maxs[1] = FLT_MIN; @@ -59,9 +57,9 @@ class RootPlot { gStyle->SetOptFit(); gStyle->SetPalette(1, nullptr); - int pCol[2] = { 2, 3 }; - if((m_type == "Map" || m_type == "EBEEMap") && (TString(m_title).Contains("status")) ) { - gStyle->SetPalette(2,pCol); + int pCol[2] = {2, 3}; + if ((m_type == "Map" || m_type == "EBEEMap") && (TString(m_title).Contains("status"))) { + gStyle->SetPalette(2, pCol); } m_rootfile = new TFile(m_outputRoot.c_str(), "RECREATE"); @@ -70,7 +68,7 @@ class RootPlot { if (m_type == "TH1F") { m_nfields = 1; m_tree->Branch("x", &m_data[0], "x/F"); - } else if(m_type == "TH2F") { + } else if (m_type == "TH2F") { m_nfields = 2; m_tree->Branch("x", &m_data[0], "x/F"); m_tree->Branch("y", &m_data[1], "y/F"); @@ -80,29 +78,25 @@ class RootPlot { m_tree->Branch("y", &m_data[1], "y/F"); } else if (m_type == "Map") { m_nfields = 2; - m_tree->Branch("x", &m_data[0], "x/F"); // channel number - m_tree->Branch("y", &m_data[1], "y/F"); // variable var + m_tree->Branch("x", &m_data[0], "x/F"); // channel number + m_tree->Branch("y", &m_data[1], "y/F"); // variable var } else if (m_type == "EBEEMap") { m_nfields = 5; - m_tree->Branch("ism_z", &m_data[0], "ism_z/F"); // SM number (EB), z (EE) - m_tree->Branch("chnum_x", &m_data[1], "chnum_x/F"); // channel number (EB) , x (EE) - m_tree->Branch("var", &m_data[2], "var/F"); // variable var - m_tree->Branch("null_y", &m_data[3], "z/F"); // null value (EB), y (EE) - m_tree->Branch("isEB", &m_data[4], "isEB/F"); // 1 (EB), 0 (EE) - - } - + m_tree->Branch("ism_z", &m_data[0], "ism_z/F"); // SM number (EB), z (EE) + m_tree->Branch("chnum_x", &m_data[1], "chnum_x/F"); // channel number (EB) , x (EE) + m_tree->Branch("var", &m_data[2], "var/F"); // variable var + m_tree->Branch("null_y", &m_data[3], "z/F"); // null value (EB), y (EE) + m_tree->Branch("isEB", &m_data[4], "isEB/F"); // 1 (EB), 0 (EE) + } }; - void setTitle(string title) { m_title = title; } void setXTitle(string xtitle) { m_xtitle = xtitle; } void setYTitle(string ytitle) { m_ytitle = ytitle; } void setDebug(int debug) { m_debug = debug; } void setXAxisType(int code) { m_xAxisType = code; } - void parseAndFill(std::string str) - { + void parseAndFill(std::string str) { if (!m_isInit) { this->init(); m_isInit = true; @@ -113,32 +107,39 @@ class RootPlot { return; } - if (m_debug) { cout << "[data] " << flush; } - + if (m_debug) { + cout << "[data] " << flush; + } + typedef boost::tokenizer > tokenizer; escaped_list_separator sep('\\', ' ', '\"'); tokenizer tokens(str, sep); float datum; int cnt = 0; - for (tokenizer::iterator tok_iter = tokens.begin(); - tok_iter != tokens.end(); ++tok_iter) { - if (cnt > m_nfields) { continue; } + for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) { + if (cnt > m_nfields) { + continue; + } if (m_debug) { - cout << "<" << *tok_iter << ">" << flush; + cout << "<" << *tok_iter << ">" << flush; } - + if (m_xAxisType == TIME_AXIS && cnt == 0) { - TDatime d((*tok_iter).c_str()); - datum = (Float_t)(d.Convert() - m_T0.Convert()); + TDatime d((*tok_iter).c_str()); + datum = (Float_t)(d.Convert() - m_T0.Convert()); } else { - datum = atof((*tok_iter).c_str()); + datum = atof((*tok_iter).c_str()); } - if(m_type != "EBEEMap") { - if (datum < m_mins[cnt]) { m_mins[cnt] = datum; } - if (datum > m_maxs[cnt]) { m_maxs[cnt] = datum; } + if (m_type != "EBEEMap") { + if (datum < m_mins[cnt]) { + m_mins[cnt] = datum; + } + if (datum > m_maxs[cnt]) { + m_maxs[cnt] = datum; + } } m_data[cnt] = datum; @@ -146,31 +147,32 @@ class RootPlot { cnt++; } - if (m_debug) { cout << endl; } + if (m_debug) { + cout << endl; + } m_tree->Fill(); }; - - void draw() - { - for (int i=0; iGetXaxis()->SetTitle(m_xtitle.c_str()); plot->GetYaxis()->SetTitle(m_ytitle.c_str()); - + if (m_xAxisType == TIME_AXIS) { TAxis* axis = plot->GetXaxis(); setTimeAxis(axis); } - + m_tree->Draw("x >> rootplot"); plot->Draw(); c1.Print(m_outputFile.c_str(), m_outputFormat.c_str()); plot->Write(); - }; - void drawTH2F() - { - TCanvas c1("c1","rootplot",200,10,600,400); + void drawTH2F() { + TCanvas c1("c1", "rootplot", 200, 10, 600, 400); c1.SetGrid(); - TH2F* plot = new TH2F("rootplot", m_title.c_str(), m_nbins[0], m_mins[0], m_maxs[0], m_nbins[1], m_mins[1], m_maxs[1]); + TH2F* plot = + new TH2F("rootplot", m_title.c_str(), m_nbins[0], m_mins[0], m_maxs[0], m_nbins[1], m_mins[1], m_maxs[1]); plot->GetXaxis()->SetTitle(m_xtitle.c_str()); plot->GetYaxis()->SetTitle(m_ytitle.c_str()); - + if (m_xAxisType == TIME_AXIS) { TAxis* axis = plot->GetXaxis(); setTimeAxis(axis); } - + m_tree->Draw("x:y >> rootplot"); plot->Draw(); @@ -244,9 +244,8 @@ class RootPlot { plot->Write(); } - void drawTGraph() - { - TCanvas c1("c1","rootplot",200,10,600,400); + void drawTGraph() { + TCanvas c1("c1", "rootplot", 200, 10, 600, 400); c1.SetGrid(); Int_t n = (Int_t)m_tree->GetEntries(); @@ -264,7 +263,7 @@ class RootPlot { TAxis* axis = plot->GetXaxis(); setTimeAxis(axis); } - + plot->SetTitle(m_title.c_str()); plot->GetXaxis()->SetTitle(m_xtitle.c_str()); plot->GetYaxis()->SetTitle(m_ytitle.c_str()); @@ -275,13 +274,12 @@ class RootPlot { plot->Write(); }; - void drawMap() - { + void drawMap() { gStyle->SetOptStat(0); const Int_t csize = 250; - TCanvas c1("c1","rootplot",Int_t(85./20.*csize),csize); - TH2F* plot = new TH2F("rootplot",m_title.c_str(),85,0.0001,85.0001,20,0.0001,20.0001); + TCanvas c1("c1", "rootplot", Int_t(85. / 20. * csize), csize); + TH2F* plot = new TH2F("rootplot", m_title.c_str(), 85, 0.0001, 85.0001, 20, 0.0001, 20.0001); plot->GetXaxis()->SetTitle(m_xtitle.c_str()); plot->GetYaxis()->SetTitle(m_ytitle.c_str()); @@ -291,21 +289,20 @@ class RootPlot { // now fill the map... Int_t n = (Int_t)m_tree->GetEntries(); - for(Int_t i=0; iGetEntry(i); // while(x>1700) x-=1700; - Float_t xmap = Float_t(Int_t(x-1)/20)+1; - Float_t ymap = Float_t(Int_t(x-1)%20)+1; - plot->Fill(xmap,ymap,y); + Float_t xmap = Float_t(Int_t(x - 1) / 20) + 1; + Float_t ymap = Float_t(Int_t(x - 1) % 20) + 1; + plot->Fill(xmap, ymap, y); } // draw the map plot->SetTitle(m_title.c_str()); - if((TString(m_title).Contains("status"))) { + if ((TString(m_title).Contains("status"))) { plot->SetMinimum(-0.001); plot->SetMaximum(1.001); - } - else if(!(m_hmin==0 && m_hmax==0)) { + } else if (!(m_hmin == 0 && m_hmax == 0)) { plot->SetMinimum(m_hmin); plot->SetMaximum(m_hmax); } @@ -321,10 +318,10 @@ class RootPlot { // and draw the grid upon the map... TH2C* labelGrid = new TH2C("labelGrid", "label grid for SM", 85, 0., 85., 20, 0., 20.); - for(Int_t i=0; i<68; i++){ - Float_t X = (i/4)*5+2; - Float_t Y = (i%4)*5+2; - labelGrid->Fill(X,Y,i+1); + for (Int_t i = 0; i < 68; i++) { + Float_t X = (i / 4) * 5 + 2; + Float_t Y = (i % 4) * 5 + 2; + labelGrid->Fill(X, Y, i + 1); } labelGrid->SetMinimum(0.1); labelGrid->SetMarkerSize(4); @@ -332,25 +329,21 @@ class RootPlot { c1.Print(m_outputFile.c_str(), m_outputFormat.c_str()); plot->Write(); - }; - void drawEBEEMap() - { - + void drawEBEEMap() { const Int_t csize = 900; - - TCanvas c1("c1","rootplot",csize,csize); - TPad p1("EBPad","EBPad",0.,0.5,1.,1.); + + TCanvas c1("c1", "rootplot", csize, csize); + TPad p1("EBPad", "EBPad", 0., 0.5, 1., 1.); p1.Draw(); - TPad p2("EEPlusPad","EEPlusPad",0.,0.,0.48,0.5); + TPad p2("EEPlusPad", "EEPlusPad", 0., 0., 0.48, 0.5); p2.Draw(); - TPad p3("EEPlusPad","EEPlusPad",0.50,0.,0.98,0.5); + TPad p3("EEPlusPad", "EEPlusPad", 0.50, 0., 0.98, 0.5); p3.Draw(); - //EB - TH2F* EBPlot = new TH2F("rootplotEB",m_title.c_str(), 360, 0., 360., 170, -85., 85.); + TH2F* EBPlot = new TH2F("rootplotEB", m_title.c_str(), 360, 0., 360., 170, -85., 85.); EBPlot->GetXaxis()->SetTitle("i#phi"); EBPlot->GetYaxis()->SetTitle("i#eta"); EBPlot->GetZaxis()->SetTitle(m_ytitle.c_str()); @@ -358,7 +351,7 @@ class RootPlot { EBPlot->GetYaxis()->SetNdivisions(2); //EE+ - TH2F* EEPlot_plus = new TH2F("rootplotEE+",m_title.c_str(), 100, 0., 100., 100, 0., 100.); + TH2F* EEPlot_plus = new TH2F("rootplotEE+", m_title.c_str(), 100, 0., 100., 100, 0., 100.); EEPlot_plus->GetXaxis()->SetTitle("ix"); EEPlot_plus->GetYaxis()->SetTitleOffset(1.3); EEPlot_plus->GetYaxis()->SetTitle("iy"); @@ -367,14 +360,14 @@ class RootPlot { EEPlot_plus->GetYaxis()->SetNdivisions(10); //EE- - TH2F* EEPlot_minus = new TH2F("rootplotEE-",m_title.c_str(), 100, 0., 100., 100, 0., 100.); + TH2F* EEPlot_minus = new TH2F("rootplotEE-", m_title.c_str(), 100, 0., 100., 100, 0., 100.); EEPlot_minus->GetXaxis()->SetTitle("ix"); EEPlot_minus->GetYaxis()->SetTitle("iy"); EEPlot_minus->GetYaxis()->SetTitleOffset(1.3); EEPlot_minus->GetZaxis()->SetTitle(m_ytitle.c_str()); EEPlot_minus->GetXaxis()->SetNdivisions(10, kTRUE); EEPlot_minus->GetYaxis()->SetNdivisions(10); - + Float_t chnum_x, var, ism_z, isEB, null_y; m_tree->SetBranchAddress("ism_z", &ism_z); m_tree->SetBranchAddress("chnum_x", &chnum_x); @@ -384,64 +377,60 @@ class RootPlot { // now fill the maps... Int_t n = (Int_t)m_tree->GetEntries(); - for(Int_t i=0; iGetEntry(i); if (isEB) { - Float_t iex = -1; - Float_t ipx = -1; - for ( unsigned int i=1; i<=36; i++ ) { - - if(i == ism_z) { - - Float_t ie = Float_t(Int_t(chnum_x-1)/20)+1; - Float_t ip = Float_t(Int_t(chnum_x-1)%20)+1; - - if ( ism_z <= 18 ) { - iex = ie - 1; - ipx = (20-ip)+20*(ism_z-1); - } else { - iex = -1*ie; - ipx = ip+20*(ism_z-19)-1; - } - - EBPlot->Fill(ipx,iex,var); - - } - - } - }//end loop on EB - + Float_t iex = -1; + Float_t ipx = -1; + for (unsigned int i = 1; i <= 36; i++) { + if (i == ism_z) { + Float_t ie = Float_t(Int_t(chnum_x - 1) / 20) + 1; + Float_t ip = Float_t(Int_t(chnum_x - 1) % 20) + 1; + + if (ism_z <= 18) { + iex = ie - 1; + ipx = (20 - ip) + 20 * (ism_z - 1); + } else { + iex = -1 * ie; + ipx = ip + 20 * (ism_z - 19) - 1; + } + + EBPlot->Fill(ipx, iex, var); + } + } + } //end loop on EB + //assuming: if not EB, it's EE (TODO: check strings)... else { - //EE+ - if (ism_z==1) EEPlot_plus->Fill(chnum_x-0.5,null_y-0.5,var); - //EE- - if (ism_z==-1) EEPlot_minus->Fill(chnum_x-0.5,null_y-0.5,var); - }//end loop on EE - - }//end loop on entries + //EE+ + if (ism_z == 1) + EEPlot_plus->Fill(chnum_x - 0.5, null_y - 0.5, var); + //EE- + if (ism_z == -1) + EEPlot_minus->Fill(chnum_x - 0.5, null_y - 0.5, var); + } //end loop on EE + + } //end loop on entries // draw the map //setting gStyle->SetOptStat("e"); gStyle->SetPaintTextFormat("+g"); - - + EBPlot->SetTitle(m_title.c_str()); EEPlot_plus->SetTitle(m_title.c_str()); EEPlot_minus->SetTitle(m_title.c_str()); - if((TString(m_title).Contains("status"))) { + if ((TString(m_title).Contains("status"))) { EBPlot->SetMinimum(-0.001); EBPlot->SetMaximum(1.001); EEPlot_plus->SetMinimum(-0.001); EEPlot_plus->SetMaximum(1.001); EEPlot_minus->SetMinimum(-0.001); EEPlot_minus->SetMaximum(1.001); - - } - else if(!(m_hmin==0 && m_hmax==0)) { + + } else if (!(m_hmin == 0 && m_hmax == 0)) { EBPlot->SetMinimum(m_hmin); EBPlot->SetMaximum(m_hmax); EEPlot_plus->SetMinimum(m_hmin); @@ -449,7 +438,7 @@ class RootPlot { EEPlot_minus->SetMinimum(m_hmin); EEPlot_minus->SetMaximum(m_hmax); } - + p1.cd(); gPad->SetGridx(); gPad->SetGridy(); @@ -457,86 +446,100 @@ class RootPlot { // and draw the grid upon the map... TH2C* labelGrid = new TH2C("labelGrid", "label grid for SM", 18, 0., 360., 2, -85., 85.); - for(Int_t sm=1; sm<=36; sm++) { - int X = (sm<=18) ? sm : sm-18; - int Y = (sm<=18) ? 2 : 1; - double posSM = (sm<=18) ? sm : -1*(sm-18); - labelGrid->SetBinContent(X,Y,posSM); + for (Int_t sm = 1; sm <= 36; sm++) { + int X = (sm <= 18) ? sm : sm - 18; + int Y = (sm <= 18) ? 2 : 1; + double posSM = (sm <= 18) ? sm : -1 * (sm - 18); + labelGrid->SetBinContent(X, Y, posSM); } labelGrid->SetMarkerSize(2); labelGrid->Draw("text,same"); c1.Print(m_outputFile.c_str(), m_outputFormat.c_str()); EBPlot->Write(); - + //END OF EBPLOT - - int ixSectorsEE[202] = {61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 0,100,100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3, 0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,100,100, 0, 61, 65, 65, 70, 70, 80, 80, 90, 90, 92, 0, 61, 65, 65, 90, 90, 97, 0, 57, 60, 60, 65, 65, 70, 70, 75, 75, 80, 80, 0, 50, 50, 0, 43, 40, 40, 35, 35, 30, 30, 25, 25, 20, 20, 0, 39, 35, 35, 10, 10, 3, 0, 39, 35, 35, 30, 30, 20, 20, 10, 10, 8, 0, 45, 45, 40, 40, 35, 35, 0, 55, 55, 60, 60, 65, 65}; - - int iySectorsEE[202] = {50, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 50, 0, 50, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,100,100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3, 0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 50, 0, 45, 45, 40, 40, 35, 35, 30, 30, 25, 25, 0, 50, 50, 55, 55, 60, 60, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, 61,100, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, 50, 50, 55, 55, 60, 60, 0, 45, 45, 40, 40, 35, 35, 30, 30, 25, 25, 0, 39, 30, 30, 15, 15, 5, 0, 39, 30, 30, 15, 15, 5}; + + int ixSectorsEE[202] = { + 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, + 41, 41, 42, 42, 43, 43, 45, 45, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 0, 100, 100, 97, 97, 95, + 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, + 13, 8, 8, 5, 5, 3, 3, 0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, + 40, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97, 100, 100, 0, 61, 65, 65, 70, + 70, 80, 80, 90, 90, 92, 0, 61, 65, 65, 90, 90, 97, 0, 57, 60, 60, 65, 65, 70, 70, 75, 75, 80, 80, 0, + 50, 50, 0, 43, 40, 40, 35, 35, 30, 30, 25, 25, 20, 20, 0, 39, 35, 35, 10, 10, 3, 0, 39, 35, 35, 30, + 30, 20, 20, 10, 10, 8, 0, 45, 45, 40, 40, 35, 35, 0, 55, 55, 60, 60, 65, 65}; + + int iySectorsEE[202] = { + 50, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, + 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 50, 0, 50, 60, 60, 65, 65, + 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97, 100, 100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, + 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3, + 0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 50, 0, 45, 45, 40, 40, + 35, 35, 30, 30, 25, 25, 0, 50, 50, 55, 55, 60, 60, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, + 61, 100, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, 50, 50, 55, 55, 60, 60, 0, 45, 45, 40, 40, + 35, 35, 30, 30, 25, 25, 0, 39, 30, 30, 15, 15, 5, 0, 39, 30, 30, 15, 15, 5}; //grid - TH2C labelGrid1("labelGrid1","label grid for EE -", 10, 0., 100., 10, 0., 100.); - for ( int i=1; i<=10; i++) { - for ( int j=1; j<=10; j++) { - labelGrid1.SetBinContent(i, j, -10); - } - } - - labelGrid1.SetBinContent(2, 5, -3); - labelGrid1.SetBinContent(2, 7, -2); - labelGrid1.SetBinContent(4, 9, -1); - labelGrid1.SetBinContent(7, 9, -9); - labelGrid1.SetBinContent(9, 7, -8); - labelGrid1.SetBinContent(9, 5, -7); - labelGrid1.SetBinContent(8, 3, -6); - labelGrid1.SetBinContent(6, 2, -5); - labelGrid1.SetBinContent(3, 3, -4); - labelGrid1.SetMarkerSize(2); - labelGrid1.SetMinimum(-9.01); - labelGrid1.SetMaximum(-0.01); - - TH2C labelGrid2("labelGrid2","label grid for EE +", 10, 0., 100., 10, 0., 100.); - - for ( int i=1; i<=10; i++) { - for ( int j=1; j<=10; j++) { - labelGrid2.SetBinContent(i, j, -10); - } - } - - labelGrid2.SetBinContent(2, 5, +3); - labelGrid2.SetBinContent(2, 7, +2); - labelGrid2.SetBinContent(4, 9, +1); - labelGrid2.SetBinContent(7, 9, +9); - labelGrid2.SetBinContent(9, 7, +8); - labelGrid2.SetBinContent(9, 5, +7); - labelGrid2.SetBinContent(8, 3, +6); - labelGrid2.SetBinContent(5, 2, +5); - labelGrid2.SetBinContent(3, 3, +4); - - labelGrid2.SetMarkerSize(2); - labelGrid2.SetMinimum(+0.01); - labelGrid2.SetMaximum(+9.01); - - + TH2C labelGrid1("labelGrid1", "label grid for EE -", 10, 0., 100., 10, 0., 100.); + for (int i = 1; i <= 10; i++) { + for (int j = 1; j <= 10; j++) { + labelGrid1.SetBinContent(i, j, -10); + } + } + + labelGrid1.SetBinContent(2, 5, -3); + labelGrid1.SetBinContent(2, 7, -2); + labelGrid1.SetBinContent(4, 9, -1); + labelGrid1.SetBinContent(7, 9, -9); + labelGrid1.SetBinContent(9, 7, -8); + labelGrid1.SetBinContent(9, 5, -7); + labelGrid1.SetBinContent(8, 3, -6); + labelGrid1.SetBinContent(6, 2, -5); + labelGrid1.SetBinContent(3, 3, -4); + labelGrid1.SetMarkerSize(2); + labelGrid1.SetMinimum(-9.01); + labelGrid1.SetMaximum(-0.01); + + TH2C labelGrid2("labelGrid2", "label grid for EE +", 10, 0., 100., 10, 0., 100.); + + for (int i = 1; i <= 10; i++) { + for (int j = 1; j <= 10; j++) { + labelGrid2.SetBinContent(i, j, -10); + } + } + + labelGrid2.SetBinContent(2, 5, +3); + labelGrid2.SetBinContent(2, 7, +2); + labelGrid2.SetBinContent(4, 9, +1); + labelGrid2.SetBinContent(7, 9, +9); + labelGrid2.SetBinContent(9, 7, +8); + labelGrid2.SetBinContent(9, 5, +7); + labelGrid2.SetBinContent(8, 3, +6); + labelGrid2.SetBinContent(5, 2, +5); + labelGrid2.SetBinContent(3, 3, +4); + + labelGrid2.SetMarkerSize(2); + labelGrid2.SetMinimum(+0.01); + labelGrid2.SetMaximum(+9.01); + //EE+ p2.cd(); gPad->SetGridx(); gPad->SetGridy(); EEPlot_plus->Draw("colz"); labelGrid2.Draw("text,same"); - - //drawing sector grid + + //drawing sector grid TLine l; l.SetLineWidth(1); - for ( int i=0; i<201; i=i+1) { - if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) && (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) { - l.DrawLine(ixSectorsEE[i], iySectorsEE[i], ixSectorsEE[i+1], iySectorsEE[i+1]); - } + for (int i = 0; i < 201; i = i + 1) { + if ((ixSectorsEE[i] != 0 || iySectorsEE[i] != 0) && (ixSectorsEE[i + 1] != 0 || iySectorsEE[i + 1] != 0)) { + l.DrawLine(ixSectorsEE[i], iySectorsEE[i], ixSectorsEE[i + 1], iySectorsEE[i + 1]); + } } - //EE- p3.cd(); gPad->SetGridx(); @@ -545,16 +548,14 @@ class RootPlot { labelGrid1.Draw("text,same"); //drawing sector grid - for ( int i=0; i<201; i=i+1) { - if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) && (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) { - l.DrawLine(ixSectorsEE[i], iySectorsEE[i], ixSectorsEE[i+1], iySectorsEE[i+1]); - } + for (int i = 0; i < 201; i = i + 1) { + if ((ixSectorsEE[i] != 0 || iySectorsEE[i] != 0) && (ixSectorsEE[i + 1] != 0 || iySectorsEE[i + 1] != 0)) { + l.DrawLine(ixSectorsEE[i], iySectorsEE[i], ixSectorsEE[i + 1], iySectorsEE[i + 1]); + } } - - - //drawing everything & printing - c1.Print(m_outputFile.c_str(), m_outputFormat.c_str()); + //drawing everything & printing + c1.Print(m_outputFile.c_str(), m_outputFormat.c_str()); }; void setTimeAxis(TAxis* axis) { @@ -564,9 +565,9 @@ class RootPlot { axis->SetLabelOffset(0.02); axis->SetLabelSize(0.03); } - + private: - RootPlot() {}; // hidden default constructor + RootPlot(){}; // hidden default constructor bool m_isInit; TFile* m_rootfile; @@ -591,35 +592,28 @@ class RootPlot { TDatime m_T0; }; -void arg_error(string msg) -{ +void arg_error(string msg) { cerr << "ERROR: " << msg << endl; cerr << "Use 'ECALrootPlotter -h' for help" << endl; exit(1); } -int main (int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { // Parse command line program_options::options_description desc("options"); - program_options::options_description visible("Usage: ECALrootPlotter [options] [Plot Type] [Output Format] [Output File] \noptions"); - visible.add_options() - ("time,t", "X axis takes time values") - ("file,f", program_options::value(), "input file name") - ("title,T", program_options::value(), "Set plot title") - ("xtitle,X", program_options::value(), "X axis title") - ("ytitle,Y", program_options::value(), "Y axis title") - ("debug","Print debug information") - ("help,h", "help message") - ; + program_options::options_description visible( + "Usage: ECALrootPlotter [options] [Plot Type] [Output Format] [Output File] \noptions"); + visible.add_options()("time,t", "X axis takes time values")( + "file,f", program_options::value(), "input file name")( + "title,T", program_options::value(), "Set plot title")( + "xtitle,X", program_options::value(), "X axis title")( + "ytitle,Y", program_options::value(), "Y axis title")("debug", "Print debug information")("help,h", + "help message"); program_options::options_description hidden("argument"); - hidden.add_options() - ("type", program_options::value(),"Type of ROOT plot") - ("format", program_options::value(), "Output format") - ("output", program_options::value(), "Output file") - ("hmin", program_options::value(), "histo_min") - ("hmax", program_options::value(), "histo_max") - ; + hidden.add_options()("type", program_options::value(), "Type of ROOT plot")( + "format", program_options::value(), "Output format")( + "output", program_options::value(), "Output file")("hmin", program_options::value(), "histo_min")( + "hmax", program_options::value(), "histo_max"); desc.add(visible).add(hidden); program_options::positional_options_description pd; pd.add("type", 1); @@ -651,37 +645,51 @@ int main (int argc, char* argv[]) int axisCode = RootPlot::DEFAULT_AXIS; int debug = 0; - if (vm.count("type")) { - type = vm["type"].as(); - if (type != "TH1F" && type != "TH2F" && type != "TGraph" && type != "Map" && type != "EBEEMap" ) { + if (vm.count("type")) { + type = vm["type"].as(); + if (type != "TH1F" && type != "TH2F" && type != "TGraph" && type != "Map" && type != "EBEEMap") { cerr << "ERROR: Plot type " << type << " is not valid." << endl; - arg_error("Valid types are:\n" - " 'TH1F' (1 col data)\n" - " 'TH2F' (2 col data)\n" - " 'TGraph' (2 col data)\n" - " 'Map' (2 col data)\n" - " 'EBEEMap' (5 col data)\n" - ); + arg_error( + "Valid types are:\n" + " 'TH1F' (1 col data)\n" + " 'TH2F' (2 col data)\n" + " 'TGraph' (2 col data)\n" + " 'Map' (2 col data)\n" + " 'EBEEMap' (5 col data)\n"); } - } else { - arg_error("type is required.\n" - "Valid types are:\n" - " 'TH1F' (1 col data)\n" - " 'TH2F' (2 col data)\n" - " 'TGraph' (2 col data)\n" - " 'Map' (2 col data)\n" - " 'EBEEMap' (5 col data)" - ); + } else { + arg_error( + "type is required.\n" + "Valid types are:\n" + " 'TH1F' (1 col data)\n" + " 'TH2F' (2 col data)\n" + " 'TGraph' (2 col data)\n" + " 'Map' (2 col data)\n" + " 'EBEEMap' (5 col data)"); + } + if (vm.count("format")) { + outputFormat = vm["format"].as(); + } else { + arg_error("format is required"); + } + if (vm.count("output")) { + outputFile = vm["output"].as(); + } else { + arg_error("output is required"); + } + if (vm.count("hmin")) { + histo_min = vm["hmin"].as(); + } + if (vm.count("hmax")) { + histo_max = vm["hmax"].as(); + } + if (vm.count("file")) { + file = vm["file"].as(); + } + + if (vm.count("time")) { + axisCode = RootPlot::TIME_AXIS; } - if (vm.count("format")) { outputFormat = vm["format"].as(); } - else { arg_error("format is required"); } - if (vm.count("output")) { outputFile = vm["output"].as(); } - else { arg_error("output is required"); } - if (vm.count("hmin")) {histo_min = vm["hmin"].as(); } - if (vm.count("hmax")) {histo_max = vm["hmax"].as(); } - if (vm.count("file")) {file = vm["file"].as(); } - - if (vm.count("time")) { axisCode = RootPlot::TIME_AXIS; } if (vm.count("title")) { title = vm["title"].as(); } @@ -691,8 +699,10 @@ int main (int argc, char* argv[]) if (vm.count("ytitle")) { ytitle = vm["ytitle"].as(); } - if (vm.count("debug")) { debug = 1; } - + if (vm.count("debug")) { + debug = 1; + } + string path = ""; if ((int)file.find("/") >= 0) { path = file.substr(0, file.rfind("/")); @@ -701,9 +711,12 @@ int main (int argc, char* argv[]) // substitute _ with spaces size_t t; - while ((t = title.find('_'))!=string::npos) title[t] = ' '; - while ((t = xtitle.find('_'))!=string::npos) xtitle[t] = ' '; - while ((t = ytitle.find('_'))!=string::npos) ytitle[t] = ' '; + while ((t = title.find('_')) != string::npos) + title[t] = ' '; + while ((t = xtitle.find('_')) != string::npos) + xtitle[t] = ' '; + while ((t = ytitle.find('_')) != string::npos) + ytitle[t] = ' '; if (debug) { cout << "Debug info: " << endl; @@ -729,8 +742,8 @@ int main (int argc, char* argv[]) rootplot.setDebug(debug); string line; - - ifstream *finput = (ifstream *)&cin; + + ifstream* finput = (ifstream*)&cin; if (file.length() > 0) { finput = new ifstream(file.c_str()); } @@ -738,7 +751,7 @@ int main (int argc, char* argv[]) rootplot.parseAndFill(line); } - if ( finput->bad() || !finput->eof() ) { + if (finput->bad() || !finput->eof()) { cerr << "Input error." << endl; } @@ -749,7 +762,7 @@ int main (int argc, char* argv[]) } rootplot.draw(); - } catch (std::exception &e) { + } catch (std::exception& e) { cerr << "ERROR: " << e.what() << endl; } }