Index: examples/Example7.C
===================================================================
--- examples/Example7.C	(revision b4786d3e836198e304f8c5ea39d38c79b10ac5b5)
+++ examples/Example7.C	(revision b4786d3e836198e304f8c5ea39d38c79b10ac5b5)
@@ -0,0 +1,106 @@
+/*
+Simple macro showing how to access branches from the delphes output root file for Snowmass studies,
+loop over events, and plot simple quantities such as the leading electron and jet pt.
+
+root -l examples/Example7.C'("delphes_output.root")'
+*/
+
+#ifdef __CLING__
+R__LOAD_LIBRARY(libDelphes)
+#include "classes/DelphesClasses.h"
+#include "external/ExRootAnalysis/ExRootTreeReader.h"
+#endif
+
+//------------------------------------------------------------------------------
+
+void Example7(const char *inputFile)
+{
+  gSystem->Load("libDelphes");
+
+  // Create chain of root trees
+  TChain chain("Delphes");
+  chain.Add(inputFile);
+
+  // Create object of class ExRootTreeReader
+  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
+  Long64_t numberOfEntries = treeReader->GetEntries();
+
+  // Get pointers to branches used in this analysis
+  TClonesArray *branchJet = treeReader->UseBranch("JetPUPPITight");
+  TClonesArray *branchElectron = treeReader->UseBranch("ElectronMedium");
+  TClonesArray *branchWeight = treeReader->UseBranch("Weight");
+
+  // Book histograms
+  TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 1000.0);
+  TH1 *histElectronPT = new TH1F("ele_pt", "electron P_{T}", 100, 0.0, 1000.0);
+
+  // Loop over all events
+  for(Int_t entry = 0; entry < numberOfEntries; ++entry)
+  {
+    // Load selected branches with data from specified event
+    treeReader->ReadEntry(entry);
+
+    Double_t w =1.0;
+    // read MC event weight
+    if(branchWeight->GetEntries() > 0)
+    {
+      Weight *weight = (Weight*) branchWeight -> At(0);
+      w = weight->Weight;
+    }
+    
+    // If event contains at least 1 jet
+    if(branchJet->GetEntries() > 0)
+    {
+      // Take first jet
+      Jet *jet = (Jet*) branchJet->At(0);
+
+      // 0 - Loose , 1 - Medium, 2 - Tight
+      Int_t wp = 1;
+
+      Bool_t BtagOk = ( jet->BTag & (1 << wp) );
+      Double_t pt = jet->PT;
+      Double_t eta = TMath::Abs(jet->Eta);
+
+      // require jet to be within acceptance and btagged with Medium WP
+      if (BtagOk && pt > 30. && eta < 5.)  
+        histJetPT->Fill(jet->PT, w);
+    }
+
+
+    // If event contains at least 1 jet
+    if(branchElectron->GetEntries() > 0)
+    {
+      // Take first jet
+      Electron *electron = (Electron*) branchElectron->At(0);
+
+      Double_t pt = electron->PT;
+      Double_t eta = TMath::Abs(electron->Eta);
+
+      // 0.1 - Loose , 0.2 - Medium, 0.3 - Tight
+      Double_t IsoCut = 0.2;
+      Bool_t IsoOk = electron->IsolationVar < IsoCut;
+
+      // Plot jet transverse momentum
+      if (IsoOk && pt > 10. && eta < 5.)  
+        histElectronPT->Fill(electron->PT, w);
+    }
+  }
+
+
+  //
+  TCanvas *cnv = new TCanvas("cnv", "cnv", 50, 50, 800, 500);
+  cnv->Divide(2, 1);
+  cnv->cd(1);
+  gStyle->SetOptStat(0);
+
+  histJetPT->Draw();
+
+  cnv->cd(2);
+  gStyle->SetOptStat(0);
+  // Show resulting histograms
+  histElectronPT->Draw();
+
+  cnv->Print("example7.png", "png");
+
+}
+
Index: examples/Example7.py
===================================================================
--- examples/Example7.py	(revision b4786d3e836198e304f8c5ea39d38c79b10ac5b5)
+++ examples/Example7.py	(revision b4786d3e836198e304f8c5ea39d38c79b10ac5b5)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+import sys
+
+import ROOT
+
+try:
+  input = raw_input
+except:
+  pass
+
+if len(sys.argv) < 2:
+  print(" Usage: Example1.py input_file")
+  sys.exit(1)
+
+ROOT.gSystem.Load("libDelphes")
+
+try:
+  ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"')
+  ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"')
+except:
+  pass
+
+inputFile = sys.argv[1]
+
+# Create chain of root trees
+chain = ROOT.TChain("Delphes")
+chain.Add(inputFile)
+
+# Create object of class ExRootTreeReader
+treeReader = ROOT.ExRootTreeReader(chain)
+numberOfEntries = treeReader.GetEntries()
+
+# Get pointers to branches used in this analysis
+branchJet = treeReader.UseBranch("JetPUPPITight")
+branchElectron = treeReader.UseBranch("ElectronMedium")
+branchWeight = treeReader.UseBranch("Weight")
+
+# Book histograms
+histJetPT = ROOT.TH1F("jet_pt", "jet P_{T}", 100, 0.0, 1000.0)
+histElectronPT = ROOT.TH1F("Electron_pt", "electron P_{T}", 100, 0.0, 1000.0)
+
+# Loop over all events
+for entry in range(0, numberOfEntries):
+  # Load selected branches with data from specified event
+  treeReader.ReadEntry(entry)
+
+  w = 1.0  
+  ## read MC event weight
+  if branchWeight.GetEntries() > 0:  
+    weight = branchWeight.At(0).Weight
+
+  # If event contains at least 1 jet
+  if branchJet.GetEntries() > 0:
+    # Take first jet
+    jet = branchJet.At(0)
+
+    ## 0 - Loose , 1 - Medium, 2 - Tight
+    wp = 1
+
+    BtagOk = ( jet.BTag & (1 << wp) )
+    pt = jet.PT
+    eta = abs(jet.Eta)
+
+    # Plot jet transverse momentum
+    if (BtagOk and pt > 30. and eta < 5.):
+        histJetPT.Fill(jet.PT, w)
+
+
+  # If event contains at least 1 electron
+  if branchElectron.GetEntries() > 0:
+    # Take first electron
+    electron = branchElectron.At(0)
+
+    pt = electron.PT
+    eta = abs(electron.Eta)
+
+    IsoCut = 0.2
+    IsoOk = electron.IsolationVar < IsoCut
+
+    # Plot electron transverse momentum
+    if (IsoOk and pt > 10. and eta < 5.):
+        histElectronPT.Fill(electron.PT, w)
+
+
+# Show resulting histograms
+cnv = ROOT.TCanvas("cnv", "cnv", 50, 50, 800, 500)
+cnv.Divide(2, 1)
+cnv.cd(1)
+ROOT.gStyle.SetOptStat(0)
+
+histJetPT.Draw()
+
+cnv.cd(2)
+ROOT.gStyle.SetOptStat(0)
+histElectronPT.Draw()
+
+input("Press Enter to continue...")
