Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:27:23

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //
0003 // etaPhiPlot(fileName, plot, drawLeg, ifEta, maxEta, tag)
0004 //      Make the plots of integrated interaction/radiation/step lengths as a
0005 //      function of eta or phi
0006 // fileName (TString)     Name of the input ROOT file ("matbdg_run3.root")
0007 // plot     (std::string) Type of plot: intl/radl/step ("intl")
0008 // drawLeg  (bool)        Flag to show the legend or not (true)
0009 // ifEta    (bool)        Draw as a function of eta or phi (true)
0010 // maxEta   (double)      Maximum value of x-axis: if -1 use default (5.2)
0011 // tag      (string)      Tag to be added to the name of the canvas ("Run3")
0012 //
0013 // etaPhi2DPlot(fileName, plot, drawLeg, maxEta, tag)
0014 //      Make the 2-D plots as a function of eta and phi with same parameter
0015 //      meanings as those of *etaPhiPlot*
0016 //
0017 // etaPhiPlotComp(fileName1, fileName2, plot, ifEta, tag, txt, debug)
0018 //      Compares material budget plots from 2 different files
0019 //
0020 // etaPhiPlotComp4(filePreFix, tag, plot, ifEta, debug)
0021 //      Compares material budget plots from 4 different files:
0022 //      dddXML, dd4hepXML, dddDB, dd4hepDB
0023 //
0024 // filePreFix (std::string) Prefix to all 4 file names which will be followed
0025 //                          by one of dddXML/dd4hepXML/dddDB/dd4hepDB strings
0026 //                          and finally with *tag* and ".root"
0027 // txt        (std::string) Part of the y-title coming after #frac for the plot
0028 //                          ("{DDD}{DD4hep}")
0029 //
0030 ///////////////////////////////////////////////////////////////////////////////
0031 
0032 // include files
0033 #include <TCanvas.h>
0034 #include <TChain.h>
0035 #include <TFile.h>
0036 #include <TGraphErrors.h>
0037 #include <TH1D.h>
0038 #include <TH2D.h>
0039 #include <THStack.h>
0040 #include <TLegend.h>
0041 #include <TPaveStats.h>
0042 #include <TPaveText.h>
0043 #include <TProfile.h>
0044 #include <TProfile2D.h>
0045 #include <TROOT.h>
0046 #include <TStyle.h>
0047 #include <vector>
0048 #include <string>
0049 #include <iomanip>
0050 #include <iostream>
0051 #include <fstream>
0052 
0053 void etaPhiPlot(TString fileName = "matbdg_run3.root",
0054                 std::string plot = "intl",
0055                 bool drawLeg = true,
0056                 bool ifEta = true,
0057                 double maxEta = 5.2,
0058                 std::string tag = "Run3");
0059 void etaPhi2DPlot(TString fileName = "matbdg_run3.root",
0060                   std::string plot = "intl",
0061                   bool drawLeg = true,
0062                   double maxEta = 5.2,
0063                   std::string tag = "Run3");
0064 void etaPhiPlotComp(TString fileName1 = "matbdg_run3.root",
0065                     TString fileName2 = "matbdg_run3_dd4hep.root",
0066                     std::string plot = "intl",
0067                     bool ifEta = true,
0068                     std::string tag = "Run3",
0069                     std::string txt = "{DDD}/{DD4hep}",
0070                     bool debug = false);
0071 void etaPhiPlotComp4(std::string filePreFix = "files/matbdgRun3",
0072                      std::string tag = "pre6",
0073                      std::string plot = "radl",
0074                      bool ifEta = true,
0075                      bool debug = false);
0076 void setStyle();
0077 
0078 const int nlay = 13;
0079 const int ngrp = 9;
0080 int nlayers[ngrp] = {5, 1, 1, 1, 1, 1, 1, 1, 1};
0081 int nflayer[ngrp] = {0, 5, 6, 7, 8, 9, 10, 11, 12};
0082 int colorLay[nlay] = {2, 2, 2, 2, 2, 3, 5, 4, 8, 6, 3, 7, 1};
0083 int styleLay[nlay] = {20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 30};
0084 int legends[nlay] = {1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
0085 std::string title[nlay] = {
0086     "Beam Pipe", "", "", "", "", "Tracker", "ECAL", "HCAL", "HGCAL", "HF", "Magnet", "MUON", "Forward"};
0087 std::string names[nlay] = {
0088     "BEAM", "BEAM1", "BEAM2", "BEAM3", "BEAM4", "Tracker", "ECAL", "HCal", "CALOEC", "VCAL", "MGNT", "MUON", "OQUA"};
0089 
0090 void etaPhiPlot(TString fileName, std::string plot, bool drawLeg, bool ifEta, double maxEta, std::string tag) {
0091   TFile *hcalFile = new TFile(fileName);
0092   hcalFile->cd("materialBudgetVolumeAnalysis");
0093   setStyle();
0094   gStyle->SetOptTitle(0);
0095 
0096   std::string xtit = "#eta";
0097   std::string ztit = "Eta";
0098   std::string ytit = "none";
0099   double xh = 0.90;
0100   if (plot == "radl") {
0101     ytit = "Material Budget (X_{0})";
0102   } else if (plot == "step") {
0103     ytit = "Material Budget (Step Length)";
0104     xh = 0.95;
0105   } else {
0106     plot = "intl";
0107     ytit = "Material Budget (#lambda)";
0108   }
0109   if (!ifEta) {
0110     xtit = "#phi";
0111     ztit = "Phi";
0112   }
0113 
0114   TLegend *leg = new TLegend(0.84, 0.69, 0.99, 0.99);
0115   leg->SetBorderSize(1);
0116   leg->SetFillColor(10);
0117   leg->SetMargin(0.25);
0118   leg->SetTextSize(0.028);
0119 
0120   char hname[20], titlex[50];
0121   sprintf(hname, "%s%s%s", plot.c_str(), ztit.c_str(), names[0].c_str());
0122   TProfile *prof;
0123   gDirectory->GetObject(hname, prof);
0124   int nb = prof->GetNbinsX();
0125   double xlow = prof->GetBinLowEdge(1);
0126   double xhigh = prof->GetBinLowEdge(nb) + prof->GetBinWidth(nb);
0127   THStack *hs = new THStack("hs", "");
0128   for (int ii = 0; ii < nlay; ++ii) {
0129     sprintf(hname, "%s%s%s", plot.c_str(), ztit.c_str(), names[ii].c_str());
0130     TProfile *prof;
0131     gDirectory->GetObject(hname, prof);
0132     sprintf(hname, "%s%s%sH", plot.c_str(), ztit.c_str(), names[ii].c_str());
0133     TH1D *hist = new TH1D(hname, "", nb, xlow, xhigh);
0134     for (int k = 1; k <= nb; ++k) {
0135       double cont = prof->GetBinContent(k);
0136       hist->SetBinContent(k, cont);
0137     }
0138     hist->SetLineColor(colorLay[ii]);
0139     hist->SetFillColor(colorLay[ii]);
0140     if (ifEta && maxEta > 0)
0141       hist->GetXaxis()->SetRangeUser(-maxEta, maxEta);
0142     hs->Add(hist);
0143     if (legends[ii] > 0) {
0144       sprintf(titlex, "%s", title[ii].c_str());
0145       leg->AddEntry(hist, titlex, "lf");
0146     }
0147   }
0148 
0149   std::string cname = "c_" + plot + ztit + tag;
0150   TCanvas *cc1 = new TCanvas(cname.c_str(), cname.c_str(), 700, 600);
0151   if (xh > 0.91) {
0152     cc1->SetLeftMargin(0.15);
0153     cc1->SetRightMargin(0.05);
0154   } else {
0155     cc1->SetLeftMargin(0.10);
0156     cc1->SetRightMargin(0.10);
0157   }
0158 
0159   hs->Draw("");
0160   if (drawLeg)
0161     leg->Draw("sames");
0162   hs->GetXaxis()->SetTitle(xtit.c_str());
0163   hs->GetYaxis()->SetTitle(ytit.c_str());
0164   if (xh > 0.91) {
0165     hs->GetYaxis()->SetTitleOffset(2.0);
0166   } else {
0167     hs->GetYaxis()->SetTitleOffset(1.2);
0168   }
0169   cc1->Modified();
0170 }
0171 
0172 void etaPhi2DPlot(TString fileName, std::string plot, bool drawLeg, double maxEta, std::string tag) {
0173   TFile *hcalFile = new TFile(fileName);
0174   hcalFile->cd("materialBudgetVolumeAnalysis");
0175   setStyle();
0176   gStyle->SetOptTitle(1);
0177 
0178   std::string xtit = "#eta";
0179   std::string ytit = "#phi";
0180   std::string ztit = "none";
0181   if (plot == "radl") {
0182     ztit = "Material Budget (X_{0})";
0183   } else if (plot == "step") {
0184     ztit = "Material Budget (Step Length)";
0185   } else {
0186     plot = "intl";
0187     ztit = "Material Budget (#lambda)";
0188   }
0189 
0190   TLegend *leg = new TLegend(0.84, 0.69, 0.99, 0.99);
0191   leg->SetBorderSize(1);
0192   leg->SetFillColor(10);
0193   leg->SetMargin(0.25);
0194   leg->SetTextSize(0.028);
0195 
0196   char hname[20], titlex[50];
0197   sprintf(hname, "%sEtaPhi%s", plot.c_str(), names[0].c_str());
0198   TProfile2D *prof;
0199   gDirectory->GetObject(hname, prof);
0200   int nx = prof->GetXaxis()->GetNbins();
0201   double xlow = prof->GetXaxis()->GetBinLowEdge(1);
0202   double xhigh = prof->GetXaxis()->GetBinUpEdge(nx);
0203   int ny = prof->GetYaxis()->GetNbins();
0204   double ylow = prof->GetYaxis()->GetBinLowEdge(1);
0205   double yhigh = prof->GetYaxis()->GetBinUpEdge(ny);
0206   std::cout << hname << " X " << nx << ":" << xlow << ":" << xhigh << " Y " << ny << ":" << ylow << ":" << yhigh
0207             << std::endl;
0208   THStack *hs = new THStack("hs", ztit.c_str());
0209   for (int ii = 0; ii < nlay; ++ii) {
0210     sprintf(hname, "%sEtaPhi%s", plot.c_str(), names[ii].c_str());
0211     gDirectory->GetObject(hname, prof);
0212     sprintf(hname, "%sEtaPhi%sH", plot.c_str(), names[ii].c_str());
0213     TH2D *hist = new TH2D(hname, "", nx, xlow, xhigh, ny, ylow, yhigh);
0214     for (int kx = 1; kx <= nx; ++kx) {
0215       for (int ky = 1; ky <= ny; ++ky) {
0216         double cont = prof->GetBinContent(kx, ky);
0217         hist->SetBinContent(kx, ky, cont);
0218       }
0219     }
0220     hist->SetLineColor(colorLay[ii]);
0221     hist->SetFillColor(colorLay[ii]);
0222     if (maxEta > 0)
0223       hist->GetXaxis()->SetRangeUser(-maxEta, maxEta);
0224     hs->Add(hist);
0225     if (legends[ii] > 0) {
0226       sprintf(titlex, "%s", title[ii].c_str());
0227       leg->AddEntry(hist, titlex, "lf");
0228     }
0229   }
0230 
0231   std::string cname = "c_" + plot + "EtaPhi" + tag;
0232   TCanvas *cc1 = new TCanvas(cname.c_str(), cname.c_str(), 700, 600);
0233   cc1->SetLeftMargin(0.10);
0234   cc1->SetRightMargin(0.10);
0235 
0236   hs->Draw("");
0237   if (drawLeg)
0238     leg->Draw("sames");
0239   hs->GetXaxis()->SetTitle(xtit.c_str());
0240   hs->GetYaxis()->SetTitle(ytit.c_str());
0241   hs->GetYaxis()->SetTitleOffset(1.2);
0242   cc1->Modified();
0243 }
0244 
0245 void etaPhiPlotComp(
0246     TString fileName1, TString fileName2, std::string plot, bool ifEta, std::string tag, std::string txt, bool debug) {
0247   setStyle();
0248   gStyle->SetOptTitle(0);
0249   TFile *file1 = new TFile(fileName1);
0250   TFile *file2 = new TFile(fileName2);
0251   if ((file1 != nullptr) && (file2 != nullptr)) {
0252     TDirectory *dir1 = (TDirectory *)(file1->FindObjectAny("materialBudgetVolumeAnalysis"));
0253     TDirectory *dir2 = (TDirectory *)(file2->FindObjectAny("materialBudgetVolumeAnalysis"));
0254     TLegend *leg = new TLegend(0.84, 0.69, 0.99, 0.99);
0255     leg->SetBorderSize(1);
0256     leg->SetFillColor(10);
0257     leg->SetMargin(0.25);
0258     leg->SetTextSize(0.028);
0259 
0260     std::string xtit = "#eta";
0261     std::string ztit = "Eta";
0262     char ytit[40];
0263     if (plot == "radl") {
0264       sprintf(ytit, "#frac%s for MB (X_{0})", txt.c_str());
0265     } else if (plot == "step") {
0266       sprintf(ytit, "#frac%s for MB (Step Length)", txt.c_str());
0267     } else {
0268       plot = "intl";
0269       sprintf(ytit, "#frac%s for MB (#lambda)", txt.c_str());
0270     }
0271     if (!ifEta) {
0272       xtit = "#phi";
0273       ztit = "Phi";
0274     }
0275 
0276     std::vector<TGraphErrors *> graphs;
0277     std::vector<int> index;
0278     char hname[20], titlex[50];
0279     int nb(0);
0280     double xlow(0), xhigh(0);
0281     for (int i = 0; i < ngrp; ++i) {
0282       std::vector<double> xx0, yy1, yy2, dy1, dy2;
0283       for (int j = 0; j < nlayers[i]; ++j) {
0284         int ii = nflayer[i] + j;
0285         sprintf(hname, "%s%s%s", plot.c_str(), ztit.c_str(), names[ii].c_str());
0286         TProfile *prof1, *prof2;
0287         dir1->GetObject(hname, prof1);
0288         dir2->GetObject(hname, prof2);
0289         if ((prof1 != nullptr) && (prof2 != nullptr)) {
0290           int nb = prof1->GetNbinsX();
0291           for (int k = 1; k <= nb; ++k) {
0292             yy1.push_back(prof1->GetBinContent(k));
0293             yy2.push_back(prof2->GetBinContent(k));
0294             dy1.push_back(prof1->GetBinError(k));
0295             dy2.push_back(prof2->GetBinError(k));
0296             xx0.push_back(prof1->GetBinLowEdge(k) + prof1->GetBinWidth(k));
0297           }
0298         }
0299       }
0300       std::vector<double> xx, yy, dx, dy;
0301       int ii = nflayer[i];
0302       double sumNum(0), sumDen(0), maxtmp(0), maxDev(0), dmaxDev(0);
0303       for (unsigned int k = 0; k < xx0.size(); ++k) {
0304         if ((yy1[k] > 0) && (yy2[k] > 0)) {
0305           double rat = yy1[k] / yy2[k];
0306           double drt = rat * sqrt((dy1[k] / yy1[k]) * (dy1[k] / yy1[k]) + (dy2[k] / yy2[k]) * (dy2[k] / yy2[k]));
0307           xx.push_back(xx0[k]);
0308           dx.push_back(0);
0309           yy.push_back(rat);
0310           dy.push_back(drt);
0311           if (debug) {
0312             std::cout << title[ii] << " [" << (xx.size() - 1) << "] " << xx0[k] << " Ratio " << rat << " +- " << drt
0313                       << std::endl;
0314           }
0315           double temp1 = (rat > 1.0) ? 1.0 / rat : rat;
0316           double temp2 = (rat > 1.0) ? drt / (rat * rat) : drt;
0317           double temp0 = (fabs(1.0 - temp1) / (temp2 * temp2));
0318           sumNum += temp0;
0319           sumDen += (1.0 / (temp2 * temp2));
0320           if (temp0 >= maxtmp) {
0321             maxtmp = temp0;
0322             maxDev = fabs(1.0 - temp1);
0323             dmaxDev = temp2;
0324           }
0325         }
0326       }
0327       sumNum = (sumDen > 0) ? (sumNum / sumDen) : 0;
0328       sumDen = (sumDen > 0) ? 1.0 / sqrt(sumDen) : 0;
0329       std::cout << "Mean deviation for " << title[ii] << "  " << sumNum << " +- " << sumDen << " Max " << maxDev
0330                 << " +- " << dmaxDev << std::endl;
0331       if (xx.size() > 0) {
0332         TGraphErrors *graph = new TGraphErrors(xx.size(), &xx[0], &yy[0], &dx[0], &dy[0]);
0333         graph->SetLineColor(colorLay[ii]);
0334         graph->SetFillColor(colorLay[ii]);
0335         graph->SetMarkerStyle(styleLay[ii]);
0336         sprintf(titlex, "%s", title[ii].c_str());
0337         leg->AddEntry(graph, titlex, "lep");
0338         graphs.push_back(graph);
0339         if (nb == 0) {
0340           sprintf(hname, "%s%s%s", plot.c_str(), ztit.c_str(), names[0].c_str());
0341           TProfile *prof;
0342           dir1->GetObject(hname, prof);
0343           nb = prof->GetNbinsX();
0344           xlow = prof->GetBinLowEdge(1);
0345           xhigh = prof->GetBinLowEdge(nb) + prof->GetBinWidth(nb);
0346         }
0347       }
0348     }
0349     if (graphs.size() > 0) {
0350       std::string cname = "c_" + plot + ztit + "Ratio" + tag;
0351       TCanvas *cc1 = new TCanvas(cname.c_str(), cname.c_str(), 700, 600);
0352       cc1->SetLeftMargin(0.10);
0353       cc1->SetRightMargin(0.10);
0354       TH1F *vFrame = cc1->DrawFrame(xlow, 0.5, xhigh, 1.5);
0355       vFrame->GetXaxis()->SetRangeUser(xlow, xhigh);
0356       vFrame->GetXaxis()->SetLabelSize(0.03);
0357       vFrame->GetXaxis()->SetTitleSize(0.035);
0358       vFrame->GetXaxis()->SetTitleOffset(0.4);
0359       vFrame->GetXaxis()->SetTitle(xtit.c_str());
0360       vFrame->GetYaxis()->SetRangeUser(0.9, 1.1);
0361       vFrame->GetYaxis()->SetLabelSize(0.03);
0362       vFrame->GetYaxis()->SetTitleSize(0.035);
0363       vFrame->GetYaxis()->SetTitleOffset(1.3);
0364       vFrame->GetYaxis()->SetTitle(ytit);
0365       for (unsigned int i = 0; i < graphs.size(); ++i)
0366         graphs[i]->Draw("P");
0367       leg->Draw("sames");
0368       cc1->Modified();
0369     }
0370   }
0371 }
0372 
0373 void etaPhiPlotComp4(std::string filePreFix, std::string tag, std::string plot, bool ifEta, bool debug) {
0374   setStyle();
0375   gStyle->SetOptTitle(0);
0376   const int files = 4;
0377   std::string nametype[files] = {"dddXML", "dd4hepXML", "dddDB", "dd4hepDB"};
0378   int colortype[files] = {1, 2, 4, 6};
0379   TFile *file[files];
0380   char fname[40];
0381   bool ok(true);
0382   for (int k1 = 0; k1 < files; ++k1) {
0383     sprintf(fname, "%s%s%s.root", filePreFix.c_str(), nametype[k1].c_str(), tag.c_str());
0384     file[k1] = new TFile(fname);
0385     if (file[k1] == nullptr)
0386       ok = false;
0387   }
0388   if (ok) {
0389     TDirectory *dir[files];
0390     for (int k1 = 0; k1 < files; ++k1) {
0391       dir[k1] = (TDirectory *)(file[k1]->FindObjectAny("materialBudgetVolumeAnalysis"));
0392     }
0393     TLegend *leg = new TLegend(0.84, 0.69, 0.99, 0.99);
0394     leg->SetBorderSize(1);
0395     leg->SetFillColor(10);
0396     leg->SetMargin(0.25);
0397     leg->SetTextSize(0.028);
0398 
0399     std::string xtit = "#eta";
0400     std::string ztit = "Eta";
0401     std::string ytit = "none";
0402     if (plot == "radl") {
0403       ytit = "#frac{Sample}{dddXML} for MB (X_{0})";
0404     } else if (plot == "step") {
0405       ytit = "#frac{Sample}{dddXML} for MB (Step Length)";
0406     } else {
0407       plot = "intl";
0408       ytit = "#frac{Sample}{dddXML} for MB (#lambda)";
0409     }
0410     if (!ifEta) {
0411       xtit = "#phi";
0412       ztit = "Phi";
0413     }
0414 
0415     std::vector<TGraphErrors *> graphs;
0416     std::vector<int> index;
0417     char hname[20], titlex[50];
0418     int nb(0);
0419     double xlow(0), xhigh(0);
0420     for (int i = 0; i < ngrp; ++i) {
0421       std::vector<double> xx0, yy0[files], dy0[files];
0422       for (int j = 0; j < nlayers[i]; ++j) {
0423         int ii = nflayer[i] + j;
0424         sprintf(hname, "%s%s%s", plot.c_str(), ztit.c_str(), names[ii].c_str());
0425         TProfile *prof[files];
0426         bool okf(true);
0427         for (int k1 = 0; k1 < files; ++k1) {
0428           dir[k1]->GetObject(hname, prof[k1]);
0429           if (dir[k1] == nullptr)
0430             okf = false;
0431         }
0432         if (okf) {
0433           int nb = prof[0]->GetNbinsX();
0434           for (int k = 1; k <= nb; ++k) {
0435             xx0.push_back(prof[0]->GetBinLowEdge(k) + prof[0]->GetBinWidth(k));
0436             for (int k1 = 0; k1 < files; ++k1) {
0437               yy0[k1].push_back(prof[k1]->GetBinContent(k));
0438               dy0[k1].push_back(prof[k1]->GetBinError(k));
0439             }
0440           }
0441         }
0442       }
0443       int ii = nflayer[i];
0444       for (int k1 = 1; k1 < files; ++k1) {
0445         std::vector<double> xx, yy, dx, dy;
0446         double sumNum(0), sumDen(0), maxtmp(0), maxDev(0), dmaxDev(0);
0447         for (unsigned int k = 0; k < xx0.size(); ++k) {
0448           if ((yy0[0][k] > 0) && (yy0[k1][k] > 0)) {
0449             double rat = yy0[k1][k] / yy0[0][k];
0450             double drt = rat * sqrt((dy0[k1][k] / yy0[k1][k]) * (dy0[k1][k] / yy0[k1][k]) +
0451                                     (dy0[0][k] / yy0[0][k]) * (dy0[0][k] / yy0[0][k]));
0452             xx.push_back(xx0[k]);
0453             dx.push_back(0);
0454             yy.push_back(rat);
0455             dy.push_back(drt);
0456             if (debug) {
0457               std::cout << nametype[k1] << ":" << title[ii] << " [" << (xx.size() - 1) << "] " << xx0[k] << " Ratio "
0458                         << rat << " +- " << drt << std::endl;
0459             }
0460             double temp1 = (rat > 1.0) ? 1.0 / rat : rat;
0461             double temp2 = (rat > 1.0) ? drt / (rat * rat) : drt;
0462             double temp0 = (fabs(1.0 - temp1) / (temp2 * temp2));
0463             sumNum += temp0;
0464             sumDen += (1.0 / (temp2 * temp2));
0465             if (temp0 >= maxtmp) {
0466               maxtmp = temp0;
0467               maxDev = fabs(1.0 - temp1);
0468               dmaxDev = temp2;
0469             }
0470           }
0471         }
0472         sumNum = (sumDen > 0) ? (sumNum / sumDen) : 0;
0473         sumDen = (sumDen > 0) ? 1.0 / sqrt(sumDen) : 0;
0474         std::cout << title[ii] << " in " << nametype[k1] << " Mean " << sumNum << " +- " << sumDen << " Max " << maxDev
0475                   << " +- " << dmaxDev << std::endl;
0476         if (xx.size() > 0) {
0477           TGraphErrors *graph = new TGraphErrors(xx.size(), &xx[0], &yy[0], &dx[0], &dy[0]);
0478           graph->SetLineColor(colortype[k1]);
0479           graph->SetFillColor(colorLay[ii]);
0480           graph->SetMarkerStyle(styleLay[ii]);
0481           if (k1 == 1) {
0482             sprintf(titlex, "%s", title[ii].c_str());
0483             leg->AddEntry(graph, titlex, "lep");
0484           }
0485           graphs.push_back(graph);
0486           if (nb == 0) {
0487             sprintf(hname, "%s%s%s", plot.c_str(), ztit.c_str(), names[0].c_str());
0488             TProfile *prof;
0489             dir[0]->GetObject(hname, prof);
0490             nb = prof->GetNbinsX();
0491             xlow = prof->GetBinLowEdge(1);
0492             xhigh = prof->GetBinLowEdge(nb) + prof->GetBinWidth(nb);
0493           }
0494         }
0495       }
0496     }
0497     if (graphs.size() > 0) {
0498       std::string cname = "c_" + plot + ztit + "Ratio" + tag;
0499       TCanvas *cc1 = new TCanvas(cname.c_str(), cname.c_str(), 700, 600);
0500       cc1->SetLeftMargin(0.10);
0501       cc1->SetRightMargin(0.10);
0502       TH1F *vFrame = cc1->DrawFrame(xlow, 0.5, xhigh, 1.5);
0503       vFrame->GetXaxis()->SetRangeUser(xlow, xhigh);
0504       vFrame->GetXaxis()->SetLabelSize(0.03);
0505       vFrame->GetXaxis()->SetTitleSize(0.035);
0506       vFrame->GetXaxis()->SetTitleOffset(0.4);
0507       vFrame->GetXaxis()->SetTitle(xtit.c_str());
0508       vFrame->GetYaxis()->SetRangeUser(0.9, 1.1);
0509       vFrame->GetYaxis()->SetLabelSize(0.03);
0510       vFrame->GetYaxis()->SetTitleSize(0.035);
0511       vFrame->GetYaxis()->SetTitleOffset(1.3);
0512       vFrame->GetYaxis()->SetTitle(ytit.c_str());
0513       for (unsigned int i = 0; i < graphs.size(); ++i)
0514         graphs[i]->Draw("P");
0515       leg->Draw("sames");
0516       cc1->Modified();
0517       double ymx = 0.68;
0518       for (int k1 = 1; k1 < files; ++k1) {
0519         TPaveText *txt1 = new TPaveText(0.84, ymx - 0.03, 0.99, ymx, "blNDC");
0520         txt1->SetFillColor(0);
0521         sprintf(fname, "%s", nametype[k1].c_str());
0522         txt1->AddText(fname);
0523         ((TText *)txt1->GetListOfLines()->Last())->SetTextColor(colortype[k1]);
0524         txt1->Draw();
0525         ymx -= 0.03;
0526       }
0527     }
0528   }
0529 }
0530 
0531 void setStyle() {
0532   gStyle->SetCanvasBorderMode(0);
0533   gStyle->SetCanvasColor(kWhite);
0534   gStyle->SetPadColor(kWhite);
0535   gStyle->SetFrameBorderMode(0);
0536   gStyle->SetFrameBorderSize(1);
0537   gStyle->SetFrameFillColor(0);
0538   gStyle->SetFrameFillStyle(0);
0539   gStyle->SetFrameLineColor(1);
0540   gStyle->SetFrameLineStyle(1);
0541   gStyle->SetFrameLineWidth(1);
0542   gStyle->SetOptStat(0);
0543   gStyle->SetLegendBorderSize(1);
0544   gStyle->SetTitleColor(0);
0545   gStyle->SetTitleOffset(2.5, "Y");
0546 }