Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:48:14

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //
0003 //   HBHEMuonHighEta h1(infile, outfile,t mode, debug)
0004 //   h1.Loop()
0005 //
0006 //   infile     const char*  Name of the input file
0007 //   outfile    const char*  Name of the output file
0008 //                           (dyll_PU20_25_output_10.root)
0009 //   mode       int          Geometry file used 0:(defined by maxDHB/HE);
0010 //                           1 (Run 1; valid till 2016); 2 (Run 2; 2018);
0011 //                           3 (Run 3; post LS2); 4 (2017 Plan 1);
0012 //                           5 (Run 4; post LS3); (default: 0)
0013 //   debug      bool         Debug flag (default: false)
0014 //
0015 ///////////////////////////////////////////////////////////////////////////////
0016 
0017 #include <TCanvas.h>
0018 #include <TChain.h>
0019 #include <TFile.h>
0020 #include <TH1.h>
0021 #include <TH1D.h>
0022 #include <TH2.h>
0023 #include <TH2D.h>
0024 #include <TProfile.h>
0025 #include <TTree.h>
0026 #include <TROOT.h>
0027 #include <TStyle.h>
0028 
0029 #include <algorithm>
0030 #include <iostream>
0031 #include <cmath>
0032 #include <vector>
0033 
0034 class HBHEMuonHighEta {
0035 public:
0036   HBHEMuonHighEta(const char *infile, const char *outfile, const int mode = 0, const bool debug = false);
0037   virtual ~HBHEMuonHighEta();
0038   virtual Int_t Cut(Long64_t entry);
0039   virtual Int_t GetEntry(Long64_t entry);
0040   virtual Long64_t LoadTree(Long64_t entry);
0041   virtual void Init(TTree *tree);
0042   virtual void Loop();
0043   virtual Bool_t Notify();
0044   virtual void Show(Long64_t entry = -1);
0045 
0046 private:
0047   void BookHistograms(const char *fname);
0048   void Close();
0049   int nDepthBins(int eta, int phi);
0050   TTree *fChain;   //!pointer to the analyzed TTree or TChain
0051   Int_t fCurrent;  //!current Tree number in a TChain
0052 
0053   static const int maxDepthHB_ = 7;
0054   static const int maxDepthHE_ = 4;
0055 
0056   // Fixed size dimensions of array or collections stored in the TTree if any.
0057   // Declaration of leaf types
0058   std::vector<double> *pt_of_muon;
0059   std::vector<double> *eta_of_muon;
0060   std::vector<double> *phi_of_muon;
0061   std::vector<double> *energy_of_muon;
0062   std::vector<double> *p_of_muon;
0063   std::vector<bool> *MediumMuon;
0064   std::vector<double> *IsolationR04;
0065   std::vector<double> *IsolationR03;
0066   std::vector<double> *ecal_3into3;
0067   std::vector<double> *hcal_3into3;
0068   std::vector<double> *tracker_3into3;
0069   std::vector<double> *emaxNearP;
0070   UInt_t Run_No;
0071   UInt_t Event_No;
0072   UInt_t GoodVertex;
0073   std::vector<bool> *matchedId;
0074   std::vector<bool> *hcal_cellHot;
0075   std::vector<double> *ecal_3x3;
0076   std::vector<double> *hcal_1x1;
0077   std::vector<unsigned int> *ecal_detID;
0078   std::vector<unsigned int> *hcal_detID;
0079   std::vector<unsigned int> *ehcal_detID;
0080   std::vector<int> *hcal_ieta;
0081   std::vector<int> *hcal_iphi;
0082   std::vector<double> *hcal_edepth1;
0083   std::vector<double> *hcal_activeL1;
0084   std::vector<double> *hcal_edepthHot1;
0085   std::vector<double> *hcal_activeHotL1;
0086   std::vector<double> *hcal_cdepthHot1;
0087   std::vector<double> *hcal_cdepthHotBG1;
0088   std::vector<double> *hcal_edepthCorrect1;
0089   std::vector<double> *hcal_edepthHotCorrect1;
0090   std::vector<bool> *hcal_depthMatch1;
0091   std::vector<bool> *hcal_depthMatchHot1;
0092   std::vector<double> *hcal_edepth2;
0093   std::vector<double> *hcal_activeL2;
0094   std::vector<double> *hcal_edepthHot2;
0095   std::vector<double> *hcal_activeHotL2;
0096   std::vector<double> *hcal_cdepthHot2;
0097   std::vector<double> *hcal_cdepthHotBG2;
0098   std::vector<double> *hcal_edepthCorrect2;
0099   std::vector<double> *hcal_edepthHotCorrect2;
0100   std::vector<bool> *hcal_depthMatch2;
0101   std::vector<bool> *hcal_depthMatchHot2;
0102   std::vector<double> *hcal_edepth3;
0103   std::vector<double> *hcal_activeL3;
0104   std::vector<double> *hcal_edepthHot3;
0105   std::vector<double> *hcal_activeHotL3;
0106   std::vector<double> *hcal_cdepthHot3;
0107   std::vector<double> *hcal_cdepthHotBG3;
0108   std::vector<double> *hcal_edepthCorrect3;
0109   std::vector<double> *hcal_edepthHotCorrect3;
0110   std::vector<bool> *hcal_depthMatch3;
0111   std::vector<bool> *hcal_depthMatchHot3;
0112   std::vector<double> *hcal_edepth4;
0113   std::vector<double> *hcal_activeL4;
0114   std::vector<double> *hcal_edepthHot4;
0115   std::vector<double> *hcal_activeHotL4;
0116   std::vector<double> *hcal_cdepthHot4;
0117   std::vector<double> *hcal_cdepthHotBG4;
0118   std::vector<double> *hcal_edepthCorrect4;
0119   std::vector<double> *hcal_edepthHotCorrect4;
0120   std::vector<bool> *hcal_depthMatch4;
0121   std::vector<bool> *hcal_depthMatchHot4;
0122   std::vector<double> *hcal_edepth5;
0123   std::vector<double> *hcal_activeL5;
0124   std::vector<double> *hcal_edepthHot5;
0125   std::vector<double> *hcal_activeHotL5;
0126   std::vector<double> *hcal_cdepthHot5;
0127   std::vector<double> *hcal_cdepthHotBG5;
0128   std::vector<double> *hcal_edepthCorrect5;
0129   std::vector<double> *hcal_edepthHotCorrect5;
0130   std::vector<bool> *hcal_depthMatch5;
0131   std::vector<bool> *hcal_depthMatchHot5;
0132   std::vector<double> *hcal_edepth6;
0133   std::vector<double> *hcal_activeL6;
0134   std::vector<double> *hcal_edepthHot6;
0135   std::vector<double> *hcal_activeHotL6;
0136   std::vector<double> *hcal_cdepthHot6;
0137   std::vector<double> *hcal_cdepthHotBG6;
0138   std::vector<double> *hcal_edepthCorrect6;
0139   std::vector<double> *hcal_edepthHotCorrect6;
0140   std::vector<bool> *hcal_depthMatch6;
0141   std::vector<bool> *hcal_depthMatchHot6;
0142   std::vector<double> *hcal_edepth7;
0143   std::vector<double> *hcal_activeL7;
0144   std::vector<double> *hcal_edepthHot7;
0145   std::vector<double> *hcal_activeHotL7;
0146   std::vector<double> *hcal_cdepthHot7;
0147   std::vector<double> *hcal_cdepthHotBG7;
0148   std::vector<double> *hcal_edepthCorrect7;
0149   std::vector<double> *hcal_edepthHotCorrect7;
0150   std::vector<bool> *hcal_depthMatch7;
0151   std::vector<bool> *hcal_depthMatchHot7;
0152   std::vector<double> *activeLength;
0153   std::vector<double> *activeLengthHot;
0154   std::vector<double> *trackDz;
0155   std::vector<int> *trackLayerCrossed;
0156   std::vector<int> *trackOuterHit;
0157   std::vector<int> *trackMissedInnerHits;
0158   std::vector<int> *trackMissedOuterHits;
0159 
0160   // List of branches
0161   TBranch *b_pt_of_muon;
0162   TBranch *b_eta_of_muon;
0163   TBranch *b_phi_of_muon;
0164   TBranch *b_energy_of_muon;
0165   TBranch *b_p_of_muon;
0166   TBranch *b_MediumMuon;
0167   TBranch *b_IsolationR04;
0168   TBranch *b_IsolationR03;
0169   TBranch *b_ecal_3into3;
0170   TBranch *b_hcal_3into3;
0171   TBranch *b_tracker_3into3;
0172   TBranch *b_emaxNearP;
0173   TBranch *b_Run_No;
0174   TBranch *b_Event_No;
0175   TBranch *b_GoodVertex;
0176   TBranch *b_matchedId;
0177   TBranch *b_hcal_cellHot;
0178   TBranch *b_ecal_3x3;
0179   TBranch *b_hcal_1x1;
0180   TBranch *b_ecal_detID;
0181   TBranch *b_hcal_detID;
0182   TBranch *b_ehcal_detID;
0183   TBranch *b_hcal_ieta;
0184   TBranch *b_hcal_iphi;
0185   TBranch *b_hcal_edepth1;
0186   TBranch *b_hcal_activeL1;
0187   TBranch *b_hcal_edepthHot1;
0188   TBranch *b_hcal_activeHotL1;
0189   TBranch *b_hcal_cdepthHot1;
0190   TBranch *b_hcal_cdepthHotBG1;
0191   TBranch *b_hcal_edepthCorrect1;
0192   TBranch *b_hcal_edepthHotCorrect1;
0193   TBranch *b_hcal_depthMatch1;
0194   TBranch *b_hcal_depthMatchHot1;
0195   TBranch *b_hcal_edepth2;
0196   TBranch *b_hcal_activeL2;
0197   TBranch *b_hcal_edepthHot2;
0198   TBranch *b_hcal_activeHotL2;
0199   TBranch *b_hcal_cdepthHot2;
0200   TBranch *b_hcal_cdepthHotBG2;
0201   TBranch *b_hcal_edepthCorrect2;
0202   TBranch *b_hcal_edepthHotCorrect2;
0203   TBranch *b_hcal_depthMatch2;
0204   TBranch *b_hcal_depthMatchHot2;
0205   TBranch *b_hcal_edepth3;
0206   TBranch *b_hcal_activeL3;
0207   TBranch *b_hcal_edepthHot3;
0208   TBranch *b_hcal_activeHotL3;
0209   TBranch *b_hcal_cdepthHot3;
0210   TBranch *b_hcal_cdepthHotBG3;
0211   TBranch *b_hcal_edepthCorrect3;
0212   TBranch *b_hcal_edepthHotCorrect3;
0213   TBranch *b_hcal_depthMatch3;
0214   TBranch *b_hcal_depthMatchHot3;
0215   TBranch *b_hcal_edepth4;
0216   TBranch *b_hcal_activeL4;
0217   TBranch *b_hcal_edepthHot4;
0218   TBranch *b_hcal_activeHotL4;
0219   TBranch *b_hcal_cdepthHot4;
0220   TBranch *b_hcal_cdepthHotBG4;
0221   TBranch *b_hcal_edepthCorrect4;
0222   TBranch *b_hcal_edepthHotCorrect4;
0223   TBranch *b_hcal_depthMatch4;
0224   TBranch *b_hcal_depthMatchHot4;
0225   TBranch *b_hcal_edepth5;
0226   TBranch *b_hcal_activeL5;
0227   TBranch *b_hcal_edepthHot5;
0228   TBranch *b_hcal_activeHotL5;
0229   TBranch *b_hcal_cdepthHot5;
0230   TBranch *b_hcal_cdepthHotBG5;
0231   TBranch *b_hcal_edepthCorrect5;
0232   TBranch *b_hcal_edepthHotCorrect5;
0233   TBranch *b_hcal_depthMatch5;
0234   TBranch *b_hcal_depthMatchHot5;
0235   TBranch *b_hcal_edepth6;
0236   TBranch *b_hcal_activeL6;
0237   TBranch *b_hcal_edepthHot6;
0238   TBranch *b_hcal_activeHotL6;
0239   TBranch *b_hcal_cdepthHot6;
0240   TBranch *b_hcal_cdepthHotBG6;
0241   TBranch *b_hcal_edepthCorrect6;
0242   TBranch *b_hcal_edepthHotCorrect6;
0243   TBranch *b_hcal_depthMatch6;
0244   TBranch *b_hcal_depthMatchHot6;
0245   TBranch *b_hcal_edepth7;
0246   TBranch *b_hcal_activeL7;
0247   TBranch *b_hcal_edepthHot7;
0248   TBranch *b_hcal_activeHotL7;
0249   TBranch *b_hcal_cdepthHot7;
0250   TBranch *b_hcal_cdepthHotBG7;
0251   TBranch *b_hcal_edepthCorrect7;
0252   TBranch *b_hcal_edepthHotCorrect7;
0253   TBranch *b_hcal_depthMatch7;
0254   TBranch *b_hcal_depthMatchHot7;
0255   TBranch *b_activeLength;
0256   TBranch *b_activeLengthHot;
0257   TBranch *b_trackDz;
0258   TBranch *b_trackLayerCrossed;
0259   TBranch *b_trackOuterHit;
0260   TBranch *b_trackMissedInnerHits;
0261   TBranch *b_trackMissedOuterHits;
0262 
0263   int modeLHC_;
0264   bool debug_;
0265   TFile *output_file;
0266 };
0267 
0268 HBHEMuonHighEta::HBHEMuonHighEta(const char *infile, const char *outfile, const int mode, const bool debug) {
0269   modeLHC_ = mode;
0270   debug_ = debug;
0271   TFile *file = new TFile(infile);
0272   TDirectory *dir = (TDirectory *)(file->FindObjectAny("hcalHBHEMuonHighEta"));
0273   TTree *tree = (TTree *)(dir->FindObjectAny("HBHEMuonHighEta"));
0274   std::cout << "Attaches tree HBHEMuonHighEta at " << tree << " in file " << infile << std::endl;
0275 
0276   BookHistograms(outfile);
0277   Init(tree);
0278 }
0279 
0280 HBHEMuonHighEta::~HBHEMuonHighEta() {
0281   Close();
0282   if (!fChain)
0283     return;
0284   delete fChain->GetCurrentFile();
0285 }
0286 
0287 Int_t HBHEMuonHighEta::GetEntry(Long64_t entry) {
0288   // Read contents of entry.
0289   if (!fChain)
0290     return 0;
0291   return fChain->GetEntry(entry);
0292 }
0293 
0294 Long64_t HBHEMuonHighEta::LoadTree(Long64_t entry) {
0295   // Set the environment to read one entry
0296   if (!fChain)
0297     return -5;
0298   Long64_t centry = fChain->LoadTree(entry);
0299   if (centry < 0)
0300     return centry;
0301   if (fChain->GetTreeNumber() != fCurrent) {
0302     fCurrent = fChain->GetTreeNumber();
0303     Notify();
0304   }
0305   return centry;
0306 }
0307 
0308 void HBHEMuonHighEta::Init(TTree *tree) {
0309   // The Init() function is called when the selector needs to initialize
0310   // a new tree or chain. Typically here the branch addresses and branch
0311   // pointers of the tree will be set.
0312   // It is normally not necessary to make changes to the generated
0313   // code, but the routine can be extended by the user if needed.
0314   // Init() will be called many times when running on PROOF
0315   // (once per file to be processed).
0316 
0317   // Set object pointer
0318   pt_of_muon = 0;
0319   eta_of_muon = 0;
0320   phi_of_muon = 0;
0321   energy_of_muon = 0;
0322   p_of_muon = 0;
0323   MediumMuon = 0;
0324   IsolationR04 = 0;
0325   IsolationR03 = 0;
0326   ecal_3into3 = 0;
0327   hcal_3into3 = 0;
0328   tracker_3into3 = 0;
0329   emaxNearP = 0;
0330   matchedId = 0;
0331   hcal_cellHot = 0;
0332   ecal_3x3 = 0;
0333   hcal_1x1 = 0;
0334   ecal_detID = 0;
0335   hcal_detID = 0;
0336   ehcal_detID = 0;
0337   hcal_ieta = 0;
0338   hcal_iphi = 0;
0339   hcal_edepth1 = 0;
0340   hcal_activeL1 = 0;
0341   hcal_edepthHot1 = 0;
0342   hcal_activeHotL1 = 0;
0343   hcal_cdepthHot1 = 0;
0344   hcal_cdepthHotBG1 = 0;
0345   hcal_edepthCorrect1 = 0;
0346   hcal_edepthHotCorrect1 = 0;
0347   hcal_depthMatch1 = 0;
0348   hcal_depthMatchHot1 = 0;
0349   hcal_edepth2 = 0;
0350   hcal_activeL2 = 0;
0351   hcal_edepthHot2 = 0;
0352   hcal_activeHotL2 = 0;
0353   hcal_cdepthHot2 = 0;
0354   hcal_cdepthHotBG2 = 0;
0355   hcal_edepthCorrect2 = 0;
0356   hcal_edepthHotCorrect2 = 0;
0357   hcal_depthMatch2 = 0;
0358   hcal_depthMatchHot2 = 0;
0359   hcal_edepth3 = 0;
0360   hcal_activeL3 = 0;
0361   hcal_edepthHot3 = 0;
0362   hcal_activeHotL3 = 0;
0363   hcal_cdepthHot3 = 0;
0364   hcal_cdepthHotBG3 = 0;
0365   hcal_edepthCorrect3 = 0;
0366   hcal_edepthHotCorrect3 = 0;
0367   hcal_depthMatch3 = 0;
0368   hcal_depthMatchHot3 = 0;
0369   hcal_edepth4 = 0;
0370   hcal_activeL4 = 0;
0371   hcal_edepthHot4 = 0;
0372   hcal_activeHotL4 = 0;
0373   hcal_cdepthHot4 = 0;
0374   hcal_cdepthHotBG4 = 0;
0375   hcal_edepthCorrect4 = 0;
0376   hcal_edepthHotCorrect4 = 0;
0377   hcal_depthMatch4 = 0;
0378   hcal_depthMatchHot4 = 0;
0379   hcal_edepth5 = 0;
0380   hcal_activeL5 = 0;
0381   hcal_edepthHot5 = 0;
0382   hcal_activeHotL5 = 0;
0383   hcal_cdepthHot5 = 0;
0384   hcal_cdepthHotBG5 = 0;
0385   hcal_edepthCorrect5 = 0;
0386   hcal_edepthHotCorrect5 = 0;
0387   hcal_depthMatch5 = 0;
0388   hcal_depthMatchHot5 = 0;
0389   hcal_edepth6 = 0;
0390   hcal_activeL6 = 0;
0391   hcal_edepthHot6 = 0;
0392   hcal_activeHotL6 = 0;
0393   hcal_cdepthHot6 = 0;
0394   hcal_cdepthHotBG6 = 0;
0395   hcal_edepthCorrect6 = 0;
0396   hcal_edepthHotCorrect6 = 0;
0397   hcal_depthMatch6 = 0;
0398   hcal_depthMatchHot6 = 0;
0399   hcal_edepth7 = 0;
0400   hcal_activeL7 = 0;
0401   hcal_edepthHot7 = 0;
0402   hcal_activeHotL7 = 0;
0403   hcal_cdepthHot7 = 0;
0404   hcal_cdepthHotBG7 = 0;
0405   hcal_edepthCorrect7 = 0;
0406   hcal_edepthHotCorrect7 = 0;
0407   hcal_depthMatch7 = 0;
0408   hcal_depthMatchHot7 = 0;
0409   activeLength = 0;
0410   activeLengthHot = 0;
0411   trackDz = 0;
0412   trackLayerCrossed = 0;
0413   trackOuterHit = 0;
0414   trackMissedInnerHits = 0;
0415   trackMissedOuterHits = 0;
0416 
0417   // Set branch addresses and branch pointers
0418   if (!tree)
0419     return;
0420   fChain = tree;
0421   fCurrent = -1;
0422   fChain->SetMakeClass(1);
0423 
0424   fChain->SetBranchAddress("pt_of_muon", &pt_of_muon, &b_pt_of_muon);
0425   fChain->SetBranchAddress("eta_of_muon", &eta_of_muon, &b_eta_of_muon);
0426   fChain->SetBranchAddress("phi_of_muon", &phi_of_muon, &b_phi_of_muon);
0427   fChain->SetBranchAddress("energy_of_muon", &energy_of_muon, &b_energy_of_muon);
0428   fChain->SetBranchAddress("p_of_muon", &p_of_muon, &b_p_of_muon);
0429   fChain->SetBranchAddress("MediumMuon", &MediumMuon, &b_MediumMuon);
0430   fChain->SetBranchAddress("IsolationR04", &IsolationR04, &b_IsolationR04);
0431   fChain->SetBranchAddress("IsolationR03", &IsolationR03, &b_IsolationR03);
0432   fChain->SetBranchAddress("ecal_3into3", &ecal_3into3, &b_ecal_3into3);
0433   fChain->SetBranchAddress("hcal_3into3", &hcal_3into3, &b_hcal_3into3);
0434   fChain->SetBranchAddress("tracker_3into3", &tracker_3into3, &b_tracker_3into3);
0435   fChain->SetBranchAddress("emaxNearP", &emaxNearP, &b_emaxNearP);
0436   fChain->SetBranchAddress("Run_No", &Run_No, &b_Run_No);
0437   fChain->SetBranchAddress("Event_No", &Event_No, &b_Event_No);
0438   fChain->SetBranchAddress("GoodVertex", &GoodVertex, &b_GoodVertex);
0439   fChain->SetBranchAddress("matchedId", &matchedId, &b_matchedId);
0440   fChain->SetBranchAddress("hcal_cellHot", &hcal_cellHot, &b_hcal_cellHot);
0441   fChain->SetBranchAddress("ecal_3x3", &ecal_3x3, &b_ecal_3x3);
0442   fChain->SetBranchAddress("hcal_1x1", &hcal_1x1, &b_hcal_1x1);
0443   fChain->SetBranchAddress("ecal_detID", &ecal_detID, &b_ecal_detID);
0444   fChain->SetBranchAddress("hcal_detID", &hcal_detID, &b_hcal_detID);
0445   fChain->SetBranchAddress("ehcal_detID", &ehcal_detID, &b_ehcal_detID);
0446   fChain->SetBranchAddress("hcal_ieta", &hcal_ieta, &b_hcal_ieta);
0447   fChain->SetBranchAddress("hcal_iphi", &hcal_iphi, &b_hcal_iphi);
0448   fChain->SetBranchAddress("hcal_edepth1", &hcal_edepth1, &b_hcal_edepth1);
0449   fChain->SetBranchAddress("hcal_activeL1", &hcal_activeL1, &b_hcal_activeL1);
0450   fChain->SetBranchAddress("hcal_edepthHot1", &hcal_edepthHot1, &b_hcal_edepthHot1);
0451   fChain->SetBranchAddress("hcal_activeHotL1", &hcal_activeHotL1, &b_hcal_activeHotL1);
0452   fChain->SetBranchAddress("hcal_cdepthHot1", &hcal_cdepthHot1, &b_hcal_cdepthHot1);
0453   fChain->SetBranchAddress("hcal_cdepthHotBG1", &hcal_cdepthHotBG1, &b_hcal_cdepthHotBG1);
0454   fChain->SetBranchAddress("hcal_edepthCorrect1", &hcal_edepthCorrect1, &b_hcal_edepthCorrect1);
0455   fChain->SetBranchAddress("hcal_edepthHotCorrect1", &hcal_edepthHotCorrect1, &b_hcal_edepthHotCorrect1);
0456   fChain->SetBranchAddress("hcal_depthMatch1", &hcal_depthMatch1, &b_hcal_depthMatch1);
0457   fChain->SetBranchAddress("hcal_depthMatchHot1", &hcal_depthMatchHot1, &b_hcal_depthMatchHot1);
0458   fChain->SetBranchAddress("hcal_edepth2", &hcal_edepth2, &b_hcal_edepth2);
0459   fChain->SetBranchAddress("hcal_activeL2", &hcal_activeL2, &b_hcal_activeL2);
0460   fChain->SetBranchAddress("hcal_edepthHot2", &hcal_edepthHot2, &b_hcal_edepthHot2);
0461   fChain->SetBranchAddress("hcal_activeHotL2", &hcal_activeHotL2, &b_hcal_activeHotL2);
0462   fChain->SetBranchAddress("hcal_cdepthHot2", &hcal_cdepthHot2, &b_hcal_cdepthHot2);
0463   fChain->SetBranchAddress("hcal_cdepthHotBG2", &hcal_cdepthHotBG2, &b_hcal_cdepthHotBG2);
0464   fChain->SetBranchAddress("hcal_edepthCorrect2", &hcal_edepthCorrect2, &b_hcal_edepthCorrect2);
0465   fChain->SetBranchAddress("hcal_edepthHotCorrect2", &hcal_edepthHotCorrect2, &b_hcal_edepthHotCorrect2);
0466   fChain->SetBranchAddress("hcal_depthMatch2", &hcal_depthMatch2, &b_hcal_depthMatch2);
0467   fChain->SetBranchAddress("hcal_depthMatchHot2", &hcal_depthMatchHot2, &b_hcal_depthMatchHot2);
0468   fChain->SetBranchAddress("hcal_edepth3", &hcal_edepth3, &b_hcal_edepth3);
0469   fChain->SetBranchAddress("hcal_activeL3", &hcal_activeL3, &b_hcal_activeL3);
0470   fChain->SetBranchAddress("hcal_edepthHot3", &hcal_edepthHot3, &b_hcal_edepthHot3);
0471   fChain->SetBranchAddress("hcal_activeHotL3", &hcal_activeHotL3, &b_hcal_activeHotL3);
0472   fChain->SetBranchAddress("hcal_cdepthHot3", &hcal_cdepthHot3, &b_hcal_cdepthHot3);
0473   fChain->SetBranchAddress("hcal_cdepthHotBG3", &hcal_cdepthHotBG3, &b_hcal_cdepthHotBG3);
0474   fChain->SetBranchAddress("hcal_edepthCorrect3", &hcal_edepthCorrect3, &b_hcal_edepthCorrect3);
0475   fChain->SetBranchAddress("hcal_edepthHotCorrect3", &hcal_edepthHotCorrect3, &b_hcal_edepthHotCorrect3);
0476   fChain->SetBranchAddress("hcal_depthMatch3", &hcal_depthMatch3, &b_hcal_depthMatch3);
0477   fChain->SetBranchAddress("hcal_depthMatchHot3", &hcal_depthMatchHot3, &b_hcal_depthMatchHot3);
0478   fChain->SetBranchAddress("hcal_edepth4", &hcal_edepth4, &b_hcal_edepth4);
0479   fChain->SetBranchAddress("hcal_activeL4", &hcal_activeL4, &b_hcal_activeL4);
0480   fChain->SetBranchAddress("hcal_edepthHot4", &hcal_edepthHot4, &b_hcal_edepthHot4);
0481   fChain->SetBranchAddress("hcal_activeHotL4", &hcal_activeHotL4, &b_hcal_activeHotL4);
0482   fChain->SetBranchAddress("hcal_cdepthHot4", &hcal_cdepthHot4, &b_hcal_cdepthHot4);
0483   fChain->SetBranchAddress("hcal_cdepthHotBG4", &hcal_cdepthHotBG4, &b_hcal_cdepthHotBG4);
0484   fChain->SetBranchAddress("hcal_edepthCorrect4", &hcal_edepthCorrect4, &b_hcal_edepthCorrect4);
0485   fChain->SetBranchAddress("hcal_edepthHotCorrect4", &hcal_edepthHotCorrect4, &b_hcal_edepthHotCorrect4);
0486   fChain->SetBranchAddress("hcal_depthMatch4", &hcal_depthMatch4, &b_hcal_depthMatch4);
0487   fChain->SetBranchAddress("hcal_depthMatchHot4", &hcal_depthMatchHot4, &b_hcal_depthMatchHot4);
0488   fChain->SetBranchAddress("hcal_edepth5", &hcal_edepth5, &b_hcal_edepth5);
0489   fChain->SetBranchAddress("hcal_activeL5", &hcal_activeL5, &b_hcal_activeL5);
0490   fChain->SetBranchAddress("hcal_edepthHot5", &hcal_edepthHot5, &b_hcal_edepthHot5);
0491   fChain->SetBranchAddress("hcal_activeHotL5", &hcal_activeHotL5, &b_hcal_activeHotL5);
0492   fChain->SetBranchAddress("hcal_cdepthHot5", &hcal_cdepthHot5, &b_hcal_cdepthHot5);
0493   fChain->SetBranchAddress("hcal_cdepthHotBG5", &hcal_cdepthHotBG5, &b_hcal_cdepthHotBG5);
0494   fChain->SetBranchAddress("hcal_edepthCorrect5", &hcal_edepthCorrect5, &b_hcal_edepthCorrect5);
0495   fChain->SetBranchAddress("hcal_edepthHotCorrect5", &hcal_edepthHotCorrect5, &b_hcal_edepthHotCorrect5);
0496   fChain->SetBranchAddress("hcal_depthMatch5", &hcal_depthMatch5, &b_hcal_depthMatch5);
0497   fChain->SetBranchAddress("hcal_depthMatchHot5", &hcal_depthMatchHot5, &b_hcal_depthMatchHot5);
0498   fChain->SetBranchAddress("hcal_edepth6", &hcal_edepth6, &b_hcal_edepth6);
0499   fChain->SetBranchAddress("hcal_activeL6", &hcal_activeL6, &b_hcal_activeL6);
0500   fChain->SetBranchAddress("hcal_edepthHot6", &hcal_edepthHot6, &b_hcal_edepthHot6);
0501   fChain->SetBranchAddress("hcal_activeHotL6", &hcal_activeHotL6, &b_hcal_activeHotL6);
0502   fChain->SetBranchAddress("hcal_cdepthHot6", &hcal_cdepthHot6, &b_hcal_cdepthHot6);
0503   fChain->SetBranchAddress("hcal_cdepthHotBG6", &hcal_cdepthHotBG6, &b_hcal_cdepthHotBG6);
0504   fChain->SetBranchAddress("hcal_edepthCorrect6", &hcal_edepthCorrect6, &b_hcal_edepthCorrect6);
0505   fChain->SetBranchAddress("hcal_edepthHotCorrect6", &hcal_edepthHotCorrect6, &b_hcal_edepthHotCorrect6);
0506   fChain->SetBranchAddress("hcal_depthMatch6", &hcal_depthMatch6, &b_hcal_depthMatch6);
0507   fChain->SetBranchAddress("hcal_depthMatchHot6", &hcal_depthMatchHot6, &b_hcal_depthMatchHot6);
0508   fChain->SetBranchAddress("hcal_edepth7", &hcal_edepth7, &b_hcal_edepth7);
0509   fChain->SetBranchAddress("hcal_activeL7", &hcal_activeL7, &b_hcal_activeL7);
0510   fChain->SetBranchAddress("hcal_edepthHot7", &hcal_edepthHot7, &b_hcal_edepthHot7);
0511   fChain->SetBranchAddress("hcal_activeHotL7", &hcal_activeHotL7, &b_hcal_activeHotL7);
0512   fChain->SetBranchAddress("hcal_cdepthHot7", &hcal_cdepthHot7, &b_hcal_cdepthHot7);
0513   fChain->SetBranchAddress("hcal_cdepthHotBG7", &hcal_cdepthHotBG7, &b_hcal_cdepthHotBG7);
0514   fChain->SetBranchAddress("hcal_edepthCorrect7", &hcal_edepthCorrect7, &b_hcal_edepthCorrect7);
0515   fChain->SetBranchAddress("hcal_edepthHotCorrect7", &hcal_edepthHotCorrect7, &b_hcal_edepthHotCorrect7);
0516   fChain->SetBranchAddress("hcal_depthMatch7", &hcal_depthMatch7, &b_hcal_depthMatch7);
0517   fChain->SetBranchAddress("hcal_depthMatchHot7", &hcal_depthMatchHot7, &b_hcal_depthMatchHot7);
0518   fChain->SetBranchAddress("activeLength", &activeLength, &b_activeLength);
0519   fChain->SetBranchAddress("activeLengthHot", &activeLengthHot, &b_activeLengthHot);
0520   fChain->SetBranchAddress("trackDz", &trackDz, &b_trackDz);
0521   fChain->SetBranchAddress("trackLayerCrossed", &trackLayerCrossed, &b_trackLayerCrossed);
0522   fChain->SetBranchAddress("trackOuterHit", &trackOuterHit, &b_trackOuterHit);
0523   fChain->SetBranchAddress("trackMissedInnerHits", &trackMissedInnerHits, &b_trackMissedInnerHits);
0524   fChain->SetBranchAddress("trackMissedOuterHits", &trackMissedOuterHits, &b_trackMissedOuterHits);
0525   Notify();
0526 }
0527 
0528 Bool_t HBHEMuonHighEta::Notify() {
0529   // The Notify() function is called when a new file is opened. This
0530   // can be either for a new TTree in a TChain or when when a new TTree
0531   // is started when using PROOF. It is normally not necessary to make changes
0532   // to the generated code, but the routine can be extended by the
0533   // user if needed. The return value is currently not used.
0534 
0535   return kTRUE;
0536 }
0537 
0538 void HBHEMuonHighEta::Show(Long64_t entry) {
0539   // Print contents of entry.
0540   // If entry is not specified, print current entry
0541   if (!fChain)
0542     return;
0543   fChain->Show(entry);
0544 }
0545 
0546 Int_t HBHEMuonHighEta::Cut(Long64_t) {
0547   // This function may be called from Loop.
0548   // returns  1 if entry is accepted.
0549   // returns -1 otherwise.
0550   return 1;
0551 }
0552 
0553 void HBHEMuonHighEta::Loop() {
0554   //   In a ROOT session, you can do:
0555   //      root> .L HBHEMuonHighEta.C+g
0556   //      root> HBHEMuonHighEta t
0557   //      root> t.GetEntry(12); // Fill t data members with entry number 12
0558   //      root> t.Show();       // Show values of entry 12
0559   //      root> t.Show(16);     // Read and show values of entry 16
0560   //      root> t.Loop();       // Loop on all entries
0561   //
0562 
0563   //     This is the loop skeleton where:
0564   //    jentry is the global entry number in the chain
0565   //    ientry is the entry number in the current Tree
0566   //  Note that the argument to GetEntry must be:
0567   //    jentry for TChain::GetEntry
0568   //    ientry for TTree::GetEntry and TBranch::GetEntry
0569   //
0570   //       To read only selected branches, Insert statements like:
0571   // METHOD1:
0572   //    fChain->SetBranchStatus("*",0);  // disable all branches
0573   //    fChain->SetBranchStatus("branchname",1);  // activate branchname
0574   // METHOD2: replace line
0575   //    fChain->GetEntry(jentry);       //read all branches
0576   //by  b_branchname->GetEntry(ientry); //read only this branch
0577   if (fChain == 0)
0578     return;
0579 
0580   Long64_t nentries = fChain->GetEntriesFast();
0581 
0582   Long64_t nbytes = 0, nb = 0;
0583   for (Long64_t jentry = 0; jentry < nentries; jentry++) {
0584     Long64_t ientry = LoadTree(jentry);
0585     if (ientry < 0)
0586       break;
0587     nb = fChain->GetEntry(jentry);
0588     nbytes += nb;
0589     // if (Cut(ientry) < 0) continue;
0590   }
0591 }
0592 
0593 void HBHEMuonHighEta::BookHistograms(const char *fname) { output_file = TFile::Open(fname, "RECREATE"); }
0594 
0595 void HBHEMuonHighEta::Close() {
0596   output_file->cd();
0597   if (debug_)
0598     std::cout << "file yet to be Written" << std::endl;
0599   output_file->Write();
0600   std::cout << "output file Written" << std::endl;
0601   output_file->Close();
0602   if (debug_)
0603     std::cout << "now doing return" << std::endl;
0604 }
0605 
0606 int HBHEMuonHighEta::nDepthBins(int eta, int phi) {
0607   // Run 1 scenario
0608   int nDepthR1[29] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2};
0609   // Run 2 scenario from 2018
0610   int nDepthR2[29] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 3, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 3};
0611   // Run 3 scenario
0612   int nDepthR3[29] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 3};
0613   // Run 4 scenario
0614   int nDepthR4[29] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};
0615   // for 2021 scenario multi depth segmentation
0616   //    int  nDepth[29]={3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5,5,5,5,5,5};
0617   // modeLHC_ = 0 --> nbin defined maxDepthHB/HE
0618   //          = 1 -->      corresponds to Run 1 (valid till 2016)
0619   //          = 2 -->      corresponds to Run 2 (2018 geometry)
0620   //          = 3 -->      corresponds to Run 3 (post LS2)
0621   //          = 4 -->      corresponds to 2017 (Plan 1)
0622   //          = 5 -->      corresponds to Run 4 (post LS3)
0623   int nbin(0);
0624   if (modeLHC_ == 0) {
0625     if (eta <= 15) {
0626       nbin = maxDepthHB_;
0627     } else if (eta == 16) {
0628       nbin = 4;
0629     } else {
0630       nbin = maxDepthHE_;
0631     }
0632   } else if (modeLHC_ == 1) {
0633     nbin = nDepthR1[eta - 1];
0634   } else if (modeLHC_ == 2) {
0635     nbin = nDepthR2[eta - 1];
0636   } else if (modeLHC_ == 3) {
0637     nbin = nDepthR3[eta - 1];
0638   } else if (modeLHC_ == 4) {
0639     if (phi > 0) {
0640       if (eta >= 16 && phi >= 63 && phi <= 66) {
0641         nbin = nDepthR2[eta - 1];
0642       } else {
0643         nbin = nDepthR1[eta - 1];
0644       }
0645     } else {
0646       if (eta >= 16) {
0647         nbin = (nDepthR2[eta - 1] > nDepthR1[eta - 1]) ? nDepthR2[eta - 1] : nDepthR1[eta - 1];
0648       } else {
0649         nbin = nDepthR1[eta - 1];
0650       }
0651     }
0652   } else {
0653     if (eta > 0 && eta < 30) {
0654       nbin = nDepthR4[eta - 1];
0655     } else {
0656       nbin = nDepthR4[28];
0657     }
0658   }
0659   return nbin;
0660 }