Index: examples/geometry.C
===================================================================
--- examples/geometry.C	(revision 7513718161c60a31381e1f92ff3b7913da347da5)
+++ examples/geometry.C	(revision e0c1ff0444fb4e93f2ccbf1fe6f7cb7285e14f8e)
@@ -14,9 +14,30 @@
 #include "TGeoCone.h"
 #include "TGeoArb8.h"
-//#include "../external/ExRootAnalysis/ExRootConfReader.h"
+//#include "external/ExRootAnalysis/ExRootConfReader.h"
+//#include "external/ExRootAnalysis/ExRootTreeReader.h"
+//#include "display/DelphesCaloData.h"
+//#include "display/DelphesDisplay.h"
+//#include "classes/DelphesClasses.h"
 #include "TF2.h"
 #include "TH1F.h"
+#include "TChain.h"
+#include "TEveElement.h"
+#include "TEveJetCone.h"
+#include "TEveTrack.h"
+#include "TEveTrackPropagator.h"
+#include "TEveCalo.h"
 #include "TMath.h"
 #include "TSystem.h"
+#include "TEveManager.h"
+#include "TEveGeoNode.h"
+#include "TEveTrans.h"
+#include "TEveViewer.h"
+#include "TEveBrowser.h"
+#include "TRootBrowser.h"
+#include "TGLViewer.h"
+#include "TGButton.h"
+#include "TCollection.h"
+#include "TClonesArray.h"
+#include "TGLClip.h"
 
 /*
@@ -131,5 +152,5 @@
    //--- the geometry manager
    geom_ = geom==NULL? gGeoManager : geom;
-   gGeoManager->DefaultColors();
+   //gGeoManager->DefaultColors();
 
    //--- define some materials
@@ -237,7 +258,7 @@
    set< pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()];
    Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo
-   unsigned int i = 0;
+   unsigned int ii = 0;
    for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) {
-     etaBins[i++] = itEtaSet.first;
+     etaBins[ii++] = itEtaSet->first;
    }
    etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
@@ -456,10 +477,13 @@
 
    // initialize the application
-   gSystem->Load("libDelphesDisplay");
+   gSystem->Load("../libDelphesDisplay");
+   TGeoManager *geom = new TGeoManager("delphes", "Delphes geometry");
    TEveManager::Create(kTRUE, "IV");
 
    // build the detector
    Delphes3DGeometry det3D;
-   det3D.readFile(filename,ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
+   //det3D.readFile(configFile,ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
+   det3D.readFile(configFile);//TODO fix this
+   //top->AddNode(det3D.getDetector(true),1);
    gRadius = det3D.getTrackerRadius();
    gHalfLength = det3D.getTrackerHalfLength();
@@ -467,5 +491,6 @@
    gEtaAxis = det3D.getCaloAxes().first;
    gPhiAxis = det3D.getCaloAxes().second;
-   TGeoVolume* top = gGeoManager->GetTopVolume()->FindNode("Delphes3DGeometry_1")->GetVolume();
+   //TGeoVolume* top = gGeoManager->GetTopVolume()->FindNode("Delphes3DGeometry_1")->GetVolume();
+   TGeoVolume* top = det3D.getDetector(true);
    TEveElementList *geometry = new TEveElementList("Geometry");
    TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("tracker_1"));
@@ -494,4 +519,5 @@
    muon->UseNodeTrans();
    geometry->AddElement(muon);
+   gGeoManager->DefaultColors();
 
    // Create chain of root trees
@@ -555,9 +581,9 @@
    // viewers and scenes
 
-   TEveCalo3D *calo = new TEveCalo3D(gCaloData);
-   calo->SetBarrelRadius(gRadius*100.0);
-   calo->SetEndCapPos(gHalfLength*100.0);
-
-   gStyle->SetPalette(1, 0);
+   TEveCalo3D *calo3d = new TEveCalo3D(gCaloData);
+   calo3d->SetBarrelRadius(gRadius*100.0);
+   calo3d->SetEndCapPos(gHalfLength*100.0);
+
+   //gStyle->SetPalette(1, 0);
    TEveCaloLego *lego = new TEveCaloLego(gCaloData);
    lego->InitMainTrans();
@@ -568,9 +594,9 @@
    gDelphesDisplay = new DelphesDisplay;
    gEve->AddGlobalElement(geometry);
-   gEve->AddGlobalElement(calo);
+   gEve->AddGlobalElement(calo3d);
    gDelphesDisplay->ImportGeomRPhi(geometry);
-   gDelphesDisplay->ImportCaloRPhi(calo);
+   gDelphesDisplay->ImportCaloRPhi(calo3d);
    gDelphesDisplay->ImportGeomRhoZ(geometry);
-   gDelphesDisplay->ImportCaloRhoZ(calo);
+   gDelphesDisplay->ImportCaloRhoZ(calo3d);
    gDelphesDisplay->ImportCaloLego(lego);
    gEve->Redraw3D(kTRUE);
@@ -594,5 +620,5 @@
    delphes_read();
 
-   TEveElement* top = gEve->GetCurrentEvent();
+   TEveElement* top = (TEveElement*)gEve->GetCurrentEvent();
    gDelphesDisplay->DestroyEventRPhi();
    gDelphesDisplay->ImportEventRPhi(top);
@@ -622,5 +648,5 @@
 
   TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
-  if(event >= gTreeReader->GetEntries()) return;
+  if(event_id >= gTreeReader->GetEntries()) return;
 
   // Load selected branches with data from specified event
@@ -694,5 +720,5 @@
    void Fwd()
    {  
-      if (event_id < tree->GetEntries() - 1) {
+      if (event_id < gTreeReader->GetEntries() - 1) {
          ++event_id;
          load_event();
@@ -763,6 +789,11 @@
                                                              const char* Calorimeters="Calorimeter") 
 {
+
+
    gSystem->Load("libGeom");
    gSystem->Load("../libDelphes");
+   delphes_event_display("delphes_card_CMS.tcl", "../delphes_output.root"); //TODO propagate parameters
+   return;
+/*
    TGeoManager *geom = new TGeoManager("delphes", "Delphes geometry");
 
@@ -836,4 +867,5 @@
    // load_event();
    // gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown.
-}
-
+   */
+}
+
