Index: examples/EventDisplay.C
===================================================================
--- examples/EventDisplay.C	(revision 01f457a2e7ecfae515ac0421fde7619872f13b80)
+++ examples/EventDisplay.C	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -1,260 +1,37 @@
-/*
-root -l examples/EventDisplay.C\(\"examples/delphes_card_CMS.tcl\",\"delphes_output.root\"\)
-ShowEvent(1);
-ShowEvent(2);
-*/
+/* Example:
+ * root -l 'EventDisplay.C("delphes_card_CMS.tcl","../delphes_output.root")'
+ * root -l 'EventDisplay.C("delphes_card_FCC_basic.tcl","../delphes_output.root","ParticlePropagator","ChargedHadronTrackingEfficiency","MuonTrackingEfficiency","Ecal,Hcal")'
+ */
 
-//------------------------------------------------------------------------------
+void EventDisplay(const char* configfile = "delphes_card_CMS.tcl", const char* datafile = "delphes_output.root",
+                  const char* ParticlePropagator="ParticlePropagator",
+                  const char* TrackingEfficiency="ChargedHadronTrackingEfficiency",
+                  const char* MuonEfficiency="MuonEfficiency",
+                  const char* Calorimeters="Calorimeter",
+                  bool displayGeometryOnly = false) 
+{
+   // load the libraries
+   gSystem->Load("libGeom");
+   gSystem->Load("libGuiHtml");
+   gSystem->Load("../libDelphesDisplay");
 
-// radius of the barrel, in m
-Double_t gRadius = 1.29;
+   if(displayGeometryOnly) {
+     // create the detector representation without transparency
+     Delphes3DGeometry det3D_geom(new TGeoManager("delphes", "Delphes geometry"), false);
+     det3D_geom.readFile(configfile, ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
 
-// half-length of the barrel, in m
-Double_t gHalfLength = 3.0;
+     // display
+     det3D_geom.getDetector()->Draw("ogl");
 
-// magnetic field
-Double_t gBz = 3.8;
+   } else {
 
-TAxis *gEtaAxis = 0;
-TAxis *gPhiAxis = 0;
+     // create the detector representation
+     Delphes3DGeometry det3D(new TGeoManager("delphes", "Delphes geometry"), true);
+     det3D.readFile(configfile, ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
 
-//------------------------------------------------------------------------------
+     // create the application
+     DelphesEventDisplay* display = new DelphesEventDisplay(configfile, datafile, det3D);
 
-#include <set>
-#include <vector>
-
-using namespace std;
-
-class ExRootTreeReader;
-class DelphesCaloData;
-class DelphesDisplay;
-
-TChain gChain("Delphes");
-
-ExRootTreeReader *gTreeReader = 0;
-
-TClonesArray *gBranchTower = 0;
-TClonesArray *gBranchTrack = 0;
-TClonesArray *gBranchJet = 0;
-
-DelphesCaloData *gCaloData = 0;
-TEveElementList *gJetList = 0;
-TEveTrackList *gTrackList = 0;
-
-DelphesDisplay *gDelphesDisplay = 0;
-
-//------------------------------------------------------------------------------
-
-void EventDisplay(const char *configFile, const char *inputFile)
-{
-  gSystem->Load("libDelphesDisplay");
-
-  TEveManager::Create(kTRUE, "IV");
-
-  ExRootConfParam param, paramEtaBins;
-  Long_t i, j, size, sizeEtaBins;
-  set< Double_t > etaSet;
-  set< Double_t >::iterator itEtaSet;
-
-  Double_t *etaBins;
-
-  ExRootConfReader *confReader = new ExRootConfReader;
-  confReader->ReadFile(configFile);
-
-  gRadius = confReader->GetDouble("ParticlePropagator::Radius", 1.0);
-  gHalfLength = confReader->GetDouble("ParticlePropagator::HalfLength", 3.0);
-  gBz = confReader->GetDouble("ParticlePropagator::Bz", 0.0);
-
-  // read eta and phi bins
-  param = confReader->GetParam("Calorimeter::EtaPhiBins");
-  size = param.GetSize();
-  etaSet.clear();
-  for(i = 0; i < size/2; ++i)
-  {
-    paramEtaBins = param[i*2];
-    sizeEtaBins = paramEtaBins.GetSize();
-
-    for(j = 0; j < sizeEtaBins; ++j)
-    {
-      etaSet.insert(paramEtaBins[j].GetDouble());
-    }
-  }
-
-  delete confReader;
-
-  etaBins = new Double_t[etaSet.size()];
-  i = 0;
-
-  for(itEtaSet = etaSet.begin(); itEtaSet != etaSet.end(); ++itEtaSet)
-  {
-    etaBins[i] = *itEtaSet;
-    ++i;
-  }
-
-  gEtaAxis = new TAxis(etaSet.size() - 1, etaBins);
-  gPhiAxis = new TAxis(72, -TMath::Pi(), TMath::Pi());
-
-  // Create chain of root trees
-  gChain.Add(inputFile);
-
-  // Create object of class ExRootTreeReader
-  gTreeReader = new ExRootTreeReader(&gChain);
-
-  // Get pointers to branches
-  gBranchTower = gTreeReader->UseBranch("Tower");
-  gBranchTrack = gTreeReader->UseBranch("Track");
-  gBranchJet = gTreeReader->UseBranch("Jet");
-
-  // data
-  gCaloData = new DelphesCaloData(2);
-  gCaloData->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
-  gCaloData->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
-  gCaloData->SetEtaBins(gEtaAxis);
-  gCaloData->SetPhiBins(gPhiAxis);
-  gCaloData->IncDenyDestroy();
-
-  gJetList = new TEveElementList("Jets");
-  gEve->AddElement(gJetList);
-
-  gTrackList = new TEveTrackList("Tracks");
-  gTrackList->SetMainColor(kBlue);
-  gTrackList->SetMarkerColor(kRed);
-  gTrackList->SetMarkerStyle(kCircle);
-  gTrackList->SetMarkerSize(0.5);
-  gEve->AddElement(gTrackList);
-
-  TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
-  trkProp->SetMagField(0.0, 0.0, -gBz);
-  trkProp->SetMaxR(gRadius*100.0);
-  trkProp->SetMaxZ(gHalfLength*100.0);
-
-  // viewers and scenes
-
-  TEveElementList *geometry = new TEveElementList("Geometry");
-
-  TEveGeoShape *barell = new TEveGeoShape("Barell");
-  barell->SetShape(new TGeoTube(gRadius*100.0 - 1, gRadius*100.0, gHalfLength*100.0));
-  barell->SetMainColor(kCyan);
-  barell->SetMainTransparency(80);
-  geometry->AddElement(barell);
-
-  TEveCalo3D *calo = new TEveCalo3D(gCaloData);
-  calo->SetBarrelRadius(gRadius*100.0);
-  calo->SetEndCapPos(gHalfLength*100.0);
-
-  gStyle->SetPalette(1, 0);
-  TEveCaloLego *lego = new TEveCaloLego(gCaloData);
-  lego->InitMainTrans();
-  lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
-  lego->SetAutoRebin(kFALSE);
-  lego->Set2DMode(TEveCaloLego::kValSizeOutline);
-
-  gDelphesDisplay = new DelphesDisplay;
-
-  gEve->AddGlobalElement(geometry);
-  gEve->AddGlobalElement(calo);
-
-  gDelphesDisplay->ImportGeomRPhi(geometry);
-  gDelphesDisplay->ImportCaloRPhi(calo);
-
-  gDelphesDisplay->ImportGeomRhoZ(geometry);
-  gDelphesDisplay->ImportCaloRhoZ(calo);
-
-  gDelphesDisplay->ImportCaloLego(lego);
-
-  gEve->Redraw3D(kTRUE);
+   }
 }
 
-//------------------------------------------------------------------------------
-
-void ShowEvent(Long64_t event)
-{
-  TIter itTower(gBranchTower);
-  TIter itTrack(gBranchTrack);
-  TIter itJet(gBranchJet);
-
-  Tower *tower;
-  Track *track;
-  Jet *jet;
-
-  TEveJetCone *eveJetCone;
-  TEveTrack *eveTrack;
-
-  Int_t counter;
-
-  TEveElement *currentEvent = gEve->GetCurrentEvent();
-
-  TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
-
-  if(event >= gTreeReader->GetEntries()) return;
-
-  // Load selected branches with data from specified event
-  gTreeReader->ReadEntry(event);
-
-  gCaloData->ClearTowers();
-  gJetList->DestroyElements();
-  gTrackList->DestroyElements();
-
-  // Loop over all towers
-  itTower.Reset();
-  while((tower = (Tower *) itTower.Next()))
-  {
-    gCaloData->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
-    gCaloData->FillSlice(0, tower->Eem);
-    gCaloData->FillSlice(1, tower->Ehad);
-  }
-  gCaloData->DataChanged();
-
-  // Loop over all tracks
-  itTrack.Reset();
-  counter = 0;
-  while((track = (Track *) itTrack.Next()))
-  {
-    TParticle pb(track->PID, 1, 0, 0, 0, 0,
-                 track->P4().Px(), track->P4().Py(),
-                 track->P4().Pz(), track->P4().E(),
-                 track->X, track->Y, track->Z, 0.0);
-
-    eveTrack = new TEveTrack(&pb, counter, trkProp);
-    eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
-    eveTrack->SetStdTitle();
-    eveTrack->SetAttLineAttMarker(gTrackList);
-
-    switch(TMath::Abs(track->PID))
-    {
-      case 11:
-        eveTrack->SetLineColor(kRed);
-        break;
-      case 13:
-        eveTrack->SetLineColor(kGreen);
-        break;
-      default:
-        eveTrack->SetLineColor(kBlue);
-    }
-    gTrackList->AddElement(eveTrack);
-    eveTrack->MakeTrack();
-  }
-
-  // Loop over all jets
-  itJet.Reset();
-  counter = 0;
-  while((jet = (Jet *) itJet.Next()))
-  {
-    eveJetCone = new TEveJetCone();
-    eveJetCone->SetName(Form("jet [%d]", counter++));
-    eveJetCone->SetMainTransparency(60);
-    eveJetCone->SetLineColor(kYellow);
-    eveJetCone->SetCylinder(gRadius*100.0 - 10, gHalfLength*100.0 - 10);
-    eveJetCone->SetPickable(kTRUE);
-    eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
-    gJetList->AddElement(eveJetCone);
-  }
-
-  gDelphesDisplay->DestroyEventRPhi();
-  gDelphesDisplay->ImportEventRPhi(currentEvent);
-
-  gDelphesDisplay->DestroyEventRhoZ();
-  gDelphesDisplay->ImportEventRhoZ(currentEvent);
-
-  gEve->Redraw3D(kTRUE);
-}
Index: examples/Example1.C
===================================================================
--- examples/Example1.C	(revision 01f457a2e7ecfae515ac0421fde7619872f13b80)
+++ examples/Example1.C	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -1,9 +1,8 @@
 /*
-
 Simple macro showing how to access branches from the delphes output root file,
 loop over events, and plot simple quantities such as the jet pt and the di-electron invariant
 mass. 
 
-root -l examples/Example1.C\(\"delphes_output.root\"\)
+root -l examples/Example1.C'("delphes_output.root")'
 */
 
@@ -67,2 +66,3 @@
   histMass->Draw();
 }
+
Index: examples/Example1.py
===================================================================
--- examples/Example1.py	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
+++ examples/Example1.py	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+import sys
+
+import ROOT
+
+if len(sys.argv) < 2:
+  print " Usage: Example1.py input_file"
+  sys.exit(1)
+
+ROOT.gSystem.Load("libDelphes")
+
+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("Jet")
+branchElectron = treeReader.UseBranch("Electron")
+
+# Book histograms
+histJetPT = ROOT.TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0)
+histMass = ROOT.TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0)
+
+# Loop over all events
+for entry in range(0, numberOfEntries):
+  # Load selected branches with data from specified event
+  treeReader.ReadEntry(entry)
+
+  # If event contains at least 1 jet
+  if branchJet.GetEntries() > 0:
+    # Take first jet
+    jet = branchJet.At(0)
+    
+    # Plot jet transverse momentum
+    histJetPT.Fill(jet.PT)
+    
+    # Print jet transverse momentum
+    print jet.PT
+
+  # If event contains at least 2 electrons
+  if branchElectron.GetEntries() > 1:
+    # Take first two electrons
+    elec1 = branchElectron.At(0)
+    elec2 = branchElectron.At(1)
+
+    # Plot their invariant mass
+    histMass.Fill(((elec1.P4()) + (elec2.P4())).M())
+
+# Show resulting histograms
+histJetPT.Draw()
+histMass.Draw()
+
+raw_input("Press Enter to continue...")
Index: examples/Example2.C
===================================================================
--- examples/Example2.C	(revision 01f457a2e7ecfae515ac0421fde7619872f13b80)
+++ examples/Example2.C	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -1,8 +1,7 @@
 /*
-
 Simple macro showing how to access branches from the delphes output root file,
 loop over events, store histograms in a root file and print them as image files.  
 
-root -l examples/Example2.C\(\"delphes_output.root\"\)
+root -l examples/Example2.C'("delphes_output.root")'
 */
 
Index: examples/Example3.C
===================================================================
--- examples/Example3.C	(revision 01f457a2e7ecfae515ac0421fde7619872f13b80)
+++ examples/Example3.C	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -1,8 +1,7 @@
 /*
-
 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")'
 */
 
Index: examples/MemoryUsage.C
===================================================================
--- examples/MemoryUsage.C	(revision 01f457a2e7ecfae515ac0421fde7619872f13b80)
+++ examples/MemoryUsage.C	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -1,4 +1,4 @@
 /*
-root -l examples/MemoryUsage.C\(\"ps_output.txt\"\)
+root -l examples/MemoryUsage.C'("ps_output.txt")'
 */
 
Index: examples/ProcessingTime.C
===================================================================
--- examples/ProcessingTime.C	(revision 01f457a2e7ecfae515ac0421fde7619872f13b80)
+++ examples/ProcessingTime.C	(revision e7e90dfd4bd3101eab20f85883eef511d88978c7)
@@ -1,4 +1,4 @@
 /*
-root -l examples/ProcessingTime.C\(\"delphes_output.root\"\)
+root -l examples/ProcessingTime.C'("delphes_output.root")'
 */
 
