Index: modules/TreeWriter.cc
===================================================================
--- modules/TreeWriter.cc	(revision 0518688553c2c3ca6c04789f7c9fcafe0ca97c09)
+++ modules/TreeWriter.cc	(revision 2116fdf8b1993a662438e62232341f4708ac0219)
@@ -17,5 +17,4 @@
  */
 
-
 /** \class TreeWriter
  *
@@ -32,22 +31,22 @@
 #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 "ExRootAnalysis/ExRootTreeBranch.h"
 
+#include "TDatabasePDG.h"
+#include "TFormula.h"
+#include "TLorentzVector.h"
+#include "TMath.h"
+#include "TObjArray.h"
 #include "TROOT.h"
-#include "TMath.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;
@@ -84,5 +83,5 @@
 
   TBranchMap::iterator itBranchMap;
-  map< TClass *, TProcessMethod >::iterator itClassMap;
+  map<TClass *, TProcessMethod>::iterator itClassMap;
 
   // read branch configuration and
@@ -97,9 +96,9 @@
 
   size = param.GetSize();
-  for(i = 0; i < size/3; ++i)
-  {
-    branchInputArray = param[i*3].GetString();
-    branchName = param[i*3 + 1].GetString();
-    branchClassName = param[i*3 + 2].GetString();
+  for(i = 0; i < size / 3; ++i)
+  {
+    branchInputArray = param[i * 3].GetString();
+    branchName = param[i * 3 + 1].GetString();
+    branchClassName = param[i * 3 + 2].GetString();
 
     branchClass = gROOT->GetClass(branchClassName);
@@ -123,5 +122,4 @@
     fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
   }
-
 }
 
@@ -139,5 +137,5 @@
   it1.Reset();
   array->Clear();
-  while((candidate = static_cast<Candidate*>(it1.Next())))
+  while((candidate = static_cast<Candidate *>(it1.Next())))
   {
     TIter it2(candidate->GetCandidates());
@@ -151,5 +149,5 @@
 
     // track
-    candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
+    candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     if(candidate->GetCandidates()->GetEntriesFast() == 0)
     {
@@ -160,5 +158,5 @@
     // tower
     it2.Reset();
-    while((candidate = static_cast<Candidate*>(it2.Next())))
+    while((candidate = static_cast<Candidate *>(it2.Next())))
     {
       array->Add(candidate->GetCandidates()->At(0));
@@ -180,10 +178,10 @@
   // loop over all particles
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     const TLorentzVector &momentum = candidate->Momentum;
     const TLorentzVector &position = candidate->Position;
 
-    entry = static_cast<GenParticle*>(branch->NewEntry());
+    entry = static_cast<GenParticle *>(branch->NewEntry());
 
     entry->SetBit(kIsReferenced);
@@ -193,6 +191,6 @@
     cosTheta = TMath::Abs(momentum.CosTheta());
     signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
+    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
 
     entry->PID = candidate->PID;
@@ -215,10 +213,10 @@
     entry->Pz = momentum.Pz();
 
-    entry->D0            = candidate->D0;
-    entry->DZ            = candidate->DZ;
-    entry->P             = candidate->P;
-    entry->PT            = candidate->PT;
-    entry->CtgTheta      = candidate->CtgTheta;
-    entry->Phi           = candidate->Phi;
+    entry->D0 = candidate->D0;
+    entry->DZ = candidate->DZ;
+    entry->P = candidate->P;
+    entry->PT = candidate->PT;
+    entry->CtgTheta = candidate->CtgTheta;
+    entry->Phi = candidate->Phi;
 
     entry->Eta = eta;
@@ -231,5 +229,5 @@
     entry->Y = position.Y();
     entry->Z = position.Z();
-    entry->T = position.T()*1.0E-3/c_light;
+    entry->T = position.T() * 1.0E-3 / c_light;
   }
 }
@@ -255,5 +253,5 @@
   // loop over all vertices
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
 
@@ -269,12 +267,12 @@
     y = candidate->Position.Y();
     z = candidate->Position.Z();
-    t = candidate->Position.T()*1.0E-3/c_light;
-
-    xError = candidate->PositionError.X ();
-    yError = candidate->PositionError.Y ();
-    zError = candidate->PositionError.Z ();
-    tError = candidate->PositionError.T ()*1.0E-3/c_light;
-
-    entry = static_cast<Vertex*>(branch->NewEntry());
+    t = candidate->Position.T() * 1.0E-3 / c_light;
+
+    xError = candidate->PositionError.X();
+    yError = candidate->PositionError.Y();
+    zError = candidate->PositionError.Z();
+    tError = candidate->PositionError.T() * 1.0E-3 / c_light;
+
+    entry = static_cast<Vertex *>(branch->NewEntry());
 
     entry->Index = index;
@@ -296,16 +294,13 @@
     entry->ErrorT = tError;
 
-
     TIter itConstituents(candidate->GetCandidates());
     itConstituents.Reset();
     entry->Constituents.Clear();
-    while((constituent = static_cast<Candidate*>(itConstituents.Next())))
+    while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     {
       entry->Constituents.Add(constituent);
     }
-
-  }
-}
-
+  }
+}
 
 //------------------------------------------------------------------------------
@@ -322,5 +317,5 @@
   // loop over all tracks
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     const TLorentzVector &position = candidate->Position;
@@ -328,8 +323,8 @@
     cosTheta = TMath::Abs(position.CosTheta());
     signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta());
-    rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity());
-
-    entry = static_cast<Track*>(branch->NewEntry());
+    eta = (cosTheta == 1.0 ? signz * 999.9 : position.Eta());
+    rapidity = (cosTheta == 1.0 ? signz * 999.9 : position.Rapidity());
+
+    entry = static_cast<Track *>(branch->NewEntry());
 
     entry->SetBit(kIsReferenced);
@@ -346,17 +341,17 @@
     entry->YOuter = position.Y();
     entry->ZOuter = position.Z();
-    entry->TOuter = position.T()*1.0E-3/c_light;
+    entry->TOuter = position.T() * 1.0E-3 / c_light;
 
     entry->L = candidate->L;
 
-    entry->D0            = candidate->D0;
-    entry->ErrorD0       = candidate->ErrorD0;
-    entry->DZ            = candidate->DZ;
-    entry->ErrorDZ       = candidate->ErrorDZ;
-
-    entry->ErrorP        = candidate->ErrorP;
-    entry->ErrorPT       = candidate->ErrorPT;
+    entry->D0 = candidate->D0;
+    entry->ErrorD0 = candidate->ErrorD0;
+    entry->DZ = candidate->DZ;
+    entry->ErrorDZ = candidate->ErrorDZ;
+
+    entry->ErrorP = candidate->ErrorP;
+    entry->ErrorPT = candidate->ErrorPT;
     entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
-    entry->ErrorPhi      = candidate->ErrorPhi;
+    entry->ErrorPhi = candidate->ErrorPhi;
 
     entry->Xd = candidate->Xd;
@@ -369,18 +364,18 @@
     p = momentum.P();
     phi = momentum.Phi();
-    ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1/TMath::Tan(momentum.Theta()) : 1e10;
+    ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10;
 
     cosTheta = TMath::Abs(momentum.CosTheta());
     signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
+    eta = (cosTheta == 1.0 ? signz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signz * 999.9 : momentum.Rapidity());
 
     entry->P = p;
-    entry->PT  = pt;
+    entry->PT = pt;
     entry->Eta = eta;
     entry->Phi = phi;
     entry->CtgTheta = ctgTheta;
 
-    particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
+    particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     const TLorentzVector &initialPosition = particle->Position;
 
@@ -388,10 +383,9 @@
     entry->Y = initialPosition.Y();
     entry->Z = initialPosition.Z();
-    entry->T = initialPosition.T()*1.0E-3/c_light;
+    entry->T = initialPosition.T() * 1.0E-3 / c_light;
 
     entry->Particle = particle;
 
     entry->VertexIndex = candidate->ClusterIndex;
-
   }
 }
@@ -409,5 +403,5 @@
   // loop over all towers
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     const TLorentzVector &momentum = candidate->Momentum;
@@ -417,8 +411,8 @@
     cosTheta = TMath::Abs(momentum.CosTheta());
     signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
-
-    entry = static_cast<Tower*>(branch->NewEntry());
+    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
+
+    entry = static_cast<Tower *>(branch->NewEntry());
 
     entry->SetBit(kIsReferenced);
@@ -436,5 +430,5 @@
     entry->Edges[3] = candidate->Edges[3];
 
-    entry->T = position.T()*1.0E-3/c_light;
+    entry->T = position.T() * 1.0E-3 / c_light;
     entry->NTimeHits = candidate->NTimeHits;
 
@@ -457,5 +451,5 @@
   // loop over all photons
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     TIter it1(candidate->GetCandidates());
@@ -466,8 +460,8 @@
     cosTheta = TMath::Abs(momentum.CosTheta());
     signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
-
-    entry = static_cast<Photon*>(branch->NewEntry());
+    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
+
+    entry = static_cast<Photon *>(branch->NewEntry());
 
     entry->Eta = eta;
@@ -475,16 +469,16 @@
     entry->PT = pt;
     entry->E = momentum.E();
-    entry->T = position.T()*1.0E-3/c_light;
+    entry->T = position.T() * 1.0E-3 / c_light;
 
     // Isolation variables
 
     entry->IsolationVar = candidate->IsolationVar;
-    entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
-    entry->SumPtCharged = candidate->SumPtCharged ;
-    entry->SumPtNeutral = candidate->SumPtNeutral ;
-    entry->SumPtChargedPU = candidate->SumPtChargedPU ;
-    entry->SumPt = candidate->SumPt ;
-
-    entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
+    entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr;
+    entry->SumPtCharged = candidate->SumPtCharged;
+    entry->SumPtNeutral = candidate->SumPtNeutral;
+    entry->SumPtChargedPU = candidate->SumPtChargedPU;
+    entry->SumPt = candidate->SumPt;
+
+    entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad / candidate->Eem : 999.9;
 
     // 1: prompt -- 2: non prompt -- 3: fake
@@ -509,5 +503,5 @@
   // loop over all electrons
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     const TLorentzVector &momentum = candidate->Momentum;
@@ -517,8 +511,8 @@
     cosTheta = TMath::Abs(momentum.CosTheta());
     signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
-
-    entry = static_cast<Electron*>(branch->NewEntry());
+    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
+
+    entry = static_cast<Electron *>(branch->NewEntry());
 
     entry->Eta = eta;
@@ -526,20 +520,19 @@
     entry->PT = pt;
 
-    entry->T = position.T()*1.0E-3/c_light;
+    entry->T = position.T() * 1.0E-3 / c_light;
 
     // displacement
-    entry->D0            = candidate->D0;
-    entry->ErrorD0       = candidate->ErrorD0;
-    entry->DZ            = candidate->DZ;
-    entry->ErrorDZ       = candidate->ErrorDZ;
+    entry->D0 = candidate->D0;
+    entry->ErrorD0 = candidate->ErrorD0;
+    entry->DZ = candidate->DZ;
+    entry->ErrorDZ = candidate->ErrorDZ;
 
     // Isolation variables
     entry->IsolationVar = candidate->IsolationVar;
-    entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
-    entry->SumPtCharged = candidate->SumPtCharged ;
-    entry->SumPtNeutral = candidate->SumPtNeutral ;
-    entry->SumPtChargedPU = candidate->SumPtChargedPU ;
-    entry->SumPt = candidate->SumPt ;
-
+    entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr;
+    entry->SumPtCharged = candidate->SumPtCharged;
+    entry->SumPtNeutral = candidate->SumPtNeutral;
+    entry->SumPtChargedPU = candidate->SumPtChargedPU;
+    entry->SumPt = candidate->SumPt;
 
     entry->Charge = candidate->Charge;
@@ -566,5 +559,5 @@
   // loop over all muons
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     const TLorentzVector &momentum = candidate->Momentum;
@@ -574,8 +567,8 @@
     cosTheta = TMath::Abs(momentum.CosTheta());
     signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
-
-    entry = static_cast<Muon*>(branch->NewEntry());
+    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
+
+    entry = static_cast<Muon *>(branch->NewEntry());
 
     entry->SetBit(kIsReferenced);
@@ -586,21 +579,20 @@
     entry->PT = pt;
 
-    entry->T = position.T()*1.0E-3/c_light;
-
+    entry->T = position.T() * 1.0E-3 / c_light;
 
     // displacement
-    entry->D0            = candidate->D0;
-    entry->ErrorD0       = candidate->ErrorD0;
-    entry->DZ            = candidate->DZ;
-    entry->ErrorDZ       = candidate->ErrorDZ;
+    entry->D0 = candidate->D0;
+    entry->ErrorD0 = candidate->ErrorD0;
+    entry->DZ = candidate->DZ;
+    entry->ErrorDZ = candidate->ErrorDZ;
 
     // Isolation variables
 
     entry->IsolationVar = candidate->IsolationVar;
-    entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;
-    entry->SumPtCharged = candidate->SumPtCharged ;
-    entry->SumPtNeutral = candidate->SumPtNeutral ;
-    entry->SumPtChargedPU = candidate->SumPtChargedPU ;
-    entry->SumPt = candidate->SumPt ;
+    entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr;
+    entry->SumPtCharged = candidate->SumPtCharged;
+    entry->SumPtNeutral = candidate->SumPtNeutral;
+    entry->SumPtChargedPU = candidate->SumPtChargedPU;
+    entry->SumPt = candidate->SumPt;
 
     entry->Charge = candidate->Charge;
@@ -626,5 +618,5 @@
   // loop over all jets
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     TIter itConstituents(candidate->GetCandidates());
@@ -636,8 +628,8 @@
     cosTheta = TMath::Abs(momentum.CosTheta());
     signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
-    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
-    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
-
-    entry = static_cast<Jet*>(branch->NewEntry());
+    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
+    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
+
+    entry = static_cast<Jet *>(branch->NewEntry());
 
     entry->Eta = eta;
@@ -645,5 +637,5 @@
     entry->PT = pt;
 
-    entry->T = position.T()*1.0E-3/c_light;
+    entry->T = position.T() * 1.0E-3 / c_light;
 
     entry->Mass = momentum.M();
@@ -672,5 +664,5 @@
     ecalEnergy = 0.0;
     hcalEnergy = 0.0;
-    while((constituent = static_cast<Candidate*>(itConstituents.Next())))
+    while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     {
       entry->Constituents.Add(constituent);
@@ -679,5 +671,5 @@
     }
 
-    entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
+    entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy / ecalEnergy : 999.9;
 
     //---   Pile-Up Jet ID variables ----
@@ -696,16 +688,15 @@
     entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
 
-    entry->SoftDroppedJet     = candidate->SoftDroppedJet ;
-    entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1 ;
+    entry->SoftDroppedJet = candidate->SoftDroppedJet;
+    entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1;
     entry->SoftDroppedSubJet2 = candidate->SoftDroppedSubJet2;
-
 
     for(i = 0; i < 5; i++)
     {
-      entry->FracPt[i] = candidate -> FracPt[i];
-      entry->Tau[i] = candidate -> Tau[i];
-      entry->TrimmedP4[i] = candidate -> TrimmedP4[i];
-      entry->PrunedP4[i] = candidate -> PrunedP4[i];
-      entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i];
+      entry->FracPt[i] = candidate->FracPt[i];
+      entry->Tau[i] = candidate->Tau[i];
+      entry->TrimmedP4[i] = candidate->TrimmedP4[i];
+      entry->PrunedP4[i] = candidate->PrunedP4[i];
+      entry->SoftDroppedP4[i] = candidate->SoftDroppedP4[i];
     }
 
@@ -714,6 +705,5 @@
     entry->ExclYmerge34 = candidate->ExclYmerge34;
     entry->ExclYmerge45 = candidate->ExclYmerge45;
-    entry->ExclYmerge56 = candidate->ExclYmerge56;    
-
+    entry->ExclYmerge56 = candidate->ExclYmerge56;
 
     FillParticles(candidate, &entry->Particles);
@@ -729,9 +719,9 @@
 
   // get the first entry
-  if((candidate = static_cast<Candidate*>(array->At(0))))
-  {
-    const TLorentzVector &momentum = candidate->Momentum;
-
-    entry = static_cast<MissingET*>(branch->NewEntry());
+  if((candidate = static_cast<Candidate *>(array->At(0))))
+  {
+    const TLorentzVector &momentum = candidate->Momentum;
+
+    entry = static_cast<MissingET *>(branch->NewEntry());
 
     entry->Eta = (-momentum).Eta();
@@ -749,9 +739,9 @@
 
   // get the first entry
-  if((candidate = static_cast<Candidate*>(array->At(0))))
-  {
-    const TLorentzVector &momentum = candidate->Momentum;
-
-    entry = static_cast<ScalarHT*>(branch->NewEntry());
+  if((candidate = static_cast<Candidate *>(array->At(0))))
+  {
+    const TLorentzVector &momentum = candidate->Momentum;
+
+    entry = static_cast<ScalarHT *>(branch->NewEntry());
 
     entry->HT = momentum.Pt();
@@ -769,9 +759,9 @@
   // loop over all rho
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
-  {
-    const TLorentzVector &momentum = candidate->Momentum;
-
-    entry = static_cast<Rho*>(branch->NewEntry());
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
+  {
+    const TLorentzVector &momentum = candidate->Momentum;
+
+    entry = static_cast<Rho *>(branch->NewEntry());
 
     entry->Rho = momentum.E();
@@ -789,9 +779,9 @@
 
   // get the first entry
-  if((candidate = static_cast<Candidate*>(array->At(0))))
-  {
-    const TLorentzVector &momentum = candidate->Momentum;
-
-    entry = static_cast<Weight*>(branch->NewEntry());
+  if((candidate = static_cast<Candidate *>(array->At(0))))
+  {
+    const TLorentzVector &momentum = candidate->Momentum;
+
+    entry = static_cast<Weight *>(branch->NewEntry());
 
     entry->Weight = momentum.E();
@@ -809,10 +799,10 @@
   // loop over all roman pot hits
   iterator.Reset();
-  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  while((candidate = static_cast<Candidate *>(iterator.Next())))
   {
     const TLorentzVector &position = candidate->Position;
     const TLorentzVector &momentum = candidate->Momentum;
 
-    entry = static_cast<HectorHit*>(branch->NewEntry());
+    entry = static_cast<HectorHit *>(branch->NewEntry());
 
     entry->E = momentum.E();
