Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:14

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