Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:18

0001 #include "TreeAnalysisReadGen.h"
0002 #include <TH2.h>
0003 #include <TStyle.h>
0004 #include <TCanvas.h>
0005 #include <vector>
0006 
0007 Bool_t FillChain(TChain *chain, const TString &inputFileList);
0008 
0009 int main(Int_t argc, Char_t *argv[]) {
0010   if( argc<6 ){
0011     std::cerr << "Please give 7 arguments "
0012               << "runList Seed" << "\n" 
0013           << "outputFileName" << "\n"
0014           << "L1 Trigger Name" << "\n" 
0015           << "dRCut for L1" << "\n" 
0016           << "maximum sample size" << "\n" 
0017           << "iRange" << "\n" 
0018           << "fRange" << "" 
0019           << std::endl;
0020     return -1;
0021   }
0022   
0023   const char *inputFileList = argv[1];
0024   const char *outFileName   = argv[2];
0025   const char *name          = argv[3];
0026   const char *DRCut         = argv[4];
0027   double totalTracks        = atof(argv[5]);
0028   const int iRange          = atoi(argv[6]);
0029   const int fRange          = atoi(argv[7]);
0030   
0031   // Reading Tree                                                                                   
0032   std::cout << "---------------------" << std::endl;
0033   std::cout << "Reading List of input trees from " << inputFileList << std::endl;
0034 
0035   //  bool debug=true;
0036   bool debug=false;
0037   const char *ranges[15] = {"0to5",     "5to15",    "15to30",   "30to50",
0038                 "50to80",   "80to120",  "120to170", "170to300", 
0039                 "300to470", "470to600", "600to800", "800to1000", 
0040                 "1000to1400", "1400to1800", "1800"};
0041   
0042   double evFrac[15]      = {4.844e10, 3.675e10, 8.159e08, 5.312e07, 
0043                 6.359e06, 7.843e05, 1.151e05, 2.426e04, 
0044                 1.168e03, 7.022e01, 1.555e01, 1.844, 
0045                 3.321e-01, 1.087e-02, 3.575e-04};
0046   double nEvents[15]     = {1082851, 1649302, 6582850, 10999212,  
0047                 6599873, 6589860, 6127443, 5593629,
0048                 6255698, 3890287, 3379490, 3585297,
0049                 2051327, 2196167, 293135 };
0050 
0051   std::vector<std::string> Ranges, rangesV;
0052   std::vector<double>      fraction, events;
0053   for(int i=0; i<15; i++) rangesV.push_back(ranges[i]);
0054   if (iRange != fRange) {
0055     for (unsigned int i=iRange; i<=fRange; i++) {
0056       Ranges.push_back(ranges[i]);
0057       fraction.push_back(evFrac[i]);
0058       events.push_back(nEvents[i]);
0059       if(debug) std::cout<< "range " << ranges[i] <<" fraction " <<  evFrac[i] << " nevents " << nEvents[i] << std::endl;
0060     }
0061   } else {
0062     Ranges.push_back(ranges[iRange]);
0063     fraction.push_back(1.0);
0064     events.push_back(totalTracks);
0065     std::cout << "range " << iRange << std::endl;
0066   }
0067   
0068   TreeAnalysisReadGen tree(outFileName, rangesV);
0069   tree.debug  = debug;
0070   tree.l1Name = name;
0071   tree.dRCut  = atof(DRCut);
0072   tree.iRange = iRange;
0073   tree.fRange = fRange;
0074   for (unsigned int i=0; i<Ranges.size(); i++) {
0075     char fileList[200], treeName[200];
0076     sprintf (fileList, "%s_%s.txt", inputFileList, Ranges[i].c_str());
0077     std::cout << "try to create a chain for " << fileList << std::endl;
0078     TChain *chain = new TChain("/isolatedGenParticles/tree");
0079     if( ! FillChain(chain, fileList) ) {
0080       std::cerr << "Cannot get the tree " << std::endl;
0081       return(0);
0082     } else {
0083       tree.Init(chain);
0084       tree.setRange(i+iRange);
0085       tree.Loop();
0086       tree.weights[i]= (fraction[i]*totalTracks)/events[i];
0087       std::cout << "range " << Ranges[i].c_str() << " cross-section " << fraction[i] << " nevents  " << events[i] << " weight " << tree.weights[i] << std::endl;
0088       tree.clear();
0089       std::cout << iRange << " tree cleared" << std::endl;
0090     }
0091   }
0092   std::cout << "Here I am " << iRange << ":" << fRange << std::endl;
0093   if (iRange != fRange) tree.AddWeight();
0094   return 0;
0095 }
0096 
0097 
0098 Bool_t FillChain(TChain *chain, const TString &inputFileList) {
0099 
0100   ifstream infile(inputFileList);
0101   std::string buffer;
0102 
0103   if(!infile.is_open()) {
0104     std::cerr << "** ERROR: Can't open '" << inputFileList << "' for input" << std::endl;
0105     return kFALSE;
0106   }
0107   
0108   std::cout << "TreeUtilities : FillChain " << std::endl;
0109   while(1) {
0110     infile >> buffer;
0111     if(!infile.good()) break;
0112     //std::cout << "Adding tree from " << buffer.c_str() << std::endl;
0113     chain->Add(buffer.c_str());
0114     //std::cout << "No. of Entries in this tree : " << chain->GetEntries() << std::endl;
0115   }
0116   return kTRUE;
0117 }
0118 
0119 TreeAnalysisReadGen::TreeAnalysisReadGen(const char *outFileName, std::vector<std::string>& ranges) {
0120 
0121   double tempgen_TH[NPBins+1] = { 0.0,  1.0,  2.0,  3.0,  4.0,  
0122                   5.0,  6.0,  7.0,  8.0,  9.0, 
0123                   10.0, 12.0, 15.0, 20.0, 25.0, 
0124                   30.0, 40.0, 60.0, 70.0, 80.0, 100., 200.};
0125 
0126   for(int i=0; i<NPBins+1; i++)  genPartPBins[i]  = tempgen_TH[i];
0127   
0128   double tempgen_Eta[NEtaBins+1] = {0.0, 0.5, 1.1, 1.7, 2.3};
0129 
0130   for(int i=0; i<NEtaBins+1; i++) genPartEtaBins[i] = tempgen_Eta[i];
0131 
0132   // if parameter tree is not specified (or zero), connect the file
0133   // used to generate this class and read the Tree.
0134   //  Init(tree);  
0135   BookHistograms(outFileName, ranges);
0136 }
0137 
0138 TreeAnalysisReadGen::~TreeAnalysisReadGen() {
0139   if (!fChain) return;
0140 
0141   fout->cd();
0142   fout->Write();
0143   fout->Close();
0144   std::cout << "after Close\n";
0145   //  delete fChain->GetCurrentFile();
0146 }
0147 
0148 Int_t TreeAnalysisReadGen::Cut(Long64_t entry) {
0149   // This function may be called from Loop.
0150   // returns  1 if entry is accepted.
0151   // returns -1 otherwise.
0152   return 1;
0153 }
0154 
0155 Int_t TreeAnalysisReadGen::GetEntry(Long64_t entry) {
0156 
0157   // Read contents of entry.
0158   if (!fChain) return 0;
0159   return fChain->GetEntry(entry);
0160 }
0161 
0162 Long64_t TreeAnalysisReadGen::LoadTree(Long64_t entry) {
0163   // Set the environment to read one entry
0164   if (!fChain) return -5;
0165   Long64_t centry = fChain->LoadTree(entry);
0166   if (centry < 0) return centry;
0167   if (!fChain->InheritsFrom(TChain::Class()))  return centry;
0168   TChain *chain = (TChain*)fChain;
0169   if (chain->GetTreeNumber() != fCurrent) {
0170     fCurrent = chain->GetTreeNumber();
0171     Notify();
0172   }
0173   return centry;
0174 }
0175 
0176 void TreeAnalysisReadGen::Init(TChain *tree) {
0177   // The Init() function is called when the selector needs to initialize
0178   // a new tree or chain. Typically here the branch addresses and branch
0179   // pointers of the tree will be set.
0180   // It is normally not necessary to make changes to the generated
0181   // code, but the routine can be extended by the user if needed.
0182   // Init() will be called many times when running on PROOF
0183   // (once per file to be processed).
0184 
0185   // Set object pointer
0186   t_isoTrkPAll = 0;
0187   t_isoTrkPtAll = 0;
0188   t_isoTrkPhiAll = 0;
0189   t_isoTrkEtaAll = 0;
0190   t_isoTrkDPhiAll = 0;
0191   t_isoTrkDEtaAll = 0;
0192   t_isoTrkPdgIdAll = 0;
0193   t_isoTrkP = 0;
0194   t_isoTrkPt = 0;
0195   t_isoTrkEne = 0;
0196   t_isoTrkEta = 0;
0197   t_isoTrkPhi = 0;
0198   t_isoTrkPdgId = 0;
0199   t_maxNearP31x31 = 0;
0200   t_cHadronEne31x31 = 0;
0201   t_cHadronEne31x31_1 = 0;
0202   t_cHadronEne31x31_2 = 0;
0203   t_cHadronEne31x31_3 = 0;
0204   t_nHadronEne31x31 = 0;
0205   t_photonEne31x31 = 0;
0206   t_eleEne31x31 = 0;
0207   t_muEne31x31 = 0;
0208   t_maxNearP25x25 = 0;
0209   t_cHadronEne25x25 = 0;
0210   t_cHadronEne25x25_1 = 0;
0211   t_cHadronEne25x25_2 = 0;
0212   t_cHadronEne25x25_3 = 0;
0213   t_nHadronEne25x25 = 0;
0214   t_photonEne25x25 = 0;
0215   t_eleEne25x25 = 0;
0216   t_muEne25x25 = 0;
0217   t_maxNearP21x21 = 0;
0218   t_cHadronEne21x21 = 0;
0219   t_cHadronEne21x21_1 = 0;
0220   t_cHadronEne21x21_2 = 0;
0221   t_cHadronEne21x21_3 = 0;
0222   t_nHadronEne21x21 = 0;
0223   t_photonEne21x21 = 0;
0224   t_eleEne21x21 = 0;
0225   t_muEne21x21 = 0;
0226   t_maxNearP15x15 = 0;
0227   t_cHadronEne15x15 = 0;
0228   t_cHadronEne15x15_1 = 0;
0229   t_cHadronEne15x15_2 = 0;
0230   t_cHadronEne15x15_3 = 0;
0231   t_nHadronEne15x15 = 0;
0232   t_photonEne15x15 = 0;
0233   t_eleEne15x15 = 0;
0234   t_muEne15x15 = 0;
0235   t_maxNearP11x11 = 0;
0236   t_cHadronEne11x11 = 0;
0237   t_cHadronEne11x11_1 = 0;
0238   t_cHadronEne11x11_2 = 0;
0239   t_cHadronEne11x11_3 = 0;
0240   t_nHadronEne11x11 = 0;
0241   t_photonEne11x11 = 0;
0242   t_eleEne11x11 = 0;
0243   t_muEne11x11 = 0;
0244   t_maxNearP9x9 = 0;
0245   t_cHadronEne9x9 = 0;
0246   t_cHadronEne9x9_1 = 0;
0247   t_cHadronEne9x9_2 = 0;
0248   t_cHadronEne9x9_3 = 0;
0249   t_nHadronEne9x9 = 0;
0250   t_photonEne9x9 = 0;
0251   t_eleEne9x9 = 0;
0252   t_muEne9x9 = 0;
0253   t_maxNearP7x7 = 0;
0254   t_cHadronEne7x7 = 0;
0255   t_cHadronEne7x7_1 = 0;
0256   t_cHadronEne7x7_2 = 0;
0257   t_cHadronEne7x7_3 = 0;
0258   t_nHadronEne7x7 = 0;
0259   t_photonEne7x7 = 0;
0260   t_eleEne7x7 = 0;
0261   t_muEne7x7 = 0;
0262   t_maxNearPHC3x3 = 0;
0263   t_cHadronEneHC3x3 = 0;
0264   t_cHadronEneHC3x3_1 = 0;
0265   t_cHadronEneHC3x3_2 = 0;
0266   t_cHadronEneHC3x3_3 = 0;
0267   t_nHadronEneHC3x3 = 0;
0268   t_photonEneHC3x3 = 0;
0269   t_eleEneHC3x3 = 0;
0270   t_muEneHC3x3 = 0;
0271   t_maxNearPHC5x5 = 0;
0272   t_cHadronEneHC5x5 = 0;
0273   t_cHadronEneHC5x5_1 = 0;
0274   t_cHadronEneHC5x5_2 = 0;
0275   t_cHadronEneHC5x5_3 = 0;
0276   t_nHadronEneHC5x5 = 0;
0277   t_photonEneHC5x5 = 0;
0278   t_eleEneHC5x5 = 0;
0279   t_muEneHC5x5 = 0;
0280 
0281   t_maxNearPHC7x7 = 0;
0282   t_cHadronEneHC7x7 = 0;
0283   t_cHadronEneHC7x7_1 = 0;
0284   t_cHadronEneHC7x7_2 = 0;
0285   t_cHadronEneHC7x7_3 = 0;
0286   t_nHadronEneHC7x7 = 0;
0287   t_photonEneHC7x7 = 0;
0288   t_eleEneHC7x7 = 0;
0289   t_muEneHC7x7 = 0;
0290 
0291   t_maxNearPR     = 0;
0292   t_cHadronEneR   = 0;
0293   t_cHadronEneR_1 = 0;
0294   t_cHadronEneR_2 = 0;
0295   t_cHadronEneR_3 = 0;
0296   t_nHadronEneR   = 0;
0297   t_photonEneR    = 0;
0298   t_eleEneR       = 0;
0299   t_muEneR        = 0;
0300 
0301   t_maxNearPIsoR     = 0;
0302   t_cHadronEneIsoR   = 0;
0303   t_cHadronEneIsoR_1 = 0;
0304   t_cHadronEneIsoR_2 = 0;
0305   t_cHadronEneIsoR_3 = 0;
0306   t_nHadronEneIsoR   = 0;
0307   t_photonEneIsoR    = 0;
0308   t_eleEneIsoR       = 0;
0309   t_muEneIsoR        = 0;
0310   
0311    t_maxNearPHCR     = 0;
0312   t_cHadronEneHCR   = 0;
0313   t_cHadronEneHCR_1 = 0;
0314   t_cHadronEneHCR_2 = 0;
0315   t_cHadronEneHCR_3 = 0;
0316   t_nHadronEneHCR   = 0;
0317   t_photonEneHCR    = 0;
0318   t_eleEneHCR       = 0;
0319   t_muEneHCR        = 0;
0320 
0321   t_maxNearPIsoHCR     = 0;
0322   t_cHadronEneIsoHCR   = 0;
0323   t_cHadronEneIsoHCR_1 = 0;
0324   t_cHadronEneIsoHCR_2 = 0;
0325   t_cHadronEneIsoHCR_3 = 0;
0326   t_nHadronEneIsoHCR   = 0;
0327   t_photonEneIsoHCR    = 0;
0328   t_eleEneIsoHCR       = 0;
0329   t_muEneIsoHCR        = 0;
0330 
0331   t_L1Decision = 0;
0332   t_L1CenJetPt = 0;
0333   t_L1CenJetEta = 0;
0334   t_L1CenJetPhi = 0;
0335   t_L1FwdJetPt = 0;
0336   t_L1FwdJetEta = 0;
0337   t_L1FwdJetPhi = 0;
0338   t_L1TauJetPt = 0;
0339   t_L1TauJetEta = 0;
0340   t_L1TauJetPhi = 0;
0341   t_L1MuonPt = 0;
0342   t_L1MuonEta = 0;
0343   t_L1MuonPhi = 0;
0344   t_L1IsoEMPt = 0;
0345   t_L1IsoEMEta = 0;
0346   t_L1IsoEMPhi = 0;
0347   t_L1NonIsoEMPt = 0;
0348   t_L1NonIsoEMEta = 0;
0349   t_L1NonIsoEMPhi = 0;
0350   t_L1METPt = 0;
0351   t_L1METEta = 0;
0352   t_L1METPhi = 0;
0353   // Set branch addresses and branch pointers
0354   if (!tree) return;
0355   fChain = tree;
0356   fCurrent = -1;
0357   fChain->SetMakeClass(1);
0358   
0359   fChain->SetBranchAddress("t_isoTrkPAll", &t_isoTrkPAll, &b_t_isoTrkPAll);
0360   fChain->SetBranchAddress("t_isoTrkPtAll", &t_isoTrkPtAll, &b_t_isoTrkPtAll);
0361   fChain->SetBranchAddress("t_isoTrkPhiAll", &t_isoTrkPhiAll, &b_t_isoTrkPhiAll);
0362   fChain->SetBranchAddress("t_isoTrkEtaAll", &t_isoTrkEtaAll, &b_t_isoTrkEtaAll);
0363   fChain->SetBranchAddress("t_isoTrkDPhiAll", &t_isoTrkDPhiAll, &b_t_isoTrkDPhiAll);
0364   fChain->SetBranchAddress("t_isoTrkDEtaAll", &t_isoTrkDEtaAll, &b_t_isoTrkDEtaAll);
0365   fChain->SetBranchAddress("t_isoTrkPdgIdAll", &t_isoTrkPdgIdAll, &b_t_isoTrkPdgIdAll);
0366   fChain->SetBranchAddress("t_isoTrkP", &t_isoTrkP, &b_t_isoTrkP);
0367   fChain->SetBranchAddress("t_isoTrkPt", &t_isoTrkPt, &b_t_isoTrkPt);
0368   fChain->SetBranchAddress("t_isoTrkEne", &t_isoTrkEne, &b_t_isoTrkEne);
0369   fChain->SetBranchAddress("t_isoTrkEta", &t_isoTrkEta, &b_t_isoTrkEta);
0370   fChain->SetBranchAddress("t_isoTrkPhi", &t_isoTrkPhi, &b_t_isoTrkPhi);
0371   fChain->SetBranchAddress("t_isoTrkPdgId", &t_isoTrkPdgId, &b_t_isoTrkPdgId);
0372   fChain->SetBranchAddress("t_maxNearP31x31", &t_maxNearP31x31, &b_t_maxNearP31x31);
0373   fChain->SetBranchAddress("t_cHadronEne31x31", &t_cHadronEne31x31, &b_t_cHadronEne31x31);
0374   fChain->SetBranchAddress("t_cHadronEne31x31_1", &t_cHadronEne31x31_1, &b_t_cHadronEne31x31_1);
0375   fChain->SetBranchAddress("t_cHadronEne31x31_2", &t_cHadronEne31x31_2, &b_t_cHadronEne31x31_2);
0376   fChain->SetBranchAddress("t_cHadronEne31x31_3", &t_cHadronEne31x31_3, &b_t_cHadronEne31x31_3);
0377   fChain->SetBranchAddress("t_nHadronEne31x31", &t_nHadronEne31x31, &b_t_nHadronEne31x31);
0378   fChain->SetBranchAddress("t_photonEne31x31", &t_photonEne31x31, &b_t_photonEne31x31);
0379   fChain->SetBranchAddress("t_eleEne31x31", &t_eleEne31x31, &b_t_eleEne31x31);
0380   fChain->SetBranchAddress("t_muEne31x31", &t_muEne31x31, &b_t_muEne31x31);
0381   fChain->SetBranchAddress("t_maxNearP25x25", &t_maxNearP25x25, &b_t_maxNearP25x25);
0382   fChain->SetBranchAddress("t_cHadronEne25x25", &t_cHadronEne25x25, &b_t_cHadronEne25x25);
0383   fChain->SetBranchAddress("t_cHadronEne25x25_1", &t_cHadronEne25x25_1, &b_t_cHadronEne25x25_1);
0384   fChain->SetBranchAddress("t_cHadronEne25x25_2", &t_cHadronEne25x25_2, &b_t_cHadronEne25x25_2);
0385   fChain->SetBranchAddress("t_cHadronEne25x25_3", &t_cHadronEne25x25_3, &b_t_cHadronEne25x25_3);
0386   fChain->SetBranchAddress("t_nHadronEne25x25", &t_nHadronEne25x25, &b_t_nHadronEne25x25);
0387   fChain->SetBranchAddress("t_photonEne25x25", &t_photonEne25x25, &b_t_photonEne25x25);
0388   fChain->SetBranchAddress("t_eleEne25x25", &t_eleEne25x25, &b_t_eleEne25x25);
0389   fChain->SetBranchAddress("t_muEne25x25", &t_muEne25x25, &b_t_muEne25x25);
0390   fChain->SetBranchAddress("t_maxNearP21x21", &t_maxNearP21x21, &b_t_maxNearP21x21);
0391   fChain->SetBranchAddress("t_cHadronEne21x21", &t_cHadronEne21x21, &b_t_cHadronEne21x21);
0392   fChain->SetBranchAddress("t_cHadronEne21x21_1", &t_cHadronEne21x21_1, &b_t_cHadronEne21x21_1);
0393   fChain->SetBranchAddress("t_cHadronEne21x21_2", &t_cHadronEne21x21_2, &b_t_cHadronEne21x21_2);
0394   fChain->SetBranchAddress("t_cHadronEne21x21_3", &t_cHadronEne21x21_3, &b_t_cHadronEne21x21_3);
0395   fChain->SetBranchAddress("t_nHadronEne21x21", &t_nHadronEne21x21, &b_t_nHadronEne21x21);
0396   fChain->SetBranchAddress("t_photonEne21x21", &t_photonEne21x21, &b_t_photonEne21x21);
0397   fChain->SetBranchAddress("t_eleEne21x21", &t_eleEne21x21, &b_t_eleEne21x21);
0398   fChain->SetBranchAddress("t_muEne21x21", &t_muEne21x21, &b_t_muEne21x21);
0399   fChain->SetBranchAddress("t_maxNearP15x15", &t_maxNearP15x15, &b_t_maxNearP15x15);
0400   fChain->SetBranchAddress("t_cHadronEne15x15", &t_cHadronEne15x15, &b_t_cHadronEne15x15);
0401   fChain->SetBranchAddress("t_cHadronEne15x15_1", &t_cHadronEne15x15_1, &b_t_cHadronEne15x15_1);
0402   fChain->SetBranchAddress("t_cHadronEne15x15_2", &t_cHadronEne15x15_2, &b_t_cHadronEne15x15_2);
0403   fChain->SetBranchAddress("t_cHadronEne15x15_3", &t_cHadronEne15x15_3, &b_t_cHadronEne15x15_3);
0404   fChain->SetBranchAddress("t_nHadronEne15x15", &t_nHadronEne15x15, &b_t_nHadronEne15x15);
0405   fChain->SetBranchAddress("t_photonEne15x15", &t_photonEne15x15, &b_t_photonEne15x15);
0406   fChain->SetBranchAddress("t_eleEne15x15", &t_eleEne15x15, &b_t_eleEne15x15);
0407   fChain->SetBranchAddress("t_muEne15x15", &t_muEne15x15, &b_t_muEne15x15);
0408   fChain->SetBranchAddress("t_maxNearP11x11", &t_maxNearP11x11, &b_t_maxNearP11x11);
0409   fChain->SetBranchAddress("t_cHadronEne11x11", &t_cHadronEne11x11, &b_t_cHadronEne11x11);
0410   fChain->SetBranchAddress("t_cHadronEne11x11_1", &t_cHadronEne11x11_1, &b_t_cHadronEne11x11_1);
0411   fChain->SetBranchAddress("t_cHadronEne11x11_2", &t_cHadronEne11x11_2, &b_t_cHadronEne11x11_2);
0412   fChain->SetBranchAddress("t_cHadronEne11x11_3", &t_cHadronEne11x11_3, &b_t_cHadronEne11x11_3);
0413   fChain->SetBranchAddress("t_nHadronEne11x11", &t_nHadronEne11x11, &b_t_nHadronEne11x11);
0414   fChain->SetBranchAddress("t_photonEne11x11", &t_photonEne11x11, &b_t_photonEne11x11);
0415   fChain->SetBranchAddress("t_eleEne11x11", &t_eleEne11x11, &b_t_eleEne11x11);
0416   fChain->SetBranchAddress("t_muEne11x11", &t_muEne11x11, &b_t_muEne11x11);
0417   fChain->SetBranchAddress("t_maxNearP9x9", &t_maxNearP9x9, &b_t_maxNearP9x9);
0418   fChain->SetBranchAddress("t_cHadronEne9x9", &t_cHadronEne9x9, &b_t_cHadronEne9x9);
0419   fChain->SetBranchAddress("t_cHadronEne9x9_1", &t_cHadronEne9x9_1, &b_t_cHadronEne9x9_1);
0420   fChain->SetBranchAddress("t_cHadronEne9x9_2", &t_cHadronEne9x9_2, &b_t_cHadronEne9x9_2);
0421   fChain->SetBranchAddress("t_cHadronEne9x9_3", &t_cHadronEne9x9_3, &b_t_cHadronEne9x9_3);
0422   fChain->SetBranchAddress("t_nHadronEne9x9", &t_nHadronEne9x9, &b_t_nHadronEne9x9);
0423   fChain->SetBranchAddress("t_photonEne9x9", &t_photonEne9x9, &b_t_photonEne9x9);
0424   fChain->SetBranchAddress("t_eleEne9x9", &t_eleEne9x9, &b_t_eleEne9x9);
0425   fChain->SetBranchAddress("t_muEne9x9", &t_muEne9x9, &b_t_muEne9x9);
0426   fChain->SetBranchAddress("t_maxNearP7x7", &t_maxNearP7x7, &b_t_maxNearP7x7);
0427   fChain->SetBranchAddress("t_cHadronEne7x7", &t_cHadronEne7x7, &b_t_cHadronEne7x7);
0428   fChain->SetBranchAddress("t_cHadronEne7x7_1", &t_cHadronEne7x7_1, &b_t_cHadronEne7x7_1);
0429   fChain->SetBranchAddress("t_cHadronEne7x7_2", &t_cHadronEne7x7_2, &b_t_cHadronEne7x7_2);
0430   fChain->SetBranchAddress("t_cHadronEne7x7_3", &t_cHadronEne7x7_3, &b_t_cHadronEne7x7_3);
0431   fChain->SetBranchAddress("t_nHadronEne7x7", &t_nHadronEne7x7, &b_t_nHadronEne7x7);
0432   fChain->SetBranchAddress("t_photonEne7x7", &t_photonEne7x7, &b_t_photonEne7x7);
0433   fChain->SetBranchAddress("t_eleEne7x7", &t_eleEne7x7, &b_t_eleEne7x7);
0434   fChain->SetBranchAddress("t_muEne7x7", &t_muEne7x7, &b_t_muEne7x7);
0435   fChain->SetBranchAddress("t_maxNearPHC3x3", &t_maxNearPHC3x3, &b_t_maxNearPHC3x3);
0436   fChain->SetBranchAddress("t_cHadronEneHC3x3", &t_cHadronEneHC3x3, &b_t_cHadronEneHC3x3);
0437   fChain->SetBranchAddress("t_cHadronEneHC3x3_1", &t_cHadronEneHC3x3_1, &b_t_cHadronEneHC3x3_1);
0438   fChain->SetBranchAddress("t_cHadronEneHC3x3_2", &t_cHadronEneHC3x3_2, &b_t_cHadronEneHC3x3_2);
0439   fChain->SetBranchAddress("t_cHadronEneHC3x3_3", &t_cHadronEneHC3x3_3, &b_t_cHadronEneHC3x3_3);
0440   fChain->SetBranchAddress("t_nHadronEneHC3x3", &t_nHadronEneHC3x3, &b_t_nHadronEneHC3x3);
0441   fChain->SetBranchAddress("t_photonEneHC3x3", &t_photonEneHC3x3, &b_t_photonEneHC3x3);
0442   fChain->SetBranchAddress("t_eleEneHC3x3", &t_eleEneHC3x3, &b_t_eleEneHC3x3);
0443   fChain->SetBranchAddress("t_muEneHC3x3", &t_muEneHC3x3, &b_t_muEneHC3x3);
0444   fChain->SetBranchAddress("t_maxNearPHC5x5", &t_maxNearPHC5x5, &b_t_maxNearPHC5x5);
0445   fChain->SetBranchAddress("t_cHadronEneHC5x5", &t_cHadronEneHC5x5, &b_t_cHadronEneHC5x5);
0446   fChain->SetBranchAddress("t_cHadronEneHC5x5_1", &t_cHadronEneHC5x5_1, &b_t_cHadronEneHC5x5_1);
0447   fChain->SetBranchAddress("t_cHadronEneHC5x5_2", &t_cHadronEneHC5x5_2, &b_t_cHadronEneHC5x5_2);
0448   fChain->SetBranchAddress("t_cHadronEneHC5x5_3", &t_cHadronEneHC5x5_3, &b_t_cHadronEneHC5x5_3);
0449   fChain->SetBranchAddress("t_nHadronEneHC5x5", &t_nHadronEneHC5x5, &b_t_nHadronEneHC5x5);
0450   fChain->SetBranchAddress("t_photonEneHC5x5", &t_photonEneHC5x5, &b_t_photonEneHC5x5);
0451   fChain->SetBranchAddress("t_eleEneHC5x5", &t_eleEneHC5x5, &b_t_eleEneHC5x5);
0452   fChain->SetBranchAddress("t_muEneHC5x5", &t_muEneHC5x5, &b_t_muEneHC5x5);
0453   fChain->SetBranchAddress("t_maxNearPHC7x7", &t_maxNearPHC7x7, &b_t_maxNearPHC7x7);
0454   fChain->SetBranchAddress("t_cHadronEneHC7x7", &t_cHadronEneHC7x7, &b_t_cHadronEneHC7x7);
0455   fChain->SetBranchAddress("t_cHadronEneHC7x7_1", &t_cHadronEneHC7x7_1, &b_t_cHadronEneHC7x7_1);
0456   fChain->SetBranchAddress("t_cHadronEneHC7x7_2", &t_cHadronEneHC7x7_2, &b_t_cHadronEneHC7x7_2);
0457   fChain->SetBranchAddress("t_cHadronEneHC7x7_3", &t_cHadronEneHC7x7_3, &b_t_cHadronEneHC7x7_3);
0458   fChain->SetBranchAddress("t_nHadronEneHC7x7", &t_nHadronEneHC7x7, &b_t_nHadronEneHC7x7);
0459   fChain->SetBranchAddress("t_photonEneHC7x7", &t_photonEneHC7x7, &b_t_photonEneHC7x7);
0460   fChain->SetBranchAddress("t_eleEneHC7x7", &t_eleEneHC7x7, &b_t_eleEneHC7x7);
0461   fChain->SetBranchAddress("t_muEneHC7x7", &t_muEneHC7x7, &b_t_muEneHC7x7);
0462   fChain->SetBranchAddress("t_maxNearPR", &t_maxNearPR, &b_t_maxNearPR);
0463   fChain->SetBranchAddress("t_cHadronEneR", &t_cHadronEneR, &b_t_cHadronEneR);
0464   fChain->SetBranchAddress("t_cHadronEneR_1", &t_cHadronEneR_1, &b_t_cHadronEneR_1);
0465   fChain->SetBranchAddress("t_cHadronEneR_2", &t_cHadronEneR_2, &b_t_cHadronEneR_2);
0466   fChain->SetBranchAddress("t_cHadronEneR_3", &t_cHadronEneR_3, &b_t_cHadronEneR_3);
0467   fChain->SetBranchAddress("t_nHadronEneR", &t_nHadronEneR, &b_t_nHadronEneR);
0468   fChain->SetBranchAddress("t_photonEneR", &t_photonEneR, &b_t_photonEneR);
0469   fChain->SetBranchAddress("t_eleEneR", &t_eleEneR, &b_t_eleEneR);
0470   fChain->SetBranchAddress("t_muEneR", &t_muEneR, &b_t_muEneR);
0471   fChain->SetBranchAddress("t_maxNearPIsoR", &t_maxNearPIsoR, &b_t_maxNearPIsoR);
0472   fChain->SetBranchAddress("t_cHadronEneIsoR", &t_cHadronEneIsoR, &b_t_cHadronEneIsoR);
0473   fChain->SetBranchAddress("t_cHadronEneIsoR_1", &t_cHadronEneIsoR_1, &b_t_cHadronEneIsoR_1);
0474   fChain->SetBranchAddress("t_cHadronEneIsoR_2", &t_cHadronEneIsoR_2, &b_t_cHadronEneIsoR_2);
0475   fChain->SetBranchAddress("t_cHadronEneIsoR_3", &t_cHadronEneIsoR_3, &b_t_cHadronEneIsoR_3);
0476   fChain->SetBranchAddress("t_nHadronEneIsoR", &t_nHadronEneIsoR, &b_t_nHadronEneIsoR);
0477   fChain->SetBranchAddress("t_photonEneIsoR", &t_photonEneIsoR, &b_t_photonEneIsoR);
0478   fChain->SetBranchAddress("t_eleEneIsoR", &t_eleEneIsoR, &b_t_eleEneIsoR);
0479   fChain->SetBranchAddress("t_muEneIsoR", &t_muEneIsoR, &b_t_muEneIsoR);
0480   fChain->SetBranchAddress("t_maxNearPHCR", &t_maxNearPHCR, &b_t_maxNearPHCR);
0481   fChain->SetBranchAddress("t_cHadronEneHCR", &t_cHadronEneHCR, &b_t_cHadronEneHCR);
0482   fChain->SetBranchAddress("t_cHadronEneHCR_1", &t_cHadronEneHCR_1, &b_t_cHadronEneHCR_1);
0483   fChain->SetBranchAddress("t_cHadronEneHCR_2", &t_cHadronEneHCR_2, &b_t_cHadronEneHCR_2);
0484   fChain->SetBranchAddress("t_cHadronEneHCR_3", &t_cHadronEneHCR_3, &b_t_cHadronEneHCR_3);
0485   fChain->SetBranchAddress("t_nHadronEneHCR", &t_nHadronEneHCR, &b_t_nHadronEneHCR);
0486   fChain->SetBranchAddress("t_photonEneHCR", &t_photonEneHCR, &b_t_photonEneHCR);
0487   fChain->SetBranchAddress("t_eleEneHCR", &t_eleEneHCR, &b_t_eleEneHCR);
0488   fChain->SetBranchAddress("t_muEneHCR", &t_muEneHCR, &b_t_muEneHCR);
0489   fChain->SetBranchAddress("t_maxNearPIsoHCR", &t_maxNearPIsoHCR, &b_t_maxNearPIsoHCR);
0490   fChain->SetBranchAddress("t_cHadronEneIsoHCR", &t_cHadronEneIsoHCR, &b_t_cHadronEneIsoHCR);
0491   fChain->SetBranchAddress("t_cHadronEneIsoHCR_1", &t_cHadronEneIsoHCR_1, &b_t_cHadronEneIsoHCR_1);
0492   fChain->SetBranchAddress("t_cHadronEneIsoHCR_2", &t_cHadronEneIsoHCR_2, &b_t_cHadronEneIsoHCR_2);
0493   fChain->SetBranchAddress("t_cHadronEneIsoHCR_3", &t_cHadronEneIsoHCR_3, &b_t_cHadronEneIsoHCR_3);
0494   fChain->SetBranchAddress("t_nHadronEneIsoHCR", &t_nHadronEneIsoHCR, &b_t_nHadronEneIsoHCR);
0495   fChain->SetBranchAddress("t_photonEneIsoHCR", &t_photonEneIsoHCR, &b_t_photonEneIsoHCR);
0496   fChain->SetBranchAddress("t_eleEneIsoHCR", &t_eleEneIsoHCR, &b_t_eleEneIsoHCR);
0497   fChain->SetBranchAddress("t_muEneIsoHCR", &t_muEneIsoHCR, &b_t_muEneIsoHCR);
0498   fChain->SetBranchAddress("t_L1Decision", &t_L1Decision, &b_t_L1Decision);
0499   fChain->SetBranchAddress("t_L1CenJetPt", &t_L1CenJetPt, &b_t_L1CenJetPt);
0500   fChain->SetBranchAddress("t_L1CenJetEta", &t_L1CenJetEta, &b_t_L1CenJetEta);
0501   fChain->SetBranchAddress("t_L1CenJetPhi", &t_L1CenJetPhi, &b_t_L1CenJetPhi);
0502   fChain->SetBranchAddress("t_L1FwdJetPt", &t_L1FwdJetPt, &b_t_L1FwdJetPt);
0503   fChain->SetBranchAddress("t_L1FwdJetEta", &t_L1FwdJetEta, &b_t_L1FwdJetEta);
0504   fChain->SetBranchAddress("t_L1FwdJetPhi", &t_L1FwdJetPhi, &b_t_L1FwdJetPhi);
0505   fChain->SetBranchAddress("t_L1TauJetPt", &t_L1TauJetPt, &b_t_L1TauJetPt);
0506   fChain->SetBranchAddress("t_L1TauJetEta", &t_L1TauJetEta, &b_t_L1TauJetEta);
0507   fChain->SetBranchAddress("t_L1TauJetPhi", &t_L1TauJetPhi, &b_t_L1TauJetPhi);
0508   fChain->SetBranchAddress("t_L1MuonPt", &t_L1MuonPt, &b_t_L1MuonPt);
0509   fChain->SetBranchAddress("t_L1MuonEta", &t_L1MuonEta, &b_t_L1MuonEta);
0510   fChain->SetBranchAddress("t_L1MuonPhi", &t_L1MuonPhi, &b_t_L1MuonPhi);
0511   fChain->SetBranchAddress("t_L1IsoEMPt", &t_L1IsoEMPt, &b_t_L1IsoEMPt);
0512   fChain->SetBranchAddress("t_L1IsoEMEta", &t_L1IsoEMEta, &b_t_L1IsoEMEta);
0513   fChain->SetBranchAddress("t_L1IsoEMPhi", &t_L1IsoEMPhi, &b_t_L1IsoEMPhi);
0514   fChain->SetBranchAddress("t_L1NonIsoEMPt", &t_L1NonIsoEMPt, &b_t_L1NonIsoEMPt);
0515   fChain->SetBranchAddress("t_L1NonIsoEMEta", &t_L1NonIsoEMEta, &b_t_L1NonIsoEMEta);
0516   fChain->SetBranchAddress("t_L1NonIsoEMPhi", &t_L1NonIsoEMPhi, &b_t_L1NonIsoEMPhi);
0517   fChain->SetBranchAddress("t_L1METPt", &t_L1METPt, &b_t_L1METPt);
0518   fChain->SetBranchAddress("t_L1METEta", &t_L1METEta, &b_t_L1METEta);
0519   fChain->SetBranchAddress("t_L1METPhi", &t_L1METPhi, &b_t_L1METPhi);
0520   Notify();
0521 }
0522 
0523 void TreeAnalysisReadGen::Loop() {
0524   
0525   getL1Names();
0526   int ibit = -1;
0527   for (std::map<std::string,int>::iterator it=l1Names.begin(); it != l1Names.end(); ++it) {
0528     if (!strcmp(l1Name.c_str(),(it->first).c_str())) {
0529       ibit =(it->second);
0530       break;
0531     }
0532   }
0533   if (debug) std::cout << "liName " << l1Name.c_str() << " " << ibit << std::endl;  
0534 
0535   if (fChain == 0) return;  
0536   Long64_t nentries = fChain->GetEntries();
0537   std::cout << "No. of Entries in tree " << nentries << std::endl;
0538   
0539   Long64_t nbytes = 0, nb = 0;
0540   unsigned int nTrk=0;    
0541   unsigned int nTrk_Bins=0;    
0542   unsigned int nTrk_maxNearP=0;
0543   unsigned int nIsoTrk=0;
0544   for (Long64_t jentry=0; jentry<nentries;jentry++) {
0545     
0546     Long64_t ientry = LoadTree(jentry);
0547     if (ientry < 0) break;
0548     nb = fChain->GetEntry(jentry);   nbytes += nb;
0549     
0550     if( !(jentry%100000) )
0551       std::cout << "processing event " << jentry+1 << std::endl;
0552     
0553     // get the inclusive distributions here
0554     for(int itrk=0; itrk<t_isoTrkPAll->size(); itrk++ ){
0555       double p     = (*t_isoTrkPAll)    [itrk];
0556       double pt    = (*t_isoTrkPtAll)   [itrk];
0557       double eta   = (*t_isoTrkEtaAll)  [itrk];
0558       double phi   = (*t_isoTrkPhiAll)  [itrk];
0559       double pdgid = (*t_isoTrkPdgIdAll)[itrk];
0560       double deta  = (*t_isoTrkDEtaAll) [itrk];
0561       double dphi  = (*t_isoTrkDPhiAll) [itrk];
0562       
0563       if (debug) std::cout << "p " << p << " pt " << pt << " eta " << eta << " phi " << phi << " pdgid " << pdgid << " deta " << deta << " dphi " << dphi << std::endl;
0564       int iTrkEtaBin=-1, iTrkMomBin=-1;
0565       for(int ieta=0; ieta<NEtaBins; ieta++)   {
0566     if (std::abs(eta)>genPartEtaBins[ieta] && std::abs(eta)<genPartEtaBins[ieta+1] ) iTrkEtaBin = ieta;
0567       }
0568       for(int ipt=0;  ipt<NPBins;   ipt++)  {
0569     if (p>genPartPBins[ipt] &&  p<genPartPBins[ipt+1] )  iTrkMomBin = ipt;
0570       }
0571       if (debug) std::cout << " etabin " << iTrkEtaBin << " mombin " << iTrkMomBin <<std::endl;
0572       if (std::abs(pdgid) == 211 ) {
0573     h_trkPAll  [0][iRangeBin] ->Fill(p);
0574     h_trkPtAll [0][iRangeBin] ->Fill(pt);
0575     h_trkEtaAll[0][iRangeBin] ->Fill(eta);
0576     h_trkPhiAll[0][iRangeBin] ->Fill(phi);
0577     if( iTrkMomBin>=0 && iTrkEtaBin>=0 ) {
0578       h_trkDEta[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(deta);
0579       h_trkDPhi[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(dphi);
0580     }
0581       }
0582       else if( std::abs(pdgid)==321 ) {
0583     h_trkPAll  [1][iRangeBin] ->Fill(p);
0584     h_trkPtAll [1][iRangeBin] ->Fill(pt);
0585     h_trkEtaAll[1][iRangeBin] ->Fill(eta);
0586     h_trkPhiAll[1][iRangeBin] ->Fill(phi);
0587     if( iTrkMomBin>=0 && iTrkEtaBin>=0 ) {
0588       h_trkDEta[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(deta);
0589       h_trkDPhi[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(dphi);
0590     }
0591       }
0592       else if( pdgid==2212 ) {
0593     h_trkPAll  [2][iRangeBin] ->Fill(p);
0594     h_trkPtAll [2][iRangeBin] ->Fill(pt);
0595     h_trkEtaAll[2][iRangeBin] ->Fill(eta);
0596     h_trkPhiAll[2][iRangeBin] ->Fill(phi);
0597     if( iTrkMomBin>=0 && iTrkEtaBin>=0 ) {
0598       h_trkDEta[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(deta);
0599       h_trkDPhi[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(dphi);
0600     }
0601       }
0602       else if( pdgid==-2212 ) {
0603     h_trkPAll  [3][iRangeBin] ->Fill(p);
0604     h_trkPtAll [3][iRangeBin] ->Fill(pt);
0605     h_trkEtaAll[3][iRangeBin] ->Fill(eta);
0606     h_trkPhiAll[3][iRangeBin] ->Fill(phi);
0607     if( iTrkMomBin>=0 && iTrkEtaBin>=0 ) {
0608       h_trkDEta[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(deta);
0609       h_trkDPhi[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(dphi);
0610     }
0611       }
0612     } /// Loop over IsoTrkpAll
0613     
0614     // L1 Trigger Information       
0615     double leadL1JetPt=0.0, leadL1JetEta=-0.999, leadL1JetPhi = -0.999;
0616     std::vector<int> myDec;
0617     bool l1SingleJet=false;
0618     if( (*t_L1Decision)[l1Names["L1_SingleJet6"]]  || (*t_L1Decision)[l1Names["L1_SingleJet20"]] || 
0619     (*t_L1Decision)[l1Names["L1_SingleJet30"]] || (*t_L1Decision)[l1Names["L1_SingleJet40"]] ||
0620     (*t_L1Decision)[l1Names["L1_SingleJet50"]] || (*t_L1Decision)[l1Names["L1_SingleJet60"]]) {
0621       l1SingleJet=true;  myDec.push_back(L1SingleJet);
0622       //std::cout<<"Single Jet "<<(*t_L1Decision)[l1Names["L1_SingleJet6"]] <<std::endl;
0623       if(t_L1CenJetPt->size()>0)  h_L1CenJetPt[iRangeBin]->Fill((*t_L1CenJetPt)[0]);
0624       if(t_L1FwdJetPt->size()>0)  h_L1FwdJetPt[iRangeBin]->Fill((*t_L1FwdJetPt)[0]);
0625       for(int i=0; i<t_L1CenJetPt->size(); i++) {
0626     if( (*t_L1CenJetPt)[i] > leadL1JetPt ) {
0627       leadL1JetPt  = (*t_L1CenJetPt)[i];
0628       leadL1JetEta = (*t_L1CenJetEta)[i];
0629       leadL1JetPhi = (*t_L1CenJetPhi)[i];
0630     }
0631       }
0632       for(int i=0; i<t_L1FwdJetPt->size(); i++) {
0633     if( (*t_L1FwdJetPt)[i] > leadL1JetPt ) {
0634       leadL1JetPt  = (*t_L1FwdJetPt)[i];
0635       leadL1JetEta = (*t_L1FwdJetEta)[i];
0636       leadL1JetPhi = (*t_L1FwdJetPhi)[i];
0637     }
0638       }
0639       //      if (debug) std::cout << " L1_SingleJet: LeadJet : pT " << leadL1JetPt << " eta " << leadL1JetEta << " phi " << leadL1JetPhi << std::endl;
0640     }
0641 
0642     bool l1SingleTauJet=false;
0643     if( (*t_L1Decision)[l1Names["L1_SingleTauJet10"]] || (*t_L1Decision)[l1Names["L1_SingleTauJet20"]] || 
0644     (*t_L1Decision)[l1Names["L1_SingleTauJet30"]] || (*t_L1Decision)[l1Names["L1_SingleTauJet50"]]) {
0645       l1SingleTauJet=true; myDec.push_back(L1SingleTauJet);
0646       if(t_L1TauJetPt->size()>0) h_L1TauJetPt[iRangeBin]->Fill((*t_L1TauJetPt)[0]);
0647       for(int i=0; i<t_L1TauJetPt->size(); i++) {
0648     if( (*t_L1TauJetPt)[i] > leadL1JetPt ) {
0649       leadL1JetPt  = (*t_L1TauJetPt)[i];
0650       leadL1JetEta = (*t_L1TauJetEta)[i];
0651       leadL1JetPhi = (*t_L1TauJetPhi)[i];
0652     }
0653       }
0654       //      if (debug) std::cout << " L1TauJet: LeadTauJet: pT " << leadL1JetPt << " eta " << leadL1JetEta << " phi " << leadL1JetPhi << std::endl; 
0655     }
0656     if( l1SingleTauJet || l1SingleJet ) h_L1LeadJetPt[iRangeBin]->Fill(leadL1JetPt);
0657     bool l1SingleIsoEG=false;
0658     if( (*t_L1Decision)[l1Names["L1_SingleIsoEG5"]]  || (*t_L1Decision)[l1Names["L1_SingleIsoEG8"]]  || 
0659     (*t_L1Decision)[l1Names["L1_SingleIsoEG10"]] || (*t_L1Decision)[l1Names["L1_SingleIsoEG12"]] ||
0660     (*t_L1Decision)[l1Names["L1_SingleIsoEG15"]] ) {
0661       l1SingleIsoEG=true; myDec.push_back(L1SingleIsoEG);
0662     }
0663     bool l1SingleEG=false;
0664     if( (*t_L1Decision)[l1Names["L1_SingleEG1"]]  || (*t_L1Decision)[l1Names["L1_SingleEG2"]]  || 
0665     (*t_L1Decision)[l1Names["L1_SingleEG5"]]  || (*t_L1Decision)[l1Names["L1_SingleEG8"]]  ||
0666     (*t_L1Decision)[l1Names["L1_SingleEG10"]] || (*t_L1Decision)[l1Names["L1_SingleEG12"]] ||
0667     (*t_L1Decision)[l1Names["L1_SingleEG15"]] || (*t_L1Decision)[l1Names["L1_SingleEG20"]] ) {
0668       l1SingleEG=true;  myDec.push_back(L1SingleEG);
0669     }
0670     bool l1L1_SingleMu=false;
0671     if( (*t_L1Decision)[l1Names["L1_SingleMu0"]]  || (*t_L1Decision)[l1Names["L1_SingleMu3"]]  || 
0672     (*t_L1Decision)[l1Names["L1_SingleMu5"]]  || (*t_L1Decision)[l1Names["L1_SingleMu7"]]  ||
0673     (*t_L1Decision)[l1Names["L1_SingleMu10"]] || (*t_L1Decision)[l1Names["L1_SingleMu14"]] ||
0674     (*t_L1Decision)[l1Names["L1_SingleMu20"]] ) {
0675       l1L1_SingleMu=true;  myDec.push_back(L1SingleMu);
0676     }
0677     //    if (debug) std::cout << " L1Decision (L1SingleJet/L1SingleTauJet/L1SingleIsoEG/L1SingleEG/L1SingleMu) " << l1SingleJet << "/" << l1SingleTauJet << "/" << l1SingleIsoEG << "/" << l1SingleEG << "/" << l1L1_SingleMu << std::endl;
0678 
0679     bool checkL1=false, checkTest=false;
0680     if (ibit >= 0) {
0681       checkTest = true;
0682       if( (*t_L1Decision)[ibit] ) checkL1 = true;
0683     } else {
0684       if (l1Name=="L1Jet" || l1Name=="L1JetL1Tau" || 
0685       l1Name=="L1JetL1TauL1EM" || l1Name=="L1JetL1EM") {
0686     checkTest = true;
0687     if (l1SingleJet) checkL1 = true;
0688       }
0689       if (l1Name=="L1Tau" || l1Name=="L1JetL1Tau" || l1Name=="L1JetL1TauL1EM") {
0690     checkTest = true;
0691     if (l1SingleTauJet) checkL1 = true;
0692       }
0693       if (l1Name=="L1EM" || l1Name=="L1JETL1EM" || l1Name=="L1JetL1TauL1EM") {
0694     checkTest = true;
0695     if (l1SingleEG) checkL1 = true;
0696       }
0697     }
0698     //    if (debug) std::cout << " ibit " << ibit << std::endl;
0699     if (debug) std::cout << "isotrkP size " << t_isoTrkP->size() << std::endl;
0700     for(int itrk=0; itrk<t_isoTrkP->size(); itrk++ ){      
0701       nTrk++;
0702       double p1            = (*t_isoTrkP)[itrk];
0703       double pt1           = (*t_isoTrkPt)[itrk];
0704       double eta1          = (*t_isoTrkEta)[itrk];
0705       double phi1          = (*t_isoTrkPhi)[itrk];
0706       double maxNearP31x31 = (*t_maxNearP31x31)[itrk];
0707       double maxNearP25x25 = (*t_maxNearP25x25)[itrk];
0708       double maxNearP21x21 = (*t_maxNearP21x21)[itrk];
0709       double maxNearP15x15 = (*t_maxNearP15x15)[itrk];
0710       double maxNearP11x11 = (*t_maxNearP11x11)[itrk];
0711       double maxNearPHC3x3 = (*t_maxNearPHC3x3)[itrk];
0712       double maxNearPHC5x5 = (*t_maxNearPHC5x5)[itrk];
0713       double maxNearPHC7x7 = (*t_maxNearPHC7x7)[itrk];
0714       double maxNearPIsoR   = (*t_maxNearPIsoR)[itrk];
0715       double maxNearPIsoHCR = (*t_maxNearPIsoHCR)[itrk];
0716       double pdgid1        = (*t_isoTrkPdgId)[itrk];
0717 
0718       if (debug)  std:: cout << "tracks: p " << p1 << " pt1 " << pt1 << " eta1 " << eta1 << " phi1 " << phi1 << " maxNearP(31x31/25x25/21x21/15x15/11x11//H3x3/H5x5/H7x7//IsoR//IsoHR " <<  maxNearP31x31 << "/" << maxNearP25x25 << "/" << maxNearP21x21 << "/" << maxNearP15x15 << "/" << maxNearP11x11 << "//" << maxNearPHC3x3 << "/" << maxNearPHC5x5 << "/" << maxNearPHC7x7 << "//" << maxNearPIsoR << "//" << maxNearPIsoHCR << std::endl; 
0719        if( pt1<1.0) continue;       
0720        for(int i=0; i<myDec.size(); i++) h_L1Decision[iRangeBin]->Fill(myDec[i]);
0721        int iTrkEtaBin=-1, iTrkMomBin=-1;
0722        for(int ieta=0; ieta<NEtaBins; ieta++)   {
0723      if(std::abs(eta1)>genPartEtaBins[ieta] && std::abs(eta1)<genPartEtaBins[ieta+1] ) iTrkEtaBin = ieta;
0724        }
0725        for(int ipt=0;  ipt<NPBins;   ipt++)  {
0726      if( p1>genPartPBins[ipt] &&  p1<genPartPBins[ipt+1] )  iTrkMomBin = ipt;
0727        }
0728        h_maxNearPIsoHCR_allbins[iRangeBin]->Fill( maxNearPIsoHCR );
0729        if( iTrkMomBin>=0) h_maxNearPIsoHCR_pbins[iTrkMomBin][iRangeBin]->Fill( maxNearPIsoHCR );
0730 
0731        if( maxNearP31x31<0 )  h_trkP_iso31x31[iRangeBin]->Fill(p1);
0732        if( maxNearP25x25<0 )  h_trkP_iso25x25[iRangeBin]->Fill(p1);
0733        if( maxNearP21x21<0 )  h_trkP_iso21x21[iRangeBin]->Fill(p1);
0734        if( maxNearP15x15<0 )  h_trkP_iso15x15[iRangeBin]->Fill(p1);
0735        if( maxNearP11x11<0 )  h_trkP_iso11x11[iRangeBin]->Fill(p1);
0736        // Optimize Charge Isolation
0737        if( iTrkMomBin>=0 && iTrkEtaBin>=0 ) {
0738      nTrk_Bins++;
0739      h_maxNearP31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearP31x31 );
0740      h_maxNearP25x25[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearP25x25 );
0741      h_maxNearP21x21[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearP21x21 );
0742      h_maxNearP15x15[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearP15x15 );
0743      h_maxNearP11x11[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearP11x11 );
0744 
0745      h_maxNearPIsoR[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearPIsoR );
0746      h_maxNearPIsoHCR[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( maxNearPIsoHCR );
0747 
0748      // dR cut from trigger object
0749      double dR=-999.0;
0750      if (checkL1) {
0751        dR = DeltaR( (*t_isoTrkEta)[itrk],(*t_isoTrkPhi)[itrk], leadL1JetEta, leadL1JetPhi);
0752      } else if (!checkTest) {
0753        dR = 999.0;
0754      }
0755 
0756      //===================================================================================================
0757      if (debug) std::cout << " maxNearP31x31 " << maxNearP31x31;
0758      if (maxNearP31x31<0) {
0759        nTrk_maxNearP++;
0760        double etotal1 = (*t_photonEne31x31)[itrk]+(*t_cHadronEne31x31_1)[itrk]+(*t_nHadronEne31x31)[itrk];
0761        h_photon_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]        ->Fill( (*t_photonEne31x31)[itrk] );
0762        h_charged_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_cHadronEne31x31_1)[itrk] );
0763        h_neutral_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_nHadronEne31x31)[itrk] );
0764        h_contamination_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin] ->Fill( etotal1 );
0765        
0766        double etotal2 = (*t_photonEne11x11)[itrk]+(*t_cHadronEne11x11_1)[itrk]+(*t_nHadronEne11x11)[itrk];
0767        h_photon11x11_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEne11x11)[itrk] );
0768        h_charged11x11_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEne11x11_1)[itrk] );
0769        h_neutral11x11_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEne11x11)[itrk] );
0770        h_contamination11x11_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( etotal2 );
0771 
0772        bool eNeutIso = (etotal1-etotal2 < 0.1);
0773        if (debug) std::cout << " etotal1 " << etotal1  << " etotal1 " << etotal1 << " eNeutIso " << eNeutIso;
0774        if (eNeutIso) {
0775          nIsoTrk++;
0776          h_photon11x11_isoEcal_NxN[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEne11x11)[itrk] );
0777          h_charged11x11_isoEcal_NxN[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEne11x11_1)[itrk] );
0778          h_neutral11x11_isoEcal_NxN[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEne11x11)[itrk] );
0779          h_contamination11x11_isoEcal_NxN[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( etotal2 );
0780        } 
0781        for(int i=0; i<myDec.size(); i++) {
0782          h_L1_iso31x31[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(myDec[i]);
0783          if( (*t_photonEne11x11)[itrk] > 0.1)  h_L1_iso31x31_isoPhoton_11x11_1[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(myDec[i]);
0784          else                                  h_L1_iso31x31_isoPhoton_11x11_2[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(myDec[i]);
0785          if( (*t_nHadronEne11x11)[itrk] > 0.1) h_L1_iso31x31_isoNeutral_11x11_1[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(myDec[i]);
0786          else                                  h_L1_iso31x31_isoNeutral_11x11_2[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill(myDec[i]);
0787        }
0788        if (debug) std::cout << " maxNearPHC7x7 " << maxNearPHC7x7 <<" ";;
0789        if (maxNearPHC7x7<0) {
0790          double htotal1 = (*t_photonEneHC7x7)[itrk]+(*t_cHadronEneHC7x7_1)[itrk]+(*t_nHadronEneHC7x7)[itrk];
0791          double htotal2 = (*t_photonEneHC3x3)[itrk]+(*t_cHadronEneHC3x3_1)[itrk]+(*t_nHadronEneHC3x3)[itrk];
0792          bool hNeutIso = (htotal1-htotal2 < 0.1);
0793          if (eNeutIso && hNeutIso) {
0794            h_photonHC5x5_IsoNxN[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEneHC5x5)[itrk] );
0795            h_chargedHC5x5_IsoNxN[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEneHC5x5_1)[itrk] );
0796            h_neutralHC5x5_IsoNxN[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEneHC5x5)[itrk] );
0797            h_contaminationHC5x5_IsoNxN[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( (*t_photonEneHC5x5)[itrk]+(*t_cHadronEneHC5x5_1)[itrk]+(*t_nHadronEneHC5x5)[itrk] );
0798          }
0799          if (debug) std::cout << " dR(dRcut) " << dR << "(" << dRCut << ")" << std::endl;
0800          if ((dR > dRCut) && eNeutIso && hNeutIso) {
0801            if( std::abs(pdgid1) == 211 ) {
0802          h_trkPIsoNxN  [0][iRangeBin] ->Fill(p1);
0803          h_trkPtIsoNxN [0][iRangeBin] ->Fill(pt1);
0804          h_trkEtaIsoNxN[0][iRangeBin] ->Fill(eta1);
0805          h_trkPhiIsoNxN[0][iRangeBin] ->Fill(phi1);
0806            } else if (std::abs(pdgid1)==321 ) {
0807          h_trkPIsoNxN  [1][iRangeBin] ->Fill(p1);
0808          h_trkPtIsoNxN [1][iRangeBin] ->Fill(pt1);
0809          h_trkEtaIsoNxN[1][iRangeBin] ->Fill(eta1);
0810          h_trkPhiIsoNxN[1][iRangeBin] ->Fill(phi1);
0811            } else if (pdgid1==2212 ) {
0812          h_trkPIsoNxN  [2][iRangeBin] ->Fill(p1);
0813          h_trkPtIsoNxN [2][iRangeBin] ->Fill(pt1);
0814          h_trkEtaIsoNxN[2][iRangeBin] ->Fill(eta1);
0815          h_trkPhiIsoNxN[2][iRangeBin] ->Fill(phi1);
0816            } else if (pdgid1==-2212 ) {
0817          h_trkPIsoNxN  [3][iRangeBin] ->Fill(p1);
0818          h_trkPtIsoNxN [3][iRangeBin] ->Fill(pt1);
0819          h_trkEtaIsoNxN[3][iRangeBin] ->Fill(eta1);
0820          h_trkPhiIsoNxN[3][iRangeBin] ->Fill(phi1);
0821            }
0822          }
0823        }
0824 
0825      } // if isolated in 31x31
0826 
0827      //===================================================================================================
0828      //////// CHARGE ISOLATION CHANGED TO 2GEV
0829      if (maxNearPIsoR<0) {
0830        double etotal1_R = (*t_photonEneIsoR)[itrk]+(*t_cHadronEneIsoR_1)[itrk]+(*t_nHadronEneIsoR)[itrk];
0831        double etotal2_R = (*t_photonEneR)[itrk]+(*t_cHadronEneR_1)[itrk]+(*t_nHadronEneR)[itrk];
0832        bool eNeutIsoR = (etotal1_R-etotal2_R < 0.1);
0833        if (eNeutIsoR) {
0834          h_photonR_isoEcal_R[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEneR)[itrk] );
0835          h_chargedR_isoEcal_R[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEneR_1)[itrk] );
0836          h_neutralR_isoEcal_R[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEneR)[itrk] );
0837          h_contaminationR_isoEcal_R[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( etotal2_R );
0838        }
0839        if (maxNearPIsoHCR<0) {
0840          double htotal1_R = (*t_photonEneIsoHCR)[itrk]+(*t_cHadronEneIsoHCR_1)[itrk]+(*t_nHadronEneIsoHCR)[itrk];
0841          double htotal2_R = (*t_photonEneHCR)[itrk]+(*t_cHadronEneHCR_1)[itrk]+(*t_nHadronEneHCR)[itrk];
0842          bool hNeutIsoR = (htotal1_R-htotal2_R < 0.1);
0843          if (eNeutIsoR && hNeutIsoR) {
0844            h_photonHCR_IsoR[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEneHCR)[itrk] );
0845            h_chargedHCR_IsoR[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEneHCR_1)[itrk] );
0846            h_neutralHCR_IsoR[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEneHCR)[itrk] );
0847            h_contaminationHCR_IsoR[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( (*t_photonEneHCR)[itrk]+(*t_cHadronEneHCR_1)[itrk]+(*t_nHadronEneHCR)[itrk] );
0848          }
0849          if ((dR > dRCut) && eNeutIsoR && hNeutIsoR) {
0850            if( std::abs(pdgid1) == 211 ) {
0851          h_trkPIsoR  [0][iRangeBin] ->Fill(p1);
0852          h_trkPtIsoR [0][iRangeBin] ->Fill(pt1);
0853          h_trkEtaIsoR[0][iRangeBin] ->Fill(eta1);
0854          h_trkPhiIsoR[0][iRangeBin] ->Fill(phi1);
0855            } else if (std::abs(pdgid1)==321 ) {
0856          h_trkPIsoR  [1][iRangeBin] ->Fill(p1);
0857          h_trkPtIsoR [1][iRangeBin] ->Fill(pt1);
0858          h_trkEtaIsoR[1][iRangeBin] ->Fill(eta1);
0859          h_trkPhiIsoR[1][iRangeBin] ->Fill(phi1);
0860            } else if (pdgid1==2212 ) {
0861          h_trkPIsoR  [2][iRangeBin] ->Fill(p1);
0862          h_trkPtIsoR [2][iRangeBin] ->Fill(pt1);
0863          h_trkEtaIsoR[2][iRangeBin] ->Fill(eta1);
0864          h_trkPhiIsoR[2][iRangeBin] ->Fill(phi1);
0865            } else if (pdgid1==-2212 ) {
0866          h_trkPIsoR  [3][iRangeBin] ->Fill(p1);
0867          h_trkPtIsoR [3][iRangeBin] ->Fill(pt1);
0868          h_trkEtaIsoR[3][iRangeBin] ->Fill(eta1);
0869          h_trkPhiIsoR[3][iRangeBin] ->Fill(phi1);
0870            }
0871          }
0872        }
0873 
0874      } // if isolated in IsoR (ECAL)
0875      //===================================================================================================
0876      if( maxNearP25x25<0 ) {
0877        double total = (*t_photonEne25x25)[itrk]+(*t_cHadronEne25x25_1)[itrk]+(*t_nHadronEne25x25)[itrk];
0878        h_photon_iso25x25[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEne25x25)[itrk] );
0879        h_charged_iso25x25[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEne25x25_1)[itrk] );
0880        h_neutral_iso25x25[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEne25x25)[itrk] );
0881        h_contamination_iso25x25[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( total );
0882      }
0883      if( maxNearP21x21<0 ) {
0884        double total = (*t_photonEne21x21)[itrk]+(*t_cHadronEne21x21_1)[itrk]+(*t_nHadronEne21x21)[itrk];
0885        h_photon_iso21x21[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEne21x21)[itrk] );
0886        h_charged_iso21x21[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEne21x21_1)[itrk] );
0887        h_neutral_iso21x21[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEne21x21)[itrk] );
0888        h_contamination_iso21x21[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( total );
0889      }
0890      if( maxNearP15x15<0 ) {
0891        double total = (*t_photonEne15x15)[itrk]+(*t_cHadronEne15x15_1)[itrk]+(*t_nHadronEne15x15)[itrk];
0892        h_photon_iso15x15[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEne15x15)[itrk] );
0893        h_charged_iso15x15[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEne15x15_1)[itrk] );
0894        h_neutral_iso15x15[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEne15x15)[itrk] );
0895        h_contamination_iso15x15[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( total );
0896      }
0897      if( maxNearP11x11<0 ) {
0898        double total = (*t_photonEne11x11)[itrk]+(*t_cHadronEne11x11_1)[itrk]+(*t_nHadronEne11x11)[itrk];
0899        h_photon_iso11x11[iTrkMomBin][iTrkEtaBin][iRangeBin]       ->Fill( (*t_photonEne11x11)[itrk] );
0900        h_charged_iso11x11[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_cHadronEne11x11_1)[itrk] );
0901        h_neutral_iso11x11[iTrkMomBin][iTrkEtaBin][iRangeBin]      ->Fill( (*t_nHadronEne11x11)[itrk] );
0902        h_contamination_iso11x11[iTrkMomBin][iTrkEtaBin][iRangeBin]->Fill( total );
0903      }
0904      //===================================================================================================
0905        }
0906     }    
0907   } // loop over entries
0908   std::cout << "number of tracks " << nTrk << std::endl
0909         << "number of tracks selected  in bins " << nTrk_Bins << std::endl
0910         << "number of tracks selected in maxnearP " << nTrk_maxNearP << std::endl
0911         << "number of isolated tracks " << nIsoTrk << std::endl;
0912 }
0913 
0914 Bool_t TreeAnalysisReadGen::Notify() {
0915 
0916   // The Notify() function is called when a new file is opened. This
0917   // can be either for a new TTree in a TChain or when when a new TTree
0918   // is started when using PROOF. It is normally not necessary to make changes
0919   // to the generated code, but the routine can be extended by the
0920   // user if needed. The return value is currently not used.
0921   
0922   return kTRUE;
0923 }
0924 
0925 void TreeAnalysisReadGen::Show(Long64_t entry) {
0926 
0927   // Print contents of entry.
0928   // If entry is not specified, print current entry
0929   if (!fChain) return;
0930   fChain->Show(entry);
0931 }
0932 
0933 void TreeAnalysisReadGen::getL1Names(){
0934 
0935   l1Names.insert( std::pair<std::string,int>("L1_SingleJet6"    ,15) );
0936   l1Names.insert( std::pair<std::string,int>("L1_SingleJet20"   ,17) );
0937   l1Names.insert( std::pair<std::string,int>("L1_SingleJet30"   ,18) );
0938   l1Names.insert( std::pair<std::string,int>("L1_SingleJet40"   ,19) );
0939   l1Names.insert( std::pair<std::string,int>("L1_SingleJet50"   ,20) );
0940   l1Names.insert( std::pair<std::string,int>("L1_SingleJet60"   ,21) );
0941   l1Names.insert( std::pair<std::string,int>("L1_SingleTauJet10",30) );
0942   l1Names.insert( std::pair<std::string,int>("L1_SingleTauJet20",31) );
0943   l1Names.insert( std::pair<std::string,int>("L1_SingleTauJet30",32) );
0944   l1Names.insert( std::pair<std::string,int>("L1_SingleTauJet50",33) );
0945   l1Names.insert( std::pair<std::string,int>("L1_SingleIsoEG5"  ,40) );
0946   l1Names.insert( std::pair<std::string,int>("L1_SingleIsoEG8"  ,41) );
0947   l1Names.insert( std::pair<std::string,int>("L1_SingleIsoEG10" ,42) );
0948   l1Names.insert( std::pair<std::string,int>("L1_SingleIsoEG12" ,43) );
0949   l1Names.insert( std::pair<std::string,int>("L1_SingleIsoEG15" ,44) );
0950   l1Names.insert( std::pair<std::string,int>("L1_SingleEG1"     ,45) );
0951   l1Names.insert( std::pair<std::string,int>("L1_SingleEG2"     ,46) );
0952   l1Names.insert( std::pair<std::string,int>("L1_SingleEG5"     ,47) );
0953   l1Names.insert( std::pair<std::string,int>("L1_SingleEG8"     ,48) );
0954   l1Names.insert( std::pair<std::string,int>("L1_SingleEG10"    ,49) );
0955   l1Names.insert( std::pair<std::string,int>("L1_SingleEG12"    ,50) );
0956   l1Names.insert( std::pair<std::string,int>("L1_SingleEG15"    ,51) );
0957   l1Names.insert( std::pair<std::string,int>("L1_SingleEG20"    ,52) );
0958   l1Names.insert( std::pair<std::string,int>("L1_SingleMu0"     ,56) );
0959   l1Names.insert( std::pair<std::string,int>("L1_SingleMu3"     ,57) );
0960   l1Names.insert( std::pair<std::string,int>("L1_SingleMu5"     ,58) );
0961   l1Names.insert( std::pair<std::string,int>("L1_SingleMu7"     ,59) );
0962   l1Names.insert( std::pair<std::string,int>("L1_SingleMu10"    ,60) );
0963   l1Names.insert( std::pair<std::string,int>("L1_SingleMu14"    ,61) );
0964   l1Names.insert( std::pair<std::string,int>("L1_SingleMu20"    ,62) );  
0965 }
0966 
0967 void TreeAnalysisReadGen::BookHistograms(const char *outFileName, std::vector<std::string>& ranges) {
0968 
0969   fout = new TFile(outFileName, "RECREATE");
0970   fout->cd();
0971   char name[100], hname[100], htit[100];
0972   // inclusive distributions
0973   fout->cd();
0974   TDirectory *d_maxNearP              = fout->mkdir( "MaxNearP" );
0975   TDirectory *d_chargeIso31x31        = fout->mkdir( "chargeIso31x31" );
0976   TDirectory *d_chargeIso25x25        = fout->mkdir( "chargeIso25x25" );
0977   TDirectory *d_chargeIso21x21        = fout->mkdir( "chargeIso21x21" );
0978   TDirectory *d_chargeIso15x15        = fout->mkdir( "chargeIso15x15" );
0979   TDirectory *d_chargeIso11x11        = fout->mkdir( "chargeIso11x11" );
0980   TDirectory *d_E11x11_chargeIso31x31 = fout->mkdir( "signalE11x11_chargeIso31x31" );
0981   TDirectory *d_R_chargeIsoIsoR       = fout->mkdir( "signalR_chargeIsoIsoR" );
0982   TDirectory *d_H5x5_IsoNxN           = fout->mkdir( "d_H5x5_IsoNxN" );
0983   TDirectory *d_HCR_IsoR              = fout->mkdir( "d_HCR_IsoR" );
0984   TDirectory *d_trigger = fout->mkdir("trigger");
0985   TDirectory *d_inclusive           = fout->mkdir( "InclusiveTracks" ); 
0986   std::string PNames[PTypes] = {"Pions", "Kaons", "Protons", "AntiProtons"};
0987   for (unsigned int j=0; j<ranges.size()+1; j++) {
0988     if(j==ranges.size()) sprintf(name, "all");
0989     else sprintf(name, "%s", ranges[j].c_str());
0990     d_inclusive ->cd();
0991     for(int itype=0; itype<PTypes; itype++){
0992       sprintf(hname, "h_trkPAll_%i_%s",itype, name);
0993       sprintf(htit,  "tracks : P(%s)_%s", PNames[itype].c_str(), name);
0994       h_trkPAll[itype][j] = new TH1F(hname, htit, NPBins, genPartPBins);
0995       h_trkPAll[itype][j]->Sumw2();
0996       
0997       sprintf(hname, "h_trkPtAll_%i_%s",itype, name);
0998       sprintf(htit,  "tracks : Pt(%s)_%s", PNames[itype].c_str(), name);
0999       h_trkPtAll[itype][j] = new TH1F(hname, htit, NPBins, genPartPBins);
1000       h_trkPtAll[itype][j]->Sumw2();
1001 
1002       sprintf(hname, "h_trkEtaAll_%i_%s",itype, name);
1003       sprintf(htit,  "tracks : Eta(%s)_%s", PNames[itype].c_str(), name);
1004       h_trkEtaAll[itype][j] = new TH1F(hname, htit, 200, -10.0, 10.0);
1005       h_trkEtaAll[itype][j]->Sumw2();
1006 
1007       sprintf(hname, "h_trkPhiAll_%i_%s",itype, name);
1008       sprintf(htit,  "tracks : Phi(%s)_%s", PNames[itype].c_str(), name);
1009       h_trkPhiAll[itype][j] = new TH1F(hname, htit, 100, -5.0, 5.0);    
1010       h_trkPhiAll[itype][j]->Sumw2();
1011       
1012       sprintf(hname, "h_trkPIsoNxN_%i_%s",itype, name);
1013       sprintf(htit,  "tracks : P(%s)_%s", PNames[itype].c_str(), name);
1014       h_trkPIsoNxN[itype][j] = new TH1F(hname, htit, NPBins, genPartPBins);
1015       h_trkPIsoNxN[itype][j]->Sumw2();
1016 
1017       sprintf(hname, "h_trkPtIsoNxN_%i_%s",itype, name);
1018       sprintf(htit,  "tracks : Pt(%s)_%s", PNames[itype].c_str(), name);
1019       h_trkPtIsoNxN[itype][j] = new TH1F(hname, htit, NPBins, genPartPBins);
1020       h_trkPtIsoNxN[itype][j]->Sumw2();
1021       
1022       sprintf(hname, "h_trkEtaIsoNxN_%i_%s",itype, name);
1023       sprintf(htit,  "tracks : Eta(%s)_%s", PNames[itype].c_str(), name);
1024       h_trkEtaIsoNxN[itype][j] = new TH1F(hname, htit, 100, -5.0, 5.0);
1025       h_trkEtaIsoNxN[itype][j]->Sumw2();
1026       
1027       sprintf(hname, "h_trkPhiIsoNxN_%i_%s",itype, name);
1028       sprintf(htit,  "tracks : Phi(%s)_%s", PNames[itype].c_str(), name);
1029       h_trkPhiIsoNxN[itype][j] = new TH1F(hname, htit, 100, -5.0, 5.0);    
1030       h_trkPhiIsoNxN[itype][j]->Sumw2();
1031       
1032       sprintf(hname, "h_trkPIsoR_%i_%s",itype, name);
1033       sprintf(htit,  "tracks : P(%s)_%s", PNames[itype].c_str(), name);
1034       h_trkPIsoR[itype][j] = new TH1F(hname, htit, NPBins, genPartPBins);
1035       h_trkPIsoR[itype][j]->Sumw2();
1036       
1037       sprintf(hname, "h_trkPtIsoR_%i_%s",itype, name);
1038       sprintf(htit,  "tracks : Pt(%s)_%s", PNames[itype].c_str(), name);
1039       h_trkPtIsoR[itype][j] = new TH1F(hname, htit, NPBins, genPartPBins);
1040       h_trkPtIsoR[itype][j]->Sumw2();
1041       
1042       sprintf(hname, "h_trkEtaIsoR_%i_%s",itype, name);
1043       sprintf(htit,  "tracks : Eta(%s)_%s", PNames[itype].c_str(), name);
1044       h_trkEtaIsoR[itype][j] = new TH1F(hname, htit, 100, -5.0, 5.0);
1045       h_trkEtaIsoR[itype][j]->Sumw2();
1046       
1047       sprintf(hname, "h_trkPhiIsoR_%i_%s",itype, name);
1048       sprintf(htit,  "tracks : Phi(%s)_%s", PNames[itype].c_str(), name);
1049       h_trkPhiIsoR[itype][j] = new TH1F(hname, htit, 100, -5.0, 5.0);    
1050       h_trkPhiIsoR[itype][j]->Sumw2();
1051     }
1052     for(int ieta=0; ieta<NEtaBins; ieta++) {
1053       double lowEta=-5.0, highEta= 5.0;
1054       lowEta  = genPartEtaBins[ieta];
1055       highEta = genPartEtaBins[ieta+1];
1056       
1057       for(int ipt=0; ipt<NPBins; ipt++) {
1058     double lowP=0.0, highP=300.0;
1059     lowP    = genPartPBins[ipt];
1060     highP   = genPartPBins[ipt+1];
1061     
1062     sprintf(hname, "h_trkDEta_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1063     sprintf(htit,  "#Delta(#eta(track),#eta(EcalImpactPoint)) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1064     h_trkDEta[ipt][ieta][j] = new TH1F(hname, htit, 250, -0.5, 0.5);
1065     h_trkDEta[ipt][ieta][j]->Sumw2();
1066     
1067     sprintf(hname, "h_trkDPhi_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1068     sprintf(htit,  "#Delta(#phi(track),#phi(EcalImpactPoint)) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1069     h_trkDPhi[ipt][ieta][j] = new TH1F(hname, htit, 350, -0.2, 1.5);
1070     h_trkDPhi[ipt][ieta][j]->Sumw2();
1071       }
1072     }
1073     
1074     sprintf(hname, "h_trkP_iso31x31_%s", name);
1075     h_trkP_iso31x31[j] = new TH1F(hname, hname, NPBins, genPartPBins);
1076     h_trkP_iso31x31[j]->Sumw2();
1077     sprintf(hname, "h_trkP_iso25x25_%s", name);
1078     h_trkP_iso25x25[j] = new TH1F(hname, hname, NPBins, genPartPBins);
1079     h_trkP_iso25x25[j]->Sumw2();
1080     sprintf(hname, "h_trkP_iso21x21_%s", name);
1081     h_trkP_iso21x21[j] = new TH1F(hname, hname, NPBins, genPartPBins);
1082     h_trkP_iso21x21[j]->Sumw2();
1083     sprintf(hname, "h_trkP_iso15x15_%s", name);
1084     h_trkP_iso15x15[j] = new TH1F(hname, hname, NPBins, genPartPBins);
1085     h_trkP_iso15x15[j]->Sumw2();
1086     sprintf(hname, "h_trkP_iso11x11_%s", name);
1087     h_trkP_iso11x11[j] = new TH1F(hname, hname, NPBins, genPartPBins);
1088     h_trkP_iso11x11[j]->Sumw2();
1089     
1090     sprintf(hname, "h_L1Decision_%s", name);
1091     h_L1Decision[j]    = new TH1F(hname,    hname,    10, -0.5, 9.5);
1092     h_L1Decision[j]->Sumw2();
1093     h_L1Decision[j]->GetXaxis()->SetBinLabel(1,"L1SingleJet");
1094     h_L1Decision[j]->GetXaxis()->SetBinLabel(2,"L1SingleTauJet");
1095     h_L1Decision[j]->GetXaxis()->SetBinLabel(3,"L1SingleEG");
1096     h_L1Decision[j]->GetXaxis()->SetBinLabel(4,"L1SingleIsoEG");
1097     h_L1Decision[j]->GetXaxis()->SetBinLabel(5,"L1SingleMu");
1098     
1099     d_maxNearP->cd();
1100     sprintf(hname, "h_maxNearPIsoHCR_allbins_%s", name);
1101     h_maxNearPIsoHCR_allbins[j] = new TH1F(hname, hname, 220, -2.0, 100.0);
1102     h_maxNearPIsoHCR_allbins[j]->Sumw2();
1103 
1104     for(int ipt=0; ipt<NPBins; ipt++) {
1105       double lowP=0.0, highP=300.0;
1106       lowP    = genPartPBins[ipt];
1107       highP   = genPartPBins[ipt+1];
1108       
1109       sprintf(hname, "h_maxNearPIsoHCR_ptBin%i_%s",ipt, name);
1110       sprintf(htit,  "maxNearP in IsoHCR (%2.0f<trkP<%3.0f) for %s", lowP, highP, name);
1111       h_maxNearPIsoHCR_pbins[ipt][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1112       h_maxNearPIsoHCR_pbins[ipt][j]->Sumw2();
1113     }
1114     for(int ieta=0; ieta<NEtaBins; ieta++) {
1115       double lowEta=-5.0, highEta= 5.0;
1116       lowEta  = genPartEtaBins[ieta];
1117       highEta = genPartEtaBins[ieta+1];
1118       
1119       for(int ipt=0; ipt<NPBins; ipt++) {
1120     double lowP=0.0, highP=300.0;
1121     lowP    = genPartPBins[ipt];
1122     highP   = genPartPBins[ipt+1];
1123     
1124     d_maxNearP->cd();
1125     sprintf(hname, "h_maxNearPIsoR_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1126     sprintf(htit,  "maxNearP in IsoR (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1127     h_maxNearPIsoR[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1128     h_maxNearPIsoR[ipt][ieta][j]->Sumw2();
1129     sprintf(hname, "h_maxNearPIsoHCR_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1130     sprintf(htit,  "maxNearP in IsoHCR (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1131     h_maxNearPIsoHCR[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1132     h_maxNearPIsoHCR[ipt][ieta][j]->Sumw2();
1133 
1134     sprintf(hname, "h_maxNearP31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1135     sprintf(htit,  "maxNearP in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1136     h_maxNearP31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1137     h_maxNearP31x31[ipt][ieta][j]->Sumw2();
1138     sprintf(hname, "h_maxNearP25x25_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1139     sprintf(htit,  "maxNearP in 25x25 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1140     h_maxNearP25x25[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1141     h_maxNearP25x25[ipt][ieta][j]->Sumw2();
1142     sprintf(hname, "h_maxNearP21x21_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1143     sprintf(htit,  "maxNearP in 21x21 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1144     h_maxNearP21x21[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1145     h_maxNearP21x21[ipt][ieta][j]->Sumw2();
1146     sprintf(hname, "h_maxNearP15x15_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1147     sprintf(htit,  "maxNearP in 15x15 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1148     h_maxNearP15x15[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1149     h_maxNearP15x15[ipt][ieta][j]->Sumw2();
1150     sprintf(hname, "h_maxNearP11x11_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1151     sprintf(htit,  "maxNearP in 11x11 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1152     h_maxNearP11x11[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 100.0);
1153     h_maxNearP11x11[ipt][ieta][j]->Sumw2();
1154 
1155 
1156     d_chargeIso31x31->cd();
1157     sprintf(hname, "h_photon_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1158     sprintf(htit,  "photon in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1159     h_photon_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1160     h_photon_iso31x31[ipt][ieta][j]->Sumw2();
1161     sprintf(hname, "h_charged_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1162     sprintf(htit,  "charged in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1163     h_charged_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1164     h_charged_iso31x31[ipt][ieta][j]->Sumw2();
1165     sprintf(hname, "h_neutral_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1166     sprintf(htit,  "neutral in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1167     h_neutral_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1168     h_neutral_iso31x31[ipt][ieta][j]->Sumw2();
1169     sprintf(hname, "h_contamination_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1170     sprintf(htit,  "contamination in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1171     h_contamination_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1172     h_contamination_iso31x31[ipt][ieta][j]->Sumw2();
1173     sprintf(hname, "h_L1_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1174     sprintf(htit,  "L1 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP, name);
1175     h_L1_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 10, -0.5, 9.5);
1176     h_L1_iso31x31[ipt][ieta][j]->Sumw2();
1177     h_L1_iso31x31[ipt][ieta][j]->GetXaxis()->SetBinLabel(1,"L1SingleJet");
1178     h_L1_iso31x31[ipt][ieta][j]->GetXaxis()->SetBinLabel(2,"L1SingleTauJet");
1179     h_L1_iso31x31[ipt][ieta][j]->GetXaxis()->SetBinLabel(3,"L1SingleEG");
1180     h_L1_iso31x31[ipt][ieta][j]->GetXaxis()->SetBinLabel(4,"L1SingleIsoEG");
1181     h_L1_iso31x31[ipt][ieta][j]->GetXaxis()->SetBinLabel(5,"L1SingleMu");
1182         
1183     d_chargeIso25x25->cd();
1184     sprintf(hname, "h_photon_iso25x25_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1185     sprintf(htit,  "photon in 25x25 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1186     h_photon_iso25x25[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1187     h_photon_iso25x25[ipt][ieta][j]->Sumw2();
1188     sprintf(hname, "h_charged_iso25x25_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1189     sprintf(htit,  "charged in 25x25 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1190     h_charged_iso25x25[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1191     h_charged_iso25x25[ipt][ieta][j]->Sumw2();
1192     sprintf(hname, "h_neutral_iso25x25_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1193     sprintf(htit,  "neutral in 25x25 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1194     h_neutral_iso25x25[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1195     h_neutral_iso25x25[ipt][ieta][j]->Sumw2();
1196     sprintf(hname, "h_contamination_iso25x25_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1197     sprintf(htit,  "contamination in 25x25 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1198     h_contamination_iso25x25[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1199     h_contamination_iso25x25[ipt][ieta][j]->Sumw2();
1200     
1201     d_chargeIso21x21->cd();
1202     sprintf(hname, "h_photon_iso21x21_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1203     sprintf(htit,  "photon in 21x21 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1204     h_photon_iso21x21[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1205     h_photon_iso21x21[ipt][ieta][j]->Sumw2();
1206     sprintf(hname, "h_charged_iso21x21_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1207     sprintf(htit,  "charged in 21x21 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1208     h_charged_iso21x21[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1209     h_charged_iso21x21[ipt][ieta][j]->Sumw2();
1210     sprintf(hname, "h_neutral_iso21x21_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1211     sprintf(htit,  "neutral in 21x21 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1212     h_neutral_iso21x21[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1213     h_neutral_iso21x21[ipt][ieta][j]->Sumw2();
1214     sprintf(hname, "h_contamination_iso21x21_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1215     sprintf(htit,  "contamination in 21x21 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1216     h_contamination_iso21x21[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1217     h_contamination_iso21x21[ipt][ieta][j]->Sumw2();
1218     
1219     d_chargeIso15x15->cd();
1220     sprintf(hname, "h_photon_iso15x15_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1221     sprintf(htit,  "photon in 15x15 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1222     h_photon_iso15x15[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1223     h_photon_iso15x15[ipt][ieta][j]->Sumw2();
1224     sprintf(hname, "h_charged_iso15x15_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1225     sprintf(htit,  "charged in 15x15 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1226     h_charged_iso15x15[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1227     h_charged_iso15x15[ipt][ieta][j]->Sumw2();
1228 
1229     sprintf(hname, "h_neutral_iso15x15_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1230     sprintf(htit,  "neutral in 15x15 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1231     h_neutral_iso15x15[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1232     h_neutral_iso15x15[ipt][ieta][j]->Sumw2();
1233     sprintf(hname, "h_contamination_iso15x15_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1234     sprintf(htit,  "contamination in 15x15 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1235     h_contamination_iso15x15[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1236     h_contamination_iso15x15[ipt][ieta][j]->Sumw2();
1237     
1238     d_chargeIso11x11->cd();
1239     sprintf(hname, "h_photon_iso11x11_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1240     sprintf(htit,  "photon in 11x11 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1241     h_photon_iso11x11[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1242     h_photon_iso11x11[ipt][ieta][j]->Sumw2();
1243     sprintf(hname, "h_charged_iso11x11_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1244     sprintf(htit,  "charged in 11x11 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1245     h_charged_iso11x11[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1246     h_charged_iso11x11[ipt][ieta][j]->Sumw2();
1247     sprintf(hname, "h_neutral_iso11x11_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1248     sprintf(htit,  "neutral in 11x11 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1249     h_neutral_iso11x11[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1250     h_neutral_iso11x11[ipt][ieta][j]->Sumw2();
1251     sprintf(hname, "h_contamination_iso11x11_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1252     sprintf(htit,  "contamination in 11x11 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1253     h_contamination_iso11x11[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1254     h_contamination_iso11x11[ipt][ieta][j]->Sumw2();
1255     
1256     d_E11x11_chargeIso31x31->cd();
1257     sprintf(hname, "h_photon11x11_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1258     sprintf(htit,  "photon in 11x11 (iso31x31) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1259     h_photon11x11_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1260     h_photon11x11_iso31x31[ipt][ieta][j]->Sumw2();
1261     sprintf(hname, "h_charged11x11_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1262     sprintf(htit,  "charged in 11x11 (iso31x31) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1263     h_charged11x11_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1264     h_charged11x11_iso31x31[ipt][ieta][j]->Sumw2();
1265     sprintf(hname, "h_neutral11x11_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1266     sprintf(htit,  "neutral in 11x11 (iso31x31) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1267     h_neutral11x11_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1268     h_neutral11x11_iso31x31[ipt][ieta][j]->Sumw2();
1269     sprintf(hname, "h_contamination11x11_iso31x31_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1270     sprintf(htit,  "contamination in 11x11 (iso31x31) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1271     h_contamination11x11_iso31x31[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1272     h_contamination11x11_iso31x31[ipt][ieta][j]->Sumw2();
1273     sprintf(hname, "h_L1_iso31x31_isoPhoton_11x11_1_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1274     sprintf(htit,  "L1(iso31x31, photonEne>0)) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1275     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j] = new TH1F(hname, htit, 10, -0.5, 9.5);
1276     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j]->Sumw2();
1277     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(1,"L1SingleJet");
1278     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(2,"L1SingleTauJet");
1279     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(3,"L1SingleEG");
1280     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(4,"L1SingleIsoEG");
1281     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(5,"L1SingleMu");
1282     sprintf(hname, "h_L1_iso31x31_isoPhoton_11x11_2_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1283     sprintf(htit,  "L1(iso31x31, photonEne==0)) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1284     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j] = new TH1F(hname, htit, 10, -0.5, 9.5);
1285     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j]->Sumw2();
1286     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(1,"L1SingleJet");
1287     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(2,"L1SingleTauJet");
1288     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(3,"L1SingleEG");
1289     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(4,"L1SingleIsoEG");
1290     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(5,"L1SingleMu");
1291     sprintf(hname, "h_L1_iso31x31_isoNeutral_11x11_1_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1292     sprintf(htit,  "L1(iso31x31, photonEne>0)) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1293     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j] = new TH1F(hname, htit, 10, -0.5, 9.5);
1294     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j]->Sumw2();
1295     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(1,"L1SingleJet");
1296     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(2,"L1SingleTauJet");
1297     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(3,"L1SingleEG");
1298     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(4,"L1SingleIsoEG");
1299     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][j]->GetXaxis()->SetBinLabel(5,"L1SingleMu");
1300     sprintf(hname, "h_L1_iso31x31_isoNeutral_11x11_2_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1301     sprintf(htit,  "L1(iso31x31, photonEne==0)) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1302     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j] = new TH1F(hname, htit, 10, -0.5, 9.5);
1303     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j]->Sumw2();
1304     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(1,"L1SingleJet");
1305     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(2,"L1SingleTauJet");
1306     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(3,"L1SingleEG");
1307     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(4,"L1SingleIsoEG");
1308     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][j]->GetXaxis()->SetBinLabel(5,"L1SingleMu");
1309     
1310     sprintf(hname, "h_photon11x11_isoEcal_NxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1311     sprintf(htit,  "photon in 11x11 (iso31x31-11x11) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1312     h_photon11x11_isoEcal_NxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1313     h_photon11x11_isoEcal_NxN[ipt][ieta][j]->Sumw2();
1314     sprintf(hname, "h_charged11x11_isoEcal_NxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1315     sprintf(htit,  "charged in 11x11 (iso31x31-11x11) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1316     h_charged11x11_isoEcal_NxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1317     h_charged11x11_isoEcal_NxN[ipt][ieta][j]->Sumw2();
1318     sprintf(hname, "h_neutral11x11_isoEcal_NxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1319     sprintf(htit,  "neutral in 11x11 (iso31x31-11x11) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1320     h_neutral11x11_isoEcal_NxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1321     h_neutral11x11_isoEcal_NxN[ipt][ieta][j]->Sumw2();
1322     sprintf(hname, "h_contamination11x11_isoEcal_NxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1323     sprintf(htit,  "contamination in 11x11 (iso31x31-11x11) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1324     h_contamination11x11_isoEcal_NxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1325     h_contamination11x11_isoEcal_NxN[ipt][ieta][j]->Sumw2();
1326     
1327     d_R_chargeIsoIsoR->cd();
1328     sprintf(hname, "h_photonR_isoEcal_R_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1329     sprintf(htit,  "photon in R iso(IsoR-R) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1330     h_photonR_isoEcal_R[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1331     h_photonR_isoEcal_R[ipt][ieta][j]->Sumw2();
1332     sprintf(hname, "h_chargedR_isoEcal_R_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1333     sprintf(htit,  "charged in R iso(IsoR-R) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1334     h_chargedR_isoEcal_R[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1335     h_chargedR_isoEcal_R[ipt][ieta][j]->Sumw2();
1336     sprintf(hname, "h_neutralR_isoEcal_R_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1337     sprintf(htit,  "neutral in R iso(IsoR-R) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1338     h_neutralR_isoEcal_R[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1339     h_neutralR_isoEcal_R[ipt][ieta][j]->Sumw2();
1340     sprintf(hname, "h_contaminationR_isoEcal_R_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1341     sprintf(htit,  "contamination in R iso(IsoR-R) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1342     h_contaminationR_isoEcal_R[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1343     h_contaminationR_isoEcal_R[ipt][ieta][j]->Sumw2();
1344     
1345     d_H5x5_IsoNxN->cd();
1346     sprintf(hname, "h_photonHC5x5_IsoNxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1347     sprintf(htit,  "photon in HC5x5 (IsoNxN) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1348     h_photonHC5x5_IsoNxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1349     h_photonHC5x5_IsoNxN[ipt][ieta][j]->Sumw2();
1350     sprintf(hname, "h_chargedHC5x5_IsoNxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1351     sprintf(htit,  "charged in HC5x5 (IsoNxN) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1352     h_chargedHC5x5_IsoNxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1353     h_chargedHC5x5_IsoNxN[ipt][ieta][j]->Sumw2();
1354     sprintf(hname, "h_neutralHC5x5_IsoNxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1355     sprintf(htit,  "neutral in HC5x5 (IsoNxN) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1356     h_neutralHC5x5_IsoNxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1357     h_neutralHC5x5_IsoNxN[ipt][ieta][j]->Sumw2();
1358     sprintf(hname, "h_contaminationHC5x5_IsoNxN_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1359     sprintf(htit,  "contamination in HC5x5 (IsoNxN) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1360     h_contaminationHC5x5_IsoNxN[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1361     h_contaminationHC5x5_IsoNxN[ipt][ieta][j]->Sumw2();
1362     
1363     d_HCR_IsoR->cd();
1364     sprintf(hname, "h_photonHCR_IsoR_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1365     sprintf(htit,  "photon in HCR (IsoR) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1366     h_photonHCR_IsoR[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1367     h_photonHCR_IsoR[ipt][ieta][j]->Sumw2();
1368     sprintf(hname, "h_chargedHCR_IsoR_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1369     sprintf(htit,  "charged in HCR (IsoR) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1370     h_chargedHCR_IsoR[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1371     h_chargedHCR_IsoR[ipt][ieta][j]->Sumw2();
1372     sprintf(hname, "h_neutralHCR_IsoR_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1373     sprintf(htit,  "neutral in HCR (IsoR) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1374     h_neutralHCR_IsoR[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1375     h_neutralHCR_IsoR[ipt][ieta][j]->Sumw2();
1376     sprintf(hname, "h_contaminationHCR_IsoR_ptBin%i_etaBin%i_%s",ipt, ieta, name);
1377     sprintf(htit,  "contamination in HCR (IsoR) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f) for %s", lowEta, highEta, lowP, highP , name);
1378     h_contaminationHCR_IsoR[ipt][ieta][j] = new TH1F(hname, htit, 220, -2.0, 20.0);
1379     h_contaminationHCR_IsoR[ipt][ieta][j]->Sumw2();
1380       }
1381     }
1382     
1383     fout->cd();
1384     d_trigger->cd();
1385     sprintf(hname, "h_L1CenJetPt_%s", name);
1386     h_L1CenJetPt[j]  = new TH1F(hname, hname, 500, 0.0, 500);
1387     h_L1CenJetPt[j]->Sumw2();
1388     sprintf(hname, "h_L1FwdJetPt_%s", name);
1389     h_L1FwdJetPt[j]  = new TH1F(hname, hname, 500, 0.0, 500);
1390     h_L1FwdJetPt[j]->Sumw2();
1391     sprintf(hname, "h_L1TauJetPt_%s", name);
1392     h_L1TauJetPt[j]  = new TH1F(hname, hname, 500, 0.0, 500);
1393     h_L1TauJetPt[j]->Sumw2();
1394     sprintf(hname, "h_L1LeadJetPt_%s", name);
1395     h_L1LeadJetPt[j] = new TH1F(hname, hname, 500, 0.0, 500);
1396     h_L1LeadJetPt[j]->Sumw2();    
1397   }
1398 }
1399 
1400 double TreeAnalysisReadGen::DeltaPhi(double v1, double v2) {
1401 
1402   // Computes the correctly normalized phi difference
1403   // v1, v2 = phi of object 1 and 2
1404 
1405   double pi    = 3.141592654;
1406   double twopi = 6.283185307;
1407   
1408   double diff = std::abs(v2 - v1);
1409   double corr = twopi - diff;
1410   if (diff < pi){ return diff;} else { return corr;}
1411 }
1412 
1413 double TreeAnalysisReadGen::DeltaR(double eta1, double phi1, double eta2, double phi2) {
1414   
1415   double deta = eta1 - eta2;
1416   double dphi = DeltaPhi(phi1, phi2);
1417   return std::sqrt(deta*deta + dphi*dphi);
1418 }
1419 
1420 void TreeAnalysisReadGen::AddWeight(){
1421 
1422   for (unsigned int i=0; i<fRange-iRange+1; i++) {
1423     for (int itype=0; itype<PTypes; itype++) {
1424       h_trkPAll[itype][NRanges]          ->Add(h_trkPAll[itype][i+iRange]          , weights[i]);
1425       h_trkPtAll[itype][NRanges]         ->Add(h_trkPtAll[itype][i+iRange]         , weights[i]);
1426       h_trkEtaAll[itype][NRanges]        ->Add(h_trkEtaAll[itype][i+iRange]        , weights[i]);
1427       h_trkPhiAll[itype][NRanges]        ->Add(h_trkPhiAll[itype][i+iRange]        , weights[i]);
1428       h_trkPIsoNxN[itype][NRanges]       ->Add(h_trkPIsoNxN[itype][i+iRange]       , weights[i]);
1429       h_trkPtIsoNxN[itype][NRanges]      ->Add(h_trkPtIsoNxN[itype][i+iRange]      , weights[i]);
1430       h_trkEtaIsoNxN[itype][NRanges]     ->Add(h_trkEtaIsoNxN[itype][i+iRange]     , weights[i]);
1431       h_trkPhiIsoNxN[itype][NRanges]     ->Add(h_trkPhiIsoNxN[itype][i+iRange]     , weights[i]);
1432       h_trkPIsoR[itype][NRanges]         ->Add(h_trkPIsoR[itype][i+iRange]         , weights[i]);
1433       h_trkPtIsoR[itype][NRanges]        ->Add(h_trkPtIsoR[itype][i+iRange]        , weights[i]);
1434       h_trkEtaIsoR[itype][NRanges]       ->Add(h_trkEtaIsoR[itype][i+iRange]       , weights[i]);
1435       h_trkPhiIsoR[itype][NRanges]       ->Add(h_trkPhiIsoR[itype][i+iRange]       , weights[i]);
1436     }
1437     h_trkP_iso31x31[NRanges] ->Add(h_trkP_iso31x31[i+iRange] , weights[i]);
1438     h_trkP_iso25x25[NRanges] ->Add(h_trkP_iso25x25[i+iRange] , weights[i]);
1439     h_trkP_iso21x21[NRanges] ->Add(h_trkP_iso21x21[i+iRange] , weights[i]);
1440     h_trkP_iso15x15[NRanges] ->Add(h_trkP_iso15x15[i+iRange] , weights[i]);
1441     h_trkP_iso11x11[NRanges] ->Add(h_trkP_iso11x11[i+iRange] , weights[i]);
1442     h_L1Decision[NRanges]    ->Add(h_L1Decision[i+iRange]    , weights[i]);
1443 
1444     for (int ieta=0; ieta<NEtaBins; ieta++) {
1445       for (int ipt=0; ipt<NPBins; ipt++) {
1446     h_trkDEta[ipt][ieta][NRanges] ->Add(h_trkDEta[ipt][ieta][i+iRange] , weights[i]);
1447     h_trkDPhi[ipt][ieta][NRanges] ->Add(h_trkDPhi[ipt][ieta][i+iRange] , weights[i]);
1448     h_maxNearP31x31[ipt][ieta][NRanges]                  ->Add(h_maxNearP31x31[ipt][ieta][i+iRange]                  , weights[i]);
1449     h_maxNearP25x25[ipt][ieta][NRanges]                  ->Add(h_maxNearP25x25[ipt][ieta][i+iRange]                  , weights[i]);
1450     h_maxNearP21x21[ipt][ieta][NRanges]                  ->Add(h_maxNearP21x21[ipt][ieta][i+iRange]                  , weights[i]);
1451     h_maxNearP15x15[ipt][ieta][NRanges]                  ->Add(h_maxNearP15x15[ipt][ieta][i+iRange]                  , weights[i]);
1452     h_maxNearP11x11[ipt][ieta][NRanges]                  ->Add(h_maxNearP11x11[ipt][ieta][i+iRange]                  , weights[i]);
1453     h_photon_iso31x31[ipt][ieta][NRanges]                ->Add(h_photon_iso31x31[ipt][ieta][i+iRange]                , weights[i]);
1454     h_charged_iso31x31[ipt][ieta][NRanges]               ->Add(h_charged_iso31x31[ipt][ieta][i+iRange]               , weights[i]);
1455     h_neutral_iso31x31[ipt][ieta][NRanges]               ->Add(h_neutral_iso31x31[ipt][ieta][i+iRange]               , weights[i]);
1456     h_contamination_iso31x31[ipt][ieta][NRanges]         ->Add(h_contamination_iso31x31[ipt][ieta][i+iRange]         , weights[i]);
1457     h_L1_iso31x31[ipt][ieta][NRanges]                    ->Add(h_L1_iso31x31[ipt][ieta][i+iRange]                    , weights[i]);
1458     h_photon_iso25x25[ipt][ieta][NRanges]                ->Add(h_photon_iso25x25[ipt][ieta][i+iRange]                , weights[i]);
1459     h_charged_iso25x25[ipt][ieta][NRanges]               ->Add(h_charged_iso25x25[ipt][ieta][i+iRange]               , weights[i]);
1460     h_neutral_iso25x25[ipt][ieta][NRanges]               ->Add(h_neutral_iso25x25[ipt][ieta][i+iRange]               , weights[i]);
1461     h_contamination_iso25x25[ipt][ieta][NRanges]         ->Add(h_contamination_iso25x25[ipt][ieta][i+iRange]         , weights[i]);
1462     h_photon_iso21x21[ipt][ieta][NRanges]                ->Add(h_photon_iso21x21[ipt][ieta][i+iRange]                , weights[i]);
1463     h_charged_iso21x21[ipt][ieta][NRanges]               ->Add(h_charged_iso21x21[ipt][ieta][i+iRange]               , weights[i]);
1464     h_neutral_iso21x21[ipt][ieta][NRanges]               ->Add(h_neutral_iso21x21[ipt][ieta][i+iRange]               , weights[i]);
1465     h_contamination_iso21x21[ipt][ieta][NRanges]         ->Add(h_contamination_iso21x21[ipt][ieta][i+iRange]         , weights[i]);
1466     h_photon_iso15x15[ipt][ieta][NRanges]                ->Add(h_photon_iso15x15[ipt][ieta][i+iRange]                , weights[i]);
1467     h_charged_iso15x15[ipt][ieta][NRanges]               ->Add(h_charged_iso15x15[ipt][ieta][i+iRange]               , weights[i]);
1468     h_neutral_iso15x15[ipt][ieta][NRanges]               ->Add(h_neutral_iso15x15[ipt][ieta][i+iRange]               , weights[i]);
1469     h_contamination_iso15x15[ipt][ieta][NRanges]         ->Add(h_contamination_iso15x15[ipt][ieta][i+iRange]         , weights[i]);
1470     h_photon_iso11x11[ipt][ieta][NRanges]                ->Add(h_photon_iso11x11[ipt][ieta][i+iRange]                , weights[i]);
1471     h_charged_iso11x11[ipt][ieta][NRanges]               ->Add(h_charged_iso11x11[ipt][ieta][i+iRange]               , weights[i]);
1472     h_neutral_iso11x11[ipt][ieta][NRanges]               ->Add(h_neutral_iso11x11[ipt][ieta][i+iRange]               , weights[i]);
1473     h_contamination_iso11x11[ipt][ieta][NRanges]         ->Add(h_contamination_iso11x11[ipt][ieta][i+iRange]         , weights[i]);
1474     h_photon11x11_iso31x31[ipt][ieta][NRanges]           ->Add(h_photon11x11_iso31x31[ipt][ieta][i+iRange]           , weights[i]);
1475     h_charged11x11_iso31x31[ipt][ieta][NRanges]          ->Add(h_charged11x11_iso31x31[ipt][ieta][i+iRange]          , weights[i]);
1476     h_neutral11x11_iso31x31[ipt][ieta][NRanges]          ->Add(h_neutral11x11_iso31x31[ipt][ieta][i+iRange]          , weights[i]);
1477     h_contamination11x11_iso31x31[ipt][ieta][NRanges]    ->Add(h_contamination11x11_iso31x31[ipt][ieta][i+iRange]    , weights[i]);
1478     h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][NRanges]  ->Add(h_L1_iso31x31_isoPhoton_11x11_1[ipt][ieta][i+iRange]  , weights[i]);
1479     h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][NRanges]  ->Add(h_L1_iso31x31_isoPhoton_11x11_2[ipt][ieta][i+iRange]  , weights[i]);
1480     h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][NRanges] ->Add(h_L1_iso31x31_isoNeutral_11x11_1[ipt][ieta][i+iRange] , weights[i]);
1481     h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][NRanges] ->Add(h_L1_iso31x31_isoNeutral_11x11_2[ipt][ieta][i+iRange] , weights[i]);
1482     h_photon11x11_isoEcal_NxN[ipt][ieta][NRanges]        ->Add(h_photon11x11_isoEcal_NxN[ipt][ieta][i+iRange]        , weights[i]);
1483     h_charged11x11_isoEcal_NxN[ipt][ieta][NRanges]       ->Add(h_charged11x11_isoEcal_NxN[ipt][ieta][i+iRange]       , weights[i]);
1484     h_neutral11x11_isoEcal_NxN[ipt][ieta][NRanges]       ->Add(h_neutral11x11_isoEcal_NxN[ipt][ieta][i+iRange]       , weights[i]);
1485     h_contamination11x11_isoEcal_NxN[ipt][ieta][NRanges] ->Add(h_contamination11x11_isoEcal_NxN[ipt][ieta][i+iRange] , weights[i]);
1486     h_photonR_isoEcal_R[ipt][ieta][NRanges]              ->Add(h_photonR_isoEcal_R[ipt][ieta][i+iRange]              , weights[i]);
1487     h_chargedR_isoEcal_R[ipt][ieta][NRanges]             ->Add(h_chargedR_isoEcal_R[ipt][ieta][i+iRange]             , weights[i]);
1488     h_neutralR_isoEcal_R[ipt][ieta][NRanges]             ->Add(h_neutralR_isoEcal_R[ipt][ieta][i+iRange]             , weights[i]);
1489     h_contaminationR_isoEcal_R[ipt][ieta][NRanges]       ->Add(h_contaminationR_isoEcal_R[ipt][ieta][i+iRange]       , weights[i]);
1490     h_photonHC5x5_IsoNxN[ipt][ieta][NRanges]             ->Add(h_photonHC5x5_IsoNxN[ipt][ieta][i+iRange]             , weights[i]);
1491     h_chargedHC5x5_IsoNxN[ipt][ieta][NRanges]            ->Add(h_chargedHC5x5_IsoNxN[ipt][ieta][i+iRange]            , weights[i]);
1492     h_neutralHC5x5_IsoNxN[ipt][ieta][NRanges]            ->Add(h_neutralHC5x5_IsoNxN[ipt][ieta][i+iRange]            , weights[i]);
1493     h_contaminationHC5x5_IsoNxN[ipt][ieta][NRanges]      ->Add(h_contaminationHC5x5_IsoNxN[ipt][ieta][i+iRange]      , weights[i]);
1494     h_photonHCR_IsoR[ipt][ieta][NRanges]                 ->Add(h_photonHCR_IsoR[ipt][ieta][i+iRange]                 , weights[i]);
1495     h_chargedHCR_IsoR[ipt][ieta][NRanges]                ->Add(h_chargedHCR_IsoR[ipt][ieta][i+iRange]                , weights[i]);
1496     h_neutralHCR_IsoR[ipt][ieta][NRanges]                ->Add(h_neutralHCR_IsoR[ipt][ieta][i+iRange]                , weights[i]);
1497     h_contaminationHCR_IsoR[ipt][ieta][NRanges]          ->Add(h_contaminationHCR_IsoR[ipt][ieta][i+iRange]          , weights[i]);
1498       }
1499     }
1500     h_L1CenJetPt[NRanges]  ->Add(h_L1CenJetPt[i+iRange]  , weights[i]);
1501     h_L1FwdJetPt[NRanges]  ->Add(h_L1FwdJetPt[i+iRange]  , weights[i]);
1502     h_L1TauJetPt[NRanges]  ->Add(h_L1TauJetPt[i+iRange]  , weights[i]);
1503     h_L1LeadJetPt[NRanges] ->Add(h_L1LeadJetPt[i+iRange] , weights[i]);
1504   }
1505 }
1506 
1507 void TreeAnalysisReadGen::setRange(unsigned int ir) {
1508   iRangeBin = ir;
1509 }
1510 
1511 void TreeAnalysisReadGen::clear() {
1512   std::cout << fChain << std::endl;
1513   if (!fChain) return;
1514   delete fChain->GetCurrentFile();
1515 }