Index: modules/DualReadoutCalorimeter.cc
===================================================================
--- modules/DualReadoutCalorimeter.cc	(revision f382b7ef76d09cb93171c0638152952e357d4e54)
+++ modules/DualReadoutCalorimeter.cc	(revision 9cc5aebd473f566f2db87baa902b47d3c14e5481)
@@ -24,5 +24,5 @@
   // This implementation of dual calorimetry relies on several approximations:
   // - If hadronic energy is found in the tower the energy resolution then the full tower enrgy is smeared according to hadronic resolution (pessimistic for (e,n) or (pi+,gamma))
-  // - While e+ vs pi+ (or gamma vs n) separation is in principle possible for single particles (using C/S, PMT timing, lateral shower profile) it is not obvious it can be done overlapping particles. 
+  // - While e+ vs pi+ (or gamma vs n) separation is in principle possible for single particles (using C/S, PMT timing, lateral shower profile) it is not obvious it can be done overlapping particles.
   //   Now we assume that regarless of the number of particle hits per tower we can always distinguish e+ vs pi+, which is probably not true in the case (e+,n) vs (pi+,gamma) without longitudinal segmentation.
 
@@ -63,5 +63,5 @@
   fItParticleInputArray(0), fItTrackInputArray(0)
 {
-  
+
   fECalResolutionFormula = new DelphesFormula;
   fHCalResolutionFormula = new DelphesFormula;
@@ -75,5 +75,5 @@
   fTowerTrackArray = new TObjArray;
   fItTowerTrackArray = fTowerTrackArray->MakeIterator();
-  
+
 }
 
@@ -82,5 +82,5 @@
 DualReadoutCalorimeter::~DualReadoutCalorimeter()
 {
-  
+
   if(fECalResolutionFormula) delete fECalResolutionFormula;
   if(fHCalResolutionFormula) delete fHCalResolutionFormula;
@@ -94,5 +94,5 @@
   if(fTowerTrackArray) delete fTowerTrackArray;
   if(fItTowerTrackArray) delete fItTowerTrackArray;
- 
+
 }
 
@@ -379,9 +379,9 @@
       fHCalTrackEnergy = 0.0;
       fTrackEnergy = 0.0;
-      
+
       fECalTrackSigma = 0.0;
       fHCalTrackSigma = 0.0;
       fTrackSigma = 0.0;
-      
+
       fTowerTrackHits = 0;
       fTowerPhotonHits = 0;
@@ -390,5 +390,5 @@
       fHCalTowerTrackArray->Clear();
       fTowerTrackArray->Clear();
-    
+
     }
 
@@ -414,40 +414,10 @@
       }
 
-      
-      /*
-      if(fECalTrackFractions[number] > 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9)
-      {
-        fECalTrackEnergy += ecalEnergy;
-        ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());        
-        if(ecalSigma/momentum.E() < track->TrackResolution) energyGuess = ecalEnergy;        
-        else energyGuess = momentum.E();
-
-        fECalTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess;
-        fECalTowerTrackArray->Add(track);
-      }
-     
-      else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9)
-      {
-        fHCalTrackEnergy += hcalEnergy;
-        hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
-        if(hcalSigma/momentum.E() < track->TrackResolution) energyGuess = hcalEnergy;
-        else energyGuess = momentum.E();
-
-        fHCalTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess;
-        fHCalTowerTrackArray->Add(track);
-      }
-      
-      // muons
-      else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9)
-      {
-        fEFlowTrackOutputArray->Add(track);
-      }
-      */
-      
+
       // in Dual Readout we do not care if tracks are ECAL of HCAL
       if(fECalTrackFractions[number] > 1.0E-9 || fHCalTrackFractions[number] > 1.0E-9)
-      { 
+      {
         fTrackEnergy += energy;
-        // this sigma will be used to determine whether neutral excess is significant. We choose the resolution according to bthe higest deposited fraction (in practice had for charged hadrons and em for electrons)      
+        // this sigma will be used to determine whether neutral excess is significant. We choose the resolution according to bthe higest deposited fraction (in practice had for charged hadrons and em for electrons)
         sigma = 0.0;
         if(fHCalTrackFractions[number] > 0)
@@ -455,13 +425,13 @@
         else
           sigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
-          
-        if(sigma/momentum.E() < track->TrackResolution) 
-          energyGuess = ecalEnergy + hcalEnergy;     
+
+        if(sigma/momentum.E() < track->TrackResolution)
+          energyGuess = ecalEnergy + hcalEnergy;
         else
           energyGuess = momentum.E();
-             
+
         fTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess;
         fTowerTrackArray->Add(track);
-      
+
       }
       else
@@ -511,10 +481,10 @@
   Double_t ecalEnergy, hcalEnergy;
   Double_t ecalNeutralEnergy, hcalNeutralEnergy, neutralEnergy;
-  
+
   Double_t ecalSigma, hcalSigma, sigma;
   Double_t ecalNeutralSigma, hcalNeutralSigma, neutralSigma;
 
   Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor;
-  
+
   TLorentzVector momentum;
   TFractionMap::iterator itFractionMap;
@@ -536,5 +506,5 @@
   //cout<<"fECalTowerEnergy: "<<fECalTowerEnergy<<", fHCalTowerEnergy: "<<fHCalTowerEnergy<<", Eta: "<<fTowerEta<<endl;
 
-  // if no hadronic energy, use ECAL resolution 
+  // if no hadronic energy, use ECAL resolution
   if (fHCalTowerEnergy <= fHCalEnergyMin)
   {
@@ -544,5 +514,5 @@
   }
 
-  // if hadronic fraction > 0, use HCAL resolution 
+  // if hadronic fraction > 0, use HCAL resolution
   else
   {
@@ -554,5 +524,5 @@
   energy = LogNormal(energy, sigma);
   //cout<<energy<<","<<ecalEnergy<<","<<hcalEnergy<<endl;
-  
+
   if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0;
 
@@ -626,5 +596,5 @@
 
   // fill energy flow candidates
-  
+
   fTrackSigma = TMath::Sqrt(fTrackSigma);
   neutralEnergy = max( (energy - fTrackEnergy) , 0.0);
@@ -638,5 +608,5 @@
   if(neutralEnergy > fEnergyMin && neutralSigma > fEnergySignificanceMin)
   {
-    
+
     //cout<<"significant neutral excess found:"<<endl;
     // create new photon tower
@@ -646,5 +616,5 @@
     tower->Momentum.SetPtEtaPhiE(pt, eta, phi, neutralEnergy);
 
-    // if no hadronic energy, use ECAL resolution 
+    // if no hadronic energy, use ECAL resolution
     if (fHCalTowerEnergy <= fHCalEnergyMin)
     {
@@ -654,5 +624,5 @@
     }
 
-    // if hadronic fraction > 0, use HCAL resolution 
+    // if hadronic fraction > 0, use HCAL resolution
     else
     {
@@ -663,5 +633,5 @@
 
     fEFlowPhotonOutputArray->Add(tower);
-    
+
 
     //clone tracks
@@ -669,5 +639,4 @@
     while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
     {
-      //cout<<"looping over tracks"<<endl;
       mother = track;
       track = static_cast<Candidate*>(track->Clone());
@@ -677,5 +646,5 @@
   }
 
-  
+
   // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the DualReadoutCalorimeter and tracking
   else if(fTrackEnergy > 0.0)
@@ -685,5 +654,5 @@
     weightCalo  = (sigma > 0.0) ? 1 / (sigma*sigma) : 0.0;
 
-    bestEnergyEstimate = (weightTrack*fTrackEnergy + weightCalo*energy) / (weightTrack + weightCalo); 
+    bestEnergyEstimate = (weightTrack*fTrackEnergy + weightCalo*energy) / (weightTrack + weightCalo);
     rescaleFactor = bestEnergyEstimate/fTrackEnergy;
 
@@ -691,15 +660,13 @@
     fItTowerTrackArray->Reset();
     while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
-    {  
+    {
       mother = track;
-      track = static_cast<Candidate*>(track->Clone());
+      track = static_cast<Candidate *>(track->Clone());
       track->AddCandidate(mother);
-
-      track->Momentum *= rescaleFactor;
-
+      track->Momentum.SetPtEtaPhiM(track->Momentum.Pt()*rescaleFactor, track->Momentum.Eta(), track->Momentum.Phi(), track->Momentum.M());
       fEFlowTrackOutputArray->Add(track);
     }
   }
-  
+
 
 }
