Index: modules/SimpleCalorimeter.cc
===================================================================
--- modules/SimpleCalorimeter.cc	(revision 7da1826092cf0024c639e1bc9be71db4f32dca72)
+++ modules/SimpleCalorimeter.cc	(revision a3261d73a34e41732f85a0bce7e5c84e1ffcfddf)
@@ -17,5 +17,4 @@
  */
 
-
 /** \class SimpleCalorimeter
  *
@@ -33,20 +32,20 @@
 #include "classes/DelphesFormula.h"
 
+#include "ExRootAnalysis/ExRootClassifier.h"
+#include "ExRootAnalysis/ExRootFilter.h"
 #include "ExRootAnalysis/ExRootResult.h"
-#include "ExRootAnalysis/ExRootFilter.h"
-#include "ExRootAnalysis/ExRootClassifier.h"
-
+
+#include "TDatabasePDG.h"
+#include "TFormula.h"
+#include "TLorentzVector.h"
 #include "TMath.h"
+#include "TObjArray.h"
+#include "TRandom3.h"
 #include "TString.h"
-#include "TFormula.h"
-#include "TRandom3.h"
-#include "TObjArray.h"
-#include "TDatabasePDG.h"
-#include "TLorentzVector.h"
 
 #include <algorithm>
-#include <stdexcept>
 #include <iostream>
 #include <sstream>
+#include <stdexcept>
 
 using namespace std;
@@ -58,9 +57,8 @@
   fItParticleInputArray(0), fItTrackInputArray(0)
 {
-  
+
   fResolutionFormula = new DelphesFormula;
   fTowerTrackArray = new TObjArray;
   fItTowerTrackArray = fTowerTrackArray->MakeIterator();
- 
 }
 
@@ -69,9 +67,8 @@
 SimpleCalorimeter::~SimpleCalorimeter()
 {
- 
+
   if(fResolutionFormula) delete fResolutionFormula;
   if(fTowerTrackArray) delete fTowerTrackArray;
   if(fItTowerTrackArray) delete fItTowerTrackArray;
- 
 }
 
@@ -84,6 +81,6 @@
   Double_t fraction;
   TBinMap::iterator itEtaBin;
-  set< Double_t >::iterator itPhiBin;
-  vector< Double_t > *phiBins;
+  set<Double_t>::iterator itPhiBin;
+  vector<Double_t> *phiBins;
 
   // read eta and phi bins
@@ -93,9 +90,9 @@
   fEtaBins.clear();
   fPhiBins.clear();
-  for(i = 0; i < size/2; ++i)
-  {
-    paramEtaBins = param[i*2];
+  for(i = 0; i < size / 2; ++i)
+  {
+    paramEtaBins = param[i * 2];
     sizeEtaBins = paramEtaBins.GetSize();
-    paramPhiBins = param[i*2 + 1];
+    paramPhiBins = param[i * 2 + 1];
     sizePhiBins = paramPhiBins.GetSize();
 
@@ -114,5 +111,5 @@
   {
     fEtaBins.push_back(itEtaBin->first);
-    phiBins = new vector< double >(itEtaBin->second.size());
+    phiBins = new vector<double>(itEtaBin->second.size());
     fPhiBins.push_back(phiBins);
     phiBins->clear();
@@ -131,9 +128,9 @@
   fFractionMap[0] = 1.0;
 
-  for(i = 0; i < size/2; ++i)
-  {
-    paramFractions = param[i*2 + 1];
+  for(i = 0; i < size / 2; ++i)
+  {
+    paramFractions = param[i * 2 + 1];
     fraction = paramFractions[0].GetDouble();
-    fFractionMap[param[i*2].GetInt()] = fraction;
+    fFractionMap[param[i * 2].GetInt()] = fraction;
   }
 
@@ -170,5 +167,5 @@
 void SimpleCalorimeter::Finish()
 {
-  vector< vector< Double_t >* >::iterator itPhiBin;
+  vector<vector<Double_t> *>::iterator itPhiBin;
   if(fItParticleInputArray) delete fItParticleInputArray;
   if(fItTrackInputArray) delete fItTrackInputArray;
@@ -197,9 +194,9 @@
   TFractionMap::iterator itFractionMap;
 
-  vector< Double_t >::iterator itEtaBin;
-  vector< Double_t >::iterator itPhiBin;
-  vector< Double_t > *phiBins;
-
-  vector< Long64_t >::iterator itTowerHits;
+  vector<Double_t>::iterator itEtaBin;
+  vector<Double_t>::iterator itPhiBin;
+  vector<Double_t> *phiBins;
+
+  vector<Long64_t>::iterator itTowerHits;
 
   DelphesFactory *factory = GetFactory();
@@ -211,5 +208,5 @@
   fItParticleInputArray->Reset();
   number = -1;
-  while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
+  while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
   {
     const TLorentzVector &particlePosition = particle->Position;
@@ -254,5 +251,5 @@
   fItTrackInputArray->Reset();
   number = -1;
-  while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
+  while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
   {
     const TLorentzVector &trackPosition = track->Position;
@@ -303,5 +300,5 @@
     towerHit = (*itTowerHits);
     flags = (towerHit >> 24) & 0x00000000000000FFLL;
-    number = (towerHit) & 0x0000000000FFFFFFLL;
+    number = (towerHit)&0x0000000000FFFFFFLL;
     hitEtaPhi = towerHit >> 32;
 
@@ -324,6 +321,6 @@
 
       // calculate eta and phi of the tower's center
-      fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
-      fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
+      fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
+      fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
 
       fTowerEdges[0] = fEtaBins[etaBin - 1];
@@ -346,5 +343,5 @@
 
       fTowerTrackArray->Clear();
-     }
+    }
 
     // check for track hits
@@ -353,5 +350,5 @@
       ++fTowerTrackHits;
 
-      track = static_cast<Candidate*>(fTrackInputArray->At(number));
+      track = static_cast<Candidate *>(fTrackInputArray->At(number));
       momentum = track->Momentum;
       position = track->Position;
@@ -359,20 +356,22 @@
       energy = momentum.E() * fTrackFractions[number];
 
-      fTrackTime += TMath::Sqrt(energy)*position.T();
+      fTrackTime += TMath::Sqrt(energy) * position.T();
       fTrackTimeWeight += TMath::Sqrt(energy);
 
       if(fTrackFractions[number] > 1.0E-9)
       {
-             
-       // compute total charged energy	 
-       fTrackEnergy += energy;
-       sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
-       if(sigma/momentum.E() < track->TrackResolution) energyGuess = energy;
-       else energyGuess = momentum.E();
-
-       fTrackSigma += ((track->TrackResolution)*energyGuess)*((track->TrackResolution)*energyGuess);
-       fTowerTrackArray->Add(track);
+
+        // compute total charged energy
+        fTrackEnergy += energy;
+        sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
+        if(sigma / momentum.E() < track->TrackResolution)
+          energyGuess = energy;
+        else
+          energyGuess = momentum.E();
+
+        fTrackSigma += ((track->TrackResolution) * energyGuess) * ((track->TrackResolution) * energyGuess);
+        fTowerTrackArray->Add(track);
       }
-       
+
       else
       {
@@ -386,5 +385,5 @@
     if(flags & 2) ++fTowerPhotonHits;
 
-    particle = static_cast<Candidate*>(fParticleInputArray->At(number));
+    particle = static_cast<Candidate *>(fParticleInputArray->At(number));
     momentum = particle->Momentum;
     position = particle->Position;
@@ -395,5 +394,5 @@
     fTowerEnergy += energy;
 
-    fTowerTime += energy*position.T();
+    fTowerTime += energy * position.T();
     fTowerTimeWeight += energy;
 
@@ -410,8 +409,8 @@
 {
   Candidate *tower, *track, *mother;
-  Double_t energy,neutralEnergy, pt, eta, phi;
+  Double_t energy, neutralEnergy, pt, eta, phi;
   Double_t sigma, neutralSigma;
   Double_t time;
-   
+
   Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor;
 
@@ -425,10 +424,9 @@
   energy = LogNormal(fTowerEnergy, sigma);
 
-  time = (fTowerTimeWeight < 1.0E-09 ) ? 0.0 : fTowerTime/fTowerTimeWeight;
+  time = (fTowerTimeWeight < 1.0E-09) ? 0.0 : fTowerTime / fTowerTimeWeight;
 
   sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy);
 
-  if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0;
-
+  if(energy < fEnergyMin || energy < fEnergySignificanceMin * sigma) energy = 0.0;
 
   if(fSmearTowerCenter)
@@ -459,20 +457,19 @@
   if(energy > 0.0) fTowerOutputArray->Add(fTower);
 
- 
   // e-flow candidates
 
   //compute neutral excess
-  
+
   fTrackSigma = TMath::Sqrt(fTrackSigma);
-  neutralEnergy = max( (energy - fTrackEnergy) , 0.0);
-  
+  neutralEnergy = max((energy - fTrackEnergy), 0.0);
+
   //compute sigma_trk total
-  neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma*fTrackSigma+ sigma*sigma);
-   
+  neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma * fTrackSigma + sigma * sigma);
+
   // if neutral excess is significant, simply create neutral Eflow tower and clone each track into eflowtrack
   if(neutralEnergy > fEnergyMin && neutralSigma > fEnergySignificanceMin)
   {
     // create new photon tower
-    tower = static_cast<Candidate*>(fTower->Clone());
+    tower = static_cast<Candidate *>(fTower->Clone());
     pt = neutralEnergy / TMath::CosH(eta);
 
@@ -480,13 +477,13 @@
     tower->Ehad = (fIsEcal) ? 0 : neutralEnergy;
     tower->PID = (fIsEcal) ? 22 : 0;
- 
+
     tower->Momentum.SetPtEtaPhiE(pt, eta, phi, neutralEnergy);
     fEFlowTowerOutputArray->Add(tower);
-    
+
     fItTowerTrackArray->Reset();
-    while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
+    while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
     {
       mother = track;
-      track = static_cast<Candidate*>(track->Clone());
+      track = static_cast<Candidate *>(track->Clone());
       track->AddCandidate(mother);
 
@@ -494,19 +491,19 @@
     }
   }
-    
+
   // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
-  else if (fTrackEnergy > 0.0)
-  {
-    weightTrack = (fTrackSigma > 0.0) ? 1 / (fTrackSigma*fTrackSigma) : 0.0;
-    weightCalo  = (sigma > 0.0) ? 1 / (sigma*sigma) : 0.0;
-  
-    bestEnergyEstimate = (weightTrack*fTrackEnergy + weightCalo*energy) / (weightTrack + weightCalo); 
-    rescaleFactor = bestEnergyEstimate/fTrackEnergy;
-   
+  else if(fTrackEnergy > 0.0)
+  {
+    weightTrack = (fTrackSigma > 0.0) ? 1 / (fTrackSigma * fTrackSigma) : 0.0;
+    weightCalo = (sigma > 0.0) ? 1 / (sigma * sigma) : 0.0;
+
+    bestEnergyEstimate = (weightTrack * fTrackEnergy + weightCalo * energy) / (weightTrack + weightCalo);
+    rescaleFactor = bestEnergyEstimate / fTrackEnergy;
+
     fItTowerTrackArray->Reset();
-    while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
+    while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
     {
       mother = track;
-      track = static_cast<Candidate*>(track->Clone());
+      track = static_cast<Candidate *>(track->Clone());
       track->AddCandidate(mother);
 
@@ -516,6 +513,5 @@
     }
   }
-   
- } 
+}
 
 //------------------------------------------------------------------------------
@@ -527,8 +523,8 @@
   if(mean > 0.0)
   {
-    b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
-    a = TMath::Log(mean) - 0.5*b*b;
-
-    return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
+    b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));
+    a = TMath::Log(mean) - 0.5 * b * b;
+
+    return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0));
   }
   else
