Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • validation/DelphesValidation.cpp

    r181c061 r341014c  
    1717 */
    1818
    19 
    2019#include <iostream>
     20#include <typeinfo>
    2121#include <utility>
    2222#include <vector>
    23 #include <typeinfo>
    24 
     23
     24#include "TApplication.h"
    2525#include "TROOT.h"
    2626#include "TSystem.h"
    27 #include "TApplication.h"
    2827
    2928#include "TString.h"
    3029
     30#include "TCanvas.h"
     31#include "TClonesArray.h"
     32#include "TGraph.h"
     33#include "TGraphErrors.h"
    3134#include "TH1.h"
    3235#include "TH2.h"
    33 #include "TMath.h"
    34 #include "TStyle.h"
    35 #include "TGraph.h"
    36 #include "TCanvas.h"
    3736#include "THStack.h"
    3837#include "TLegend.h"
     38#include "TLorentzVector.h"
     39#include "TMath.h"
     40#include "TMultiGraph.h"
    3941#include "TPaveText.h"
    40 #include "TClonesArray.h"
    41 #include "TLorentzVector.h"
    42 #include "TGraphErrors.h"
    43 #include "TMultiGraph.h"
     42#include "TStyle.h"
    4443
    4544#include "classes/DelphesClasses.h"
    4645
     46#include "ExRootAnalysis/ExRootResult.h"
     47#include "ExRootAnalysis/ExRootTreeBranch.h"
    4748#include "ExRootAnalysis/ExRootTreeReader.h"
    4849#include "ExRootAnalysis/ExRootTreeWriter.h"
    49 #include "ExRootAnalysis/ExRootTreeBranch.h"
    50 #include "ExRootAnalysis/ExRootResult.h"
    5150#include "ExRootAnalysis/ExRootUtilities.h"
    5251
     
    8281unsigned int k;
    8382
    84 
    8583struct resolPlot
    8684{
    87   TH1* resolHist;
     85  TH1 *resolHist;
    8886  double ptmin;
    8987  double ptmax;
     
    9997  void set(double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
    10098  void set(double etadown, double etaup, double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
    101   void print(){std::cout << ptmin << std::endl;}
     99  void print() { std::cout << ptmin << std::endl; }
    102100};
    103 
    104101
    105102resolPlot::resolPlot()
     
    109106resolPlot::resolPlot(double ptdown, double ptup, TString object)
    110107{
    111   this->set(ptdown,ptup,object);
     108  this->set(ptdown, ptup, object);
    112109}
    113110
     
    123120  obj = object;
    124121
    125   resolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax), obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax), 1000, xmin, xmax);
     122  resolHist = new TH1D(obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax), obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax), 1000, xmin, xmax);
    126123}
    127124
     
    134131  obj = object;
    135132
    136   resolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_"+Form("%4.2f",etamin)+"_"+Form("%4.2f",etamax), obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_"+Form("%4.2f",etamin)+"_"+Form("%4.2f",etamax), 1000, xmin, xmax);
     133  resolHist = new TH1D(obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax) + "_" + Form("%4.2f", etamin) + "_" + Form("%4.2f", etamax), obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax) + "_" + Form("%4.2f", etamin) + "_" + Form("%4.2f", etamax), 1000, xmin, xmax);
    137134}
    138 
    139 
    140135
    141136void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
     
    146141  resolPlot ptemp;
    147142
    148   for (int i = 0; i < Nbins; i++)
     143  for(int i = 0; i < Nbins; i++)
    149144  {
    150145    width = (ptmax - ptmin) / Nbins;
    151     ptdown = TMath::Power(10,ptmin + i * width );
    152     ptup = TMath::Power(10,ptmin + (i+1) * width );
     146    ptdown = TMath::Power(10, ptmin + i * width);
     147    ptup = TMath::Power(10, ptmin + (i + 1) * width);
    153148    ptemp.set(ptdown, ptup, obj, xmin, xmax);
    154149    histos->push_back(ptemp);
    155150  }
    156151}
    157 
    158152
    159153void HistogramsCollectionVsEta(std::vector<resolPlot> *histos, double etamin, double etamax, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
     
    164158  double etaup;
    165159
    166   for (int i = 0; i < Nbins; i++)
     160  for(int i = 0; i < Nbins; i++)
    167161  {
    168162    width = (etamax - etamin) / Nbins;
    169163    etadown = etamin + i * width;
    170     etaup = etamin + (i+1) * width;
     164    etaup = etamin + (i + 1) * width;
    171165
    172166    ptemp.set(etadown, etaup, ptmin, ptmax, obj, xmin, xmax);
     
    175169}
    176170
    177 
    178171//------------------------------------------------------------------------------
    179172
     
    183176//------------------------------------------------------------------------------
    184177
    185 void BinLogX(TH1*h)
     178void BinLogX(TH1 *h)
    186179{
    187180  TAxis *axis = h->GetXaxis();
     
    193186  Axis_t *new_bins = new Axis_t[bins + 1];
    194187
    195   for (int i = 0; i <= bins; i++)
     188  for(int i = 0; i <= bins; i++)
    196189  {
    197190    new_bins[i] = TMath::Power(10, from + i * width);
     
    201194}
    202195
    203 
    204196//------------------------------------------------------------------------------
    205197
    206 template<typename T>
    207 TH1D* GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     198template <typename T>
     199TH1D *GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    208200{
    209201
    210   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     202  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    211203
    212204  Long64_t allEntries = treeReader->GetEntries();
     
    223215  Int_t i, j;
    224216
    225   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    226   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     217  TH1D *histGenPt = new TH1D(name + " gen spectra Pt", name + " gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     218  TH1D *histRecoPt = new TH1D(name + " reco spectra Pt", name + " reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    227219
    228220  histGenPt->SetDirectory(0);
     
    242234    {
    243235
    244       particle = (GenParticle*) branchParticle->At(i);
     236      particle = (GenParticle *)branchParticle->At(i);
    245237      genMomentum = particle->P4();
    246238
    247239      deltaR = 999;
    248240
    249       pt  = genMomentum.Pt();
     241      pt = genMomentum.Pt();
    250242      eta = TMath::Abs(genMomentum.Eta());
    251243
    252 
    253       if(eta > etamax || eta < etamin ) continue;
    254 
    255       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     244      if(eta > etamax || eta < etamin) continue;
     245
     246      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    256247      //if (TMath::Abs(particle->PID) == pdgID && (particle->Status>20 && particle->Status <30) && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    257248      {
     
    259250        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    260251        {
    261           recoObj = (T*)branchReco->At(j);
     252          recoObj = (T *)branchReco->At(j);
    262253          recoMomentum = recoObj->P4();
    263         //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    264 
    265 
     254          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    266255
    267256          // take the closest parton candidate
     
    269258          {
    270259            Jet *jet = (Jet *)recoObj;
    271             if( !(jet->BTag & (1 << 0)) ) continue;
     260            if(!(jet->BTag & (1 << 0))) continue;
    272261
    273262            //if(jet->BTag != ) continue;
    274263          }
    275264
    276             if(TMath::Abs(pdgID) == 4)
     265          if(TMath::Abs(pdgID) == 4)
    277266          {
    278267            Jet *jet = (Jet *)recoObj;
    279             if( !(jet->BTag & (1 << 0)) ) continue;
     268            if(!(jet->BTag & (1 << 0))) continue;
    280269          }
    281270
    282             if(TMath::Abs(pdgID) == 1)
     271          if(TMath::Abs(pdgID) == 1)
    283272          {
    284273            Jet *jet = (Jet *)recoObj;
    285             if( !(jet->BTag & (1 << 0)) ) continue;
     274            if(!(jet->BTag & (1 << 0))) continue;
    286275          }
    287276
     
    291280            if(jet->TauTag != 1) continue;
    292281          }
    293 
    294282
    295283          if(genMomentum.DeltaR(recoMomentum) < deltaR)
     
    300288        }
    301289        histGenPt->Fill(pt);
    302         if(deltaR < 0.3 && bestRecoMomentum.Pt()> 0.20*pt ) { histRecoPt->Fill(pt);}
    303 
     290        if(deltaR < 0.3 && bestRecoMomentum.Pt() > 0.20 * pt)
     291        {
     292          histRecoPt->Fill(pt);
     293        }
    304294      }
    305295    }
     
    315305}
    316306
    317 
    318 template<typename T>
    319 TH1D* GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     307template <typename T>
     308TH1D *GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    320309{
    321310
    322   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     311  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    323312
    324313  Long64_t allEntries = treeReader->GetEntries();
     
    335324  Int_t i, j;
    336325
    337   TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
    338   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
     326  TH1D *histGenEta = new TH1D(name + " gen spectra Eta", name + " gen spectra", Nbins, etamin, etamax);
     327  TH1D *histRecoEta = new TH1D(name + " reco spectra Eta", name + " reco spectra", Nbins, etamin, etamax);
    339328
    340329  histGenEta->SetDirectory(0);
     
    351340    {
    352341
    353       particle = (GenParticle*) branchParticle->At(i);
     342      particle = (GenParticle *)branchParticle->At(i);
    354343      genMomentum = particle->P4();
    355344
    356345      deltaR = 999;
    357346
    358       pt  = genMomentum.Pt();
     347      pt = genMomentum.Pt();
    359348      eta = genMomentum.Eta();
    360349
    361       if(pt > ptmax || pt < ptmin ) continue;
    362 
    363       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     350      if(pt > ptmax || pt < ptmin) continue;
     351
     352      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    364353      //if (TMath::Abs(particle->PID) == pdgID && (particle->Status>20 && particle->Status <30) && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    365354      {
     
    367356        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    368357        {
    369           recoObj = (T*)branchReco->At(j);
     358          recoObj = (T *)branchReco->At(j);
    370359          recoMomentum = recoObj->P4();
    371360          // this is simply to avoid warnings from initial state particle
    372361          // having infite rapidity ...
    373         //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     362          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    374363
    375364          // take the closest parton candidate
     
    377366          {
    378367            Jet *jet = (Jet *)recoObj;
    379             if( !(jet->BTag & (1 << 0)) ) continue;
    380 
     368            if(!(jet->BTag & (1 << 0))) continue;
    381369          }
    382370
     
    384372          {
    385373            Jet *jet = (Jet *)recoObj;
    386             if( !(jet->BTag & (1 << 0)) ) continue;
     374            if(!(jet->BTag & (1 << 0))) continue;
    387375          }
    388376
    389            if(TMath::Abs(pdgID) == 1)
     377          if(TMath::Abs(pdgID) == 1)
    390378          {
    391379            Jet *jet = (Jet *)recoObj;
    392             if( !(jet->BTag & (1 << 0)) ) continue;
     380            if(!(jet->BTag & (1 << 0))) continue;
    393381          }
    394382
     
    406394
    407395        histGenEta->Fill(eta);
    408         if(deltaR < 0.3) { histRecoEta->Fill(eta); }
    409 
     396        if(deltaR < 0.3)
     397        {
     398          histRecoEta->Fill(eta);
     399        }
    410400      }
    411401    }
     
    421411}
    422412
    423 
    424413//------------------------------------------------------------------------------
    425414
    426 template<typename T>
    427 TH1D* GetJetEffPt(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     415template <typename T>
     416TH1D *GetJetEffPt(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    428417{
    429418
    430   cout << "** Computing Efficiency of reconstructing "<< branchJet->GetName() << " with PID " << pdgID << endl;
     419  cout << "** Computing Efficiency of reconstructing " << branchJet->GetName() << " with PID " << pdgID << endl;
    431420
    432421  Long64_t allEntries = treeReader->GetEntries();
     
    441430  Int_t j;
    442431
    443   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    444   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     432  TH1D *histGenPt = new TH1D(name + " gen spectra Pt", name + " gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     433  TH1D *histRecoPt = new TH1D(name + " reco spectra Pt", name + " reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    445434
    446435  histGenPt->SetDirectory(0);
     
    459448    for(j = 0; j < branchJet->GetEntriesFast(); ++j)
    460449    {
    461       recoObj = (T*)branchJet->At(j);
     450      recoObj = (T *)branchJet->At(j);
    462451      recoMomentum = recoObj->P4();
    463       pt =   recoMomentum.Pt();     
     452      pt = recoMomentum.Pt();
    464453      eta = TMath::Abs(recoMomentum.Eta());
    465454      Jet *jet = (Jet *)recoObj;
    466          
    467       if(eta > etamax || eta < etamin ) continue;
     455
     456      if(eta > etamax || eta < etamin) continue;
    468457      if(pt < ptmin || pt > ptmax) continue;
    469      
     458
    470459      Int_t flavor = jet->Flavor;
    471460      if(flavor == 21) flavor = 0;
    472    
     461
    473462      if(TMath::Abs(pdgID) == 1)
    474463      {
    475        
     464
    476465        if(flavor < 4)
    477466        {
    478467          histGenPt->Fill(pt);
    479           if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
     468          if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
    480469        }
    481470      }
     
    485474        {
    486475          histGenPt->Fill(pt);
    487           if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
     476          if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
    488477        }
    489478      }
     
    493482        {
    494483          histGenPt->Fill(pt);
    495           if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
     484          if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
    496485        }
    497486      }
    498    }
    499 
     487    }
    500488  }
    501489
     
    511499// ------------------------------------------------------------------------------------------------------------------------------------------------------
    512500
    513 template<typename T>
    514 TH1D* GetJetEffEta(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     501template <typename T>
     502TH1D *GetJetEffEta(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    515503{
    516504
    517   cout << "** Computing Efficiency of reconstructing "<< branchJet->GetName() << " with PID " << pdgID << endl;
     505  cout << "** Computing Efficiency of reconstructing " << branchJet->GetName() << " with PID " << pdgID << endl;
    518506
    519507  Long64_t allEntries = treeReader->GetEntries();
     
    528516  Int_t j;
    529517
    530   TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
    531   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
     518  TH1D *histGenEta = new TH1D(name + " gen spectra Eta", name + " gen spectra", Nbins, etamin, etamax);
     519  TH1D *histRecoEta = new TH1D(name + " reco spectra Eta", name + " reco spectra", Nbins, etamin, etamax);
    532520
    533521  histGenEta->SetDirectory(0);
     
    542530    for(j = 0; j < branchJet->GetEntriesFast(); ++j)
    543531    {
    544       recoObj = (T*)branchJet->At(j);
     532      recoObj = (T *)branchJet->At(j);
    545533      recoMomentum = recoObj->P4();
    546       pt =   recoMomentum.Pt();     
     534      pt = recoMomentum.Pt();
    547535      eta = recoMomentum.Eta();
    548536      Jet *jet = (Jet *)recoObj;
    549          
    550       if(eta > etamax || eta < etamin ) continue;
     537
     538      if(eta > etamax || eta < etamin) continue;
    551539      if(pt < ptmin || pt > ptmax) continue;
    552      
     540
    553541      Int_t flavor = jet->Flavor;
    554542      if(flavor == 21) flavor = 0;
    555          
     543
    556544      if(TMath::Abs(pdgID) == 1)
    557545      {
    558         if(flavor  == 1 || flavor == 21)
     546        if(flavor == 1 || flavor == 21)
    559547        {
    560548          histGenEta->Fill(eta);
    561           if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
     549          if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
    562550        }
    563551      }
     
    567555        {
    568556          histGenEta->Fill(eta);
    569           if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
     557          if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
    570558        }
    571559      }
     
    575563        {
    576564          histGenEta->Fill(eta);
    577           if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
     565          if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
    578566        }
    579567      }
    580    }
    581 
    582   }
    583 
     568    }
     569  }
    584570
    585571  histRecoEta->Sumw2();
     
    592578}
    593579
    594 
    595580// -----------------------------------------------------------------------------------------------------------------------------------------------------
    596581
    597 template<typename T>
    598 TH1D* GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     582template <typename T>
     583TH1D *GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    599584{
    600585
    601   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     586  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    602587
    603588  Long64_t allEntries = treeReader->GetEntries();
     
    614599  Int_t i, j;
    615600
    616   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    617   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     601  TH1D *histGenPt = new TH1D(name + " gen spectra Pt", name + " gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     602  TH1D *histRecoPt = new TH1D(name + " reco spectra Pt", name + " reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    618603
    619604  histGenPt->SetDirectory(0);
     
    633618    {
    634619
    635       particle = (GenParticle*) branchParticle->At(i);
     620      particle = (GenParticle *)branchParticle->At(i);
    636621      genMomentum = particle->P4();
    637622
    638623      deltaR = 999;
    639624
    640       pt  = genMomentum.Pt();
     625      pt = genMomentum.Pt();
    641626      eta = TMath::Abs(genMomentum.Eta());
    642627
    643       if(eta > etamax || eta < etamin ) continue;
    644 
    645       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     628      if(eta > etamax || eta < etamin) continue;
     629
     630      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    646631      {
    647632        // Loop over all reco object in event
    648633        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    649634        {
    650           recoObj = (T*)branchReco->At(j);
     635          recoObj = (T *)branchReco->At(j);
    651636          recoMomentum = recoObj->P4();
    652637          // this is simply to avoid warnings from initial state particle
     
    657642          {
    658643            Jet *jet = (Jet *)recoObj;
    659             if( jet->TauTag != 1 ) continue;
     644            if(jet->TauTag != 1) continue;
    660645          }
    661646
     
    674659
    675660        histGenPt->Fill(pt);
    676         if(deltaR < 0.3) { histRecoPt->Fill(pt); }
    677 
     661        if(deltaR < 0.3)
     662        {
     663          histRecoPt->Fill(pt);
     664        }
    678665      }
    679666    }
     
    683670  histGenPt->Sumw2();
    684671
    685 
    686672  histRecoPt->Divide(histGenPt);
    687673  histRecoPt->Scale(100.);
    688   if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1/0.648);
     674  if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1 / 0.648);
    689675
    690676  return histRecoPt;
    691677}
    692678
    693 template<typename T>
    694 TH1D* GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     679template <typename T>
     680TH1D *GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    695681{
    696682
    697   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     683  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    698684
    699685  Long64_t allEntries = treeReader->GetEntries();
     
    710696  Int_t i, j;
    711697
    712   TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
    713   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
     698  TH1D *histGenEta = new TH1D(name + " gen spectra Eta", name + " gen spectra", Nbins, etamin, etamax);
     699  TH1D *histRecoEta = new TH1D(name + " reco spectra Eta", name + " reco spectra", Nbins, etamin, etamax);
    714700
    715701  histGenEta->SetDirectory(0);
     
    726712    {
    727713
    728       particle = (GenParticle*) branchParticle->At(i);
     714      particle = (GenParticle *)branchParticle->At(i);
    729715      genMomentum = particle->P4();
    730716
    731717      deltaR = 999;
    732718
    733       pt  = genMomentum.Pt();
     719      pt = genMomentum.Pt();
    734720      eta = genMomentum.Eta();
    735721
    736       if(pt > ptmax || pt < ptmin ) continue;
    737 
    738       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     722      if(pt > ptmax || pt < ptmin) continue;
     723
     724      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    739725      {
    740726        // Loop over all reco object in event
    741727        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    742728        {
    743           recoObj = (T*)branchReco->At(j);
     729          recoObj = (T *)branchReco->At(j);
    744730          recoMomentum = recoObj->P4();
    745731          // this is simply to avoid warnings from initial state particle
    746732          // having infite rapidity ...
    747         //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    748 
    749          if(TMath::Abs(pdgID) == 1)
     733          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     734
     735          if(TMath::Abs(pdgID) == 1)
    750736          {
    751737            Jet *jet = (Jet *)recoObj;
    752             if( jet->TauTag != 1 ) continue;
     738            if(jet->TauTag != 1) continue;
    753739          }
    754740
     
    767753
    768754        histGenEta->Fill(eta);
    769         if(deltaR < 0.3) { histRecoEta->Fill(eta); }
    770 
     755        if(deltaR < 0.3)
     756        {
     757          histRecoEta->Fill(eta);
     758        }
    771759      }
    772760    }
     
    778766  histRecoEta->Divide(histGenEta);
    779767  histRecoEta->Scale(100.);
    780   if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1/0.648);
     768  if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1 / 0.648);
    781769
    782770  return histRecoEta;
    783771}
    784772
    785 
    786 template<typename T>
     773template <typename T>
    787774void GetPtres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
    788775{
     
    792779
    793780  GenParticle *particle;
    794   T* recoObj;
     781  T *recoObj;
    795782
    796783  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    811798    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    812799    {
    813       recoObj = (T*) branchReco->At(i);
     800      recoObj = (T *)branchReco->At(i);
    814801      recoMomentum = recoObj->P4();
    815802
    816803      deltaR = 999;
    817804
    818      // Loop over all hard partons in event
    819      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    820      {
    821         particle = (GenParticle*) branchParticle->At(j);
    822         if (particle->PID == pdgID && particle->Status == 1)
     805      // Loop over all hard partons in event
     806      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     807      {
     808        particle = (GenParticle *)branchParticle->At(j);
     809        if(particle->PID == pdgID && particle->Status == 1)
    823810        {
    824811          genMomentum = particle->P4();
     
    831818          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    832819          {
    833              deltaR = genMomentum.DeltaR(recoMomentum);
    834              bestGenMomentum = genMomentum;
     820            deltaR = genMomentum.DeltaR(recoMomentum);
     821            bestGenMomentum = genMomentum;
    835822          }
    836823        }
     
    839826      if(deltaR < 0.3)
    840827      {
    841         pt  = bestGenMomentum.Pt();
     828        pt = bestGenMomentum.Pt();
    842829        eta = TMath::Abs(bestGenMomentum.Eta());
    843830
    844         for (bin = 0; bin < Nbins; bin++)
     831        for(bin = 0; bin < Nbins; bin++)
    845832        {
    846833          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
    847834          {
    848             histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
     835            histos->at(bin).resolHist->Fill(recoMomentum.Pt() / bestGenMomentum.Pt());
    849836          }
    850837        }
     
    854841}
    855842
    856 
    857 template<typename T>
     843template <typename T>
    858844void GetEres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
    859845{
     
    863849
    864850  GenParticle *particle;
    865   T* recoObj;
     851  T *recoObj;
    866852
    867853  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    879865    treeReader->ReadEntry(entry);
    880866
    881      // Loop over all reconstructed jets in event
     867    // Loop over all reconstructed jets in event
    882868    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    883869    {
    884       recoObj = (T*) branchReco->At(i);
     870      recoObj = (T *)branchReco->At(i);
    885871      recoMomentum = recoObj->P4();
    886872
    887873      deltaR = 999;
    888874
    889      // Loop over all hard partons in event
    890      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    891      {
    892         particle = (GenParticle*) branchParticle->At(j);
    893         if (particle->PID == pdgID && particle->Status == 1)
     875      // Loop over all hard partons in event
     876      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     877      {
     878        particle = (GenParticle *)branchParticle->At(j);
     879        if(particle->PID == pdgID && particle->Status == 1)
    894880        {
    895881          genMomentum = particle->P4();
     
    902888          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    903889          {
    904              deltaR = genMomentum.DeltaR(recoMomentum);
    905              bestGenMomentum = genMomentum;
     890            deltaR = genMomentum.DeltaR(recoMomentum);
     891            bestGenMomentum = genMomentum;
    906892          }
    907893        }
     
    910896      if(deltaR < 0.3)
    911897      {
    912         e  = bestGenMomentum.E();
     898        e = bestGenMomentum.E();
    913899        eta = TMath::Abs(bestGenMomentum.Eta());
    914900
    915         for (bin = 0; bin < Nbins; bin++)
     901        for(bin = 0; bin < Nbins; bin++)
    916902        {
    917903          if(e > histos->at(bin).ptmin && e < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
    918904          {
    919             histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
     905            histos->at(bin).resolHist->Fill(recoMomentum.E() / bestGenMomentum.E());
    920906          }
    921907        }
     
    925911}
    926912
    927 
    928 template<typename T>
     913template <typename T>
    929914void GetPtresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t ptMin, Double_t ptMax, ExRootTreeReader *treeReader)
    930915{
     
    934919
    935920  GenParticle *particle;
    936   T* recoObj;
     921  T *recoObj;
    937922
    938923  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    953938    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    954939    {
    955       recoObj = (T*) branchReco->At(i);
     940      recoObj = (T *)branchReco->At(i);
    956941      recoMomentum = recoObj->P4();
    957942
    958943      deltaR = 999;
    959944
    960      // Loop over all hard partons in event
    961      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    962      {
    963         particle = (GenParticle*) branchParticle->At(j);
    964         if (particle->PID == pdgID && particle->Status == 1)
     945      // Loop over all hard partons in event
     946      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     947      {
     948        particle = (GenParticle *)branchParticle->At(j);
     949        if(particle->PID == pdgID && particle->Status == 1)
    965950        {
    966951          genMomentum = particle->P4();
     
    973958          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    974959          {
    975              deltaR = genMomentum.DeltaR(recoMomentum);
    976              bestGenMomentum = genMomentum;
     960            deltaR = genMomentum.DeltaR(recoMomentum);
     961            bestGenMomentum = genMomentum;
    977962          }
    978963        }
     
    981966      if(deltaR < 0.3)
    982967      {
    983         pt  = bestGenMomentum.Pt();
     968        pt = bestGenMomentum.Pt();
    984969        eta = bestGenMomentum.Eta();
    985970
    986         for (bin = 0; bin < Nbins; bin++)
     971        for(bin = 0; bin < Nbins; bin++)
    987972        {
    988973          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt > ptMin && pt < ptMax)
    989974          {
    990              histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
     975            histos->at(bin).resolHist->Fill(recoMomentum.Pt() / bestGenMomentum.Pt());
    991976          }
    992977        }
     
    996981}
    997982
    998 template<typename T>
     983template <typename T>
    999984void GetEresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t eMin, Double_t eMax, ExRootTreeReader *treeReader)
    1000985{
     
    1004989
    1005990  GenParticle *particle;
    1006   T* recoObj;
     991  T *recoObj;
    1007992
    1008993  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    10231008    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    10241009    {
    1025       recoObj = (T*) branchReco->At(i);
     1010      recoObj = (T *)branchReco->At(i);
    10261011      recoMomentum = recoObj->P4();
    10271012
    10281013      deltaR = 999;
    10291014
    1030      // Loop over all hard partons in event
    1031      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    1032      {
    1033         particle = (GenParticle*) branchParticle->At(j);
    1034         if (particle->PID == pdgID && particle->Status == 1)
     1015      // Loop over all hard partons in event
     1016      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     1017      {
     1018        particle = (GenParticle *)branchParticle->At(j);
     1019        if(particle->PID == pdgID && particle->Status == 1)
    10351020        {
    10361021          genMomentum = particle->P4();
     
    10431028          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    10441029          {
    1045              deltaR = genMomentum.DeltaR(recoMomentum);
    1046              bestGenMomentum = genMomentum;
     1030            deltaR = genMomentum.DeltaR(recoMomentum);
     1031            bestGenMomentum = genMomentum;
    10471032          }
    10481033        }
     
    10511036      if(deltaR < 0.3)
    10521037      {
    1053         e  = bestGenMomentum.E();
     1038        e = bestGenMomentum.E();
    10541039        eta = bestGenMomentum.Eta();
    10551040
    1056 
    1057 
    1058         for (bin = 0; bin < Nbins; bin++)
     1041        for(bin = 0; bin < Nbins; bin++)
    10591042        {
    10601043          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && e > eMin && e < eMax)
    10611044          {
    1062              histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
     1045            histos->at(bin).resolHist->Fill(recoMomentum.E() / bestGenMomentum.E());
    10631046          }
    10641047        }
     
    10681051}
    10691052
    1070 
    1071 
    10721053void GetJetsEres(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader, Double_t etaMin, Double_t etaMax)
    10731054{
     
    10931074    treeReader->ReadEntry(entry);
    10941075
    1095     if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
     1076    if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
    10961077
    10971078    // Loop over all reconstructed jets in event
    1098     for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
     1079    for(i = 0; i < TMath::Min(2, branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
    10991080    {
    11001081
    1101       jet = (Jet*) branchJet->At(i);
     1082      jet = (Jet *)branchJet->At(i);
    11021083      jetMomentum = jet->P4();
    11031084
    11041085      deltaR = 999;
    11051086
    1106      // Loop over all hard partons in event
    1107      for(j = 0; j < TMath::Min(2,branchGenJet->GetEntriesFast()); ++j)
    1108      {
    1109         genjet = (Jet*) branchGenJet->At(j);
     1087      // Loop over all hard partons in event
     1088      for(j = 0; j < TMath::Min(2, branchGenJet->GetEntriesFast()); ++j)
     1089      {
     1090        genjet = (Jet *)branchGenJet->At(j);
    11101091
    11111092        genJetMomentum = genjet->P4();
     
    11181099        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
    11191100        {
    1120            deltaR = genJetMomentum.DeltaR(jetMomentum);
    1121            bestGenJetMomentum = genJetMomentum;
     1101          deltaR = genJetMomentum.DeltaR(jetMomentum);
     1102          bestGenJetMomentum = genJetMomentum;
    11221103        }
    11231104      }
     
    11251106      if(deltaR < 0.3)
    11261107      {
    1127         pt  = genJetMomentum.E();
     1108        pt = genJetMomentum.E();
    11281109        eta = genJetMomentum.Eta();
    11291110
    1130         for (bin = 0; bin < Nbins; bin++)
     1111        for(bin = 0; bin < Nbins; bin++)
    11311112        {
    11321113          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < etaMax && eta > etaMin)
    11331114          {
    1134              histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
     1115            histos->at(bin).resolHist->Fill(jetMomentum.E() / bestGenJetMomentum.E());
    11351116          }
    11361117        }
     
    11631144    treeReader->ReadEntry(entry);
    11641145
    1165     if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
     1146    if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
    11661147
    11671148    // Loop over all reconstructed jets in event
    1168     for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
     1149    for(i = 0; i < TMath::Min(2, branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
    11691150    {
    11701151
    1171       jet = (Jet*) branchJet->At(i);
     1152      jet = (Jet *)branchJet->At(i);
    11721153      jetMomentum = jet->P4();
    11731154
    11741155      deltaR = 999;
    11751156
    1176      // Loop over all hard partons in event
    1177      for(j = 0; j < TMath::Min(2,branchGenJet->GetEntriesFast()); ++j)
    1178      {
    1179         genjet = (Jet*) branchGenJet->At(j);
     1157      // Loop over all hard partons in event
     1158      for(j = 0; j < TMath::Min(2, branchGenJet->GetEntriesFast()); ++j)
     1159      {
     1160        genjet = (Jet *)branchGenJet->At(j);
    11801161
    11811162        genJetMomentum = genjet->P4();
     
    11881169        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
    11891170        {
    1190            deltaR = genJetMomentum.DeltaR(jetMomentum);
    1191            bestGenJetMomentum = genJetMomentum;
     1171          deltaR = genJetMomentum.DeltaR(jetMomentum);
     1172          bestGenJetMomentum = genJetMomentum;
    11921173        }
    11931174      }
     
    11961177      {
    11971178
    1198         pt  = genJetMomentum.E();
     1179        pt = genJetMomentum.E();
    11991180        eta = genJetMomentum.Eta();
    12001181
    1201         for (bin = 0; bin < Nbins; bin++)
     1182        for(bin = 0; bin < Nbins; bin++)
    12021183        {
    12031184          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt < eMax && pt > eMin)
    12041185          {
    1205              histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
     1186            histos->at(bin).resolHist->Fill(jetMomentum.E() / bestGenJetMomentum.E());
    12061187          }
    12071188        }
     
    12111192}
    12121193
    1213 
    1214 
    1215 std::pair<Double_t, Double_t> GausFit(TH1* hist)
     1194std::pair<Double_t, Double_t> GausFit(TH1 *hist)
    12161195{
    1217   TF1 *f1 = new TF1("f1", "gaus", hist->GetMean()-2*hist->GetRMS(), hist->GetMean()+2*hist->GetRMS());
    1218   hist->Fit("f1","RQ");
    1219 
    1220   TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2*f1->GetParameter(2), f1->GetParameter(1) + 2*f1->GetParameter(2));
    1221   hist->Fit("f2","RQ");
     1196  TF1 *f1 = new TF1("f1", "gaus", hist->GetMean() - 2 * hist->GetRMS(), hist->GetMean() + 2 * hist->GetRMS());
     1197  hist->Fit("f1", "RQ");
     1198
     1199  TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2 * f1->GetParameter(2), f1->GetParameter(1) + 2 * f1->GetParameter(2));
     1200  hist->Fit("f2", "RQ");
    12221201
    12231202  Double_t sig = f2->GetParameter(2);
     
    12261205  delete f1;
    12271206  delete f2;
    1228   return make_pair (sig, sigErr);
     1207  return make_pair(sig, sigErr);
    12291208}
    1230 
    12311209
    12321210TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool rms = false)
     
    12341212  Int_t bin;
    12351213  Int_t count = 0;
    1236   TGraphErrors gr = TGraphErrors(Nbins/2);
     1214  TGraphErrors gr = TGraphErrors(Nbins / 2);
    12371215  double val, error;
    1238   for (bin = 0; bin < Nbins; bin++)
    1239   {
    1240      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
    1241      if (rms == true)
    1242      {
    1243        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, 100*histos->at(bin).resolHist->GetRMS());
    1244        //gr.SetPointError(count,0, 100*sigvalues.second); // to correct
    1245        error = 100*histos->at(bin).resolHist->GetRMSError();
    1246        val = 100*histos->at(bin).resolHist->GetRMS();
    1247        if(error > 0.2*val) error = 0.2*val;
    1248        gr.SetPointError(count,0, error); // to correct
    1249      }
    1250      else
    1251      {
    1252 
    1253        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, 100*sigvalues.first);
    1254        error = 100*sigvalues.second;
    1255        val = 100*sigvalues.first;
    1256        if(error > 0.2*val) error = 0.2*val;
    1257        gr.SetPointError(count,0, error); // to correct
    1258        //gr.SetPointError(count,0, 100*sigvalues.second);
    1259      }
    1260      count++;
     1216  for(bin = 0; bin < Nbins; bin++)
     1217  {
     1218    std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
     1219    if(rms == true)
     1220    {
     1221      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, 100 * histos->at(bin).resolHist->GetRMS());
     1222      //gr.SetPointError(count,0, 100*sigvalues.second); // to correct
     1223      error = 100 * histos->at(bin).resolHist->GetRMSError();
     1224      val = 100 * histos->at(bin).resolHist->GetRMS();
     1225      if(error > 0.2 * val) error = 0.2 * val;
     1226      gr.SetPointError(count, 0, error); // to correct
     1227    }
     1228    else
     1229    {
     1230
     1231      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, 100 * sigvalues.first);
     1232      error = 100 * sigvalues.second;
     1233      val = 100 * sigvalues.first;
     1234      if(error > 0.2 * val) error = 0.2 * val;
     1235      gr.SetPointError(count, 0, error); // to correct
     1236      //gr.SetPointError(count,0, 100*sigvalues.second);
     1237    }
     1238    count++;
    12611239  }
    12621240
     
    12681246  Int_t bin;
    12691247  Int_t count = 0;
    1270   TGraphErrors gr = TGraphErrors(Nbins/2);
     1248  TGraphErrors gr = TGraphErrors(Nbins / 2);
    12711249  double val, error;
    1272   for (bin = 0; bin < Nbins; bin++)
    1273   {
    1274      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
    1275      if (rms == true)
    1276      {
    1277        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, histos->at(bin).resolHist->GetRMS());
    1278        error = histos->at(bin).resolHist->GetRMSError();
    1279        val = histos->at(bin).resolHist->GetRMS();
    1280        if(error > 0.2*val) error = 0.2*val;
    1281        gr.SetPointError(count,0, error); // to correct
    1282      }
    1283      else
    1284      {
    1285 
    1286        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first);
    1287        val = sigvalues.first;
    1288        error = sigvalues.second;
    1289        if(error > 0.2*val) error = 0.2*val;
    1290        gr.SetPointError(count,0, error);
    1291        //gr.SetPointError(count,0, 100*sigvalues.second);
    1292      }
    1293      count++;
     1250  for(bin = 0; bin < Nbins; bin++)
     1251  {
     1252    std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
     1253    if(rms == true)
     1254    {
     1255      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, histos->at(bin).resolHist->GetRMS());
     1256      error = histos->at(bin).resolHist->GetRMSError();
     1257      val = histos->at(bin).resolHist->GetRMS();
     1258      if(error > 0.2 * val) error = 0.2 * val;
     1259      gr.SetPointError(count, 0, error); // to correct
     1260    }
     1261    else
     1262    {
     1263
     1264      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, sigvalues.first);
     1265      val = sigvalues.first;
     1266      error = sigvalues.second;
     1267      if(error > 0.2 * val) error = 0.2 * val;
     1268      gr.SetPointError(count, 0, error);
     1269      //gr.SetPointError(count,0, 100*sigvalues.second);
     1270    }
     1271    count++;
    12941272  }
    12951273
    12961274  return gr;
    12971275}
    1298 
    1299 
    13001276
    13011277TGraphErrors EresGraphVsEta(std::vector<resolPlot> *histos, bool rms = false)
     
    13031279  Int_t bin;
    13041280  Int_t count = 0;
    1305   TGraphErrors gr = TGraphErrors(Nbins/2);
     1281  TGraphErrors gr = TGraphErrors(Nbins / 2);
    13061282  double val, error;
    1307   for (bin = 0; bin < Nbins; bin++)
    1308   {
    1309 
    1310      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
    1311      if (rms == true)
    1312      {
    1313        gr.SetPoint(count,(histos->at(bin).etamin+histos->at(bin).etamax)/2.0, histos->at(bin).resolHist->GetRMS());
    1314        error = 100*histos->at(bin).resolHist->GetRMSError();
    1315        val = 100*histos->at(bin).resolHist->GetRMS();
    1316        if(error > 0.2*val) error = 0.2*val;
    1317        gr.SetPointError(count,0, error); // to correct
    1318      }
    1319      else
    1320      {
    1321        gr.SetPoint(count,(histos->at(bin).etamin+histos->at(bin).etamax)/2.0, 100*sigvalues.first);
    1322        val = 100*sigvalues.first;
    1323        error = 100*sigvalues.second;
    1324        if(error > 0.2*val) error = 0.2*val;
    1325        gr.SetPointError(count,0, error);
    1326        //gr.SetPointError(count,0, 100*sigvalues.second);
    1327      }
    1328      count++;
     1283  for(bin = 0; bin < Nbins; bin++)
     1284  {
     1285
     1286    std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
     1287    if(rms == true)
     1288    {
     1289      gr.SetPoint(count, (histos->at(bin).etamin + histos->at(bin).etamax) / 2.0, histos->at(bin).resolHist->GetRMS());
     1290      error = 100 * histos->at(bin).resolHist->GetRMSError();
     1291      val = 100 * histos->at(bin).resolHist->GetRMS();
     1292      if(error > 0.2 * val) error = 0.2 * val;
     1293      gr.SetPointError(count, 0, error); // to correct
     1294    }
     1295    else
     1296    {
     1297      gr.SetPoint(count, (histos->at(bin).etamin + histos->at(bin).etamax) / 2.0, 100 * sigvalues.first);
     1298      val = 100 * sigvalues.first;
     1299      error = 100 * sigvalues.second;
     1300      if(error > 0.2 * val) error = 0.2 * val;
     1301      gr.SetPointError(count, 0, error);
     1302      //gr.SetPointError(count,0, 100*sigvalues.second);
     1303    }
     1304    count++;
    13291305  }
    13301306
     
    13561332    treeReader->ReadEntry(entry);
    13571333
    1358     if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
    1359 
    1360     if (branchJet->GetEntriesFast() > 1)
     1334    if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
     1335
     1336    if(branchJet->GetEntriesFast() > 1)
    13611337    {
    13621338
    1363       jet = (Jet*) branchJet->At(0);
     1339      jet = (Jet *)branchJet->At(0);
    13641340      p1 = jet->P4();
    1365       jet = (Jet*) branchJet->At(1);
     1341      jet = (Jet *)branchJet->At(1);
    13661342      p2 = jet->P4();
    13671343
    1368       met = (MissingET*) branchMet->At(0);
    1369       scalarHT = (ScalarHT*) branchScalarHT->At(0);
     1344      met = (MissingET *)branchMet->At(0);
     1345      scalarHT = (ScalarHT *)branchScalarHT->At(0);
    13701346      ht = scalarHT->HT;
    13711347
    1372       if(p1.Pt() < 0.75*ht/2) continue;
    1373       if(p2.Pt() < 0.75*ht/2) continue;
    1374 
    1375       for (bin = 0; bin < Nbins; bin++)
     1348      if(p1.Pt() < 0.75 * ht / 2) continue;
     1349      if(p2.Pt() < 0.75 * ht / 2) continue;
     1350
     1351      for(bin = 0; bin < Nbins; bin++)
    13761352      {
    1377         if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax )
     1353        if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax)
    13781354        {
    13791355          histos->at(bin).resolHist->Fill(met->P4().Px());
     
    13841360}
    13851361
    1386 
    1387 
    13881362//------------------------------------------------------------------------------
    1389 
    13901363
    13911364void addResoGraph(TMultiGraph *mg, TGraphErrors *gr, TLegend *leg, int style, Color_t color, TString text)
     
    14001373  std::cout << "Adding " << gr->GetName() << std::endl;
    14011374  mg->Add(gr);
    1402   leg->AddEntry(gr,text,"p");
    1403 
     1375  leg->AddEntry(gr, text, "p");
    14041376}
    1405 
    14061377
    14071378void DrawAxis(TMultiGraph *mg, TLegend *leg, double xmin, double xmax, double ymin, double ymax, TString tx, TString ty, bool logx = 0, bool logy = 0)
     
    14091380  mg->SetMinimum(ymin);
    14101381  mg->SetMaximum(ymax);
    1411   mg->GetXaxis()->SetLimits(xmin,xmax);
     1382  mg->GetXaxis()->SetLimits(xmin, xmax);
    14121383
    14131384  mg->GetXaxis()->SetTitle(tx);
     
    14401411  if(logy) gPad->SetLogy();
    14411412
    1442 
    14431413  //gPad->SetGridx();
    14441414  //gPad->SetGridy();
     
    14471417  gPad->Modified();
    14481418  gPad->Update();
    1449 
    14501419}
    1451 
    14521420
    14531421void DelphesValidation(
     
    15451513  colors.push_back(kBlue);
    15461514  colors.push_back(kRed);
    1547   colors.push_back(kGreen+1);
    1548   colors.push_back(kMagenta+1);
     1515  colors.push_back(kGreen + 1);
     1516  colors.push_back(kMagenta + 1);
    15491517  colors.push_back(kOrange);
    15501518
     
    15661534  Int_t lastSlash = figPath.Last('/');
    15671535  Int_t sizePath = figPath.Length();
    1568   figPath.Remove(lastSlash+1,sizePath);
     1536  figPath.Remove(lastSlash + 1, sizePath);
    15691537
    15701538  TString header = pdfOutput;
     
    15731541  lastSlash = header.Last('/');
    15741542  sizePath = header.Length();
    1575   header.Remove(0,lastSlash+1);
     1543  header.Remove(0, lastSlash + 1);
    15761544
    15771545  TString vrs(version);
    15781546
    1579   TPaveText *pave = new TPaveText(0.0, 0.89, 0.94, 0.94,"NDC");
     1547  TPaveText *pave = new TPaveText(0.0, 0.89, 0.94, 0.94, "NDC");
    15801548  pave->SetTextAlign(30);
    15811549  pave->SetTextFont(132);
     
    15841552  pave->SetFillColor(0);
    15851553  pave->SetFillStyle(0);
    1586   pave->AddText("Delphes "+vrs+" - "+header);
     1554  pave->AddText("Delphes " + vrs + " - " + header);
    15871555
    15881556  TString s_etaMin, s_etaMax, s_eta, s_pt, s_e;
     
    16101578  etaVals.push_back(6.0);
    16111579
    1612   const int n_etabins = etaVals.size()-1;
     1580  const int n_etabins = etaVals.size() - 1;
    16131581  const int n_ptbins = ptVals.size();
    16141582
     
    16191587  // --------- Pion Tracks  --------- //
    16201588
    1621   TMultiGraph *mg_trkpi_res_pt  = new TMultiGraph("","");
    1622   TMultiGraph *mg_trkpi_eff_pt  = new TMultiGraph("","");
    1623   TMultiGraph *mg_trkpi_res_eta = new TMultiGraph("","");
    1624   TMultiGraph *mg_trkpi_eff_eta = new TMultiGraph("","");
    1625 
    1626   TLegend *leg_trkpi_res_pt = new TLegend(0.55,0.22,0.90,0.48);
    1627   TLegend *leg_trkpi_eff_pt = (TLegend*)leg_trkpi_res_pt->Clone();
    1628   TLegend *leg_trkpi_res_eta = (TLegend*)leg_trkpi_res_pt->Clone();
    1629   TLegend *leg_trkpi_eff_eta = (TLegend*)leg_trkpi_res_eta->Clone();
    1630 
    1631   TGraphErrors *gr_trkpi_res_pt  = new TGraphErrors[n_etabins];
    1632   TGraphErrors *gr_trkpi_eff_pt  = new TGraphErrors[n_etabins];
     1589  TMultiGraph *mg_trkpi_res_pt = new TMultiGraph("", "");
     1590  TMultiGraph *mg_trkpi_eff_pt = new TMultiGraph("", "");
     1591  TMultiGraph *mg_trkpi_res_eta = new TMultiGraph("", "");
     1592  TMultiGraph *mg_trkpi_eff_eta = new TMultiGraph("", "");
     1593
     1594  TLegend *leg_trkpi_res_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     1595  TLegend *leg_trkpi_eff_pt = (TLegend *)leg_trkpi_res_pt->Clone();
     1596  TLegend *leg_trkpi_res_eta = (TLegend *)leg_trkpi_res_pt->Clone();
     1597  TLegend *leg_trkpi_eff_eta = (TLegend *)leg_trkpi_res_eta->Clone();
     1598
     1599  TGraphErrors *gr_trkpi_res_pt = new TGraphErrors[n_etabins];
     1600  TGraphErrors *gr_trkpi_eff_pt = new TGraphErrors[n_etabins];
    16331601  TGraphErrors *gr_trkpi_res_eta = new TGraphErrors[n_ptbins];
    16341602  TGraphErrors *gr_trkpi_eff_eta = new TGraphErrors[n_ptbins];
    1635   TH1D* h_trkpi_eff_pt, *h_trkpi_eff_eta;
    1636 
    1637   std::vector<resolPlot> *plots_trkpi_res_pt   = new std::vector<resolPlot>[n_etabins];
    1638   std::vector<resolPlot> *plots_trkpi_res_eta  = new std::vector<resolPlot>[n_ptbins];
     1603  TH1D *h_trkpi_eff_pt, *h_trkpi_eff_eta;
     1604
     1605  std::vector<resolPlot> *plots_trkpi_res_pt = new std::vector<resolPlot>[n_etabins];
     1606  std::vector<resolPlot> *plots_trkpi_res_eta = new std::vector<resolPlot>[n_ptbins];
    16391607
    16401608  // loop over eta bins
    1641   for (k = 0; k < etaVals.size()-1; k++)
    1642   {
    1643      HistogramsCollection(&plots_trkpi_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
    1644      GetPtres<Track>(&plots_trkpi_res_pt[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    1645      gr_trkpi_res_pt[k] = EresGraph(&plots_trkpi_res_pt[k]);
    1646 
    1647      h_trkpi_eff_pt = GetEffPt<Track>(branchTrackPion, branchParticlePion, "Pion", 211, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    1648      gr_trkpi_eff_pt[k] = TGraphErrors(h_trkpi_eff_pt);
    1649 
    1650      s_etaMin = Form("%.1f",etaVals.at(k));
    1651      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1652 
    1653      s_eta = "#pi^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1654 
    1655      gr_trkpi_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1656      gr_trkpi_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
    1657 
    1658      addResoGraph(mg_trkpi_res_pt, &gr_trkpi_res_pt[k], leg_trkpi_res_pt, markerStyles.at(k), colors.at(k), s_eta);
    1659      addResoGraph(mg_trkpi_eff_pt, &gr_trkpi_eff_pt[k], leg_trkpi_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     1609  for(k = 0; k < etaVals.size() - 1; k++)
     1610  {
     1611    HistogramsCollection(&plots_trkpi_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
     1612    GetPtres<Track>(&plots_trkpi_res_pt[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     1613    gr_trkpi_res_pt[k] = EresGraph(&plots_trkpi_res_pt[k]);
     1614
     1615    h_trkpi_eff_pt = GetEffPt<Track>(branchTrackPion, branchParticlePion, "Pion", 211, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     1616    gr_trkpi_eff_pt[k] = TGraphErrors(h_trkpi_eff_pt);
     1617
     1618    s_etaMin = Form("%.1f", etaVals.at(k));
     1619    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1620
     1621    s_eta = "#pi^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1622
     1623    gr_trkpi_res_pt[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1624    gr_trkpi_eff_pt[k].SetName("trkEff_" + s_etaMin + "_" + s_etaMax);
     1625
     1626    addResoGraph(mg_trkpi_res_pt, &gr_trkpi_res_pt[k], leg_trkpi_res_pt, markerStyles.at(k), colors.at(k), s_eta);
     1627    addResoGraph(mg_trkpi_eff_pt, &gr_trkpi_eff_pt[k], leg_trkpi_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    16601628  }
    16611629
    16621630  // loop over pt
    1663   for (k = 0; k < ptVals.size(); k++)
    1664   {
    1665      HistogramsCollectionVsEta(&plots_trkpi_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkpi", 0.0, 2.0);
    1666      GetPtresVsEta<Track>(&plots_trkpi_res_eta[k], branchTrackPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
    1667      gr_trkpi_res_eta[k] = EresGraphVsEta(&plots_trkpi_res_eta[k]);
    1668 
    1669      h_trkpi_eff_eta = GetEffEta<Track>(branchTrackPion, branchParticlePion, "Pion", 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderPion);
    1670      gr_trkpi_eff_eta[k] = TGraphErrors(h_trkpi_eff_eta);
    1671 
    1672      s_pt = Form("#pi^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    1673      if(ptVals.at(k) >= 1000.) s_pt = Form("#pi^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    1674 
    1675      addResoGraph(mg_trkpi_res_eta, &gr_trkpi_res_eta[k], leg_trkpi_res_eta, markerStyles.at(k), colors.at(k), s_pt );
    1676      addResoGraph(mg_trkpi_eff_eta, &gr_trkpi_eff_eta[k], leg_trkpi_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    1677 
    1678   }
    1679 
    1680   TCanvas *c_trkpi_res_pt = new TCanvas("","", 800, 600);
     1631  for(k = 0; k < ptVals.size(); k++)
     1632  {
     1633    HistogramsCollectionVsEta(&plots_trkpi_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkpi", 0.0, 2.0);
     1634    GetPtresVsEta<Track>(&plots_trkpi_res_eta[k], branchTrackPion, branchParticlePion, 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPion);
     1635    gr_trkpi_res_eta[k] = EresGraphVsEta(&plots_trkpi_res_eta[k]);
     1636
     1637    h_trkpi_eff_eta = GetEffEta<Track>(branchTrackPion, branchParticlePion, "Pion", 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderPion);
     1638    gr_trkpi_eff_eta[k] = TGraphErrors(h_trkpi_eff_eta);
     1639
     1640    s_pt = Form("#pi^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     1641    if(ptVals.at(k) >= 1000.) s_pt = Form("#pi^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     1642
     1643    addResoGraph(mg_trkpi_res_eta, &gr_trkpi_res_eta[k], leg_trkpi_res_eta, markerStyles.at(k), colors.at(k), s_pt);
     1644    addResoGraph(mg_trkpi_eff_eta, &gr_trkpi_eff_eta[k], leg_trkpi_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     1645  }
     1646
     1647  TCanvas *c_trkpi_res_pt = new TCanvas("", "", 800, 600);
    16811648
    16821649  mg_trkpi_res_pt->Draw("APE");
     
    16851652  pave->Draw();
    16861653
    1687   c_trkpi_res_pt->Print(pdfOutput+"(","pdf");
    1688   c_trkpi_res_pt->Print(figPath+"img_trkpi_res_pt.pdf","pdf");
    1689   c_trkpi_res_pt->Print(figPath+"img_trkpi_res_pt.png","png");
    1690 
    1691   TCanvas *c_trkpi_res_eta = new TCanvas("","", 800, 600);
     1654  c_trkpi_res_pt->Print(pdfOutput + "(", "pdf");
     1655  c_trkpi_res_pt->Print(figPath + "img_trkpi_res_pt.pdf", "pdf");
     1656  c_trkpi_res_pt->Print(figPath + "img_trkpi_res_pt.png", "png");
     1657
     1658  TCanvas *c_trkpi_res_eta = new TCanvas("", "", 800, 600);
    16921659
    16931660  mg_trkpi_res_eta->Draw("APE");
     
    16961663  pave->Draw();
    16971664
    1698   c_trkpi_res_eta->Print(pdfOutput,"pdf");
    1699   c_trkpi_res_eta->Print(figPath+"img_trkpi_res_eta.pdf","pdf");
    1700   c_trkpi_res_eta->Print(figPath+"img_trkpi_res_eta.png","png");
    1701 
    1702   TCanvas *c_trkpi_eff_pt = new TCanvas("","", 800, 600);
     1665  c_trkpi_res_eta->Print(pdfOutput, "pdf");
     1666  c_trkpi_res_eta->Print(figPath + "img_trkpi_res_eta.pdf", "pdf");
     1667  c_trkpi_res_eta->Print(figPath + "img_trkpi_res_eta.png", "png");
     1668
     1669  TCanvas *c_trkpi_eff_pt = new TCanvas("", "", 800, 600);
    17031670
    17041671  mg_trkpi_eff_pt->Draw("APE");
     
    17071674  pave->Draw();
    17081675
    1709   c_trkpi_eff_pt->Print(pdfOutput,"pdf");
    1710   c_trkpi_eff_pt->Print(figPath+"img_trkpi_eff_pt.pdf","pdf");
    1711   c_trkpi_eff_pt->Print(figPath+"img_trkpi_eff_pt.png","png");
    1712 
    1713   TCanvas *c_trkpi_eff_eta = new TCanvas("","", 800, 600);
     1676  c_trkpi_eff_pt->Print(pdfOutput, "pdf");
     1677  c_trkpi_eff_pt->Print(figPath + "img_trkpi_eff_pt.pdf", "pdf");
     1678  c_trkpi_eff_pt->Print(figPath + "img_trkpi_eff_pt.png", "png");
     1679
     1680  TCanvas *c_trkpi_eff_eta = new TCanvas("", "", 800, 600);
    17141681
    17151682  mg_trkpi_eff_eta->Draw("APE");
     
    17181685  pave->Draw();
    17191686
    1720 
    1721   c_trkpi_eff_eta->Print(pdfOutput,"pdf");
    1722   c_trkpi_eff_eta->Print(figPath+"img_trkpi_eff_eta.pdf","pdf");
    1723   c_trkpi_eff_eta->Print(figPath+"img_trkpi_eff_eta.png","png");
     1687  c_trkpi_eff_eta->Print(pdfOutput, "pdf");
     1688  c_trkpi_eff_eta->Print(figPath + "img_trkpi_eff_eta.pdf", "pdf");
     1689  c_trkpi_eff_eta->Print(figPath + "img_trkpi_eff_eta.png", "png");
    17241690
    17251691  // --------- Electron Tracks  --------- //
    17261692
    1727   TMultiGraph *mg_trkele_res_pt  = new TMultiGraph("","");
    1728   TMultiGraph *mg_trkele_eff_pt  = new TMultiGraph("","");
    1729   TMultiGraph *mg_trkele_res_eta = new TMultiGraph("","");
    1730   TMultiGraph *mg_trkele_eff_eta = new TMultiGraph("","");
    1731 
    1732   TLegend *leg_trkele_res_pt = new TLegend(0.55,0.22,0.90,0.48);
    1733   TLegend *leg_trkele_eff_pt = (TLegend*)leg_trkele_res_pt->Clone();
    1734   TLegend *leg_trkele_res_eta = (TLegend*)leg_trkele_res_pt->Clone();
    1735   TLegend *leg_trkele_eff_eta = (TLegend*)leg_trkele_res_eta->Clone();
    1736 
    1737   TGraphErrors *gr_trkele_res_pt  = new TGraphErrors[n_etabins];
    1738   TGraphErrors *gr_trkele_eff_pt  = new TGraphErrors[n_etabins];
     1693  TMultiGraph *mg_trkele_res_pt = new TMultiGraph("", "");
     1694  TMultiGraph *mg_trkele_eff_pt = new TMultiGraph("", "");
     1695  TMultiGraph *mg_trkele_res_eta = new TMultiGraph("", "");
     1696  TMultiGraph *mg_trkele_eff_eta = new TMultiGraph("", "");
     1697
     1698  TLegend *leg_trkele_res_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     1699  TLegend *leg_trkele_eff_pt = (TLegend *)leg_trkele_res_pt->Clone();
     1700  TLegend *leg_trkele_res_eta = (TLegend *)leg_trkele_res_pt->Clone();
     1701  TLegend *leg_trkele_eff_eta = (TLegend *)leg_trkele_res_eta->Clone();
     1702
     1703  TGraphErrors *gr_trkele_res_pt = new TGraphErrors[n_etabins];
     1704  TGraphErrors *gr_trkele_eff_pt = new TGraphErrors[n_etabins];
    17391705  TGraphErrors *gr_trkele_res_eta = new TGraphErrors[n_ptbins];
    17401706  TGraphErrors *gr_trkele_eff_eta = new TGraphErrors[n_ptbins];
    17411707
    1742   TH1D* h_trkele_eff_pt, *h_trkele_eff_eta;
    1743 
    1744   std::vector<resolPlot> *plots_trkele_res_pt   = new std::vector<resolPlot>[n_etabins];
    1745   std::vector<resolPlot> *plots_trkele_res_eta  = new std::vector<resolPlot>[n_ptbins];
     1708  TH1D *h_trkele_eff_pt, *h_trkele_eff_eta;
     1709
     1710  std::vector<resolPlot> *plots_trkele_res_pt = new std::vector<resolPlot>[n_etabins];
     1711  std::vector<resolPlot> *plots_trkele_res_eta = new std::vector<resolPlot>[n_ptbins];
    17461712
    17471713  // loop over eta bins
    1748   for (k = 0; k < etaVals.size()-1; k++)
    1749   {
    1750      HistogramsCollection(&plots_trkele_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
    1751      GetPtres<Track>(&plots_trkele_res_pt[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    1752      gr_trkele_res_pt[k] = EresGraph(&plots_trkele_res_pt[k]);
    1753 
    1754      h_trkele_eff_pt = GetEffPt<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    1755      gr_trkele_eff_pt[k] = TGraphErrors(h_trkele_eff_pt);
    1756 
    1757      s_etaMin = Form("%.1f",etaVals.at(k));
    1758      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1759 
    1760      s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1761 
    1762      gr_trkele_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1763      gr_trkele_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
    1764 
    1765      addResoGraph(mg_trkele_res_pt, &gr_trkele_res_pt[k], leg_trkele_res_pt, markerStyles.at(k), colors.at(k), s_eta);
    1766      addResoGraph(mg_trkele_eff_pt, &gr_trkele_eff_pt[k], leg_trkele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     1714  for(k = 0; k < etaVals.size() - 1; k++)
     1715  {
     1716    HistogramsCollection(&plots_trkele_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
     1717    GetPtres<Track>(&plots_trkele_res_pt[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     1718    gr_trkele_res_pt[k] = EresGraph(&plots_trkele_res_pt[k]);
     1719
     1720    h_trkele_eff_pt = GetEffPt<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     1721    gr_trkele_eff_pt[k] = TGraphErrors(h_trkele_eff_pt);
     1722
     1723    s_etaMin = Form("%.1f", etaVals.at(k));
     1724    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1725
     1726    s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1727
     1728    gr_trkele_res_pt[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1729    gr_trkele_eff_pt[k].SetName("trkEff_" + s_etaMin + "_" + s_etaMax);
     1730
     1731    addResoGraph(mg_trkele_res_pt, &gr_trkele_res_pt[k], leg_trkele_res_pt, markerStyles.at(k), colors.at(k), s_eta);
     1732    addResoGraph(mg_trkele_eff_pt, &gr_trkele_eff_pt[k], leg_trkele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    17671733  }
    17681734
    17691735  // loop over pt
    1770   for (k = 0; k < ptVals.size(); k++)
    1771   {
    1772      HistogramsCollectionVsEta(&plots_trkele_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkele", 0.0, 2.0);
    1773      GetPtresVsEta<Track>(&plots_trkele_res_eta[k], branchTrackElectron, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
    1774      gr_trkele_res_eta[k] = EresGraphVsEta(&plots_trkele_res_eta[k]);
    1775 
    1776      h_trkele_eff_eta = GetEffEta<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderElectron);
    1777      gr_trkele_eff_eta[k] = TGraphErrors(h_trkele_eff_eta);
    1778 
    1779      s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    1780      if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    1781 
    1782      addResoGraph(mg_trkele_res_eta, &gr_trkele_res_eta[k], leg_trkele_res_eta, markerStyles.at(k), colors.at(k), s_pt );
    1783      addResoGraph(mg_trkele_eff_eta, &gr_trkele_eff_eta[k], leg_trkele_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    1784 
    1785   }
    1786 
    1787   TCanvas *c_trkele_res_pt = new TCanvas("","", 800, 600);
     1736  for(k = 0; k < ptVals.size(); k++)
     1737  {
     1738    HistogramsCollectionVsEta(&plots_trkele_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkele", 0.0, 2.0);
     1739    GetPtresVsEta<Track>(&plots_trkele_res_eta[k], branchTrackElectron, branchParticleElectron, 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderElectron);
     1740    gr_trkele_res_eta[k] = EresGraphVsEta(&plots_trkele_res_eta[k]);
     1741
     1742    h_trkele_eff_eta = GetEffEta<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderElectron);
     1743    gr_trkele_eff_eta[k] = TGraphErrors(h_trkele_eff_eta);
     1744
     1745    s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     1746    if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     1747
     1748    addResoGraph(mg_trkele_res_eta, &gr_trkele_res_eta[k], leg_trkele_res_eta, markerStyles.at(k), colors.at(k), s_pt);
     1749    addResoGraph(mg_trkele_eff_eta, &gr_trkele_eff_eta[k], leg_trkele_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     1750  }
     1751
     1752  TCanvas *c_trkele_res_pt = new TCanvas("", "", 800, 600);
    17881753
    17891754  mg_trkele_res_pt->Draw("APE");
     
    17921757  pave->Draw();
    17931758
    1794   c_trkele_res_pt->Print(pdfOutput,"pdf");
    1795   c_trkele_res_pt->Print(figPath+"img_trkele_res_pt.pdf","pdf");
    1796   c_trkele_res_pt->Print(figPath+"img_trkele_res_pt.png","png");
    1797 
    1798   TCanvas *c_trkele_res_eta = new TCanvas("","", 800, 600);
     1759  c_trkele_res_pt->Print(pdfOutput, "pdf");
     1760  c_trkele_res_pt->Print(figPath + "img_trkele_res_pt.pdf", "pdf");
     1761  c_trkele_res_pt->Print(figPath + "img_trkele_res_pt.png", "png");
     1762
     1763  TCanvas *c_trkele_res_eta = new TCanvas("", "", 800, 600);
    17991764
    18001765  mg_trkele_res_eta->Draw("APE");
     
    18031768  pave->Draw();
    18041769
    1805   c_trkele_res_eta->Print(pdfOutput,"pdf");
    1806   c_trkele_res_eta->Print(figPath+"img_trkele_res_eta.pdf","pdf");
    1807   c_trkele_res_eta->Print(figPath+"img_trkele_res_eta.png","png");
    1808 
    1809   TCanvas *c_trkele_eff_pt = new TCanvas("","", 800, 600);
     1770  c_trkele_res_eta->Print(pdfOutput, "pdf");
     1771  c_trkele_res_eta->Print(figPath + "img_trkele_res_eta.pdf", "pdf");
     1772  c_trkele_res_eta->Print(figPath + "img_trkele_res_eta.png", "png");
     1773
     1774  TCanvas *c_trkele_eff_pt = new TCanvas("", "", 800, 600);
    18101775
    18111776  mg_trkele_eff_pt->Draw("APE");
     
    18141779  pave->Draw();
    18151780
    1816   c_trkele_eff_pt->Print(pdfOutput,"pdf");
    1817   c_trkele_eff_pt->Print(figPath+"img_trkele_eff_pt.pdf","pdf");
    1818   c_trkele_eff_pt->Print(figPath+"img_trkele_eff_pt.png","png");
    1819 
    1820   TCanvas *c_trkele_eff_eta = new TCanvas("","", 800, 600);
     1781  c_trkele_eff_pt->Print(pdfOutput, "pdf");
     1782  c_trkele_eff_pt->Print(figPath + "img_trkele_eff_pt.pdf", "pdf");
     1783  c_trkele_eff_pt->Print(figPath + "img_trkele_eff_pt.png", "png");
     1784
     1785  TCanvas *c_trkele_eff_eta = new TCanvas("", "", 800, 600);
    18211786
    18221787  mg_trkele_eff_eta->Draw("APE");
     
    18251790  pave->Draw();
    18261791
    1827   c_trkele_eff_eta->Print(pdfOutput,"pdf");
    1828   c_trkele_eff_eta->Print(figPath+"img_trkele_eff_eta.pdf","pdf");
    1829   c_trkele_eff_eta->Print(figPath+"img_trkele_eff_eta.png","png");
    1830 
     1792  c_trkele_eff_eta->Print(pdfOutput, "pdf");
     1793  c_trkele_eff_eta->Print(figPath + "img_trkele_eff_eta.pdf", "pdf");
     1794  c_trkele_eff_eta->Print(figPath + "img_trkele_eff_eta.png", "png");
    18311795
    18321796  // --------- Muon Tracks  --------- //
    18331797
    1834   TMultiGraph *mg_trkmu_res_pt  = new TMultiGraph("","");
    1835   TMultiGraph *mg_trkmu_eff_pt  = new TMultiGraph("","");
    1836   TMultiGraph *mg_trkmu_res_eta = new TMultiGraph("","");
    1837   TMultiGraph *mg_trkmu_eff_eta = new TMultiGraph("","");
    1838 
    1839   TLegend *leg_trkmu_res_pt = new TLegend(0.55,0.22,0.90,0.48);
    1840   TLegend *leg_trkmu_eff_pt = (TLegend*)leg_trkmu_res_pt->Clone();
    1841 
    1842   TLegend *leg_trkmu_res_eta = (TLegend*)leg_trkmu_res_pt->Clone();
    1843   TLegend *leg_trkmu_eff_eta = (TLegend*)leg_trkmu_res_eta->Clone();
    1844 
    1845 
    1846   TGraphErrors *gr_trkmu_res_pt  = new TGraphErrors[n_etabins];
    1847   TGraphErrors *gr_trkmu_eff_pt  = new TGraphErrors[n_etabins];
     1798  TMultiGraph *mg_trkmu_res_pt = new TMultiGraph("", "");
     1799  TMultiGraph *mg_trkmu_eff_pt = new TMultiGraph("", "");
     1800  TMultiGraph *mg_trkmu_res_eta = new TMultiGraph("", "");
     1801  TMultiGraph *mg_trkmu_eff_eta = new TMultiGraph("", "");
     1802
     1803  TLegend *leg_trkmu_res_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     1804  TLegend *leg_trkmu_eff_pt = (TLegend *)leg_trkmu_res_pt->Clone();
     1805
     1806  TLegend *leg_trkmu_res_eta = (TLegend *)leg_trkmu_res_pt->Clone();
     1807  TLegend *leg_trkmu_eff_eta = (TLegend *)leg_trkmu_res_eta->Clone();
     1808
     1809  TGraphErrors *gr_trkmu_res_pt = new TGraphErrors[n_etabins];
     1810  TGraphErrors *gr_trkmu_eff_pt = new TGraphErrors[n_etabins];
    18481811  TGraphErrors *gr_trkmu_res_eta = new TGraphErrors[n_ptbins];
    18491812  TGraphErrors *gr_trkmu_eff_eta = new TGraphErrors[n_ptbins];
    18501813
    1851   TH1D* h_trkmu_eff_pt, *h_trkmu_eff_eta;
    1852 
    1853   std::vector<resolPlot> *plots_trkmu_res_pt   = new std::vector<resolPlot>[n_etabins];
    1854   std::vector<resolPlot> *plots_trkmu_res_eta  = new std::vector<resolPlot>[n_ptbins];
     1814  TH1D *h_trkmu_eff_pt, *h_trkmu_eff_eta;
     1815
     1816  std::vector<resolPlot> *plots_trkmu_res_pt = new std::vector<resolPlot>[n_etabins];
     1817  std::vector<resolPlot> *plots_trkmu_res_eta = new std::vector<resolPlot>[n_ptbins];
    18551818
    18561819  // loop over eta bins
    1857   for (k = 0; k < etaVals.size()-1; k++)
    1858   {
    1859      HistogramsCollection(&plots_trkmu_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkmu");
    1860      GetPtres<Track>(&plots_trkmu_res_pt[k], branchTrackMuon, branchParticleMuon, 13, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
    1861      gr_trkmu_res_pt[k] = EresGraph(&plots_trkmu_res_pt[k]);
    1862 
    1863      h_trkmu_eff_pt = GetEffPt<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
    1864      gr_trkmu_eff_pt[k] = TGraphErrors(h_trkmu_eff_pt);
    1865 
    1866      s_etaMin = Form("%.1f",etaVals.at(k));
    1867      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1868 
    1869      s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1870 
    1871      gr_trkmu_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1872      gr_trkmu_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
    1873 
    1874      addResoGraph(mg_trkmu_res_pt, &gr_trkmu_res_pt[k], leg_trkmu_res_pt, markerStyles.at(k), colors.at(k), s_eta);
    1875      addResoGraph(mg_trkmu_eff_pt, &gr_trkmu_eff_pt[k], leg_trkmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     1820  for(k = 0; k < etaVals.size() - 1; k++)
     1821  {
     1822    HistogramsCollection(&plots_trkmu_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkmu");
     1823    GetPtres<Track>(&plots_trkmu_res_pt[k], branchTrackMuon, branchParticleMuon, 13, etaVals.at(k), etaVals.at(k + 1), treeReaderMuon);
     1824    gr_trkmu_res_pt[k] = EresGraph(&plots_trkmu_res_pt[k]);
     1825
     1826    h_trkmu_eff_pt = GetEffPt<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderMuon);
     1827    gr_trkmu_eff_pt[k] = TGraphErrors(h_trkmu_eff_pt);
     1828
     1829    s_etaMin = Form("%.1f", etaVals.at(k));
     1830    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1831
     1832    s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1833
     1834    gr_trkmu_res_pt[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1835    gr_trkmu_eff_pt[k].SetName("trkEff_" + s_etaMin + "_" + s_etaMax);
     1836
     1837    addResoGraph(mg_trkmu_res_pt, &gr_trkmu_res_pt[k], leg_trkmu_res_pt, markerStyles.at(k), colors.at(k), s_eta);
     1838    addResoGraph(mg_trkmu_eff_pt, &gr_trkmu_eff_pt[k], leg_trkmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    18761839  }
    18771840
    18781841  // loop over pt
    1879   for (k = 0; k < ptVals.size(); k++)
    1880   {
    1881      HistogramsCollectionVsEta(&plots_trkmu_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkmu", 0.0, 2.0);
    1882      GetPtresVsEta<Track>(&plots_trkmu_res_eta[k], branchTrackMuon, branchParticleMuon, 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderMuon);
    1883      gr_trkmu_res_eta[k] = EresGraphVsEta(&plots_trkmu_res_eta[k]);
    1884 
    1885      h_trkmu_eff_eta = GetEffEta<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderMuon);
    1886      gr_trkmu_eff_eta[k] = TGraphErrors(h_trkmu_eff_eta);
    1887 
    1888      s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    1889      if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    1890 
    1891      addResoGraph(mg_trkmu_res_eta, &gr_trkmu_res_eta[k], leg_trkmu_res_eta, markerStyles.at(k), colors.at(k), s_pt );
    1892      addResoGraph(mg_trkmu_eff_eta, &gr_trkmu_eff_eta[k], leg_trkmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    1893 
    1894   }
    1895 
    1896   TCanvas *c_trkmu_res_pt = new TCanvas("","", 800, 600);
     1842  for(k = 0; k < ptVals.size(); k++)
     1843  {
     1844    HistogramsCollectionVsEta(&plots_trkmu_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkmu", 0.0, 2.0);
     1845    GetPtresVsEta<Track>(&plots_trkmu_res_eta[k], branchTrackMuon, branchParticleMuon, 13, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderMuon);
     1846    gr_trkmu_res_eta[k] = EresGraphVsEta(&plots_trkmu_res_eta[k]);
     1847
     1848    h_trkmu_eff_eta = GetEffEta<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderMuon);
     1849    gr_trkmu_eff_eta[k] = TGraphErrors(h_trkmu_eff_eta);
     1850
     1851    s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     1852    if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     1853
     1854    addResoGraph(mg_trkmu_res_eta, &gr_trkmu_res_eta[k], leg_trkmu_res_eta, markerStyles.at(k), colors.at(k), s_pt);
     1855    addResoGraph(mg_trkmu_eff_eta, &gr_trkmu_eff_eta[k], leg_trkmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     1856  }
     1857
     1858  TCanvas *c_trkmu_res_pt = new TCanvas("", "", 800, 600);
    18971859
    18981860  mg_trkmu_res_pt->Draw("APE");
     
    19011863  pave->Draw();
    19021864
    1903   c_trkmu_res_pt->Print(pdfOutput,"pdf");
    1904   c_trkmu_res_pt->Print(figPath+"img_trkmu_res_pt.pdf","pdf");
    1905   c_trkmu_res_pt->Print(figPath+"img_trkmu_res_pt.png","png");
    1906 
    1907   TCanvas *c_trkmu_res_eta = new TCanvas("","", 800, 600);
     1865  c_trkmu_res_pt->Print(pdfOutput, "pdf");
     1866  c_trkmu_res_pt->Print(figPath + "img_trkmu_res_pt.pdf", "pdf");
     1867  c_trkmu_res_pt->Print(figPath + "img_trkmu_res_pt.png", "png");
     1868
     1869  TCanvas *c_trkmu_res_eta = new TCanvas("", "", 800, 600);
    19081870
    19091871  mg_trkmu_res_eta->Draw("APE");
     
    19121874  pave->Draw();
    19131875
    1914   c_trkmu_res_eta->Print(pdfOutput,"pdf");
    1915   c_trkmu_res_eta->Print(figPath+"img_trkmu_res_eta.pdf","pdf");
    1916   c_trkmu_res_eta->Print(figPath+"img_trkmu_res_eta.png","png");
    1917 
    1918   TCanvas *c_trkmu_eff_pt = new TCanvas("","", 800, 600);
     1876  c_trkmu_res_eta->Print(pdfOutput, "pdf");
     1877  c_trkmu_res_eta->Print(figPath + "img_trkmu_res_eta.pdf", "pdf");
     1878  c_trkmu_res_eta->Print(figPath + "img_trkmu_res_eta.png", "png");
     1879
     1880  TCanvas *c_trkmu_eff_pt = new TCanvas("", "", 800, 600);
    19191881
    19201882  mg_trkmu_eff_pt->Draw("APE");
     
    19231885  pave->Draw();
    19241886
    1925   c_trkmu_eff_pt->Print(pdfOutput,"pdf");
    1926   c_trkmu_eff_pt->Print(figPath+"img_trkmu_eff_pt.pdf","pdf");
    1927   c_trkmu_eff_pt->Print(figPath+"img_trkmu_eff_pt.png","png");
    1928 
    1929   TCanvas *c_trkmu_eff_eta = new TCanvas("","", 800, 600);
     1887  c_trkmu_eff_pt->Print(pdfOutput, "pdf");
     1888  c_trkmu_eff_pt->Print(figPath + "img_trkmu_eff_pt.pdf", "pdf");
     1889  c_trkmu_eff_pt->Print(figPath + "img_trkmu_eff_pt.png", "png");
     1890
     1891  TCanvas *c_trkmu_eff_eta = new TCanvas("", "", 800, 600);
    19301892
    19311893  mg_trkmu_eff_eta->Draw("APE");
     
    19341896  pave->Draw();
    19351897
    1936   c_trkmu_eff_eta->Print(pdfOutput,"pdf");
    1937   c_trkmu_eff_eta->Print(figPath+"img_trkmu_eff_eta.pdf","pdf");
    1938   c_trkmu_eff_eta->Print(figPath+"img_trkmu_eff_eta.png","png");
    1939 
     1898  c_trkmu_eff_eta->Print(pdfOutput, "pdf");
     1899  c_trkmu_eff_eta->Print(figPath + "img_trkmu_eff_eta.pdf", "pdf");
     1900  c_trkmu_eff_eta->Print(figPath + "img_trkmu_eff_eta.png", "png");
    19401901
    19411902  //////////////////////
     
    19431904  //////////////////////
    19441905
    1945 
    1946   TMultiGraph *mg_ecal_res_e  = new TMultiGraph("","");
    1947   TMultiGraph *mg_ecal_res_eta = new TMultiGraph("","");
    1948 
    1949   TLegend *leg_ecal_res_e = new TLegend(0.55,0.64,0.90,0.90);
    1950   TLegend *leg_ecal_res_eta = new TLegend(0.60,0.59,0.95,0.90);
    1951 
    1952   TGraphErrors *gr_ecal_res_e    = new TGraphErrors[n_etabins];
    1953   TGraphErrors *gr_ecal_res_eta  = new TGraphErrors[n_ptbins];
    1954 
    1955   std::vector<resolPlot> *plots_ecal_res_e   = new std::vector<resolPlot>[n_etabins];
     1906  TMultiGraph *mg_ecal_res_e = new TMultiGraph("", "");
     1907  TMultiGraph *mg_ecal_res_eta = new TMultiGraph("", "");
     1908
     1909  TLegend *leg_ecal_res_e = new TLegend(0.55, 0.64, 0.90, 0.90);
     1910  TLegend *leg_ecal_res_eta = new TLegend(0.60, 0.59, 0.95, 0.90);
     1911
     1912  TGraphErrors *gr_ecal_res_e = new TGraphErrors[n_etabins];
     1913  TGraphErrors *gr_ecal_res_eta = new TGraphErrors[n_ptbins];
     1914
     1915  std::vector<resolPlot> *plots_ecal_res_e = new std::vector<resolPlot>[n_etabins];
    19561916  std::vector<resolPlot> *plots_ecal_res_eta = new std::vector<resolPlot>[n_ptbins];
    19571917
    19581918  // loop over eta bins
    1959   for (k = 0; k < etaVals.size()-1; k++)
    1960   {
    1961      HistogramsCollection(&plots_ecal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "ecal");
    1962      GetEres<Tower>(&plots_ecal_res_e[k], branchTowerPhoton, branchParticlePhoton, 22, etaVals.at(k), etaVals.at(k+1), treeReaderPhoton);
    1963      gr_ecal_res_e[k] = EresGraph(&plots_ecal_res_e[k]);
    1964 
    1965      s_etaMin = Form("%.1f",etaVals.at(k));
    1966      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1967 
    1968      s_eta = "#gamma , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1969 
    1970      gr_ecal_res_e[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1971 
    1972      addResoGraph(mg_ecal_res_e, &gr_ecal_res_e[k], leg_ecal_res_e, markerStyles.at(k), colors.at(k), s_eta);
     1919  for(k = 0; k < etaVals.size() - 1; k++)
     1920  {
     1921    HistogramsCollection(&plots_ecal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "ecal");
     1922    GetEres<Tower>(&plots_ecal_res_e[k], branchTowerPhoton, branchParticlePhoton, 22, etaVals.at(k), etaVals.at(k + 1), treeReaderPhoton);
     1923    gr_ecal_res_e[k] = EresGraph(&plots_ecal_res_e[k]);
     1924
     1925    s_etaMin = Form("%.1f", etaVals.at(k));
     1926    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1927
     1928    s_eta = "#gamma , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1929
     1930    gr_ecal_res_e[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1931
     1932    addResoGraph(mg_ecal_res_e, &gr_ecal_res_e[k], leg_ecal_res_e, markerStyles.at(k), colors.at(k), s_eta);
    19731933  }
    19741934
    19751935  // loop over pt
    1976   for (k = 0; k < ptVals.size(); k++)
    1977   {
    1978      HistogramsCollectionVsEta(&plots_ecal_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "ecal", 0.0, 2.0);
    1979      GetEresVsEta<Tower>(&plots_ecal_res_eta[k], branchTowerPhoton, branchParticlePhoton, 22, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPhoton);
    1980      gr_ecal_res_eta[k] = EresGraphVsEta(&plots_ecal_res_eta[k]);
    1981 
    1982      s_e = Form("#gamma , E = %.0f GeV",ptVals.at(k));
    1983      if(ptVals.at(k) >= 1000.) s_e = Form("#gamma , E = %.0f TeV",ptVals.at(k)/1000.);
    1984 
    1985      addResoGraph(mg_ecal_res_eta, &gr_ecal_res_eta[k], leg_ecal_res_eta, markerStyles.at(k), colors.at(k), s_e );
    1986   }
    1987 
    1988   TCanvas *c_ecal_res_e = new TCanvas("","", 800, 600);
     1936  for(k = 0; k < ptVals.size(); k++)
     1937  {
     1938    HistogramsCollectionVsEta(&plots_ecal_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "ecal", 0.0, 2.0);
     1939    GetEresVsEta<Tower>(&plots_ecal_res_eta[k], branchTowerPhoton, branchParticlePhoton, 22, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPhoton);
     1940    gr_ecal_res_eta[k] = EresGraphVsEta(&plots_ecal_res_eta[k]);
     1941
     1942    s_e = Form("#gamma , E = %.0f GeV", ptVals.at(k));
     1943    if(ptVals.at(k) >= 1000.) s_e = Form("#gamma , E = %.0f TeV", ptVals.at(k) / 1000.);
     1944
     1945    addResoGraph(mg_ecal_res_eta, &gr_ecal_res_eta[k], leg_ecal_res_eta, markerStyles.at(k), colors.at(k), s_e);
     1946  }
     1947
     1948  TCanvas *c_ecal_res_e = new TCanvas("", "", 800, 600);
    19891949
    19901950  mg_ecal_res_e->Draw("APE");
    1991  // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
     1951  // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
    19921952  DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.0, 20, "E [GeV]", "(ECAL resolution in E)/E (%)", true, false);
    19931953  leg_ecal_res_e->Draw();
    19941954  pave->Draw();
    19951955
    1996   c_ecal_res_e->Print(pdfOutput,"pdf");
    1997   c_ecal_res_e->Print(figPath+"img_ecal_res_e.pdf","pdf");
    1998   c_ecal_res_e->Print(figPath+"img_ecal_res_e.png","png");
    1999 
    2000   TCanvas *c_ecal_res_eta = new TCanvas("","", 800, 600);
     1956  c_ecal_res_e->Print(pdfOutput, "pdf");
     1957  c_ecal_res_e->Print(figPath + "img_ecal_res_e.pdf", "pdf");
     1958  c_ecal_res_e->Print(figPath + "img_ecal_res_e.png", "png");
     1959
     1960  TCanvas *c_ecal_res_eta = new TCanvas("", "", 800, 600);
    20011961
    20021962  mg_ecal_res_eta->Draw("APE");
     
    20061966  pave->Draw();
    20071967
    2008   c_ecal_res_eta->Print(pdfOutput,"pdf");
    2009   c_ecal_res_eta->Print(figPath+"img_ecal_res_eta.pdf","pdf");
    2010   c_ecal_res_eta->Print(figPath+"img_ecal_res_eta.png","png");
     1968  c_ecal_res_eta->Print(pdfOutput, "pdf");
     1969  c_ecal_res_eta->Print(figPath + "img_ecal_res_eta.pdf", "pdf");
     1970  c_ecal_res_eta->Print(figPath + "img_ecal_res_eta.png", "png");
    20111971
    20121972  //////////////////////
     
    20141974  //////////////////////
    20151975
    2016 
    2017   TMultiGraph *mg_hcal_res_e  = new TMultiGraph("","");
    2018   TMultiGraph *mg_hcal_res_eta = new TMultiGraph("","");
    2019 
    2020   TLegend *leg_hcal_res_e = new TLegend(0.55,0.64,0.90,0.90);
    2021   TLegend *leg_hcal_res_eta = new TLegend(0.60,0.59,0.95,0.90);
    2022 
    2023   TGraphErrors *gr_hcal_res_e   = new TGraphErrors[n_etabins];
     1976  TMultiGraph *mg_hcal_res_e = new TMultiGraph("", "");
     1977  TMultiGraph *mg_hcal_res_eta = new TMultiGraph("", "");
     1978
     1979  TLegend *leg_hcal_res_e = new TLegend(0.55, 0.64, 0.90, 0.90);
     1980  TLegend *leg_hcal_res_eta = new TLegend(0.60, 0.59, 0.95, 0.90);
     1981
     1982  TGraphErrors *gr_hcal_res_e = new TGraphErrors[n_etabins];
    20241983  TGraphErrors *gr_hcal_res_eta = new TGraphErrors[n_ptbins];
    20251984
    2026   std::vector<resolPlot> *plots_hcal_res_e   = new std::vector<resolPlot>[n_etabins];
     1985  std::vector<resolPlot> *plots_hcal_res_e = new std::vector<resolPlot>[n_etabins];
    20271986  std::vector<resolPlot> *plots_hcal_res_eta = new std::vector<resolPlot>[n_ptbins];
    20281987
    20291988  // loop over eta bins
    2030   for (k = 0; k < etaVals.size()-1; k++)
    2031   {
    2032      HistogramsCollection(&plots_hcal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "hcal");
    2033      GetEres<Tower>(&plots_hcal_res_e[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, etaVals.at(k), etaVals.at(k+1), treeReaderNeutralHadron);
    2034 
    2035      gr_hcal_res_e[k] = EresGraph(&plots_hcal_res_e[k]);
    2036 
    2037      s_etaMin = Form("%.1f",etaVals.at(k));
    2038      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2039 
    2040      s_eta = "n , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2041 
    2042      gr_hcal_res_e[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    2043 
    2044      addResoGraph(mg_hcal_res_e, &gr_hcal_res_e[k], leg_hcal_res_e, markerStyles.at(k), colors.at(k), s_eta);
     1989  for(k = 0; k < etaVals.size() - 1; k++)
     1990  {
     1991    HistogramsCollection(&plots_hcal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "hcal");
     1992    GetEres<Tower>(&plots_hcal_res_e[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, etaVals.at(k), etaVals.at(k + 1), treeReaderNeutralHadron);
     1993
     1994    gr_hcal_res_e[k] = EresGraph(&plots_hcal_res_e[k]);
     1995
     1996    s_etaMin = Form("%.1f", etaVals.at(k));
     1997    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1998
     1999    s_eta = "n , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2000
     2001    gr_hcal_res_e[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     2002
     2003    addResoGraph(mg_hcal_res_e, &gr_hcal_res_e[k], leg_hcal_res_e, markerStyles.at(k), colors.at(k), s_eta);
    20452004  }
    20462005
    20472006  // loop over pt
    2048   for (k = 0; k < ptVals.size(); k++)
    2049   {
    2050      HistogramsCollectionVsEta(&plots_hcal_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "hcal", 0.0, 2.0);
    2051      GetEresVsEta<Tower>(&plots_hcal_res_eta[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderNeutralHadron);
    2052      gr_hcal_res_eta[k] = EresGraphVsEta(&plots_hcal_res_eta[k]);
    2053 
    2054      s_e = Form("n , E = %.0f GeV",ptVals.at(k));
    2055      if(ptVals.at(k) >= 1000.) s_e = Form("n , E = %.0f TeV",ptVals.at(k)/1000.);
    2056 
    2057      addResoGraph(mg_hcal_res_eta, &gr_hcal_res_eta[k], leg_hcal_res_eta, markerStyles.at(k), colors.at(k), s_e );
    2058   }
    2059 
    2060 
    2061   TCanvas *c_hcal_res_e = new TCanvas("","", 800, 600);
     2007  for(k = 0; k < ptVals.size(); k++)
     2008  {
     2009    HistogramsCollectionVsEta(&plots_hcal_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "hcal", 0.0, 2.0);
     2010    GetEresVsEta<Tower>(&plots_hcal_res_eta[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderNeutralHadron);
     2011    gr_hcal_res_eta[k] = EresGraphVsEta(&plots_hcal_res_eta[k]);
     2012
     2013    s_e = Form("n , E = %.0f GeV", ptVals.at(k));
     2014    if(ptVals.at(k) >= 1000.) s_e = Form("n , E = %.0f TeV", ptVals.at(k) / 1000.);
     2015
     2016    addResoGraph(mg_hcal_res_eta, &gr_hcal_res_eta[k], leg_hcal_res_eta, markerStyles.at(k), colors.at(k), s_e);
     2017  }
     2018
     2019  TCanvas *c_hcal_res_e = new TCanvas("", "", 800, 600);
    20622020
    20632021  mg_hcal_res_e->Draw("APE");
     
    20672025  pave->Draw();
    20682026
    2069   c_hcal_res_e->Print(pdfOutput,"pdf");
    2070   c_hcal_res_e->Print(figPath+"img_hcal_res_e.pdf","pdf");
    2071   c_hcal_res_e->Print(figPath+"img_hcal_res_e.png","png");
    2072 
    2073   TCanvas *c_hcal_res_eta = new TCanvas("","", 800, 600);
     2027  c_hcal_res_e->Print(pdfOutput, "pdf");
     2028  c_hcal_res_e->Print(figPath + "img_hcal_res_e.pdf", "pdf");
     2029  c_hcal_res_e->Print(figPath + "img_hcal_res_e.png", "png");
     2030
     2031  TCanvas *c_hcal_res_eta = new TCanvas("", "", 800, 600);
    20742032
    20752033  mg_hcal_res_eta->Draw("APE");
     
    20792037  pave->Draw();
    20802038
    2081   c_hcal_res_eta->Print(pdfOutput,"pdf");
    2082   c_hcal_res_eta->Print(figPath+"img_hcal_res_eta.pdf","pdf");
    2083   c_hcal_res_eta->Print(figPath+"img_hcal_res_eta.png","png");
     2039  c_hcal_res_eta->Print(pdfOutput, "pdf");
     2040  c_hcal_res_eta->Print(figPath + "img_hcal_res_eta.pdf", "pdf");
     2041  c_hcal_res_eta->Print(figPath + "img_hcal_res_eta.png", "png");
    20842042
    20852043  ////////////////////
     
    20982056  TGraphErrors *gr_trkele_res_eeta = new TGraphErrors[n_ptbins];
    20992057
    2100   std::vector<resolPlot> *plots_pfele_res_e     = new std::vector<resolPlot>[n_etabins];
    2101   std::vector<resolPlot> *plots_pfele_res_eta   = new std::vector<resolPlot>[n_ptbins];
    2102   std::vector<resolPlot> *plots_trkele_res_e    = new std::vector<resolPlot>[n_etabins];
     2058  std::vector<resolPlot> *plots_pfele_res_e = new std::vector<resolPlot>[n_etabins];
     2059  std::vector<resolPlot> *plots_pfele_res_eta = new std::vector<resolPlot>[n_ptbins];
     2060  std::vector<resolPlot> *plots_trkele_res_e = new std::vector<resolPlot>[n_etabins];
    21032061  std::vector<resolPlot> *plots_trkele_res_eeta = new std::vector<resolPlot>[n_ptbins];
    21042062
     
    21062064  TCanvas *c_pfele_res_eta[n_ptbins];
    21072065
    2108 
    21092066  // loop over eta bins
    2110   for (k = 0; k < etaVals.size()-1; k++)
    2111   {
    2112      mg_pfele_res_e[k] = new TMultiGraph("","");
    2113      leg_pfele_res_e[k] = new TLegend(0.40,0.60,0.75,0.90);
    2114 
    2115      HistogramsCollection(&plots_pfele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfele");
    2116      GetEres<Electron>(&plots_pfele_res_e[k], branchElectronPF, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    2117      gr_pfele_res_e[k] = EresGraph(&plots_pfele_res_e[k]);
    2118 
    2119      HistogramsCollection(&plots_trkele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
    2120      GetEres<Track>(&plots_trkele_res_e[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    2121      gr_trkele_res_e[k] = EresGraph(&plots_trkele_res_e[k]);
    2122 
    2123      s_etaMin = Form("%.1f",etaVals.at(k));
    2124      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2125      s_eta    = "e^{ #pm}, "+ s_etaMin + " < | #eta | < " + s_etaMax;
    2126 
    2127      leg_pfele_res_e[k]->SetTextFont(132);
    2128      leg_pfele_res_e[k]->SetHeader(s_eta);
    2129 
    2130      addResoGraph(mg_pfele_res_e[k], &gr_ecal_res_e[k], leg_pfele_res_e[k], markerStyles.at(0), colors.at(0), "ECAL");
    2131      addResoGraph(mg_pfele_res_e[k], &gr_trkele_res_e[k], leg_pfele_res_e[k], markerStyles.at(1), colors.at(1), "Track");
    2132      addResoGraph(mg_pfele_res_e[k], &gr_pfele_res_e[k], leg_pfele_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2133 
    2134      c_pfele_res_e[k] = new TCanvas("","", 800, 600);
    2135 
    2136      mg_pfele_res_e[k]->Draw("APE");
    2137      //DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
    2138      DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.0, 20, "E [GeV]", "(resolution in E)/E (%)", true, false);
    2139      leg_pfele_res_e[k]->Draw();
    2140      pave->Draw();
    2141 
    2142      TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
    2143 
    2144      c_pfele_res_e[k]->Print(pdfOutput,"pdf");
    2145      c_pfele_res_e[k]->Print(figPath+"img_pfele_res_"+s_etarange+"e.pdf","pdf");
    2146      c_pfele_res_e[k]->Print(figPath+"img_pfele_res_"+s_etarange+"e.png","png");
    2147 
    2148   }
    2149 
    2150 
    2151     // loop over eta bins
    2152   for (k = 0; k < ptVals.size(); k++)
    2153   {
    2154 
    2155      mg_pfele_res_eta[k] = new TMultiGraph("","");
    2156      leg_pfele_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
    2157 
    2158      HistogramsCollectionVsEta(&plots_pfele_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfele", 0.0, 2.0);
    2159      GetEresVsEta<Electron>(&plots_pfele_res_eta[k], branchElectronPF, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
    2160      gr_pfele_res_eta[k] = EresGraphVsEta(&plots_pfele_res_eta[k]);
    2161 
    2162      HistogramsCollectionVsEta(&plots_trkele_res_eeta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkele", 0.0, 2.0);
    2163      GetEresVsEta<Track>(&plots_trkele_res_eeta[k], branchTrackElectron, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
    2164      gr_trkele_res_eeta[k] = EresGraphVsEta(&plots_trkele_res_eeta[k]);
    2165 
    2166      s_e = Form("e^{ #pm}, E = %.0f GeV",ptVals.at(k));
    2167      if(ptVals.at(k) >= 1000.) s_e = Form("e^{ #pm}, E = %.0f TeV",ptVals.at(k)/1000.);
    2168 
    2169 
    2170      leg_pfele_res_eta[k]->SetTextFont(132);
    2171      leg_pfele_res_eta[k]->SetHeader(s_e);
    2172 
    2173      addResoGraph(mg_pfele_res_eta[k], &gr_ecal_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(0), colors.at(0), "ECAL");
    2174      addResoGraph(mg_pfele_res_eta[k], &gr_trkele_res_eeta[k], leg_pfele_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
    2175      addResoGraph(mg_pfele_res_eta[k], &gr_pfele_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2176 
    2177      c_pfele_res_eta[k] = new TCanvas("","", 800, 600);
    2178 
    2179      mg_pfele_res_eta[k]->Draw("APE");
    2180      //DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
    2181      DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
    2182      leg_pfele_res_eta[k]->Draw();
    2183      pave->Draw();
    2184 
    2185      TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
    2186 
    2187      c_pfele_res_eta[k]->Print(pdfOutput,"pdf");
    2188      c_pfele_res_eta[k]->Print(figPath+"img_pfele_res_"+s_ptrange+"eta.pdf","pdf");
    2189      c_pfele_res_eta[k]->Print(figPath+"img_pfele_res_"+s_ptrange+"eta.png","png");
    2190 
     2067  for(k = 0; k < etaVals.size() - 1; k++)
     2068  {
     2069    mg_pfele_res_e[k] = new TMultiGraph("", "");
     2070    leg_pfele_res_e[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2071
     2072    HistogramsCollection(&plots_pfele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfele");
     2073    GetEres<Electron>(&plots_pfele_res_e[k], branchElectronPF, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     2074    gr_pfele_res_e[k] = EresGraph(&plots_pfele_res_e[k]);
     2075
     2076    HistogramsCollection(&plots_trkele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
     2077    GetEres<Track>(&plots_trkele_res_e[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     2078    gr_trkele_res_e[k] = EresGraph(&plots_trkele_res_e[k]);
     2079
     2080    s_etaMin = Form("%.1f", etaVals.at(k));
     2081    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2082    s_eta = "e^{ #pm}, " + s_etaMin + " < | #eta | < " + s_etaMax;
     2083
     2084    leg_pfele_res_e[k]->SetTextFont(132);
     2085    leg_pfele_res_e[k]->SetHeader(s_eta);
     2086
     2087    addResoGraph(mg_pfele_res_e[k], &gr_ecal_res_e[k], leg_pfele_res_e[k], markerStyles.at(0), colors.at(0), "ECAL");
     2088    addResoGraph(mg_pfele_res_e[k], &gr_trkele_res_e[k], leg_pfele_res_e[k], markerStyles.at(1), colors.at(1), "Track");
     2089    addResoGraph(mg_pfele_res_e[k], &gr_pfele_res_e[k], leg_pfele_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2090
     2091    c_pfele_res_e[k] = new TCanvas("", "", 800, 600);
     2092
     2093    mg_pfele_res_e[k]->Draw("APE");
     2094    //DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
     2095    DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.0, 20, "E [GeV]", "(resolution in E)/E (%)", true, false);
     2096    leg_pfele_res_e[k]->Draw();
     2097    pave->Draw();
     2098
     2099    TString s_etarange = "eta_" + s_etaMin + "_" + s_etaMax + "_";
     2100
     2101    c_pfele_res_e[k]->Print(pdfOutput, "pdf");
     2102    c_pfele_res_e[k]->Print(figPath + "img_pfele_res_" + s_etarange + "e.pdf", "pdf");
     2103    c_pfele_res_e[k]->Print(figPath + "img_pfele_res_" + s_etarange + "e.png", "png");
     2104  }
     2105
     2106  // loop over eta bins
     2107  for(k = 0; k < ptVals.size(); k++)
     2108  {
     2109
     2110    mg_pfele_res_eta[k] = new TMultiGraph("", "");
     2111    leg_pfele_res_eta[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2112
     2113    HistogramsCollectionVsEta(&plots_pfele_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "pfele", 0.0, 2.0);
     2114    GetEresVsEta<Electron>(&plots_pfele_res_eta[k], branchElectronPF, branchParticleElectron, 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderElectron);
     2115    gr_pfele_res_eta[k] = EresGraphVsEta(&plots_pfele_res_eta[k]);
     2116
     2117    HistogramsCollectionVsEta(&plots_trkele_res_eeta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkele", 0.0, 2.0);
     2118    GetEresVsEta<Track>(&plots_trkele_res_eeta[k], branchTrackElectron, branchParticleElectron, 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderElectron);
     2119    gr_trkele_res_eeta[k] = EresGraphVsEta(&plots_trkele_res_eeta[k]);
     2120
     2121    s_e = Form("e^{ #pm}, E = %.0f GeV", ptVals.at(k));
     2122    if(ptVals.at(k) >= 1000.) s_e = Form("e^{ #pm}, E = %.0f TeV", ptVals.at(k) / 1000.);
     2123
     2124    leg_pfele_res_eta[k]->SetTextFont(132);
     2125    leg_pfele_res_eta[k]->SetHeader(s_e);
     2126
     2127    addResoGraph(mg_pfele_res_eta[k], &gr_ecal_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(0), colors.at(0), "ECAL");
     2128    addResoGraph(mg_pfele_res_eta[k], &gr_trkele_res_eeta[k], leg_pfele_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
     2129    addResoGraph(mg_pfele_res_eta[k], &gr_pfele_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2130
     2131    c_pfele_res_eta[k] = new TCanvas("", "", 800, 600);
     2132
     2133    mg_pfele_res_eta[k]->Draw("APE");
     2134    //DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
     2135    DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
     2136    leg_pfele_res_eta[k]->Draw();
     2137    pave->Draw();
     2138
     2139    TString s_ptrange = Form("pt_%.0f_", ptVals.at(k));
     2140
     2141    c_pfele_res_eta[k]->Print(pdfOutput, "pdf");
     2142    c_pfele_res_eta[k]->Print(figPath + "img_pfele_res_" + s_ptrange + "eta.pdf", "pdf");
     2143    c_pfele_res_eta[k]->Print(figPath + "img_pfele_res_" + s_ptrange + "eta.png", "png");
    21912144  }
    21922145
     
    22012154  TLegend *leg_pfpi_res_eta[n_ptbins];
    22022155
    2203   TGraphErrors *gr_pfpi_res_e     = new TGraphErrors[n_etabins];
    2204   TGraphErrors *gr_pfpi_res_eta   = new TGraphErrors[n_ptbins];
    2205 
    2206   TGraphErrors *gr_trkpi_res_e    = new TGraphErrors[n_etabins];
     2156  TGraphErrors *gr_pfpi_res_e = new TGraphErrors[n_etabins];
     2157  TGraphErrors *gr_pfpi_res_eta = new TGraphErrors[n_ptbins];
     2158
     2159  TGraphErrors *gr_trkpi_res_e = new TGraphErrors[n_etabins];
    22072160  TGraphErrors *gr_trkpi_res_eeta = new TGraphErrors[n_ptbins];
    22082161
    2209   std::vector<resolPlot> *plots_pfpi_res_e     = new std::vector<resolPlot>[n_etabins];
    2210   std::vector<resolPlot> *plots_pfpi_res_eta   = new std::vector<resolPlot>[n_ptbins];
    2211   std::vector<resolPlot> *plots_trkpi_res_e    = new std::vector<resolPlot>[n_etabins];
     2162  std::vector<resolPlot> *plots_pfpi_res_e = new std::vector<resolPlot>[n_etabins];
     2163  std::vector<resolPlot> *plots_pfpi_res_eta = new std::vector<resolPlot>[n_ptbins];
     2164  std::vector<resolPlot> *plots_trkpi_res_e = new std::vector<resolPlot>[n_etabins];
    22122165  std::vector<resolPlot> *plots_trkpi_res_eeta = new std::vector<resolPlot>[n_ptbins];
    22132166
     
    22152168  TCanvas *c_pfpi_res_eta[n_ptbins];
    22162169
    2217 
    22182170  // loop over eta bins
    2219   for (k = 0; k < etaVals.size()-1; k++)
    2220   {
    2221      mg_pfpi_res_e[k] = new TMultiGraph("","");
    2222      leg_pfpi_res_e[k] = new TLegend(0.40,0.60,0.75,0.90);
    2223 
    2224      HistogramsCollection(&plots_pfpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfpi");
    2225      GetEres<Track>(&plots_pfpi_res_e[k], branchPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    2226      gr_pfpi_res_e[k] = EresGraph(&plots_pfpi_res_e[k]);
    2227 
    2228      HistogramsCollection(&plots_trkpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
    2229      GetEres<Track>(&plots_trkpi_res_e[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    2230      gr_trkpi_res_e[k] = EresGraph(&plots_trkpi_res_e[k]);
    2231 
    2232 
    2233      s_etaMin = Form("%.1f",etaVals.at(k));
    2234      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2235      s_eta    = "#pi^{ #pm}, "+ s_etaMin + " < | #eta | < " + s_etaMax;
    2236 
    2237      leg_pfpi_res_e[k]->SetTextFont(132);
    2238      leg_pfpi_res_e[k]->SetHeader(s_eta);
    2239 
    2240      addResoGraph(mg_pfpi_res_e[k], &gr_hcal_res_e[k], leg_pfpi_res_e[k], markerStyles.at(0), colors.at(0), "HCAL");
    2241      addResoGraph(mg_pfpi_res_e[k], &gr_trkpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(1), colors.at(1), "Track");
    2242      addResoGraph(mg_pfpi_res_e[k], &gr_pfpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2243 
    2244      c_pfpi_res_e[k] = new TCanvas("","", 800, 600);
    2245 
    2246      mg_pfpi_res_e[k]->Draw("APE");
    2247      //DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
    2248      DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 50, "E [GeV]", "(resolution in E)/E (%)", true, false);
    2249      leg_pfpi_res_e[k]->Draw();
    2250      pave->Draw();
    2251 
    2252      TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
    2253 
    2254      c_pfpi_res_e[k]->Print(pdfOutput,"pdf");
    2255      c_pfpi_res_e[k]->Print(figPath+"img_pfpi_res_"+s_etarange+"e.pdf","pdf");
    2256      c_pfpi_res_e[k]->Print(figPath+"img_pfpi_res_"+s_etarange+"e.png","png");
    2257 
    2258   }
    2259 
    2260 
    2261     // loop over eta bins
    2262   for (k = 0; k < ptVals.size(); k++)
    2263   {
    2264 
    2265      mg_pfpi_res_eta[k] = new TMultiGraph("","");
    2266      leg_pfpi_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
    2267 
    2268      HistogramsCollectionVsEta(&plots_pfpi_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfpi", 0.0, 2.0);
    2269      GetEresVsEta<Track>(&plots_pfpi_res_eta[k], branchPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
    2270      gr_pfpi_res_eta[k] = EresGraphVsEta(&plots_pfpi_res_eta[k]);
    2271 
    2272      HistogramsCollectionVsEta(&plots_trkpi_res_eeta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkpi", 0.0, 2.0);
    2273      GetEresVsEta<Track>(&plots_trkpi_res_eeta[k], branchPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
    2274      gr_trkpi_res_eeta[k] = EresGraphVsEta(&plots_trkpi_res_eeta[k]);
    2275 
    2276 
    2277      s_e = Form("#pi^{ #pm}, E = %.0f GeV",ptVals.at(k));
    2278      if(ptVals.at(k) >= 1000.) s_e = Form("#pi^{ #pm}, E = %.0f TeV",ptVals.at(k)/1000.);
    2279 
    2280      leg_pfpi_res_eta[k]->SetTextFont(132);
    2281      leg_pfpi_res_eta[k]->SetHeader(s_e);
    2282 
    2283      addResoGraph(mg_pfpi_res_eta[k], &gr_hcal_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(0), colors.at(0), "HCAL");
    2284      addResoGraph(mg_pfpi_res_eta[k], &gr_trkpi_res_eeta[k], leg_pfpi_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
    2285      addResoGraph(mg_pfpi_res_eta[k], &gr_pfpi_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2286 
    2287      c_pfpi_res_eta[k] = new TCanvas("","", 800, 600);
    2288 
    2289      mg_pfpi_res_eta[k]->Draw("APE");
    2290      //DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
    2291      DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
    2292      leg_pfpi_res_eta[k]->Draw();
    2293      pave->Draw();
    2294 
    2295      TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
    2296 
    2297      c_pfpi_res_eta[k]->Print(pdfOutput,"pdf");
    2298      c_pfpi_res_eta[k]->Print(figPath+"img_pfpi_res_"+s_ptrange+"eta.pdf","pdf");
    2299      c_pfpi_res_eta[k]->Print(figPath+"img_pfpi_res_"+s_ptrange+"eta.png","png");
    2300 
    2301   }
    2302 
     2171  for(k = 0; k < etaVals.size() - 1; k++)
     2172  {
     2173    mg_pfpi_res_e[k] = new TMultiGraph("", "");
     2174    leg_pfpi_res_e[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2175
     2176    HistogramsCollection(&plots_pfpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfpi");
     2177    GetEres<Track>(&plots_pfpi_res_e[k], branchPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     2178    gr_pfpi_res_e[k] = EresGraph(&plots_pfpi_res_e[k]);
     2179
     2180    HistogramsCollection(&plots_trkpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
     2181    GetEres<Track>(&plots_trkpi_res_e[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     2182    gr_trkpi_res_e[k] = EresGraph(&plots_trkpi_res_e[k]);
     2183
     2184    s_etaMin = Form("%.1f", etaVals.at(k));
     2185    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2186    s_eta = "#pi^{ #pm}, " + s_etaMin + " < | #eta | < " + s_etaMax;
     2187
     2188    leg_pfpi_res_e[k]->SetTextFont(132);
     2189    leg_pfpi_res_e[k]->SetHeader(s_eta);
     2190
     2191    addResoGraph(mg_pfpi_res_e[k], &gr_hcal_res_e[k], leg_pfpi_res_e[k], markerStyles.at(0), colors.at(0), "HCAL");
     2192    addResoGraph(mg_pfpi_res_e[k], &gr_trkpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(1), colors.at(1), "Track");
     2193    addResoGraph(mg_pfpi_res_e[k], &gr_pfpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2194
     2195    c_pfpi_res_e[k] = new TCanvas("", "", 800, 600);
     2196
     2197    mg_pfpi_res_e[k]->Draw("APE");
     2198    //DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
     2199    DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 50, "E [GeV]", "(resolution in E)/E (%)", true, false);
     2200    leg_pfpi_res_e[k]->Draw();
     2201    pave->Draw();
     2202
     2203    TString s_etarange = "eta_" + s_etaMin + "_" + s_etaMax + "_";
     2204
     2205    c_pfpi_res_e[k]->Print(pdfOutput, "pdf");
     2206    c_pfpi_res_e[k]->Print(figPath + "img_pfpi_res_" + s_etarange + "e.pdf", "pdf");
     2207    c_pfpi_res_e[k]->Print(figPath + "img_pfpi_res_" + s_etarange + "e.png", "png");
     2208  }
     2209
     2210  // loop over eta bins
     2211  for(k = 0; k < ptVals.size(); k++)
     2212  {
     2213
     2214    mg_pfpi_res_eta[k] = new TMultiGraph("", "");
     2215    leg_pfpi_res_eta[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2216
     2217    HistogramsCollectionVsEta(&plots_pfpi_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "pfpi", 0.0, 2.0);
     2218    GetEresVsEta<Track>(&plots_pfpi_res_eta[k], branchPion, branchParticlePion, 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPion);
     2219    gr_pfpi_res_eta[k] = EresGraphVsEta(&plots_pfpi_res_eta[k]);
     2220
     2221    HistogramsCollectionVsEta(&plots_trkpi_res_eeta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkpi", 0.0, 2.0);
     2222    GetEresVsEta<Track>(&plots_trkpi_res_eeta[k], branchPion, branchParticlePion, 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPion);
     2223    gr_trkpi_res_eeta[k] = EresGraphVsEta(&plots_trkpi_res_eeta[k]);
     2224
     2225    s_e = Form("#pi^{ #pm}, E = %.0f GeV", ptVals.at(k));
     2226    if(ptVals.at(k) >= 1000.) s_e = Form("#pi^{ #pm}, E = %.0f TeV", ptVals.at(k) / 1000.);
     2227
     2228    leg_pfpi_res_eta[k]->SetTextFont(132);
     2229    leg_pfpi_res_eta[k]->SetHeader(s_e);
     2230
     2231    addResoGraph(mg_pfpi_res_eta[k], &gr_hcal_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(0), colors.at(0), "HCAL");
     2232    addResoGraph(mg_pfpi_res_eta[k], &gr_trkpi_res_eeta[k], leg_pfpi_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
     2233    addResoGraph(mg_pfpi_res_eta[k], &gr_pfpi_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2234
     2235    c_pfpi_res_eta[k] = new TCanvas("", "", 800, 600);
     2236
     2237    mg_pfpi_res_eta[k]->Draw("APE");
     2238    //DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
     2239    DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
     2240    leg_pfpi_res_eta[k]->Draw();
     2241    pave->Draw();
     2242
     2243    TString s_ptrange = Form("pt_%.0f_", ptVals.at(k));
     2244
     2245    c_pfpi_res_eta[k]->Print(pdfOutput, "pdf");
     2246    c_pfpi_res_eta[k]->Print(figPath + "img_pfpi_res_" + s_ptrange + "eta.pdf", "pdf");
     2247    c_pfpi_res_eta[k]->Print(figPath + "img_pfpi_res_" + s_ptrange + "eta.png", "png");
     2248  }
    23032249
    23042250  /////////////////
     
    23122258  TLegend *leg_pfjet_res_eta[n_ptbins];
    23132259
    2314   TGraphErrors *gr_pfjet_res_e   = new TGraphErrors[n_etabins];
     2260  TGraphErrors *gr_pfjet_res_e = new TGraphErrors[n_etabins];
    23152261  TGraphErrors *gr_pfjet_res_eta = new TGraphErrors[n_ptbins];
    23162262
    2317   TGraphErrors *gr_cajet_res_e   = new TGraphErrors[n_etabins];
     2263  TGraphErrors *gr_cajet_res_e = new TGraphErrors[n_etabins];
    23182264  TGraphErrors *gr_cajet_res_eta = new TGraphErrors[n_ptbins];
    23192265
    2320   std::vector<resolPlot> *plots_pfjet_res_e   = new std::vector<resolPlot>[n_etabins];
     2266  std::vector<resolPlot> *plots_pfjet_res_e = new std::vector<resolPlot>[n_etabins];
    23212267  std::vector<resolPlot> *plots_pfjet_res_eta = new std::vector<resolPlot>[n_ptbins];
    2322   std::vector<resolPlot> *plots_cajet_res_e   = new std::vector<resolPlot>[n_etabins];
     2268  std::vector<resolPlot> *plots_cajet_res_e = new std::vector<resolPlot>[n_etabins];
    23232269  std::vector<resolPlot> *plots_cajet_res_eta = new std::vector<resolPlot>[n_ptbins];
    23242270
     
    23262272  TCanvas *c_pfjet_res_eta[n_ptbins];
    23272273
    2328 
    23292274  // loop over eta bins
    2330   for (k = 0; k < etaVals.size()-1; k++)
    2331   {
    2332 
    2333      mg_pfjet_res_e[k] = new TMultiGraph("","");
    2334      leg_pfjet_res_e[k] = new TLegend(0.40,0.70,0.90,0.90);
    2335 
    2336      HistogramsCollection(&plots_pfjet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfjet");
    2337      HistogramsCollection(&plots_cajet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "cajet");
    2338 
    2339      GetJetsEres(&plots_pfjet_res_e[k], branchPFJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k+1));
    2340      GetJetsEres(&plots_cajet_res_e[k], branchCaloJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k+1));
    2341 
    2342      gr_pfjet_res_e[k] = EresGraph(&plots_pfjet_res_e[k]);
    2343      gr_cajet_res_e[k] = EresGraph(&plots_cajet_res_e[k]);
    2344 
    2345      s_etaMin = Form("%.1f",etaVals.at(k));
    2346      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2347      s_eta    = "anti-k_{T},  R = 0.4,  "+ s_etaMin + " < | #eta | < " + s_etaMax;
    2348 
    2349      leg_pfjet_res_e[k]->SetTextFont(132);
    2350      leg_pfjet_res_e[k]->SetHeader(s_eta);
    2351 
    2352      addResoGraph(mg_pfjet_res_e[k], &gr_cajet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
    2353      addResoGraph(mg_pfjet_res_e[k], &gr_pfjet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
    2354 
    2355      c_pfjet_res_e[k] = new TCanvas("","", 800, 600);
    2356 
    2357      mg_pfjet_res_e[k]->Draw("APE");
    2358      //DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.5, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
    2359      DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.0, 30, "E [GeV]", "(resolution in E)/E (%)", true, false);
    2360      leg_pfjet_res_e[k]->Draw();
    2361      pave->Draw();
    2362 
    2363      TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
    2364 
    2365      c_pfjet_res_e[k]->Print(pdfOutput,"pdf");
    2366      c_pfjet_res_e[k]->Print(figPath+"img_pfjet_res_"+s_etarange+"e.pdf","pdf");
    2367      c_pfjet_res_e[k]->Print(figPath+"img_pfjet_res_"+s_etarange+"e.png","png");
    2368 
    2369   }
    2370 
    2371 
    2372     // loop over eta bins
    2373   for (k = 0; k < ptVals.size(); k++)
    2374   {
    2375 
    2376      mg_pfjet_res_eta[k] = new TMultiGraph("","");
    2377      leg_pfjet_res_eta[k] = new TLegend(0.30,0.70,0.85,0.90);
    2378 
    2379      HistogramsCollectionVsEta(&plots_pfjet_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfjet", 0.0, 2.0);
    2380      HistogramsCollectionVsEta(&plots_cajet_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "cajet", 0.0, 2.0);
    2381 
    2382      GetJetsEresVsEta(&plots_pfjet_res_eta[k], branchPFJet, branchGenJet, treeReaderJet, 0.5*ptVals.at(k), 2.0*ptVals.at(k));
    2383      GetJetsEresVsEta(&plots_cajet_res_eta[k], branchCaloJet, branchGenJet, treeReaderJet, 0.5*ptVals.at(k), 2.0*ptVals.at(k));
    2384 
    2385      gr_pfjet_res_eta[k] = EresGraphVsEta(&plots_pfjet_res_eta[k]);
    2386      gr_cajet_res_eta[k] = EresGraphVsEta(&plots_cajet_res_eta[k]);
    2387 
    2388      s_e = Form("anti-k_{T},  R = 0.4,  jets, E = %.0f GeV",ptVals.at(k));
    2389      if(ptVals.at(k) >= 1000.) s_e = Form("anti-k_{T},  R = 0.4,  E = %.0f TeV",ptVals.at(k)/1000.);
    2390 
    2391      leg_pfjet_res_eta[k]->SetTextFont(132);
    2392      leg_pfjet_res_eta[k]->SetHeader(s_e);
    2393 
    2394      addResoGraph(mg_pfjet_res_eta[k], &gr_cajet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
    2395      addResoGraph(mg_pfjet_res_eta[k], &gr_pfjet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
    2396 
    2397      c_pfjet_res_eta[k] = new TCanvas("","", 800, 600);
    2398 
    2399      mg_pfjet_res_eta[k]->Draw("APE");
    2400      //DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
    2401      DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
    2402      leg_pfjet_res_eta[k]->Draw();
    2403      pave->Draw();
    2404 
    2405      TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
    2406 
    2407      c_pfjet_res_eta[k]->Print(pdfOutput,"pdf");
    2408      c_pfjet_res_eta[k]->Print(figPath+"img_pfjet_res_"+s_ptrange+"eta.pdf","pdf");
    2409      c_pfjet_res_eta[k]->Print(figPath+"img_pfjet_res_"+s_ptrange+"eta.png","png");
    2410 
    2411   }
    2412 
    2413 
    2414     /////////////////////
    2415     // PF Missing ET  ///
    2416     /////////////////////
    2417 
    2418     TMultiGraph *mg_met_res_ht = new TMultiGraph("","");
    2419     TLegend *leg_met_res_ht    = new TLegend(0.60,0.22,0.90,0.42);
    2420 
    2421     std::vector<resolPlot> plots_pfmet, plots_camet;
    2422 
    2423     HistogramsCollection(&plots_pfmet, TMath::Log10(ptMin), TMath::Log10(ptMax), "pfMET", -500, 500);
    2424     HistogramsCollection(&plots_camet, TMath::Log10(ptMin), TMath::Log10(ptMax), "caMET", -500, 500);
    2425 
    2426     GetMetres(&plots_pfmet, branchGenScalarHT, branchMet, branchPFJet, treeReaderJet);
    2427     GetMetres(&plots_camet, branchGenScalarHT, branchCaloMet, branchCaloJet, treeReaderJet);
    2428 
    2429     TGraphErrors gr_pfmet_res_ht = MetResGraph(&plots_pfmet, true);
    2430     TGraphErrors gr_camet_res_ht = MetResGraph(&plots_camet, true);
    2431 
    2432     addResoGraph(mg_met_res_ht, &gr_camet_res_ht, leg_met_res_ht, markerStyles.at(0), colors.at(0), "Calorimeter E_{T}^{miss}");
    2433     addResoGraph(mg_met_res_ht, &gr_pfmet_res_ht, leg_met_res_ht, markerStyles.at(1), colors.at(1), "Particle-flow E_{T}^{miss}");
    2434 
    2435     TCanvas *c_met_res_ht = new TCanvas("","", 800, 600);
    2436 
    2437     mg_met_res_ht->Draw("APE");
    2438     DrawAxis(mg_met_res_ht, leg_met_res_ht, 1000, 100000, 0.1, 1000, " #sum p_{T} [GeV]", "resolution in E_{x,y}^{miss} [GeV]", true, true);
    2439 
    2440     leg_met_res_ht->Draw();
     2275  for(k = 0; k < etaVals.size() - 1; k++)
     2276  {
     2277
     2278    mg_pfjet_res_e[k] = new TMultiGraph("", "");
     2279    leg_pfjet_res_e[k] = new TLegend(0.40, 0.70, 0.90, 0.90);
     2280
     2281    HistogramsCollection(&plots_pfjet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfjet");
     2282    HistogramsCollection(&plots_cajet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "cajet");
     2283
     2284    GetJetsEres(&plots_pfjet_res_e[k], branchPFJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k + 1));
     2285    GetJetsEres(&plots_cajet_res_e[k], branchCaloJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k + 1));
     2286
     2287    gr_pfjet_res_e[k] = EresGraph(&plots_pfjet_res_e[k]);
     2288    gr_cajet_res_e[k] = EresGraph(&plots_cajet_res_e[k]);
     2289
     2290    s_etaMin = Form("%.1f", etaVals.at(k));
     2291    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2292    s_eta = "anti-k_{T},  R = 0.4,  " + s_etaMin + " < | #eta | < " + s_etaMax;
     2293
     2294    leg_pfjet_res_e[k]->SetTextFont(132);
     2295    leg_pfjet_res_e[k]->SetHeader(s_eta);
     2296
     2297    addResoGraph(mg_pfjet_res_e[k], &gr_cajet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
     2298    addResoGraph(mg_pfjet_res_e[k], &gr_pfjet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
     2299
     2300    c_pfjet_res_e[k] = new TCanvas("", "", 800, 600);
     2301
     2302    mg_pfjet_res_e[k]->Draw("APE");
     2303    //DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.5, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
     2304    DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.0, 30, "E [GeV]", "(resolution in E)/E (%)", true, false);
     2305    leg_pfjet_res_e[k]->Draw();
    24412306    pave->Draw();
    2442     c_met_res_ht->Print(pdfOutput,"pdf");
    2443     c_met_res_ht->Print(figPath+"img_met_res_ht.pdf","pdf");
    2444     c_met_res_ht->Print(figPath+"img_met_res_ht.png","png");
    2445 
    2446 
    2447     /////////////////////////////////////////
    2448     // Electron Reconstruction Efficiency ///
    2449     /////////////////////////////////////////
    2450 
    2451     TMultiGraph *mg_recele_eff_pt  = new TMultiGraph("","");
    2452     TMultiGraph *mg_recele_eff_eta = new TMultiGraph("","");
    2453 
    2454     TLegend *leg_recele_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
    2455     TLegend *leg_recele_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
    2456 
    2457     TGraphErrors *gr_recele_eff_pt  = new TGraphErrors[n_etabins];
    2458     TGraphErrors *gr_recele_eff_eta = new TGraphErrors[n_ptbins];
    2459     TH1D* h_recele_eff_pt, *h_recele_eff_eta;
    2460 
    2461     // loop over eta bins
    2462     for (k = 0; k < etaVals.size()-1; k++)
     2307
     2308    TString s_etarange = "eta_" + s_etaMin + "_" + s_etaMax + "_";
     2309
     2310    c_pfjet_res_e[k]->Print(pdfOutput, "pdf");
     2311    c_pfjet_res_e[k]->Print(figPath + "img_pfjet_res_" + s_etarange + "e.pdf", "pdf");
     2312    c_pfjet_res_e[k]->Print(figPath + "img_pfjet_res_" + s_etarange + "e.png", "png");
     2313  }
     2314
     2315  // loop over eta bins
     2316  for(k = 0; k < ptVals.size(); k++)
     2317  {
     2318
     2319    mg_pfjet_res_eta[k] = new TMultiGraph("", "");
     2320    leg_pfjet_res_eta[k] = new TLegend(0.30, 0.70, 0.85, 0.90);
     2321
     2322    HistogramsCollectionVsEta(&plots_pfjet_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "pfjet", 0.0, 2.0);
     2323    HistogramsCollectionVsEta(&plots_cajet_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "cajet", 0.0, 2.0);
     2324
     2325    GetJetsEresVsEta(&plots_pfjet_res_eta[k], branchPFJet, branchGenJet, treeReaderJet, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k));
     2326    GetJetsEresVsEta(&plots_cajet_res_eta[k], branchCaloJet, branchGenJet, treeReaderJet, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k));
     2327
     2328    gr_pfjet_res_eta[k] = EresGraphVsEta(&plots_pfjet_res_eta[k]);
     2329    gr_cajet_res_eta[k] = EresGraphVsEta(&plots_cajet_res_eta[k]);
     2330
     2331    s_e = Form("anti-k_{T},  R = 0.4,  jets, E = %.0f GeV", ptVals.at(k));
     2332    if(ptVals.at(k) >= 1000.) s_e = Form("anti-k_{T},  R = 0.4,  E = %.0f TeV", ptVals.at(k) / 1000.);
     2333
     2334    leg_pfjet_res_eta[k]->SetTextFont(132);
     2335    leg_pfjet_res_eta[k]->SetHeader(s_e);
     2336
     2337    addResoGraph(mg_pfjet_res_eta[k], &gr_cajet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
     2338    addResoGraph(mg_pfjet_res_eta[k], &gr_pfjet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
     2339
     2340    c_pfjet_res_eta[k] = new TCanvas("", "", 800, 600);
     2341
     2342    mg_pfjet_res_eta[k]->Draw("APE");
     2343    //DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
     2344    DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
     2345    leg_pfjet_res_eta[k]->Draw();
     2346    pave->Draw();
     2347
     2348    TString s_ptrange = Form("pt_%.0f_", ptVals.at(k));
     2349
     2350    c_pfjet_res_eta[k]->Print(pdfOutput, "pdf");
     2351    c_pfjet_res_eta[k]->Print(figPath + "img_pfjet_res_" + s_ptrange + "eta.pdf", "pdf");
     2352    c_pfjet_res_eta[k]->Print(figPath + "img_pfjet_res_" + s_ptrange + "eta.png", "png");
     2353  }
     2354
     2355  /////////////////////
     2356  // PF Missing ET  ///
     2357  /////////////////////
     2358
     2359  TMultiGraph *mg_met_res_ht = new TMultiGraph("", "");
     2360  TLegend *leg_met_res_ht = new TLegend(0.60, 0.22, 0.90, 0.42);
     2361
     2362  std::vector<resolPlot> plots_pfmet, plots_camet;
     2363
     2364  HistogramsCollection(&plots_pfmet, TMath::Log10(ptMin), TMath::Log10(ptMax), "pfMET", -500, 500);
     2365  HistogramsCollection(&plots_camet, TMath::Log10(ptMin), TMath::Log10(ptMax), "caMET", -500, 500);
     2366
     2367  GetMetres(&plots_pfmet, branchGenScalarHT, branchMet, branchPFJet, treeReaderJet);
     2368  GetMetres(&plots_camet, branchGenScalarHT, branchCaloMet, branchCaloJet, treeReaderJet);
     2369
     2370  TGraphErrors gr_pfmet_res_ht = MetResGraph(&plots_pfmet, true);
     2371  TGraphErrors gr_camet_res_ht = MetResGraph(&plots_camet, true);
     2372
     2373  addResoGraph(mg_met_res_ht, &gr_camet_res_ht, leg_met_res_ht, markerStyles.at(0), colors.at(0), "Calorimeter E_{T}^{miss}");
     2374  addResoGraph(mg_met_res_ht, &gr_pfmet_res_ht, leg_met_res_ht, markerStyles.at(1), colors.at(1), "Particle-flow E_{T}^{miss}");
     2375
     2376  TCanvas *c_met_res_ht = new TCanvas("", "", 800, 600);
     2377
     2378  mg_met_res_ht->Draw("APE");
     2379  DrawAxis(mg_met_res_ht, leg_met_res_ht, 1000, 100000, 0.1, 1000, " #sum p_{T} [GeV]", "resolution in E_{x,y}^{miss} [GeV]", true, true);
     2380
     2381  leg_met_res_ht->Draw();
     2382  pave->Draw();
     2383  c_met_res_ht->Print(pdfOutput, "pdf");
     2384  c_met_res_ht->Print(figPath + "img_met_res_ht.pdf", "pdf");
     2385  c_met_res_ht->Print(figPath + "img_met_res_ht.png", "png");
     2386
     2387  /////////////////////////////////////////
     2388  // Electron Reconstruction Efficiency ///
     2389  /////////////////////////////////////////
     2390
     2391  TMultiGraph *mg_recele_eff_pt = new TMultiGraph("", "");
     2392  TMultiGraph *mg_recele_eff_eta = new TMultiGraph("", "");
     2393
     2394  TLegend *leg_recele_eff_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     2395  TLegend *leg_recele_eff_eta = new TLegend(0.55, 0.22, 0.90, 0.48);
     2396
     2397  TGraphErrors *gr_recele_eff_pt = new TGraphErrors[n_etabins];
     2398  TGraphErrors *gr_recele_eff_eta = new TGraphErrors[n_ptbins];
     2399  TH1D *h_recele_eff_pt, *h_recele_eff_eta;
     2400
     2401  // loop over eta bins
     2402  for(k = 0; k < etaVals.size() - 1; k++)
     2403  {
     2404
     2405    h_recele_eff_pt = GetEffPt<Electron>(branchElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     2406    gr_recele_eff_pt[k] = TGraphErrors(h_recele_eff_pt);
     2407
     2408    s_etaMin = Form("%.1f", etaVals.at(k));
     2409    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2410
     2411    s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2412
     2413    gr_recele_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2414
     2415    addResoGraph(mg_recele_eff_pt, &gr_recele_eff_pt[k], leg_recele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2416  }
     2417
     2418  // loop over pt
     2419  for(k = 0; k < ptVals.size(); k++)
     2420  {
     2421    h_recele_eff_eta = GetEffEta<Electron>(branchElectron, branchParticleElectron, "Electron", 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderElectron);
     2422    gr_recele_eff_eta[k] = TGraphErrors(h_recele_eff_eta);
     2423
     2424    s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     2425    if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2426
     2427    addResoGraph(mg_recele_eff_eta, &gr_recele_eff_eta[k], leg_recele_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2428  }
     2429
     2430  TCanvas *c_recele_eff_pt = new TCanvas("", "", 800, 600);
     2431
     2432  mg_recele_eff_pt->Draw("APE");
     2433  DrawAxis(mg_recele_eff_pt, leg_recele_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
     2434  leg_recele_eff_pt->Draw();
     2435  pave->Draw();
     2436
     2437  c_recele_eff_pt->Print(pdfOutput, "pdf");
     2438  c_recele_eff_pt->Print(figPath + "img_recele_eff_pt.pdf", "pdf");
     2439  c_recele_eff_pt->Print(figPath + "img_recele_eff_pt.png", "png");
     2440
     2441  TCanvas *c_recele_eff_eta = new TCanvas("", "", 800, 600);
     2442
     2443  mg_recele_eff_eta->Draw("APE");
     2444  DrawAxis(mg_recele_eff_eta, leg_recele_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
     2445  leg_recele_eff_eta->Draw();
     2446  pave->Draw();
     2447
     2448  c_recele_eff_eta->Print(pdfOutput, "pdf");
     2449  c_recele_eff_eta->Print(figPath + "img_recele_eff_eta.pdf", "pdf");
     2450  c_recele_eff_eta->Print(figPath + "img_recele_eff_eta.png", "png");
     2451
     2452  /////////////////////////////////////////
     2453  // Muon Reconstruction Efficiency ///
     2454  /////////////////////////////////////////
     2455
     2456  TMultiGraph *mg_recmu_eff_pt = new TMultiGraph("", "");
     2457  TMultiGraph *mg_recmu_eff_eta = new TMultiGraph("", "");
     2458
     2459  TLegend *leg_recmu_eff_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     2460  TLegend *leg_recmu_eff_eta = new TLegend(0.55, 0.22, 0.90, 0.48);
     2461
     2462  TGraphErrors *gr_recmu_eff_pt = new TGraphErrors[n_etabins];
     2463  TGraphErrors *gr_recmu_eff_eta = new TGraphErrors[n_ptbins];
     2464  TH1D *h_recmu_eff_pt, *h_recmu_eff_eta;
     2465
     2466  // loop over eta bins
     2467  for(k = 0; k < etaVals.size() - 1; k++)
     2468  {
     2469
     2470    h_recmu_eff_pt = GetEffPt<Muon>(branchMuon, branchParticleMuon, "muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderMuon);
     2471    gr_recmu_eff_pt[k] = TGraphErrors(h_recmu_eff_pt);
     2472
     2473    s_etaMin = Form("%.1f", etaVals.at(k));
     2474    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2475
     2476    s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2477
     2478    gr_recmu_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2479
     2480    addResoGraph(mg_recmu_eff_pt, &gr_recmu_eff_pt[k], leg_recmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2481  }
     2482
     2483  // loop over pt
     2484  for(k = 0; k < ptVals.size(); k++)
     2485  {
     2486    h_recmu_eff_eta = GetEffEta<Muon>(branchMuon, branchParticleMuon, "muon", 13, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderMuon);
     2487    gr_recmu_eff_eta[k] = TGraphErrors(h_recmu_eff_eta);
     2488
     2489    s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     2490    if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2491
     2492    addResoGraph(mg_recmu_eff_eta, &gr_recmu_eff_eta[k], leg_recmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2493  }
     2494
     2495  TCanvas *c_recmu_eff_pt = new TCanvas("", "", 800, 600);
     2496
     2497  mg_recmu_eff_pt->Draw("APE");
     2498  DrawAxis(mg_recmu_eff_pt, leg_recmu_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
     2499  leg_recmu_eff_pt->Draw();
     2500  pave->Draw();
     2501
     2502  c_recmu_eff_pt->Print(pdfOutput, "pdf");
     2503  c_recmu_eff_pt->Print(figPath + "img_recmu_eff_pt.pdf", "pdf");
     2504  c_recmu_eff_pt->Print(figPath + "img_recmu_eff_pt.png", "png");
     2505
     2506  TCanvas *c_recmu_eff_eta = new TCanvas("", "", 800, 600);
     2507
     2508  mg_recmu_eff_eta->Draw("APE");
     2509  DrawAxis(mg_recmu_eff_eta, leg_recmu_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
     2510  leg_recmu_eff_eta->Draw();
     2511  pave->Draw();
     2512
     2513  c_recmu_eff_eta->Print(pdfOutput, "pdf");
     2514  c_recmu_eff_eta->Print(figPath + "img_recmu_eff_eta.pdf", "pdf");
     2515  c_recmu_eff_eta->Print(figPath + "img_recmu_eff_eta.png", "png");
     2516
     2517  /////////////////////////////////////////
     2518  // Photon Reconstruction Efficiency   ///
     2519  /////////////////////////////////////////
     2520
     2521  TMultiGraph *mg_recpho_eff_pt = new TMultiGraph("", "");
     2522  TMultiGraph *mg_recpho_eff_eta = new TMultiGraph("", "");
     2523
     2524  TLegend *leg_recpho_eff_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     2525  TLegend *leg_recpho_eff_eta = new TLegend(0.55, 0.22, 0.90, 0.48);
     2526
     2527  TGraphErrors *gr_recpho_eff_pt = new TGraphErrors[n_etabins];
     2528  TGraphErrors *gr_recpho_eff_eta = new TGraphErrors[n_ptbins];
     2529  TH1D *h_recpho_eff_pt, *h_recpho_eff_eta;
     2530
     2531  // loop over eta bins
     2532  for(k = 0; k < etaVals.size() - 1; k++)
     2533  {
     2534
     2535    h_recpho_eff_pt = GetEffPt<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderPhoton);
     2536    gr_recpho_eff_pt[k] = TGraphErrors(h_recpho_eff_pt);
     2537
     2538    s_etaMin = Form("%.1f", etaVals.at(k));
     2539    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2540
     2541    s_eta = "#gamma , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2542
     2543    gr_recpho_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2544
     2545    addResoGraph(mg_recpho_eff_pt, &gr_recpho_eff_pt[k], leg_recpho_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2546  }
     2547
     2548  // loop over pt
     2549  for(k = 0; k < ptVals.size(); k++)
     2550  {
     2551    h_recpho_eff_eta = GetEffEta<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderPhoton);
     2552    gr_recpho_eff_eta[k] = TGraphErrors(h_recpho_eff_eta);
     2553
     2554    s_pt = Form("#gamma , p_{T} = %.0f GeV", ptVals.at(k));
     2555    if(ptVals.at(k) >= 1000.) s_pt = Form("#gamma , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2556
     2557    addResoGraph(mg_recpho_eff_eta, &gr_recpho_eff_eta[k], leg_recpho_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2558  }
     2559
     2560  TCanvas *c_recpho_eff_pt = new TCanvas("", "", 800, 600);
     2561
     2562  mg_recpho_eff_pt->Draw("APE");
     2563  DrawAxis(mg_recpho_eff_pt, leg_recpho_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
     2564  leg_recpho_eff_pt->Draw();
     2565  pave->Draw();
     2566
     2567  c_recpho_eff_pt->Print(pdfOutput, "pdf");
     2568  c_recpho_eff_pt->Print(figPath + "img_recpho_eff_pt.pdf", "pdf");
     2569  c_recpho_eff_pt->Print(figPath + "img_recpho_eff_pt.png", "png");
     2570
     2571  TCanvas *c_recpho_eff_eta = new TCanvas("", "", 800, 600);
     2572
     2573  mg_recpho_eff_eta->Draw("APE");
     2574  DrawAxis(mg_recpho_eff_eta, leg_recpho_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
     2575  leg_recpho_eff_eta->Draw();
     2576  pave->Draw();
     2577
     2578  c_recpho_eff_eta->Print(pdfOutput, "pdf");
     2579  c_recpho_eff_eta->Print(figPath + "img_recpho_eff_eta.pdf", "pdf");
     2580  c_recpho_eff_eta->Print(figPath + "img_recpho_eff_eta.png", "png");
     2581
     2582  /////////////////////////////////////////
     2583  // B-jets  Efficiency/ mistag rates   ///
     2584  /////////////////////////////////////////
     2585
     2586  TMultiGraph *mg_recbjet_eff_pt = new TMultiGraph("", "");
     2587  TMultiGraph *mg_recbjet_eff_eta = new TMultiGraph("", "");
     2588
     2589  TLegend *leg_recbjet_eff_pt = new TLegend(0.50, 0.22, 0.90, 0.48);
     2590  TLegend *leg_recbjet_eff_eta = new TLegend(0.50, 0.22, 0.90, 0.48);
     2591
     2592  TGraphErrors *gr_recbjet_eff_pt = new TGraphErrors[n_etabins];
     2593  TGraphErrors *gr_recbjet_eff_eta = new TGraphErrors[n_ptbins];
     2594  TH1D *h_recbjet_eff_pt, *h_recbjet_eff_eta;
     2595
     2596  // loop over eta bins
     2597  for(k = 0; k < etaVals.size() - 1; k++)
     2598  {
     2599
     2600    h_recbjet_eff_pt = GetJetEffPt<Jet>(branchPFBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderBJet);
     2601    //h_recbjet_eff_pt = GetEffPt<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
     2602    gr_recbjet_eff_pt[k] = TGraphErrors(h_recbjet_eff_pt);
     2603
     2604    s_etaMin = Form("%.1f", etaVals.at(k));
     2605    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2606
     2607    s_eta = "b-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2608
     2609    gr_recbjet_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2610
     2611    addResoGraph(mg_recbjet_eff_pt, &gr_recbjet_eff_pt[k], leg_recbjet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2612  }
     2613
     2614  // loop over pt
     2615  for(k = 0; k < ptVals.size(); k++)
     2616  {
     2617    h_recbjet_eff_eta = GetJetEffEta<Jet>(branchPFBJet, "BJet", 5, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderBJet);
     2618    //h_recbjet_eff_eta = GetEffEta<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
     2619    gr_recbjet_eff_eta[k] = TGraphErrors(h_recbjet_eff_eta);
     2620
     2621    s_pt = Form("b-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2622    if(ptVals.at(k) >= 1000.) s_pt = Form("b-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2623
     2624    addResoGraph(mg_recbjet_eff_eta, &gr_recbjet_eff_eta[k], leg_recbjet_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2625  }
     2626
     2627  TCanvas *c_recbjet_eff_pt = new TCanvas("", "", 800, 600);
     2628
     2629  mg_recbjet_eff_pt->Draw("APE");
     2630  DrawAxis(mg_recbjet_eff_pt, leg_recbjet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "b - tag efficiency (%)", true, false);
     2631  leg_recbjet_eff_pt->Draw();
     2632  pave->Draw();
     2633
     2634  c_recbjet_eff_pt->Print(pdfOutput, "pdf");
     2635  c_recbjet_eff_pt->Print(figPath + "img_recbjet_eff_pt.pdf", "pdf");
     2636  c_recbjet_eff_pt->Print(figPath + "img_recbjet_eff_pt.png", "png");
     2637
     2638  TCanvas *c_recbjet_eff_eta = new TCanvas("", "", 800, 600);
     2639
     2640  mg_recbjet_eff_eta->Draw("APE");
     2641  DrawAxis(mg_recbjet_eff_eta, leg_recbjet_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "b - tag efficiency (%)", false, false);
     2642  leg_recbjet_eff_eta->Draw();
     2643  pave->Draw();
     2644
     2645  c_recbjet_eff_eta->Print(pdfOutput, "pdf");
     2646  c_recbjet_eff_eta->Print(figPath + "img_recbjet_eff_eta.pdf", "pdf");
     2647  c_recbjet_eff_eta->Print(figPath + "img_recbjet_eff_eta.png", "png");
     2648
     2649  // ------ c - mistag  ------
     2650
     2651  TMultiGraph *mg_recbjet_cmis_pt = new TMultiGraph("", "");
     2652  TMultiGraph *mg_recbjet_cmis_eta = new TMultiGraph("", "");
     2653
     2654  TLegend *leg_recbjet_cmis_pt = new TLegend(0.50, 0.64, 0.90, 0.90);
     2655  TLegend *leg_recbjet_cmis_eta = new TLegend(0.50, 0.64, 0.90, 0.90);
     2656
     2657  TGraphErrors *gr_recbjet_cmis_pt = new TGraphErrors[n_etabins];
     2658  TGraphErrors *gr_recbjet_cmis_eta = new TGraphErrors[n_ptbins];
     2659  TH1D *h_recbjet_cmis_pt, *h_recbjet_cmis_eta;
     2660
     2661  // loop over eta bins
     2662  for(k = 0; k < etaVals.size() - 1; k++)
     2663  {
     2664
     2665    h_recbjet_cmis_pt = GetJetEffPt<Jet>(branchPFCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderCJet);
     2666    //h_recbjet_cmis_pt = GetEffPt<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
     2667    gr_recbjet_cmis_pt[k] = TGraphErrors(h_recbjet_cmis_pt);
     2668
     2669    s_etaMin = Form("%.1f", etaVals.at(k));
     2670    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2671
     2672    s_eta = "c-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2673
     2674    gr_recbjet_cmis_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2675
     2676    addResoGraph(mg_recbjet_cmis_pt, &gr_recbjet_cmis_pt[k], leg_recbjet_cmis_pt, markerStyles.at(k), colors.at(k), s_eta);
     2677  }
     2678
     2679  // loop over pt
     2680  for(k = 0; k < ptVals.size(); k++)
     2681  {
     2682    h_recbjet_cmis_eta = GetJetEffEta<Jet>(branchPFCJet, "CJet", 4, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderCJet);
     2683    //h_recbjet_cmis_eta = GetEffEta<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
     2684    gr_recbjet_cmis_eta[k] = TGraphErrors(h_recbjet_cmis_eta);
     2685
     2686    s_pt = Form("c-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2687    if(ptVals.at(k) >= 1000.) s_pt = Form("c-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2688
     2689    addResoGraph(mg_recbjet_cmis_eta, &gr_recbjet_cmis_eta[k], leg_recbjet_cmis_eta, markerStyles.at(k), colors.at(k), s_pt);
     2690  }
     2691
     2692  TCanvas *c_recbjet_cmis_pt = new TCanvas("", "", 800, 600);
     2693
     2694  mg_recbjet_cmis_pt->Draw("APE");
     2695  DrawAxis(mg_recbjet_cmis_pt, leg_recbjet_cmis_pt, ptMin, ptMax, 0.0, 20, "p_{T} [GeV]", "c - mistag rate (%)", true, false);
     2696  leg_recbjet_cmis_pt->Draw();
     2697  pave->Draw();
     2698
     2699  c_recbjet_cmis_pt->Print(pdfOutput, "pdf");
     2700  c_recbjet_cmis_pt->Print(figPath + "img_recbjet_cmis_pt.pdf", "pdf");
     2701  c_recbjet_cmis_pt->Print(figPath + "img_recbjet_cmis_pt.png", "png");
     2702
     2703  TCanvas *c_recbjet_cmis_eta = new TCanvas("", "", 800, 600);
     2704
     2705  mg_recbjet_cmis_eta->Draw("APE");
     2706  DrawAxis(mg_recbjet_cmis_eta, leg_recbjet_cmis_eta, etaMin, etaMax, 0.0, 20, " #eta ", "c - mistag rate (%)", false, false);
     2707  leg_recbjet_cmis_eta->Draw();
     2708  pave->Draw();
     2709
     2710  c_recbjet_cmis_eta->Print(pdfOutput, "pdf");
     2711  c_recbjet_cmis_eta->Print(figPath + "img_recbjet_cmis_eta.pdf", "pdf");
     2712  c_recbjet_cmis_eta->Print(figPath + "img_recbjet_cmis_eta.png", "png");
     2713
     2714  // ------ light - mistag  ------
     2715
     2716  TMultiGraph *mg_recbjet_lmis_pt = new TMultiGraph("", "");
     2717  TMultiGraph *mg_recbjet_lmis_eta = new TMultiGraph("", "");
     2718
     2719  TLegend *leg_recbjet_lmis_pt = new TLegend(0.50, 0.64, 0.90, 0.90);
     2720  TLegend *leg_recbjet_lmis_eta = new TLegend(0.50, 0.64, 0.90, 0.90);
     2721
     2722  TGraphErrors *gr_recbjet_lmis_pt = new TGraphErrors[n_etabins];
     2723  TGraphErrors *gr_recbjet_lmis_eta = new TGraphErrors[n_ptbins];
     2724  TH1D *h_recbjet_lmis_pt, *h_recbjet_lmis_eta;
     2725
     2726  // loop over eta bins
     2727  for(k = 0; k < etaVals.size() - 1; k++)
     2728  {
     2729
     2730    h_recbjet_lmis_pt = GetJetEffPt<Jet>(branchJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderJet);
     2731    //h_recbjet_lmis_pt = GetEffPt<Jet>(branchJet, branchParticleJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
     2732    gr_recbjet_lmis_pt[k] = TGraphErrors(h_recbjet_lmis_pt);
     2733
     2734    s_etaMin = Form("%.1f", etaVals.at(k));
     2735    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2736
     2737    s_eta = "uds-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2738
     2739    gr_recbjet_lmis_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2740
     2741    addResoGraph(mg_recbjet_lmis_pt, &gr_recbjet_lmis_pt[k], leg_recbjet_lmis_pt, markerStyles.at(k), colors.at(k), s_eta);
     2742  }
     2743
     2744  // loop over pt
     2745  for(k = 0; k < ptVals.size(); k++)
     2746  {
     2747    h_recbjet_lmis_eta = GetJetEffEta<Jet>(branchJet, "Jet", 1, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderJet);
     2748    //h_recbjet_lmis_eta = GetEffEta<Jet>(branchJet, branchParticleJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
     2749    gr_recbjet_lmis_eta[k] = TGraphErrors(h_recbjet_lmis_eta);
     2750
     2751    s_pt = Form("uds-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2752    if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2753
     2754    addResoGraph(mg_recbjet_lmis_eta, &gr_recbjet_lmis_eta[k], leg_recbjet_lmis_eta, markerStyles.at(k), colors.at(k), s_pt);
     2755  }
     2756
     2757  TCanvas *c_recbjet_lmis_pt = new TCanvas("", "", 800, 600);
     2758
     2759  mg_recbjet_lmis_pt->Draw("APE");
     2760
     2761  DrawAxis(mg_recbjet_lmis_pt, leg_recbjet_lmis_pt, ptMin, ptMax, 0.0, 1.0, "p_{T} [GeV]", "light - mistag rate (%)", true, false);
     2762
     2763  leg_recbjet_lmis_pt->Draw();
     2764  pave->Draw();
     2765
     2766  c_recbjet_lmis_pt->Print(pdfOutput, "pdf");
     2767  c_recbjet_lmis_pt->Print(figPath + "img_recbjet_lmis_pt.pdf", "pdf");
     2768  c_recbjet_lmis_pt->Print(figPath + "img_recbjet_lmis_pt.png", "png");
     2769
     2770  TCanvas *c_recbjet_lmis_eta = new TCanvas("", "", 800, 600);
     2771
     2772  mg_recbjet_lmis_eta->Draw("APE");
     2773  DrawAxis(mg_recbjet_lmis_eta, leg_recbjet_lmis_eta, etaMin, etaMax, 0.0, 1.0, " #eta ", "light - mistag rate (%)", false, false);
     2774  leg_recbjet_lmis_eta->Draw();
     2775  pave->Draw();
     2776
     2777  c_recbjet_lmis_eta->Print(pdfOutput, "pdf");
     2778  c_recbjet_lmis_eta->Print(figPath + "img_recbjet_lmis_eta.pdf", "pdf");
     2779  c_recbjet_lmis_eta->Print(figPath + "img_recbjet_lmis_eta.png", "png");
     2780
     2781  ///////////////////////////////////////////
     2782  // tau-jets  Efficiency/ mistag rates   ///
     2783  ///////////////////////////////////////////
     2784
     2785  TMultiGraph *mg_rectaujet_eff_pt = new TMultiGraph("", "");
     2786  TMultiGraph *mg_rectaujet_eff_eta = new TMultiGraph("", "");
     2787
     2788  TLegend *leg_rectaujet_eff_pt = new TLegend(0.50, 0.22, 0.90, 0.48);
     2789  TLegend *leg_rectaujet_eff_eta = new TLegend(0.50, 0.22, 0.90, 0.48);
     2790
     2791  TGraphErrors *gr_rectaujet_eff_pt = new TGraphErrors[n_etabins];
     2792  TGraphErrors *gr_rectaujet_eff_eta = new TGraphErrors[n_ptbins];
     2793  TH1D *h_rectaujet_eff_pt, *h_rectaujet_eff_eta;
     2794
     2795  // loop over eta bins
     2796  for(k = 0; k < etaVals.size() - 1; k++)
     2797  {
     2798
     2799    h_rectaujet_eff_pt = GetTauEffPt<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderTauJet);
     2800    gr_rectaujet_eff_pt[k] = TGraphErrors(h_rectaujet_eff_pt);
     2801
     2802    s_etaMin = Form("%.1f", etaVals.at(k));
     2803    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2804
     2805    s_eta = "#tau-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2806
     2807    gr_rectaujet_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2808
     2809    addResoGraph(mg_rectaujet_eff_pt, &gr_rectaujet_eff_pt[k], leg_rectaujet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2810  }
     2811
     2812  // loop over pt
     2813  for(k = 0; k < ptVals.size(); k++)
     2814  {
     2815    h_rectaujet_eff_eta = GetTauEffEta<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderTauJet);
     2816    gr_rectaujet_eff_eta[k] = TGraphErrors(h_rectaujet_eff_eta);
     2817
     2818    s_pt = Form("#tau-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2819    if(ptVals.at(k) >= 1000.) s_pt = Form("#tau-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2820
     2821    addResoGraph(mg_rectaujet_eff_eta, &gr_rectaujet_eff_eta[k], leg_rectaujet_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2822  }
     2823
     2824  TCanvas *c_rectaujet_eff_pt = new TCanvas("", "", 800, 600);
     2825
     2826  mg_rectaujet_eff_pt->Draw("APE");
     2827  DrawAxis(mg_rectaujet_eff_pt, leg_rectaujet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "#tau - tag efficiency (%)", true, false);
     2828  leg_rectaujet_eff_pt->Draw();
     2829  pave->Draw();
     2830
     2831  c_rectaujet_eff_pt->Print(pdfOutput, "pdf");
     2832  c_rectaujet_eff_pt->Print(figPath + "img_rectaujet_eff_pt.pdf", "pdf");
     2833  c_rectaujet_eff_pt->Print(figPath + "img_rectaujet_eff_pt.png", "png");
     2834
     2835  TCanvas *c_rectaujet_eff_eta = new TCanvas("", "", 800, 600);
     2836
     2837  mg_rectaujet_eff_eta->Draw("APE");
     2838  DrawAxis(mg_rectaujet_eff_eta, leg_rectaujet_eff_eta, etaMin, etaMax, 0.0, 100., " #eta ", "#tau - tag efficiency (%)", false, false);
     2839  leg_rectaujet_eff_eta->Draw();
     2840  pave->Draw();
     2841
     2842  c_rectaujet_eff_eta->Print(pdfOutput, "pdf");
     2843  c_rectaujet_eff_eta->Print(figPath + "img_rectaujet_eff_eta.pdf", "pdf");
     2844  c_rectaujet_eff_eta->Print(figPath + "img_rectaujet_eff_eta.png", "png");
     2845
     2846  //--------------- tau mistag rate ----------
     2847
     2848  TMultiGraph *mg_rectaujet_mis_pt = new TMultiGraph("", "");
     2849  TMultiGraph *mg_rectaujet_mis_eta = new TMultiGraph("", "");
     2850
     2851  TLegend *leg_rectaujet_mis_pt = new TLegend(0.50, 0.64, 0.90, 0.90);
     2852  TLegend *leg_rectaujet_mis_eta = new TLegend(0.50, 0.64, 0.90, 0.90);
     2853
     2854  TGraphErrors *gr_rectaujet_mis_pt = new TGraphErrors[n_etabins];
     2855  TGraphErrors *gr_rectaujet_mis_eta = new TGraphErrors[n_ptbins];
     2856  TH1D *h_rectaujet_mis_pt, *h_rectaujet_mis_eta;
     2857
     2858  // loop over eta bins
     2859  for(k = 0; k < etaVals.size() - 1; k++)
     2860  {
     2861
     2862    h_rectaujet_mis_pt = GetTauEffPt<Jet>(branchJet, branchParticleJet, "TauJet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderJet);
     2863    gr_rectaujet_mis_pt[k] = TGraphErrors(h_rectaujet_mis_pt);
     2864
     2865    s_etaMin = Form("%.1f", etaVals.at(k));
     2866    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2867
     2868    s_eta = "uds-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2869
     2870    gr_rectaujet_mis_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2871
     2872    addResoGraph(mg_rectaujet_mis_pt, &gr_rectaujet_mis_pt[k], leg_rectaujet_mis_pt, markerStyles.at(k), colors.at(k), s_eta);
     2873  }
     2874
     2875  // loop over pt
     2876  for(k = 0; k < ptVals.size(); k++)
     2877  {
     2878    h_rectaujet_mis_eta = GetTauEffEta<Jet>(branchJet, branchParticleJet, "TauJet", 1, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderJet);
     2879    gr_rectaujet_mis_eta[k] = TGraphErrors(h_rectaujet_mis_eta);
     2880
     2881    s_pt = Form("uds-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2882    if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2883
     2884    addResoGraph(mg_rectaujet_mis_eta, &gr_rectaujet_mis_eta[k], leg_rectaujet_mis_eta, markerStyles.at(k), colors.at(k), s_pt);
     2885  }
     2886
     2887  TCanvas *c_rectaujet_mis_pt = new TCanvas("", "", 800, 600);
     2888
     2889  mg_rectaujet_mis_pt->Draw("APE");
     2890  DrawAxis(mg_rectaujet_mis_pt, leg_rectaujet_mis_pt, ptMin, ptMax, 0.0, 5., "p_{T} [GeV]", "#tau - mistag(%)", true, false);
     2891  leg_rectaujet_mis_pt->Draw();
     2892  pave->Draw();
     2893
     2894  c_rectaujet_mis_pt->Print(pdfOutput, "pdf");
     2895  c_rectaujet_mis_pt->Print(figPath + "img_rectaujet_mis_pt.pdf", "pdf");
     2896  c_rectaujet_mis_pt->Print(figPath + "img_rectaujet_mis_pt.png", "png");
     2897
     2898  TCanvas *c_rectaujet_mis_eta = new TCanvas("", "", 800, 600);
     2899
     2900  mg_rectaujet_mis_eta->Draw("APE");
     2901  DrawAxis(mg_rectaujet_mis_eta, leg_rectaujet_mis_eta, etaMin, etaMax, 0.0, 5., " #eta ", "#tau - mistag (%)", false, false);
     2902  leg_rectaujet_mis_eta->Draw();
     2903  pave->Draw();
     2904
     2905  c_rectaujet_mis_eta->Print(pdfOutput + ")", "pdf");
     2906  c_rectaujet_mis_eta->Print(figPath + "img_rectaujet_mis_eta.pdf", "pdf");
     2907  c_rectaujet_mis_eta->Print(figPath + "img_rectaujet_mis_eta.png", "png");
     2908
     2909  //   ----   store resolution histograms in the output (for leave efficiencies out) ---
     2910
     2911  TFile *fout = new TFile(outputFile, "recreate");
     2912
     2913  for(int bin = 0; bin < Nbins; bin++)
     2914  {
     2915
     2916    for(k = 0; k < etaVals.size() - 1; k++)
    24632917    {
    2464 
    2465        h_recele_eff_pt = GetEffPt<Electron>(branchElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    2466        gr_recele_eff_pt[k] = TGraphErrors(h_recele_eff_pt);
    2467 
    2468        s_etaMin = Form("%.1f",etaVals.at(k));
    2469        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2470 
    2471        s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2472 
    2473        gr_recele_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2474 
    2475        addResoGraph(mg_recele_eff_pt, &gr_recele_eff_pt[k], leg_recele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2918      plots_trkpi_res_pt[k].at(bin).resolHist->Write();
     2919      plots_trkele_res_pt[k].at(bin).resolHist->Write();
     2920      plots_trkmu_res_pt[k].at(bin).resolHist->Write();
     2921      plots_ecal_res_e[k].at(bin).resolHist->Write();
     2922      plots_hcal_res_e[k].at(bin).resolHist->Write();
     2923      plots_pfele_res_e[k].at(bin).resolHist->Write();
     2924      plots_pfpi_res_e[k].at(bin).resolHist->Write();
     2925      plots_pfjet_res_e[k].at(bin).resolHist->Write();
     2926      plots_cajet_res_e[k].at(bin).resolHist->Write();
    24762927    }
    24772928
    2478     // loop over pt
    2479     for (k = 0; k < ptVals.size(); k++)
     2929    for(k = 0; k < ptVals.size(); k++)
    24802930    {
    2481        h_recele_eff_eta = GetEffEta<Electron>(branchElectron, branchParticleElectron, "Electron", 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderElectron);
    2482        gr_recele_eff_eta[k] = TGraphErrors(h_recele_eff_eta);
    2483 
    2484        s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    2485        if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2486 
    2487        addResoGraph(mg_recele_eff_eta, &gr_recele_eff_eta[k], leg_recele_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2488     }
    2489 
    2490     TCanvas *c_recele_eff_pt = new TCanvas("","", 800, 600);
    2491 
    2492     mg_recele_eff_pt->Draw("APE");
    2493     DrawAxis(mg_recele_eff_pt, leg_recele_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
    2494     leg_recele_eff_pt->Draw();
    2495     pave->Draw();
    2496 
    2497     c_recele_eff_pt->Print(pdfOutput,"pdf");
    2498     c_recele_eff_pt->Print(figPath+"img_recele_eff_pt.pdf","pdf");
    2499     c_recele_eff_pt->Print(figPath+"img_recele_eff_pt.png","png");
    2500 
    2501     TCanvas *c_recele_eff_eta = new TCanvas("","", 800, 600);
    2502 
    2503     mg_recele_eff_eta->Draw("APE");
    2504     DrawAxis(mg_recele_eff_eta, leg_recele_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
    2505     leg_recele_eff_eta->Draw();
    2506     pave->Draw();
    2507 
    2508     c_recele_eff_eta->Print(pdfOutput,"pdf");
    2509     c_recele_eff_eta->Print(figPath+"img_recele_eff_eta.pdf","pdf");
    2510     c_recele_eff_eta->Print(figPath+"img_recele_eff_eta.png","png");
    2511 
    2512 
    2513     /////////////////////////////////////////
    2514     // Muon Reconstruction Efficiency ///
    2515     /////////////////////////////////////////
    2516 
    2517     TMultiGraph *mg_recmu_eff_pt  = new TMultiGraph("","");
    2518     TMultiGraph *mg_recmu_eff_eta = new TMultiGraph("","");
    2519 
    2520     TLegend *leg_recmu_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
    2521     TLegend *leg_recmu_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
    2522 
    2523     TGraphErrors *gr_recmu_eff_pt  = new TGraphErrors[n_etabins];
    2524     TGraphErrors *gr_recmu_eff_eta = new TGraphErrors[n_ptbins];
    2525     TH1D* h_recmu_eff_pt, *h_recmu_eff_eta;
    2526 
    2527     // loop over eta bins
    2528     for (k = 0; k < etaVals.size()-1; k++)
    2529     {
    2530 
    2531        h_recmu_eff_pt = GetEffPt<Muon>(branchMuon, branchParticleMuon, "muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
    2532        gr_recmu_eff_pt[k] = TGraphErrors(h_recmu_eff_pt);
    2533 
    2534        s_etaMin = Form("%.1f",etaVals.at(k));
    2535        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2536 
    2537        s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2538 
    2539        gr_recmu_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2540 
    2541        addResoGraph(mg_recmu_eff_pt, &gr_recmu_eff_pt[k], leg_recmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2542     }
    2543 
    2544     // loop over pt
    2545     for (k = 0; k < ptVals.size(); k++)
    2546     {
    2547        h_recmu_eff_eta = GetEffEta<Muon>(branchMuon, branchParticleMuon, "muon", 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderMuon);
    2548        gr_recmu_eff_eta[k] = TGraphErrors(h_recmu_eff_eta);
    2549 
    2550        s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    2551        if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2552 
    2553        addResoGraph(mg_recmu_eff_eta, &gr_recmu_eff_eta[k], leg_recmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2554     }
    2555 
    2556     TCanvas *c_recmu_eff_pt = new TCanvas("","", 800, 600);
    2557 
    2558     mg_recmu_eff_pt->Draw("APE");
    2559     DrawAxis(mg_recmu_eff_pt, leg_recmu_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
    2560     leg_recmu_eff_pt->Draw();
    2561     pave->Draw();
    2562 
    2563     c_recmu_eff_pt->Print(pdfOutput,"pdf");
    2564     c_recmu_eff_pt->Print(figPath+"img_recmu_eff_pt.pdf","pdf");
    2565     c_recmu_eff_pt->Print(figPath+"img_recmu_eff_pt.png","png");
    2566 
    2567     TCanvas *c_recmu_eff_eta = new TCanvas("","", 800, 600);
    2568 
    2569     mg_recmu_eff_eta->Draw("APE");
    2570     DrawAxis(mg_recmu_eff_eta, leg_recmu_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
    2571     leg_recmu_eff_eta->Draw();
    2572     pave->Draw();
    2573 
    2574     c_recmu_eff_eta->Print(pdfOutput,"pdf");
    2575     c_recmu_eff_eta->Print(figPath+"img_recmu_eff_eta.pdf","pdf");
    2576     c_recmu_eff_eta->Print(figPath+"img_recmu_eff_eta.png","png");
    2577 
    2578 
    2579     /////////////////////////////////////////
    2580     // Photon Reconstruction Efficiency   ///
    2581     /////////////////////////////////////////
    2582 
    2583     TMultiGraph *mg_recpho_eff_pt  = new TMultiGraph("","");
    2584     TMultiGraph *mg_recpho_eff_eta = new TMultiGraph("","");
    2585 
    2586     TLegend *leg_recpho_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
    2587     TLegend *leg_recpho_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
    2588 
    2589     TGraphErrors *gr_recpho_eff_pt  = new TGraphErrors[n_etabins];
    2590     TGraphErrors *gr_recpho_eff_eta = new TGraphErrors[n_ptbins];
    2591     TH1D* h_recpho_eff_pt, *h_recpho_eff_eta;
    2592 
    2593     // loop over eta bins
    2594     for (k = 0; k < etaVals.size()-1; k++)
    2595     {
    2596 
    2597        h_recpho_eff_pt = GetEffPt<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderPhoton);
    2598        gr_recpho_eff_pt[k] = TGraphErrors(h_recpho_eff_pt);
    2599 
    2600        s_etaMin = Form("%.1f",etaVals.at(k));
    2601        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2602 
    2603        s_eta = "#gamma , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2604 
    2605        gr_recpho_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2606 
    2607        addResoGraph(mg_recpho_eff_pt, &gr_recpho_eff_pt[k], leg_recpho_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2608     }
    2609 
    2610     // loop over pt
    2611     for (k = 0; k < ptVals.size(); k++)
    2612     {
    2613        h_recpho_eff_eta = GetEffEta<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderPhoton);
    2614        gr_recpho_eff_eta[k] = TGraphErrors(h_recpho_eff_eta);
    2615 
    2616        s_pt = Form("#gamma , p_{T} = %.0f GeV",ptVals.at(k));
    2617        if(ptVals.at(k) >= 1000.) s_pt = Form("#gamma , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2618 
    2619        addResoGraph(mg_recpho_eff_eta, &gr_recpho_eff_eta[k], leg_recpho_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2620     }
    2621 
    2622     TCanvas *c_recpho_eff_pt = new TCanvas("","", 800, 600);
    2623 
    2624     mg_recpho_eff_pt->Draw("APE");
    2625     DrawAxis(mg_recpho_eff_pt, leg_recpho_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
    2626     leg_recpho_eff_pt->Draw();
    2627     pave->Draw();
    2628 
    2629     c_recpho_eff_pt->Print(pdfOutput,"pdf");
    2630     c_recpho_eff_pt->Print(figPath+"img_recpho_eff_pt.pdf","pdf");
    2631     c_recpho_eff_pt->Print(figPath+"img_recpho_eff_pt.png","png");
    2632 
    2633     TCanvas *c_recpho_eff_eta = new TCanvas("","", 800, 600);
    2634 
    2635     mg_recpho_eff_eta->Draw("APE");
    2636     DrawAxis(mg_recpho_eff_eta, leg_recpho_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
    2637     leg_recpho_eff_eta->Draw();
    2638     pave->Draw();
    2639 
    2640     c_recpho_eff_eta->Print(pdfOutput,"pdf");
    2641     c_recpho_eff_eta->Print(figPath+"img_recpho_eff_eta.pdf","pdf");
    2642     c_recpho_eff_eta->Print(figPath+"img_recpho_eff_eta.png","png");
    2643    
    2644     /////////////////////////////////////////
    2645     // B-jets  Efficiency/ mistag rates   ///
    2646     /////////////////////////////////////////
    2647 
    2648     TMultiGraph *mg_recbjet_eff_pt  = new TMultiGraph("","");
    2649     TMultiGraph *mg_recbjet_eff_eta = new TMultiGraph("","");
    2650 
    2651     TLegend *leg_recbjet_eff_pt  = new TLegend(0.50,0.22,0.90,0.48);
    2652     TLegend *leg_recbjet_eff_eta = new TLegend(0.50,0.22,0.90,0.48);
    2653 
    2654     TGraphErrors *gr_recbjet_eff_pt  = new TGraphErrors[n_etabins];
    2655     TGraphErrors *gr_recbjet_eff_eta = new TGraphErrors[n_ptbins];
    2656     TH1D* h_recbjet_eff_pt, *h_recbjet_eff_eta;
    2657 
    2658     // loop over eta bins
    2659     for (k = 0; k < etaVals.size()-1; k++)
    2660     {
    2661 
    2662        h_recbjet_eff_pt = GetJetEffPt<Jet>(branchPFBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
    2663        //h_recbjet_eff_pt = GetEffPt<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
    2664        gr_recbjet_eff_pt[k] = TGraphErrors(h_recbjet_eff_pt);
    2665 
    2666        s_etaMin = Form("%.1f",etaVals.at(k));
    2667        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2668 
    2669        s_eta = "b-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2670 
    2671        gr_recbjet_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2672 
    2673        addResoGraph(mg_recbjet_eff_pt, &gr_recbjet_eff_pt[k], leg_recbjet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2674     }
    2675 
    2676     // loop over pt
    2677     for (k = 0; k < ptVals.size(); k++)
    2678     {
    2679        h_recbjet_eff_eta = GetJetEffEta<Jet>(branchPFBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
    2680        //h_recbjet_eff_eta = GetEffEta<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
    2681        gr_recbjet_eff_eta[k] = TGraphErrors(h_recbjet_eff_eta);
    2682 
    2683        s_pt = Form("b-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2684        if(ptVals.at(k) >= 1000.) s_pt = Form("b-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2685 
    2686        addResoGraph(mg_recbjet_eff_eta, &gr_recbjet_eff_eta[k], leg_recbjet_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2687     }
    2688 
    2689     TCanvas *c_recbjet_eff_pt = new TCanvas("","", 800, 600);
    2690 
    2691     mg_recbjet_eff_pt->Draw("APE");
    2692     DrawAxis(mg_recbjet_eff_pt, leg_recbjet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "b - tag efficiency (%)", true, false);
    2693     leg_recbjet_eff_pt->Draw();
    2694     pave->Draw();
    2695 
    2696     c_recbjet_eff_pt->Print(pdfOutput,"pdf");
    2697     c_recbjet_eff_pt->Print(figPath+"img_recbjet_eff_pt.pdf","pdf");
    2698     c_recbjet_eff_pt->Print(figPath+"img_recbjet_eff_pt.png","png");
    2699 
    2700     TCanvas *c_recbjet_eff_eta = new TCanvas("","", 800, 600);
    2701 
    2702     mg_recbjet_eff_eta->Draw("APE");
    2703     DrawAxis(mg_recbjet_eff_eta, leg_recbjet_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "b - tag efficiency (%)", false, false);
    2704     leg_recbjet_eff_eta->Draw();
    2705     pave->Draw();
    2706 
    2707     c_recbjet_eff_eta->Print(pdfOutput,"pdf");
    2708     c_recbjet_eff_eta->Print(figPath+"img_recbjet_eff_eta.pdf","pdf");
    2709     c_recbjet_eff_eta->Print(figPath+"img_recbjet_eff_eta.png","png");
    2710 
    2711     // ------ c - mistag  ------
    2712 
    2713     TMultiGraph *mg_recbjet_cmis_pt  = new TMultiGraph("","");
    2714     TMultiGraph *mg_recbjet_cmis_eta = new TMultiGraph("","");
    2715 
    2716     TLegend *leg_recbjet_cmis_pt  = new TLegend(0.50,0.64,0.90,0.90);
    2717     TLegend *leg_recbjet_cmis_eta = new TLegend(0.50,0.64,0.90,0.90);
    2718 
    2719     TGraphErrors *gr_recbjet_cmis_pt  = new TGraphErrors[n_etabins];
    2720     TGraphErrors *gr_recbjet_cmis_eta = new TGraphErrors[n_ptbins];
    2721     TH1D* h_recbjet_cmis_pt, *h_recbjet_cmis_eta;
    2722 
    2723     // loop over eta bins
    2724     for (k = 0; k < etaVals.size()-1; k++)
    2725     {
    2726 
    2727        h_recbjet_cmis_pt = GetJetEffPt<Jet>(branchPFCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
    2728        //h_recbjet_cmis_pt = GetEffPt<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
    2729        gr_recbjet_cmis_pt[k] = TGraphErrors(h_recbjet_cmis_pt);
    2730 
    2731        s_etaMin = Form("%.1f",etaVals.at(k));
    2732        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2733 
    2734        s_eta = "c-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2735 
    2736        gr_recbjet_cmis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2737 
    2738        addResoGraph(mg_recbjet_cmis_pt, &gr_recbjet_cmis_pt[k], leg_recbjet_cmis_pt, markerStyles.at(k), colors.at(k), s_eta);
    2739     }
    2740 
    2741     // loop over pt
    2742     for (k = 0; k < ptVals.size(); k++)
    2743     {
    2744        h_recbjet_cmis_eta = GetJetEffEta<Jet>(branchPFCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
    2745        //h_recbjet_cmis_eta = GetEffEta<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
    2746        gr_recbjet_cmis_eta[k] = TGraphErrors(h_recbjet_cmis_eta);
    2747 
    2748        s_pt = Form("c-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2749        if(ptVals.at(k) >= 1000.) s_pt = Form("c-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2750 
    2751        addResoGraph(mg_recbjet_cmis_eta, &gr_recbjet_cmis_eta[k], leg_recbjet_cmis_eta, markerStyles.at(k), colors.at(k), s_pt );
    2752     }
    2753 
    2754     TCanvas *c_recbjet_cmis_pt = new TCanvas("","", 800, 600);
    2755 
    2756     mg_recbjet_cmis_pt->Draw("APE");
    2757     DrawAxis(mg_recbjet_cmis_pt, leg_recbjet_cmis_pt, ptMin, ptMax, 0.0, 20, "p_{T} [GeV]", "c - mistag rate (%)", true, false);
    2758     leg_recbjet_cmis_pt->Draw();
    2759     pave->Draw();
    2760 
    2761     c_recbjet_cmis_pt->Print(pdfOutput,"pdf");
    2762     c_recbjet_cmis_pt->Print(figPath+"img_recbjet_cmis_pt.pdf","pdf");
    2763     c_recbjet_cmis_pt->Print(figPath+"img_recbjet_cmis_pt.png","png");
    2764 
    2765     TCanvas *c_recbjet_cmis_eta = new TCanvas("","", 800, 600);
    2766 
    2767     mg_recbjet_cmis_eta->Draw("APE");
    2768     DrawAxis(mg_recbjet_cmis_eta, leg_recbjet_cmis_eta, etaMin, etaMax, 0.0, 20, " #eta ", "c - mistag rate (%)", false, false);
    2769     leg_recbjet_cmis_eta->Draw();
    2770     pave->Draw();
    2771 
    2772     c_recbjet_cmis_eta->Print(pdfOutput,"pdf");
    2773     c_recbjet_cmis_eta->Print(figPath+"img_recbjet_cmis_eta.pdf","pdf");
    2774     c_recbjet_cmis_eta->Print(figPath+"img_recbjet_cmis_eta.png","png");
    2775 
    2776     // ------ light - mistag  ------
    2777 
    2778     TMultiGraph *mg_recbjet_lmis_pt  = new TMultiGraph("","");
    2779     TMultiGraph *mg_recbjet_lmis_eta = new TMultiGraph("","");
    2780 
    2781     TLegend *leg_recbjet_lmis_pt  = new TLegend(0.50,0.64,0.90,0.90);
    2782     TLegend *leg_recbjet_lmis_eta = new TLegend(0.50,0.64,0.90,0.90);
    2783 
    2784     TGraphErrors *gr_recbjet_lmis_pt  = new TGraphErrors[n_etabins];
    2785     TGraphErrors *gr_recbjet_lmis_eta = new TGraphErrors[n_ptbins];
    2786     TH1D* h_recbjet_lmis_pt, *h_recbjet_lmis_eta;
    2787 
    2788     // loop over eta bins
    2789     for (k = 0; k < etaVals.size()-1; k++)
    2790     {
    2791 
    2792        h_recbjet_lmis_pt = GetJetEffPt<Jet>(branchJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
    2793        //h_recbjet_lmis_pt = GetEffPt<Jet>(branchJet, branchParticleJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
    2794        gr_recbjet_lmis_pt[k] = TGraphErrors(h_recbjet_lmis_pt);
    2795 
    2796        s_etaMin = Form("%.1f",etaVals.at(k));
    2797        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2798 
    2799        s_eta = "uds-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2800 
    2801        gr_recbjet_lmis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2802 
    2803        addResoGraph(mg_recbjet_lmis_pt, &gr_recbjet_lmis_pt[k], leg_recbjet_lmis_pt, markerStyles.at(k), colors.at(k), s_eta);
    2804     }
    2805 
    2806     // loop over pt
    2807     for (k = 0; k < ptVals.size(); k++)
    2808     {
    2809        h_recbjet_lmis_eta = GetJetEffEta<Jet>(branchJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
    2810        //h_recbjet_lmis_eta = GetEffEta<Jet>(branchJet, branchParticleJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
    2811        gr_recbjet_lmis_eta[k] = TGraphErrors(h_recbjet_lmis_eta);
    2812 
    2813        s_pt = Form("uds-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2814        if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2815 
    2816        addResoGraph(mg_recbjet_lmis_eta, &gr_recbjet_lmis_eta[k], leg_recbjet_lmis_eta, markerStyles.at(k), colors.at(k), s_pt );
    2817     }
    2818 
    2819     TCanvas *c_recbjet_lmis_pt = new TCanvas("","", 800, 600);
    2820 
    2821     mg_recbjet_lmis_pt->Draw("APE");
    2822    
    2823     DrawAxis(mg_recbjet_lmis_pt, leg_recbjet_lmis_pt, ptMin, ptMax, 0.0, 1.0, "p_{T} [GeV]", "light - mistag rate (%)", true, false);
    2824    
    2825     leg_recbjet_lmis_pt->Draw();
    2826     pave->Draw();
    2827 
    2828     c_recbjet_lmis_pt->Print(pdfOutput,"pdf");
    2829     c_recbjet_lmis_pt->Print(figPath+"img_recbjet_lmis_pt.pdf","pdf");
    2830     c_recbjet_lmis_pt->Print(figPath+"img_recbjet_lmis_pt.png","png");
    2831 
    2832     TCanvas *c_recbjet_lmis_eta = new TCanvas("","", 800, 600);
    2833 
    2834     mg_recbjet_lmis_eta->Draw("APE");
    2835     DrawAxis(mg_recbjet_lmis_eta, leg_recbjet_lmis_eta, etaMin, etaMax, 0.0, 1.0, " #eta ", "light - mistag rate (%)", false, false);
    2836     leg_recbjet_lmis_eta->Draw();
    2837     pave->Draw();
    2838 
    2839     c_recbjet_lmis_eta->Print(pdfOutput,"pdf");
    2840     c_recbjet_lmis_eta->Print(figPath+"img_recbjet_lmis_eta.pdf","pdf");
    2841     c_recbjet_lmis_eta->Print(figPath+"img_recbjet_lmis_eta.png","png");
    2842 
    2843 
    2844     ///////////////////////////////////////////
    2845     // tau-jets  Efficiency/ mistag rates   ///
    2846     ///////////////////////////////////////////
    2847 
    2848     TMultiGraph *mg_rectaujet_eff_pt  = new TMultiGraph("","");
    2849     TMultiGraph *mg_rectaujet_eff_eta = new TMultiGraph("","");
    2850 
    2851     TLegend *leg_rectaujet_eff_pt  = new TLegend(0.50,0.22,0.90,0.48);
    2852     TLegend *leg_rectaujet_eff_eta = new TLegend(0.50,0.22,0.90,0.48);
    2853 
    2854     TGraphErrors *gr_rectaujet_eff_pt  = new TGraphErrors[n_etabins];
    2855     TGraphErrors *gr_rectaujet_eff_eta = new TGraphErrors[n_ptbins];
    2856     TH1D* h_rectaujet_eff_pt, *h_rectaujet_eff_eta;
    2857 
    2858     // loop over eta bins
    2859     for (k = 0; k < etaVals.size()-1; k++)
    2860     {
    2861 
    2862        h_rectaujet_eff_pt = GetTauEffPt<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderTauJet);
    2863        gr_rectaujet_eff_pt[k] = TGraphErrors(h_rectaujet_eff_pt);
    2864 
    2865        s_etaMin = Form("%.1f",etaVals.at(k));
    2866        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2867 
    2868        s_eta = "#tau-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2869 
    2870        gr_rectaujet_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2871 
    2872        addResoGraph(mg_rectaujet_eff_pt, &gr_rectaujet_eff_pt[k], leg_rectaujet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2873     }
    2874 
    2875     // loop over pt
    2876     for (k = 0; k < ptVals.size(); k++)
    2877     {
    2878        h_rectaujet_eff_eta = GetTauEffEta<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderTauJet);
    2879        gr_rectaujet_eff_eta[k] = TGraphErrors(h_rectaujet_eff_eta);
    2880 
    2881        s_pt = Form("#tau-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2882        if(ptVals.at(k) >= 1000.) s_pt = Form("#tau-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2883 
    2884        addResoGraph(mg_rectaujet_eff_eta, &gr_rectaujet_eff_eta[k], leg_rectaujet_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2885     }
    2886 
    2887 
    2888     TCanvas *c_rectaujet_eff_pt = new TCanvas("","", 800, 600);
    2889 
    2890     mg_rectaujet_eff_pt->Draw("APE");
    2891     DrawAxis(mg_rectaujet_eff_pt, leg_rectaujet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "#tau - tag efficiency (%)", true, false);
    2892     leg_rectaujet_eff_pt->Draw();
    2893     pave->Draw();
    2894 
    2895     c_rectaujet_eff_pt->Print(pdfOutput,"pdf");
    2896     c_rectaujet_eff_pt->Print(figPath+"img_rectaujet_eff_pt.pdf","pdf");
    2897     c_rectaujet_eff_pt->Print(figPath+"img_rectaujet_eff_pt.png","png");
    2898 
    2899     TCanvas *c_rectaujet_eff_eta = new TCanvas("","", 800, 600);
    2900 
    2901     mg_rectaujet_eff_eta->Draw("APE");
    2902     DrawAxis(mg_rectaujet_eff_eta, leg_rectaujet_eff_eta, etaMin, etaMax, 0.0, 100., " #eta ", "#tau - tag efficiency (%)", false, false);
    2903     leg_rectaujet_eff_eta->Draw();
    2904     pave->Draw();
    2905 
    2906     c_rectaujet_eff_eta->Print(pdfOutput,"pdf");
    2907     c_rectaujet_eff_eta->Print(figPath+"img_rectaujet_eff_eta.pdf","pdf");
    2908     c_rectaujet_eff_eta->Print(figPath+"img_rectaujet_eff_eta.png","png");
    2909 
    2910 
    2911     //--------------- tau mistag rate ----------
    2912 
    2913     TMultiGraph *mg_rectaujet_mis_pt  = new TMultiGraph("","");
    2914     TMultiGraph *mg_rectaujet_mis_eta = new TMultiGraph("","");
    2915 
    2916     TLegend *leg_rectaujet_mis_pt  = new TLegend(0.50,0.64,0.90,0.90);
    2917     TLegend *leg_rectaujet_mis_eta = new TLegend(0.50,0.64,0.90,0.90);
    2918 
    2919     TGraphErrors *gr_rectaujet_mis_pt  = new TGraphErrors[n_etabins];
    2920     TGraphErrors *gr_rectaujet_mis_eta = new TGraphErrors[n_ptbins];
    2921     TH1D* h_rectaujet_mis_pt, *h_rectaujet_mis_eta;
    2922 
    2923     // loop over eta bins
    2924     for (k = 0; k < etaVals.size()-1; k++)
    2925     {
    2926 
    2927        h_rectaujet_mis_pt = GetTauEffPt<Jet>(branchJet, branchParticleJet, "TauJet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
    2928        gr_rectaujet_mis_pt[k] = TGraphErrors(h_rectaujet_mis_pt);
    2929 
    2930        s_etaMin = Form("%.1f",etaVals.at(k));
    2931        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2932 
    2933        s_eta = "uds-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2934 
    2935        gr_rectaujet_mis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2936 
    2937        addResoGraph(mg_rectaujet_mis_pt, &gr_rectaujet_mis_pt[k], leg_rectaujet_mis_pt, markerStyles.at(k), colors.at(k), s_eta);
    2938     }
    2939 
    2940     // loop over pt
    2941     for (k = 0; k < ptVals.size(); k++)
    2942     {
    2943        h_rectaujet_mis_eta = GetTauEffEta<Jet>(branchJet, branchParticleJet, "TauJet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
    2944        gr_rectaujet_mis_eta[k] = TGraphErrors(h_rectaujet_mis_eta);
    2945 
    2946        s_pt = Form("uds-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2947        if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2948 
    2949        addResoGraph(mg_rectaujet_mis_eta, &gr_rectaujet_mis_eta[k], leg_rectaujet_mis_eta, markerStyles.at(k), colors.at(k), s_pt );
    2950     }
    2951 
    2952     TCanvas *c_rectaujet_mis_pt = new TCanvas("","", 800, 600);
    2953 
    2954     mg_rectaujet_mis_pt->Draw("APE");
    2955     DrawAxis(mg_rectaujet_mis_pt, leg_rectaujet_mis_pt, ptMin, ptMax, 0.0, 5., "p_{T} [GeV]", "#tau - mistag(%)", true, false);
    2956     leg_rectaujet_mis_pt->Draw();
    2957     pave->Draw();
    2958 
    2959     c_rectaujet_mis_pt->Print(pdfOutput,"pdf");
    2960     c_rectaujet_mis_pt->Print(figPath+"img_rectaujet_mis_pt.pdf","pdf");
    2961     c_rectaujet_mis_pt->Print(figPath+"img_rectaujet_mis_pt.png","png");
    2962 
    2963     TCanvas *c_rectaujet_mis_eta = new TCanvas("","", 800, 600);
    2964 
    2965     mg_rectaujet_mis_eta->Draw("APE");
    2966     DrawAxis(mg_rectaujet_mis_eta, leg_rectaujet_mis_eta, etaMin, etaMax, 0.0, 5., " #eta ", "#tau - mistag (%)", false, false);
    2967     leg_rectaujet_mis_eta->Draw();
    2968     pave->Draw();
    2969 
    2970     c_rectaujet_mis_eta->Print(pdfOutput+")","pdf");
    2971     c_rectaujet_mis_eta->Print(figPath+"img_rectaujet_mis_eta.pdf","pdf");
    2972     c_rectaujet_mis_eta->Print(figPath+"img_rectaujet_mis_eta.png","png");
    2973 
    2974 
    2975 //   ----   store resolution histograms in the output (for leave efficiencies out) ---
    2976 
    2977 
    2978   TFile *fout = new TFile(outputFile,"recreate");
    2979 
    2980   for (int bin = 0; bin < Nbins; bin++)
    2981   {
    2982 
    2983     for (k = 0; k < etaVals.size()-1; k++)
    2984     {
    2985        plots_trkpi_res_pt[k].at(bin).resolHist->Write();
    2986        plots_trkele_res_pt[k].at(bin).resolHist->Write();
    2987        plots_trkmu_res_pt[k].at(bin).resolHist->Write();
    2988        plots_ecal_res_e[k].at(bin).resolHist->Write();
    2989        plots_hcal_res_e[k].at(bin).resolHist->Write();
    2990        plots_pfele_res_e[k].at(bin).resolHist->Write();
    2991        plots_pfpi_res_e[k].at(bin).resolHist->Write();
    2992        plots_pfjet_res_e[k].at(bin).resolHist->Write();
    2993        plots_cajet_res_e[k].at(bin).resolHist->Write();
    2994 
    2995     }
    2996 
    2997     for (k = 0; k < ptVals.size(); k++)
    2998     {
    2999        plots_trkpi_res_eta[k].at(bin).resolHist->Write();
    3000        plots_trkele_res_eta[k].at(bin).resolHist->Write();
    3001        plots_trkmu_res_eta[k].at(bin).resolHist->Write();
    3002        plots_ecal_res_eta[k].at(bin).resolHist->Write();
    3003        plots_hcal_res_eta[k].at(bin).resolHist->Write();
    3004        plots_pfele_res_eta[k].at(bin).resolHist->Write();
    3005        plots_pfpi_res_eta[k].at(bin).resolHist->Write();
    3006        plots_pfjet_res_eta[k].at(bin).resolHist->Write();
    3007        plots_cajet_res_eta[k].at(bin).resolHist->Write();
    3008 
     2931      plots_trkpi_res_eta[k].at(bin).resolHist->Write();
     2932      plots_trkele_res_eta[k].at(bin).resolHist->Write();
     2933      plots_trkmu_res_eta[k].at(bin).resolHist->Write();
     2934      plots_ecal_res_eta[k].at(bin).resolHist->Write();
     2935      plots_hcal_res_eta[k].at(bin).resolHist->Write();
     2936      plots_pfele_res_eta[k].at(bin).resolHist->Write();
     2937      plots_pfpi_res_eta[k].at(bin).resolHist->Write();
     2938      plots_pfjet_res_eta[k].at(bin).resolHist->Write();
     2939      plots_cajet_res_eta[k].at(bin).resolHist->Write();
    30092940    }
    30102941
    30112942    plots_pfmet.at(bin).resolHist->Write();
    30122943    plots_camet.at(bin).resolHist->Write();
    3013 
    30142944  }
    30152945
    30162946  fout->Write();
    3017 
    30182947
    30192948  cout << "** Exiting..." << endl;
     
    30652994  DelphesValidation(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]);
    30662995}
    3067 
    3068 
    3069 
Note: See TracChangeset for help on using the changeset viewer.