Index: modules/FastJetGridMedianEstimator.cc
===================================================================
--- modules/FastJetGridMedianEstimator.cc	(revision cab38f67bfdb282911fa60f8e3ae4346ef70ee4a)
+++ modules/FastJetGridMedianEstimator.cc	(revision 406b698c06fe4f407ae1b22d74541e35189553af)
@@ -94,22 +94,24 @@
 void FastJetGridMedianEstimator::Init()
 {
-  // read eta ranges
+  ExRootConfParam param;
+  Long_t i, size;
+  Double_t drap, dphi, rapMin, rapMax;
 
-  ExRootConfParam param = GetParam("GridRange");
-  Long_t i, size;
-  
-  fGrid.clear();
+  // read rapidity ranges
+
+  param = GetParam("GridRange");
   size = param.GetSize();
+
+  fEstimators.clear();
   for(i = 0; i < size/4; ++i)
   {
-    fGrid[make_pair(param[i*4].GetDouble(), param[i*4 + 1].GetDouble())] = make_pair(param[i*4 + 2].GetDouble(), param[i*4 + 3].GetDouble());
-    //cout<<param[i*4].GetDouble()<<","<<  param[i*4 + 1].GetDouble()<<","<< param[i*4 + 2].GetDouble()<<","<< param[i*4 + 3].GetDouble()<<endl;
+    rapMin = param[i*4].GetDouble();
+    rapMax = param[i*4 + 1].GetDouble();
+    drap = param[i*4 + 2].GetDouble();
+    dphi = param[i*4 + 3].GetDouble();
+    fEstimators.push_back(new GridMedianBackgroundEstimator(rapMin, rapMax, drap, dphi));
+  }
 
-  }
- 
-  
-  //cout<<fGrid[make_pair(0.0,2.5)].first<<","<<fGrid[make_pair(0.0,2.5)].second<<endl;
- 
- // import input array
+  // import input array
 
   fInputArray = ImportArray(GetString("InputArray", "Calorimeter/towers"));
@@ -117,5 +119,4 @@
 
   fRhoOutputArray = ExportArray(GetString("RhoOutputArray", "rho"));
-  
 }
 
@@ -124,4 +125,11 @@
 void FastJetGridMedianEstimator::Finish()
 {
+  vector< GridMedianBackgroundEstimator * >::iterator itEstimators;
+
+  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
+  {
+    if(*itEstimators) delete *itEstimators;
+  }
+
   if(fItInputArray) delete fItInputArray;
 }
@@ -133,16 +141,15 @@
   Candidate *candidate;
   TLorentzVector momentum;
-  Double_t deta, dphi, detaMin, detaMax;
   Int_t number;
   Double_t rho = 0;
   PseudoJet jet;
-  vector<PseudoJet> inputList, outputList;
-  
-  std::map< std::pair< Double_t , Double_t > , std::pair< Double_t , Double_t > >::iterator itGrid;
-  
+  vector< PseudoJet > inputList, outputList;
+
+  vector< GridMedianBackgroundEstimator * >::iterator itEstimators;;
+
   DelphesFactory *factory = GetFactory();
- 
+
   inputList.clear();
- 
+
   // loop over input objects
   fItInputArray->Reset();
@@ -157,43 +164,17 @@
   }
 
- 
   // compute rho and store it
-  
-  // cout<<"caio"<<endl;
-  for(itGrid = fGrid.begin(); itGrid != fGrid.end(); ++itGrid)
+
+  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
   {
-   //Selector select_rapidity = SelectorAbsRapRange(itEtaRangeMap->first, itEtaRangeMap->second);
-   // JetMedianBackgroundEstimator estimator(select_rapidity, *fDefinition, *fAreaDefinition);
-      
-    //cout<<itGrid->first.first<<endl;
-   
-    detaMin = (itGrid->first).first;
-    detaMax = (itGrid->first).second;
-    deta    = (itGrid->second).first;
-    dphi    = (itGrid->second).second;
-    
-    //cout<<detaMin<<","<<detaMax<<","<<deta<<","<<dphi<<endl;
-    
-    
-    RectangularGrid grid(detaMin, detaMax, deta, dphi);
-    //cout<<grid.is_initialised()<<endl;
-    //cout<<grid.rapmin()<<","<<grid.rapmax()<<","<<grid.drap()<<","<<grid.dphi()<<endl;
-      
-    GridMedianBackgroundEstimator estimator(grid);
-      
-    estimator.set_particles(inputList);
-      
-    //cout<<estimator.description()<<endl;
-      
-    rho = estimator.rho();
-    //cout<<rho<<endl;      
+    (*itEstimators)->set_particles(inputList);
 
+    rho = (*itEstimators)->rho();
 
     candidate = factory->NewCandidate();
     candidate->Momentum.SetPtEtaPhiE(rho, 0.0, 0.0, rho);
-    candidate->Edges[0] = detaMin;
-    candidate->Edges[1] = detaMax;
+    candidate->Edges[0] = (*itEstimators)->rapmin();
+    candidate->Edges[1] = (*itEstimators)->rapmax();
     fRhoOutputArray->Add(candidate);
   }
- 
 }
