Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:38:15

0001 //###########################################################################
0002 //
0003 //   void noseRecHitPlots(fname, dirnm, tag, save)
0004 //        Plots histograms created by recHitStudy for the Nose detector
0005 //   void hgcalStudyPlots(fname, type, tag, dtype, save, debug)
0006 //        Plots histograms created by SimHit/Digi/RecHit Study for HGCal
0007 //   void hgcalGeomCheckPlots(fname, tag, dtype, save, debug)
0008 //        Plots histograms created by HGCGeometryCheck
0009 //   void hgcalBHValidPlots(fname, tag, dtype, save, debug)
0010 //        Plots histograms created by HGCalBHValidation
0011 //   void hgcalSiliconAnalysisPlots(fname, tag, dtype, save, debug)
0012 //        Plots histograms created by HGCalSiliconValidation
0013 //   void hgcalMissedHitPlots(fname, tag, dtype, save, debug)
0014 //        Plots histograms created by HGCalMissedRecHit
0015 //   void ehcalPlots(fname, dirnm, tag, dets, save, debug)
0016 //        Plots histograms created by EcalSimHitStudy
0017 //
0018 //   where
0019 //     fanme     (std::string)  Input ROOT file name
0020 //                              ("hfnRecHitD115tt.root" for noseRecHitPlots,
0021 //                               "roots/hgcSimHitD95tt.root" hgcalStudyPlots,
0022 //                               "roots/hgcGeomCheckD95.root" hgcalGeomCheck,
0023 //                               "roots/hgcBHValidD95.root" hgcalBHValid,
0024 //                               "roots/hgcSilValidD100.root" hgcalSiliconAnalysis,
0025 //                               "missedRecHitD105.root" hgcalMissedHitPlots,
0026 //                               "ecalHitdd4hep.root" ehcalPlot)
0027 //     dirnm     (std::string)  Directory name
0028 //                              ("hfnoseRecHitStudy" for noseRecHitPlots
0029 //                               "hgcGeomCheck" for hgcalGeomCheck,
0030 //                               "hgcalBHAnalysis" for hgcalBHValid,
0031 //                               "hgcMissingRecHit" for hgcalMissedHitPlots,
0032 //                               "EcalSimHitStudy" for ehcalPlot)
0033 //     type      (int)          Type: 0 SimHit; 1 Digi; 2 RecHit (0)
0034 //     tag       (std::string)  Name of the tag for the canvas name
0035 //                              ("HFNose" for noseRecHitPlots,
0036 //                               "SimHitD95" for hgcalStudyPlots,
0037 //                               "GeomChkD95" for hgcalGeomCheck,
0038 //                               "BHValidD95" for hgcalBHValid,
0039 //                               "SilValidD100" for hgcalSiliconAnalysisPlots,
0040 //                               "MissedHitD105" for hgcalMissedHitPlots,
0041 //                               "DD4Hep" for ehcalPlots)
0042 //     dtype     (std::string)  Data type added for canvas name
0043 //                              ("ttbar D95" for hgcalStudyPlots,
0044 //                               "#mu D95" for hgcalGeomCheck, hgcalBHValid',
0045 //                               "ttbar D100" for hgcalSiliconAnalysisPlots,
0046 //                               "#mu D105" for hgcalMissedHitPlots)
0047 //     save      (bool)         Flag to save the canvas (false)
0048 //     debug     (bool)         Debug flag (false)
0049 //
0050 //   In addition there is a tree analysis class to study the ROOT tree
0051 //   created by HGCHitAnalysis code. To invoke this, one needs to do
0052 //   the following steps:
0053 //   .L MakePlots.C+g
0054 //   hgchits c1(fname);
0055 //   c1.Loop();
0056 //   c1.saveHistos(outFile);
0057 //
0058 //###########################################################################
0059 //
0060 #include <TROOT.h>
0061 #include <TChain.h>
0062 #include <TFile.h>
0063 #include <TH1D.h>
0064 #include <TH2D.h>
0065 #include <TProfile.h>
0066 #include <TFitResult.h>
0067 #include <TFitResultPtr.h>
0068 #include <TStyle.h>
0069 #include <TCanvas.h>
0070 #include <TLegend.h>
0071 #include <TPaveStats.h>
0072 #include <TPaveText.h>
0073 #include <vector>
0074 #include <string>
0075 #include <iomanip>
0076 #include <iostream>
0077 #include <fstream>
0078 
0079 void noseRecHitPlots(std::string fname = "hfnRecHitD115tt.root",
0080                      std::string dirnm = "hfnoseRecHitStudy",
0081                      std::string tag = "HFNose",
0082                      bool save = false) {
0083   int nums[2] = {5, 2};
0084   int layers(8);
0085   std::string name1[5] = {
0086       "Energy_Layer", "HitOccupancy_Minus_layer", "HitOccupaancy_Plus_layer", "EtaPhi_Minus_Layer", "EtaPhi_Plus_Layer"};
0087   std::string name2[2] = {"EtaPhi", "RZ"};
0088   std::string detName = "HGCalHFNoseSensitive";
0089   int type1[5] = {1, 1, 1, 2, 2};
0090   int rebin[5] = {10, 1, 1, 1, 1};
0091   int type2[2] = {2, 2};
0092   std::string xtitl1[5] = {"Energy (GeV)", "Hits", "Hits", "#eta", "#eta"};
0093   std::string ytitl1[5] = {" ", " ", " ", "#phi", "#phi"};
0094   std::string xtitl2[2] = {"#eta", "z (cm)"};
0095   std::string ytitl2[2] = {"#phi", "R (cm)"};
0096 
0097   gStyle->SetCanvasBorderMode(0);
0098   gStyle->SetCanvasColor(kWhite);
0099   gStyle->SetPadColor(kWhite);
0100   gStyle->SetFillColor(kWhite);
0101   gStyle->SetOptStat(111110);
0102   TFile *file = new TFile(fname.c_str());
0103   if (file) {
0104     TDirectory *dir = (TDirectory *)file->FindObjectAny(dirnm.c_str());
0105     char name[100], title[100];
0106     for (int i1 = 0; i1 < 2; ++i1) {
0107       int kk = (i1 == 0) ? layers : 1;
0108       for (int i2 = 0; i2 < nums[i1]; ++i2) {
0109         for (int k = 0; k < kk; ++k) {
0110           int type(0);
0111           if (i1 == 0) {
0112             sprintf(name, "%s_%d", name1[i2].c_str(), k + 1);
0113             sprintf(title, "%s (Layer %d)", tag.c_str(), k + 1);
0114             type = type1[i2];
0115           } else {
0116             sprintf(name, "%s_%s", name2[i2].c_str(), detName.c_str());
0117             sprintf(title, "Simulation of %s", tag.c_str());
0118             type = type2[i2];
0119           }
0120           TH1D *hist1(nullptr);
0121           TH2D *hist2(nullptr);
0122           if (type == 1)
0123             hist1 = (TH1D *)dir->FindObjectAny(name);
0124           else
0125             hist2 = (TH2D *)dir->FindObjectAny(name);
0126           if ((hist1 != nullptr) || (hist2 != nullptr)) {
0127             TCanvas *pad = new TCanvas(name, name, 500, 500);
0128             pad->SetRightMargin(0.10);
0129             pad->SetTopMargin(0.10);
0130             if (type == 1) {
0131               if (i1 == 0) {
0132                 hist1->GetYaxis()->SetTitle(ytitl1[i2].c_str());
0133                 hist1->GetXaxis()->SetTitle(xtitl1[i2].c_str());
0134                 hist1->Rebin(rebin[i2]);
0135               } else {
0136                 hist1->GetYaxis()->SetTitle(ytitl2[i2].c_str());
0137                 hist1->GetXaxis()->SetTitle(xtitl2[i2].c_str());
0138               }
0139               hist1->SetTitle(title);
0140               hist1->GetYaxis()->SetTitleOffset(1.2);
0141               pad->SetLogy();
0142               hist1->Draw();
0143             } else {
0144               if (i1 == 0) {
0145                 hist2->GetYaxis()->SetTitle(ytitl1[i2].c_str());
0146                 hist2->GetXaxis()->SetTitle(xtitl1[i2].c_str());
0147               } else {
0148                 hist2->GetYaxis()->SetTitle(ytitl2[i2].c_str());
0149                 hist2->GetXaxis()->SetTitle(xtitl2[i2].c_str());
0150               }
0151               hist2->GetYaxis()->SetTitleOffset(1.2);
0152               hist2->SetMarkerStyle(20);
0153               hist2->SetMarkerSize(0.1);
0154               hist2->SetTitle(title);
0155               hist2->Draw();
0156             }
0157             pad->Update();
0158             TPaveStats *st1 = ((hist1 != nullptr) ? ((TPaveStats *)hist1->GetListOfFunctions()->FindObject("stats"))
0159                                                   : ((TPaveStats *)hist2->GetListOfFunctions()->FindObject("stats")));
0160             if (st1 != NULL) {
0161               st1->SetY1NDC(0.70);
0162               st1->SetY2NDC(0.90);
0163               st1->SetX1NDC(0.65);
0164               st1->SetX2NDC(0.90);
0165             }
0166             pad->Modified();
0167             pad->Update();
0168             if (save) {
0169               sprintf(name, "c_%s%s.jpg", tag.c_str(), pad->GetName());
0170               pad->Print(name);
0171             }
0172           }
0173         }
0174       }
0175     }
0176   }
0177 }
0178 
0179 void hgcalStudyPlots(std::string fname = "roots/hgcSimHitD95tt.root",
0180                      int type = 0,
0181                      std::string tag = "SimHitD95",
0182                      std::string dtype = "ttbar D95",
0183                      bool save = false,
0184                      bool debug = false) {
0185   int ndir[3] = {1, 3, 3};
0186   std::string dirnm[3][3] = {{"hgcalSimHitStudy", "", ""},
0187                              {"hgcalDigiStudyEE", "hgcalDigiStudyHEF", "hgcalDigiStudyHEB"},
0188                              {"hgcalRecHitStudyEE", "hgcalRecHitStudyFH", "hgcalRecHitStudyBH"}};
0189   std::string name0[4] = {"HGCal EE", "HGCal HE Silicon", "HGCal HE Scintillator", "HGCal"};
0190   int nname[3] = {4, 1, 1};
0191   std::string name1[4] = {
0192       "HGCalEESensitive", "HGCalHESiliconSensitive", "HGCalHEScintillatorSensitive", "AllDetectors"};
0193   int nhist[3] = {4, 2, 2};
0194   int nhtype[3][4] = {{1, 1, 2, 2}, {1, 2, 0, 0}, {2, 2, 0, 0}};
0195   int yax[3][4] = {{1, 1, 0, 0}, {1, 0, 0, 0}, {0, 0, 0, 0}};
0196   std::string name2[3][4] = {
0197       {"E_", "T_", "RZ_", "EtaPhi_"}, {"Charge_", "RZ_", " ", " "}, {"RZ_", "EtaPhi_", " ", " "}};
0198   std::string xtitl[3][4] = {
0199       {"Energy (GeV)", "Time (ns)", "Z (mm)", "#phi"}, {"Charge", "Z (cm)", " ", " "}, {"Z (cm)", "#phi", " ", " "}};
0200   std::string ytitl[3][4] = {
0201       {"Hits", "Hits", "R (mm)", "#eta"}, {"Hits", "R (cm)", " ", " "}, {"R (cm)", "#eta", " ", " "}};
0202   double xmax[3][4] = {{0.2, 20.0, -1, -1}, {25.0, -1, -1, -1}, {-1, -1, -1, -1}};
0203 
0204   gStyle->SetCanvasBorderMode(0);
0205   gStyle->SetCanvasColor(kWhite);
0206   gStyle->SetPadColor(kWhite);
0207   gStyle->SetFillColor(kWhite);
0208   gStyle->SetOptStat(111110);
0209   if (debug)
0210     std::cout << "File " << fname << " Type " << type << ":" << name0[type] << " Tags " << tag << " : " << dtype
0211               << " Save " << save << "\n";
0212   TFile *file = new TFile(fname.c_str());
0213   if (file) {
0214     for (int it = 0; it < ndir[type]; ++it) {
0215       char dirx[100];
0216       sprintf(dirx, "%s", dirnm[type][it].c_str());
0217       TDirectory *dir = (TDirectory *)file->FindObjectAny(dirx);
0218       if (debug)
0219         std::cout << "Directory " << dirx << " : " << dir << std::endl;
0220       if (dir) {
0221         for (int in = 0; in < nname[type]; ++in) {
0222           for (int ih = 0; ih < nhist[type]; ++ih) {
0223             char hname[100];
0224             if (type == 0) {
0225               sprintf(hname, "%s%s", name2[type][ih].c_str(), name1[in].c_str());
0226             } else {
0227               sprintf(hname, "%s%s", name2[type][ih].c_str(), name1[it].c_str());
0228             }
0229             TH1D *hist1(nullptr);
0230             TH2D *hist2(nullptr);
0231             if (nhtype[type][ih] == 1)
0232               hist1 = (TH1D *)dir->FindObjectAny(hname);
0233             else
0234               hist2 = (TH2D *)dir->FindObjectAny(hname);
0235             if (debug)
0236               std::cout << "Hist " << hname << " : " << hist1 << " : " << hist2 << " Xtitle " << xtitl[type][ih]
0237                         << " Ytitle " << ytitl[type][ih] << " xmax " << xmax[type][ih] << " Type " << nhtype[type][ih]
0238                         << " yscale " << yax[type][ih] << std::endl;
0239             if ((hist1 != nullptr) || (hist2 != nullptr)) {
0240               char name[100], title[100];
0241               sprintf(name, "%s%s", hname, tag.c_str());
0242               TCanvas *pad = new TCanvas(name, name, 500, 500);
0243               pad->SetRightMargin(0.10);
0244               pad->SetTopMargin(0.10);
0245               if (type == 0)
0246                 sprintf(title, "%s (%s)", name0[in].c_str(), dtype.c_str());
0247               else
0248                 sprintf(title, "%s (%s)", name0[it].c_str(), dtype.c_str());
0249               if (debug)
0250                 std::cout << "Pad " << name << " : " << pad << "\n";
0251               if (nhtype[type][ih] == 1) {
0252                 hist1->GetYaxis()->SetTitle(ytitl[type][ih].c_str());
0253                 hist1->GetXaxis()->SetTitle(xtitl[type][ih].c_str());
0254                 if (xmax[type][ih] > 0)
0255                   hist1->GetXaxis()->SetRangeUser(0, xmax[type][ih]);
0256                 if (yax[type][ih] > 0)
0257                   pad->SetLogy();
0258                 hist1->SetTitle(title);
0259                 hist1->GetYaxis()->SetTitleOffset(1.2);
0260                 hist1->Draw();
0261               } else {
0262                 hist2->GetYaxis()->SetTitle(ytitl[type][ih].c_str());
0263                 hist2->GetXaxis()->SetTitle(xtitl[type][ih].c_str());
0264                 hist2->GetYaxis()->SetTitleOffset(1.2);
0265                 hist2->SetMarkerStyle(20);
0266                 hist2->SetMarkerSize(0.1);
0267                 hist2->SetTitle(title);
0268                 hist2->Draw();
0269               }
0270               pad->Update();
0271               TPaveStats *st1 = ((hist1 != nullptr) ? ((TPaveStats *)hist1->GetListOfFunctions()->FindObject("stats"))
0272                                                     : ((TPaveStats *)hist2->GetListOfFunctions()->FindObject("stats")));
0273               if (st1 != NULL) {
0274                 st1->SetY1NDC(0.70);
0275                 st1->SetY2NDC(0.90);
0276                 st1->SetX1NDC(0.65);
0277                 st1->SetX2NDC(0.90);
0278               }
0279               pad->Modified();
0280               pad->Update();
0281               if (save) {
0282                 sprintf(name, "c_%s.jpg", pad->GetName());
0283                 pad->Print(name);
0284               }
0285             }
0286           }
0287         }
0288       }
0289     }
0290   }
0291 }
0292 
0293 void hgcalGeomCheckPlots(std::string fname = "roots/hgcGeomCheckD95.root",
0294                          std::string tag = "GeomChkD95",
0295                          std::string dtype = "#mu D95",
0296                          bool statbox = true,
0297                          bool save = false,
0298                          bool debug = false) {
0299   std::string dirnm = "hgcGeomCheck";
0300   std::string name0[3] = {"HGCal EE", "HGCal HE Silicon", "HGCal HE Scintillator"};
0301   int nhist = 3;
0302   int nhtype = 3;
0303   std::string name2[9] = {"heerVsLayer",
0304                           "heezVsLayer",
0305                           "heedzVsZ",
0306                           "hefrVsLayer",
0307                           "hefzVsLayer",
0308                           "hefdzVsZ",
0309                           "hebrVsLayer",
0310                           "hebzVsLayer",
0311                           "hebdzVsZ"};
0312   std::string xtitl[9] = {"Layer", "Layer", "Z (cm)", "Layer", "Layer", "Z (cm)", "Layer", "Layer", "Z (cm)"};
0313   std::string ytitl[9] = {
0314       "R (cm)", "Z (cm)", "#Delta Z (cm)", "R (cm)", "Z (cm)", "#Delta Z (cm)", "R (cm)", "Z (cm)", "#Delta Z (cm)"};
0315 
0316   gStyle->SetCanvasBorderMode(0);
0317   gStyle->SetCanvasColor(kWhite);
0318   gStyle->SetPadColor(kWhite);
0319   gStyle->SetFillColor(kWhite);
0320   if (statbox)
0321     gStyle->SetOptStat(111110);
0322   else
0323     gStyle->SetOptStat(0);
0324   if (debug)
0325     std::cout << "File " << fname << " Tags " << tag << " : " << dtype << " Save " << save << "\n";
0326   TFile *file = new TFile(fname.c_str());
0327   if (file) {
0328     char dirx[100];
0329     sprintf(dirx, "%s", dirnm.c_str());
0330     TDirectory *dir = (TDirectory *)file->FindObjectAny(dirx);
0331     if (debug)
0332       std::cout << "Directory " << dirx << " : " << dir << std::endl;
0333     if (dir) {
0334       for (int in = 0; in < nhtype; ++in) {
0335         for (int ih = 0; ih < nhist; ++ih) {
0336           char hname[100];
0337           int inh = in * nhist + ih;
0338           sprintf(hname, "%s", name2[inh].c_str());
0339           TH2D *hist = (TH2D *)dir->FindObjectAny(hname);
0340           if (debug)
0341             std::cout << "Hist " << hname << " : " << hist << " Xtitle " << xtitl[inh] << " Ytitle " << ytitl[inh]
0342                       << std::endl;
0343           if (hist != nullptr) {
0344             char name[100], title[100];
0345             sprintf(name, "%s%s", hname, tag.c_str());
0346             TCanvas *pad = new TCanvas(name, name, 500, 500);
0347             pad->SetRightMargin(0.10);
0348             pad->SetTopMargin(0.10);
0349             sprintf(title, "%s (%s)", name0[in].c_str(), dtype.c_str());
0350             if (debug)
0351               std::cout << "Pad " << name << " : " << pad << "\n";
0352             hist->GetYaxis()->SetTitle(ytitl[inh].c_str());
0353             hist->GetXaxis()->SetTitle(xtitl[inh].c_str());
0354             hist->SetTitle(title);
0355             hist->GetYaxis()->SetTitleOffset(1.2);
0356             hist->Draw();
0357             pad->Update();
0358             TPaveStats *st1 = (TPaveStats *)hist->GetListOfFunctions()->FindObject("stats");
0359             if (st1 != NULL) {
0360               st1->SetY1NDC(0.70);
0361               st1->SetY2NDC(0.90);
0362               st1->SetX1NDC(0.65);
0363               st1->SetX2NDC(0.90);
0364             }
0365             pad->Modified();
0366             pad->Update();
0367             if (save) {
0368               sprintf(name, "c_%s.jpg", pad->GetName());
0369               pad->Print(name);
0370             }
0371           }
0372         }
0373       }
0374     }
0375   }
0376 }
0377 
0378 void hgcalBHValidPlots(std::string fname = "roots/hgcBHValidD95.root",
0379                        std::string tag = "BHValidD95",
0380                        std::string dtype = "#mu D95",
0381                        bool save = false,
0382                        bool debug = false) {
0383   std::string dirnm = "hgcalBHAnalysis";
0384   std::string name0 = "HGCal HE Scintillator";
0385   int nhist = 9;
0386   std::string name2[9] = {"SimHitEn1",
0387                           "SimHitEn2",
0388                           "SimHitLong",
0389                           "SimHitOccup",
0390                           "SimHitOccu3",
0391                           "SimHitTime",
0392                           "DigiLong",
0393                           "DigiOccup",
0394                           "DigiOccu3"};
0395   std::string xtitl[9] = {"SimHit Energy (GeV)",
0396                           "SimHit Energy (GeV)",
0397                           "SimHit Layer #",
0398                           "SimHit i#eta",
0399                           "SimHit i#eta",
0400                           "Digi Layer #",
0401                           "Digi i#eta",
0402                           "Digi i#eta"};
0403   std::string ytitl[9] = {"Hits", "Hits", "Energy Sum (GeV)", "i#phi", "Layer #", "Digi Sum", "i#phi", "Layer #"};
0404   double xmax[9] = {0.05, 0.20, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0};
0405   int ihty[9] = {1, 1, 1, 2, 2, 1, 1, 2, 2};
0406   int iaxty[9] = {1, 1, 0, 0, 0, 1, 0, 0, 0};
0407   int ibin[10] = {0, 0, 0, 0, 0, 10, 0, 0, 0};
0408   gStyle->SetCanvasBorderMode(0);
0409   gStyle->SetCanvasColor(kWhite);
0410   gStyle->SetPadColor(kWhite);
0411   gStyle->SetFillColor(kWhite);
0412   gStyle->SetOptStat(111110);
0413   if (debug)
0414     std::cout << "File " << fname << " Tags " << tag << " : " << dtype << " Save " << save << "\n";
0415   TFile *file = new TFile(fname.c_str());
0416   if (file) {
0417     char dirx[100];
0418     sprintf(dirx, "%s", dirnm.c_str());
0419     TDirectory *dir = (TDirectory *)file->FindObjectAny(dirx);
0420     if (debug)
0421       std::cout << "Directory " << dirx << " : " << dir << std::endl;
0422     if (dir) {
0423       for (int ih = 0; ih < nhist; ++ih) {
0424         char hname[100];
0425         sprintf(hname, "%s", name2[ih].c_str());
0426         TH1D *hist1(nullptr);
0427         TH2D *hist2(nullptr);
0428         if (ihty[ih] <= 1)
0429           hist1 = (TH1D *)dir->FindObjectAny(hname);
0430         else
0431           hist2 = (TH2D *)dir->FindObjectAny(hname);
0432         if (debug)
0433           std::cout << "Hist " << hname << " : " << hist1 << ":" << hist2 << " Xtitle " << xtitl[ih] << " Ytitle "
0434                     << ytitl[ih] << " xmax " << xmax[ih] << " iaxty " << iaxty[ih] << " ibin " << ibin[ih] << std::endl;
0435         if ((hist1 != nullptr) || (hist2 != nullptr)) {
0436           char name[100], title[100];
0437           sprintf(name, "%s%s", hname, tag.c_str());
0438           TCanvas *pad = new TCanvas(name, name, 500, 500);
0439           pad->SetRightMargin(0.10);
0440           pad->SetTopMargin(0.10);
0441           sprintf(title, "%s (%s)", name0.c_str(), dtype.c_str());
0442           if (debug)
0443             std::cout << "Pad " << name << " : " << pad << "\n";
0444           if (hist1 != nullptr) {
0445             hist1->GetYaxis()->SetTitle(ytitl[ih].c_str());
0446             hist1->GetXaxis()->SetTitle(xtitl[ih].c_str());
0447             hist1->SetTitle(title);
0448             if (xmax[ih] > 0)
0449               hist1->GetXaxis()->SetRangeUser(0, xmax[ih]);
0450             if (iaxty[ih] > 0)
0451               pad->SetLogy();
0452             if (ibin[ih] > 0)
0453               hist1->Rebin(ibin[ih]);
0454             hist1->GetYaxis()->SetTitleOffset(1.2);
0455             hist1->Draw();
0456           } else {
0457             hist2->GetYaxis()->SetTitle(ytitl[ih].c_str());
0458             hist2->GetXaxis()->SetTitle(xtitl[ih].c_str());
0459             hist2->SetTitle(title);
0460             hist2->GetYaxis()->SetTitleOffset(1.2);
0461             hist2->Draw();
0462           }
0463           pad->Update();
0464           TPaveStats *st1 = ((hist1 != nullptr) ? ((TPaveStats *)hist1->GetListOfFunctions()->FindObject("stats"))
0465                                                 : ((TPaveStats *)hist2->GetListOfFunctions()->FindObject("stats")));
0466           if (st1 != NULL) {
0467             st1->SetY1NDC(0.70);
0468             st1->SetY2NDC(0.90);
0469             st1->SetX1NDC(0.65);
0470             st1->SetX2NDC(0.90);
0471           }
0472           pad->Modified();
0473           pad->Update();
0474           if (save) {
0475             sprintf(name, "c_%s.jpg", pad->GetName());
0476             pad->Print(name);
0477           }
0478         }
0479       }
0480     }
0481   }
0482 }
0483 
0484 void hgcalSiliconAnalysisPlots(std::string fname = "roots/hgcSilValidD100.root",
0485                                std::string tag = "SilValidD100",
0486                                std::string dtype = "ttbar D100",
0487                                bool save = false,
0488                                bool debug = false) {
0489   std::string dirnm[2] = {"hgcalSiliconAnalysisEE", "hgcalSiliconAnalysisHEF"};
0490   std::string name0[2] = {"HGCal EE", "HGCal HE Silicon"};
0491   int nhist = 9;
0492   std::string name2[9] = {"SimHitEn1",
0493                           "SimHitEn2",
0494                           "SimHitLong",
0495                           "SimHitOccup",
0496                           "SimHitOccu2",
0497                           "SimHitTime",
0498                           "DigiLong",
0499                           "DigiOccup",
0500                           "DigiOccu2"};
0501   std::string xtitl[9] = {"SimHit Energy (GeV)",
0502                           "SimHit Energy (GeV)",
0503                           "SimHit Layer #",
0504                           "SimHit i#eta",
0505                           "SimHit i#eta",
0506                           "Digi Layer #",
0507                           "Digi i#eta",
0508                           "Digi i#eta"};
0509   std::string ytitl[9] = {"Hits", "Hits", "Energy Sum (GeV)", "i#phi", "Layer #", "Digi Sum", "i#phi", "Layer #"};
0510   double xmax[9] = {0.05, 0.20, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0};
0511   int ihty[9] = {1, 1, 1, 2, 2, 1, 1, 2, 2};
0512   int iaxty[9] = {1, 1, 0, 0, 0, 1, 0, 0, 0};
0513   int ibin[10] = {0, 0, 0, 0, 0, 10, 0, 0, 0};
0514   gStyle->SetCanvasBorderMode(0);
0515   gStyle->SetCanvasColor(kWhite);
0516   gStyle->SetPadColor(kWhite);
0517   gStyle->SetFillColor(kWhite);
0518   gStyle->SetOptStat(111110);
0519   if (debug)
0520     std::cout << "File " << fname << " Tags " << tag << " : " << dtype << " Save " << save << "\n";
0521   TFile *file = new TFile(fname.c_str());
0522   if (file) {
0523     for (int idir = 0; idir < 2; ++idir) {
0524       char dirx[100];
0525       sprintf(dirx, "%s", dirnm[idir].c_str());
0526       TDirectory *dir = (TDirectory *)file->FindObjectAny(dirx);
0527       if (debug)
0528         std::cout << "Directory " << dirx << " : " << dir << std::endl;
0529       if (dir) {
0530         for (int ih = 0; ih < nhist; ++ih) {
0531           char hname[100];
0532           sprintf(hname, "%s", name2[ih].c_str());
0533           TH1D *hist1(nullptr);
0534           TH2D *hist2(nullptr);
0535           if (ihty[ih] <= 1)
0536             hist1 = (TH1D *)dir->FindObjectAny(hname);
0537           else
0538             hist2 = (TH2D *)dir->FindObjectAny(hname);
0539           if (debug)
0540             std::cout << "Hist " << hname << " : " << hist1 << ":" << hist2 << " Xtitle " << xtitl[ih] << " Ytitle "
0541                       << ytitl[ih] << " xmax " << xmax[ih] << " iaxty " << iaxty[ih] << " ibin " << ibin[ih]
0542                       << std::endl;
0543           if ((hist1 != nullptr) || (hist2 != nullptr)) {
0544             char name[100], title[100];
0545             sprintf(name, "%s%s", hname, tag.c_str());
0546             TCanvas *pad = new TCanvas(name, name, 500, 500);
0547             pad->SetRightMargin(0.10);
0548             pad->SetTopMargin(0.10);
0549             sprintf(title, "%s (%s)", name0[idir].c_str(), dtype.c_str());
0550             if (debug)
0551               std::cout << "Pad " << name << " : " << pad << "\n";
0552             if (hist1 != nullptr) {
0553               hist1->GetYaxis()->SetTitle(ytitl[ih].c_str());
0554               hist1->GetXaxis()->SetTitle(xtitl[ih].c_str());
0555               hist1->SetTitle(title);
0556               if (xmax[ih] > 0)
0557                 hist1->GetXaxis()->SetRangeUser(0, xmax[ih]);
0558               if (iaxty[ih] > 0)
0559                 pad->SetLogy();
0560               if (ibin[ih] > 0)
0561                 hist1->Rebin(ibin[ih]);
0562               hist1->GetYaxis()->SetTitleOffset(1.2);
0563               hist1->Draw();
0564             } else {
0565               hist2->GetYaxis()->SetTitle(ytitl[ih].c_str());
0566               hist2->GetXaxis()->SetTitle(xtitl[ih].c_str());
0567               hist2->SetTitle(title);
0568               hist2->GetYaxis()->SetTitleOffset(1.2);
0569               hist2->Draw();
0570             }
0571             pad->Update();
0572             TPaveStats *st1 = ((hist1 != nullptr) ? ((TPaveStats *)hist1->GetListOfFunctions()->FindObject("stats"))
0573                                                   : ((TPaveStats *)hist2->GetListOfFunctions()->FindObject("stats")));
0574             if (st1 != NULL) {
0575               st1->SetY1NDC(0.70);
0576               st1->SetY2NDC(0.90);
0577               st1->SetX1NDC(0.65);
0578               st1->SetX2NDC(0.90);
0579             }
0580             pad->Modified();
0581             pad->Update();
0582             if (save) {
0583               sprintf(name, "c_%s.jpg", pad->GetName());
0584               pad->Print(name);
0585             }
0586           }
0587         }
0588       }
0589     }
0590   }
0591 }
0592 
0593 void hgcalMissedHitPlots(std::string fname = "missedRecHitD105.root",
0594                          std::string tag = "MissedHitD105",
0595                          std::string dtype = "#mu D105",
0596                          bool save = false,
0597                          bool debug = false) {
0598   std::string dirnm = "hgcMissingRecHit";
0599   std::string name0 = "HGCal HE Scintillator";
0600   const int nhist = 24;
0601   std::string name2[nhist] = {"GoodDEHGCalEESensitive",
0602                               "MissDEHGCalEESensitive",
0603                               "GoodDEHGCalHESiliconSensitive",
0604                               "MissDEHGCalHESiliconSensitive",
0605                               "GoodDEHGCalHEScintillatorSensitive",
0606                               "MissDEHGCalHEScintillatorSensitive",
0607                               "GoodREHGCalEESensitive",
0608                               "MissREHGCalEESensitive",
0609                               "GoodREHGCalHESiliconSensitive",
0610                               "MissREHGCalHESiliconSensitive",
0611                               "GoodREHGCalHEScintillatorSensitive",
0612                               "MissREHGCalHEScintillatorSensitive",
0613                               "GoodDTHGCalEESensitive",
0614                               "MissDTHGCalEESensitive",
0615                               "GoodDTHGCalHESiliconSensitive",
0616                               "MissDTHGCalHESiliconSensitive",
0617                               "GoodDTHGCalHEScintillatorSensitive",
0618                               "MissDTHGCalHEScintillatorSensitive",
0619                               "GoodRTHGCalEESensitive",
0620                               "MissRTHGCalEESensitive",
0621                               "GoodRTHGCalHESiliconSensitive",
0622                               "MissRTHGCalHESiliconSensitive",
0623                               "GoodRTHGCalHEScintillatorSensitive",
0624                               "MissRTHGCalHEScintillatorSensitive"};
0625   std::string xtitl[nhist] = {"SimHit Energy (GeV)",
0626                               "SimHit Energy (GeV)",
0627                               "SimHit Energy (GeV)",
0628                               "SimHit Energy (GeV)",
0629                               "SimHit Energy (GeV)",
0630                               "SimHit Energy (GeV)",
0631                               "SimHit Energy (GeV)",
0632                               "SimHit Energy (GeV)",
0633                               "SimHit Energy (GeV)",
0634                               "SimHit Energy (GeV)",
0635                               "SimHit Energy (GeV)",
0636                               "SimHit Energy (GeV)",
0637                               "|#eta|",
0638                               "|#eta|",
0639                               "|#eta|",
0640                               "|#eta|",
0641                               "|#eta|",
0642                               "|#eta|",
0643                               "|#eta|",
0644                               "|#eta|",
0645                               "|#eta|",
0646                               "|#eta|",
0647                               "|#eta|",
0648                               "|#eta|"};
0649   std::string ytitl[nhist] = {"Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits",
0650                               "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits",
0651                               "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits", "Hits"};
0652   int ibin[nhist] = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
0653   gStyle->SetCanvasBorderMode(0);
0654   gStyle->SetCanvasColor(kWhite);
0655   gStyle->SetPadColor(kWhite);
0656   gStyle->SetFillColor(kWhite);
0657   gStyle->SetOptStat(111110);
0658   if (debug)
0659     std::cout << "File " << fname << " Tags " << tag << " : " << dtype << " Save " << save << "\n";
0660   TFile *file = new TFile(fname.c_str());
0661   if (file) {
0662     char dirx[100];
0663     sprintf(dirx, "%s", dirnm.c_str());
0664     TDirectory *dir = (TDirectory *)file->FindObjectAny(dirx);
0665     if (debug)
0666       std::cout << "Directory " << dirx << " : " << dir << std::endl;
0667     if (dir) {
0668       for (int ih = 0; ih < nhist; ++ih) {
0669         char hname[100];
0670         sprintf(hname, "%s", name2[ih].c_str());
0671         TH1D *hist1 = (TH1D *)dir->FindObjectAny(hname);
0672         if (debug)
0673           std::cout << "Hist " << hname << " : " << hist1 << " Xtitle " << xtitl[ih] << " Ytitle " << ytitl[ih]
0674                     << " ibin " << ibin[ih] << std::endl;
0675         if (hist1 != nullptr) {
0676           char name[100], title[100];
0677           sprintf(name, "%s%s", hname, tag.c_str());
0678           TCanvas *pad = new TCanvas(name, name, 500, 500);
0679           pad->SetRightMargin(0.10);
0680           pad->SetTopMargin(0.10);
0681           sprintf(title, "%s (%s)", hist1->GetTitle(), dtype.c_str());
0682           if (debug)
0683             std::cout << "Pad " << name << " : " << pad << "\n";
0684           hist1->GetYaxis()->SetTitle(ytitl[ih].c_str());
0685           hist1->GetXaxis()->SetTitle(xtitl[ih].c_str());
0686           hist1->SetTitle(title);
0687           pad->SetLogy();
0688           if (ibin[ih] > 0)
0689             hist1->Rebin(ibin[ih]);
0690           hist1->GetYaxis()->SetTitleOffset(1.2);
0691           hist1->Draw();
0692           pad->Update();
0693           TPaveStats *st1 = ((TPaveStats *)hist1->GetListOfFunctions()->FindObject("stats"));
0694           if (st1 != NULL) {
0695             st1->SetY1NDC(0.70);
0696             st1->SetY2NDC(0.90);
0697             st1->SetX1NDC(0.65);
0698             st1->SetX2NDC(0.90);
0699           }
0700           pad->Modified();
0701           pad->Update();
0702           if (save) {
0703             sprintf(name, "c_%s.jpg", pad->GetName());
0704             pad->Print(name);
0705           }
0706         }
0707       }
0708     }
0709   }
0710 }
0711 
0712 void ehcalPlots(std::string fname = "ecalHitdd4hep.root",
0713                 std::string dirnm = "EcalSimHitStudy",
0714                 std::string tag = "DD4Hep",
0715                 int dets = 2,
0716                 bool save = false,
0717                 bool debug = false) {
0718   const int nh = 2;
0719   std::string name[nh] = {"poszp", "poszn"};
0720   gStyle->SetCanvasBorderMode(0);
0721   gStyle->SetCanvasColor(kWhite);
0722   gStyle->SetPadColor(kWhite);
0723   gStyle->SetFillColor(kWhite);
0724   gStyle->SetOptStat(10);
0725   if (debug)
0726     std::cout << "File " << fname << " Tag " << tag << " Detectors " << dets << " Save " << save << "\n";
0727   TFile *file = new TFile(fname.c_str());
0728   if (file) {
0729     TDirectory *dir = (TDirectory *)file->FindObjectAny(dirnm.c_str());
0730     if (debug)
0731       std::cout << "Directory " << dirnm << " : " << dir << std::endl;
0732     if (dir) {
0733       for (int id = 0; id < dets; ++id) {
0734         for (int ih = 0; ih < nh; ++ih) {
0735           char hname[100];
0736           sprintf(hname, "%s%d", name[ih].c_str(), id);
0737           TH2D *hist = (TH2D *)(dir->FindObjectAny(hname));
0738           if (debug)
0739             std::cout << "Hist " << hname << " : " << hist << ":" << hist->GetTitle() << " Xtitle "
0740                       << hist->GetXaxis()->GetTitle() << " Ytitle " << hist->GetYaxis()->GetTitle() << std::endl;
0741           if (hist != nullptr) {
0742             char cname[100], title[100];
0743             sprintf(cname, "%s%s", hname, tag.c_str());
0744             TCanvas *pad = new TCanvas(cname, cname, 500, 500);
0745             pad->SetRightMargin(0.10);
0746             pad->SetTopMargin(0.10);
0747             sprintf(title, "%s (%s)", hist->GetTitle(), tag.c_str());
0748             if (debug)
0749               std::cout << "Pad " << cname << " : " << pad << "\n";
0750             hist->SetTitle(title);
0751             hist->SetMarkerStyle(20);
0752             hist->SetMarkerSize(0.1);
0753             hist->GetYaxis()->SetTitleOffset(1.3);
0754             hist->Draw();
0755             pad->Update();
0756             TPaveStats *st1 = ((TPaveStats *)hist->GetListOfFunctions()->FindObject("stats"));
0757             if (st1 != NULL) {
0758               st1->SetY1NDC(0.85);
0759               st1->SetY2NDC(0.90);
0760               st1->SetX1NDC(0.70);
0761               st1->SetX2NDC(0.90);
0762             }
0763             pad->Modified();
0764             pad->Update();
0765             if (save) {
0766               sprintf(cname, "c_%s.jpg", pad->GetName());
0767               pad->Print(cname);
0768             }
0769           }
0770         }
0771       }
0772     }
0773   }
0774 }
0775 
0776 class hgcHits {
0777 public:
0778   TTree *fChain;
0779   Int_t fCurrent;
0780 
0781 private:
0782   // Declaration of leaf types
0783   std::vector<float> *heeRecX;
0784   std::vector<float> *heeRecY;
0785   std::vector<float> *heeRecZ;
0786   std::vector<float> *heeRecEnergy;
0787   std::vector<float> *hefRecX;
0788   std::vector<float> *hefRecY;
0789   std::vector<float> *hefRecZ;
0790   std::vector<float> *hefRecEnergy;
0791   std::vector<float> *hebRecX;
0792   std::vector<float> *hebRecY;
0793   std::vector<float> *hebRecZ;
0794   std::vector<float> *hebRecEta;
0795   std::vector<float> *hebRecPhi;
0796   std::vector<float> *hebRecEnergy;
0797   std::vector<float> *heeSimX;
0798   std::vector<float> *heeSimY;
0799   std::vector<float> *heeSimZ;
0800   std::vector<float> *heeSimEnergy;
0801   std::vector<float> *hefSimX;
0802   std::vector<float> *hefSimY;
0803   std::vector<float> *hefSimZ;
0804   std::vector<float> *hefSimEnergy;
0805   std::vector<float> *hebSimX;
0806   std::vector<float> *hebSimY;
0807   std::vector<float> *hebSimZ;
0808   std::vector<float> *hebSimEta;
0809   std::vector<float> *hebSimPhi;
0810   std::vector<float> *hebSimEnergy;
0811   std::vector<unsigned int> *heeDetID;
0812   std::vector<unsigned int> *hefDetID;
0813   std::vector<unsigned int> *hebDetID;
0814 
0815   // List of branches
0816   TBranch *b_heeRecX;
0817   TBranch *b_heeRecY;
0818   TBranch *b_heeRecZ;
0819   TBranch *b_heeRecEnergy;
0820   TBranch *b_hefRecX;
0821   TBranch *b_hefRecY;
0822   TBranch *b_hefRecZ;
0823   TBranch *b_hefRecEnergy;
0824   TBranch *b_hebRecX;
0825   TBranch *b_hebRecY;
0826   TBranch *b_hebRecZ;
0827   TBranch *b_hebRecEta;
0828   TBranch *b_hebRecPhi;
0829   TBranch *b_hebRecEnergy;
0830   TBranch *b_heeSimX;
0831   TBranch *b_heeSimY;
0832   TBranch *b_heeSimZ;
0833   TBranch *b_heeSimEnergy;
0834   TBranch *b_hefSimX;
0835   TBranch *b_hefSimY;
0836   TBranch *b_hefSimZ;
0837   TBranch *b_hefSimEnergy;
0838   TBranch *b_hebSimX;
0839   TBranch *b_hebSimY;
0840   TBranch *b_hebSimZ;
0841   TBranch *b_hebSimEta;
0842   TBranch *b_hebSimPhi;
0843   TBranch *b_hebSimEnergy;
0844   TBranch *b_heeDetID;
0845   TBranch *b_hefDetID;
0846   TBranch *b_hebDetID;
0847 
0848 public:
0849   hgcHits(const char *infile);
0850   virtual ~hgcHits();
0851   virtual Int_t Cut(Long64_t entry);
0852   virtual Int_t GetEntry(Long64_t entry);
0853   virtual Long64_t LoadTree(Long64_t entry);
0854   virtual void Init(TTree *tree);
0855   virtual void Loop();
0856   virtual Bool_t Notify();
0857   virtual void Show(Long64_t entry = -1);
0858 
0859   void bookHistograms();
0860   void saveHistos(const char *outfile);
0861 
0862 private:
0863 };
0864 
0865 hgcHits::hgcHits::hgcHits(const char *infile) {
0866   TFile *file = new TFile(infile);
0867   TDirectory *dir = (TDirectory *)(file->FindObjectAny("hgcHitAnalysis"));
0868   TTree *tree = (TTree *)(dir->FindObjectAny("hgcHits"));
0869   std::cout << "Attaches tree hgcHits at " << tree << " in file " << infile << std::endl;
0870   bookHistograms();
0871   Init(tree);
0872 }
0873 
0874 hgcHits::~hgcHits() {
0875   if (!fChain)
0876     return;
0877   delete fChain->GetCurrentFile();
0878 }
0879 
0880 Int_t hgcHits::GetEntry(Long64_t entry) {
0881   // Read contents of entry.
0882   if (!fChain)
0883     return 0;
0884   return fChain->GetEntry(entry);
0885 }
0886 
0887 Long64_t hgcHits::LoadTree(Long64_t entry) {
0888   // Set the environment to read one entry
0889   if (!fChain)
0890     return -5;
0891   Long64_t centry = fChain->LoadTree(entry);
0892   if (centry < 0)
0893     return centry;
0894   if (!fChain->InheritsFrom(TChain::Class()))
0895     return centry;
0896   TChain *chain = (TChain *)fChain;
0897   if (chain->GetTreeNumber() != fCurrent) {
0898     fCurrent = chain->GetTreeNumber();
0899     Notify();
0900   }
0901   return centry;
0902 }
0903 
0904 void hgcHits::Init(TTree *tree) {
0905   // The Init() function is called when the selector needs to initialize
0906   // a new tree or chain. Typically here the branch addresses and branch
0907   // pointers of the tree will be set.
0908   // It is normally not necessary to make changes to the generated
0909   // code, but the routine can be extended by the user if needed.
0910   // Init() will be called many times when running on PROOF
0911   // (once per file to be processed).
0912 
0913   // Set object pointer
0914   heeRecX = 0;
0915   heeRecY = 0;
0916   heeRecZ = 0;
0917   heeRecEnergy = 0;
0918   hefRecX = 0;
0919   hefRecY = 0;
0920   hefRecZ = 0;
0921   hefRecEnergy = 0;
0922   hebRecX = 0;
0923   hebRecY = 0;
0924   hebRecZ = 0;
0925   hebRecEta = 0;
0926   hebRecPhi = 0;
0927   hebRecEnergy = 0;
0928   heeSimX = 0;
0929   heeSimY = 0;
0930   heeSimZ = 0;
0931   heeSimEnergy = 0;
0932   hefSimX = 0;
0933   hefSimY = 0;
0934   hefSimZ = 0;
0935   hefSimEnergy = 0;
0936   hebSimX = 0;
0937   hebSimY = 0;
0938   hebSimZ = 0;
0939   hebSimEta = 0;
0940   hebSimPhi = 0;
0941   hebSimEnergy = 0;
0942   heeDetID = 0;
0943   hefDetID = 0;
0944   hebDetID = 0;
0945   // Set branch addresses and branch pointers
0946   if (!tree)
0947     return;
0948   fChain = tree;
0949   fCurrent = -1;
0950   fChain->SetMakeClass(1);
0951 
0952   fChain->SetBranchAddress("heeRecX", &heeRecX, &b_heeRecX);
0953   fChain->SetBranchAddress("heeRecY", &heeRecY, &b_heeRecY);
0954   fChain->SetBranchAddress("heeRecZ", &heeRecZ, &b_heeRecZ);
0955   fChain->SetBranchAddress("heeRecEnergy", &heeRecEnergy, &b_heeRecEnergy);
0956   fChain->SetBranchAddress("hefRecX", &hefRecX, &b_hefRecX);
0957   fChain->SetBranchAddress("hefRecY", &hefRecY, &b_hefRecY);
0958   fChain->SetBranchAddress("hefRecZ", &hefRecZ, &b_hefRecZ);
0959   fChain->SetBranchAddress("hefRecEnergy", &hefRecEnergy, &b_hefRecEnergy);
0960   fChain->SetBranchAddress("hebRecX", &hebRecX, &b_hebRecX);
0961   fChain->SetBranchAddress("hebRecY", &hebRecY, &b_hebRecY);
0962   fChain->SetBranchAddress("hebRecZ", &hebRecZ, &b_hebRecZ);
0963   fChain->SetBranchAddress("hebRecEta", &hebRecEta, &b_hebRecEta);
0964   fChain->SetBranchAddress("hebRecPhi", &hebRecPhi, &b_hebRecPhi);
0965   fChain->SetBranchAddress("hebRecEnergy", &hebRecEnergy, &b_hebRecEnergy);
0966   fChain->SetBranchAddress("heeSimX", &heeSimX, &b_heeSimX);
0967   fChain->SetBranchAddress("heeSimY", &heeSimY, &b_heeSimY);
0968   fChain->SetBranchAddress("heeSimZ", &heeSimZ, &b_heeSimZ);
0969   fChain->SetBranchAddress("heeSimEnergy", &heeSimEnergy, &b_heeSimEnergy);
0970   fChain->SetBranchAddress("hefSimX", &hefSimX, &b_hefSimX);
0971   fChain->SetBranchAddress("hefSimY", &hefSimY, &b_hefSimY);
0972   fChain->SetBranchAddress("hefSimZ", &hefSimZ, &b_hefSimZ);
0973   fChain->SetBranchAddress("hefSimEnergy", &hefSimEnergy, &b_hefSimEnergy);
0974   fChain->SetBranchAddress("hebSimX", &hebSimX, &b_hebSimX);
0975   fChain->SetBranchAddress("hebSimY", &hebSimY, &b_hebSimY);
0976   fChain->SetBranchAddress("hebSimZ", &hebSimZ, &b_hebSimZ);
0977   fChain->SetBranchAddress("hebSimEta", &hebSimEta, &b_hebSimEta);
0978   fChain->SetBranchAddress("hebSimPhi", &hebSimPhi, &b_hebSimPhi);
0979   fChain->SetBranchAddress("hebSimEnergy", &hebSimEnergy, &b_hebSimEnergy);
0980   fChain->SetBranchAddress("heeDetID", &heeDetID, &b_heeDetID);
0981   fChain->SetBranchAddress("hefDetID", &hefDetID, &b_hefDetID);
0982   fChain->SetBranchAddress("hebDetID", &hebDetID, &b_hebDetID);
0983   Notify();
0984 }
0985 
0986 Bool_t hgcHits::Notify() {
0987   // The Notify() function is called when a new file is opened. This
0988   // can be either for a new TTree in a TChain or when when a new TTree
0989   // is started when using PROOF. It is normally not necessary to make changes
0990   // to the generated code, but the routine can be extended by the
0991   // user if needed. The return value is currently not used.
0992 
0993   return kTRUE;
0994 }
0995 
0996 void hgcHits::Show(Long64_t entry) {
0997   // Print contents of entry.
0998   // If entry is not specified, print current entry
0999   if (!fChain)
1000     return;
1001   fChain->Show(entry);
1002 }
1003 
1004 Int_t hgcHits::Cut(Long64_t) {
1005   // This function may be called from Loop.
1006   // returns  1 if entry is accepted.
1007   // returns -1 otherwise.
1008   return 1;
1009 }
1010 
1011 void hgcHits::Loop() {
1012   //   In a ROOT session, you can do:
1013   //      Root > .L hgcHits.C
1014   //      Root > hgcHits t
1015   //      Root > t.GetEntry(12); // Fill t data members with entry number 12
1016   //      Root > t.Show();       // Show values of entry 12
1017   //      Root > t.Show(16);     // Read and show values of entry 16
1018   //      Root > t.Loop();       // Loop on all entries
1019   //
1020 
1021   //     This is the loop skeleton where:
1022   //    jentry is the global entry number in the chain
1023   //    ientry is the entry number in the current Tree
1024   //  Note that the argument to GetEntry must be:
1025   //    jentry for TChain::GetEntry
1026   //    ientry for TTree::GetEntry and TBranch::GetEntry
1027   //
1028   //       To read only selected branches, Insert statements like:
1029   // METHOD1:
1030   //    fChain->SetBranchStatus("*",0);  // disable all branches
1031   //    fChain->SetBranchStatus("branchname",1);  // activate branchname
1032   // METHOD2: replace line
1033   //    fChain->GetEntry(jentry);       //read all branches
1034   //by  b_branchname->GetEntry(ientry); //read only this branch
1035   if (fChain == 0)
1036     return;
1037 
1038   Long64_t nentries = fChain->GetEntriesFast();
1039 
1040   Long64_t nbytes = 0, nb = 0;
1041   for (Long64_t jentry = 0; jentry < nentries; jentry++) {
1042     Long64_t ientry = LoadTree(jentry);
1043     if (ientry < 0)
1044       break;
1045     nb = fChain->GetEntry(jentry);
1046     nbytes += nb;
1047     // if (Cut(ientry) < 0) continue;
1048   }
1049 }
1050 
1051 void hgcHits::bookHistograms() {}
1052 
1053 void hgcHits::saveHistos(const char *) {}