Index: modules/SimpleCalorimeter.cc
===================================================================
--- modules/SimpleCalorimeter.cc	(revision cab38f67bfdb282911fa60f8e3ae4346ef70ee4a)
+++ modules/SimpleCalorimeter.cc	(revision e5767b57219464dbd30e396bdf1204c380d3d636)
@@ -60,5 +60,5 @@
 {
   fResolutionFormula = new DelphesFormula;
- 
+
   fTowerTrackArray = new TObjArray;
   fItTowerTrackArray = fTowerTrackArray->MakeIterator();
@@ -70,5 +70,5 @@
 {
   if(fResolutionFormula) delete fResolutionFormula;
- 
+
   if(fTowerTrackArray) delete fTowerTrackArray;
   if(fItTowerTrackArray) delete fItTowerTrackArray;
@@ -136,4 +136,5 @@
     fFractionMap[param[i*2].GetInt()] = fraction;
   }
+
 /*
   TFractionMap::iterator itFractionMap;
@@ -145,10 +146,14 @@
 
   // read min E value for towers to be saved
-  fEnergyMin = GetDouble("TowerMinEnergy", 0.0); 
-  fSigmaMin  = GetDouble("TowerMinSignificance", 0.0); 
- 
+  fEnergyMin = GetDouble("EnergyMin", 0.0);
+
+  fEnergySignificanceMin = GetDouble("EnergySignificanceMin", 0.0);
+
+  // switch on or off the dithering of the center of calorimeter towers
+  fDitherTowerCenter = GetBool("DitherTowerCenter", true);
+
   // read resolution formulas
   fResolutionFormula->Compile(GetString("ResolutionFormula", "0"));
- 
+
   // import array with output from other modules
   fParticleInputArray = ImportArray(GetString("ParticleInputArray", "ParticlePropagator/particles"));
@@ -161,5 +166,4 @@
   fTowerOutputArray = ExportArray(GetString("TowerOutputArray", "towers"));
   fEFlowTowerOutputArray = ExportArray(GetString("EFlowTowerOutputArray", "eflowTowers"));
- 
 }
 
@@ -202,5 +206,5 @@
   fTowerFractions.clear();
   fTrackFractions.clear();
- 
+
   // loop over all particles
   fItParticleInputArray->Reset();
@@ -221,5 +225,5 @@
     fraction = itFractionMap->second;
     fTowerFractions.push_back(fraction);
-   
+
     if(fraction < 1.0E-9) continue;
 
@@ -263,7 +267,7 @@
 
     fraction = itFractionMap->second;
-  
+
     fTrackFractions.push_back(fraction);
-  
+
     // find eta bin [1, fEtaBins.size - 1]
     itEtaBin = lower_bound(fEtaBins.begin(), fEtaBins.end(), trackPosition.Eta());
@@ -329,13 +333,13 @@
       fTowerEnergy = 0.0;
       fTrackEnergy = 0.0;
-      
+
       fTowerTime = 0.0;
       fTrackTime = 0.0;
-     
-      fTowerWeightTime = 0.0; 
-      
+
+      fTowerTimeWeight = 0.0;
+
       fTowerTrackHits = 0;
       fTowerPhotonHits = 0;
-      
+
       fTowerTrackArray->Clear();
     }
@@ -349,20 +353,20 @@
       momentum = track->Momentum;
       position = track->Position;
- 
+
       energy = momentum.E() * fTrackFractions[number];
-      
+
       fTrackEnergy += energy;
-      
+
       fTrackTime += TMath::Sqrt(energy)*position.T();
-      fTrackWeightTime += TMath::Sqrt(energy);
-    
+      fTrackTimeWeight += TMath::Sqrt(energy);
+
       fTowerTrackArray->Add(track);
 
       continue;
     }
-   
+
     // check for photon and electron hits in current tower
     if(flags & 2) ++fTowerPhotonHits;
-    
+
     particle = static_cast<Candidate*>(fParticleInputArray->At(number));
     momentum = particle->Momentum;
@@ -371,10 +375,10 @@
     // fill current tower
     energy = momentum.E() * fTowerFractions[number];
-   
+
     fTowerEnergy += energy;
-    
+
     fTowerTime += TMath::Sqrt(energy)*position.T();
-    fTowerWeightTime += TMath::Sqrt(energy);
-    
+    fTowerTimeWeight += TMath::Sqrt(energy);
+
     fTower->AddCandidate(particle);
   }
@@ -397,23 +401,28 @@
   sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerEnergy);
 
-//  energy = gRandom->Gaus(fTowerEnergy, sigma);
-//  if(energy < 0.0) energy = 0.0;
-
   energy = LogNormal(fTowerEnergy, sigma);
-  time = (fTowerWeightTime < 1.0E-09 ) ? 0 : fTowerTime/fTowerWeightTime;
+
+  time = (fTowerTimeWeight < 1.0E-09 ) ? 0.0 : fTowerTime/fTowerTimeWeight;
 
   sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy);
-  
-  energy = (energy < fEnergyMin || energy < fSigmaMin*sigma) ? 0 : energy;
-  
-  eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
-  phi = gRandom->Uniform(fTowerEdges[2], fTowerEdges[3]);
+
+  if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0;
+
+  if(fDitherTowerCenter)
+  {
+    eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
+    phi = gRandom->Uniform(fTowerEdges[2], fTowerEdges[3]);
+  }
+  else
+  {
+    eta = fTowerEta;
+    phi = fTowerPhi;
+  }
 
   pt = energy / TMath::CosH(eta);
 
- // fTower->Position.SetXYZT(-time, 0.0, 0.0, time);
   fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time);
   fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
- 
+
   fTower->Edges[0] = fTowerEdges[0];
   fTower->Edges[1] = fTowerEdges[1];
@@ -421,13 +430,14 @@
   fTower->Edges[3] = fTowerEdges[3];
 
-
   // fill SimpleCalorimeter towers
   if(energy > 0.0) fTowerOutputArray->Add(fTower);
 
-  
   // fill energy flow candidates
   energy -= fTrackEnergy;
-  if(energy < fEnergyMin || energy < fSigmaMin*fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy)) energy = 0.0;
-   
+
+  sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy);
+
+  if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0;
+
   // save energy excess as an energy flow tower
   if(energy > 0.0)
@@ -440,5 +450,4 @@
     fEFlowTowerOutputArray->Add(tower);
   }
-
 }
 
@@ -454,5 +463,5 @@
     a = TMath::Log(mean) - 0.5*b*b;
 
-    return TMath::Exp(a + b*gRandom->Gaus(0, 1));
+    return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
   }
   else
