Index: examples/Example3.C
===================================================================
--- examples/Example3.C	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ examples/Example3.C	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
@@ -1,18 +1,5 @@
 /*
-This macro shows how to access the particle-level reference for reconstructed objects.
-It is also shown how to loop over the jet constituents.
-
-root -l examples/Example3.C'("delphes_output.root")'
+root -l examples/Example3.C\(\"delphes_output.root\"\)
 */
-
-#ifdef __CLING__
-R__LOAD_LIBRARY(libDelphes)
-#include "classes/DelphesClasses.h"
-#include "external/ExRootAnalysis/ExRootTreeReader.h"
-#include "external/ExRootAnalysis/ExRootResult.h"
-#else
-class ExRootTreeReader;
-class ExRootResult;
-#endif
 
 //------------------------------------------------------------------------------
@@ -30,4 +17,10 @@
   TH1 *fMuonDeltaEta;
 
+  TH1 *fTrackDeltaPT;
+  TH1 *fTrackDeltaEta;
+
+  TH1 *fTowerDeltaEem;
+  TH1 *fTowerDeltaEhad;
+
   TH1 *fJetDeltaPT;
 };
@@ -35,4 +28,9 @@
 //------------------------------------------------------------------------------
 
+class ExRootResult;
+class ExRootTreeReader;
+
+//------------------------------------------------------------------------------
+
 void BookHistograms(ExRootResult *result, TestPlots *plots)
 {
@@ -41,42 +39,62 @@
 
   plots->fElectronDeltaPT = result->AddHist1D(
-    "electron_delta_pt", "(p_{T}^{particle} - p_{T}^{electron})/p_{T}^{particle}",
+    "electron delta pt", "(p_{T}^{particle} - p_{T}^{electron})/p_{T}^{particle}",
     "(p_{T}^{particle} - p_{T}^{electron})/p_{T}^{particle}", "number of electrons",
     100, -0.1, 0.1);
 
   plots->fElectronDeltaEta = result->AddHist1D(
-    "electron_delta_eta", "(#eta^{particle} - #eta^{electron})/#eta^{particle}",
+    "electron delta eta", "(#eta^{particle} - #eta^{electron})/#eta^{particle}",
     "(#eta^{particle} - #eta^{electron})/#eta^{particle}", "number of electrons",
     100, -0.1, 0.1);
 
   plots->fPhotonDeltaPT = result->AddHist1D(
-    "photon_delta_pt", "(p_{T}^{particle} - p_{T}^{photon})/p_{T}^{particle}",
+    "photon delta pt", "(p_{T}^{particle} - p_{T}^{photon})/p_{T}^{particle}",
     "(p_{T}^{particle} - p_{T}^{photon})/p_{T}^{particle}", "number of photons",
     100, -0.1, 0.1);
 
   plots->fPhotonDeltaEta = result->AddHist1D(
-    "photon_delta_eta", "(#eta^{particle} - #eta^{photon})/#eta^{particle}",
+    "photon delta eta", "(#eta^{particle} - #eta^{photon})/#eta^{particle}",
     "(#eta^{particle} - #eta^{photon})/#eta^{particle}", "number of photons",
     100, -0.1, 0.1);
 
   plots->fPhotonDeltaE = result->AddHist1D(
-    "photon_delta_energy", "(E^{particle} - E^{photon})/E^{particle}",
+    "photon delta energy", "(E^{particle} - E^{photon})/E^{particle}",
     "(E^{particle} - E^{photon})/E^{particle}", "number of photons",
     100, -0.1, 0.1);
 
   plots->fMuonDeltaPT = result->AddHist1D(
-    "muon_delta_pt", "(p_{T}^{particle} - p_{T}^{muon})/p_{T}^{particle}",
+    "muon delta pt", "(p_{T}^{particle} - p_{T}^{muon})/p_{T}^{particle}",
     "(p_{T}^{particle} - p_{T}^{muon})/p_{T}^{particle}", "number of muons",
     100, -0.1, 0.1);
 
   plots->fMuonDeltaEta = result->AddHist1D(
-    "muon_delta_eta", "(#eta^{particle} - #eta^{muon})/#eta^{particle}",
+    "muon delta eta", "(#eta^{particle} - #eta^{muon})/#eta^{particle}",
     "(#eta^{particle} - #eta^{muon})/#eta^{particle}", "number of muons",
     100, -0.1, 0.1);
 
+  plots->fTrackDeltaPT = result->AddHist1D(
+    "track delta pt", "(p_{T}^{particle} - p_{T}^{track})/p_{T}^{particle}",
+    "(p_{T}^{particle} - p_{T}^{track})/p_{T}^{particle}", "number of tracks",
+    100, -0.1, 0.1);
+
+  plots->fTrackDeltaEta = result->AddHist1D(
+    "track delta eta", "(#eta^{particle} - #eta^{track})/#eta^{particle}",
+    "(#eta^{particle} - #eta^{track})/#eta^{particle}", "number of tracks",
+    100, -0.1, 0.1);
+
+  plots->fTowerDeltaEem = result->AddHist1D(
+    "tower delta Eem", "(Eem^{particles} - Eem^{tower})/Eem^{particles}",
+    "(Eem^{particles} - Eem^{tower})/Eem^{particles}", "number of tower",
+    100, -0.5, 0.5);
+
+  plots->fTowerDeltaEhad = result->AddHist1D(
+    "tower delta Ehad", "(Ehad^{particles} - Ehad^{tower})/Ehad^{particles}",
+    "(Ehad^{particles} - Ehad^{tower})/Ehad^{particles}", "number of tower",
+    100, -5.0, 5.0);
+
   plots->fJetDeltaPT = result->AddHist1D(
-    "jet_delta_pt", "(p_{T}^{jet} - p_{T}^{constituents})/p_{T}^{jet}",
+    "jet delta pt", "(p_{T}^{jet} - p_{T}^{constituents})/p_{T}^{jet}",
     "(p_{T}^{jet} - p_{T}^{constituents})/p_{T}^{jet}", "number of jets",
-    100, -1.0e-1, 1.0e-1);
+    100, -1.0e-7, 1.0e-7);
 
 }
@@ -90,7 +108,8 @@
   TClonesArray *branchPhoton = treeReader->UseBranch("Photon");
   TClonesArray *branchMuon = treeReader->UseBranch("Muon");
+
   TClonesArray *branchEFlowTrack = treeReader->UseBranch("EFlowTrack");
-  TClonesArray *branchEFlowPhoton = treeReader->UseBranch("EFlowPhoton");
-  TClonesArray *branchEFlowNeutralHadron = treeReader->UseBranch("EFlowNeutralHadron");
+  TClonesArray *branchEFlowTower = treeReader->UseBranch("EFlowTower");
+  TClonesArray *branchEFlowMuon = treeReader->UseBranch("EFlowMuon");
   TClonesArray *branchJet = treeReader->UseBranch("Jet");
 
@@ -144,8 +163,8 @@
 
       particle = (GenParticle*) photon->Particles.At(0);
+
       plots->fPhotonDeltaPT->Fill((particle->PT - photon->PT)/particle->PT);
       plots->fPhotonDeltaEta->Fill((particle->Eta - photon->Eta)/particle->Eta);
       plots->fPhotonDeltaE->Fill((particle->E - photon->E)/particle->E);
-          
     }
 
@@ -160,5 +179,52 @@
     }
 
-    // cout << "--  New event -- " << endl;
+    // Loop over all tracks in event
+    for(i = 0; i < branchEFlowTrack->GetEntriesFast(); ++i)
+    {
+      track = (Track*) branchEFlowTrack->At(i);
+      particle = (GenParticle*) track->Particle.GetObject();
+
+      plots->fTrackDeltaPT->Fill((particle->PT - track->PT)/particle->PT);
+      plots->fTrackDeltaEta->Fill((particle->Eta - track->Eta)/particle->Eta);
+    }
+
+    // Loop over all towers in event
+    for(i = 0; i < branchEFlowTower->GetEntriesFast(); ++i)
+    {
+      tower = (Tower*) branchEFlowTower->At(i);
+
+      Eem = 0.0;
+      Ehad = 0.0;
+      skip = kFALSE;
+      for(j = 0; j < tower->Particles.GetEntriesFast(); ++j)
+      {
+        particle = (GenParticle*) tower->Particles.At(j);
+        pdgCode = TMath::Abs(particle->PID);
+
+        // skip muons and neutrinos
+        if(pdgCode == 12 || pdgCode == 13 || pdgCode == 14 || pdgCode == 16)
+        {
+          continue;
+        }
+
+        // skip K0short and Lambda
+        if(pdgCode == 310 || pdgCode == 3122)
+        {
+          skip = kTRUE;
+        }
+
+        if(pdgCode == 11 || pdgCode == 22)
+        {
+          Eem += particle->E;
+        }
+        else
+        {
+          Ehad += particle->E;
+        }
+      }
+      if(skip) continue;
+      if(Eem > 0.0 && tower->Eem > 0.0) plots->fTowerDeltaEem->Fill((Eem - tower->Eem)/Eem);
+      if(Ehad > 0.0 && tower->Ehad > 0.0) plots->fTowerDeltaEhad->Fill((Ehad - tower->Ehad)/Ehad);
+    }
 
     // Loop over all jets in event
@@ -168,6 +234,4 @@
 
       momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
-
-      // cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl;
 
       // Loop over all jet's constituents
@@ -181,22 +245,20 @@
         if(object->IsA() == GenParticle::Class())
         {
-          particle = (GenParticle*) object;
-          // cout << "    GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl;
-          momentum += particle->P4();
+          momentum += ((GenParticle*) object)->P4();
         }
         else if(object->IsA() == Track::Class())
         {
-          track = (Track*) object;
-          // cout << "    Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl;
-          momentum += track->P4();
+          momentum += ((Track*) object)->P4();
         }
         else if(object->IsA() == Tower::Class())
         {
-          tower = (Tower*) object;
-          // cout << "    Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl;
-          momentum += tower->P4();
+          momentum += ((Tower*) object)->P4();
+        }
+        else if(object->IsA() == Muon::Class())
+        {
+          momentum += ((Muon*) object)->P4();
         }
       }
-      plots->fJetDeltaPT->Fill((jet->PT - momentum.Pt())/jet->PT);
+      plots->fJetDeltaPT->Fill((jet->PT - momentum.Pt())/jet->PT );
     }
   }
