Index: examples/geometry.C
===================================================================
--- examples/geometry.C	(revision 1d42548bd4ed311a7d84a50af72652fb2ff77a0d)
+++ examples/geometry.C	(revision df634866c9818edc469dde5613f93338d3e24ba7)
@@ -3,4 +3,5 @@
 #include <utility>
 #include <vector>
+#include <algorithm>
 #include "TGeoManager.h"
 #include "TGeoVolume.h"
@@ -39,8 +40,8 @@
 
    private:
-     void addTracker(TGeoVolume *top);
-     void addCalorimeters(TGeoVolume *top);
-     void addMuonDets(TGeoVolume *top);
-     void addCaloTowers(TGeoVolume *top);
+     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, set< 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, set< pair<Double_t, Int_t> >& caloBinning);
 
    private:
@@ -60,16 +61,10 @@
      Double_t tk_length_;
      Double_t tk_etamax_;
-     Double_t calo_endcap_etamax_;
-     Double_t muonSystem_etamax_;
-     Double_t calo_barrel_innerRadius_;
-     Double_t calo_endcap_etamin_;
-     Double_t calo_endcap_innerRadius1_;
-     Double_t calo_endcap_innerRadius2_;
-     Double_t calo_endcap_outerRadius1_;
-     Double_t calo_endcap_outerRadius2_;
-     Double_t calo_endcap_coneThickness_;
-     Double_t calo_endcap_diskThickness_;
-
-     set< pair<Double_t, Int_t> > caloBinning_;
+
+     std::vector<std::string> calorimeters_;
+     std::vector<std::string> muondets_;
+
+     std::map<std::string, Double_t> muonSystem_etamax_;
+     std::map<std::string, set< pair<Double_t, Int_t> > > caloBinning_;
      
 };
@@ -96,5 +91,5 @@
    calo_barrel_thickness_ = 50.;
    calo_endcap_thickness_ = 75.;
-   muonSystem_thickn_ = contingency_;
+   muonSystem_thickn_ = 10.;
 
    // read these parameters from the Delphes Card (with default values)
@@ -102,6 +97,4 @@
    tk_length_ = 150.;
    tk_etamax_ = 3.0;
-   calo_endcap_etamax_ = 2.6;
-   muonSystem_etamax_  = 2.4;
 }
 
@@ -138,4 +131,5 @@
 
    {
+   muondets_.push_back("muons");
    TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0");
    muonEffFormula.ReplaceAll("pt","x");
@@ -154,31 +148,31 @@
    bin = etaHisto.FindLastBinAbove(0.5);
    Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
-   muonSystem_etamax_ = TMath::Max(fabs(etamin),fabs(etamax));				// muonSystem_etamax
+   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
-   ExRootConfParam paramEtaBins, paramPhiBins;
-   ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",Calorimeters));
-   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));
-   }
-
-   if (size>0) calo_endcap_etamax_ = TMath::Max(fabs(caloBinning_.begin()->first),fabs(caloBinning_.rbegin()->first)); // calo_endcap_etamax_
+   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;
+   }
 
    delete confReader;
 
-   calo_barrel_innerRadius_   = tk_radius_+contingency_;
-   calo_endcap_etamin_        = -log(tk_radius_/(2*tk_length_));
-   calo_endcap_innerRadius1_  = tk_length_*2.*exp(-calo_endcap_etamax_)/(1-exp(-2.*calo_endcap_etamax_));
-   calo_endcap_innerRadius2_  = (tk_length_+calo_endcap_thickness_)*2.*exp(-calo_endcap_etamax_)/(1-exp(-2.*calo_endcap_etamax_));
-   calo_endcap_outerRadius1_  = tk_radius_;
-   calo_endcap_outerRadius2_  = tk_radius_+calo_barrel_thickness_;
-   calo_endcap_coneThickness_ = calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin_)) / (2.*exp(-calo_endcap_etamin_));
-   calo_endcap_diskThickness_ = TMath::Max(0.,calo_endcap_thickness_-calo_endcap_coneThickness_);
 }
 
@@ -186,13 +180,23 @@
    // compute the envelope
    Double_t system_radius = tk_radius_+calo_barrel_thickness_+3*contingency_;
-   Double_t system_length = tk_length_+TMath::Max(calo_endcap_coneThickness_,calo_endcap_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
-   addTracker(top);
-   addCalorimeters(top); // TODO: allow for more than one calo
-   addMuonDets(top);
-   if (withTowers) {
-     addCaloTowers(top);
+   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
@@ -200,6 +204,5 @@
 }
 
-//typically from ChargedHadronTrackingEfficiency 
-void Delphes3DGeometry::addTracker(TGeoVolume *top) {
+std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) {
    // tracker: a cylinder with two cones substracted
    TGeoCone* forwardCone = new TGeoCone("forwardTkAcceptance",(tk_length_/2.+0.05),0.,tk_radius_,(tk_length_)*2.*exp(-tk_etamax_)/(1-exp(-2.*tk_etamax_)),tk_radius_);
@@ -214,27 +217,41 @@
    tracker->SetLineColor(kYellow);
    top->AddNode(tracker,1);
-}
-
-void Delphes3DGeometry::addCalorimeters(TGeoVolume *top) {
+   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
-   
-   /*TGeoTube *calo_barrel_cylinder =*/ new TGeoTube("calo_barrel_cylinder",calo_barrel_innerRadius_,tk_radius_+calo_barrel_thickness_+contingency_,tk_length_+calo_barrel_thickness_);
-   /*TGeoCone *calo_endcap_cone =*/ new TGeoCone("calo_endcap_cone",calo_endcap_coneThickness_/2.,calo_endcap_innerRadius1_,calo_endcap_outerRadius1_,calo_endcap_innerRadius2_,calo_endcap_outerRadius2_);
-   /*TGeoTube *calo_endcap_disk =*/ new TGeoTube("calo_endcap_disk",calo_endcap_innerRadius2_,tk_radius_+calo_barrel_thickness_,calo_endcap_diskThickness_/2.);
-   TGeoTranslation *tr1 = new TGeoTranslation("tr1",0., 0., (calo_endcap_coneThickness_+calo_endcap_diskThickness_)/2.);
+   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("calo_endcap_cs","calo_endcap_cone+calo_endcap_disk:tr1");
-   TGeoTranslation *trc1 = new TGeoTranslation("calo_endcap1_position",0.,0., tk_length_+calo_endcap_coneThickness_/2.);
+   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("negz",0,180,0);
-   TGeoCombiTrans  *trc2 = new TGeoCombiTrans("calo_endcap2_position",0.,0.,-(tk_length_+calo_endcap_coneThickness_/2.),negz);
+   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("calo_endcap1_position_cont",0.,0., tk_length_+calo_endcap_coneThickness_/2.+contingency_);
+   TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.+contingency_);
    trc1c->RegisterYourself();
-   TGeoCombiTrans  *trc2c = new TGeoCombiTrans("calo_endcap2_position_cont",0.,0.,-(tk_length_+calo_endcap_coneThickness_/2.)-contingency_,negz);
+   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("calo_endcap",calo_endcap_cs,calomed_);
-   TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape("calo_barrel_cs","calo_barrel_cylinder-calo_endcap_cs:calo_endcap1_position-calo_endcap_cs:calo_endcap2_position");
-   TGeoVolume *calo_barrel = new TGeoVolume("calo_barrel",calo_barrel_cs,calomed_);
+   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);
@@ -243,37 +260,41 @@
    top->AddNode(calo_endcap,2,trc2c);
    top->AddNode(calo_barrel,1); 
-}
-
-void Delphes3DGeometry::addMuonDets(TGeoVolume *top) {
-
+   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 = tk_radius_+calo_barrel_thickness_+2*contingency_;
-   Double_t muonSystem_length = tk_length_+TMath::Max(calo_endcap_coneThickness_,calo_endcap_thickness_)+2*contingency_;
-   Double_t muonSystem_rmin   = muonSystem_length*2.*exp(-muonSystem_etamax_)/(1-exp(-2.*muonSystem_etamax_));
-   TGeoVolume *muon_barrel = geom_->MakeTube("muon_barrel",mudetmed_,muonSystem_radius,muonSystem_radius+muonSystem_thickn_,muonSystem_length);
+   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("muon_endcap",mudetmed_,muonSystem_rmin,muonSystem_radius+muonSystem_thickn_,muonSystem_thickn_/2.);
+   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("muonEndcap1_position",0.,0.,muonSystem_length);
+   TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position",name),0.,0.,muonSystem_length);
    trm1->RegisterYourself();
-   TGeoTranslation *trm2 = new TGeoTranslation("muonEndcap2_position",0.,0.,-muonSystem_length);
+   TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position",name),0.,0.,-muonSystem_length);
    trm1->RegisterYourself();
    top->AddNode(muon_endcap,1,trm1);
    top->AddNode(muon_endcap,1,trm2);
-}
-
-void Delphes3DGeometry::addCaloTowers(TGeoVolume *top) {
-
-   TGeoVolume* calo_endcap = top->GetNode("calo_endcap_1")->GetVolume();
-   TGeoVolume* calo_barrel = top->GetNode("calo_barrel_1")->GetVolume();
+   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_+calo_barrel_thickness_+2*contingency_; // radius of the muons system = height of the pyramid
-   Int_t nEtaBins = caloBinning_.size();
+   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("initTowerRot",0.,90.,0.);
-   TGeoCombiTrans* initTower  = new TGeoCombiTrans("initTower",0.,-R/2.,0.,initTowerRot);
+   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.
@@ -284,6 +305,6 @@
    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
+   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);
@@ -291,5 +312,5 @@
      dx[etaslice] = R*tan(TMath::Pi()*phiRotationAngle/360.);
      for(int phislice=0;phislice<nphi[etaslice];++phislice) {
-       phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("phi%d_%d",etaslice,phislice),phiRotationAngle*phislice,0.,0.);
+       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();
      }
@@ -302,8 +323,8 @@
      vertices[12] =  dx[i]; vertices[13] = y[i+1];
      vertices[14] =  dx[i]; vertices[15] = y[i];
-     /*TGeoArb8 *tower =*/ new TGeoArb8(Form("tower%d",i),R/2., vertices); // tower in the proper eta slice, at phi=0
+     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("ftower%d_cs",i),Form("tower%d:initTower*calo_barrel_cs",i));
-     TGeoVolume *finaltower = new TGeoVolume(Form("ftower%d",i),finaltower_cs,calomed_);
+     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
@@ -315,8 +336,8 @@
    delete[] nphi;
    //the towers in the forward region
-   R  = tk_length_+calo_endcap_thickness_+3*contingency_; // Z of the muons system = height of the pyramid
-   nEtaBins = caloBinning_.size();
-   // translation to bring the origin of the tower to (0,0,0)
-   TGeoTranslation* towerdz = new TGeoTranslation("towerdz",0.,0.,R/2.-(tk_length_+calo_endcap_coneThickness_/2.));
+   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.
@@ -325,11 +346,11 @@
    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
+   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("forward_phi%d_%d",etaslice,phislice),phiRotationAngle*phislice,0.,0.);
+       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();
      }
@@ -342,8 +363,8 @@
      vertices[12] =  r[i]*sin(TMath::Pi()/20.);   vertices[13] = r[i]*cos(TMath::Pi()/20.);
      vertices[14] =  r[i+1]*sin(TMath::Pi()/20.); vertices[15] = r[i+1]*cos(TMath::Pi()/20.);
-     /*TGeoArb8 *fwdtower =*/ new TGeoArb8(Form("fwdtower%d",i),R/2., vertices); // tower in the proper eta slice, at phi=0
+     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("ffwdtower%d_cs",i),Form("fwdtower%d:towerdz*calo_endcap_cs",i));
-     TGeoVolume *finalfwdtower = new TGeoVolume(Form("ffwdtower%d",i),finalfwdtower_cs,calomed_);
+     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
