Index: display/Delphes3DGeometry.cc
===================================================================
--- display/Delphes3DGeometry.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/Delphes3DGeometry.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -17,24 +17,24 @@
  */
 
+#include <algorithm>
+#include <cassert>
+#include <map>
 #include <set>
-#include <map>
+#include <sstream>
 #include <utility>
 #include <vector>
-#include <algorithm>
-#include <sstream>
-#include <cassert>
 
 #include "TAxis.h"
+#include "TF2.h"
+#include "TFormula.h"
+#include "TGeoArb8.h"
+#include "TGeoCompositeShape.h"
+#include "TGeoCone.h"
 #include "TGeoManager.h"
-#include "TGeoVolume.h"
+#include "TGeoMatrix.h"
 #include "TGeoMedium.h"
 #include "TGeoNode.h"
-#include "TGeoCompositeShape.h"
-#include "TGeoMatrix.h"
 #include "TGeoTube.h"
-#include "TGeoCone.h"
-#include "TGeoArb8.h"
-#include "TF2.h"
-#include "TFormula.h"
+#include "TGeoVolume.h"
 #include "TH1F.h"
 #include "TMath.h"
@@ -48,350 +48,379 @@
 using namespace std;
 
-Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom, bool transp) {
-
-   //--- the geometry manager
-   geom_ = geom==NULL? gGeoManager : geom;
-   //gGeoManager->DefaultColors();
-
-   //--- define some materials
-   TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
-   TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // placeholder
-   if(transp) {
-     matVacuum->SetTransparency(85);
-     matAl->SetTransparency(85);
-   }
-
-   //--- define some media
-   TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
-   TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);
-   vacuum_ = Vacuum;
-   tkmed_ = Vacuum; // placeholder
-   calomed_ = Al;   // placeholder
-   mudetmed_ = Al;  // placeholder
-
-   // custom parameters
-   contingency_ = 10.;
-   calo_barrel_thickness_ = 50.;
-   calo_endcap_thickness_ = 75.;
-   muonSystem_thickn_ = 10.;
-
-   // read these parameters from the Delphes Card (with default values)
-   etaAxis_   = NULL;
-   phiAxis_   = NULL;
-   tk_radius_ = 120.;
-   tk_length_ = 150.;
-   tk_etamax_ = 3.0;
-   tk_Bz_     = 1.;
-   muonSystem_radius_ = 200.;
+Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom, bool transp)
+{
+
+  //--- the geometry manager
+  geom_ = geom == NULL ? gGeoManager : geom;
+  //gGeoManager->DefaultColors();
+
+  //--- define some materials
+  TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
+  TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7); // placeholder
+  if(transp)
+  {
+    matVacuum->SetTransparency(85);
+    matAl->SetTransparency(85);
+  }
+
+  //--- define some media
+  TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
+  TGeoMedium *Al = new TGeoMedium("Root Material", 2, matAl);
+  vacuum_ = Vacuum;
+  tkmed_ = Vacuum; // placeholder
+  calomed_ = Al; // placeholder
+  mudetmed_ = Al; // placeholder
+
+  // custom parameters
+  contingency_ = 10.;
+  calo_barrel_thickness_ = 50.;
+  calo_endcap_thickness_ = 75.;
+  muonSystem_thickn_ = 10.;
+
+  // read these parameters from the Delphes Card (with default values)
+  etaAxis_ = NULL;
+  phiAxis_ = NULL;
+  tk_radius_ = 120.;
+  tk_length_ = 150.;
+  tk_etamax_ = 3.0;
+  tk_Bz_ = 1.;
+  muonSystem_radius_ = 200.;
 }
 
 void Delphes3DGeometry::readFile(const char *configFile,
-                                 const char* ParticlePropagator, const char* TrackingEfficiency,
-                                 const char* MuonEfficiency, const char* Calorimeters) {
-
-   ExRootConfReader *confReader = new ExRootConfReader;
-   confReader->ReadFile(configFile);
-
-   tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100.;		// tk_radius
-   tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100.; 	// tk_length
-   tk_Bz_     = confReader->GetDouble("ParticlePropagator::Bz", 0.0);                           // tk_Bz
-   
-   TString buffer;
-   const char *it;
- 
-   
-   {
-   TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",TrackingEfficiency),"abs(eta)<3.0");
-   tkEffFormula.ReplaceAll("pt","x");
-   tkEffFormula.ReplaceAll("eta","y");
-   tkEffFormula.ReplaceAll("phi","0.");
- 
-   buffer.Clear();
-   for(it = tkEffFormula.Data(); *it; ++it)
-   {
-     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
-     buffer.Append(*it);
-   }
-
-   TF2* tkEffFunction = new TF2("tkEff",buffer,0,1000,-10,10);
-   TH1F etaHisto("eta","eta",100,5.,-5.);
-   Double_t pt,eta;
-   for(int i=0;i<1000;++i) {
-     tkEffFunction->GetRandom2(pt,eta);
-     etaHisto.Fill(eta);
-   }
-   Int_t bin = -1;
-   bin = etaHisto.FindFirstBinAbove(0.5);
-   Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
-   bin = etaHisto.FindLastBinAbove(0.5);
-   Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
-   tk_etamax_ = TMath::Max(fabs(etamin),fabs(etamax)); 						// tk_etamax
-   delete tkEffFunction;
-   }
-
-   {
-   muondets_.push_back("muons");
-   TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0");
-   muonEffFormula.ReplaceAll("pt","x");
-   muonEffFormula.ReplaceAll("eta","y");
-   muonEffFormula.ReplaceAll("phi","0.");
-   
-   buffer.Clear();
-   for(it = muonEffFormula.Data(); *it; ++it)
-   {
-     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
-     buffer.Append(*it);
-   }
-
-   TF2* muEffFunction = new TF2("muEff",buffer,0,1000,-10,10);
-   TH1F etaHisto("eta2","eta2",100,5.,-5.);
-   Double_t pt,eta;
-   for(int i=0;i<1000;++i) {
-     muEffFunction->GetRandom2(pt,eta);
-     etaHisto.Fill(eta);
-   }
-   Int_t bin = -1;
-   bin = etaHisto.FindFirstBinAbove(0.5);
-   Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
-   bin = etaHisto.FindLastBinAbove(0.5);
-   Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
-   muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin),fabs(etamax));			// muonSystem_etamax
-   delete muEffFunction;
-   }
-
-   std::string s(Calorimeters);
-   std::replace( s.begin(), s.end(), ',', ' ' );
-   std::istringstream stream( s );
-   std::string word;
-   while (stream >> word) calorimeters_.push_back(word);
-
-   caloBinning_.clear();								// calo binning
-   for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) {
-     set< pair<Double_t, Int_t> > caloBinning;
-     ExRootConfParam paramEtaBins, paramPhiBins;
-     ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str()));
-     Int_t size = param.GetSize();
-     for(int i = 0; i < size/2; ++i) {
-       paramEtaBins = param[i*2];
-       paramPhiBins = param[i*2+1];
-       assert(paramEtaBins.GetSize()==1);
-       caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1));
-     }
-     caloBinning_[*calo] = caloBinning;
-   }
-
-   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 ii = 0;
-   for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) {
-     etaBins[ii++] = itEtaSet->first;
-   }
-   etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
-   phiAxis_ = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT
-
-   muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_+calo_barrel_thickness_)*calorimeters_.size() + muonSystem_thickn_;
-   muonSystem_length_ = tk_length_ + contingency_ + (contingency_+calo_endcap_thickness_)*calorimeters_.size() + muonSystem_thickn_;
-
-   delete confReader;
-
-}
-
-TGeoVolume* Delphes3DGeometry::getDetector(bool withTowers) {
-   // compute the envelope
-   Double_t system_radius = tk_radius_+calo_barrel_thickness_+3*contingency_;
-   Double_t system_length = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size()+contingency_;
-   // the detector volume
-   TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length);
-   // build the detector
-   std::pair<Double_t, Double_t> limits = addTracker(top);
-   Double_t radius = limits.first;
-   Double_t length = limits.second;
-   for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) {
-     limits = addCalorimeter(top,calo->c_str(),radius,length,caloBinning_[*calo]);
-     if (withTowers) {
-       addCaloTowers(top,calo->c_str(),radius,length,caloBinning_[*calo]);
-     }
-     radius = limits.first;
-     length = limits.second;
-   }
-   for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon) {
-     limits = addMuonDets(top, muon->c_str(), radius, length);
-     radius = limits.first;
-     length = limits.second;
-   }
-   // return the result
-   return top;
-}
-
-std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) {
-   // tracker: a cylinder with two cones substracted
-   new TGeoCone("forwardTkAcceptance",(tk_length_/2.+0.05),0.,tk_radius_,(tk_length_)*2.*exp(-tk_etamax_)/(1-exp(-2.*tk_etamax_)),tk_radius_);
-   TGeoTranslation *tr1  = new TGeoTranslation("tkacc1",0., 0., tk_length_/2.);
-   tr1->RegisterYourself();
-   TGeoRotation *negz    = new TGeoRotation("tknegz",0,180,0);
-   negz->RegisterYourself();
-   TGeoCombiTrans  *tr2  = new TGeoCombiTrans("tkacc2",0.,0.,-tk_length_/2.,negz);
-   tr2->RegisterYourself();
-   TGeoCompositeShape* tracker_cs = new TGeoCompositeShape("tracker_cs","forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2");
-   TGeoVolume *tracker = new TGeoVolume("tracker",tracker_cs,tkmed_);   
-   tracker->SetLineColor(kYellow);
-   top->AddNode(tracker,1);
-   return std::make_pair(tk_radius_,tk_length_);
-}
-
-std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char* name, 
-                                                                Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
-   // parameters derived from the inputs
-   Double_t calo_endcap_etamax        = TMath::Max(fabs(caloBinning.begin()->first),fabs(caloBinning.rbegin()->first));
-   Double_t calo_barrel_innerRadius   = innerBarrelRadius+contingency_;
-   Double_t calo_barrel_length        = innerBarrelLength + calo_barrel_thickness_;
-   Double_t calo_endcap_etamin        = -log(innerBarrelRadius/(2*innerBarrelLength));
-   Double_t calo_endcap_innerRadius1  = innerBarrelLength*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
-   Double_t calo_endcap_innerRadius2  = (innerBarrelLength+calo_endcap_thickness_)*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
-   Double_t calo_endcap_outerRadius1  = innerBarrelRadius;
-   Double_t calo_endcap_outerRadius2  = innerBarrelRadius+calo_barrel_thickness_;
-   Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
-   Double_t calo_endcap_diskThickness = TMath::Max(0.,calo_endcap_thickness_-calo_endcap_coneThickness);
-
-   // calorimeters: tube truncated in eta + cones
-   new TGeoTube(Form("%s_barrel_cylinder",name),calo_barrel_innerRadius,calo_barrel_innerRadius+calo_barrel_thickness_,calo_barrel_length);
-   new TGeoCone(Form("%s_endcap_cone",name),calo_endcap_coneThickness/2.,calo_endcap_innerRadius1,calo_endcap_outerRadius1,calo_endcap_innerRadius2,calo_endcap_outerRadius2);
-   new TGeoTube(Form("%s_endcap_disk",name),calo_endcap_innerRadius2,tk_radius_+calo_barrel_thickness_,calo_endcap_diskThickness/2.);
-   TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1",name),0., 0., (calo_endcap_coneThickness+calo_endcap_diskThickness)/2.);
-   tr1->RegisterYourself();
-   TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs",name),Form("%s_endcap_cone+%s_endcap_disk:%s_tr1",name,name,name));
-   TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.);
-   trc1->RegisterYourself();
-   TGeoRotation *negz = new TGeoRotation(Form("%s_negz",name),0,180,0);
-   TGeoCombiTrans  *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.),negz);
-   trc2->RegisterYourself();
-   TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.+contingency_);
-   trc1c->RegisterYourself();
-   TGeoCombiTrans  *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.)-contingency_,negz);
-   trc2c->RegisterYourself();
-   TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap",name),calo_endcap_cs,calomed_);
-   TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs",name),
-                                                               Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position",name,name,name,name,name));
-   TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel",name),calo_barrel_cs,calomed_);
-   calo_endcap->SetLineColor(kViolet);
-   calo_endcap->SetFillColor(kViolet);
-   calo_barrel->SetLineColor(kRed);
-   top->AddNode(calo_endcap,1,trc1c);
-   top->AddNode(calo_endcap,2,trc2c);
-   top->AddNode(calo_barrel,1); 
-   return std::make_pair(calo_barrel_innerRadius+calo_barrel_thickness_,innerBarrelLength+calo_endcap_thickness_+contingency_);
-}
-
-std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength) {
-   // muon system: tube + disks
-   Double_t muonSystem_radius = innerBarrelRadius + contingency_;
-   Double_t muonSystem_length = innerBarrelLength + contingency_;
-   Double_t muonSystem_rmin   = muonSystem_length*2.*exp(-muonSystem_etamax_[name])/(1-exp(-2.*muonSystem_etamax_[name]));
-   TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel",name),mudetmed_,muonSystem_radius,muonSystem_radius+muonSystem_thickn_,muonSystem_length);
-   muon_barrel->SetLineColor(kBlue);
-   top->AddNode(muon_barrel,1);
-   TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap",name),mudetmed_,muonSystem_rmin,muonSystem_radius+muonSystem_thickn_,muonSystem_thickn_/2.);
-   muon_endcap->SetLineColor(kBlue);
-   TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position",name),0.,0.,muonSystem_length);
-   trm1->RegisterYourself();
-   TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position",name),0.,0.,-muonSystem_length);
-   trm1->RegisterYourself();
-   top->AddNode(muon_endcap,1,trm1);
-   top->AddNode(muon_endcap,2,trm2);
-   return std::make_pair(muonSystem_radius,muonSystem_length);
-}
-
-void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char* name,
-                                                       Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
-
-   TGeoVolume* calo_endcap = top->GetNode(Form("%s_endcap_1",name))->GetVolume();
-   TGeoVolume* calo_barrel = top->GetNode(Form("%s_barrel_1",name))->GetVolume();
-   Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength));
-   Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
-
-   // calo towers in the barrel
-   Double_t vertices[16] = {0.,0.,0.,0.,0.,0.,0.,0.}; // summit of the pyramid
-   Double_t R  = tk_radius_ + contingency_+(contingency_+calo_barrel_thickness_)*calorimeters_.size(); // radius of the muons system = height of the pyramid
-   Int_t nEtaBins = caloBinning.size();
-   // this rotation is to make the tower point "up"
-   TGeoRotation* initTowerRot = new TGeoRotation(Form("%s_initTowerRot",name),0.,90.,0.);
-   TGeoCombiTrans* initTower  = new TGeoCombiTrans(Form("%s_initTower",name),0.,-R/2.,0.,initTowerRot);
-   initTower->RegisterYourself();
-   // eta bins... we build one pyramid per eta slice and then translate it nphi times.
-   // phi bins represented by rotations around z
-   Double_t *y = new Double_t[nEtaBins];
-   Double_t *dx = new Double_t[nEtaBins];
-   Int_t *nphi = new Int_t[nEtaBins];
-   Int_t etaslice = 0;
-   std::map<std::pair<int,int>, TGeoRotation*> phirotations;
-   for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
-     if(abs(bin->first)>calo_endcap_etamin) continue; // only in the barrel
-     nphi[etaslice] = bin->second;
-     y[etaslice] = 0.5*R*(1-exp(-2*bin->first))/exp(-bin->first);
-     Double_t phiRotationAngle = 360./nphi[etaslice];
-     dx[etaslice] = R*tan(TMath::Pi()*phiRotationAngle/360.);
-     for(int phislice=0;phislice<nphi[etaslice];++phislice) {
-       phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
-       phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
-     }
-     ++etaslice;
-   }
-   nEtaBins = etaslice;
-   for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
-     vertices[8]  = -dx[i]; vertices[9]  = y[i];
-     vertices[10] = -dx[i]; vertices[11] = y[i+1];
-     vertices[12] =  dx[i]; vertices[13] = y[i+1];
-     vertices[14] =  dx[i]; vertices[15] = y[i];
-     new TGeoArb8(Form("%s_tower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
-     // intersection between the tower and the calo_barrel
-     TGeoCompositeShape *finaltower_cs = new TGeoCompositeShape(Form("%s_ftower%d_cs",name,i),Form("%s_tower%d:%s_initTower*%s_barrel_cs",name,i,name,name));
-     TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d",name,i),finaltower_cs,calomed_);
-     finaltower->SetLineColor(kRed);
-     for(int j=0;j<nphi[i];++j) { // loop on the phi slices
-       calo_barrel->AddNode(finaltower,j,phirotations[make_pair(i,j)]);
-     }
-   }
-   delete[] y;
-   delete[] dx;
-   delete[] nphi;
-   //the towers in the forward region
-   R  = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size(); // Z of the muons system = height of the pyramid
-   nEtaBins = caloBinning.size();
-   // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place)
-   TGeoTranslation* towerdz = new TGeoTranslation(Form("%s_towerdz",name),0.,0.,R/2.-(innerBarrelLength+calo_endcap_coneThickness/2.));
-   towerdz->RegisterYourself();
-   // eta bins... we build one pyramid per eta slice and then translate it nphi times.
-   Double_t *r = new Double_t[nEtaBins];
-   nphi = new Int_t[nEtaBins];
-   etaslice = 0;
-   phirotations.clear();
-   for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
-     if(bin->first<calo_endcap_etamin) continue; // only in the + endcap
-     r[etaslice] = R*2*exp(-bin->first)/(1-exp(-2*bin->first)); 
-     nphi[etaslice] = bin->second;
-     Double_t phiRotationAngle = 360./nphi[etaslice];
-     for(int phislice=0;phislice<nphi[etaslice];++phislice) {
-       phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
-       phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
-     }
-     ++etaslice;
-   }
-   nEtaBins = etaslice;
-   for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
-     vertices[8]  = -r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[9]  = r[i+1]*cos(TMath::Pi()/nphi[i]);
-     vertices[10] = -r[i]*sin(TMath::Pi()/nphi[i]);   vertices[11] = r[i]*cos(TMath::Pi()/nphi[i]);
-     vertices[12] =  r[i]*sin(TMath::Pi()/nphi[i]);   vertices[13] = r[i]*cos(TMath::Pi()/nphi[i]);
-     vertices[14] =  r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[15] = r[i+1]*cos(TMath::Pi()/nphi[i]);
-     new TGeoArb8(Form("%sfwdtower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
-     // intersection between the tower and the calo_endcap
-     TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs",name,i),Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs",name,i,name,name));
-     TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d",name,i),finalfwdtower_cs,calomed_);
-     finalfwdtower->SetLineColor(kViolet); 
-     for(int j=0;j<nphi[i];++j) { // loop on the phi slices
-       calo_endcap->AddNode(finalfwdtower,j,phirotations[make_pair(i,j)]);
-     }
-   }
-   delete[] r;
-   delete[] nphi;
-}
-
+  const char *ParticlePropagator, const char *TrackingEfficiency,
+  const char *MuonEfficiency, const char *Calorimeters)
+{
+
+  ExRootConfReader *confReader = new ExRootConfReader;
+  confReader->ReadFile(configFile);
+
+  tk_radius_ = confReader->GetDouble(Form("%s::Radius", ParticlePropagator), 1.0) * 100.; // tk_radius
+  tk_length_ = confReader->GetDouble(Form("%s::HalfLength", ParticlePropagator), 3.0) * 100.; // tk_length
+  tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz
+
+  TString buffer;
+  const char *it;
+
+  {
+    TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula", TrackingEfficiency), "abs(eta)<3.0");
+    tkEffFormula.ReplaceAll("pt", "x");
+    tkEffFormula.ReplaceAll("eta", "y");
+    tkEffFormula.ReplaceAll("phi", "0.");
+
+    buffer.Clear();
+    for(it = tkEffFormula.Data(); *it; ++it)
+    {
+      if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
+      buffer.Append(*it);
+    }
+
+    TF2 *tkEffFunction = new TF2("tkEff", buffer, 0, 1000, -10, 10);
+    TH1F etaHisto("eta", "eta", 100, 5., -5.);
+    Double_t pt, eta;
+    for(int i = 0; i < 1000; ++i)
+    {
+      tkEffFunction->GetRandom2(pt, eta);
+      etaHisto.Fill(eta);
+    }
+    Int_t bin = -1;
+    bin = etaHisto.FindFirstBinAbove(0.5);
+    Double_t etamin = (bin > -1) ? etaHisto.GetBinLowEdge(bin) : -10.;
+    bin = etaHisto.FindLastBinAbove(0.5);
+    Double_t etamax = (bin > -1) ? etaHisto.GetBinLowEdge(bin + 1) : -10.;
+    tk_etamax_ = TMath::Max(fabs(etamin), fabs(etamax)); // tk_etamax
+    delete tkEffFunction;
+  }
+
+  {
+    muondets_.push_back("muons");
+    TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula", MuonEfficiency), "abs(eta)<2.0");
+    muonEffFormula.ReplaceAll("pt", "x");
+    muonEffFormula.ReplaceAll("eta", "y");
+    muonEffFormula.ReplaceAll("phi", "0.");
+
+    buffer.Clear();
+    for(it = muonEffFormula.Data(); *it; ++it)
+    {
+      if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
+      buffer.Append(*it);
+    }
+
+    TF2 *muEffFunction = new TF2("muEff", buffer, 0, 1000, -10, 10);
+    TH1F etaHisto("eta2", "eta2", 100, 5., -5.);
+    Double_t pt, eta;
+    for(int i = 0; i < 1000; ++i)
+    {
+      muEffFunction->GetRandom2(pt, eta);
+      etaHisto.Fill(eta);
+    }
+    Int_t bin = -1;
+    bin = etaHisto.FindFirstBinAbove(0.5);
+    Double_t etamin = (bin > -1) ? etaHisto.GetBinLowEdge(bin) : -10.;
+    bin = etaHisto.FindLastBinAbove(0.5);
+    Double_t etamax = (bin > -1) ? etaHisto.GetBinLowEdge(bin + 1) : -10.;
+    muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin), fabs(etamax)); // muonSystem_etamax
+    delete muEffFunction;
+  }
+
+  std::string s(Calorimeters);
+  std::replace(s.begin(), s.end(), ',', ' ');
+  std::istringstream stream(s);
+  std::string word;
+  while(stream >> word) calorimeters_.push_back(word);
+
+  caloBinning_.clear(); // calo binning
+  for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo)
+  {
+    set<pair<Double_t, Int_t>> caloBinning;
+    ExRootConfParam paramEtaBins, paramPhiBins;
+    ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins", calo->c_str()));
+    Int_t size = param.GetSize();
+    for(int i = 0; i < size / 2; ++i)
+    {
+      paramEtaBins = param[i * 2];
+      paramPhiBins = param[i * 2 + 1];
+      assert(paramEtaBins.GetSize() == 1);
+      caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(), paramPhiBins.GetSize() - 1));
+    }
+    caloBinning_[*calo] = caloBinning;
+  }
+
+  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 ii = 0;
+  for(set<pair<Double_t, Int_t>>::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet)
+  {
+    etaBins[ii++] = itEtaSet->first;
+  }
+  etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
+  phiAxis_ = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT
+
+  muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_ + calo_barrel_thickness_) * calorimeters_.size() + muonSystem_thickn_;
+  muonSystem_length_ = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size() + muonSystem_thickn_;
+
+  delete confReader;
+}
+
+TGeoVolume *Delphes3DGeometry::getDetector(bool withTowers)
+{
+  // compute the envelope
+  Double_t system_radius = tk_radius_ + calo_barrel_thickness_ + 3 * contingency_;
+  Double_t system_length = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size() + contingency_;
+  // the detector volume
+  TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length);
+  // build the detector
+  std::pair<Double_t, Double_t> limits = addTracker(top);
+  Double_t radius = limits.first;
+  Double_t length = limits.second;
+  for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo)
+  {
+    limits = addCalorimeter(top, calo->c_str(), radius, length, caloBinning_[*calo]);
+    if(withTowers)
+    {
+      addCaloTowers(top, calo->c_str(), radius, length, caloBinning_[*calo]);
+    }
+    radius = limits.first;
+    length = limits.second;
+  }
+  for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon)
+  {
+    limits = addMuonDets(top, muon->c_str(), radius, length);
+    radius = limits.first;
+    length = limits.second;
+  }
+  // return the result
+  return top;
+}
+
+std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top)
+{
+  // tracker: a cylinder with two cones substracted
+  new TGeoCone("forwardTkAcceptance", (tk_length_ / 2. + 0.05), 0., tk_radius_, (tk_length_)*2. * exp(-tk_etamax_) / (1 - exp(-2. * tk_etamax_)), tk_radius_);
+  TGeoTranslation *tr1 = new TGeoTranslation("tkacc1", 0., 0., tk_length_ / 2.);
+  tr1->RegisterYourself();
+  TGeoRotation *negz = new TGeoRotation("tknegz", 0, 180, 0);
+  negz->RegisterYourself();
+  TGeoCombiTrans *tr2 = new TGeoCombiTrans("tkacc2", 0., 0., -tk_length_ / 2., negz);
+  tr2->RegisterYourself();
+  TGeoCompositeShape *tracker_cs = new TGeoCompositeShape("tracker_cs", "forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2");
+  TGeoVolume *tracker = new TGeoVolume("tracker", tracker_cs, tkmed_);
+  tracker->SetLineColor(kYellow);
+  top->AddNode(tracker, 1);
+  return std::make_pair(tk_radius_, tk_length_);
+}
+
+std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char *name,
+  Double_t innerBarrelRadius, Double_t innerBarrelLength, set<pair<Double_t, Int_t>> &caloBinning)
+{
+  // parameters derived from the inputs
+  Double_t calo_endcap_etamax = TMath::Max(fabs(caloBinning.begin()->first), fabs(caloBinning.rbegin()->first));
+  Double_t calo_barrel_innerRadius = innerBarrelRadius + contingency_;
+  Double_t calo_barrel_length = innerBarrelLength + calo_barrel_thickness_;
+  Double_t calo_endcap_etamin = -log(innerBarrelRadius / (2 * innerBarrelLength));
+  Double_t calo_endcap_innerRadius1 = innerBarrelLength * 2. * exp(-calo_endcap_etamax) / (1 - exp(-2. * calo_endcap_etamax));
+  Double_t calo_endcap_innerRadius2 = (innerBarrelLength + calo_endcap_thickness_) * 2. * exp(-calo_endcap_etamax) / (1 - exp(-2. * calo_endcap_etamax));
+  Double_t calo_endcap_outerRadius1 = innerBarrelRadius;
+  Double_t calo_endcap_outerRadius2 = innerBarrelRadius + calo_barrel_thickness_;
+  Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1 - exp(-2. * calo_endcap_etamin)) / (2. * exp(-calo_endcap_etamin)), calo_endcap_thickness_);
+  Double_t calo_endcap_diskThickness = TMath::Max(0., calo_endcap_thickness_ - calo_endcap_coneThickness);
+
+  // calorimeters: tube truncated in eta + cones
+  new TGeoTube(Form("%s_barrel_cylinder", name), calo_barrel_innerRadius, calo_barrel_innerRadius + calo_barrel_thickness_, calo_barrel_length);
+  new TGeoCone(Form("%s_endcap_cone", name), calo_endcap_coneThickness / 2., calo_endcap_innerRadius1, calo_endcap_outerRadius1, calo_endcap_innerRadius2, calo_endcap_outerRadius2);
+  new TGeoTube(Form("%s_endcap_disk", name), calo_endcap_innerRadius2, tk_radius_ + calo_barrel_thickness_, calo_endcap_diskThickness / 2.);
+  TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1", name), 0., 0., (calo_endcap_coneThickness + calo_endcap_diskThickness) / 2.);
+  tr1->RegisterYourself();
+  TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs", name), Form("%s_endcap_cone+%s_endcap_disk:%s_tr1", name, name, name));
+  TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position", name), 0., 0., innerBarrelLength + calo_endcap_coneThickness / 2.);
+  trc1->RegisterYourself();
+  TGeoRotation *negz = new TGeoRotation(Form("%s_negz", name), 0, 180, 0);
+  TGeoCombiTrans *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position", name), 0., 0., -(innerBarrelLength + calo_endcap_coneThickness / 2.), negz);
+  trc2->RegisterYourself();
+  TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont", name), 0., 0., innerBarrelLength + calo_endcap_coneThickness / 2. + contingency_);
+  trc1c->RegisterYourself();
+  TGeoCombiTrans *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont", name), 0., 0., -(innerBarrelLength + calo_endcap_coneThickness / 2.) - contingency_, negz);
+  trc2c->RegisterYourself();
+  TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap", name), calo_endcap_cs, calomed_);
+  TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs", name),
+    Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position", name, name, name, name, name));
+  TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel", name), calo_barrel_cs, calomed_);
+  calo_endcap->SetLineColor(kViolet);
+  calo_endcap->SetFillColor(kViolet);
+  calo_barrel->SetLineColor(kRed);
+  top->AddNode(calo_endcap, 1, trc1c);
+  top->AddNode(calo_endcap, 2, trc2c);
+  top->AddNode(calo_barrel, 1);
+  return std::make_pair(calo_barrel_innerRadius + calo_barrel_thickness_, innerBarrelLength + calo_endcap_thickness_ + contingency_);
+}
+
+std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength)
+{
+  // muon system: tube + disks
+  Double_t muonSystem_radius = innerBarrelRadius + contingency_;
+  Double_t muonSystem_length = innerBarrelLength + contingency_;
+  Double_t muonSystem_rmin = muonSystem_length * 2. * exp(-muonSystem_etamax_[name]) / (1 - exp(-2. * muonSystem_etamax_[name]));
+  TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel", name), mudetmed_, muonSystem_radius, muonSystem_radius + muonSystem_thickn_, muonSystem_length);
+  muon_barrel->SetLineColor(kBlue);
+  top->AddNode(muon_barrel, 1);
+  TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap", name), mudetmed_, muonSystem_rmin, muonSystem_radius + muonSystem_thickn_, muonSystem_thickn_ / 2.);
+  muon_endcap->SetLineColor(kBlue);
+  TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position", name), 0., 0., muonSystem_length);
+  trm1->RegisterYourself();
+  TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position", name), 0., 0., -muonSystem_length);
+  trm1->RegisterYourself();
+  top->AddNode(muon_endcap, 1, trm1);
+  top->AddNode(muon_endcap, 2, trm2);
+  return std::make_pair(muonSystem_radius, muonSystem_length);
+}
+
+void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char *name,
+  Double_t innerBarrelRadius, Double_t innerBarrelLength, set<pair<Double_t, Int_t>> &caloBinning)
+{
+
+  TGeoVolume *calo_endcap = top->GetNode(Form("%s_endcap_1", name))->GetVolume();
+  TGeoVolume *calo_barrel = top->GetNode(Form("%s_barrel_1", name))->GetVolume();
+  Double_t calo_endcap_etamin = -log(innerBarrelRadius / (2 * innerBarrelLength));
+  Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1 - exp(-2. * calo_endcap_etamin)) / (2. * exp(-calo_endcap_etamin)), calo_endcap_thickness_);
+
+  // calo towers in the barrel
+  Double_t vertices[16] = {0., 0., 0., 0., 0., 0., 0., 0.}; // summit of the pyramid
+  Double_t R = tk_radius_ + contingency_ + (contingency_ + calo_barrel_thickness_) * calorimeters_.size(); // radius of the muons system = height of the pyramid
+  Int_t nEtaBins = caloBinning.size();
+  // this rotation is to make the tower point "up"
+  TGeoRotation *initTowerRot = new TGeoRotation(Form("%s_initTowerRot", name), 0., 90., 0.);
+  TGeoCombiTrans *initTower = new TGeoCombiTrans(Form("%s_initTower", name), 0., -R / 2., 0., initTowerRot);
+  initTower->RegisterYourself();
+  // eta bins... we build one pyramid per eta slice and then translate it nphi times.
+  // phi bins represented by rotations around z
+  Double_t *y = new Double_t[nEtaBins];
+  Double_t *dx = new Double_t[nEtaBins];
+  Int_t *nphi = new Int_t[nEtaBins];
+  Int_t etaslice = 0;
+  std::map<std::pair<int, int>, TGeoRotation *> phirotations;
+  for(set<pair<Double_t, Int_t>>::const_iterator bin = caloBinning.begin(); bin != caloBinning.end(); ++bin)
+  {
+    if(abs(bin->first) > calo_endcap_etamin) continue; // only in the barrel
+    nphi[etaslice] = bin->second;
+    y[etaslice] = 0.5 * R * (1 - exp(-2 * bin->first)) / exp(-bin->first);
+    Double_t phiRotationAngle = 360. / nphi[etaslice];
+    dx[etaslice] = R * tan(TMath::Pi() * phiRotationAngle / 360.);
+    for(int phislice = 0; phislice < nphi[etaslice]; ++phislice)
+    {
+      phirotations[make_pair(etaslice, phislice)] = new TGeoRotation(Form("%s_phi%d_%d", name, etaslice, phislice), phiRotationAngle * phislice, 0., 0.);
+      phirotations[make_pair(etaslice, phislice)]->RegisterYourself();
+    }
+    ++etaslice;
+  }
+  nEtaBins = etaslice;
+  for(int i = 0; i < nEtaBins - 1; ++i)
+  { // loop on the eta slices
+    vertices[8] = -dx[i];
+    vertices[9] = y[i];
+    vertices[10] = -dx[i];
+    vertices[11] = y[i + 1];
+    vertices[12] = dx[i];
+    vertices[13] = y[i + 1];
+    vertices[14] = dx[i];
+    vertices[15] = y[i];
+    new TGeoArb8(Form("%s_tower%d", name, i), R / 2., vertices); // tower in the proper eta slice, at phi=0
+    // intersection between the tower and the calo_barrel
+    TGeoCompositeShape *finaltower_cs = new TGeoCompositeShape(Form("%s_ftower%d_cs", name, i), Form("%s_tower%d:%s_initTower*%s_barrel_cs", name, i, name, name));
+    TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d", name, i), finaltower_cs, calomed_);
+    finaltower->SetLineColor(kRed);
+    for(int j = 0; j < nphi[i]; ++j)
+    { // loop on the phi slices
+      calo_barrel->AddNode(finaltower, j, phirotations[make_pair(i, j)]);
+    }
+  }
+  delete[] y;
+  delete[] dx;
+  delete[] nphi;
+  //the towers in the forward region
+  R = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size(); // Z of the muons system = height of the pyramid
+  nEtaBins = caloBinning.size();
+  // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place)
+  TGeoTranslation *towerdz = new TGeoTranslation(Form("%s_towerdz", name), 0., 0., R / 2. - (innerBarrelLength + calo_endcap_coneThickness / 2.));
+  towerdz->RegisterYourself();
+  // eta bins... we build one pyramid per eta slice and then translate it nphi times.
+  Double_t *r = new Double_t[nEtaBins];
+  nphi = new Int_t[nEtaBins];
+  etaslice = 0;
+  phirotations.clear();
+  for(set<pair<Double_t, Int_t>>::const_iterator bin = caloBinning.begin(); bin != caloBinning.end(); ++bin)
+  {
+    if(bin->first < calo_endcap_etamin) continue; // only in the + endcap
+    r[etaslice] = R * 2 * exp(-bin->first) / (1 - exp(-2 * bin->first));
+    nphi[etaslice] = bin->second;
+    Double_t phiRotationAngle = 360. / nphi[etaslice];
+    for(int phislice = 0; phislice < nphi[etaslice]; ++phislice)
+    {
+      phirotations[make_pair(etaslice, phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d", name, etaslice, phislice), phiRotationAngle * phislice, 0., 0.);
+      phirotations[make_pair(etaslice, phislice)]->RegisterYourself();
+    }
+    ++etaslice;
+  }
+  nEtaBins = etaslice;
+  for(int i = 0; i < nEtaBins - 1; ++i)
+  { // loop on the eta slices
+    vertices[8] = -r[i + 1] * sin(TMath::Pi() / nphi[i]);
+    vertices[9] = r[i + 1] * cos(TMath::Pi() / nphi[i]);
+    vertices[10] = -r[i] * sin(TMath::Pi() / nphi[i]);
+    vertices[11] = r[i] * cos(TMath::Pi() / nphi[i]);
+    vertices[12] = r[i] * sin(TMath::Pi() / nphi[i]);
+    vertices[13] = r[i] * cos(TMath::Pi() / nphi[i]);
+    vertices[14] = r[i + 1] * sin(TMath::Pi() / nphi[i]);
+    vertices[15] = r[i + 1] * cos(TMath::Pi() / nphi[i]);
+    new TGeoArb8(Form("%sfwdtower%d", name, i), R / 2., vertices); // tower in the proper eta slice, at phi=0
+    // intersection between the tower and the calo_endcap
+    TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs", name, i), Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs", name, i, name, name));
+    TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d", name, i), finalfwdtower_cs, calomed_);
+    finalfwdtower->SetLineColor(kViolet);
+    for(int j = 0; j < nphi[i]; ++j)
+    { // loop on the phi slices
+      calo_endcap->AddNode(finalfwdtower, j, phirotations[make_pair(i, j)]);
+    }
+  }
+  delete[] r;
+  delete[] nphi;
+}
Index: display/Delphes3DGeometry.h
===================================================================
--- display/Delphes3DGeometry.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/Delphes3DGeometry.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -20,6 +20,6 @@
 #define Delphes3DGeometry_h
 
+#include <map>
 #include <set>
-#include <map>
 #include <vector>
 
@@ -33,63 +33,62 @@
 // TODO: asymmetric detector
 
-class Delphes3DGeometry {
-   public:
-     Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false);
-     ~Delphes3DGeometry() {}
+class Delphes3DGeometry
+{
+public:
+  Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false);
+  ~Delphes3DGeometry() {}
 
-     void readFile(const char *filename, const char *ParticlePropagator="ParticlePropagator",
-                                         const char *TrackingEfficiency="ChargedHadronTrackingEfficiency",
-                                         const char *MuonEfficiency="MuonEfficiency",
-                                         const char *Calorimeters="Calorimeter");
+  void readFile(const char *filename, const char *ParticlePropagator = "ParticlePropagator",
+    const char *TrackingEfficiency = "ChargedHadronTrackingEfficiency",
+    const char *MuonEfficiency = "MuonEfficiency",
+    const char *Calorimeters = "Calorimeter");
 
-     void setContingency(Double_t contingency) { contingency_ = contingency; }
-     void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; }
-     void setCaloEndcapThickness(Double_t thickness) { calo_endcap_thickness_ = thickness; }
-     void setMuonSystemThickness(Double_t thickness) { muonSystem_thickn_ = thickness; }
+  void setContingency(Double_t contingency) { contingency_ = contingency; }
+  void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; }
+  void setCaloEndcapThickness(Double_t thickness) { calo_endcap_thickness_ = thickness; }
+  void setMuonSystemThickness(Double_t thickness) { muonSystem_thickn_ = thickness; }
 
-     TGeoVolume *getDetector(bool withTowers = true);
+  TGeoVolume *getDetector(bool withTowers = true);
 
-     Double_t getTrackerRadius() const { return tk_radius_; }
-     Double_t getDetectorRadius() const { return muonSystem_radius_; }
-     Double_t getTrackerHalfLength() const { return tk_length_; }
-     Double_t getDetectorHalfLength() const { return muonSystem_length_; }
-     Double_t getBField() const { return tk_Bz_; }
-     std::pair<TAxis*, TAxis*> getCaloAxes() { return std::make_pair(etaAxis_,phiAxis_); }
+  Double_t getTrackerRadius() const { return tk_radius_; }
+  Double_t getDetectorRadius() const { return muonSystem_radius_; }
+  Double_t getTrackerHalfLength() const { return tk_length_; }
+  Double_t getDetectorHalfLength() const { return muonSystem_length_; }
+  Double_t getBField() const { return tk_Bz_; }
+  std::pair<TAxis *, TAxis *> getCaloAxes() { return std::make_pair(etaAxis_, phiAxis_); }
 
-   private:
-     std::pair<Double_t, Double_t> addTracker(TGeoVolume *top);
-     std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set< std::pair<Double_t, Int_t> >& caloBinning);
-     std::pair<Double_t, Double_t> addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength);
-     void addCaloTowers(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set< std::pair<Double_t, Int_t> >& caloBinning);
+private:
+  std::pair<Double_t, Double_t> addTracker(TGeoVolume *top);
+  std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set<std::pair<Double_t, Int_t>> &caloBinning);
+  std::pair<Double_t, Double_t> addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength);
+  void addCaloTowers(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set<std::pair<Double_t, Int_t>> &caloBinning);
 
-   private:
+private:
+  TGeoManager *geom_;
 
-     TGeoManager *geom_;
+  TGeoMedium *vacuum_;
+  TGeoMedium *tkmed_;
+  TGeoMedium *calomed_;
+  TGeoMedium *mudetmed_;
 
-     TGeoMedium *vacuum_;
-     TGeoMedium *tkmed_;
-     TGeoMedium *calomed_;
-     TGeoMedium *mudetmed_;
+  TAxis *etaAxis_;
+  TAxis *phiAxis_;
 
-     TAxis *etaAxis_;
-     TAxis *phiAxis_;
+  Double_t contingency_;
+  Double_t calo_barrel_thickness_;
+  Double_t calo_endcap_thickness_;
+  Double_t muonSystem_thickn_;
+  Double_t muonSystem_radius_;
+  Double_t muonSystem_length_;
+  Double_t tk_radius_;
+  Double_t tk_length_;
+  Double_t tk_etamax_;
+  Double_t tk_Bz_;
 
-     Double_t contingency_;
-     Double_t calo_barrel_thickness_;
-     Double_t calo_endcap_thickness_;
-     Double_t muonSystem_thickn_;
-     Double_t muonSystem_radius_;
-     Double_t muonSystem_length_;
-     Double_t tk_radius_;
-     Double_t tk_length_;
-     Double_t tk_etamax_;
-     Double_t tk_Bz_;
+  std::vector<std::string> calorimeters_;
+  std::vector<std::string> muondets_;
 
-     std::vector<std::string> calorimeters_;
-     std::vector<std::string> muondets_;
-
-     std::map<std::string, Double_t> muonSystem_etamax_;
-     std::map<std::string, std::set< std::pair<Double_t, Int_t> > > caloBinning_;
-
+  std::map<std::string, Double_t> muonSystem_etamax_;
+  std::map<std::string, std::set<std::pair<Double_t, Int_t>>> caloBinning_;
 };
 
Index: display/DelphesBranchElement.cc
===================================================================
--- display/DelphesBranchElement.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesBranchElement.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -18,26 +18,34 @@
 
 #include "display/DelphesBranchElement.h"
-#include "classes/DelphesClasses.h"
+#include "TEveArrow.h"
 #include "TEveJetCone.h"
 #include "TEveTrack.h"
 #include "TEveTrackPropagator.h"
-#include "TEveArrow.h"
 #include "TEveVector.h"
+#include "classes/DelphesClasses.h"
 #include <iostream>
 
 // special case for calo towers
-template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
-    data_ = new DelphesCaloData(2);
-    data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
-    data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
-    data_->IncDenyDestroy();
-}
-template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
-template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() {
-  if(TString(GetType())=="Tower") {
+template <>
+DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
+  DelphesBranchBase(name, branch, color, maxPt)
+{
+  data_ = new DelphesCaloData(2);
+  data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
+  data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
+  data_->IncDenyDestroy();
+}
+template <>
+void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
+template <>
+void DelphesBranchElement<DelphesCaloData>::ReadBranch()
+{
+  if(TString(GetType()) == "Tower")
+  {
     // Loop over all towers
     TIter itTower(branch_);
     Tower *tower;
-    while((tower = (Tower *) itTower.Next())) {
+    while((tower = (Tower *)itTower.Next()))
+    {
       data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
       data_->FillSlice(0, tower->Eem);
@@ -47,12 +55,16 @@
   }
 }
-template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() {
+template <>
+std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors()
+{
   std::vector<TLorentzVector> output;
-  if(TString(GetType())=="Tower") {
+  if(TString(GetType()) == "Tower")
+  {
     TIter itTower(branch_);
     Tower *tower;
-    while((tower = (Tower *) itTower.Next())) {
+    while((tower = (Tower *)itTower.Next()))
+    {
       TLorentzVector v;
-      v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.);
+      v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2., 0.);
       output.push_back(v);
     }
@@ -62,11 +74,18 @@
 
 // special case for element lists
-template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
-    data_ = new TEveElementList(name);
-    data_->SetMainColor(color_);
-}
-template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
-template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
-  if(TString(GetType())=="Jet") {
+template <>
+DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
+  DelphesBranchBase(name, branch, color, maxPt)
+{
+  data_ = new TEveElementList(name);
+  data_->SetMainColor(color_);
+}
+template <>
+void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
+template <>
+void DelphesBranchElement<TEveElementList>::ReadBranch()
+{
+  if(TString(GetType()) == "Jet")
+  {
     TIter itJet(branch_);
     Jet *jet;
@@ -74,7 +93,8 @@
     // Loop over all jets
     Int_t counter = 0;
-    while((jet = (Jet *) itJet.Next())) {
+    while((jet = (Jet *)itJet.Next()))
+    {
       eveJetCone = new TEveJetCone();
-      eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
+      eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter, jet->PT, jet->Eta, jet->Phi, jet->Mass));
       eveJetCone->SetName(Form("jet [%d]", counter++));
       eveJetCone->SetMainTransparency(60);
@@ -86,5 +106,7 @@
       data_->AddElement(eveJetCone);
     }
-  } else if(TString(GetType())=="MissingET") {
+  }
+  else if(TString(GetType()) == "MissingET")
+  {
     // MissingET as invisible track (like a photon)
     MissingET *MET;
@@ -94,10 +116,11 @@
     trkProp->SetMaxR(tkRadius_);
     trkProp->SetMaxZ(tkHalfLength_);
-    if(branch_->GetEntriesFast() > 0) {
-      MET = (MissingET*) branch_->At(0);
+    if(branch_->GetEntriesFast() > 0)
+    {
+      MET = (MissingET *)branch_->At(0);
       TParticle pb(13, 1, 0, 0, 0, 0,
-                   (tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi),
-                   (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi),
-                   0., MET->MET, 0.0, 0.0, 0.0, 0.0);
+        (tkRadius_ * MET->MET / maxPt_) * cos(MET->Phi),
+        (tkRadius_ * MET->MET / maxPt_) * sin(MET->Phi),
+        0., MET->MET, 0.0, 0.0, 0.0, 0.0);
       eveMet = new TEveTrack(&pb, 0, trkProp);
       eveMet->SetName("Missing Et");
@@ -115,22 +138,29 @@
   }
 }
-template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() {
+template <>
+std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors()
+{
   std::vector<TLorentzVector> output;
-  if(TString(GetType())=="Jet") {
+  if(TString(GetType()) == "Jet")
+  {
     TIter itJet(branch_);
     Jet *jet;
     // Loop over all jets
-    while((jet = (Jet *) itJet.Next())) {
+    while((jet = (Jet *)itJet.Next()))
+    {
       TLorentzVector v;
       v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
       output.push_back(v);
     }
-  } else if(TString(GetType())=="MissingET") {
+  }
+  else if(TString(GetType()) == "MissingET")
+  {
     TIter itMet(branch_);
     MissingET *MET;
     // Missing Et
-    while((MET = (MissingET*) itMet.Next())) {
+    while((MET = (MissingET *)itMet.Next()))
+    {
       TLorentzVector v;
-      v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.);
+      v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi, 0.);
       output.push_back(v);
     }
@@ -140,5 +170,8 @@
 
 // special case for track lists
-template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
+template <>
+DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
+  DelphesBranchBase(name, branch, color, maxPt)
+{
   data_ = new TEveTrackList(name);
   data_->SetMainColor(color_);
@@ -147,6 +180,8 @@
   data_->SetMarkerSize(0.5);
 }
-template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
-  tkRadius_ = r; 
+template <>
+void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz)
+{
+  tkRadius_ = r;
   tkHalfLength_ = l;
   tk_Bz_ = Bz;
@@ -156,6 +191,9 @@
   trkProp->SetMaxZ(tkHalfLength_);
 }
-template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
-template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
+template <>
+void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
+template <>
+void DelphesBranchElement<TEveTrackList>::ReadBranch()
+{
   TString type = GetType();
   TIter itTrack(branch_);
@@ -167,58 +205,69 @@
   trkProp->SetMaxZ(tkHalfLength_);
   GenParticle *particle;
-  if(type=="Track") { // CASE 1: TRACKS
+  if(type == "Track")
+  { // CASE 1: TRACKS
     Track *track;
-    while((track = (Track *) itTrack.Next())) {
+    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/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0);
-      eveTrack = new TEveTrack(&pb, counter, trkProp);
-      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
-      eveTrack->SetStdTitle();
-      eveTrack->SetAttLineAttMarker(data_);
-      data_->AddElement(eveTrack);
-      eveTrack->SetLineColor(GetColor());
-      eveTrack->MakeTrack();
-    }
-  } else if(type=="Electron") { // CASE 2: ELECTRONS
+        track->P4().Px(), track->P4().Py(),
+        track->P4().Pz(), track->P4().E(),
+        track->X / 10.0, track->Y / 10.0, track->Z / 10.0, track->T / 10.0);
+      eveTrack = new TEveTrack(&pb, counter, trkProp);
+      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
+      eveTrack->SetStdTitle();
+      eveTrack->SetAttLineAttMarker(data_);
+      data_->AddElement(eveTrack);
+      eveTrack->SetLineColor(GetColor());
+      eveTrack->MakeTrack();
+    }
+  }
+  else if(type == "Electron")
+  { // CASE 2: ELECTRONS
     Electron *electron;
-    while((electron = (Electron *) itTrack.Next())) {
-      particle = (GenParticle*) electron->Particle.GetObject();
-      TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
-                   electron->P4().Px(), electron->P4().Py(),
-                   electron->P4().Pz(), electron->P4().E(),
-                   particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
-      eveTrack = new TEveTrack(&pb, counter, trkProp);
-      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
-      eveTrack->SetStdTitle();
-      eveTrack->SetAttLineAttMarker(data_);
-      data_->AddElement(eveTrack);
-      eveTrack->SetLineColor(GetColor());
-      eveTrack->MakeTrack();
-    }
-  } else if(type=="Muon") { // CASE 3: MUONS
+    while((electron = (Electron *)itTrack.Next()))
+    {
+      particle = (GenParticle *)electron->Particle.GetObject();
+      TParticle pb(electron->Charge < 0 ? 11 : -11, 1, 0, 0, 0, 0,
+        electron->P4().Px(), electron->P4().Py(),
+        electron->P4().Pz(), electron->P4().E(),
+        particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
+      eveTrack = new TEveTrack(&pb, counter, trkProp);
+      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
+      eveTrack->SetStdTitle();
+      eveTrack->SetAttLineAttMarker(data_);
+      data_->AddElement(eveTrack);
+      eveTrack->SetLineColor(GetColor());
+      eveTrack->MakeTrack();
+    }
+  }
+  else if(type == "Muon")
+  { // CASE 3: MUONS
     Muon *muon;
-    while((muon = (Muon *) itTrack.Next())) {
-      particle = (GenParticle*) muon->Particle.GetObject();
-      TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
-                   muon->P4().Px(), muon->P4().Py(),
-                   muon->P4().Pz(), muon->P4().E(),
-                   particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
-      eveTrack = new TEveTrack(&pb, counter, trkProp);
-      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
-      eveTrack->SetStdTitle();
-      eveTrack->SetAttLineAttMarker(data_);
-      data_->AddElement(eveTrack);
-      eveTrack->SetLineColor(GetColor());
-      eveTrack->MakeTrack();
-    }
-  } else if(type=="Photon") { // CASE 4: PHOTONS
+    while((muon = (Muon *)itTrack.Next()))
+    {
+      particle = (GenParticle *)muon->Particle.GetObject();
+      TParticle pb(muon->Charge < 0 ? 13 : -13, 1, 0, 0, 0, 0,
+        muon->P4().Px(), muon->P4().Py(),
+        muon->P4().Pz(), muon->P4().E(),
+        particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
+      eveTrack = new TEveTrack(&pb, counter, trkProp);
+      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
+      eveTrack->SetStdTitle();
+      eveTrack->SetAttLineAttMarker(data_);
+      data_->AddElement(eveTrack);
+      eveTrack->SetLineColor(GetColor());
+      eveTrack->MakeTrack();
+    }
+  }
+  else if(type == "Photon")
+  { // CASE 4: PHOTONS
     Photon *photon;
-    while((photon = (Photon *) itTrack.Next())) {
+    while((photon = (Photon *)itTrack.Next()))
+    {
       TParticle pb(22, 1, 0, 0, 0, 0,
-                   photon->P4().Px(), photon->P4().Py(),
-                   photon->P4().Pz(), photon->P4().E(),
-                   0.0, 0.0, 0.0, 0.0);
+        photon->P4().Px(), photon->P4().Py(),
+        photon->P4().Pz(), photon->P4().E(),
+        0.0, 0.0, 0.0, 0.0);
       eveTrack = new TEveTrack(&pb, counter, trkProp);
       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
@@ -230,52 +279,71 @@
       eveTrack->MakeTrack();
     }
-  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
+  }
+  else if(type == "GenParticle")
+  { // CASE 5: GENPARTICLES
     GenParticle *particle;
-    while((particle = (GenParticle *) itTrack.Next())) {
+    while((particle = (GenParticle *)itTrack.Next()))
+    {
       if(particle->Status != 1) continue;
       TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
-                   particle->P4().Px(), particle->P4().Py(),
-                   particle->P4().Pz(), particle->P4().E(),
-                   particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
-      eveTrack = new TEveTrack(&pb, counter, trkProp);
-      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
-      eveTrack->SetStdTitle();
-      eveTrack->SetAttLineAttMarker(data_);
-      data_->AddElement(eveTrack);
-      eveTrack->SetLineColor(GetColor());
-      if(particle->Charge==0) eveTrack->SetLineStyle(7);
-      eveTrack->MakeTrack();
-    }
-  }
-}
-template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
+        particle->P4().Px(), particle->P4().Py(),
+        particle->P4().Pz(), particle->P4().E(),
+        particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
+      eveTrack = new TEveTrack(&pb, counter, trkProp);
+      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
+      eveTrack->SetStdTitle();
+      eveTrack->SetAttLineAttMarker(data_);
+      data_->AddElement(eveTrack);
+      eveTrack->SetLineColor(GetColor());
+      if(particle->Charge == 0) eveTrack->SetLineStyle(7);
+      eveTrack->MakeTrack();
+    }
+  }
+}
+template <>
+std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors()
+{
   std::vector<TLorentzVector> output;
   TString type = GetType();
   TIter itTrack(branch_);
-  if(type=="Track") { // CASE 1: TRACKS
+  if(type == "Track")
+  { // CASE 1: TRACKS
     Track *track;
-    while((track = (Track *) itTrack.Next())) {
+    while((track = (Track *)itTrack.Next()))
+    {
       output.push_back(track->P4());
     }
-  } else if(type=="Electron") { // CASE 2: ELECTRONS
+  }
+  else if(type == "Electron")
+  { // CASE 2: ELECTRONS
     Electron *electron;
-    while((electron = (Electron *) itTrack.Next())) {
+    while((electron = (Electron *)itTrack.Next()))
+    {
       output.push_back(electron->P4());
     }
-  } else if(type=="Muon") { // CASE 3: MUONS
+  }
+  else if(type == "Muon")
+  { // CASE 3: MUONS
     Muon *muon;
-    while((muon = (Muon *) itTrack.Next())) {
+    while((muon = (Muon *)itTrack.Next()))
+    {
       output.push_back(muon->P4());
     }
-  } else if(type=="Photon") { // CASE 4: PHOTONS
+  }
+  else if(type == "Photon")
+  { // CASE 4: PHOTONS
     Photon *photon;
-    while((photon = (Photon *) itTrack.Next())) {
+    while((photon = (Photon *)itTrack.Next()))
+    {
       output.push_back(photon->P4());
     }
-  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
+  }
+  else if(type == "GenParticle")
+  { // CASE 5: GENPARTICLES
     GenParticle *particle;
-    while((particle = (GenParticle *) itTrack.Next())) {
+    while((particle = (GenParticle *)itTrack.Next()))
+    {
       if(particle->Status != 1) continue;
-        output.push_back(particle->P4());
+      output.push_back(particle->P4());
     }
   }
Index: display/DelphesBranchElement.h
===================================================================
--- display/DelphesBranchElement.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesBranchElement.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -20,69 +20,87 @@
 #define DelphesBranchElement_h
 
+#include "TClass.h"
+#include "TClonesArray.h"
 #include "TColor.h"
+#include "TEveElement.h"
+#include "TEveTrack.h"
 #include "TString.h"
-#include "TClonesArray.h"
-#include "TClass.h"
+#include "display/DelphesCaloData.h"
 #include <exception>
 #include <iostream>
-#include "display/DelphesCaloData.h"
-#include "TEveElement.h"
-#include "TEveTrack.h"
 
 // virtual class to represent objects from a Delphes-tree branch
 class DelphesBranchBase
 {
-  public:
-    DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):name_(name),maxPt_(maxPt),branch_(branch),color_(color) {}
-    virtual ~DelphesBranchBase() {}
-    const char* GetName() const { return (const char*)name_; }
-    const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
-    virtual const char* GetClassName() = 0;
-    enum EColor GetColor() const { return color_; }
-    virtual void Reset() = 0;
-    virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
-    virtual void ReadBranch() = 0;
-    virtual std::vector<TLorentzVector> GetVectors() = 0;
+public:
+  DelphesBranchBase(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) :
+    name_(name), maxPt_(maxPt), branch_(branch), color_(color) {}
+  virtual ~DelphesBranchBase() {}
+  const char *GetName() const { return (const char *)name_; }
+  const char *GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
+  virtual const char *GetClassName() = 0;
+  enum EColor GetColor() const { return color_; }
+  virtual void Reset() = 0;
+  virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.)
+  {
+    tkRadius_ = r;
+    tkHalfLength_ = l;
+    tk_Bz_ = Bz;
+  }
+  virtual void ReadBranch() = 0;
+  virtual std::vector<TLorentzVector> GetVectors() = 0;
 
-  protected:
-    TString name_;
-    Float_t maxPt_;
-    TClonesArray* branch_;
-    const enum EColor color_;
-    Float_t tkRadius_,tkHalfLength_, tk_Bz_;
+protected:
+  TString name_;
+  Float_t maxPt_;
+  TClonesArray *branch_;
+  const enum EColor color_;
+  Float_t tkRadius_, tkHalfLength_, tk_Bz_;
 };
 
 // concrete implementations. EveContainer can be a TrackList, ElementList or CaloData.
-template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase
+template <typename EveContainer>
+class DelphesBranchElement: public DelphesBranchBase
 {
-  public:
-    // constructor
-    DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):DelphesBranchBase(name, branch, color, maxPt) {
-      throw std::exception();
-    }
+public:
+  // constructor
+  DelphesBranchElement(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) :
+    DelphesBranchBase(name, branch, color, maxPt)
+  {
+    throw std::exception();
+  }
 
-    // destructor
-    virtual ~DelphesBranchElement() { delete data_; }
+  // destructor
+  virtual ~DelphesBranchElement() { delete data_; }
 
-    // get the container (ElementList, TrackList, or CaloData)
-    EveContainer* GetContainer() { return data_; }
+  // get the container (ElementList, TrackList, or CaloData)
+  EveContainer *GetContainer() { return data_; }
 
-    // tracking volume
-    virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
+  // tracking volume
+  virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.)
+  {
+    tkRadius_ = r;
+    tkHalfLength_ = l;
+    tk_Bz_ = Bz;
+  }
 
-    // resets the collection (before moving to the next event)
-    virtual void Reset() {};
+  // resets the collection (before moving to the next event)
+  virtual void Reset(){};
 
-    // template class name
-    virtual const char* GetClassName() { return data_->ClassName(); }
+  // template class name
+  virtual const char *GetClassName() { return data_->ClassName(); }
 
-    // read the branch and fill elements for display
-    virtual void ReadBranch() {}
+  // read the branch and fill elements for display
+  virtual void ReadBranch() {}
 
-    // return the vector for all elements
-    virtual std::vector<TLorentzVector> GetVectors() { std::vector<TLorentzVector> v; return v; }
+  // return the vector for all elements
+  virtual std::vector<TLorentzVector> GetVectors()
+  {
+    std::vector<TLorentzVector> v;
+    return v;
+  }
 
-  private:
-    EveContainer* data_;
+private:
+  EveContainer *data_;
 };
 
@@ -90,21 +108,34 @@
 
 // special case for calo towers
-template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
-template<> void DelphesBranchElement<DelphesCaloData>::Reset();
-template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch();
-template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
+template <>
+DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
+template <>
+void DelphesBranchElement<DelphesCaloData>::Reset();
+template <>
+void DelphesBranchElement<DelphesCaloData>::ReadBranch();
+template <>
+std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
 
 // special case for element lists
-template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
-template<> void DelphesBranchElement<TEveElementList>::Reset();
-template<> void DelphesBranchElement<TEveElementList>::ReadBranch();
-template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
+template <>
+DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
+template <>
+void DelphesBranchElement<TEveElementList>::Reset();
+template <>
+void DelphesBranchElement<TEveElementList>::ReadBranch();
+template <>
+std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
 
 // special case for track lists
-template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
-template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
-template<> void DelphesBranchElement<TEveTrackList>::Reset();
-template<> void DelphesBranchElement<TEveTrackList>::ReadBranch();
-template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
+template <>
+DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
+template <>
+void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
+template <>
+void DelphesBranchElement<TEveTrackList>::Reset();
+template <>
+void DelphesBranchElement<TEveTrackList>::ReadBranch();
+template <>
+std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
 
 #endif // CINT, CLING
Index: display/DelphesCaloData.cc
===================================================================
--- display/DelphesCaloData.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesCaloData.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -16,5 +16,4 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
 
 #include "display/DelphesCaloData.h"
@@ -37,5 +36,5 @@
 void DelphesCaloData::ClearTowers()
 {
-   fGeomVec.clear();
+  fGeomVec.clear();
 }
 
Index: display/DelphesCaloData.h
===================================================================
--- display/DelphesCaloData.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesCaloData.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -22,8 +22,7 @@
 #include "TEveCaloData.h"
 
-class DelphesCaloData: public TEveCaloDataVec 
+class DelphesCaloData: public TEveCaloDataVec
 {
 public:
-  
   DelphesCaloData(Int_t nslices);
 
@@ -36,3 +35,2 @@
 
 #endif /* DelphesCaloData_h */
-
Index: display/DelphesDisplay.cc
===================================================================
--- display/DelphesDisplay.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesDisplay.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -17,18 +17,17 @@
  */
 
-
+#include "TEveBrowser.h"
 #include "TEveManager.h"
+#include "TEveProjectionAxes.h"
+#include "TEveProjectionManager.h"
+#include "TEveScene.h"
 #include "TEveViewer.h"
+#include "TEveWindow.h"
 #include "TGLViewer.h"
 #include "TGLWidget.h"
-#include "TEveScene.h"
-#include "TEveProjectionManager.h"
-#include "TEveProjectionAxes.h"
-#include "TEveBrowser.h"
-#include "TEveWindow.h"
 #include "TGTab.h"
 
 #include "TEveCalo2DGL.h"
-#include "TEveCalo3DGL.h"  
+#include "TEveCalo3DGL.h"
 #include "TEveCaloLegoGL.h"
 #include "TEveCaloLegoOverlay.h"
@@ -48,14 +47,14 @@
   fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
 
-	fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry");
-	fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry");
+  fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry");
+  fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry");
 
-	fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter");
-	fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter");
-	fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter");
+  fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter");
+  fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter");
+  fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter");
 
-	fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data");
-	fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data");
-  
+  fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data");
+  fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data");
+
   axes = new TEveProjectionAxes(fRPhiMgr);
   fRPhiGeomScene->AddElement(axes);
@@ -85,10 +84,10 @@
   f3DimView->AddScene(gEve->GetGlobalScene());
   f3DimView->AddScene(gEve->GetEventScene());
-  
+
   pack1->NewSlot()->MakeCurrent();
   fLegoView = gEve->SpawnNewViewer("Lego View", "");
   fLegoView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
   fLegoView->AddScene(fLegoCaloScene);
-  
+
   pack0->NewSlot()->MakeCurrent();
   fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
@@ -97,5 +96,5 @@
   fRPhiView->AddScene(fRPhiCaloScene);
   fRPhiView->AddScene(fRPhiEventScene);
-        
+
   pack0->NewSlot()->MakeCurrent();
   fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
@@ -114,11 +113,11 @@
 //------------------------------------------------------------------------------
 
-void DelphesDisplay::ImportGeomRPhi(TEveElement* el)
-{ 
+void DelphesDisplay::ImportGeomRPhi(TEveElement *el)
+{
   fRPhiMgr->ImportElements(el, fRPhiGeomScene);
 }
 
-void DelphesDisplay::ImportGeomRhoZ(TEveElement* el)
-{ 
+void DelphesDisplay::ImportGeomRhoZ(TEveElement *el)
+{
   fRhoZMgr->ImportElements(el, fRhoZGeomScene);
 }
@@ -137,5 +136,5 @@
 {
   TEveCaloLegoOverlay *overlay = new TEveCaloLegoOverlay();
- 
+
   overlay->SetCaloLego(calo);
   fLegoView->GetGLViewer()->AddOverlayElement(overlay);
@@ -144,11 +143,11 @@
 }
 
-void DelphesDisplay::ImportEventRPhi(TEveElement* el)
-{ 
+void DelphesDisplay::ImportEventRPhi(TEveElement *el)
+{
   fRPhiMgr->ImportElements(el, fRPhiEventScene);
 }
 
-void DelphesDisplay::ImportEventRhoZ(TEveElement* el)
-{ 
+void DelphesDisplay::ImportEventRhoZ(TEveElement *el)
+{
   fRhoZMgr->ImportElements(el, fRhoZEventScene);
 }
@@ -166,3 +165,2 @@
 }
 //------------------------------------------------------------------------------
-
Index: display/DelphesDisplay.h
===================================================================
--- display/DelphesDisplay.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesDisplay.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -30,11 +30,10 @@
 {
 public:
-  
   DelphesDisplay();
 
   virtual ~DelphesDisplay();
 
-  void ImportGeomRPhi(TEveElement* el);
-  void ImportGeomRhoZ(TEveElement* el);
+  void ImportGeomRPhi(TEveElement *el);
+  void ImportGeomRhoZ(TEveElement *el);
 
   void ImportCaloRPhi(TEveCalo3D *calo);
@@ -42,6 +41,6 @@
   void ImportCaloLego(TEveCaloLego *calo);
 
-  void ImportEventRPhi(TEveElement* el);
-  void ImportEventRhoZ(TEveElement* el);
+  void ImportEventRPhi(TEveElement *el);
+  void ImportEventRhoZ(TEveElement *el);
 
   void DestroyEventRPhi();
@@ -49,5 +48,4 @@
 
 private:
-
   TEveProjectionManager *fRPhiMgr;
   TEveProjectionManager *fRhoZMgr;
@@ -70,3 +68,2 @@
 
 #endif /* DelphesDisplay_h */
-
Index: display/DelphesEventDisplay.cc
===================================================================
--- display/DelphesEventDisplay.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesEventDisplay.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -17,45 +17,44 @@
  */
 
+#include <algorithm>
 #include <cassert>
 #include <iostream>
 #include <utility>
-#include <algorithm>
-
+
+#include "TAxis.h"
+#include "TCanvas.h"
+#include "TChain.h"
+#include "TClonesArray.h"
+#include "TEveArrow.h"
+#include "TEveBrowser.h"
+#include "TEveCalo.h"
+#include "TEveElement.h"
+#include "TEveEventManager.h"
+#include "TEveGeoNode.h"
+#include "TEveJetCone.h"
+#include "TEveManager.h"
+#include "TEveTrack.h"
+#include "TEveTrackPropagator.h"
+#include "TEveTrans.h"
+#include "TEveViewer.h"
+#include "TGButton.h"
+#include "TGHtml.h"
+#include "TGNumberEntry.h"
+#include "TGProgressBar.h"
+#include "TGStatusBar.h"
+#include "TGTextEntry.h"
 #include "TGeoManager.h"
 #include "TGeoVolume.h"
-#include "TEveElement.h"
-#include "TEveJetCone.h"
-#include "TEveTrack.h"
-#include "TEveTrackPropagator.h"
-#include "TEveCalo.h"
-#include "TEveManager.h"
-#include "TEveGeoNode.h"
-#include "TEveTrans.h"
-#include "TEveViewer.h"
-#include "TEveBrowser.h"
-#include "TEveArrow.h"
+#include "TH1F.h"
 #include "TMath.h"
+#include "TRootBrowser.h"
+#include "TRootEmbeddedCanvas.h"
 #include "TSystem.h"
-#include "TRootBrowser.h"
-#include "TGButton.h"
-#include "TGTextEntry.h"
-#include "TGProgressBar.h"
-#include "TGNumberEntry.h"
-#include "TRootEmbeddedCanvas.h"
-#include "TClonesArray.h"
-#include "TEveEventManager.h"
-#include "TCanvas.h"
-#include "TH1F.h"
-#include "TAxis.h"
-#include "TChain.h"
-#include "TGHtml.h"
-#include "TGStatusBar.h"
-
+
+#include "display/Delphes3DGeometry.h"
+#include "display/DelphesBranchElement.h"
 #include "display/DelphesCaloData.h"
-#include "display/DelphesBranchElement.h"
-#include "display/Delphes3DGeometry.h"
+#include "display/DelphesDisplay.h"
 #include "display/DelphesEventDisplay.h"
-#include "display/DelphesDisplay.h"
-#include "display/Delphes3DGeometry.h"
 #include "display/DelphesHtmlSummary.h"
 #include "display/DelphesPlotSummary.h"
@@ -67,293 +66,324 @@
 DelphesEventDisplay::DelphesEventDisplay()
 {
-   event_id_ = 0;
-   tkRadius_ = 1.29;
-   totRadius_ = 2.0;
-   tkHalfLength_ = 3.0;
-   muHalfLength_ = 6.0;
-   bz_ = 3.8;
-   chain_ = new TChain("Delphes");
-   treeReader_ = 0;
-   delphesDisplay_ = 0;
-   etaAxis_ = 0;
-   phiAxis_ = 0;
+  event_id_ = 0;
+  tkRadius_ = 1.29;
+  totRadius_ = 2.0;
+  tkHalfLength_ = 3.0;
+  muHalfLength_ = 6.0;
+  bz_ = 3.8;
+  chain_ = new TChain("Delphes");
+  treeReader_ = 0;
+  delphesDisplay_ = 0;
+  etaAxis_ = 0;
+  phiAxis_ = 0;
 }
 
 DelphesEventDisplay::~DelphesEventDisplay()
 {
-   delete chain_;
+  delete chain_;
 }
 
 void DelphesEventDisplay::EventChanged(Int_t e)
 {
-  if( e!= event_id_ ) {
+  if(e != event_id_)
+  {
     event_id_ = e;
-    Emit("EventChanged(Int_t)",e);
+    Emit("EventChanged(Int_t)", e);
     load_event();
   }
 }
 
-
-DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D)
-{
-   event_id_ = 0;
-   tkRadius_ = 1.29;
-   totRadius_ = 2.0;
-   tkHalfLength_ = 3.0;
-   bz_ = 3.8;
-   chain_ = new TChain("Delphes");
-   treeReader_ = 0;
-   delphesDisplay_ = 0;
-
-   // initialize the application
-   TEveManager::Create(kTRUE, "IV");
-   fStatusBar_ = gEve->GetBrowser()->GetStatusBar();
-   TGeoManager *geom = gGeoManager;
-
-   // build the detector
-   tkRadius_ = det3D.getTrackerRadius();
-   totRadius_ = det3D.getDetectorRadius();
-   tkHalfLength_ = det3D.getTrackerHalfLength();
-   muHalfLength_ = det3D.getDetectorHalfLength();
-   bz_ = det3D.getBField();
-   etaAxis_ = det3D.getCaloAxes().first;
-   phiAxis_ = det3D.getCaloAxes().second;
-   TGeoVolume *top = det3D.getDetector(false);
-   geom->SetTopVolume(top);
-   TEveElementList *geometry = new TEveElementList("Geometry");
-   TObjArray *nodes = top->GetNodes();
-   TIter itNodes(nodes);
-   TGeoNode *nodeobj;
-   TEveGeoTopNode *node;
-   while((nodeobj = (TGeoNode*)itNodes.Next())) {
-     node = new TEveGeoTopNode(gGeoManager,nodeobj);
-     node->UseNodeTrans();
-     geometry->AddElement(node);
-   }
-
-   // Create chain of root trees
-   chain_->Add(inputFile);
-
-   // Create object of class ExRootTreeReader
-   fStatusBar_->SetText("Opening Delphes data file", 1);
-   gSystem->ProcessEvents();
-   treeReader_ = new ExRootTreeReader(chain_);
-
-   // prepare data collections
-   readConfig(configFile, elements_);
-   for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element<elements_.end(); ++element) {
-     DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element);
-     DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element);
-     if(item_v1) gEve->AddElement(item_v1->GetContainer());
-     if(item_v2) gEve->AddElement(item_v2->GetContainer());
-   }
-
-   // viewers and scenes
-   delphesDisplay_ = new DelphesDisplay;
-   gEve->AddGlobalElement(geometry);
-   delphesDisplay_->ImportGeomRPhi(geometry);
-   delphesDisplay_->ImportGeomRhoZ(geometry);
-   // find the first calo data and use that to initialize the calo display
-   for(std::vector<DelphesBranchBase *>::iterator data=elements_.begin();data<elements_.end();++data) {
-     if(TString((*data)->GetType())=="Tower") { // we could also use GetClassName()=="DelphesCaloData"
-       DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
-       assert(container);
-       TEveCalo3D *calo3d = new TEveCalo3D(container);
-       calo3d->SetBarrelRadius(tkRadius_);
-       calo3d->SetEndCapPos(tkHalfLength_);
-       gEve->AddGlobalElement(calo3d);
-       delphesDisplay_->ImportCaloRPhi(calo3d);
-       delphesDisplay_->ImportCaloRhoZ(calo3d);
-       TEveCaloLego *lego = new TEveCaloLego(container);
-       lego->InitMainTrans();
- //    lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
-       lego->RefMainTrans().SetScale(100, 100, TMath::Pi());
-       lego->SetAutoRebin(kFALSE);
-       lego->Set2DMode(TEveCaloLego::kValSizeOutline);
-       delphesDisplay_->ImportCaloLego(lego);
-       break;
-     }
-   }
-
-   // the GUI: control panel, summary tab
-   make_gui();
-
-   //ready...
-   fStatusBar_->SetText("Ready.", 1);
-   gSystem->ProcessEvents();
-   load_event();
-   gEve->Redraw3D(kTRUE);   
-
+DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry &det3D)
+{
+  event_id_ = 0;
+  tkRadius_ = 1.29;
+  totRadius_ = 2.0;
+  tkHalfLength_ = 3.0;
+  bz_ = 3.8;
+  chain_ = new TChain("Delphes");
+  treeReader_ = 0;
+  delphesDisplay_ = 0;
+
+  // initialize the application
+  TEveManager::Create(kTRUE, "IV");
+  fStatusBar_ = gEve->GetBrowser()->GetStatusBar();
+  TGeoManager *geom = gGeoManager;
+
+  // build the detector
+  tkRadius_ = det3D.getTrackerRadius();
+  totRadius_ = det3D.getDetectorRadius();
+  tkHalfLength_ = det3D.getTrackerHalfLength();
+  muHalfLength_ = det3D.getDetectorHalfLength();
+  bz_ = det3D.getBField();
+  etaAxis_ = det3D.getCaloAxes().first;
+  phiAxis_ = det3D.getCaloAxes().second;
+  TGeoVolume *top = det3D.getDetector(false);
+  geom->SetTopVolume(top);
+  TEveElementList *geometry = new TEveElementList("Geometry");
+  TObjArray *nodes = top->GetNodes();
+  TIter itNodes(nodes);
+  TGeoNode *nodeobj;
+  TEveGeoTopNode *node;
+  while((nodeobj = (TGeoNode *)itNodes.Next()))
+  {
+    node = new TEveGeoTopNode(gGeoManager, nodeobj);
+    node->UseNodeTrans();
+    geometry->AddElement(node);
+  }
+
+  // Create chain of root trees
+  chain_->Add(inputFile);
+
+  // Create object of class ExRootTreeReader
+  fStatusBar_->SetText("Opening Delphes data file", 1);
+  gSystem->ProcessEvents();
+  treeReader_ = new ExRootTreeReader(chain_);
+
+  // prepare data collections
+  readConfig(configFile, elements_);
+  for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element < elements_.end(); ++element)
+  {
+    DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList> *>(*element);
+    DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList> *>(*element);
+    if(item_v1) gEve->AddElement(item_v1->GetContainer());
+    if(item_v2) gEve->AddElement(item_v2->GetContainer());
+  }
+
+  // viewers and scenes
+  delphesDisplay_ = new DelphesDisplay;
+  gEve->AddGlobalElement(geometry);
+  delphesDisplay_->ImportGeomRPhi(geometry);
+  delphesDisplay_->ImportGeomRhoZ(geometry);
+  // find the first calo data and use that to initialize the calo display
+  for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data)
+  {
+    if(TString((*data)->GetType()) == "Tower")
+    { // we could also use GetClassName()=="DelphesCaloData"
+      DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData> *>((*data))->GetContainer();
+      assert(container);
+      TEveCalo3D *calo3d = new TEveCalo3D(container);
+      calo3d->SetBarrelRadius(tkRadius_);
+      calo3d->SetEndCapPos(tkHalfLength_);
+      gEve->AddGlobalElement(calo3d);
+      delphesDisplay_->ImportCaloRPhi(calo3d);
+      delphesDisplay_->ImportCaloRhoZ(calo3d);
+      TEveCaloLego *lego = new TEveCaloLego(container);
+      lego->InitMainTrans();
+      //    lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
+      lego->RefMainTrans().SetScale(100, 100, TMath::Pi());
+      lego->SetAutoRebin(kFALSE);
+      lego->Set2DMode(TEveCaloLego::kValSizeOutline);
+      delphesDisplay_->ImportCaloLego(lego);
+      break;
+    }
+  }
+
+  // the GUI: control panel, summary tab
+  make_gui();
+
+  //ready...
+  fStatusBar_->SetText("Ready.", 1);
+  gSystem->ProcessEvents();
+  load_event();
+  gEve->Redraw3D(kTRUE);
 }
 
 // function that parses the config to extract the branches of interest and prepare containers
-void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements) {
-   ExRootConfReader *confReader = new ExRootConfReader;
-   confReader->ReadFile(configFile);
-   ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
-   Int_t nBranches = branches.GetSize()/3;
-   DelphesBranchElement<TEveTrackList> *tlist;
-   DelphesBranchElement<DelphesCaloData> *clist;
-   DelphesBranchElement<TEveElementList> *elist;
-   // first loop with all but tracks
-   for(Int_t b = 0; b<nBranches; ++b) {
-     TString input = branches[b*3].GetString();
-     TString name = branches[b*3+1].GetString();
-     TString className = branches[b*3+2].GetString();
-     if(className=="Tower") {
-       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
-       clist = new DelphesBranchElement<DelphesCaloData>(name,treeReader_->UseBranch(name),kBlack);
-       clist->GetContainer()->SetEtaBins(etaAxis_);
-       clist->GetContainer()->SetPhiBins(phiAxis_);
-       elements.push_back(clist);
-     } else if(className=="Jet") {
-       if(input.Contains("GenJetFinder")) {
-         elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kCyan);
-         elist->GetContainer()->SetRnrSelf(false);
-         elist->GetContainer()->SetRnrChildren(false);
-         elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-         elements.push_back(elist);
-       } else {
-         elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kYellow);
-         elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-         elements.push_back(elist);
-       }
-     } else if(className=="Electron") {
-       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kRed);
-       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-       elements.push_back(tlist);
-     } else if(className=="Photon") {
-       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kYellow);
-       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-       elements.push_back(tlist);
-     } else if(className=="Muon") {
-       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kGreen);
-       tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_);
-       elements.push_back(tlist);
-     } else if(className=="MissingET") {
-       elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kViolet);
-       elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-       elements.push_back(elist);
-     } else if(className=="GenParticle") {
-       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kCyan);
-       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-       tlist->GetContainer()->SetRnrSelf(false);
-       tlist->GetContainer()->SetRnrChildren(false);
-       elements.push_back(tlist);
-     } else {
-       continue;
-     }
-   }
-   // second loop for tracks
-   for(Int_t b = 0; b<nBranches; ++b) {
-     TString input = branches[b*3].GetString();
-     TString name = branches[b*3+1].GetString();
-     TString className = branches[b*3+2].GetString();
-     if(className=="Track") {
-       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
-       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kBlue);
-       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
-       elements.push_back(tlist);
-     }
-   }
+void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase *> &elements)
+{
+  ExRootConfReader *confReader = new ExRootConfReader;
+  confReader->ReadFile(configFile);
+  ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
+  Int_t nBranches = branches.GetSize() / 3;
+  DelphesBranchElement<TEveTrackList> *tlist;
+  DelphesBranchElement<DelphesCaloData> *clist;
+  DelphesBranchElement<TEveElementList> *elist;
+  // first loop with all but tracks
+  for(Int_t b = 0; b < nBranches; ++b)
+  {
+    TString input = branches[b * 3].GetString();
+    TString name = branches[b * 3 + 1].GetString();
+    TString className = branches[b * 3 + 2].GetString();
+    if(className == "Tower")
+    {
+      if(input.Contains("eflow", TString::kIgnoreCase) || name.Contains("eflow", TString::kIgnoreCase)) continue; //no eflow
+      clist = new DelphesBranchElement<DelphesCaloData>(name, treeReader_->UseBranch(name), kBlack);
+      clist->GetContainer()->SetEtaBins(etaAxis_);
+      clist->GetContainer()->SetPhiBins(phiAxis_);
+      elements.push_back(clist);
+    }
+    else if(className == "Jet")
+    {
+      if(input.Contains("GenJetFinder"))
+      {
+        elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kCyan);
+        elist->GetContainer()->SetRnrSelf(false);
+        elist->GetContainer()->SetRnrChildren(false);
+        elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+        elements.push_back(elist);
+      }
+      else
+      {
+        elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kYellow);
+        elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+        elements.push_back(elist);
+      }
+    }
+    else if(className == "Electron")
+    {
+      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kRed);
+      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+      elements.push_back(tlist);
+    }
+    else if(className == "Photon")
+    {
+      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kYellow);
+      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+      elements.push_back(tlist);
+    }
+    else if(className == "Muon")
+    {
+      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kGreen);
+      tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_);
+      elements.push_back(tlist);
+    }
+    else if(className == "MissingET")
+    {
+      elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kViolet);
+      elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+      elements.push_back(elist);
+    }
+    else if(className == "GenParticle")
+    {
+      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kCyan);
+      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+      tlist->GetContainer()->SetRnrSelf(false);
+      tlist->GetContainer()->SetRnrChildren(false);
+      elements.push_back(tlist);
+    }
+    else
+    {
+      continue;
+    }
+  }
+  // second loop for tracks
+  for(Int_t b = 0; b < nBranches; ++b)
+  {
+    TString input = branches[b * 3].GetString();
+    TString name = branches[b * 3 + 1].GetString();
+    TString className = branches[b * 3 + 2].GetString();
+    if(className == "Track")
+    {
+      if(input.Contains("eflow", TString::kIgnoreCase) || name.Contains("eflow", TString::kIgnoreCase)) continue; //no eflow
+      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kBlue);
+      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
+      elements.push_back(tlist);
+    }
+  }
 }
 
 void DelphesEventDisplay::load_event()
 {
-   // Load event specified in global event_id_.
-   // The contents of previous event are removed.
-
-   // safety
-   if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return;
-
-   // message
-   fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1);
-   gSystem->ProcessEvents();
-
-   // clear the previous event
-   gEve->GetViewers()->DeleteAnnotations();
-   for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
-     (*data)->Reset();
-   }
-
-   // Load selected branches with data from specified event
-   treeReader_->ReadEntry(event_id_);
-   for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
-     (*data)->ReadBranch();
-   }
-
-   // update display
-   TEveElement *top = (TEveElement*)gEve->GetCurrentEvent();
-   delphesDisplay_->DestroyEventRPhi();
-   delphesDisplay_->ImportEventRPhi(top);
-   delphesDisplay_->DestroyEventRhoZ();
-   delphesDisplay_->ImportEventRhoZ(top);
-   update_html_summary();
-   plotSummary_->FillEvent();
-   plotSummary_->Draw();
-
-   gEve->Redraw3D(kFALSE, kTRUE);
-   fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1);
-   gSystem->ProcessEvents();
+  // Load event specified in global event_id_.
+  // The contents of previous event are removed.
+
+  // safety
+  if(event_id_ >= treeReader_->GetEntries() || event_id_ < 0) return;
+
+  // message
+  fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1);
+  gSystem->ProcessEvents();
+
+  // clear the previous event
+  gEve->GetViewers()->DeleteAnnotations();
+  for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data)
+  {
+    (*data)->Reset();
+  }
+
+  // Load selected branches with data from specified event
+  treeReader_->ReadEntry(event_id_);
+  for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data)
+  {
+    (*data)->ReadBranch();
+  }
+
+  // update display
+  TEveElement *top = (TEveElement *)gEve->GetCurrentEvent();
+  delphesDisplay_->DestroyEventRPhi();
+  delphesDisplay_->ImportEventRPhi(top);
+  delphesDisplay_->DestroyEventRhoZ();
+  delphesDisplay_->ImportEventRhoZ(top);
+  update_html_summary();
+  plotSummary_->FillEvent();
+  plotSummary_->Draw();
+
+  gEve->Redraw3D(kFALSE, kTRUE);
+  fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1);
+  gSystem->ProcessEvents();
 }
 
 void DelphesEventDisplay::update_html_summary()
 {
-   // Update summary of current event.
-
-   TEveElement::List_i i;
-   TEveElement::List_i j;
-   Int_t k;
-   TEveElement *el;
-   DelphesHtmlObjTable *table;
-   TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
-   if (mgr) {
-      htmlSummary_->Clear("D");
-      for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) {
-         el = ((TEveElement*)(*i));
-         if (el->IsA() == TEvePointSet::Class()) {
-            TEvePointSet *ps = (TEvePointSet *)el;
-            TString ename  = ps->GetElementName();
-            TString etitle = ps->GetElementTitle();
-            if (ename.First('\'') != kNPOS)
-               ename.Remove(ename.First('\''));
-            etitle.Remove(0, 2);
-            Int_t nel = atoi(etitle.Data());
-            table = htmlSummary_->AddTable(ename, 0, nel);
-         }
-         else if (el->IsA() == TEveTrackList::Class()) {
-            TEveTrackList *tracks = (TEveTrackList *)el;
-            TString ename  = tracks->GetElementName();
-            if (ename.First('\'') != kNPOS)
-               ename.Remove(ename.First('\''));
-            table = htmlSummary_->AddTable(ename.Data(), 5, 
-                     tracks->NumChildren(), kTRUE, "first");
-            table->SetLabel(0, "Momentum");
-            table->SetLabel(1, "P_t");
-            table->SetLabel(2, "Phi");
-            table->SetLabel(3, "Theta");
-            table->SetLabel(4, "Eta");
-            k=0;
-            for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) {
-               Float_t p     = ((TEveTrack*)(*j))->GetMomentum().Mag();
-               table->SetValue(0, k, p);
-               Float_t pt    = ((TEveTrack*)(*j))->GetMomentum().Perp();
-               table->SetValue(1, k, pt);
-               Float_t phi   = ((TEveTrack*)(*j))->GetMomentum().Phi();
-               table->SetValue(2, k, phi);
-               Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta();
-               table->SetValue(3, k, theta);
-               Float_t eta   = theta>0.0005 && theta<3.1413 ? ((TEveTrack*)(*j))->GetMomentum().Eta() : 1e10;
-               table->SetValue(4, k, eta);
-               ++k;
-            }
-         }
+  // Update summary of current event.
+
+  TEveElement::List_i i;
+  TEveElement::List_i j;
+  Int_t k;
+  TEveElement *el;
+  DelphesHtmlObjTable *table;
+  TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
+  if(mgr)
+  {
+    htmlSummary_->Clear("D");
+    for(i = mgr->BeginChildren(); i != mgr->EndChildren(); ++i)
+    {
+      el = ((TEveElement *)(*i));
+      if(el->IsA() == TEvePointSet::Class())
+      {
+        TEvePointSet *ps = (TEvePointSet *)el;
+        TString ename = ps->GetElementName();
+        TString etitle = ps->GetElementTitle();
+        if(ename.First('\'') != kNPOS)
+          ename.Remove(ename.First('\''));
+        etitle.Remove(0, 2);
+        Int_t nel = atoi(etitle.Data());
+        table = htmlSummary_->AddTable(ename, 0, nel);
       }
-      htmlSummary_->Build();
-      gHtml_->Clear();
-      gHtml_->ParseText((char*)htmlSummary_->Html().Data());
-      gHtml_->Layout();
-   }
-  
+      else if(el->IsA() == TEveTrackList::Class())
+      {
+        TEveTrackList *tracks = (TEveTrackList *)el;
+        TString ename = tracks->GetElementName();
+        if(ename.First('\'') != kNPOS)
+          ename.Remove(ename.First('\''));
+        table = htmlSummary_->AddTable(ename.Data(), 5,
+          tracks->NumChildren(), kTRUE, "first");
+        table->SetLabel(0, "Momentum");
+        table->SetLabel(1, "P_t");
+        table->SetLabel(2, "Phi");
+        table->SetLabel(3, "Theta");
+        table->SetLabel(4, "Eta");
+        k = 0;
+        for(j = tracks->BeginChildren(); j != tracks->EndChildren(); ++j)
+        {
+          Float_t p = ((TEveTrack *)(*j))->GetMomentum().Mag();
+          table->SetValue(0, k, p);
+          Float_t pt = ((TEveTrack *)(*j))->GetMomentum().Perp();
+          table->SetValue(1, k, pt);
+          Float_t phi = ((TEveTrack *)(*j))->GetMomentum().Phi();
+          table->SetValue(2, k, phi);
+          Float_t theta = ((TEveTrack *)(*j))->GetMomentum().Theta();
+          table->SetValue(3, k, theta);
+          Float_t eta = theta > 0.0005 && theta < 3.1413 ? ((TEveTrack *)(*j))->GetMomentum().Eta() : 1e10;
+          table->SetValue(4, k, eta);
+          ++k;
+        }
+      }
+    }
+    htmlSummary_->Build();
+    gHtml_->Clear();
+    gHtml_->ParseText((char *)htmlSummary_->Html().Data());
+    gHtml_->Layout();
+  }
 }
 
@@ -364,115 +394,127 @@
 void DelphesEventDisplay::make_gui()
 {
-   // Create minimal GUI for event navigation.
-
-   // add a tab on the left
-   TEveBrowser *browser = gEve->GetBrowser();
-   browser->SetWindowName("Delphes Event Display");
-   browser->StartEmbedding(TRootBrowser::kLeft);
-
-   // set the main title
-   TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
-   frmMain->SetWindowName("Delphes Event Display");
-   frmMain->SetCleanup(kDeepCleanup);
-
-   // build the navigation menu
-   TString icondir;
-   if(gSystem->Getenv("ROOTSYS"))
-     icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
-   if(!gSystem->OpenDirectory(icondir)) 
-     icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") );
-   TGGroupFrame *vf = new TGGroupFrame(frmMain,"Event navigation",kVerticalFrame | kFitWidth );
-   {
-     TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain);
-     {
-        TGPictureButton *b = 0;
-
-        b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
-        hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 10, 2, 10, 10));
-        b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()");
-
-        TGNumberEntry *numberEntry = new TGNumberEntry(hf,0,9,-1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries());
-        hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY , 2, 0, 10, 10));
-        this->Connect("EventChanged(Int_t)","TGNumberEntry",numberEntry,"SetIntNumber(Long_t)");
-        numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)");
-        numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()");
-        
-        b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
-        hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY , 2, 10, 10, 10));
-        b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()");
-  
-     }
-     vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX , 2, 2, 2, 2));
-
-     TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100);
-     progress->SetMax( treeReader_->GetEntries());
-     progress->ShowPosition(kTRUE, kFALSE, "Event %.0f");
-     progress->SetBarColor("green");
-     vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5));
-     this->Connect("EventChanged(Int_t)","TGHProgressBar",progress,"SetPosition(Float_t)");
-   }
-   frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5));
-   vf = new TGGroupFrame(frmMain,"Batch operations",kVerticalFrame | kFitWidth );
-   {
-        TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots");
-        vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10));
-        b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()");
-   }
-   frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5));
-
-   frmMain->MapSubwindows();
-   frmMain->Resize();
-   frmMain->MapWindow();
-   browser->StopEmbedding();
-   browser->SetTabTitle("Event Control", 0);
-
-   // the summary tab
-   htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table");
-   TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
-   gHtml_ = new TGHtml(0, 100, 100);
-   TEveWindowFrame *wf = slot->MakeFrame(gHtml_);
-   gHtml_->MapSubwindows();
-   wf->SetElementName("Summary tables");
-
-   // plot tab
-   slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
-   TEveWindowTab *tab = slot->MakeTab();
-   tab->SetElementName("Summary plots");
-   tab->SetShowTitleBar(kFALSE);
-   plotSummary_ = new DelphesPlotSummary(tab);
-   plotSummary_->Init(elements_);
-   plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)");
-
-}
-
-void DelphesEventDisplay::Fwd() {  
-  if (event_id_ < treeReader_->GetEntries() - 2) {
-     EventChanged(event_id_+1);
-  } else {
-     printf("Already at last event.\n");
-  }
-}
-
-void DelphesEventDisplay::Bck() {
-  if (event_id_ > 0) {
-     EventChanged(event_id_-1);
-  } else {
-     printf("Already at first event.\n");
-  }
-}
-
-void DelphesEventDisplay::PreSetEv(char *ev) {
+  // Create minimal GUI for event navigation.
+
+  // add a tab on the left
+  TEveBrowser *browser = gEve->GetBrowser();
+  browser->SetWindowName("Delphes Event Display");
+  browser->StartEmbedding(TRootBrowser::kLeft);
+
+  // set the main title
+  TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
+  frmMain->SetWindowName("Delphes Event Display");
+  frmMain->SetCleanup(kDeepCleanup);
+
+  // build the navigation menu
+  TString icondir;
+  if(gSystem->Getenv("ROOTSYS"))
+    icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
+  if(!gSystem->OpenDirectory(icondir))
+    icondir = Form("%s/icons/", (const char *)gSystem->GetFromPipe("root-config --etcdir"));
+  TGGroupFrame *vf = new TGGroupFrame(frmMain, "Event navigation", kVerticalFrame | kFitWidth);
+  {
+    TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain);
+    {
+      TGPictureButton *b = 0;
+
+      b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoBack.gif"));
+      hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 10, 10));
+      b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()");
+
+      TGNumberEntry *numberEntry = new TGNumberEntry(hf, 0, 9, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries());
+      hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 0, 10, 10));
+      this->Connect("EventChanged(Int_t)", "TGNumberEntry", numberEntry, "SetIntNumber(Long_t)");
+      numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)");
+      numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()");
+
+      b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoForward.gif"));
+      hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 2, 10, 10, 10));
+      b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()");
+    }
+    vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
+
+    TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100);
+    progress->SetMax(treeReader_->GetEntries());
+    progress->ShowPosition(kTRUE, kFALSE, "Event %.0f");
+    progress->SetBarColor("green");
+    vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5));
+    this->Connect("EventChanged(Int_t)", "TGHProgressBar", progress, "SetPosition(Float_t)");
+  }
+  frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
+  vf = new TGGroupFrame(frmMain, "Batch operations", kVerticalFrame | kFitWidth);
+  {
+    TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots");
+    vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10));
+    b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()");
+  }
+  frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
+
+  frmMain->MapSubwindows();
+  frmMain->Resize();
+  frmMain->MapWindow();
+  browser->StopEmbedding();
+  browser->SetTabTitle("Event Control", 0);
+
+  // the summary tab
+  htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table");
+  TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
+  gHtml_ = new TGHtml(0, 100, 100);
+  TEveWindowFrame *wf = slot->MakeFrame(gHtml_);
+  gHtml_->MapSubwindows();
+  wf->SetElementName("Summary tables");
+
+  // plot tab
+  slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
+  TEveWindowTab *tab = slot->MakeTab();
+  tab->SetElementName("Summary plots");
+  tab->SetShowTitleBar(kFALSE);
+  plotSummary_ = new DelphesPlotSummary(tab);
+  plotSummary_->Init(elements_);
+  plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)");
+}
+
+void DelphesEventDisplay::Fwd()
+{
+  if(event_id_ < treeReader_->GetEntries() - 2)
+  {
+    EventChanged(event_id_ + 1);
+  }
+  else
+  {
+    printf("Already at last event.\n");
+  }
+}
+
+void DelphesEventDisplay::Bck()
+{
+  if(event_id_ > 0)
+  {
+    EventChanged(event_id_ - 1);
+  }
+  else
+  {
+    printf("Already at first event.\n");
+  }
+}
+
+void DelphesEventDisplay::PreSetEv(char *ev)
+{
   event_id_tmp_ = Int_t(atoi(ev));
 }
 
-void DelphesEventDisplay::GoTo() {
-  if (event_id_tmp_>=0 && event_id_tmp_ < treeReader_->GetEntries()-1) {
+void DelphesEventDisplay::GoTo()
+{
+  if(event_id_tmp_ >= 0 && event_id_tmp_ < treeReader_->GetEntries() - 1)
+  {
     EventChanged(event_id_tmp_);
-  } else {
+  }
+  else
+  {
     printf("Error: no such event.\n");
   }
 }
 
-void DelphesEventDisplay::InitSummaryPlots() {
+void DelphesEventDisplay::InitSummaryPlots()
+{
   plotSummary_->FillSample(treeReader_, event_id_);
   plotSummary_->FillEvent();
@@ -480,6 +522,7 @@
 }
 
-void DelphesEventDisplay::DisplayProgress(Int_t p) { 
-  fStatusBar_->SetText(Form("Processing... %d %%",p), 1);
+void DelphesEventDisplay::DisplayProgress(Int_t p)
+{
+  fStatusBar_->SetText(Form("Processing... %d %%", p), 1);
   gSystem->ProcessEvents();
 }
Index: display/DelphesEventDisplay.h
===================================================================
--- display/DelphesEventDisplay.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesEventDisplay.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -22,6 +22,6 @@
 #include <vector>
 
+#include "RQ_OBJECT.h"
 #include "Rtypes.h"
-#include "RQ_OBJECT.h"
 
 class TAxis;
@@ -45,44 +45,44 @@
 class DelphesEventDisplay
 {
-    RQ_OBJECT("DelphesEventDisplay")
-  public:
-    DelphesEventDisplay();
-    DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D);
-    ~DelphesEventDisplay();
-    void EventChanged(Int_t); // *SIGNAL*
+  RQ_OBJECT("DelphesEventDisplay")
+public:
+  DelphesEventDisplay();
+  DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry &det3D);
+  ~DelphesEventDisplay();
+  void EventChanged(Int_t); // *SIGNAL*
 
-  private:
-    void update_html_summary();
-    void make_gui();
-    void load_event();
-    void readConfig(const char *configFile, std::vector<DelphesBranchBase *>& elements);
+private:
+  void update_html_summary();
+  void make_gui();
+  void load_event();
+  void readConfig(const char *configFile, std::vector<DelphesBranchBase *> &elements);
 
-    // Configuration and global variables.
-    Int_t event_id_;
-    Int_t event_id_tmp_;
-    ExRootTreeReader *treeReader_;
-    Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_;
-    TAxis *etaAxis_, *phiAxis_;
-    TChain *chain_;
-    std::vector<DelphesBranchBase *> elements_;
-    DelphesDisplay *delphesDisplay_;
-    DelphesHtmlSummary *htmlSummary_;
-    TGHtml *gHtml_;
-    DelphesPlotSummary *plotSummary_;
-    TGStatusBar *fStatusBar_;
-    
-    // gui controls
-  public:
-     void Fwd();
+  // Configuration and global variables.
+  Int_t event_id_;
+  Int_t event_id_tmp_;
+  ExRootTreeReader *treeReader_;
+  Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_;
+  TAxis *etaAxis_, *phiAxis_;
+  TChain *chain_;
+  std::vector<DelphesBranchBase *> elements_;
+  DelphesDisplay *delphesDisplay_;
+  DelphesHtmlSummary *htmlSummary_;
+  TGHtml *gHtml_;
+  DelphesPlotSummary *plotSummary_;
+  TGStatusBar *fStatusBar_;
 
-     void Bck();
+  // gui controls
+public:
+  void Fwd();
 
-    void PreSetEv(char *ev);
+  void Bck();
 
-    void GoTo();
+  void PreSetEv(char *ev);
 
-    void InitSummaryPlots();
+  void GoTo();
 
-    void DisplayProgress(Int_t p);
+  void InitSummaryPlots();
+
+  void DisplayProgress(Int_t p);
 };
 
Index: display/DelphesHtmlSummary.cc
===================================================================
--- display/DelphesHtmlSummary.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesHtmlSummary.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -18,28 +18,28 @@
 
 #include "display/DelphesHtmlSummary.h"
-#include "TGHtml.h"
 #include "TEveElement.h"
+#include "TEveEventManager.h"
 #include "TEveManager.h"
-#include "TEveEventManager.h"
 #include "TEvePointSet.h"
 #include "TEveTrack.h"
+#include "TGHtml.h"
 
 //==============================================================================
 
 DelphesHtmlSummary *fgDelphesHtmlSummary = 0;
-TGHtml      *fgHtml        = 0;
+TGHtml *fgHtml = 0;
 
 //==============================================================================
 
 //______________________________________________________________________________
-DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) : 
-   fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
-{
-   // Constructor.
-
-   fValues = new TArrayF[fNFields];
-   for (int i=0;i<fNFields;i++)
-      fValues[i].Set(nvals);
-   fLabels = new TString[fNFields];
+DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) :
+  fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
+{
+  // Constructor.
+
+  fValues = new TArrayF[fNFields];
+  for(int i = 0; i < fNFields; i++)
+    fValues[i].Set(nvals);
+  fLabels = new TString[fNFields];
 }
 
@@ -47,8 +47,8 @@
 DelphesHtmlObjTable::~DelphesHtmlObjTable()
 {
-   // Destructor.
-
-   delete [] fValues;
-   delete [] fLabels;
+  // Destructor.
+
+  delete[] fValues;
+  delete[] fLabels;
 }
 
@@ -56,15 +56,16 @@
 void DelphesHtmlObjTable::Build()
 {
-   // Build HTML code.
-
-   fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
-
-   BuildTitle();
-   if (fExpand && (fNFields > 0) && (fNValues > 0)) {
-      BuildLabels();
-      BuildTable();
-   }
-
-   fHtml += "</table>";
+  // Build HTML code.
+
+  fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
+
+  BuildTitle();
+  if(fExpand && (fNFields > 0) && (fNValues > 0))
+  {
+    BuildLabels();
+    BuildTable();
+  }
+
+  fHtml += "</table>";
 }
 
@@ -72,20 +73,20 @@
 void DelphesHtmlObjTable::BuildTitle()
 {
-   // Build table title.
-   
-   fHtml += "<tr><td colspan=";
-   fHtml += Form("%d>", fNFields+1);
-   fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
-   fHtml += "<tr><td align=left>";
-   fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
-   fHtml += fName;
-   fHtml += "</i></b></font></td>";
-   fHtml += "<td>";
-   fHtml += "<td align=right> ";
-   fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
-   fHtml += Form("Size = %d", fNValues);
-   fHtml += "</i></b></font></td></tr>";
-   fHtml += "</table>";
-   fHtml += "</td></tr>";
+  // Build table title.
+
+  fHtml += "<tr><td colspan=";
+  fHtml += Form("%d>", fNFields + 1);
+  fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
+  fHtml += "<tr><td align=left>";
+  fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
+  fHtml += fName;
+  fHtml += "</i></b></font></td>";
+  fHtml += "<td>";
+  fHtml += "<td align=right> ";
+  fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
+  fHtml += Form("Size = %d", fNValues);
+  fHtml += "</i></b></font></td></tr>";
+  fHtml += "</table>";
+  fHtml += "</td></tr>";
 }
 
@@ -93,15 +94,16 @@
 void DelphesHtmlObjTable::BuildLabels()
 {
-   // Build table labels.
-
-   Int_t i;
-   fHtml += "<tr bgcolor=c0c0ff>";
-   fHtml += "<th> </th>"; // for the check boxes
-   for (i=0;i<fNFields;i++) {
-      fHtml += "<th> ";
-      fHtml += fLabels[i];
-      fHtml += " </th>"; // for the check boxes
-   }
-   fHtml += "</tr>";
+  // Build table labels.
+
+  Int_t i;
+  fHtml += "<tr bgcolor=c0c0ff>";
+  fHtml += "<th> </th>"; // for the check boxes
+  for(i = 0; i < fNFields; i++)
+  {
+    fHtml += "<th> ";
+    fHtml += fLabels[i];
+    fHtml += " </th>"; // for the check boxes
+  }
+  fHtml += "</tr>";
 }
 
@@ -109,39 +111,42 @@
 void DelphesHtmlObjTable::BuildTable()
 {
-   // Build part of table with values.
-
-   for (int i = 0; i < fNValues; i++) {
-      if (i%2)
-         fHtml += "<tr bgcolor=e0e0ff>";
-      else
-         fHtml += "<tr bgcolor=ffffff>";
-      
-      TString name = fName;
-      name.ReplaceAll(" ", "_");
-      // checkboxes
-      fHtml += "<td bgcolor=d0d0ff align=\"center\">";
-      fHtml += "<input type=\"checkbox\" name=\"";
-      fHtml += name;
-      fHtml += Form("[%d]\">",i);
+  // Build part of table with values.
+
+  for(int i = 0; i < fNValues; i++)
+  {
+    if(i % 2)
+      fHtml += "<tr bgcolor=e0e0ff>";
+    else
+      fHtml += "<tr bgcolor=ffffff>";
+
+    TString name = fName;
+    name.ReplaceAll(" ", "_");
+    // checkboxes
+    fHtml += "<td bgcolor=d0d0ff align=\"center\">";
+    fHtml += "<input type=\"checkbox\" name=\"";
+    fHtml += name;
+    fHtml += Form("[%d]\">", i);
+    fHtml += "</td>";
+
+    for(int j = 0; j < fNFields; j++)
+    {
+      fHtml += "<td width=";
+      fHtml += Form("%d%%", 100 / fNFields);
+      fHtml += " align=\"center\"";
+      fHtml += ">";
+      fHtml += Form("%1.4f", fValues[j][i]);
       fHtml += "</td>";
-
-      for (int j = 0; j < fNFields; j++) {
-         fHtml += "<td width=";
-         fHtml += Form("%d%%", 100/fNFields);
-         fHtml += " align=\"center\"";
-         fHtml += ">";
-         fHtml += Form("%1.4f", fValues[j][i]);
-         fHtml += "</td>";
-      }
-      fHtml += "</tr> ";
-   }
-}
-
-//______________________________________________________________________________
-DelphesHtmlSummary::DelphesHtmlSummary(const char *title) : fNTables(0), fTitle(title)
-{
-   // Constructor.
-
-   fObjTables = new TOrdCollection();
+    }
+    fHtml += "</tr> ";
+  }
+}
+
+//______________________________________________________________________________
+DelphesHtmlSummary::DelphesHtmlSummary(const char *title) :
+  fNTables(0), fTitle(title)
+{
+  // Constructor.
+
+  fObjTables = new TOrdCollection();
 }
 
@@ -149,24 +154,24 @@
 DelphesHtmlSummary::~DelphesHtmlSummary()
 {
-   // Destructor.
-
-   Reset();
+  // Destructor.
+
+  Reset();
 }
 
 //______________________________________________________________________________
 DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
-                                    Bool_t exp, Option_t *option)
-{
-   // Add a new table in our list of tables.
-
-   TString opt = option;
-   opt.ToLower();
-   DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp);
-   fNTables++;
-   if (opt.Contains("first"))
-      fObjTables->AddFirst(table);
-   else
-      fObjTables->Add(table);
-   return table;
+  Bool_t exp, Option_t *option)
+{
+  // Add a new table in our list of tables.
+
+  TString opt = option;
+  opt.ToLower();
+  DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp);
+  fNTables++;
+  if(opt.Contains("first"))
+    fObjTables->AddFirst(table);
+  else
+    fObjTables->Add(table);
+  return table;
 }
 
@@ -174,11 +179,11 @@
 void DelphesHtmlSummary::Clear(Option_t *option)
 {
-   // Clear the table list.
-
-   if (option && option[0] == 'D')
-      fObjTables->Delete(option);
-   else
-      fObjTables->Clear(option);
-   fNTables = 0;
+  // Clear the table list.
+
+  if(option && option[0] == 'D')
+    fObjTables->Delete(option);
+  else
+    fObjTables->Clear(option);
+  fNTables = 0;
 }
 
@@ -186,8 +191,9 @@
 void DelphesHtmlSummary::Reset(Option_t *)
 {
-   // Reset (delete) the table list;
-
-   delete fObjTables; fObjTables = 0;
-   fNTables = 0;
+  // Reset (delete) the table list;
+
+  delete fObjTables;
+  fObjTables = 0;
+  fNTables = 0;
 }
 
@@ -195,12 +201,13 @@
 void DelphesHtmlSummary::Build()
 {
-   // Build the summary.
-
-   MakeHeader();
-   for (int i=0;i<fNTables;i++) {
-      GetTable(i)->Build();
-      fHtml += GetTable(i)->Html();
-   }
-   MakeFooter();
+  // Build the summary.
+
+  MakeHeader();
+  for(int i = 0; i < fNTables; i++)
+  {
+    GetTable(i)->Build();
+    fHtml += GetTable(i)->Html();
+  }
+  MakeFooter();
 }
 
@@ -208,13 +215,13 @@
 void DelphesHtmlSummary::MakeHeader()
 {
-   // Make HTML header.
-
-   fHeader  = "<html><head><title>";
-   fHeader += fTitle;
-   fHeader += "</title></head><body>";
-   fHeader += "<center><h2><font color=#2222ee><i>";
-   fHeader += fTitle;
-   fHeader += "</i></font></h2></center>";
-   fHtml    = fHeader;
+  // Make HTML header.
+
+  fHeader = "<html><head><title>";
+  fHeader += fTitle;
+  fHeader += "</title></head><body>";
+  fHeader += "<center><h2><font color=#2222ee><i>";
+  fHeader += fTitle;
+  fHeader += "</i></font></h2></center>";
+  fHtml = fHeader;
 }
 
@@ -222,12 +229,11 @@
 void DelphesHtmlSummary::MakeFooter()
 {
-   // Make HTML footer.
-
-   fFooter  = "<br><p><br><center><strong><font size=2 color=#2222ee>";
-   fFooter += "Example of using Html widget to display tabular data";
-   fFooter += "<br>";
-   fFooter += "(c) 2007-2010 Bertrand Bellenot";
-   fFooter += "</font></strong></center></body></html>";  
-   fHtml   += fFooter;
-}
-
+  // Make HTML footer.
+
+  fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
+  fFooter += "Example of using Html widget to display tabular data";
+  fFooter += "<br>";
+  fFooter += "(c) 2007-2010 Bertrand Bellenot";
+  fFooter += "</font></strong></center></body></html>";
+  fHtml += fFooter;
+}
Index: display/DelphesHtmlSummary.h
===================================================================
--- display/DelphesHtmlSummary.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesHtmlSummary.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -17,41 +17,39 @@
  */
 
-// Delphes HTML table for the event display. 
+// Delphes HTML table for the event display.
 // Based on the ROOT example "alice_esd_html_summary.C"
 
 #ifndef DelphesHtmlSummary_h
-#define DelphesHtmlSummary_h 
+#define DelphesHtmlSummary_h
 
 #include "TArrayF.h"
 #include "TOrdCollection.h"
 
+class DelphesHtmlObjTable: public TObject
+{
+public: // make them public for shorter code
+  TString fName;
+  Int_t fNValues; // number of values
+  Int_t fNFields; // number of fields
+  TArrayF *fValues;
+  TString *fLabels;
+  Bool_t fExpand;
 
-class DelphesHtmlObjTable : public TObject
-{
-public:                     // make them public for shorter code
+  TString fHtml; // HTML output code
 
-   TString   fName;
-   Int_t     fNValues;      // number of values
-   Int_t     fNFields;      // number of fields
-   TArrayF  *fValues;
-   TString  *fLabels;
-   Bool_t    fExpand;
-
-   TString   fHtml;         // HTML output code
-
-   void Build();
-   void BuildTitle();
-   void BuildLabels();
-   void BuildTable();
+  void Build();
+  void BuildTitle();
+  void BuildLabels();
+  void BuildTable();
 
 public:
-   DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
-   virtual ~DelphesHtmlObjTable();
+  DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp = kTRUE);
+  virtual ~DelphesHtmlObjTable();
 
-   void     SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
-   void     SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
-   TString  Html() const { return fHtml; }
+  void SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
+  void SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
+  TString Html() const { return fHtml; }
 
-   ClassDef(DelphesHtmlObjTable, 0);
+  ClassDef(DelphesHtmlObjTable, 0);
 };
 
@@ -60,28 +58,28 @@
 class DelphesHtmlSummary
 {
-public:                           // make them public for shorter code
-   Int_t           fNTables;
-   TOrdCollection *fObjTables;    // ->array of object tables
-   TString         fHtml;         // output HTML string
-   TString         fTitle;        // page title
-   TString         fHeader;       // HTML header
-   TString         fFooter;       // HTML footer
+public: // make them public for shorter code
+  Int_t fNTables;
+  TOrdCollection *fObjTables; // ->array of object tables
+  TString fHtml; // output HTML string
+  TString fTitle; // page title
+  TString fHeader; // HTML header
+  TString fFooter; // HTML footer
 
-   void     MakeHeader();
-   void     MakeFooter();
+  void MakeHeader();
+  void MakeFooter();
 
 public:
-   DelphesHtmlSummary(const char *title);
-   virtual ~DelphesHtmlSummary();
+  DelphesHtmlSummary(const char *title);
+  virtual ~DelphesHtmlSummary();
 
-   DelphesHtmlObjTable  *AddTable(const char *name, Int_t nfields, Int_t nvals, 
-                           Bool_t exp=kTRUE, Option_t *opt="");
-   DelphesHtmlObjTable  *GetTable(Int_t at) const { return (DelphesHtmlObjTable *)fObjTables->At(at); }
-   void           Build();
-   void           Clear(Option_t *option="");
-   void           Reset(Option_t *option="");
-   TString        Html() const { return fHtml; }
+  DelphesHtmlObjTable *AddTable(const char *name, Int_t nfields, Int_t nvals,
+    Bool_t exp = kTRUE, Option_t *opt = "");
+  DelphesHtmlObjTable *GetTable(Int_t at) const { return (DelphesHtmlObjTable *)fObjTables->At(at); }
+  void Build();
+  void Clear(Option_t *option = "");
+  void Reset(Option_t *option = "");
+  TString Html() const { return fHtml; }
 
-   ClassDef(DelphesHtmlSummary, 0);
+  ClassDef(DelphesHtmlSummary, 0);
 };
 
Index: display/DelphesPlotSummary.cc
===================================================================
--- display/DelphesPlotSummary.cc	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesPlotSummary.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -21,7 +21,8 @@
 #include <algorithm>
 
-bool vecsorter (TLorentzVector i,TLorentzVector j) { return (i.Pt()>j.Pt()); }
-
-DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {}
+bool vecsorter(TLorentzVector i, TLorentzVector j) { return (i.Pt() > j.Pt()); }
+
+DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab *tab) :
+  tab_(tab) {}
 
 DelphesPlotSummary::~DelphesPlotSummary() {}
@@ -29,47 +30,55 @@
 void DelphesPlotSummary::Progress(Int_t p)
 {
-  Emit("Progress(Int_t)",p);
-}
-
-void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) {
+  Emit("Progress(Int_t)", p);
+}
+
+void DelphesPlotSummary::Init(std::vector<DelphesBranchBase *> &elements)
+{
   elements_ = &elements;
   // loop on the elements, and create tabs
-  for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) {
+  for(std::vector<DelphesBranchBase *>::iterator data = elements.begin(); data < elements.end(); ++data)
+  {
     // the canvas
-    TEveWindowSlot* slot = tab_->NewSlot();
-    TRootEmbeddedCanvas* trec = new TRootEmbeddedCanvas();
-    TCanvas* canvas = trec->GetCanvas();
-    TEveWindowFrame * wf = slot->MakeFrame(trec);
+    TEveWindowSlot *slot = tab_->NewSlot();
+    TRootEmbeddedCanvas *trec = new TRootEmbeddedCanvas();
+    TCanvas *canvas = trec->GetCanvas();
+    TEveWindowFrame *wf = slot->MakeFrame(trec);
     wf->SetElementName((*data)->GetName());
-    canvas->Divide(3,3);
+    canvas->Divide(3, 3);
     canvases_[(*data)->GetName()] = canvas;
     // the histograms
-    TH1F* h;
-    std::vector<TH1F*> histograms;
+    TH1F *h;
+    std::vector<TH1F *> histograms;
     histograms.reserve(9);
-    h = new TH1F(Form("%sPt",(*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("%sEta",(*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("%sPhi",(*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("l%sPt",(*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("l%sEta",(*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("l%sPhi",(*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("sl%sPt",(*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("sl%sEta",(*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1);
-    histograms.push_back(h);
-    h = new TH1F(Form("sl%sPhi",(*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1);
+    h = new TH1F(Form("%sPt", (*data)->GetName()), Form("%s Pt", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("%sEta", (*data)->GetName()), Form("%s Eta", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("%sPhi", (*data)->GetName()), Form("%s Phi", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("l%sPt", (*data)->GetName()), Form("leading %s Pt", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("l%sEta", (*data)->GetName()), Form("leading %s Eta", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("l%sPhi", (*data)->GetName()), Form("leading %s Phi", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("sl%sPt", (*data)->GetName()), Form("subleading %s Pt", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("sl%sEta", (*data)->GetName()), Form("subleading %s Eta", (*data)->GetName()), 100, 0, -1);
+    histograms.push_back(h);
+    h = new TH1F(Form("sl%sPhi", (*data)->GetName()), Form("subleading %s Phi", (*data)->GetName()), 100, 0, -1);
     histograms.push_back(h);
     histograms_[(*data)->GetName()] = histograms;
     // the event histograms
-    TH1F* h1 = (TH1F*)histograms[0]->Clone(); h1->Reset(); h1->SetLineColor(kBlue);
-    TH1F* h2 = (TH1F*)histograms[1]->Clone(); h2->Reset(); h2->SetLineColor(kBlue);
-    TH1F* h3 = (TH1F*)histograms[2]->Clone(); h3->Reset(); h3->SetLineColor(kBlue);
-    std::vector<TH1F*> hv;
+    TH1F *h1 = (TH1F *)histograms[0]->Clone();
+    h1->Reset();
+    h1->SetLineColor(kBlue);
+    TH1F *h2 = (TH1F *)histograms[1]->Clone();
+    h2->Reset();
+    h2->SetLineColor(kBlue);
+    TH1F *h3 = (TH1F *)histograms[2]->Clone();
+    h3->Reset();
+    h3->SetLineColor(kBlue);
+    std::vector<TH1F *> hv;
     hv.push_back(h1);
     hv.push_back(h2);
@@ -78,16 +87,28 @@
     // the event markers
     TMarker *m;
-    std::vector<TMarker*> mv;
-    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
-    mv.push_back(m);
-    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
-    mv.push_back(m);
-    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
-    mv.push_back(m);
-    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
-    mv.push_back(m);
-    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
-    mv.push_back(m);
-    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
+    std::vector<TMarker *> mv;
+    m = new TMarker(0, 0, 29);
+    m->SetMarkerColor(kBlue);
+    m->SetMarkerSize(3);
+    mv.push_back(m);
+    m = new TMarker(0, 0, 29);
+    m->SetMarkerColor(kBlue);
+    m->SetMarkerSize(3);
+    mv.push_back(m);
+    m = new TMarker(0, 0, 29);
+    m->SetMarkerColor(kBlue);
+    m->SetMarkerSize(3);
+    mv.push_back(m);
+    m = new TMarker(0, 0, 29);
+    m->SetMarkerColor(kBlue);
+    m->SetMarkerSize(3);
+    mv.push_back(m);
+    m = new TMarker(0, 0, 29);
+    m->SetMarkerColor(kBlue);
+    m->SetMarkerSize(3);
+    mv.push_back(m);
+    m = new TMarker(0, 0, 29);
+    m->SetMarkerColor(kBlue);
+    m->SetMarkerSize(3);
     mv.push_back(m);
     eventMarkers_[(*data)->GetName()] = mv;
@@ -95,22 +116,28 @@
 }
 
-void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) {
+void DelphesPlotSummary::FillSample(ExRootTreeReader *treeReader, Int_t event_id)
+{
   Int_t entries = treeReader->GetEntries();
-  for(Int_t i=0;i<entries;++i) {
+  for(Int_t i = 0; i < entries; ++i)
+  {
     treeReader->ReadEntry(i);
-    for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
+    for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element)
+    {
       std::vector<TLorentzVector> vectors = (*element)->GetVectors();
-      std::sort(vectors.begin(), vectors.end(), vecsorter); 
-      std::vector<TH1F*> histograms = histograms_[(*element)->GetName()];
-      for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) {
+      std::sort(vectors.begin(), vectors.end(), vecsorter);
+      std::vector<TH1F *> histograms = histograms_[(*element)->GetName()];
+      for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it)
+      {
         histograms[0]->Fill(it->Pt());
         histograms[1]->Fill(it->Eta());
         histograms[2]->Fill(it->Phi());
-        if(it==vectors.begin()) {
+        if(it == vectors.begin())
+        {
           histograms[3]->Fill(it->Pt());
           histograms[4]->Fill(it->Eta());
           histograms[5]->Fill(it->Phi());
         }
-        if(it==vectors.begin()+1) {
+        if(it == vectors.begin() + 1)
+        {
           histograms[6]->Fill(it->Pt());
           histograms[7]->Fill(it->Eta());
@@ -119,5 +146,5 @@
       }
     }
-    Progress(int(100*i/entries));
+    Progress(int(100 * i / entries));
   }
   treeReader->ReadEntry(event_id);
@@ -125,60 +152,84 @@
 }
 
-void DelphesPlotSummary::Draw() {
-  for(std::map< TString, TCanvas* >::iterator it=canvases_.begin(); it!=canvases_.end(); ++it) {
-    TCanvas* c = it->second;
-    std::vector<TH1F*> histograms = histograms_[it->first];
-    std::vector<TH1F*> eventProfiles = eventProfiles_[it->first];
-    std::vector<TMarker*> eventMarkers = eventMarkers_[it->first];
-    for(Int_t i=0;i<9;++i) {
-      c->cd(i+1);
-      if(histograms[i]->GetEntries()==0) continue;
+void DelphesPlotSummary::Draw()
+{
+  for(std::map<TString, TCanvas *>::iterator it = canvases_.begin(); it != canvases_.end(); ++it)
+  {
+    TCanvas *c = it->second;
+    std::vector<TH1F *> histograms = histograms_[it->first];
+    std::vector<TH1F *> eventProfiles = eventProfiles_[it->first];
+    std::vector<TMarker *> eventMarkers = eventMarkers_[it->first];
+    for(Int_t i = 0; i < 9; ++i)
+    {
+      c->cd(i + 1);
+      if(histograms[i]->GetEntries() == 0) continue;
       histograms[i]->Draw();
-      if(i<3) {
+      if(i < 3)
+      {
         eventProfiles[i]->Draw("same");
-      } else {
-        eventMarkers[i-3]->Draw("same");
+      }
+      else
+      {
+        eventMarkers[i - 3]->Draw("same");
       }
     }
     c->Update();
-  } 
-}
-
-void DelphesPlotSummary::FillEvent() {
+  }
+}
+
+void DelphesPlotSummary::FillEvent()
+{
   // clear event histograms and markers
-  for(std::map< TString, std::vector<TH1F*> >::iterator hv = eventProfiles_.begin(); hv!=eventProfiles_.end();++hv) {
-    for(std::vector<TH1F*>::iterator h = hv->second.begin(); h<hv->second.end();++h) {
+  for(std::map<TString, std::vector<TH1F *>>::iterator hv = eventProfiles_.begin(); hv != eventProfiles_.end(); ++hv)
+  {
+    for(std::vector<TH1F *>::iterator h = hv->second.begin(); h < hv->second.end(); ++h)
+    {
       (*h)->Reset();
     }
   }
-  for(std::map< TString, std::vector<TMarker*> >::iterator mv = eventMarkers_.begin(); mv!=eventMarkers_.end();++mv) {
-    for(std::vector<TMarker*>::iterator m = mv->second.begin(); m<mv->second.end();++m) {
+  for(std::map<TString, std::vector<TMarker *>>::iterator mv = eventMarkers_.begin(); mv != eventMarkers_.end(); ++mv)
+  {
+    for(std::vector<TMarker *>::iterator m = mv->second.begin(); m < mv->second.end(); ++m)
+    {
       (*m)->SetMarkerSize(0);
     }
   }
   // loop over the elements and fill markers with event data
-  for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
+  for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element)
+  {
     std::vector<TLorentzVector> vectors = (*element)->GetVectors();
-    std::sort(vectors.begin(), vectors.end(), vecsorter); 
-    std::vector<TH1F*> hv = eventProfiles_[(*element)->GetName()];
-    TH1F* h1 = hv[0]; h1->Reset();
-    TH1F* h2 = hv[1]; h1->Reset();
-    TH1F* h3 = hv[2]; h1->Reset();
-    std::vector<TMarker*> mv = eventMarkers_[(*element)->GetName()];
-    for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) {
+    std::sort(vectors.begin(), vectors.end(), vecsorter);
+    std::vector<TH1F *> hv = eventProfiles_[(*element)->GetName()];
+    TH1F *h1 = hv[0];
+    h1->Reset();
+    TH1F *h2 = hv[1];
+    h1->Reset();
+    TH1F *h3 = hv[2];
+    h1->Reset();
+    std::vector<TMarker *> mv = eventMarkers_[(*element)->GetName()];
+    for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it)
+    {
       h1->Fill(it->Pt());
       h2->Fill(it->Eta());
       h3->Fill(it->Phi());
-      if(it==vectors.begin()) {
-        mv[0]->SetX(it->Pt()); mv[0]->SetMarkerSize(3);
-        mv[1]->SetX(it->Eta()); mv[1]->SetMarkerSize(3);
-        mv[2]->SetX(it->Phi()); mv[2]->SetMarkerSize(3);
-      }
-      if(it==vectors.begin()+1) {
-        mv[3]->SetX(it->Pt()); mv[3]->SetMarkerSize(3);
-        mv[4]->SetX(it->Eta()); mv[4]->SetMarkerSize(3);
-        mv[5]->SetX(it->Phi()); mv[5]->SetMarkerSize(3);
-      }
-    }
-  }
-}
+      if(it == vectors.begin())
+      {
+        mv[0]->SetX(it->Pt());
+        mv[0]->SetMarkerSize(3);
+        mv[1]->SetX(it->Eta());
+        mv[1]->SetMarkerSize(3);
+        mv[2]->SetX(it->Phi());
+        mv[2]->SetMarkerSize(3);
+      }
+      if(it == vectors.begin() + 1)
+      {
+        mv[3]->SetX(it->Pt());
+        mv[3]->SetMarkerSize(3);
+        mv[4]->SetX(it->Eta());
+        mv[4]->SetMarkerSize(3);
+        mv[5]->SetX(it->Phi());
+        mv[5]->SetMarkerSize(3);
+      }
+    }
+  }
+}
Index: display/DelphesPlotSummary.h
===================================================================
--- display/DelphesPlotSummary.h	(revision 0ac1afd86220730c399ac9a205fa9ac568125c95)
+++ display/DelphesPlotSummary.h	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -20,37 +20,34 @@
 #define DelphesPlotSummary_h
 
-#include <vector>
-#include <map>
-#include "TString.h"
-#include "TH1F.h"
+#include "DelphesBranchElement.h"
 #include "TCanvas.h"
 #include "TEveWindow.h"
-#include "DelphesBranchElement.h"
+#include "TH1F.h"
+#include "TString.h"
 #include "external/ExRootAnalysis/ExRootTreeReader.h"
 #include <RQ_OBJECT.h>
-
+#include <map>
+#include <vector>
 
 class DelphesPlotSummary
 {
-    RQ_OBJECT("DelphesPlotSummary")
-  public:
-    DelphesPlotSummary(TEveWindowTab* tab);
-    virtual ~DelphesPlotSummary();
-    void Init(std::vector<DelphesBranchBase*>& elements);
-    void FillSample(ExRootTreeReader* treeReader, Int_t event_id);
-    void FillEvent();
-    void Draw();
-    void Progress(Int_t); // *SIGNAL*
+  RQ_OBJECT("DelphesPlotSummary")
+public:
+  DelphesPlotSummary(TEveWindowTab *tab);
+  virtual ~DelphesPlotSummary();
+  void Init(std::vector<DelphesBranchBase *> &elements);
+  void FillSample(ExRootTreeReader *treeReader, Int_t event_id);
+  void FillEvent();
+  void Draw();
+  void Progress(Int_t); // *SIGNAL*
 
-  private:
-    TEveWindowTab* tab_;
-    std::map< TString, TCanvas* >           canvases_;
-    std::map< TString, std::vector<TH1F*> > histograms_;
-    std::vector<DelphesBranchBase*>* elements_;
-    std::map< TString, std::vector<TMarker*> > eventMarkers_;
-    std::map< TString, std::vector<TH1F*> > eventProfiles_;
-
+private:
+  TEveWindowTab *tab_;
+  std::map<TString, TCanvas *> canvases_;
+  std::map<TString, std::vector<TH1F *>> histograms_;
+  std::vector<DelphesBranchBase *> *elements_;
+  std::map<TString, std::vector<TMarker *>> eventMarkers_;
+  std::map<TString, std::vector<TH1F *>> eventProfiles_;
 };
 
 #endif // DelphesPlotSummary_h
-
