Index: modules/VertexSorter.cc
===================================================================
--- modules/VertexSorter.cc	(revision 4154bbda8cb3b2dc05c3f4258ee0b6bf25132273)
+++ modules/VertexSorter.cc	(revision 341014c3f3bd3259d845de52bde54ba6c3b4ed08)
@@ -16,33 +16,33 @@
 #include "classes/DelphesPileUpReader.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 "TMatrixT.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 "TMatrixT.h"
 #include "TVector3.h"
 
+#include <algorithm>
+#include <iostream>
+#include <map>
+#include <stdexcept>
+#include <string>
 #include <utility>
-#include <algorithm>
-#include <stdexcept>
-#include <iostream>
 #include <vector>
-#include <map>
-#include <string>
 
 using namespace std;
 
-static const Double_t mm  = 1.;
-static const Double_t m = 1000.*mm;
-static const Double_t ns  = 1.;
-static const Double_t s = 1.e+9 *ns;
-static const Double_t c_light   = 2.99792458e+8 * m/s;
+static const Double_t mm = 1.;
+static const Double_t m = 1000. * mm;
+static const Double_t ns = 1.;
+static const Double_t s = 1.e+9 * ns;
+static const Double_t c_light = 2.99792458e+8 * m / s;
 
 //------------------------------------------------------------------------------
@@ -68,9 +68,9 @@
   fItTrackInputArray = fTrackInputArray->MakeIterator();
 
-  if (string (GetString("JetInputArray", "")) != "")
-    {
-      fJetInputArray = ImportArray(GetString("JetInputArray", ""));
-      fItJetInputArray = fJetInputArray->MakeIterator();
-    }
+  if(string(GetString("JetInputArray", "")) != "")
+  {
+    fJetInputArray = ImportArray(GetString("JetInputArray", ""));
+    fItJetInputArray = fJetInputArray->MakeIterator();
+  }
 
   // import beamspot
@@ -82,6 +82,6 @@
   {
     fBeamSpotInputArray = 0;
-  }  
- 
+  }
+
   fOutputArray = ExportArray(GetString("OutputArray", "clusters"));
 
@@ -99,10 +99,10 @@
 //------------------------------------------------------------------------------
 
-static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
+static Bool_t secondDescending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
 {
   return (pair0.second > pair1.second);
 }
 
-static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
+static Bool_t secondAscending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
 {
   return (pair0.second < pair1.second);
@@ -118,115 +118,115 @@
   map<Int_t, Double_t> clusterIDToSumPT2;
   map<Int_t, Double_t>::const_iterator itClusterIDToSumPT2;
-  vector<pair<Int_t, Double_t> > sortedClusterIDs;
-  vector<pair<Int_t, Double_t> >::const_iterator itSortedClusterIDs;
-
-  for (Int_t iCluster = 0; iCluster < fInputArray->GetEntries (); iCluster++)
-    {
-      const Candidate &cluster = *((Candidate *) fInputArray->At (iCluster));
-      clusterIDToIndex[cluster.ClusterIndex] = iCluster;
-      clusterIDToSumPT2[cluster.ClusterIndex] = 0.0;
-    }
+  vector<pair<Int_t, Double_t>> sortedClusterIDs;
+  vector<pair<Int_t, Double_t>>::const_iterator itSortedClusterIDs;
+
+  for(Int_t iCluster = 0; iCluster < fInputArray->GetEntries(); iCluster++)
+  {
+    const Candidate &cluster = *((Candidate *)fInputArray->At(iCluster));
+    clusterIDToIndex[cluster.ClusterIndex] = iCluster;
+    clusterIDToSumPT2[cluster.ClusterIndex] = 0.0;
+  }
 
   if(fMethod == "BTV")
-    {
-      if (!fJetInputArray)
-        {
-          cout << "BTV PV sorting selected, but no jet collection given!" << endl;
-          throw 0;
-        }
-
-      fItTrackInputArray->Reset();
-      while((candidate = static_cast<Candidate*>(fItTrackInputArray->Next())))
-        {
-          if (candidate->Momentum.Pt () < 1.0)
-            continue;
-          if (candidate->ClusterIndex < 0)
-            continue;
-          TLorentzVector p (candidate->Momentum.Px (), candidate->Momentum.Py (), candidate->Momentum.Pz (), candidate->Momentum.E ());
-          Bool_t isInJet = false;
-
-          fItJetInputArray->Reset();
-          while((jetCandidate = static_cast<Candidate*>(fItJetInputArray->Next())))
-            {
-              if (jetCandidate->Momentum.Pt () < 30.0)
-                continue;
-              TLorentzVector q (jetCandidate->Momentum.Px (), jetCandidate->Momentum.Py (), jetCandidate->Momentum.Pz (), jetCandidate->Momentum.E ());
-
-              if (p.DeltaR (q) > 0.4)
-                continue;
-              isInJet = true;
-              break;
-            }
-          if (!isInJet)
-            continue;
-
-          clusterIDToSumPT2.at (candidate->ClusterIndex) += candidate->Momentum.Pt () * candidate->Momentum.Pt ();
-        }
-
-      for (itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
-        sortedClusterIDs.push_back (make_pair (itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
-      sort (sortedClusterIDs.begin (), sortedClusterIDs.end (), secondDescending);
-    }
-  else if (fMethod == "GenClosest")
-    {
-      if (!fBeamSpotInputArray)
-        {
-          cout << "GenClosest PV sorting selected, but no beamspot collection given!" << endl;
-          throw 0;
-        }
-      if (!fBeamSpotInputArray->GetSize ())
-        {
-          cout << "Beamspot collection is empty!" << endl;
-          throw 0;
-        }
-
-      beamSpotCandidate = (Candidate *) fBeamSpotInputArray->At (0);
-      for (Int_t iCluster = 0; iCluster < fInputArray->GetEntries (); iCluster++)
-        {
-          const Candidate &cluster = *((Candidate *) fInputArray->At (iCluster));
-          sortedClusterIDs.push_back (make_pair (cluster.ClusterIndex, fabs (cluster.Position.Z () - beamSpotCandidate->Position.Z ())));
-        }
-      sort (sortedClusterIDs.begin (), sortedClusterIDs.end (), secondAscending);
-    }
-  else if (fMethod == "GenBest")
-    {
-      fItTrackInputArray->Reset();
-      while((candidate = static_cast<Candidate*>(fItTrackInputArray->Next())))
-        {
-          if (candidate->IsPU)
-            continue;
-          for (itClusterIDToIndex = clusterIDToIndex.begin(); itClusterIDToIndex != clusterIDToIndex.end(); ++itClusterIDToIndex)
-            {
-              if (candidate->ClusterIndex != itClusterIDToIndex->first)
-                continue;
-              clusterIDToSumPT2.at (itClusterIDToIndex->first) += candidate->Momentum.Pt () * candidate->Momentum.Pt ();
-            }
-        }
-
-      for (itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
-        sortedClusterIDs.push_back (make_pair (itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
-      sort (sortedClusterIDs.begin (), sortedClusterIDs.end (), secondDescending);
-    }
+  {
+    if(!fJetInputArray)
+    {
+      cout << "BTV PV sorting selected, but no jet collection given!" << endl;
+      throw 0;
+    }
+
+    fItTrackInputArray->Reset();
+    while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
+    {
+      if(candidate->Momentum.Pt() < 1.0)
+        continue;
+      if(candidate->ClusterIndex < 0)
+        continue;
+      TLorentzVector p(candidate->Momentum.Px(), candidate->Momentum.Py(), candidate->Momentum.Pz(), candidate->Momentum.E());
+      Bool_t isInJet = false;
+
+      fItJetInputArray->Reset();
+      while((jetCandidate = static_cast<Candidate *>(fItJetInputArray->Next())))
+      {
+        if(jetCandidate->Momentum.Pt() < 30.0)
+          continue;
+        TLorentzVector q(jetCandidate->Momentum.Px(), jetCandidate->Momentum.Py(), jetCandidate->Momentum.Pz(), jetCandidate->Momentum.E());
+
+        if(p.DeltaR(q) > 0.4)
+          continue;
+        isInJet = true;
+        break;
+      }
+      if(!isInJet)
+        continue;
+
+      clusterIDToSumPT2.at(candidate->ClusterIndex) += candidate->Momentum.Pt() * candidate->Momentum.Pt();
+    }
+
+    for(itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
+      sortedClusterIDs.push_back(make_pair(itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
+    sort(sortedClusterIDs.begin(), sortedClusterIDs.end(), secondDescending);
+  }
+  else if(fMethod == "GenClosest")
+  {
+    if(!fBeamSpotInputArray)
+    {
+      cout << "GenClosest PV sorting selected, but no beamspot collection given!" << endl;
+      throw 0;
+    }
+    if(!fBeamSpotInputArray->GetSize())
+    {
+      cout << "Beamspot collection is empty!" << endl;
+      throw 0;
+    }
+
+    beamSpotCandidate = (Candidate *)fBeamSpotInputArray->At(0);
+    for(Int_t iCluster = 0; iCluster < fInputArray->GetEntries(); iCluster++)
+    {
+      const Candidate &cluster = *((Candidate *)fInputArray->At(iCluster));
+      sortedClusterIDs.push_back(make_pair(cluster.ClusterIndex, fabs(cluster.Position.Z() - beamSpotCandidate->Position.Z())));
+    }
+    sort(sortedClusterIDs.begin(), sortedClusterIDs.end(), secondAscending);
+  }
+  else if(fMethod == "GenBest")
+  {
+    fItTrackInputArray->Reset();
+    while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
+    {
+      if(candidate->IsPU)
+        continue;
+      for(itClusterIDToIndex = clusterIDToIndex.begin(); itClusterIDToIndex != clusterIDToIndex.end(); ++itClusterIDToIndex)
+      {
+        if(candidate->ClusterIndex != itClusterIDToIndex->first)
+          continue;
+        clusterIDToSumPT2.at(itClusterIDToIndex->first) += candidate->Momentum.Pt() * candidate->Momentum.Pt();
+      }
+    }
+
+    for(itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
+      sortedClusterIDs.push_back(make_pair(itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
+    sort(sortedClusterIDs.begin(), sortedClusterIDs.end(), secondDescending);
+  }
   else
-    {
-      cout << "\"" << fMethod << "\" is not a valid sorting method!" << endl;
-      cout << "Valid methods are:" << endl;
-      cout << "  BTV" << endl;
-      cout << "  GenClosest" << endl;
-      cout << "  GenBest" << endl;
-      throw 0;
-    }
-  for (itSortedClusterIDs = sortedClusterIDs.begin(); itSortedClusterIDs != sortedClusterIDs.end(); ++itSortedClusterIDs)
-    {
-      Candidate *cluster = (Candidate *) fInputArray->At (clusterIDToIndex.at (itSortedClusterIDs->first));
-      if (fMethod == "BTV")
-        cluster->BTVSumPT2 = itSortedClusterIDs->second;
-      else if (fMethod == "GenClosest")
-        cluster->GenDeltaZ = itSortedClusterIDs->second;
-      else if (fMethod == "GenBest")
-        cluster->GenSumPT2 = itSortedClusterIDs->second;
-      fOutputArray->Add (cluster);
-    }
-}
-
-//------------------------------------------------------------------------------
+  {
+    cout << "\"" << fMethod << "\" is not a valid sorting method!" << endl;
+    cout << "Valid methods are:" << endl;
+    cout << "  BTV" << endl;
+    cout << "  GenClosest" << endl;
+    cout << "  GenBest" << endl;
+    throw 0;
+  }
+  for(itSortedClusterIDs = sortedClusterIDs.begin(); itSortedClusterIDs != sortedClusterIDs.end(); ++itSortedClusterIDs)
+  {
+    Candidate *cluster = (Candidate *)fInputArray->At(clusterIDToIndex.at(itSortedClusterIDs->first));
+    if(fMethod == "BTV")
+      cluster->BTVSumPT2 = itSortedClusterIDs->second;
+    else if(fMethod == "GenClosest")
+      cluster->GenDeltaZ = itSortedClusterIDs->second;
+    else if(fMethod == "GenBest")
+      cluster->GenSumPT2 = itSortedClusterIDs->second;
+    fOutputArray->Add(cluster);
+  }
+}
+
+//------------------------------------------------------------------------------
