Index: examples/Validation.cpp
===================================================================
--- examples/Validation.cpp	(revision 87ff5a0d5ba9c8c4cc9eedbcb708eb9ac2813385)
+++ examples/Validation.cpp	(revision 92237ca859b003026b5fcdec8e41b9088fdb5736)
@@ -55,7 +55,5 @@
 //------------------------------------------------------------------------------
 
-double ptrangemin = 10;
-double ptrangemax = 10000;
-static const int Nbins = 20;
+static const int Nbins = 50;
 
 int objStyle = 1;
@@ -82,11 +80,14 @@
 double topLeftLegYmax = 0.85;
 
+unsigned int k;
+
 
 struct resolPlot
 {
-  TH1 *cenResolHist;
-  TH1 *fwdResolHist;
+  TH1* resolHist;
   double ptmin;
   double ptmax;
+  double etamin;
+  double etamax;
   double xmin;
   double xmax;
@@ -95,5 +96,7 @@
   resolPlot();
   resolPlot(double ptdown, double ptup, TString object);
+  resolPlot(double etadown, double etaup, double ptdown, double ptup, TString object);
   void set(double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
+  void set(double etadown, double etaup, double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
   void print(){std::cout << ptmin << std::endl;}
 };
@@ -107,4 +110,9 @@
 {
   this->set(ptdown,ptup,object);
+}
+
+resolPlot::resolPlot(double etadown, double etaup, double ptdown, double ptup, TString object)
+{
+  this->set(etadown, etaup, ptdown, ptup, object);
 }
 
@@ -115,7 +123,19 @@
   obj = object;
 
-  cenResolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_cen", obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_cen", 200,  xmin, xmax);
-  fwdResolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_fwd", obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_fwd", 200,  xmin, xmax);
+  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);
 }
+
+void resolPlot::set(double etadown, double etaup, double ptdown, double ptup, TString object, double xmin, double xmax)
+{
+  etamin = etadown;
+  etamax = etaup;
+  ptmin = ptdown;
+  ptmax = ptup;
+  obj = object;
+
+  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);
+}
+
+
 
 void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
@@ -136,4 +156,24 @@
 }
 
+
+void HistogramsCollectionVsEta(std::vector<resolPlot> *histos, double etamin, double etamax, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
+{
+  resolPlot ptemp;
+  double width;
+  double etadown;
+  double etaup;
+
+  for (int i = 0; i < Nbins; i++)
+  {
+    width = (etamax - etamin) / Nbins;
+    etadown = etamin + i * width;
+    etaup = etamin + (i+1) * width;
+
+    ptemp.set(etadown, etaup, ptmin, ptmax, obj, xmin, xmax);
+    histos->push_back(ptemp);
+  }
+}
+
+
 //------------------------------------------------------------------------------
 
@@ -165,5 +205,5 @@
 
 template<typename T>
-std::pair<TH1D*, TH1D*> GetEff(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, ExRootTreeReader *treeReader)
+TH1D* GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
 {
 
@@ -183,18 +223,12 @@
   Int_t i, j;
 
-  TH1D *histGenPtcen = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
-  TH1D *histRecoPtcen = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
-  TH1D *histGenPtfwd  = new TH1D(name+" gen spectra Eta",name+" gen spectra fwd", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
-  TH1D *histRecoPtfwd = new TH1D(name+" reco spectra Eta",name+" reco spectra fwd", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
-
-  histGenPtcen->SetDirectory(0);
-  histRecoPtcen->SetDirectory(0);
-  histGenPtfwd->SetDirectory(0);
-  histRecoPtfwd->SetDirectory(0);
-
-  BinLogX(histGenPtcen);
-  BinLogX(histRecoPtcen);
-  BinLogX(histGenPtfwd);
-  BinLogX(histRecoPtfwd);
+  TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
+  TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
+
+  histGenPt->SetDirectory(0);
+  histRecoPt->SetDirectory(0);
+
+  BinLogX(histGenPt);
+  BinLogX(histRecoPt);
 
   // Loop over all events
@@ -213,7 +247,11 @@
       deltaR = 999;
 
-      if (particle->PID == pdgID && genMomentum.Pt() > ptrangemin && genMomentum.Pt() < ptrangemax )
+      pt  = genMomentum.Pt();
+      eta = TMath::Abs(genMomentum.Eta());
+
+      if(eta > etamax || eta < etamin ) continue;
+
+      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
       {
-
         // Loop over all reco object in event
         for(j = 0; j < branchReco->GetEntriesFast(); ++j)
@@ -229,6 +267,127 @@
           {
             Jet *jet = (Jet *)recoObj;
-            if(jet->BTag != 1) continue;
+            if( !(jet->BTag & (1 << 0)) ) continue;
+
+            //if(jet->BTag != ) continue;
           }
+
+            if(TMath::Abs(pdgID) == 4)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( !(jet->BTag & (1 << 0)) ) continue;
+          }
+
+           if(TMath::Abs(pdgID) == 1)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( !(jet->BTag & (1 << 0)) ) continue;
+          }
+
+          if(TMath::Abs(pdgID) == 15)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if(jet->TauTag != 1) continue;
+          }
+
+
+          if(genMomentum.DeltaR(recoMomentum) < deltaR)
+          {
+            deltaR = genMomentum.DeltaR(recoMomentum);
+            bestRecoMomentum = recoMomentum;
+          }
+        }
+
+        histGenPt->Fill(pt);
+        if(deltaR < 0.3) { histRecoPt->Fill(pt); }
+
+      }
+    }
+  }
+
+  histRecoPt->Sumw2();
+  histGenPt->Sumw2();
+
+  histRecoPt->Divide(histGenPt);
+  histRecoPt->Scale(100.);
+
+  return histRecoPt;
+}
+
+template<typename T>
+TH1D* GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
+{
+
+  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+
+  Long64_t allEntries = treeReader->GetEntries();
+
+  GenParticle *particle;
+  T *recoObj;
+
+  TLorentzVector recoMomentum, genMomentum, bestRecoMomentum;
+
+  Float_t deltaR;
+  Float_t pt, eta;
+  Long64_t entry;
+
+  Int_t i, j;
+
+  TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
+  TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
+
+  histGenEta->SetDirectory(0);
+  histRecoEta->SetDirectory(0);
+
+  // Loop over all events
+  for(entry = 0; entry < allEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    // Loop over all generated particle in event
+    for(i = 0; i < branchParticle->GetEntriesFast(); ++i)
+    {
+
+      particle = (GenParticle*) branchParticle->At(i);
+      genMomentum = particle->P4();
+
+      deltaR = 999;
+
+      pt  = genMomentum.Pt();
+      eta = genMomentum.Eta();
+
+      if(pt > ptmax || pt < ptmin ) continue;
+
+      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
+      {
+        // Loop over all reco object in event
+        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
+        {
+          recoObj = (T*)branchReco->At(j);
+          recoMomentum = recoObj->P4();
+          // this is simply to avoid warnings from initial state particle
+          // having infite rapidity ...
+        //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
+
+          // take the closest parton candidate
+          if(TMath::Abs(pdgID) == 5)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( !(jet->BTag & (1 << 0)) ) continue;
+
+          }
+
+          if(TMath::Abs(pdgID) == 4)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( !(jet->BTag & (1 << 0)) ) continue;
+          }
+
+           if(TMath::Abs(pdgID) == 1)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( !(jet->BTag & (1 << 0)) ) continue;
+          }
+
           if(TMath::Abs(pdgID) == 15)
           {
@@ -243,40 +402,217 @@
         }
 
-        pt  = genMomentum.Pt();
-        eta = genMomentum.Eta();
-
-        if (TMath::Abs(eta) < 1.5)
+        histGenEta->Fill(eta);
+        if(deltaR < 0.3) { histRecoEta->Fill(eta); }
+
+      }
+    }
+  }
+
+  histRecoEta->Sumw2();
+  histGenEta->Sumw2();
+
+  histRecoEta->Divide(histGenEta);
+  histRecoEta->Scale(100.);
+
+  return histRecoEta;
+}
+
+
+
+template<typename T>
+TH1D* GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
+{
+
+  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+
+  Long64_t allEntries = treeReader->GetEntries();
+
+  GenParticle *particle;
+  T *recoObj;
+
+  TLorentzVector recoMomentum, genMomentum, bestRecoMomentum;
+
+  Float_t deltaR;
+  Float_t pt, eta;
+  Long64_t entry;
+
+  Int_t i, j;
+
+  TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
+  TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
+
+  histGenPt->SetDirectory(0);
+  histRecoPt->SetDirectory(0);
+
+  BinLogX(histGenPt);
+  BinLogX(histRecoPt);
+
+  // Loop over all events
+  for(entry = 0; entry < allEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    // Loop over all generated particle in event
+    for(i = 0; i < branchParticle->GetEntriesFast(); ++i)
+    {
+
+      particle = (GenParticle*) branchParticle->At(i);
+      genMomentum = particle->P4();
+
+      deltaR = 999;
+
+      pt  = genMomentum.Pt();
+      eta = TMath::Abs(genMomentum.Eta());
+
+      if(eta > etamax || eta < etamin ) continue;
+
+      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
+      {
+        // Loop over all reco object in event
+        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
         {
-          histGenPtcen->Fill(pt);
-          if(deltaR < 0.3) { histRecoPtcen->Fill(pt); }
+          recoObj = (T*)branchReco->At(j);
+          recoMomentum = recoObj->P4();
+          // this is simply to avoid warnings from initial state particle
+          // having infite rapidity ...
+          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
+
+          if(TMath::Abs(pdgID) == 1)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( jet->TauTag != 1 ) continue;
+          }
+
+          if(TMath::Abs(pdgID) == 15)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if(jet->TauTag != 1) continue;
+          }
+
+          if(genMomentum.DeltaR(recoMomentum) < deltaR)
+          {
+            deltaR = genMomentum.DeltaR(recoMomentum);
+            bestRecoMomentum = recoMomentum;
+          }
         }
-        else if (TMath::Abs(eta) < 2.5)
+
+        histGenPt->Fill(pt);
+        if(deltaR < 0.3) { histRecoPt->Fill(pt); }
+
+      }
+    }
+  }
+
+  histRecoPt->Sumw2();
+  histGenPt->Sumw2();
+
+
+  histRecoPt->Divide(histGenPt);
+  histRecoPt->Scale(100.);
+  if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1/0.648);
+
+  return histRecoPt;
+}
+
+template<typename T>
+TH1D* GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
+{
+
+  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+
+  Long64_t allEntries = treeReader->GetEntries();
+
+  GenParticle *particle;
+  T *recoObj;
+
+  TLorentzVector recoMomentum, genMomentum, bestRecoMomentum;
+
+  Float_t deltaR;
+  Float_t pt, eta;
+  Long64_t entry;
+
+  Int_t i, j;
+
+  TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
+  TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
+
+  histGenEta->SetDirectory(0);
+  histRecoEta->SetDirectory(0);
+
+  // Loop over all events
+  for(entry = 0; entry < allEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    // Loop over all generated particle in event
+    for(i = 0; i < branchParticle->GetEntriesFast(); ++i)
+    {
+
+      particle = (GenParticle*) branchParticle->At(i);
+      genMomentum = particle->P4();
+
+      deltaR = 999;
+
+      pt  = genMomentum.Pt();
+      eta = genMomentum.Eta();
+
+      if(pt > ptmax || pt < ptmin ) continue;
+
+      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
+      {
+        // Loop over all reco object in event
+        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
         {
-          histGenPtfwd->Fill(pt);
-          if(deltaR < 0.3) { histRecoPtfwd->Fill(pt); }
-
+          recoObj = (T*)branchReco->At(j);
+          recoMomentum = recoObj->P4();
+          // this is simply to avoid warnings from initial state particle
+          // having infite rapidity ...
+        //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
+
+         if(TMath::Abs(pdgID) == 1)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if( jet->TauTag != 1 ) continue;
+          }
+
+          if(TMath::Abs(pdgID) == 15)
+          {
+            Jet *jet = (Jet *)recoObj;
+            if(jet->TauTag != 1) continue;
+          }
+
+          if(genMomentum.DeltaR(recoMomentum) < deltaR)
+          {
+            deltaR = genMomentum.DeltaR(recoMomentum);
+            bestRecoMomentum = recoMomentum;
+          }
         }
+
+        histGenEta->Fill(eta);
+        if(deltaR < 0.3) { histRecoEta->Fill(eta); }
+
       }
     }
   }
 
-
-  std::pair<TH1D*,TH1D*> histos;
-
-  histRecoPtcen->Divide(histGenPtcen);
-  histRecoPtfwd->Divide(histGenPtfwd);
-
-  histos.first = histRecoPtcen;
-  histos.second = histRecoPtfwd;
-
-  return histos;
+  histRecoEta->Sumw2();
+  histGenEta->Sumw2();
+
+  histRecoEta->Divide(histGenEta);
+  histRecoEta->Scale(100.);
+  if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1/0.648);
+
+  return histRecoEta;
 }
 
+
 template<typename T>
-void GetEres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, ExRootTreeReader *treeReader)
+void GetPtres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
 {
   Long64_t allEntries = treeReader->GetEntries();
 
-  cout << "** Computing resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+  cout << "** Computing pt resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
 
   GenParticle *particle;
@@ -328,13 +664,12 @@
       if(deltaR < 0.3)
       {
-        pt  = bestGenMomentum.E();
+        pt  = bestGenMomentum.Pt();
         eta = TMath::Abs(bestGenMomentum.Eta());
 
         for (bin = 0; bin < Nbins; bin++)
         {
-          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5)
+          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
           {
-            if (eta < 1.5) {histos->at(bin).cenResolHist->Fill(recoMomentum.E()/bestGenMomentum.E());}
-            else if (eta < 2.5) {histos->at(bin).fwdResolHist->Fill(recoMomentum.E()/bestGenMomentum.E());}
+            histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
           }
         }
@@ -346,9 +681,9 @@
 
 template<typename T>
-void GetPtres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, ExRootTreeReader *treeReader)
+void GetEres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
 {
   Long64_t allEntries = treeReader->GetEntries();
 
-  cout << "** Computing pt resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+  cout << "** Computing e resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
 
   GenParticle *particle;
@@ -358,5 +693,5 @@
 
   Float_t deltaR;
-  Float_t pt, eta;
+  Float_t e, eta;
   Long64_t entry;
 
@@ -369,5 +704,5 @@
     treeReader->ReadEntry(entry);
 
-    // Loop over all reconstructed jets in event
+     // Loop over all reconstructed jets in event
     for(i = 0; i < branchReco->GetEntriesFast(); ++i)
     {
@@ -400,13 +735,12 @@
       if(deltaR < 0.3)
       {
-        pt  = bestGenMomentum.Pt();
+        e  = bestGenMomentum.E();
         eta = TMath::Abs(bestGenMomentum.Eta());
 
         for (bin = 0; bin < Nbins; bin++)
         {
-          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5)
+          if(e > histos->at(bin).ptmin && e < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
           {
-            if (eta < 1.5) {histos->at(bin).cenResolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());}
-            else if (eta < 2.5) {histos->at(bin).fwdResolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());}
+            histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
           }
         }
@@ -417,5 +751,149 @@
 
 
-void GetJetsEres(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader)
+template<typename T>
+void GetPtresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t ptMin, Double_t ptMax, ExRootTreeReader *treeReader)
+{
+  Long64_t allEntries = treeReader->GetEntries();
+
+  cout << "** Computing pt resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+
+  GenParticle *particle;
+  T* recoObj;
+
+  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
+
+  Float_t deltaR;
+  Float_t pt, eta;
+  Long64_t entry;
+
+  Int_t i, j, bin;
+
+  // Loop over all events
+  for(entry = 0; entry < allEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    // Loop over all reconstructed jets in event
+    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
+    {
+      recoObj = (T*) branchReco->At(i);
+      recoMomentum = recoObj->P4();
+
+      deltaR = 999;
+
+     // Loop over all hard partons in event
+     for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
+     {
+        particle = (GenParticle*) branchParticle->At(j);
+        if (particle->PID == pdgID && particle->Status == 1)
+        {
+          genMomentum = particle->P4();
+
+          // this is simply to avoid warnings from initial state particle
+          // having infite rapidity ...
+          if(genMomentum.Px() == 0 && genMomentum.Py() == 0) continue;
+
+          // take the closest parton candidate
+          if(genMomentum.DeltaR(recoMomentum) < deltaR)
+          {
+             deltaR = genMomentum.DeltaR(recoMomentum);
+             bestGenMomentum = genMomentum;
+          }
+        }
+      }
+
+      if(deltaR < 0.3)
+      {
+        pt  = bestGenMomentum.Pt();
+        eta = bestGenMomentum.Eta();
+
+        for (bin = 0; bin < Nbins; bin++)
+        {
+          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt > ptMin && pt < ptMax)
+          {
+             histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
+          }
+        }
+      }
+    }
+  }
+}
+
+template<typename T>
+void GetEresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t eMin, Double_t eMax, ExRootTreeReader *treeReader)
+{
+  Long64_t allEntries = treeReader->GetEntries();
+
+  cout << "** Computing E resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
+
+  GenParticle *particle;
+  T* recoObj;
+
+  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
+
+  Float_t deltaR;
+  Float_t e, eta;
+  Long64_t entry;
+
+  Int_t i, j, bin;
+
+  // Loop over all events
+  for(entry = 0; entry < allEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    // Loop over all reconstructed jets in event
+    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
+    {
+      recoObj = (T*) branchReco->At(i);
+      recoMomentum = recoObj->P4();
+
+      deltaR = 999;
+
+     // Loop over all hard partons in event
+     for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
+     {
+        particle = (GenParticle*) branchParticle->At(j);
+        if (particle->PID == pdgID && particle->Status == 1)
+        {
+          genMomentum = particle->P4();
+
+          // this is simply to avoid warnings from initial state particle
+          // having infite rapidity ...
+          if(genMomentum.Px() == 0 && genMomentum.Py() == 0) continue;
+
+          // take the closest parton candidate
+          if(genMomentum.DeltaR(recoMomentum) < deltaR)
+          {
+             deltaR = genMomentum.DeltaR(recoMomentum);
+             bestGenMomentum = genMomentum;
+          }
+        }
+      }
+
+      if(deltaR < 0.3)
+      {
+        e  = bestGenMomentum.E();
+        eta = bestGenMomentum.Eta();
+
+
+
+        for (bin = 0; bin < Nbins; bin++)
+        {
+          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && e > eMin && e < eMax)
+          {
+             histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
+          }
+        }
+      }
+    }
+  }
+}
+
+
+
+void GetJetsEres(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader, Double_t etaMin, Double_t etaMax)
 {
 
@@ -470,23 +948,211 @@
       }
 
-      if(deltaR < 0.25)
+      if(deltaR < 0.3)
       {
         pt  = genJetMomentum.E();
-        eta = TMath::Abs(genJetMomentum.Eta());
+        eta = genJetMomentum.Eta();
 
         for (bin = 0; bin < Nbins; bin++)
         {
-            if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 1.5)
-            {
-                histos->at(bin).cenResolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
-            }
-            else if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5)
-            {
-                histos->at(bin).fwdResolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
-            }
+          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < etaMax && eta > etaMin)
+          {
+             histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
+          }
         }
       }
     }
   }
+}
+
+void GetJetsEresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader, Double_t eMin, Double_t eMax)
+{
+
+  Long64_t allEntries = treeReader->GetEntries();
+
+  cout << "** Computing resolution of " << branchJet->GetName() << " induced by " << branchGenJet->GetName() << endl;
+
+  Jet *jet, *genjet;
+
+  TLorentzVector jetMomentum, genJetMomentum, bestGenJetMomentum;
+
+  Float_t deltaR;
+  Float_t pt, eta;
+  Long64_t entry;
+
+  Int_t i, j, bin;
+
+  // Loop over all events
+  for(entry = 0; entry < allEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
+
+    // Loop over all reconstructed jets in event
+    for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
+    {
+
+      jet = (Jet*) branchJet->At(i);
+      jetMomentum = jet->P4();
+
+      deltaR = 999;
+
+     // Loop over all hard partons in event
+     for(j = 0; j < TMath::Min(2,branchGenJet->GetEntriesFast()); ++j)
+     {
+        genjet = (Jet*) branchGenJet->At(j);
+
+        genJetMomentum = genjet->P4();
+
+        // this is simply to avoid warnings from initial state particle
+        // having infite rapidity ...
+        if(genJetMomentum.Px() == 0 && genJetMomentum.Py() == 0) continue;
+
+        // take the closest parton candidate
+        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
+        {
+           deltaR = genJetMomentum.DeltaR(jetMomentum);
+           bestGenJetMomentum = genJetMomentum;
+        }
+      }
+
+      if(deltaR < 0.3)
+      {
+
+        pt  = genJetMomentum.E();
+        eta = genJetMomentum.Eta();
+
+        for (bin = 0; bin < Nbins; bin++)
+        {
+          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt < eMax && pt > eMin)
+          {
+             histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
+          }
+        }
+      }
+    }
+  }
+}
+
+
+
+std::pair<Double_t, Double_t> GausFit(TH1* hist)
+{
+  TF1 *f1 = new TF1("f1", "gaus", hist->GetMean()-2*hist->GetRMS(), hist->GetMean()+2*hist->GetRMS());
+  hist->Fit("f1","RQ");
+
+  TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2*f1->GetParameter(2), f1->GetParameter(1) + 2*f1->GetParameter(2));
+  hist->Fit("f2","RQ");
+
+  Double_t sig = f2->GetParameter(2);
+  Double_t sigErr = f2->GetParError(2);
+
+  delete f1;
+  delete f2;
+  return make_pair (sig, sigErr);
+}
+
+
+TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool rms = false)
+{
+  Int_t bin;
+  Int_t count = 0;
+  TGraphErrors gr = TGraphErrors(Nbins/2);
+  double val, error;
+  for (bin = 0; bin < Nbins; bin++)
+  {
+     std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
+     if (rms == true)
+     {
+       gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, 100*histos->at(bin).resolHist->GetRMS());
+       //gr.SetPointError(count,0, 100*sigvalues.second); // to correct
+       error = 100*histos->at(bin).resolHist->GetRMSError();
+       val = 100*histos->at(bin).resolHist->GetRMS();
+       if(error > 0.2*val) error = 0.2*val;
+       gr.SetPointError(count,0, error); // to correct
+     }
+     else
+     {
+
+       gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, 100*sigvalues.first);
+       error = 100*sigvalues.second;
+       val = 100*sigvalues.first;
+       if(error > 0.2*val) error = 0.2*val;
+       gr.SetPointError(count,0, error); // to correct
+       //gr.SetPointError(count,0, 100*sigvalues.second);
+     }
+     count++;
+  }
+
+  return gr;
+}
+
+TGraphErrors MetResGraph(std::vector<resolPlot> *histos, bool rms = false)
+{
+  Int_t bin;
+  Int_t count = 0;
+  TGraphErrors gr = TGraphErrors(Nbins/2);
+  double val, error;
+  for (bin = 0; bin < Nbins; bin++)
+  {
+     std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
+     if (rms == true)
+     {
+       gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, histos->at(bin).resolHist->GetRMS());
+       error = histos->at(bin).resolHist->GetRMSError();
+       val = histos->at(bin).resolHist->GetRMS();
+       if(error > 0.2*val) error = 0.2*val;
+       gr.SetPointError(count,0, error); // to correct
+     }
+     else
+     {
+
+       gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first);
+       val = sigvalues.first;
+       error = sigvalues.second;
+       if(error > 0.2*val) error = 0.2*val;
+       gr.SetPointError(count,0, error);
+       //gr.SetPointError(count,0, 100*sigvalues.second);
+     }
+     count++;
+  }
+
+  return gr;
+}
+
+
+
+TGraphErrors EresGraphVsEta(std::vector<resolPlot> *histos, bool rms = false)
+{
+  Int_t bin;
+  Int_t count = 0;
+  TGraphErrors gr = TGraphErrors(Nbins/2);
+  double val, error;
+  for (bin = 0; bin < Nbins; bin++)
+  {
+
+     std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
+     if (rms == true)
+     {
+       gr.SetPoint(count,(histos->at(bin).etamin+histos->at(bin).etamax)/2.0, histos->at(bin).resolHist->GetRMS());
+       error = 100*histos->at(bin).resolHist->GetRMSError();
+       val = 100*histos->at(bin).resolHist->GetRMS();
+       if(error > 0.2*val) error = 0.2*val;
+       gr.SetPointError(count,0, error); // to correct
+     }
+     else
+     {
+       gr.SetPoint(count,(histos->at(bin).etamin+histos->at(bin).etamax)/2.0, 100*sigvalues.first);
+       val = 100*sigvalues.first;
+       error = 100*sigvalues.second;
+       if(error > 0.2*val) error = 0.2*val;
+       gr.SetPointError(count,0, error);
+       //gr.SetPointError(count,0, 100*sigvalues.second);
+     }
+     count++;
+  }
+
+  return gr;
 }
 
@@ -536,6 +1202,5 @@
         if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax )
         {
-          histos->at(bin).cenResolHist->Fill(met->P4().Px());
-          histos->at(bin).fwdResolHist->Fill(met->P4().Py());
+          histos->at(bin).resolHist->Fill(met->P4().Px());
         }
       }
@@ -545,156 +1210,33 @@
 
 
-std::pair<Double_t, Double_t> GausFit(TH1* hist)
+
+//------------------------------------------------------------------------------
+
+
+void addResoGraph(TMultiGraph *mg, TGraphErrors *gr, TLegend *leg, int style, Color_t color, TString text)
 {
-  TF1 *f1 = new TF1("f1", "gaus", hist->GetMean()-2*hist->GetRMS(), hist->GetMean()+2*hist->GetRMS());
-  hist->Fit("f1","RQ");
-
-  TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2*f1->GetParameter(2), f1->GetParameter(1) + 2*f1->GetParameter(2));
-  hist->Fit("f2","RQ");
-
-  Double_t sig = f2->GetParameter(2);
-  Double_t sigErr = f2->GetParError(2);
-
-  delete f1;
-  delete f2;
-  return make_pair (sig, sigErr);
+
+  gr->SetLineWidth(2);
+  gr->SetLineColor(color);
+  gr->SetMarkerStyle(style);
+  gr->SetMarkerColor(color);
+  gr->SetMarkerSize(1.5);
+
+  std::cout << "Adding " << gr->GetName() << std::endl;
+  mg->Add(gr);
+  leg->AddEntry(gr,text,"p");
+
 }
 
 
-TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool central, bool rms = false)
+void DrawAxis(TMultiGraph *mg, TLegend *leg, double xmin, double xmax, double ymin, double ymax, TString tx, TString ty, bool logx = 0, bool logy = 0)
 {
-  Int_t bin;
-  Int_t count = 0;
-  TGraphErrors gr = TGraphErrors(Nbins/2);
-  Double_t sig = 0;
-  Double_t sigErr = 0;
-  for (bin = 0; bin < Nbins; bin++)
-  {
-    if (central == true && histos->at(bin).cenResolHist->GetEntries() > 100)
-    {
-      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).cenResolHist);
-      if (rms == true)
-      {
-        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.second);
-        gr.SetPointError(count,0, sigvalues.second); // to correct
-      }
-      else
-      {
-        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first);
-        gr.SetPointError(count,0, sigvalues.second);
-      }
-      count++;
-    }
-
-    else if (central == false && histos->at(bin).fwdResolHist->GetEntries() > 10)
-    {
-      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).fwdResolHist);
-      if (rms == true)
-      {
-        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.second);
-        gr.SetPointError(count,0, sigvalues.second); // to correct
-      }
-      else
-      {
-        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first);
-        gr.SetPointError(count,0, sigvalues.second);
-      }
-      count++;
-    }
-
-  }
-  return gr;
-}
-
-
-//------------------------------------------------------------------------------
-
-
-// type 1 : object, 2 : track, 3 : tower
-
-void addGraph(TMultiGraph *mg, TGraphErrors *gr, TLegend *leg, int type)
-{
-
-  gr->SetLineWidth(2);
-
-  switch ( type )
-  {
-    case 1:
-      gr->SetLineColor(objColor);
-      gr->SetLineStyle(objStyle);
-      std::cout << "Adding " << gr->GetName() << std::endl;
-      mg->Add(gr);
-      leg->AddEntry(gr,"Reco","l");
-      break;
-
-    case 2:
-      gr->SetLineColor(trackColor);
-      gr->SetLineStyle(trackStyle);
-      mg->Add(gr);
-      leg->AddEntry(gr,"Track","l");
-      break;
-
-    case 3:
-      gr->SetLineColor(towerColor);
-      gr->SetLineStyle(towerStyle);
-      mg->Add(gr);
-      leg->AddEntry(gr,"Tower","l");
-      break;
-
-    case 0:
-      gr->SetLineColor(objColor);
-      gr->SetLineStyle(objStyle);
-      mg->Add(gr);
-      break;
-
-    default:
-      std::cout << "wrong type, possibles choices are Object, Track and Tower" << std::endl;
-      break;
-  }
-}
-
-void addHist(TH1D *h, TLegend *leg, int type)
-{
-  h->SetLineWidth(2);
-
-  switch ( type )
-  {
-    case 1:
-      h->SetLineColor(objColor);
-      h->SetLineStyle(objStyle);
-      leg->AddEntry(h,"Reco","l");
-      break;
-
-    case 2:
-      h->SetLineColor(trackColor);
-      h->SetLineStyle(trackStyle);
-      leg->AddEntry(h,"Track","l");
-      break;
-
-    case 3:
-      h->SetLineColor(towerColor);
-      h->SetLineStyle(towerStyle);
-      leg->AddEntry(h,"Tower","l");
-      break;
-
-    case 0:
-      h->SetLineColor(objColor);
-      h->SetLineStyle(objStyle);
-      break;
-
-    default:
-      std::cout << "wrong type, possibles choices are Object, Track and Tower" << std::endl;
-      break;
-  }
-}
-
-void DrawAxis(TMultiGraph *mg, TLegend *leg, double max, int type = 0)
-{
-  mg->SetMinimum(0.);
-  mg->SetMaximum(max);
-  mg->GetXaxis()->SetLimits(ptrangemin,ptrangemax);
-  mg->GetYaxis()->SetTitle("resolution");
-  if (type == 0) mg->GetXaxis()->SetTitle("E [GeV]");
-  else mg->GetXaxis()->SetTitle("p_{T} [GeV]");
+  mg->SetMinimum(ymin);
+  mg->SetMaximum(ymax);
+  mg->GetXaxis()->SetLimits(xmin,xmax);
+
+  mg->GetXaxis()->SetTitle(tx);
+  mg->GetYaxis()->SetTitle(ty);
+
   mg->GetYaxis()->SetTitleSize(0.07);
   mg->GetXaxis()->SetTitleSize(0.07);
@@ -705,6 +1247,12 @@
   mg->GetXaxis()->SetTitleOffset(1.4);
 
+  mg->GetXaxis()->SetTitleFont(132);
+  mg->GetYaxis()->SetTitleFont(132);
+  mg->GetXaxis()->SetLabelFont(132);
+  mg->GetYaxis()->SetLabelFont(132);
+
   mg->GetYaxis()->SetNdivisions(505);
 
+  leg->SetTextFont(132);
   leg->SetBorderSize(0);
   leg->SetShadowColor(0);
@@ -713,5 +1261,10 @@
 
   gStyle->SetOptTitle(0);
-  gPad->SetLogx();
+
+  if(logx) gPad->SetLogx();
+  if(logy) gPad->SetLogy();
+
+  //gPad->SetGridx();
+  //gPad->SetGridy();
   gPad->SetBottomMargin(0.2);
   gPad->SetLeftMargin(0.2);
@@ -721,39 +1274,12 @@
 }
 
-void DrawAxis(TH1D *h, TLegend *leg, int type = 0)
+
+void Validation(const char *inputFilePion, const char *inputFileElectron, const char *inputFileMuon, const char *inputFilePhoton, const char *inputFileNeutralHadron, const char *inputFileJet, const char *inputFileBJet, const char *inputFileCJet, const char *inputFileTauJet, const char *outputFile)
 {
 
-  h->GetYaxis()->SetRangeUser(0,1.0);
-  if (type == 0) h->GetXaxis()->SetTitle("E [GeV]");
-  else h->GetXaxis()->SetTitle("p_{T} [GeV]");
-  h->GetYaxis()->SetTitle("efficiency");
-  h->GetYaxis()->SetTitleSize(0.07);
-  h->GetXaxis()->SetTitleSize(0.07);
-  h->GetYaxis()->SetLabelSize(0.06);
-  h->GetXaxis()->SetLabelSize(0.06);
-  h->GetYaxis()->SetLabelOffset(0.03);
-  h->GetYaxis()->SetTitleOffset(1.3);
-  h->GetXaxis()->SetTitleOffset(1.4);
-
-  h->GetYaxis()->SetNdivisions(505);
-
-  leg->SetBorderSize(0);
-  leg->SetShadowColor(0);
-  leg->SetFillColor(0);
-  leg->SetFillStyle(0);
-
-  gStyle->SetOptTitle(0);
-  gStyle->SetOptStat(0);
-  gPad->SetBottomMargin(0.2);
-  gPad->SetLeftMargin(0.2);
-
-  gPad->Modified();
-  gPad->Update();
-
-}
-
-
-void Validation(const char *inputFileElectron, const char *inputFileMuon, const char *inputFilePhoton, const char *inputFileJet, const char *inputFileBJet, const char *inputFileTauJet, const char *outputFile)
-{
+  TChain *chainPion = new TChain("Delphes");
+  chainPion->Add(inputFilePion);
+  ExRootTreeReader *treeReaderPion = new ExRootTreeReader(chainPion);
+
   TChain *chainElectron = new TChain("Delphes");
   chainElectron->Add(inputFileElectron);
@@ -768,4 +1294,8 @@
   ExRootTreeReader *treeReaderPhoton = new ExRootTreeReader(chainPhoton);
 
+  TChain *chainNeutralHadron = new TChain("Delphes");
+  chainNeutralHadron->Add(inputFileNeutralHadron);
+  ExRootTreeReader *treeReaderNeutralHadron = new ExRootTreeReader(chainNeutralHadron);
+
   TChain *chainJet = new TChain("Delphes");
   chainJet->Add(inputFileJet);
@@ -776,4 +1306,8 @@
   ExRootTreeReader *treeReaderBJet = new ExRootTreeReader(chainBJet);
 
+  TChain *chainCJet = new TChain("Delphes");
+  chainCJet->Add(inputFileCJet);
+  ExRootTreeReader *treeReaderCJet = new ExRootTreeReader(chainCJet);
+
   TChain *chainTauJet = new TChain("Delphes");
   chainTauJet->Add(inputFileTauJet);
@@ -782,5 +1316,4 @@
   TClonesArray *branchParticleElectron = treeReaderElectron->UseBranch("Particle");
   TClonesArray *branchTrackElectron = treeReaderElectron->UseBranch("Track");
-  TClonesArray *branchTowerElectron = treeReaderElectron->UseBranch("Tower");
   TClonesArray *branchElectron = treeReaderElectron->UseBranch("Electron");
 
@@ -789,9 +1322,17 @@
   TClonesArray *branchMuon = treeReaderMuon->UseBranch("Muon");
 
+  TClonesArray *branchParticlePion = treeReaderPion->UseBranch("Particle");
+  TClonesArray *branchTrackPion = treeReaderPion->UseBranch("Track");
+  TClonesArray *branchPion = treeReaderPion->UseBranch("Pion");
+
   TClonesArray *branchParticlePhoton = treeReaderPhoton->UseBranch("Particle");
   TClonesArray *branchTowerPhoton = treeReaderPhoton->UseBranch("Tower");
   TClonesArray *branchPhoton = treeReaderPhoton->UseBranch("Photon");
 
+  TClonesArray *branchParticleNeutralHadron = treeReaderNeutralHadron->UseBranch("Particle");
+  TClonesArray *branchTowerNeutralHadron = treeReaderNeutralHadron->UseBranch("Tower");
+
   TClonesArray *branchGenJet = treeReaderJet->UseBranch("GenJet");
+  TClonesArray *branchParticleJet = treeReaderJet->UseBranch("Particle");
   TClonesArray *branchPFJet = treeReaderJet->UseBranch("Jet");
   TClonesArray *branchCaloJet = treeReaderJet->UseBranch("CaloJet");
@@ -800,478 +1341,1331 @@
   TClonesArray *branchPFBJet = treeReaderBJet->UseBranch("Jet");
 
+  TClonesArray *branchParticleCJet = treeReaderCJet->UseBranch("Particle");
+  TClonesArray *branchPFCJet = treeReaderCJet->UseBranch("Jet");
+
   TClonesArray *branchParticleTauJet = treeReaderTauJet->UseBranch("Particle");
   TClonesArray *branchPFTauJet = treeReaderTauJet->UseBranch("Jet");
 
-  TClonesArray *branchScalarHT = treeReaderJet->UseBranch("ScalarHT");
+  TClonesArray *branchGenScalarHT = treeReaderJet->UseBranch("GenScalarHT");
   TClonesArray *branchMet = treeReaderJet->UseBranch("MissingET");
-
-  ///////////////
-  // Electrons //
-  ///////////////
-
-  // Reconstruction efficiency
-  TString elecs = "Electron";
-  int elID = 11;
-  std::pair<TH1D*,TH1D*> histos_el = GetEff<Electron>(branchElectron, branchParticleElectron, "Electron", elID, treeReaderElectron);
-
-  // tracking reconstruction efficiency
-  std::pair <TH1D*,TH1D*> histos_eltrack = GetEff<Track>(branchTrackElectron, branchParticleElectron, "electronTrack", elID, treeReaderElectron);
-
-  // Tower reconstruction efficiency
-  std::pair <TH1D*,TH1D*> histos_eltower = GetEff<Tower>(branchTowerElectron, branchParticleElectron, "electronTower", elID, treeReaderElectron);
-
-  // Electron Energy Resolution
-  std::vector<resolPlot> plots_el;
-  HistogramsCollection(&plots_el, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "electrons");
-  GetEres<Electron>(&plots_el, branchElectron, branchParticleElectron, elID, treeReaderElectron);
-  TGraphErrors gr_el = EresGraph(&plots_el, true);
-  TGraphErrors gr_elFwd = EresGraph(&plots_el, false);
-  gr_el.SetName("Electron");
-  gr_elFwd.SetName("ElectronFwd");
-
-  // Electron Track Energy Resolution
-  std::vector<resolPlot> plots_eltrack;
-  HistogramsCollection(&plots_eltrack, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "electronsTracks");
-  GetEres<Track>(&plots_eltrack, branchTrackElectron, branchParticleElectron, elID, treeReaderElectron);
-  TGraphErrors gr_eltrack = EresGraph(&plots_eltrack, true);
-  TGraphErrors gr_eltrackFwd = EresGraph(&plots_eltrack, false);
-  gr_eltrack.SetName("ElectronTracks");
-  gr_eltrackFwd.SetName("ElectronTracksFwd");
-
-  // Electron Tower Energy Resolution
-  std::vector<resolPlot> plots_eltower;
-  HistogramsCollection(&plots_eltower, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "electronsTower");
-  GetEres<Tower>(&plots_eltower, branchTowerElectron, branchParticleElectron, elID, treeReaderElectron);
-  TGraphErrors gr_eltower = EresGraph(&plots_eltower, true);
-  TGraphErrors gr_eltowerFwd = EresGraph(&plots_eltower, false);
-  gr_eltower.SetName("ElectronTower");
-  gr_eltrackFwd.SetName("ElectronTracksFwd");
-
-  // Canvases
-  TString elEff = "electronEff";
-  TCanvas *C_el1 = new TCanvas(elEff,elEff, 1600, 600);
-  C_el1->Divide(2);
-  C_el1->cd(1);
-  TLegend *leg_el1 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
-  leg_el1->SetHeader("#splitline{electrons}{|#eta| < 1.5}");
-  leg_el1->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_eltrack.first->Draw("][");
-  addHist(histos_eltrack.first, leg_el1, 2);
-  histos_el.first->Draw("same ][");
-  addHist(histos_el.first, leg_el1, 1);
-  DrawAxis(histos_eltrack.first, leg_el1,1);
-
-  leg_el1->Draw();
-
-  C_el1->cd(2);
-  TLegend *leg_el2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
-  leg_el2->SetHeader("#splitline{electrons}{1.5 < |#eta| < 2.5}");
-  leg_el2->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_eltrack.second->Draw("][");
-  addHist(histos_eltrack.second, leg_el2, 2);
-  histos_el.second->Draw("same ][");
-  addHist(histos_el.second, leg_el2, 1);
-
-  DrawAxis(histos_eltrack.second, leg_el2, 1);
-  leg_el2->Draw();
-
-  TString elRes = "electronERes";
-  TString elResFwd = "electronEResForward";
-  TCanvas *C_el2 = new TCanvas(elRes,elRes, 1600, 600);
-  C_el2->Divide(2);
-  C_el2->cd(1);
-  TMultiGraph *mg_el = new TMultiGraph(elRes,elRes);
-  TLegend *leg_el = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_el->SetHeader("#splitline{electrons}{|#eta| < 1.5}");
-  leg_el->AddEntry("","","");
-
-  addGraph(mg_el, &gr_eltower, leg_el, 3);
-  addGraph(mg_el, &gr_eltrack, leg_el, 2);
-  addGraph(mg_el, &gr_el, leg_el, 1);
-
-  mg_el->Draw("ACX");
-  leg_el->Draw();
-
-  DrawAxis(mg_el, leg_el, 0.1);
-
-  C_el2->cd(2);
-  TMultiGraph *mg_elFwd = new TMultiGraph(elResFwd,elResFwd);
-  TLegend *leg_elFwd = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_elFwd->SetHeader("#splitline{electrons}{1.5 < |#eta| < 2.5}");
-  leg_elFwd->AddEntry("","","");
-
-  addGraph(mg_elFwd, &gr_eltowerFwd, leg_elFwd, 3);
-  addGraph(mg_elFwd, &gr_eltrackFwd, leg_elFwd, 2);
-  addGraph(mg_elFwd, &gr_elFwd, leg_elFwd, 1);
-
-  mg_elFwd->Draw("ACX");
-  leg_elFwd->Draw();
-
-  DrawAxis(mg_elFwd, leg_elFwd, 0.2);
+  TClonesArray *branchCaloMet = treeReaderJet->UseBranch("CaloMissingET");
+
+  std::vector<Color_t> colors;
+
+  colors.push_back(kBlack);
+  colors.push_back(kBlue);
+  colors.push_back(kRed);
+  colors.push_back(kGreen+1);
+  colors.push_back(kMagenta+1);
+  colors.push_back(kOrange);
+
+  std::vector<Int_t> markerStyles;
+
+  markerStyles.push_back(20);
+  markerStyles.push_back(21);
+  markerStyles.push_back(22);
+  markerStyles.push_back(23);
+  markerStyles.push_back(33);
+  markerStyles.push_back(34);
 
   TString pdfOutput(outputFile);
   pdfOutput.ReplaceAll(".root", ".pdf");
 
-  C_el1->Print(pdfOutput+"(","pdf");
-  C_el2->Print(pdfOutput,"pdf");
-
-  gDirectory->cd(0);
-
-  ///////////
-  // Muons //
-  ///////////
-
-  // Reconstruction efficiency
-  int muID = 13;
-  std::pair<TH1D*,TH1D*> histos_mu = GetEff<Muon>(branchMuon, branchParticleMuon,"Muon", muID, treeReaderMuon);
-
-  // muon tracking reconstruction efficiency
-  std::pair <TH1D*,TH1D*> histos_mutrack = GetEff<Track>(branchTrackMuon, branchParticleMuon, "muonTrack", muID, treeReaderMuon);
-
-  // Muon Pt Resolution
-  std::vector<resolPlot> plots_mu;
-  HistogramsCollection(&plots_mu, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "muons");
-  GetPtres<Muon>(&plots_mu, branchMuon, branchParticleMuon, muID, treeReaderMuon);
-  TGraphErrors gr_mu = EresGraph(&plots_mu, true);
-  TGraphErrors gr_muFwd = EresGraph(&plots_mu, false);
-  gr_mu.SetName("Muon");
-  gr_muFwd.SetName("MuonFwd");
-
-  // Muon Track Energy Resolution
-  std::vector<resolPlot> plots_mutrack;
-  HistogramsCollection(&plots_mutrack, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "muonsTracks");
-  GetPtres<Track>(&plots_mutrack, branchTrackMuon, branchParticleMuon, muID, treeReaderMuon);
-  TGraphErrors gr_mutrack = EresGraph(&plots_mutrack, true);
-  TGraphErrors gr_mutrackFwd = EresGraph(&plots_mutrack, false);
-  gr_mutrackFwd.SetName("MuonTracksFwd");
-
-  // Canvas
-
-  TString muEff = "muonEff";
-  TCanvas *C_mu1 = new TCanvas(muEff,muEff, 1600, 600);
-  C_mu1->Divide(2);
-  C_mu1->cd(1);
-  TLegend *leg_mu1 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
-  leg_mu1->SetHeader("#splitline{muons}{|#eta| < 1.5}");
-  leg_mu1->AddEntry("","","");
-
-
-  gPad->SetLogx();
-  histos_mutrack.first->Draw("][");
-  addHist(histos_mutrack.first, leg_mu1, 2);
-  histos_mu.first->Draw("same ][");
-  addHist(histos_mu.first, leg_mu1, 1);
-
-  DrawAxis(histos_mutrack.first, leg_mu1, 1);
-
-  leg_mu1->Draw();
-
-  C_mu1->cd(2);
-  TLegend *leg_mu2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
-  leg_mu2->SetHeader("#splitline{muons}{1.5 < |#eta| < 2.5}");
-  leg_mu2->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_mutrack.second->Draw("][");
-  addHist(histos_mutrack.second, leg_mu2, 2);
-  histos_mu.second->Draw("same ][");
-  addHist(histos_mu.second, leg_mu2, 1);
-
-  DrawAxis(histos_mutrack.second, leg_mu2, 1);
-  leg_mu2->Draw();
-
-  TString muRes = "muonERes";
-  TString muResFwd = "muonEResFwd";
-
-  TCanvas *C_mu = new TCanvas(muRes,muRes, 1600, 600);
-  C_mu->Divide(2);
-  C_mu->cd(1);
-  TMultiGraph *mg_mu = new TMultiGraph(muRes,muRes);
-  TLegend *leg_mu = new TLegend(topLeftLegXmin,topLeftLegYmin,topLeftLegXmax,topLeftLegYmax);
-  leg_mu->SetHeader("#splitline{muons}{|#eta| < 1.5}");
-  leg_mu->AddEntry("","","");
-
-  addGraph(mg_mu, &gr_mutrack, leg_mu, 2);
-  addGraph(mg_mu, &gr_mu, leg_mu, 1);
-
-  mg_mu->Draw("ACX");
-  leg_mu->Draw();
-
-  DrawAxis(mg_mu, leg_mu, 0.3, 1);
-
-  C_mu->cd(2);
-  TMultiGraph *mg_muFwd = new TMultiGraph(muResFwd,muResFwd);
-  TLegend *leg_muFwd = new TLegend(topLeftLegXmin,topLeftLegYmin,topLeftLegXmax,topLeftLegYmax);
-  leg_muFwd->SetHeader("#splitline{muons}{1.5 < |#eta| < 2.5}");
-  leg_muFwd->AddEntry("","","");
-
-  addGraph(mg_muFwd, &gr_mutrackFwd, leg_muFwd, 2);
-  addGraph(mg_muFwd, &gr_muFwd, leg_muFwd, 1);
-
-  mg_muFwd->Draw("ACX");
-  leg_muFwd->Draw();
-
-  DrawAxis(mg_muFwd, leg_muFwd, 0.3, 1);
-
-  C_mu1->Print(pdfOutput,"pdf");
-  C_mu->Print(pdfOutput,"pdf");
-
-  gDirectory->cd(0);
-
-  /////////////
-  // Photons //
-  /////////////
-
-  // Reconstruction efficiency
-  int phID = 22;
-  std::pair<TH1D*,TH1D*> histos_ph = GetEff<Electron>(branchPhoton, branchParticlePhoton, "Photon", phID, treeReaderPhoton);
-  std::pair<TH1D*,TH1D*> histos_phtower = GetEff<Electron>(branchTowerPhoton, branchParticlePhoton, "Photon", phID, treeReaderPhoton);
-
-  // Photon Energy Resolution
-  std::vector<resolPlot> plots_ph;
-  HistogramsCollection(&plots_ph, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "photons");
-  GetEres<Photon>(&plots_ph, branchPhoton, branchParticlePhoton, phID, treeReaderPhoton);
-  TGraphErrors gr_ph = EresGraph(&plots_ph, true);
-  TGraphErrors gr_phFwd = EresGraph(&plots_ph, false);
-  gr_ph.SetName("Photon");
-  gr_phFwd.SetName("PhotonFwd");
-
-
-  // Photon Tower Energy Resolution
-  std::vector<resolPlot> plots_phtower;
-  HistogramsCollection(&plots_phtower, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "photonsTower");
-  GetEres<Tower>(&plots_phtower, branchTowerPhoton, branchParticlePhoton, phID, treeReaderPhoton);
-  TGraphErrors gr_phtower = EresGraph(&plots_phtower, true);
-  TGraphErrors gr_phtowerFwd = EresGraph(&plots_phtower, false);
-  gr_phtower.SetName("PhotonTower");
-  gr_phtowerFwd.SetName("PhotonTowerFwd");
-
-  // Canvas
-
-  TString phEff = "photonEff";
-  TCanvas *C_ph1 = new TCanvas(phEff,phEff, 1600, 600);
-  C_ph1->Divide(2);
-  C_ph1->cd(1);
-  TLegend *leg_ph1 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
-  leg_ph1->SetHeader("#splitline{photons}{|#eta| < 1.5}");
-  leg_ph1->AddEntry("","","");
-
-
-  gPad->SetLogx();
-  histos_phtower.first->Draw("][");
-  addHist(histos_phtower.first, leg_ph1, 3);
-  histos_ph.first->Draw("same ][");
-  addHist(histos_ph.first, leg_ph1, 1);
-
-  DrawAxis(histos_phtower.first, leg_ph1, 1);
-  leg_ph1->Draw();
-
-  C_ph1->cd(2);
-  TLegend *leg_ph2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
-  leg_ph2->SetHeader("#splitline{photons}{1.5 < |#eta| < 2.5}");
-  leg_ph2->AddEntry("","","");
-
-
-  gPad->SetLogx();
-  histos_phtower.second->Draw("][");
-  addHist(histos_phtower.second, leg_ph2, 3);
-  histos_ph.second->Draw("same ][");
-  addHist(histos_ph.second, leg_ph2, 1);
-
-  DrawAxis(histos_phtower.second, leg_ph2, 1);
-  leg_ph2->Draw();
-
-  TString phRes = "phERes";
-  TString phResFwd = "phEResFwd";
-
-  TCanvas *C_ph = new TCanvas(phRes,phRes, 1600, 600);
-  C_ph->Divide(2);
-  C_ph->cd(1);
-  TMultiGraph *mg_ph = new TMultiGraph(phRes,phRes);
-  TLegend *leg_ph = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_ph->SetHeader("#splitline{photons}{|#eta| < 1.5}");
-  leg_ph->AddEntry("","","");
-
-  addGraph(mg_ph, &gr_phtower, leg_ph, 3);
-  addGraph(mg_ph, &gr_ph, leg_ph, 1);
-
-  mg_ph->Draw("ACX");
-  leg_ph->Draw();
-
-  DrawAxis(mg_ph, leg_ph, 0.1);
-
-  C_ph->cd(2);
-  TMultiGraph *mg_phFwd = new TMultiGraph(phResFwd,phResFwd);
-  TLegend *leg_phFwd = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_phFwd->SetHeader("#splitline{photons}{1.5 < |#eta| < 2.5}");
-  leg_phFwd->AddEntry("","","");
-
-  addGraph(mg_phFwd, &gr_phtowerFwd, leg_phFwd, 3);
-  addGraph(mg_phFwd, &gr_phFwd, leg_phFwd, 1);
-
-  mg_phFwd->Draw("ACX");
-  leg_phFwd->Draw();
-
-  DrawAxis(mg_phFwd, leg_phFwd, 0.1);
-
-  C_ph1->Print(pdfOutput,"pdf");
-  C_ph->Print(pdfOutput,"pdf");
-
-  gDirectory->cd(0);
-
-  //////////
-  // Jets //
-  //////////
-
-  // BJets Reconstruction efficiency
-  int bID = 5;
-  std::pair<TH1D*,TH1D*> histos_btag = GetEff<Jet>(branchPFBJet, branchParticleBJet,"BTag", bID, treeReaderBJet);
-
-  // TauJets Reconstruction efficiency
-  int tauID = 15;
-  std::pair<TH1D*,TH1D*> histos_tautag = GetEff<Jet>(branchPFTauJet, branchParticleTauJet,"TauTag", tauID, treeReaderTauJet);
-
-  // PFJets Energy Resolution
-  std::vector<resolPlot> plots_pfjets;
-  HistogramsCollection(&plots_pfjets, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "PFJet");
-  GetJetsEres(&plots_pfjets, branchPFJet, branchGenJet, treeReaderJet);
-  TGraphErrors gr_pfjets = EresGraph(&plots_pfjets, true);
-  TGraphErrors gr_pfjetsFwd = EresGraph(&plots_pfjets, false);
-  gr_pfjets.SetName("pfJet");
-  gr_pfjetsFwd.SetName("pfJetFwd");
-
-  // CaloJets Energy Resolution
-  std::vector<resolPlot> plots_calojets;
-  HistogramsCollection(&plots_calojets, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "CaloJet");
-  GetJetsEres(&plots_calojets, branchCaloJet, branchGenJet, treeReaderJet);
-  TGraphErrors gr_calojets = EresGraph(&plots_calojets, true);
-  TGraphErrors gr_calojetsFwd = EresGraph(&plots_calojets, false);
-  gr_calojets.SetName("caloJet");
-  gr_calojetsFwd.SetName("caloJetFwd");
-
-  // MET Resolution vs HT
-  std::vector<resolPlot> plots_met;
-  HistogramsCollection(&plots_met, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "MET", -500, 500);
-  GetMetres(&plots_met, branchScalarHT, branchMet, branchPFJet, treeReaderJet);
-  TGraphErrors gr_met = EresGraph(&plots_met, true);
-  gr_calojets.SetName("MET");
-
-  // Canvas
-  TString btagEff = "btagEff";
-  TCanvas *C_btag1 = new TCanvas(btagEff,btagEff, 1600, 600);
-  C_btag1->Divide(2);
-  C_btag1->cd(1);
-  TLegend *leg_btag1 = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_btag1->SetHeader("#splitline{B-tagging}{|#eta| < 1.5}");
-  leg_btag1->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_btag.first->Draw();
-  addHist(histos_btag.first, leg_btag1, 0);
-
-  DrawAxis(histos_btag.first, leg_btag1, 1);
-  leg_btag1->Draw();
-
-  C_btag1->cd(2);
-  TLegend *leg_btag2 = new TLegend(resLegXmin,resLegYmin,resLegXmax+0.05,resLegYmax);
-  leg_btag2->SetHeader("#splitline{B-tagging}{1.5 < |#eta| < 2.5}");
-  leg_btag2->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_btag.second->Draw();
-  addHist(histos_btag.second, leg_btag2, 0);
-
-  DrawAxis(histos_btag.second, leg_btag2, 1);
-  leg_btag2->Draw();
-  C_btag1->cd(0);
-
-  TString tautagEff = "tautagEff";
-  TCanvas *C_tautag1 = new TCanvas(tautagEff,tautagEff, 1600, 600);
-  C_tautag1->Divide(2);
-  C_tautag1->cd(1);
-  TLegend *leg_tautag1 = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_tautag1->SetHeader("#splitline{#tau-tagging}{|#eta| < 1.5}");
-  leg_tautag1->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_tautag.first->Draw();
-  addHist(histos_tautag.first, leg_tautag1, 0);
-
-  DrawAxis(histos_tautag.first, leg_tautag1, 1);
-  leg_tautag1->Draw();
-
-  C_tautag1->cd(2);
-  TLegend *leg_tautag2 = new TLegend(resLegXmin,resLegYmin,resLegXmax+0.05,resLegYmax);
-  leg_tautag2->SetHeader("#splitline{#tau-tagging}{1.5 < |#eta| < 2.5}");
-  leg_tautag2->AddEntry("","","");
-
-  gPad->SetLogx();
-  histos_tautag.second->Draw();
-  addHist(histos_tautag.second, leg_tautag2, 0);
-
-  DrawAxis(histos_tautag.second, leg_tautag2, 1);
-  leg_tautag2->Draw();
-  C_tautag1->cd(0);
-
-  TString jetRes = "jetERes";
-  TString jetResFwd = "jetEResFwd";
-  TCanvas *C_jet = new TCanvas(jetRes,jetRes, 1600, 600);
-  C_jet->Divide(2);
-
-  C_jet->cd(1);
-  TMultiGraph *mg_jet = new TMultiGraph(jetRes,jetRes);
-  TLegend *leg_jet = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_jet->SetHeader("#splitline{jets}{|#eta| < 1.5}");
-  leg_jet->AddEntry("","","");
-
-  addGraph(mg_jet, &gr_calojets, leg_jet, 3);
-  addGraph(mg_jet, &gr_pfjets, leg_jet, 1);
-
-  mg_jet->Draw("ALX");
-  leg_jet->Draw();
-
-  DrawAxis(mg_jet, leg_jet, 0.5);
-
-  C_jet->cd(2);
-  TMultiGraph *mg_jetFwd = new TMultiGraph(jetResFwd,jetResFwd);
-  TLegend *leg_jetFwd = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax);
-  leg_jetFwd->SetHeader("#splitline{jets}{1.5 < |#eta| < 2.5}");
-  leg_jetFwd->AddEntry("","","");
-
-  addGraph(mg_jetFwd, &gr_calojetsFwd, leg_jetFwd, 3);
-  addGraph(mg_jetFwd, &gr_pfjetsFwd, leg_jetFwd, 1);
-
-  mg_jetFwd->Draw("ALX");
-  leg_jetFwd->Draw();
-
-  DrawAxis(mg_jetFwd, leg_jetFwd, 0.5);
-
-  TString metRes = "MetRes";
-  TCanvas *C_met = new TCanvas(metRes,metRes, 800, 600);
-
-  TMultiGraph *mg_met = new TMultiGraph(metRes,metRes);
-  TLegend *leg_met = new TLegend(topLeftLegXmin,topLeftLegYmin+0.2,topLeftLegXmax-0.2,topLeftLegYmax);
-  leg_met->SetHeader("E_{T}^{miss}");
-  leg_met->AddEntry("","","");
-
-
-  addGraph(mg_met, &gr_met, leg_met, 0);
-
-  mg_met->Draw("ACX");
-  leg_met->Draw();
-
-  DrawAxis(mg_met, leg_met, 300);
-
-  mg_met->GetXaxis()->SetTitle("H_{T} [GeV]");
-  mg_met->GetYaxis()->SetTitle("#sigma(ME_{x}) [GeV]");
-
-  C_jet->Print(pdfOutput,"pdf");
-  C_btag1->Print(pdfOutput,"pdf");
-  C_tautag1->Print(pdfOutput,"pdf");
-  C_met->Print(pdfOutput+")","pdf");
+  TString figPath = inputFilePion;
+  figPath.ReplaceAll(".root", "");
+  figPath.ReplaceAll("root", "www/fig");
+  Int_t lastSlash = figPath.Last('/');
+  Int_t sizePath = figPath.Length();
+  figPath.Remove(lastSlash+1,sizePath);
+
+  TString s_etaMin, s_etaMax, s_eta, s_pt, s_e;
+
+  Double_t ptMin = 1.;
+  Double_t ptMax = 50000.;
+
+  Double_t etaMin = -6.;
+  Double_t etaMax = 6.;
+
+  std::vector<Double_t> ptVals;
+
+  ptVals.push_back(1.);
+  ptVals.push_back(10.);
+  ptVals.push_back(100.);
+  ptVals.push_back(1000.);
+  ptVals.push_back(10000.);
+
+  std::vector<Double_t> etaVals;
+
+  etaVals.push_back(0.);
+  etaVals.push_back(1.5);
+  etaVals.push_back(2.5);
+  etaVals.push_back(4.0);
+  etaVals.push_back(6.0);
+
+  const int n_etabins = etaVals.size()-1;
+  const int n_ptbins = ptVals.size();
+
+
+  //////////////////////////
+  // Tracking performance //
+  //////////////////////////
+
+  // --------- Pion Tracks  --------- //
+
+  TMultiGraph *mg_trkpi_res_pt  = new TMultiGraph("","");
+  TMultiGraph *mg_trkpi_eff_pt  = new TMultiGraph("","");
+  TMultiGraph *mg_trkpi_res_eta = new TMultiGraph("","");
+  TMultiGraph *mg_trkpi_eff_eta = new TMultiGraph("","");
+
+  TLegend *leg_trkpi_res_pt = new TLegend(0.55,0.22,0.90,0.48);
+  TLegend *leg_trkpi_eff_pt = (TLegend*)leg_trkpi_res_pt->Clone();
+  TLegend *leg_trkpi_res_eta = (TLegend*)leg_trkpi_res_pt->Clone();
+  TLegend *leg_trkpi_eff_eta = (TLegend*)leg_trkpi_res_eta->Clone();
+
+
+  TGraphErrors gr_trkpi_res_pt[n_etabins], gr_trkpi_eff_pt[n_etabins], gr_trkpi_res_eta[n_ptbins], gr_trkpi_eff_eta[n_ptbins];
+  TH1D* h_trkpi_eff_pt, *h_trkpi_eff_eta;
+
+  std::vector<resolPlot> plots_trkpi_res_pt[n_etabins], plots_trkpi_res_eta[n_ptbins];
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     HistogramsCollection(&plots_trkpi_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
+     GetPtres<Track>(&plots_trkpi_res_pt[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
+     gr_trkpi_res_pt[k] = EresGraph(&plots_trkpi_res_pt[k]);
+
+     h_trkpi_eff_pt = GetEffPt<Track>(branchTrackPion, branchParticlePion, "Pion", 211, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
+     gr_trkpi_eff_pt[k] = TGraphErrors(h_trkpi_eff_pt);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+     s_eta = "#pi^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+     gr_trkpi_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
+     gr_trkpi_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
+
+     addResoGraph(mg_trkpi_res_pt, &gr_trkpi_res_pt[k], leg_trkpi_res_pt, markerStyles.at(k), colors.at(k), s_eta);
+     addResoGraph(mg_trkpi_eff_pt, &gr_trkpi_eff_pt[k], leg_trkpi_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+  }
+
+  // loop over pt
+  for (k = 0; k < ptVals.size(); k++)
+  {
+     HistogramsCollectionVsEta(&plots_trkpi_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkpi", 0.0, 2.0);
+     GetPtresVsEta<Track>(&plots_trkpi_res_eta[k], branchTrackPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
+     gr_trkpi_res_eta[k] = EresGraphVsEta(&plots_trkpi_res_eta[k]);
+
+     h_trkpi_eff_eta = GetEffEta<Track>(branchTrackPion, branchParticlePion, "Pion", 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderPion);
+     gr_trkpi_eff_eta[k] = TGraphErrors(h_trkpi_eff_eta);
+
+     s_pt = Form("#pi^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_pt = Form("#pi^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+     addResoGraph(mg_trkpi_res_eta, &gr_trkpi_res_eta[k], leg_trkpi_res_eta, markerStyles.at(k), colors.at(k), s_pt );
+     addResoGraph(mg_trkpi_eff_eta, &gr_trkpi_eff_eta[k], leg_trkpi_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+
+  }
+
+  TCanvas *c_trkpi_res_pt = new TCanvas("","", 800, 600);
+
+  mg_trkpi_res_pt->Draw("APE");
+  DrawAxis(mg_trkpi_res_pt, leg_trkpi_res_pt, ptMin, ptMax, 0.01, 100, "p_{T} [GeV]", "(track resolution in p_{T})/p_{T} (%)", true, true);
+  leg_trkpi_res_pt->Draw();
+
+  c_trkpi_res_pt->Print(pdfOutput+"(","pdf");
+  c_trkpi_res_pt->Print(figPath+"img_trkpi_res_pt.pdf","pdf");
+  c_trkpi_res_pt->Print(figPath+"img_trkpi_res_pt.png","png");
+
+  TCanvas *c_trkpi_res_eta = new TCanvas("","", 800, 600);
+
+  mg_trkpi_res_eta->Draw("APE");
+  DrawAxis(mg_trkpi_res_eta, leg_trkpi_res_eta, etaMin, etaMax, 0.01, 100, " #eta ", "(track resolution in p_{T})/p_{T} (%)", false, true);
+  leg_trkpi_res_eta->Draw();
+
+  c_trkpi_res_eta->Print(pdfOutput,"pdf");
+  c_trkpi_res_eta->Print(figPath+"img_trkpi_res_eta.pdf","pdf");
+  c_trkpi_res_eta->Print(figPath+"img_trkpi_res_eta.png","png");
+
+  TCanvas *c_trkpi_eff_pt = new TCanvas("","", 800, 600);
+
+  mg_trkpi_eff_pt->Draw("APE");
+  DrawAxis(mg_trkpi_eff_pt, leg_trkpi_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "tracking efficiency (%)", true, false);
+  leg_trkpi_eff_pt->Draw();
+
+  c_trkpi_eff_pt->Print(pdfOutput,"pdf");
+  c_trkpi_eff_pt->Print(figPath+"img_trkpi_eff_pt.pdf","pdf");
+  c_trkpi_eff_pt->Print(figPath+"img_trkpi_eff_pt.png","png");
+
+  TCanvas *c_trkpi_eff_eta = new TCanvas("","", 800, 600);
+
+  mg_trkpi_eff_eta->Draw("APE");
+  DrawAxis(mg_trkpi_eff_eta, leg_trkpi_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "tracking efficiency (%)", false, false);
+  leg_trkpi_eff_eta->Draw();
+
+  c_trkpi_eff_eta->Print(pdfOutput,"pdf");
+  c_trkpi_eff_eta->Print(figPath+"img_trkpi_eff_eta.pdf","pdf");
+  c_trkpi_eff_eta->Print(figPath+"img_trkpi_eff_eta.png","png");
+
+  // --------- Electron Tracks  --------- //
+
+  TMultiGraph *mg_trkele_res_pt  = new TMultiGraph("","");
+  TMultiGraph *mg_trkele_eff_pt  = new TMultiGraph("","");
+  TMultiGraph *mg_trkele_res_eta = new TMultiGraph("","");
+  TMultiGraph *mg_trkele_eff_eta = new TMultiGraph("","");
+
+  TLegend *leg_trkele_res_pt = new TLegend(0.55,0.22,0.90,0.48);
+  TLegend *leg_trkele_eff_pt = (TLegend*)leg_trkele_res_pt->Clone();
+  TLegend *leg_trkele_res_eta = (TLegend*)leg_trkele_res_pt->Clone();
+  TLegend *leg_trkele_eff_eta = (TLegend*)leg_trkele_res_eta->Clone();
+
+  TGraphErrors gr_trkele_res_pt[n_etabins], gr_trkele_eff_pt[n_etabins], gr_trkele_res_eta[n_ptbins], gr_trkele_eff_eta[n_ptbins];
+  TH1D* h_trkele_eff_pt, *h_trkele_eff_eta;
+
+  std::vector<resolPlot> plots_trkele_res_pt[n_etabins], plots_trkele_res_eta[n_ptbins];
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     HistogramsCollection(&plots_trkele_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
+     GetPtres<Track>(&plots_trkele_res_pt[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
+     gr_trkele_res_pt[k] = EresGraph(&plots_trkele_res_pt[k]);
+
+     h_trkele_eff_pt = GetEffPt<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
+     gr_trkele_eff_pt[k] = TGraphErrors(h_trkele_eff_pt);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+     s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+     gr_trkele_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
+     gr_trkele_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
+
+     addResoGraph(mg_trkele_res_pt, &gr_trkele_res_pt[k], leg_trkele_res_pt, markerStyles.at(k), colors.at(k), s_eta);
+     addResoGraph(mg_trkele_eff_pt, &gr_trkele_eff_pt[k], leg_trkele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+  }
+
+  // loop over pt
+  for (k = 0; k < ptVals.size(); k++)
+  {
+     HistogramsCollectionVsEta(&plots_trkele_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkele", 0.0, 2.0);
+     GetPtresVsEta<Track>(&plots_trkele_res_eta[k], branchTrackElectron, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
+     gr_trkele_res_eta[k] = EresGraphVsEta(&plots_trkele_res_eta[k]);
+
+     h_trkele_eff_eta = GetEffEta<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderElectron);
+     gr_trkele_eff_eta[k] = TGraphErrors(h_trkele_eff_eta);
+
+     s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+     addResoGraph(mg_trkele_res_eta, &gr_trkele_res_eta[k], leg_trkele_res_eta, markerStyles.at(k), colors.at(k), s_pt );
+     addResoGraph(mg_trkele_eff_eta, &gr_trkele_eff_eta[k], leg_trkele_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+
+  }
+
+  TCanvas *c_trkele_res_pt = new TCanvas("","", 800, 600);
+
+  mg_trkele_res_pt->Draw("APE");
+  DrawAxis(mg_trkele_res_pt, leg_trkele_res_pt, ptMin, ptMax, 0.01, 100, "p_{T} [GeV]", "(track resolution in p_{T})/p_{T} (%)", true, true);
+  leg_trkele_res_pt->Draw();
+
+  c_trkele_res_pt->Print(pdfOutput,"pdf");
+  c_trkele_res_pt->Print(figPath+"img_trkele_res_pt.pdf","pdf");
+  c_trkele_res_pt->Print(figPath+"img_trkele_res_pt.png","png");
+
+  TCanvas *c_trkele_res_eta = new TCanvas("","", 800, 600);
+
+  mg_trkele_res_eta->Draw("APE");
+  DrawAxis(mg_trkele_res_eta, leg_trkele_res_eta, etaMin, etaMax, 0.01, 100, " #eta ", "(track resolution in p_{T})/p_{T} (%)", false, true);
+  leg_trkele_res_eta->Draw();
+
+  c_trkele_res_eta->Print(pdfOutput,"pdf");
+  c_trkele_res_eta->Print(figPath+"img_trkele_res_eta.pdf","pdf");
+  c_trkele_res_eta->Print(figPath+"img_trkele_res_eta.png","png");
+
+  TCanvas *c_trkele_eff_pt = new TCanvas("","", 800, 600);
+
+  mg_trkele_eff_pt->Draw("APE");
+  DrawAxis(mg_trkele_eff_pt, leg_trkele_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "tracking efficiency (%)", true, false);
+  leg_trkele_eff_pt->Draw();
+
+  c_trkele_eff_pt->Print(pdfOutput,"pdf");
+  c_trkele_eff_pt->Print(figPath+"img_trkele_eff_pt.pdf","pdf");
+  c_trkele_eff_pt->Print(figPath+"img_trkele_eff_pt.png","png");
+
+  TCanvas *c_trkele_eff_eta = new TCanvas("","", 800, 600);
+
+  mg_trkele_eff_eta->Draw("APE");
+  DrawAxis(mg_trkele_eff_eta, leg_trkele_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "tracking efficiency (%)", false, false);
+  leg_trkele_eff_eta->Draw();
+
+  c_trkele_eff_eta->Print(pdfOutput,"pdf");
+  c_trkele_eff_eta->Print(figPath+"img_trkele_eff_eta.pdf","pdf");
+  c_trkele_eff_eta->Print(figPath+"img_trkele_eff_eta.png","png");
+
+
+  // --------- Muon Tracks  --------- //
+
+  TMultiGraph *mg_trkmu_res_pt  = new TMultiGraph("","");
+  TMultiGraph *mg_trkmu_eff_pt  = new TMultiGraph("","");
+  TMultiGraph *mg_trkmu_res_eta = new TMultiGraph("","");
+  TMultiGraph *mg_trkmu_eff_eta = new TMultiGraph("","");
+
+  TLegend *leg_trkmu_res_pt = new TLegend(0.55,0.22,0.90,0.48);
+  TLegend *leg_trkmu_eff_pt = (TLegend*)leg_trkmu_res_pt->Clone();
+
+  TLegend *leg_trkmu_res_eta = (TLegend*)leg_trkmu_res_pt->Clone();
+  TLegend *leg_trkmu_eff_eta = (TLegend*)leg_trkmu_res_eta->Clone();
+
+
+  TGraphErrors gr_trkmu_res_pt[n_etabins], gr_trkmu_eff_pt[n_etabins], gr_trkmu_res_eta[n_ptbins], gr_trkmu_eff_eta[n_ptbins];
+  TH1D* h_trkmu_eff_pt, *h_trkmu_eff_eta;
+
+  std::vector<resolPlot> plots_trkmu_res_pt[n_etabins], plots_trkmu_res_eta[n_ptbins];
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     HistogramsCollection(&plots_trkmu_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkmu");
+     GetPtres<Track>(&plots_trkmu_res_pt[k], branchTrackMuon, branchParticleMuon, 13, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
+     gr_trkmu_res_pt[k] = EresGraph(&plots_trkmu_res_pt[k]);
+
+     h_trkmu_eff_pt = GetEffPt<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
+     gr_trkmu_eff_pt[k] = TGraphErrors(h_trkmu_eff_pt);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+     s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+     gr_trkmu_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
+     gr_trkmu_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
+
+     addResoGraph(mg_trkmu_res_pt, &gr_trkmu_res_pt[k], leg_trkmu_res_pt, markerStyles.at(k), colors.at(k), s_eta);
+     addResoGraph(mg_trkmu_eff_pt, &gr_trkmu_eff_pt[k], leg_trkmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+  }
+
+  // loop over pt
+  for (k = 0; k < ptVals.size(); k++)
+  {
+     HistogramsCollectionVsEta(&plots_trkmu_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkmu", 0.0, 2.0);
+     GetPtresVsEta<Track>(&plots_trkmu_res_eta[k], branchTrackMuon, branchParticleMuon, 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderMuon);
+     gr_trkmu_res_eta[k] = EresGraphVsEta(&plots_trkmu_res_eta[k]);
+
+     h_trkmu_eff_eta = GetEffEta<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderMuon);
+     gr_trkmu_eff_eta[k] = TGraphErrors(h_trkmu_eff_eta);
+
+     s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+     addResoGraph(mg_trkmu_res_eta, &gr_trkmu_res_eta[k], leg_trkmu_res_eta, markerStyles.at(k), colors.at(k), s_pt );
+     addResoGraph(mg_trkmu_eff_eta, &gr_trkmu_eff_eta[k], leg_trkmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+
+  }
+
+  TCanvas *c_trkmu_res_pt = new TCanvas("","", 800, 600);
+
+  mg_trkmu_res_pt->Draw("APE");
+  DrawAxis(mg_trkmu_res_pt, leg_trkmu_res_pt, ptMin, ptMax, 0.01, 100, "p_{T} [GeV]", "(track resolution in p_{T})/p_{T} (%)", true, true);
+  leg_trkmu_res_pt->Draw();
+
+  c_trkmu_res_pt->Print(pdfOutput,"pdf");
+  c_trkmu_res_pt->Print(figPath+"img_trkmu_res_pt.pdf","pdf");
+  c_trkmu_res_pt->Print(figPath+"img_trkmu_res_pt.png","png");
+
+  TCanvas *c_trkmu_res_eta = new TCanvas("","", 800, 600);
+
+  mg_trkmu_res_eta->Draw("APE");
+  DrawAxis(mg_trkmu_res_eta, leg_trkmu_res_eta, etaMin, etaMax, 0.01, 100, " #eta ", "(track resolution in p_{T})/p_{T} (%)", false, true);
+  leg_trkmu_res_eta->Draw();
+
+  c_trkmu_res_eta->Print(pdfOutput,"pdf");
+  c_trkmu_res_eta->Print(figPath+"img_trkmu_res_eta.pdf","pdf");
+  c_trkmu_res_eta->Print(figPath+"img_trkmu_res_eta.png","png");
+
+  TCanvas *c_trkmu_eff_pt = new TCanvas("","", 800, 600);
+
+  mg_trkmu_eff_pt->Draw("APE");
+  DrawAxis(mg_trkmu_eff_pt, leg_trkmu_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "tracking efficiency (%)", true, false);
+  leg_trkmu_eff_pt->Draw();
+
+  c_trkmu_eff_pt->Print(pdfOutput,"pdf");
+  c_trkmu_eff_pt->Print(figPath+"img_trkmu_eff_pt.pdf","pdf");
+  c_trkmu_eff_pt->Print(figPath+"img_trkmu_eff_pt.png","png");
+
+  TCanvas *c_trkmu_eff_eta = new TCanvas("","", 800, 600);
+
+  mg_trkmu_eff_eta->Draw("APE");
+  DrawAxis(mg_trkmu_eff_eta, leg_trkmu_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "tracking efficiency (%)", false, false);
+  leg_trkmu_eff_eta->Draw();
+
+  c_trkmu_eff_eta->Print(pdfOutput,"pdf");
+  c_trkmu_eff_eta->Print(figPath+"img_trkmu_eff_eta.pdf","pdf");
+  c_trkmu_eff_eta->Print(figPath+"img_trkmu_eff_eta.png","png");
+
+
+  //////////////////////
+  // Ecal performance //
+  //////////////////////
+
+
+  TMultiGraph *mg_ecal_res_e  = new TMultiGraph("","");
+  TMultiGraph *mg_ecal_res_eta = new TMultiGraph("","");
+
+  TLegend *leg_ecal_res_e = new TLegend(0.55,0.64,0.90,0.90);
+  TLegend *leg_ecal_res_eta = new TLegend(0.60,0.59,0.95,0.90);
+
+  TGraphErrors gr_ecal_res_e[n_etabins], gr_ecal_res_eta[n_ptbins];
+
+  std::vector<resolPlot> plots_ecal_res_e[n_etabins], plots_ecal_res_eta[n_ptbins];
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     HistogramsCollection(&plots_ecal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "ecal");
+     GetEres<Tower>(&plots_ecal_res_e[k], branchTowerPhoton, branchParticlePhoton, 22, etaVals.at(k), etaVals.at(k+1), treeReaderPhoton);
+     gr_ecal_res_e[k] = EresGraph(&plots_ecal_res_e[k]);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+     s_eta = "#gamma , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+     gr_ecal_res_e[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
+
+     addResoGraph(mg_ecal_res_e, &gr_ecal_res_e[k], leg_ecal_res_e, markerStyles.at(k), colors.at(k), s_eta);
+  }
+
+  // loop over pt
+  for (k = 0; k < ptVals.size(); k++)
+  {
+     HistogramsCollectionVsEta(&plots_ecal_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "ecal", 0.0, 2.0);
+     GetEresVsEta<Tower>(&plots_ecal_res_eta[k], branchTowerPhoton, branchParticlePhoton, 22, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPhoton);
+     gr_ecal_res_eta[k] = EresGraphVsEta(&plots_ecal_res_eta[k]);
+
+     s_e = Form("#gamma , E = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_e = Form("#gamma , E = %.0f TeV",ptVals.at(k)/1000.);
+
+     addResoGraph(mg_ecal_res_eta, &gr_ecal_res_eta[k], leg_ecal_res_eta, markerStyles.at(k), colors.at(k), s_e );
+  }
+
+  TCanvas *c_ecal_res_e = new TCanvas("","", 800, 600);
+
+  mg_ecal_res_e->Draw("APE");
+ // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
+  DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.0, 20, "E [GeV]", "(ECAL resolution in E)/E (%)", true, false);
+  leg_ecal_res_e->Draw();
+
+  c_ecal_res_e->Print(pdfOutput,"pdf");
+  c_ecal_res_e->Print(figPath+"img_ecal_res_e.pdf","pdf");
+  c_ecal_res_e->Print(figPath+"img_ecal_res_e.png","png");
+
+  TCanvas *c_ecal_res_eta = new TCanvas("","", 800, 600);
+
+  mg_ecal_res_eta->Draw("APE");
+  //DrawAxis(mg_ecal_res_eta, leg_ecal_res_eta, etaMin, etaMax, 0.5, 100, " #eta ", "(ECAL resolution in E)/E (%)", false, true);
+  DrawAxis(mg_ecal_res_eta, leg_ecal_res_eta, etaMin, etaMax, 0.0, 20, " #eta ", "(ECAL resolution in E)/E (%)", false, false);
+  leg_ecal_res_eta->Draw();
+
+  c_ecal_res_eta->Print(pdfOutput,"pdf");
+  c_ecal_res_eta->Print(figPath+"img_ecal_res_eta.pdf","pdf");
+  c_ecal_res_eta->Print(figPath+"img_ecal_res_eta.png","png");
+
+  //////////////////////
+  // Hcal performance //
+  //////////////////////
+
+
+  TMultiGraph *mg_hcal_res_e  = new TMultiGraph("","");
+  TMultiGraph *mg_hcal_res_eta = new TMultiGraph("","");
+
+  TLegend *leg_hcal_res_e = new TLegend(0.55,0.64,0.90,0.90);
+  TLegend *leg_hcal_res_eta = new TLegend(0.60,0.59,0.95,0.90);
+
+  TGraphErrors gr_hcal_res_e[n_etabins], gr_hcal_res_eta[n_ptbins];
+
+  std::vector<resolPlot> plots_hcal_res_e[n_etabins], plots_hcal_res_eta[n_ptbins];
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     HistogramsCollection(&plots_hcal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "hcal");
+     GetEres<Tower>(&plots_hcal_res_e[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, etaVals.at(k), etaVals.at(k+1), treeReaderNeutralHadron);
+
+     gr_hcal_res_e[k] = EresGraph(&plots_hcal_res_e[k]);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+     s_eta = "n , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+     gr_hcal_res_e[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
+
+     addResoGraph(mg_hcal_res_e, &gr_hcal_res_e[k], leg_hcal_res_e, markerStyles.at(k), colors.at(k), s_eta);
+  }
+
+  // loop over pt
+  for (k = 0; k < ptVals.size(); k++)
+  {
+     HistogramsCollectionVsEta(&plots_hcal_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "hcal", 0.0, 2.0);
+     GetEresVsEta<Tower>(&plots_hcal_res_eta[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderNeutralHadron);
+     gr_hcal_res_eta[k] = EresGraphVsEta(&plots_hcal_res_eta[k]);
+
+     s_e = Form("n , E = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_e = Form("n , E = %.0f TeV",ptVals.at(k)/1000.);
+
+     addResoGraph(mg_hcal_res_eta, &gr_hcal_res_eta[k], leg_hcal_res_eta, markerStyles.at(k), colors.at(k), s_e );
+  }
+
+
+  TCanvas *c_hcal_res_e = new TCanvas("","", 800, 600);
+
+  mg_hcal_res_e->Draw("APE");
+  //DrawAxis(mg_hcal_res_e, leg_hcal_res_e, ptMin, ptMax, 1, 100, "E [GeV]", "(HCAL resolution in E)/E (%)", true, true);
+  DrawAxis(mg_hcal_res_e, leg_hcal_res_e, ptMin, ptMax, 0.0, 50, "E [GeV]", "(HCAL resolution in E)/E (%)", true, false);
+  leg_hcal_res_e->Draw();
+
+  c_hcal_res_e->Print(pdfOutput,"pdf");
+  c_hcal_res_e->Print(figPath+"img_hcal_res_e.pdf","pdf");
+  c_hcal_res_e->Print(figPath+"img_hcal_res_e.png","png");
+
+  TCanvas *c_hcal_res_eta = new TCanvas("","", 800, 600);
+
+  mg_hcal_res_eta->Draw("APE");
+  //DrawAxis(mg_hcal_res_eta, leg_hcal_res_eta, etaMin, etaMax, 1, 100, " #eta ", "(HCAL resolution in E)/E (%)", false, true);
+  DrawAxis(mg_hcal_res_eta, leg_hcal_res_eta, etaMin, etaMax, 0.0, 50, " #eta ", "(HCAL resolution in E)/E (%)", false, false);
+  leg_hcal_res_eta->Draw();
+
+  c_hcal_res_eta->Print(pdfOutput,"pdf");
+  c_hcal_res_eta->Print(figPath+"img_hcal_res_eta.pdf","pdf");
+  c_hcal_res_eta->Print(figPath+"img_hcal_res_eta.png","png");
+
+  ////////////////////
+  // PF - electrons //
+  ////////////////////
+
+  TMultiGraph *mg_pfele_res_e[n_etabins];
+  TMultiGraph *mg_pfele_res_eta[n_ptbins];
+
+  TLegend *leg_pfele_res_e[n_etabins];
+  TLegend *leg_pfele_res_eta[n_ptbins];
+
+  TGraphErrors gr_pfele_res_e[n_etabins];
+  TGraphErrors gr_pfele_res_eta[n_ptbins];
+
+  std::vector<resolPlot> plots_pfele_res_e[n_etabins], plots_pfele_res_eta[n_ptbins];
+
+  TCanvas *c_pfele_res_e[n_etabins];
+  TCanvas *c_pfele_res_eta[n_ptbins];
+
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     mg_pfele_res_e[k] = new TMultiGraph("","");
+     leg_pfele_res_e[k] = new TLegend(0.40,0.60,0.75,0.90);
+
+     HistogramsCollection(&plots_pfele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfele");
+     GetEres<Electron>(&plots_pfele_res_e[k], branchElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
+     gr_pfele_res_e[k] = EresGraph(&plots_pfele_res_e[k]);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+     s_eta    = "e^{ #pm}, "+ s_etaMin + " < | #eta | < " + s_etaMax;
+
+     leg_pfele_res_e[k]->SetTextFont(132);
+     leg_pfele_res_e[k]->SetHeader(s_eta);
+
+     addResoGraph(mg_pfele_res_e[k], &gr_ecal_res_e[k], leg_pfele_res_e[k], markerStyles.at(0), colors.at(0), "ecal");
+     addResoGraph(mg_pfele_res_e[k], &gr_trkele_res_pt[k], leg_pfele_res_e[k], markerStyles.at(1), colors.at(1), "track");
+     addResoGraph(mg_pfele_res_e[k], &gr_pfele_res_e[k], leg_pfele_res_e[k], markerStyles.at(2), colors.at(2), "p-flow");
+
+     c_pfele_res_e[k] = new TCanvas("","", 800, 600);
+
+     mg_pfele_res_e[k]->Draw("APE");
+     //DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
+     DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.0, 20, "E [GeV]", "(resolution in E)/E (%)", true, false);
+     leg_pfele_res_e[k]->Draw();
+
+     TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
+
+     c_pfele_res_e[k]->Print(pdfOutput,"pdf");
+     c_pfele_res_e[k]->Print(figPath+"img_pfele_res_"+s_etarange+"e.pdf","pdf");
+     c_pfele_res_e[k]->Print(figPath+"img_pfele_res_"+s_etarange+"e.png","png");
+
+  }
+
+
+    // loop over eta bins
+  for (k = 0; k < ptVals.size(); k++)
+  {
+
+     mg_pfele_res_eta[k] = new TMultiGraph("","");
+     leg_pfele_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
+
+     HistogramsCollectionVsEta(&plots_pfele_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfele", 0.0, 2.0);
+     GetEresVsEta<Electron>(&plots_pfele_res_eta[k], branchElectron, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
+     gr_pfele_res_eta[k] = EresGraphVsEta(&plots_pfele_res_eta[k]);
+
+     s_e = Form("e^{ #pm}, E = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_e = Form("e^{ #pm}, E = %.0f TeV",ptVals.at(k)/1000.);
+
+
+     leg_pfele_res_eta[k]->SetTextFont(132);
+     leg_pfele_res_eta[k]->SetHeader(s_e);
+
+     addResoGraph(mg_pfele_res_eta[k], &gr_ecal_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(0), colors.at(0), "ecal");
+     addResoGraph(mg_pfele_res_eta[k], &gr_trkele_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(1), colors.at(1), "track");
+     addResoGraph(mg_pfele_res_eta[k], &gr_pfele_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(2), colors.at(2), "p-flow");
+
+     c_pfele_res_eta[k] = new TCanvas("","", 800, 600);
+
+     mg_pfele_res_eta[k]->Draw("APE");
+     //DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
+     DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
+     leg_pfele_res_eta[k]->Draw();
+
+     TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
+
+     c_pfele_res_eta[k]->Print(pdfOutput,"pdf");
+     c_pfele_res_eta[k]->Print(figPath+"img_pfele_res_"+s_ptrange+"eta.pdf","pdf");
+     c_pfele_res_eta[k]->Print(figPath+"img_pfele_res_"+s_ptrange+"eta.png","png");
+
+  }
+
+  /////////////////
+  // PF - Pions  //
+  /////////////////
+
+  TMultiGraph *mg_pfpi_res_e[n_etabins];
+  TMultiGraph *mg_pfpi_res_eta[n_ptbins];
+
+  TLegend *leg_pfpi_res_e[n_etabins];
+  TLegend *leg_pfpi_res_eta[n_ptbins];
+
+  TGraphErrors gr_pfpi_res_e[n_etabins];
+  TGraphErrors gr_pfpi_res_eta[n_ptbins];
+
+  std::vector<resolPlot> plots_pfpi_res_e[n_etabins], plots_pfpi_res_eta[n_ptbins];
+
+  TCanvas *c_pfpi_res_e[n_etabins];
+  TCanvas *c_pfpi_res_eta[n_ptbins];
+
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+     mg_pfpi_res_e[k] = new TMultiGraph("","");
+     leg_pfpi_res_e[k] = new TLegend(0.40,0.60,0.75,0.90);
+
+     HistogramsCollection(&plots_pfpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfpi");
+     GetEres<Track>(&plots_pfpi_res_e[k], branchPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
+     gr_pfpi_res_e[k] = EresGraph(&plots_pfpi_res_e[k]);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+     s_eta    = "#pi^{ #pm}, "+ s_etaMin + " < | #eta | < " + s_etaMax;
+
+     leg_pfpi_res_e[k]->SetTextFont(132);
+     leg_pfpi_res_e[k]->SetHeader(s_eta);
+
+     addResoGraph(mg_pfpi_res_e[k], &gr_hcal_res_e[k], leg_pfpi_res_e[k], markerStyles.at(0), colors.at(0), "hcal");
+     addResoGraph(mg_pfpi_res_e[k], &gr_trkpi_res_pt[k], leg_pfpi_res_e[k], markerStyles.at(1), colors.at(1), "track");
+     addResoGraph(mg_pfpi_res_e[k], &gr_pfpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(2), colors.at(2), "p-flow");
+
+     c_pfpi_res_e[k] = new TCanvas("","", 800, 600);
+
+     mg_pfpi_res_e[k]->Draw("APE");
+     //DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
+     DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 50, "E [GeV]", "(resolution in E)/E (%)", true, false);
+     leg_pfpi_res_e[k]->Draw();
+
+     TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
+
+     c_pfpi_res_e[k]->Print(pdfOutput,"pdf");
+     c_pfpi_res_e[k]->Print(figPath+"img_pfpi_res_"+s_etarange+"e.pdf","pdf");
+     c_pfpi_res_e[k]->Print(figPath+"img_pfpi_res_"+s_etarange+"e.png","png");
+
+  }
+
+
+    // loop over eta bins
+  for (k = 0; k < ptVals.size(); k++)
+  {
+
+     mg_pfpi_res_eta[k] = new TMultiGraph("","");
+     leg_pfpi_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
+
+     HistogramsCollectionVsEta(&plots_pfpi_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfpi", 0.0, 2.0);
+     GetEresVsEta<Track>(&plots_pfpi_res_eta[k], branchPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
+     gr_pfpi_res_eta[k] = EresGraphVsEta(&plots_pfpi_res_eta[k]);
+
+     s_e = Form("#pi^{ #pm}, E = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_e = Form("#pi^{ #pm}, E = %.0f TeV",ptVals.at(k)/1000.);
+
+     leg_pfpi_res_eta[k]->SetTextFont(132);
+     leg_pfpi_res_eta[k]->SetHeader(s_e);
+
+     addResoGraph(mg_pfpi_res_eta[k], &gr_hcal_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(0), colors.at(0), "hcal");
+     addResoGraph(mg_pfpi_res_eta[k], &gr_trkpi_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(1), colors.at(1), "track");
+     addResoGraph(mg_pfpi_res_eta[k], &gr_pfpi_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(2), colors.at(2), "p-flow");
+
+     c_pfpi_res_eta[k] = new TCanvas("","", 800, 600);
+
+     mg_pfpi_res_eta[k]->Draw("APE");
+     //DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
+     DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
+     leg_pfpi_res_eta[k]->Draw();
+
+     TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
+
+     c_pfpi_res_eta[k]->Print(pdfOutput,"pdf");
+     c_pfpi_res_eta[k]->Print(figPath+"img_pfpi_res_"+s_ptrange+"eta.pdf","pdf");
+     c_pfpi_res_eta[k]->Print(figPath+"img_pfpi_res_"+s_ptrange+"eta.png","png");
+
+  }
+
+
+  /////////////////
+  // PF - jets   //
+  /////////////////
+
+  TMultiGraph *mg_pfjet_res_e[n_etabins];
+  TMultiGraph *mg_pfjet_res_eta[n_ptbins];
+
+  TLegend *leg_pfjet_res_e[n_etabins];
+  TLegend *leg_pfjet_res_eta[n_ptbins];
+
+  TGraphErrors gr_pfjet_res_e[n_etabins];
+  TGraphErrors gr_pfjet_res_eta[n_ptbins];
+
+  TGraphErrors gr_cajet_res_e[n_etabins];
+  TGraphErrors gr_cajet_res_eta[n_ptbins];
+
+  std::vector<resolPlot> plots_pfjet_res_e[n_etabins], plots_pfjet_res_eta[n_ptbins];
+  std::vector<resolPlot> plots_cajet_res_e[n_etabins], plots_cajet_res_eta[n_ptbins];
+
+  TCanvas *c_pfjet_res_e[n_etabins];
+  TCanvas *c_pfjet_res_eta[n_ptbins];
+
+
+  // loop over eta bins
+  for (k = 0; k < etaVals.size()-1; k++)
+  {
+
+     mg_pfjet_res_e[k] = new TMultiGraph("","");
+     leg_pfjet_res_e[k] = new TLegend(0.60,0.60,0.90,0.90);
+
+     HistogramsCollection(&plots_pfjet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfjet");
+     HistogramsCollection(&plots_cajet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "cajet");
+
+     GetJetsEres(&plots_pfjet_res_e[k], branchPFJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k+1));
+     GetJetsEres(&plots_cajet_res_e[k], branchCaloJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k+1));
+
+     gr_pfjet_res_e[k] = EresGraph(&plots_pfjet_res_e[k]);
+     gr_cajet_res_e[k] = EresGraph(&plots_cajet_res_e[k]);
+
+     s_etaMin = Form("%.1f",etaVals.at(k));
+     s_etaMax = Form("%.1f",etaVals.at(k+1));
+     s_eta    = "jets, "+ s_etaMin + " < | #eta | < " + s_etaMax;
+
+     leg_pfjet_res_e[k]->SetTextFont(132);
+     leg_pfjet_res_e[k]->SetHeader(s_eta);
+
+     addResoGraph(mg_pfjet_res_e[k], &gr_cajet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(0), colors.at(0), "calo");
+     addResoGraph(mg_pfjet_res_e[k], &gr_pfjet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(1), colors.at(1), "p-flow");
+
+     c_pfjet_res_e[k] = new TCanvas("","", 800, 600);
+
+     mg_pfjet_res_e[k]->Draw("APE");
+     //DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.5, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
+     DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.0, 30, "E [GeV]", "(resolution in E)/E (%)", true, false);
+     leg_pfjet_res_e[k]->Draw();
+
+     TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
+
+     c_pfjet_res_e[k]->Print(pdfOutput,"pdf");
+     c_pfjet_res_e[k]->Print(figPath+"img_pfjet_res_"+s_etarange+"e.pdf","pdf");
+     c_pfjet_res_e[k]->Print(figPath+"img_pfjet_res_"+s_etarange+"e.png","png");
+
+  }
+
+
+    // loop over eta bins
+  for (k = 0; k < ptVals.size(); k++)
+  {
+
+     mg_pfjet_res_eta[k] = new TMultiGraph("","");
+     leg_pfjet_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
+
+     HistogramsCollectionVsEta(&plots_pfjet_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfjet", 0.0, 2.0);
+     HistogramsCollectionVsEta(&plots_cajet_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "cajet", 0.0, 2.0);
+
+     GetJetsEresVsEta(&plots_pfjet_res_eta[k], branchPFJet, branchGenJet, treeReaderJet, 0.5*ptVals.at(k), 2.0*ptVals.at(k));
+     GetJetsEresVsEta(&plots_cajet_res_eta[k], branchCaloJet, branchGenJet, treeReaderJet, 0.5*ptVals.at(k), 2.0*ptVals.at(k));
+
+     gr_pfjet_res_eta[k] = EresGraphVsEta(&plots_pfjet_res_eta[k]);
+     gr_cajet_res_eta[k] = EresGraphVsEta(&plots_cajet_res_eta[k]);
+
+     s_e = Form("jets, E = %.0f GeV",ptVals.at(k));
+     if(ptVals.at(k) >= 1000.) s_e = Form("jets, E = %.0f TeV",ptVals.at(k)/1000.);
+
+     leg_pfjet_res_eta[k]->SetTextFont(132);
+     leg_pfjet_res_eta[k]->SetHeader(s_e);
+
+     addResoGraph(mg_pfjet_res_eta[k], &gr_cajet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(0), colors.at(0), "calo");
+     addResoGraph(mg_pfjet_res_eta[k], &gr_pfjet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(1), colors.at(1), "p-flow");
+
+     c_pfjet_res_eta[k] = new TCanvas("","", 800, 600);
+
+     mg_pfjet_res_eta[k]->Draw("APE");
+     //DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
+     DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
+     leg_pfjet_res_eta[k]->Draw();
+
+     TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
+
+     c_pfjet_res_eta[k]->Print(pdfOutput,"pdf");
+     c_pfjet_res_eta[k]->Print(figPath+"img_pfjet_res_"+s_ptrange+"eta.pdf","pdf");
+     c_pfjet_res_eta[k]->Print(figPath+"img_pfjet_res_"+s_ptrange+"eta.png","png");
+
+  }
+
+
+    /////////////////////
+    // PF Missing ET  ///
+    /////////////////////
+
+    TMultiGraph *mg_met_res_ht = new TMultiGraph("","");
+    TLegend *leg_met_res_ht    = new TLegend(0.60,0.22,0.90,0.42);
+
+    std::vector<resolPlot> plots_pfmet, plots_camet;
+
+    HistogramsCollection(&plots_pfmet, TMath::Log10(ptMin), TMath::Log10(ptMax), "pfMET", -500, 500);
+    HistogramsCollection(&plots_camet, TMath::Log10(ptMin), TMath::Log10(ptMax), "caMET", -500, 500);
+
+    GetMetres(&plots_pfmet, branchGenScalarHT, branchMet, branchPFJet, treeReaderJet);
+    GetMetres(&plots_camet, branchGenScalarHT, branchCaloMet, branchCaloJet, treeReaderJet);
+
+    TGraphErrors gr_pfmet_res_ht = MetResGraph(&plots_pfmet, true);
+    TGraphErrors gr_camet_res_ht = MetResGraph(&plots_camet, true);
+
+    addResoGraph(mg_met_res_ht, &gr_camet_res_ht, leg_met_res_ht, markerStyles.at(0), colors.at(0), "calo");
+    addResoGraph(mg_met_res_ht, &gr_pfmet_res_ht, leg_met_res_ht, markerStyles.at(1), colors.at(1), "p-flow");
+
+    TCanvas *c_met_res_ht = new TCanvas("","", 800, 600);
+
+    mg_met_res_ht->Draw("APE");
+    DrawAxis(mg_met_res_ht, leg_met_res_ht, 10, 10000, 0.1, 1000, " #sum p_{T} [GeV]", "resolution in E_{x,y} [GeV]", true, true);
+
+    leg_met_res_ht->Draw();
+
+    c_met_res_ht->Print(pdfOutput,"pdf");
+    c_met_res_ht->Print(figPath+"img_met_res_ht.pdf","pdf");
+    c_met_res_ht->Print(figPath+"img_met_res_ht.png","png");
+
+
+    /////////////////////////////////////////
+    // Electron Reconstruction Efficiency ///
+    /////////////////////////////////////////
+
+    TMultiGraph *mg_recele_eff_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_recele_eff_eta = new TMultiGraph("","");
+
+    TLegend *leg_recele_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
+    TLegend *leg_recele_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
+
+    TGraphErrors gr_recele_eff_pt[n_etabins], gr_recele_eff_eta[n_ptbins];
+    TH1D* h_recele_eff_pt, *h_recele_eff_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_recele_eff_pt = GetEffPt<Electron>(branchElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
+       gr_recele_eff_pt[k] = TGraphErrors(h_recele_eff_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_recele_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_recele_eff_pt, &gr_recele_eff_pt[k], leg_recele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_recele_eff_eta = GetEffEta<Electron>(branchElectron, branchParticleElectron, "Electron", 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderElectron);
+       gr_recele_eff_eta[k] = TGraphErrors(h_recele_eff_eta);
+
+       s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_recele_eff_eta, &gr_recele_eff_eta[k], leg_recele_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_recele_eff_pt = new TCanvas("","", 800, 600);
+
+    mg_recele_eff_pt->Draw("APE");
+    DrawAxis(mg_recele_eff_pt, leg_recele_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
+    leg_recele_eff_pt->Draw();
+
+    c_recele_eff_pt->Print(pdfOutput,"pdf");
+    c_recele_eff_pt->Print(figPath+"img_recele_eff_pt.pdf","pdf");
+    c_recele_eff_pt->Print(figPath+"img_recele_eff_pt.png","png");
+
+    TCanvas *c_recele_eff_eta = new TCanvas("","", 800, 600);
+
+    mg_recele_eff_eta->Draw("APE");
+    DrawAxis(mg_recele_eff_eta, leg_recele_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
+    leg_recele_eff_eta->Draw();
+
+    c_recele_eff_eta->Print(pdfOutput,"pdf");
+    c_recele_eff_eta->Print(figPath+"img_recele_eff_eta.pdf","pdf");
+    c_recele_eff_eta->Print(figPath+"img_recele_eff_eta.png","png");
+
+
+    /////////////////////////////////////////
+    // Muon Reconstruction Efficiency ///
+    /////////////////////////////////////////
+
+    TMultiGraph *mg_recmu_eff_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_recmu_eff_eta = new TMultiGraph("","");
+
+    TLegend *leg_recmu_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
+    TLegend *leg_recmu_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
+
+    TGraphErrors gr_recmu_eff_pt[n_etabins], gr_recmu_eff_eta[n_ptbins];
+    TH1D* h_recmu_eff_pt, *h_recmu_eff_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_recmu_eff_pt = GetEffPt<Muon>(branchMuon, branchParticleMuon, "muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
+       gr_recmu_eff_pt[k] = TGraphErrors(h_recmu_eff_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_recmu_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_recmu_eff_pt, &gr_recmu_eff_pt[k], leg_recmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_recmu_eff_eta = GetEffEta<Muon>(branchMuon, branchParticleMuon, "muon", 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderMuon);
+       gr_recmu_eff_eta[k] = TGraphErrors(h_recmu_eff_eta);
+
+       s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_recmu_eff_eta, &gr_recmu_eff_eta[k], leg_recmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_recmu_eff_pt = new TCanvas("","", 800, 600);
+
+    mg_recmu_eff_pt->Draw("APE");
+    DrawAxis(mg_recmu_eff_pt, leg_recmu_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
+    leg_recmu_eff_pt->Draw();
+
+    c_recmu_eff_pt->Print(pdfOutput,"pdf");
+    c_recmu_eff_pt->Print(figPath+"img_recmu_eff_pt.pdf","pdf");
+    c_recmu_eff_pt->Print(figPath+"img_recmu_eff_pt.png","png");
+
+    TCanvas *c_recmu_eff_eta = new TCanvas("","", 800, 600);
+
+    mg_recmu_eff_eta->Draw("APE");
+    DrawAxis(mg_recmu_eff_eta, leg_recmu_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
+    leg_recmu_eff_eta->Draw();
+
+    c_recmu_eff_eta->Print(pdfOutput,"pdf");
+    c_recmu_eff_eta->Print(figPath+"img_recmu_eff_eta.pdf","pdf");
+    c_recmu_eff_eta->Print(figPath+"img_recmu_eff_eta.png","png");
+
+
+    /////////////////////////////////////////
+    // Photon Reconstruction Efficiency   ///
+    /////////////////////////////////////////
+
+    TMultiGraph *mg_recpho_eff_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_recpho_eff_eta = new TMultiGraph("","");
+
+    TLegend *leg_recpho_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
+    TLegend *leg_recpho_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
+
+    TGraphErrors gr_recpho_eff_pt[n_etabins], gr_recpho_eff_eta[n_ptbins];
+    TH1D* h_recpho_eff_pt, *h_recpho_eff_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_recpho_eff_pt = GetEffPt<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderPhoton);
+       gr_recpho_eff_pt[k] = TGraphErrors(h_recpho_eff_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "#gamma , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_recpho_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_recpho_eff_pt, &gr_recpho_eff_pt[k], leg_recpho_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_recpho_eff_eta = GetEffEta<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderPhoton);
+       gr_recpho_eff_eta[k] = TGraphErrors(h_recpho_eff_eta);
+
+       s_pt = Form("#gamma , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("#gamma , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_recpho_eff_eta, &gr_recpho_eff_eta[k], leg_recpho_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_recpho_eff_pt = new TCanvas("","", 800, 600);
+
+    mg_recpho_eff_pt->Draw("APE");
+    DrawAxis(mg_recpho_eff_pt, leg_recpho_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
+    leg_recpho_eff_pt->Draw();
+
+    c_recpho_eff_pt->Print(pdfOutput,"pdf");
+    c_recpho_eff_pt->Print(figPath+"img_recpho_eff_pt.pdf","pdf");
+    c_recpho_eff_pt->Print(figPath+"img_recpho_eff_pt.png","png");
+
+    TCanvas *c_recpho_eff_eta = new TCanvas("","", 800, 600);
+
+    mg_recpho_eff_eta->Draw("APE");
+    DrawAxis(mg_recpho_eff_eta, leg_recpho_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
+    leg_recpho_eff_eta->Draw();
+
+    c_recpho_eff_eta->Print(pdfOutput,"pdf");
+    c_recpho_eff_eta->Print(figPath+"img_recpho_eff_eta.pdf","pdf");
+    c_recpho_eff_eta->Print(figPath+"img_recpho_eff_eta.png","png");
+
+    /////////////////////////////////////////
+    // B-jets  Efficiency/ mistag rates   ///
+    /////////////////////////////////////////
+
+    TMultiGraph *mg_recbjet_eff_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_recbjet_eff_eta = new TMultiGraph("","");
+
+    TLegend *leg_recbjet_eff_pt  = new TLegend(0.50,0.22,0.90,0.48);
+    TLegend *leg_recbjet_eff_eta = new TLegend(0.50,0.22,0.90,0.48);
+
+    TGraphErrors gr_recbjet_eff_pt[n_etabins], gr_recbjet_eff_eta[n_ptbins];
+    TH1D* h_recbjet_eff_pt, *h_recbjet_eff_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_recbjet_eff_pt = GetEffPt<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
+       gr_recbjet_eff_pt[k] = TGraphErrors(h_recbjet_eff_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "b-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_recbjet_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_recbjet_eff_pt, &gr_recbjet_eff_pt[k], leg_recbjet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_recbjet_eff_eta = GetEffEta<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
+       gr_recbjet_eff_eta[k] = TGraphErrors(h_recbjet_eff_eta);
+
+       s_pt = Form("b-jet , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("b-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_recbjet_eff_eta, &gr_recbjet_eff_eta[k], leg_recbjet_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_recbjet_eff_pt = new TCanvas("","", 800, 600);
+
+    mg_recbjet_eff_pt->Draw("APE");
+    DrawAxis(mg_recbjet_eff_pt, leg_recbjet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "b - tag efficiency (%)", true, false);
+    leg_recbjet_eff_pt->Draw();
+
+    c_recbjet_eff_pt->Print(pdfOutput,"pdf");
+    c_recbjet_eff_pt->Print(figPath+"img_recbjet_eff_pt.pdf","pdf");
+    c_recbjet_eff_pt->Print(figPath+"img_recbjet_eff_pt.png","png");
+
+    TCanvas *c_recbjet_eff_eta = new TCanvas("","", 800, 600);
+
+    mg_recbjet_eff_eta->Draw("APE");
+    DrawAxis(mg_recbjet_eff_eta, leg_recbjet_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "b - tag efficiency (%)", false, false);
+    leg_recbjet_eff_eta->Draw();
+
+    c_recbjet_eff_eta->Print(pdfOutput,"pdf");
+    c_recbjet_eff_eta->Print(figPath+"img_recbjet_eff_eta.pdf","pdf");
+    c_recbjet_eff_eta->Print(figPath+"img_recbjet_eff_eta.png","png");
+
+
+
+    // ------ c - mistag  ------
+
+    TMultiGraph *mg_recbjet_cmis_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_recbjet_cmis_eta = new TMultiGraph("","");
+
+    TLegend *leg_recbjet_cmis_pt  = new TLegend(0.50,0.64,0.90,0.90);
+    TLegend *leg_recbjet_cmis_eta = new TLegend(0.50,0.64,0.90,0.90);
+
+    TGraphErrors gr_recbjet_cmis_pt[n_etabins], gr_recbjet_cmis_eta[n_ptbins];
+    TH1D* h_recbjet_cmis_pt, *h_recbjet_cmis_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_recbjet_cmis_pt = GetEffPt<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
+       gr_recbjet_cmis_pt[k] = TGraphErrors(h_recbjet_cmis_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "c-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_recbjet_cmis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_recbjet_cmis_pt, &gr_recbjet_cmis_pt[k], leg_recbjet_cmis_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_recbjet_cmis_eta = GetEffEta<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
+       gr_recbjet_cmis_eta[k] = TGraphErrors(h_recbjet_cmis_eta);
+
+       s_pt = Form("c-jet , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("c-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_recbjet_cmis_eta, &gr_recbjet_cmis_eta[k], leg_recbjet_cmis_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_recbjet_cmis_pt = new TCanvas("","", 800, 600);
+
+    mg_recbjet_cmis_pt->Draw("APE");
+    DrawAxis(mg_recbjet_cmis_pt, leg_recbjet_cmis_pt, ptMin, ptMax, 0.0, 20, "p_{T} [GeV]", "c - mistag rate (%)", true, false);
+    leg_recbjet_cmis_pt->Draw();
+
+    c_recbjet_cmis_pt->Print(pdfOutput,"pdf");
+    c_recbjet_cmis_pt->Print(figPath+"img_recbjet_cmis_pt.pdf","pdf");
+    c_recbjet_cmis_pt->Print(figPath+"img_recbjet_cmis_pt.png","png");
+
+    TCanvas *c_recbjet_cmis_eta = new TCanvas("","", 800, 600);
+
+    mg_recbjet_cmis_eta->Draw("APE");
+    DrawAxis(mg_recbjet_cmis_eta, leg_recbjet_cmis_eta, etaMin, etaMax, 0.0, 20, " #eta ", "c - mistag rate (%)", false, false);
+    leg_recbjet_cmis_eta->Draw();
+
+    c_recbjet_cmis_eta->Print(pdfOutput,"pdf");
+    c_recbjet_cmis_eta->Print(figPath+"img_recbjet_cmis_eta.pdf","pdf");
+    c_recbjet_cmis_eta->Print(figPath+"img_recbjet_cmis_eta.png","png");
+
+    // ------ light - mistag  ------
+
+    TMultiGraph *mg_recbjet_lmis_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_recbjet_lmis_eta = new TMultiGraph("","");
+
+    TLegend *leg_recbjet_lmis_pt  = new TLegend(0.50,0.64,0.90,0.90);
+    TLegend *leg_recbjet_lmis_eta = new TLegend(0.50,0.64,0.90,0.90);
+
+    TGraphErrors gr_recbjet_lmis_pt[n_etabins], gr_recbjet_lmis_eta[n_ptbins];
+    TH1D* h_recbjet_lmis_pt, *h_recbjet_lmis_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_recbjet_lmis_pt = GetEffPt<Jet>(branchPFJet, branchParticleJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
+       gr_recbjet_lmis_pt[k] = TGraphErrors(h_recbjet_lmis_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "uds-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_recbjet_lmis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_recbjet_lmis_pt, &gr_recbjet_lmis_pt[k], leg_recbjet_lmis_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_recbjet_lmis_eta = GetEffEta<Jet>(branchPFJet, branchParticleJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
+       gr_recbjet_lmis_eta[k] = TGraphErrors(h_recbjet_lmis_eta);
+
+       s_pt = Form("uds-jet , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_recbjet_lmis_eta, &gr_recbjet_lmis_eta[k], leg_recbjet_lmis_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_recbjet_lmis_pt = new TCanvas("","", 800, 600);
+
+    mg_recbjet_lmis_pt->Draw("APE");
+    DrawAxis(mg_recbjet_lmis_pt, leg_recbjet_lmis_pt, ptMin, ptMax, 0.0, 0.1, "p_{T} [GeV]", "light - mistag rate (%)", true, false);
+    leg_recbjet_lmis_pt->Draw();
+
+    c_recbjet_lmis_pt->Print(pdfOutput,"pdf");
+    c_recbjet_lmis_pt->Print(figPath+"img_recbjet_lmis_pt.pdf","pdf");
+    c_recbjet_lmis_pt->Print(figPath+"img_recbjet_lmis_pt.png","png");
+
+    TCanvas *c_recbjet_lmis_eta = new TCanvas("","", 800, 600);
+
+    mg_recbjet_lmis_eta->Draw("APE");
+    DrawAxis(mg_recbjet_lmis_eta, leg_recbjet_lmis_eta, etaMin, etaMax, 0.0, 0.1, " #eta ", "light - mistag rate (%)", false, false);
+    leg_recbjet_lmis_eta->Draw();
+
+    c_recbjet_lmis_eta->Print(pdfOutput,"pdf");
+    c_recbjet_lmis_eta->Print(figPath+"img_recbjet_lmis_eta.pdf","pdf");
+    c_recbjet_lmis_eta->Print(figPath+"img_recbjet_lmis_eta.png","png");
+
+
+    ///////////////////////////////////////////
+    // tau-jets  Efficiency/ mistag rates   ///
+    ///////////////////////////////////////////
+
+    TMultiGraph *mg_rectaujet_eff_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_rectaujet_eff_eta = new TMultiGraph("","");
+
+    TLegend *leg_rectaujet_eff_pt  = new TLegend(0.50,0.22,0.90,0.48);
+    TLegend *leg_rectaujet_eff_eta = new TLegend(0.50,0.22,0.90,0.48);
+
+    TGraphErrors gr_rectaujet_eff_pt[n_etabins], gr_rectaujet_eff_eta[n_ptbins];
+    TH1D* h_rectaujet_eff_pt, *h_rectaujet_eff_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_rectaujet_eff_pt = GetTauEffPt<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderTauJet);
+       gr_rectaujet_eff_pt[k] = TGraphErrors(h_rectaujet_eff_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "#tau-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_rectaujet_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_rectaujet_eff_pt, &gr_rectaujet_eff_pt[k], leg_rectaujet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_rectaujet_eff_eta = GetTauEffEta<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderTauJet);
+       gr_rectaujet_eff_eta[k] = TGraphErrors(h_rectaujet_eff_eta);
+
+       s_pt = Form("#tau-jet , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("#tau-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_rectaujet_eff_eta, &gr_rectaujet_eff_eta[k], leg_rectaujet_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+
+    TCanvas *c_rectaujet_eff_pt = new TCanvas("","", 800, 600);
+
+    mg_rectaujet_eff_pt->Draw("APE");
+    DrawAxis(mg_rectaujet_eff_pt, leg_rectaujet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "#tau - tag efficiency (%)", true, false);
+    leg_rectaujet_eff_pt->Draw();
+
+    c_rectaujet_eff_pt->Print(pdfOutput,"pdf");
+    c_rectaujet_eff_pt->Print(figPath+"img_rectaujet_eff_pt.pdf","pdf");
+    c_rectaujet_eff_pt->Print(figPath+"img_rectaujet_eff_pt.png","png");
+
+    TCanvas *c_rectaujet_eff_eta = new TCanvas("","", 800, 600);
+
+    mg_rectaujet_eff_eta->Draw("APE");
+    DrawAxis(mg_rectaujet_eff_eta, leg_rectaujet_eff_eta, etaMin, etaMax, 0.0000001, 100, " #eta ", "#tau - tag efficiency (%)", false, true);
+    leg_rectaujet_eff_eta->Draw();
+
+    c_rectaujet_eff_eta->Print(pdfOutput,"pdf");
+    c_rectaujet_eff_eta->Print(figPath+"img_rectaujet_eff_eta.pdf","pdf");
+    c_rectaujet_eff_eta->Print(figPath+"img_rectaujet_eff_eta.png","png");
+
+
+    //--------------- tau mistag rate ----------
+
+    TMultiGraph *mg_rectaujet_mis_pt  = new TMultiGraph("","");
+    TMultiGraph *mg_rectaujet_mis_eta = new TMultiGraph("","");
+
+    TLegend *leg_rectaujet_mis_pt  = new TLegend(0.50,0.64,0.90,0.90);
+    TLegend *leg_rectaujet_mis_eta = new TLegend(0.50,0.64,0.90,0.90);
+
+    TGraphErrors gr_rectaujet_mis_pt[n_etabins], gr_rectaujet_mis_eta[n_ptbins];
+    TH1D* h_rectaujet_mis_pt, *h_rectaujet_mis_eta;
+
+    // loop over eta bins
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+
+       h_rectaujet_mis_pt = GetTauEffPt<Jet>(branchPFJet, branchParticleJet, "TauJet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
+       gr_rectaujet_mis_pt[k] = TGraphErrors(h_rectaujet_mis_pt);
+
+       s_etaMin = Form("%.1f",etaVals.at(k));
+       s_etaMax = Form("%.1f",etaVals.at(k+1));
+
+       s_eta = "uds-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
+
+       gr_rectaujet_mis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
+
+       addResoGraph(mg_rectaujet_mis_pt, &gr_rectaujet_mis_pt[k], leg_rectaujet_mis_pt, markerStyles.at(k), colors.at(k), s_eta);
+    }
+
+    // loop over pt
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       h_rectaujet_mis_eta = GetTauEffEta<Jet>(branchPFJet, branchParticleJet, "TauJet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
+       gr_rectaujet_mis_eta[k] = TGraphErrors(h_rectaujet_mis_eta);
+
+       s_pt = Form("uds-jet , p_{T} = %.0f GeV",ptVals.at(k));
+       if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
+
+       addResoGraph(mg_rectaujet_mis_eta, &gr_rectaujet_mis_eta[k], leg_rectaujet_mis_eta, markerStyles.at(k), colors.at(k), s_pt );
+    }
+
+    TCanvas *c_rectaujet_mis_pt = new TCanvas("","", 800, 600);
+
+    mg_rectaujet_mis_pt->Draw("APE");
+    DrawAxis(mg_rectaujet_mis_pt, leg_rectaujet_mis_pt, ptMin, ptMax, 0.0, 10., "p_{T} [GeV]", "#tau - mistag(%)", true, false);
+    leg_rectaujet_mis_pt->Draw();
+
+    c_rectaujet_mis_pt->Print(pdfOutput,"pdf");
+    c_rectaujet_mis_pt->Print(figPath+"img_rectaujet_mis_pt.pdf","pdf");
+    c_rectaujet_mis_pt->Print(figPath+"img_rectaujet_mis_pt.png","png");
+
+    TCanvas *c_rectaujet_mis_eta = new TCanvas("","", 800, 600);
+
+    mg_rectaujet_mis_eta->Draw("APE");
+    DrawAxis(mg_rectaujet_mis_eta, leg_rectaujet_mis_eta, etaMin, etaMax, 0.0, 5., " #eta ", "#tau - mistag (%)", false, false);
+    leg_rectaujet_mis_eta->Draw();
+
+    c_rectaujet_mis_eta->Print(pdfOutput+")","pdf");
+    c_rectaujet_mis_eta->Print(figPath+"img_rectaujet_mis_eta.pdf","pdf");
+    c_rectaujet_mis_eta->Print(figPath+"img_rectaujet_mis_eta.png","png");
+
+
+//   ----   store resolution histograms in the output (for leave efficiencies out) ---
+
 
   TFile *fout = new TFile(outputFile,"recreate");
@@ -1279,57 +2673,37 @@
   for (int bin = 0; bin < Nbins; bin++)
   {
-    plots_el.at(bin).cenResolHist->Write();
-    plots_eltrack.at(bin).cenResolHist->Write();
-    plots_eltower.at(bin).cenResolHist->Write();
-    plots_el.at(bin).fwdResolHist->Write();
-    plots_eltrack.at(bin).fwdResolHist->Write();
-    plots_eltower.at(bin).fwdResolHist->Write();
-  }
-
-  histos_el.first->Write();
-  histos_el.second->Write();
-  histos_eltrack.first->Write();
-  histos_eltrack.second->Write();
-  histos_eltower.first->Write();
-  histos_eltower.second->Write();
-  C_el1->Write();
-  C_el2->Write();
-
-  for (int bin = 0; bin < Nbins; bin++)
-  {
-    plots_mu.at(bin).cenResolHist->Write();
-    plots_mutrack.at(bin).cenResolHist->Write();
-    plots_mu.at(bin).fwdResolHist->Write();
-    plots_mutrack.at(bin).fwdResolHist->Write();
-  }
-
-  histos_mu.first->Write();
-  histos_mu.second->Write();
-  histos_mutrack.first->Write();
-  histos_mutrack.second->Write();
-  C_mu1->Write();
-  C_mu->Write();
-
-  histos_ph.first->Write();
-  histos_ph.second->Write();
-  C_ph1->Write();
-  C_ph->Write();
-
-  for (int bin = 0; bin < Nbins; bin++)
-  {
-    plots_pfjets.at(bin).cenResolHist->Write();
-    plots_pfjets.at(bin).fwdResolHist->Write();
-    plots_calojets.at(bin).cenResolHist->Write();
-    plots_calojets.at(bin).fwdResolHist->Write();
-    plots_met.at(bin).cenResolHist->Write();
-  }
-  histos_btag.first->Write();
-  histos_btag.second->Write();
-  histos_tautag.first->Write();
-  histos_tautag.second->Write();
-  C_btag1->Write();
-  C_tautag1->Write();
-  C_jet->Write();
-  C_met->Write();
+
+    for (k = 0; k < etaVals.size()-1; k++)
+    {
+       plots_trkpi_res_pt[k].at(bin).resolHist->Write();
+       plots_trkele_res_pt[k].at(bin).resolHist->Write();
+	   plots_trkmu_res_pt[k].at(bin).resolHist->Write();
+       plots_ecal_res_e[k].at(bin).resolHist->Write();
+       plots_hcal_res_e[k].at(bin).resolHist->Write();
+       plots_pfele_res_e[k].at(bin).resolHist->Write();
+       plots_pfpi_res_e[k].at(bin).resolHist->Write();
+       plots_pfjet_res_e[k].at(bin).resolHist->Write();
+       plots_cajet_res_e[k].at(bin).resolHist->Write();
+
+    }
+
+    for (k = 0; k < ptVals.size(); k++)
+    {
+       plots_trkpi_res_eta[k].at(bin).resolHist->Write();
+       plots_trkele_res_eta[k].at(bin).resolHist->Write();
+       plots_trkmu_res_eta[k].at(bin).resolHist->Write();
+       plots_ecal_res_eta[k].at(bin).resolHist->Write();
+       plots_hcal_res_eta[k].at(bin).resolHist->Write();
+       plots_pfele_res_eta[k].at(bin).resolHist->Write();
+       plots_pfpi_res_eta[k].at(bin).resolHist->Write();
+       plots_pfjet_res_eta[k].at(bin).resolHist->Write();
+       plots_cajet_res_eta[k].at(bin).resolHist->Write();
+
+    }
+
+    plots_pfmet.at(bin).resolHist->Write();
+    plots_camet.at(bin).resolHist->Write();
+
+  }
 
   fout->Write();
@@ -1357,12 +2731,15 @@
   char *appName = "Validation";
 
-  if(argc != 8)
+  if(argc != 11)
   {
     cout << " Usage: " << appName << " input_file_electron input_file_muon input_file_photon input_file_jet input_file_bjet input_file_taujet output_file" << endl;
+    cout << " input_file_pion  - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " input_file_electron  - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " input_file_muon - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " input_file_photon - input file in ROOT format ('Delphes' tree)," << endl;
+    cout << " input_file_neutralhadron - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " input_file_jet - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " input_file_bjet - input file in ROOT format ('Delphes' tree)," << endl;
+    cout << " input_file_cjet - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " input_file_taujet - input file in ROOT format ('Delphes' tree)," << endl;
     cout << " output_file - output file in ROOT format" << endl;
@@ -1376,6 +2753,7 @@
   TApplication app(appName, &appargc, appargv);
 
-  Validation(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]);
+  Validation(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]);
 }
 
 
+
