Index: external/fastjet/internal/ClosestPair2D.hh
===================================================================
--- external/fastjet/internal/ClosestPair2D.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/ClosestPair2D.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: ClosestPair2D.hh 2577 2011-09-13 15:11:38Z salam $
-//
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//FJSTARTHEADER
+// $Id: ClosestPair2D.hh 3433 2014-07-23 08:17:03Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 #ifndef __FASTJET_CLOSESTPAIR2D__HH__
Index: external/fastjet/internal/ClosestPair2DBase.hh
===================================================================
--- external/fastjet/internal/ClosestPair2DBase.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/ClosestPair2DBase.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: ClosestPair2DBase.hh 2577 2011-09-13 15:11:38Z salam $
+//FJSTARTHEADER
+// $Id: ClosestPair2DBase.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 #ifndef __FASTJET_CLOSESTPAIR2DBASE__HH__
Index: external/fastjet/internal/ClusterSequence_N2.icc
===================================================================
--- external/fastjet/internal/ClusterSequence_N2.icc	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/ClusterSequence_N2.icc	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -4,8 +4,8 @@
 #include "fastjet/ClusterSequence.hh"
 
-//STARTHEADER
+//FJSTARTHEADER
 // $Id: ClusterSequence_N2.cc 1351 2009-01-09 18:03:03Z salam $
 //
-// Copyright (c) 2005-2009, Matteo Cacciari, Gavin Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -18,7 +18,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -28,9 +30,7 @@
 //
 //  You should have received a copy of the GNU General Public License
-//  along with FastJet; if not, write to the Free Software
-//  Foundation, Inc.:
-//      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 //----------------------------------------------------------------------
Index: external/fastjet/internal/Dnn2piCylinder.hh
===================================================================
--- external/fastjet/internal/Dnn2piCylinder.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/Dnn2piCylinder.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: Dnn2piCylinder.hh 2577 2011-09-13 15:11:38Z salam $
-//
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//FJSTARTHEADER
+// $Id: Dnn2piCylinder.hh 3442 2014-07-24 07:20:49Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
@@ -73,14 +75,14 @@
   /// Returns the index of  the nearest neighbour of point labelled
   /// by ii (assumes ii is valid)
-  int NearestNeighbourIndex(const int & ii) const ;
+  int NearestNeighbourIndex(const int ii) const ;
 
   /// Returns the distance to the nearest neighbour of point labelled
   /// by index ii (assumes ii is valid)
-  double NearestNeighbourDistance(const int & ii) const ;
+  double NearestNeighbourDistance(const int ii) const ;
 
   /// Returns true iff the given index corresponds to a point that
   /// exists in the DNN structure (meaning that it has been added, and
   /// not removed in the meantime)
-  bool Valid(const int & index) const;
+  bool Valid(const int index) const;
 
   void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
@@ -216,5 +218,5 @@
 /// initialised the class with instructions to ignore this problem the
 /// program will detect and ignore it, or crash.
-inline int Dnn2piCylinder::NearestNeighbourIndex(const int & current) const {
+inline int Dnn2piCylinder::NearestNeighbourIndex(const int current) const {
   int main_index = _mirror_info[current].main_index;
   int mirror_index = _mirror_info[current].mirror_index;
@@ -241,5 +243,5 @@
 }
 
-inline double Dnn2piCylinder::NearestNeighbourDistance(const int & current) const {
+inline double Dnn2piCylinder::NearestNeighbourDistance(const int current) const {
   int main_index = _mirror_info[current].main_index;
   int mirror_index = _mirror_info[current].mirror_index;
@@ -256,5 +258,5 @@
 }
 
-inline bool Dnn2piCylinder::Valid(const int & index) const {
+inline bool Dnn2piCylinder::Valid(const int index) const {
   return (_DNN->Valid(_mirror_info[index].main_index));
 }
Index: external/fastjet/internal/Dnn3piCylinder.hh
===================================================================
--- external/fastjet/internal/Dnn3piCylinder.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/Dnn3piCylinder.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: Dnn3piCylinder.hh 2577 2011-09-13 15:11:38Z salam $
-//
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//FJSTARTHEADER
+// $Id: Dnn3piCylinder.hh 3442 2014-07-24 07:20:49Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
@@ -70,14 +72,14 @@
   /// Returns the index of  the nearest neighbour of point labelled
   /// by ii (assumes ii is valid)
-  int NearestNeighbourIndex(const int & ii) const ;
+  int NearestNeighbourIndex(const int ii) const ;
 
   /// Returns the distance to the nearest neighbour of point labelled
   /// by index ii (assumes ii is valid)
-  double NearestNeighbourDistance(const int & ii) const ;
+  double NearestNeighbourDistance(const int ii) const ;
 
   /// Returns true iff the given index corresponds to a point that
   /// exists in the DNN structure (meaning that it has been added, and
   /// not removed in the meantime)
-  bool Valid(const int & index) const;
+  bool Valid(const int index) const;
 
   void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
@@ -204,5 +206,5 @@
 /// initialised the class with instructions to ignore this problem the
 /// program will detect and ignore it, or crash.
-inline int Dnn3piCylinder::NearestNeighbourIndex(const int & current) const {
+inline int Dnn3piCylinder::NearestNeighbourIndex(const int current) const {
   int main_index = _mirror_info[current].main_index;
   int mirror_index = _mirror_info[current].mirror_index;
@@ -229,5 +231,5 @@
 }
 
-inline double Dnn3piCylinder::NearestNeighbourDistance(const int & current) const {
+inline double Dnn3piCylinder::NearestNeighbourDistance(const int current) const {
   int main_index = _mirror_info[current].main_index;
   int mirror_index = _mirror_info[current].mirror_index;
@@ -244,5 +246,5 @@
 }
 
-inline bool Dnn3piCylinder::Valid(const int & index) const {
+inline bool Dnn3piCylinder::Valid(const int index) const {
   return (_DNN->Valid(_mirror_info[index].main_index));
 }
Index: external/fastjet/internal/Dnn4piCylinder.hh
===================================================================
--- external/fastjet/internal/Dnn4piCylinder.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/Dnn4piCylinder.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: Dnn4piCylinder.hh 2577 2011-09-13 15:11:38Z salam $
+//FJSTARTHEADER
+// $Id: Dnn4piCylinder.hh 3442 2014-07-24 07:20:49Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
@@ -57,14 +59,14 @@
   /// Returns the index of  the nearest neighbour of point labelled
   /// by ii (assumes ii is valid)
-  int NearestNeighbourIndex(const int & ii) const ;
+  int NearestNeighbourIndex(const int ii) const ;
 
   /// Returns the distance to the nearest neighbour of point labelled
   /// by index ii (assumes ii is valid)
-  double NearestNeighbourDistance(const int & ii) const ;
+  double NearestNeighbourDistance(const int ii) const ;
 
   /// Returns true iff the given index corresponds to a point that
   /// exists in the DNN structure (meaning that it has been added, and
   /// not removed in the meantime)
-  bool Valid(const int & index) const;
+  bool Valid(const int index) const;
 
   void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
@@ -98,5 +100,5 @@
 // functions defined above
 
-inline int Dnn4piCylinder::NearestNeighbourIndex(const int & current) const {
+inline int Dnn4piCylinder::NearestNeighbourIndex(const int current) const {
   return (_DNN1->NearestNeighbourDistance(current) < 
 	  _DNN2->NearestNeighbourDistance(current)) ? 
@@ -105,5 +107,5 @@
 }
 
-inline double Dnn4piCylinder::NearestNeighbourDistance(const int & current) const {
+inline double Dnn4piCylinder::NearestNeighbourDistance(const int current) const {
   return (_DNN1->NearestNeighbourDistance(current) < 
 	  _DNN2->NearestNeighbourDistance(current)) ? 
@@ -112,5 +114,5 @@
 }
 
-inline bool Dnn4piCylinder::Valid(const int & index) const {
+inline bool Dnn4piCylinder::Valid(const int index) const {
   return (_DNN1->Valid(index) && _DNN2->Valid(index));
 }
Index: external/fastjet/internal/DnnPlane.hh
===================================================================
--- external/fastjet/internal/DnnPlane.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/DnnPlane.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: DnnPlane.hh 2577 2011-09-13 15:11:38Z salam $
-//
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//FJSTARTHEADER
+// $Id: DnnPlane.hh 3442 2014-07-24 07:20:49Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
@@ -44,4 +46,11 @@
 /// class derived from DynamicNearestNeighbours that provides an
 /// implementation for the Euclidean plane
+///
+/// This class that uses CGAL Delaunay triangulation for most of the
+/// work (it allows for easy and efficient removal and addition of
+/// points and circulation over a point's neighbours). The treatment
+/// of coincident points is not supported by CGAL and is implemented
+/// according to the method specified in
+/// issue-tracker/2012-02-CGAL-coincident/METHOD
 /// \endif
 class DnnPlane : public DynamicNearestNeighbours {
@@ -57,14 +66,14 @@
   /// Returns the index of  the nearest neighbour of point labelled
   /// by ii (assumes ii is valid)
-  int NearestNeighbourIndex(const int & ii) const ;
+  int NearestNeighbourIndex(const int ii) const ;
 
   /// Returns the distance to the nearest neighbour of point labelled
   /// by index ii (assumes ii is valid)
-  double NearestNeighbourDistance(const int & ii) const ;
+  double NearestNeighbourDistance(const int ii) const ;
 
   /// Returns true iff the given index corresponds to a point that
   /// exists in the DNN structure (meaning that it has been added, and
   /// not removed in the meantime)
-  bool Valid(const int & index) const;
+  bool Valid(const int index) const;
 
   void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
@@ -80,5 +89,5 @@
   double phi(const int i) const;
 
- private:
+private:
 
   /// Structure containing a vertex_handle and cached information on
@@ -88,4 +97,6 @@
     double NNdistance;
     int NNindex;
+    int coincidence;  // ==vertex->info.val() if no coincidence
+                      // points to the coinciding SV in case of coincidence
     // later on for cylinder put a second vertex?
   };
@@ -95,6 +106,6 @@
   bool _verbose;
 
-  static const bool _crash_on_coincidence = true;
-  //static const bool _crash_on_coincidence = false;
+  //static const bool _crash_on_coincidence = true;
+  static const bool _crash_on_coincidence = false;
 
   Triangulation _TR; /// CGAL object for dealing with triangulations
@@ -111,5 +122,5 @@
   /// Determines the index and distance of the nearest neighbour to 
   /// point j and puts the information into the _supervertex entry for j
-  void _SetNearest(const int & j);
+  void _SetNearest(const int j);
 
   //----------------------------------------------------------------------
@@ -123,13 +134,93 @@
   /// Note that j is NOT pushed onto indices_of_updated_neighbours --
   /// if you want it there, put it there yourself.
-  void _SetAndUpdateNearest(const int & j, 
+  void _SetAndUpdateNearest(const int j, 
 			    std::vector<int> & indices_of_updated_neighbours);
 
   /// given a vertex_handle returned by CGAL on insertion of a new
-  /// points, crash if it turns out that it corresponds to a vertex
-  /// that we already knew about (usually because two points coincide)
-  void _CrashIfVertexPresent(const Vertex_handle & vertex, 
-			     const int & its_index);
-
+  /// points, returns the coinciding vertex's value if it turns out
+  /// that it corresponds to a vertex that we already knew about
+  /// (usually because two points coincide)
+  int _CheckIfVertexPresent(const Vertex_handle & vertex, 
+			    const int its_index);
+
+  //----------------------------------------------------------------------
+  /// if the distance between 'pref' and 'candidate' is smaller (or
+  /// equal) than the one between 'pref' and 'near', return true and
+  /// set 'mindist' to that distance. Note that it is assumed that
+  /// 'mindist' is the euclidian distance between 'pref' and 'near'
+  ///
+  /// Note that the 'near' point is passed through its vertex rather
+  /// than as a point. This allows us to handle cases where we have no min
+  /// yet (near is the infinite vertex)
+  inline bool _is_closer_to(const Point &pref, 
+			    const Point &candidate,
+			    const Vertex_handle &near,
+			    double & dist,
+			    double & mindist){
+    dist = _euclid_distance(pref, candidate);
+    return _is_closer_to_with_hint(pref, candidate, near, dist, mindist);
+  }
+
+  /// same as '_is_closer_to' except that 'dist' already contains the
+  /// distance between 'pref' and 'candidate'
+  inline bool _is_closer_to_with_hint(const Point &pref, 
+				      const Point &candidate,
+				      const Vertex_handle &near,
+				      const double & dist,
+				      double & mindist){
+    
+    // check if 'dist', the pre-computed distance between 'candidate'
+    // and 'pref' is smaller than the distance between 'pref' and its
+    // currently registered nearest neighbour 'near' (and update
+    // things if it is)
+    //
+    // Interestingly enough, it has to be pointed out that the use of
+    // 'abs' instead of 'std::abs' returns wrong results (apparently
+    // ints without any compiler warning)
+    //
+    // The (near != NULL) test is there for one single reason: when
+    // checking that a newly inserted point is not closer than a
+    // previous NN, if that distance comparison involves a "nearly
+    // degenerate" distance we need to access near->point. But
+    // sometimes, in the course of RemoveAndAddPoints, its previous NN
+    // has been deleted and its vertex (corresponding to 'near') set
+    // to NULL. This is not a problem as all points having a deleted
+    // point as NN will have their NN explicitly recomputed at the end
+    // of RemoveAndAddPoints so here we should just make sure there is
+    // no crash... that's done by checking (near != NULL)
+    if ((std::abs(dist-mindist)<DISTANCE_FOR_CGAL_CHECKS) &&
+	(near != NULL) &&
+	(_euclid_distance(candidate, near->point())<DISTANCE_FOR_CGAL_CHECKS)){
+      // we're in a situation where there might be a rounding issue,
+      // use CGAL's distance computation to get it right
+      //
+      // Note that in the test right above,
+      // (abs(dist-mindist)<1e-12) guarantees that the current
+      // nearest point is not the infinite vertex and thus
+      // nearest->point() is not ill-defined
+      if (_verbose) std::cout << "using CGAL's distance ordering" << std::endl;
+      if (CGAL::compare_distance_to_point(pref, candidate, near->point())!=CGAL::LARGER){
+	mindist = dist;
+	return true;
+      }
+    } else if (dist <= mindist) {
+      // Note that the use of a <= in the above expression (instead of
+      // a strict ordering <) is important in one case: when checking
+      // if a new point is the new NN of one of the points in its
+      // neighbourhood, in case of distances being ==, we are sure
+      // that 'candidate' is in a cell adjacent to 'pref' while it may
+      // no longer be the case for 'near'
+      mindist = dist;
+      return true;
+    } 
+    
+    return false;
+  }
+
+  /// if a distance between a point and 2 others is smaller than this
+  /// and the distance between the two points is also smaller than this
+  /// then use CGAL to compare the distances. 
+  static const double DISTANCE_FOR_CGAL_CHECKS;  
+  
 };
 
@@ -138,11 +229,11 @@
 // functions defined above
 
-inline int DnnPlane::NearestNeighbourIndex(const int & ii) const {
+inline int DnnPlane::NearestNeighbourIndex(const int ii) const {
   return _supervertex[ii].NNindex;}
 
-inline double DnnPlane::NearestNeighbourDistance(const int & ii) const {
+inline double DnnPlane::NearestNeighbourDistance(const int ii) const {
   return _supervertex[ii].NNdistance;}
 
-inline bool DnnPlane::Valid(const int & index) const {
+inline bool DnnPlane::Valid(const int index) const {
   if (index >= 0 && index < static_cast<int>(_supervertex.size())) {
     return (_supervertex[index].vertex != NULL);} else {return false;} }
Index: external/fastjet/internal/DynamicNearestNeighbours.hh
===================================================================
--- external/fastjet/internal/DynamicNearestNeighbours.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/DynamicNearestNeighbours.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: DynamicNearestNeighbours.hh 2687 2011-11-14 11:17:51Z soyez $
+//FJSTARTHEADER
+// $Id: DynamicNearestNeighbours.hh 3619 2014-08-13 14:17:19Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
@@ -37,4 +39,5 @@
 #include<cassert>
 #include "fastjet/internal/numconsts.hh"
+#include "fastjet/Error.hh"
 
 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
@@ -68,15 +71,9 @@
 /// Nearest Neighbours code
 /// \endif
-class DnnError {
+class DnnError : public Error {
 public:
   // constructors
-  DnnError() {;};
-  DnnError(const std::string & message_in) {
-    _message = message_in; std::cerr << message_in << std::endl;};
-
-  std::string message() const {return _message;};
-
-private:
-  std::string _message;
+  //DnnError() {}
+  DnnError(const std::string & message_in) : Error(message_in) {}
 };
 
@@ -112,14 +109,14 @@
   /// Returns the index of the nearest neighbour of point labelled
   /// by ii (assumes ii is valid)
-  virtual int NearestNeighbourIndex(const int & ii) const = 0;
+  virtual int NearestNeighbourIndex(const int ii) const = 0;
 
   /// Returns the distance to the nearest neighbour of point labelled
   /// by index ii (assumes ii is valid)
-  virtual double NearestNeighbourDistance(const int & ii) const = 0;
+  virtual double NearestNeighbourDistance(const int ii) const = 0;
 
   /// Returns true iff the given index corresponds to a point that
   /// exists in the DNN structure (meaning that it has been added, and
   /// not removed in the meantime)
-  virtual bool Valid(const int & index) const = 0;
+  virtual bool Valid(const int index) const = 0;
 
   /// remove the points labelled by the std::vector indices_to_remove, and
@@ -141,5 +138,5 @@
   /// Remove the point labelled by index and return the list of
   /// points whose nearest neighbours have changed in the process
-  inline void RemovePoint (const int & index,
+  inline void RemovePoint (const int index,
 			   std::vector<int> & indices_of_updated_neighbours) {
     std::vector<int> indices_added;
@@ -158,5 +155,5 @@
   /// point).
   inline void RemoveCombinedAddCombination(
-			const int & index1, const int & index2,
+			const int index1, const int index2,
 			const EtaPhi & newpoint,
 			int & index3,
Index: external/fastjet/internal/IsBase.hh
===================================================================
--- external/fastjet/internal/IsBase.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/IsBase.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: IsBase.hh 3071 2013-04-01 12:52:46Z cacciari $
+//FJSTARTHEADER
+// $Id: IsBase.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 #ifndef __FASTJET_INTERNAL_IS_BASE_HH__
Index: external/fastjet/internal/LazyTiling25.hh
===================================================================
--- external/fastjet/internal/LazyTiling25.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
+++ external/fastjet/internal/LazyTiling25.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -0,0 +1,195 @@
+#ifndef __FASTJET_LAZYTILING25_HH__
+#define __FASTJET_LAZYTILING25_HH__
+
+// #define INSTRUMENT2 1
+
+//FJSTARTHEADER
+// $Id: LazyTiling25.hh 3477 2014-07-29 14:34:39Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//
+//----------------------------------------------------------------------
+// This file is part of FastJet.
+//
+//  FastJet is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  The algorithms that underlie FastJet have required considerable
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
+//  FastJet as part of work towards a scientific publication, please
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
+//
+//  FastJet is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
+//----------------------------------------------------------------------
+//FJENDHEADER
+
+//#include "fastjet/PseudoJet.hh"
+#include "fastjet/internal/MinHeap.hh"
+#include "fastjet/ClusterSequence.hh"
+#include "fastjet/internal/LazyTiling9Alt.hh"
+#include "fastjet/internal/LazyTiling9.hh"
+
+
+
+FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
+
+typedef Tile2Base<25> Tile25;
+
+
+// class Tile25 {
+// public:
+//   /// pointers to neighbouring tiles, including self
+//   Tile25 *   begin_tiles[25];
+//   /// neighbouring tiles, excluding self
+//   Tile25 **  surrounding_tiles; 
+//   /// half of neighbouring tiles, no self
+//   Tile25 **  RH_tiles;  
+//   /// just beyond end of tiles
+//   Tile25 **  end_tiles; 
+//   /// start of list of BriefJets contained in this tile
+//   TiledJet * head;    
+//   /// sometimes useful to be able to tag a tile
+//   bool     tagged;    
+//   /// for all particles in the tile, this stores the largest of the
+//   /// (squared) nearest-neighbour distances.
+//   double max_NN_dist;
+//   double eta_centre, phi_centre;
+// 
+//   bool is_near_zero_phi(double tile_size_phi) const {
+//     return phi_centre < 2*tile_size_phi || (twopi-phi_centre) < 2*tile_size_phi;
+//   }
+// };
+
+
+//----------------------------------------------------------------------
+class LazyTiling25 {
+public:
+  LazyTiling25(ClusterSequence & cs);
+
+  void run();
+
+protected:
+  ClusterSequence & _cs;
+  const std::vector<PseudoJet> & _jets;
+  std::vector<Tile25> _tiles;
+
+#ifdef INSTRUMENT2
+  int _ncall; // GPS tmp
+  int _ncall_dtt; // GPS tmp
+#endif // INSTRUMENT2
+
+  double _Rparam, _R2, _invR2;
+  double _tiles_eta_min, _tiles_eta_max;
+  double _tile_size_eta, _tile_size_phi;
+  double _tile_half_size_eta, _tile_half_size_phi;
+  int    _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
+
+  std::vector<TiledJet *> _jets_for_minheap;
+  
+  //MinHeap _minheap;
+
+  void _initialise_tiles();
+
+  // reasonably robust return of tile index given ieta and iphi, in particular
+  // it works even if iphi is negative
+  inline int _tile_index (int ieta, int iphi) const {
+    // note that (-1)%n = -1 so that we have to add _n_tiles_phi
+    // before performing modulo operation
+    return (ieta-_tiles_ieta_min)*_n_tiles_phi
+                  + (iphi+_n_tiles_phi) % _n_tiles_phi;
+  }
+
+  void  _bj_remove_from_tiles(TiledJet * const jet);
+
+  /// returns the tile index given the eta and phi values of a jet
+  int _tile_index(const double eta, const double phi) const;
+
+  // sets up information regarding the tiling of the given jet
+  void _tj_set_jetinfo(TiledJet * const jet, const int _jets_index);
+
+  void _print_tiles(TiledJet * briefjets ) const;
+  void _add_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles) const;
+  void _add_untagged_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  void _add_untagged_neighbours_to_tile_union_using_max_info(const TiledJet * const jet, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  double _distance_to_tile(const TiledJet * bj, const Tile25 *) 
+#ifdef INSTRUMENT2
+    ;
+#else
+    const;
+#endif 
+  void _update_jetX_jetI_NN(TiledJet * jetX, TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
+
+  void _set_NN(TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
+
+  // return the diJ (multiplied by _R2) for this jet assuming its NN
+  // info is correct
+  template <class J> double _bj_diJ(const J * const jet) const {
+    double kt2 = jet->kt2;
+    if (jet->NN != NULL) {if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
+    return jet->NN_dist * kt2;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline void _bj_set_jetinfo(
+                            J * const jetA, const int _jets_index) const {
+    jetA->eta  = _jets[_jets_index].rap();
+    jetA->phi  = _jets[_jets_index].phi_02pi();
+    jetA->kt2  = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
+    jetA->_jets_index = _jets_index;
+    // initialise NN info as well
+    jetA->NN_dist = _R2;
+    jetA->NN      = NULL;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist(
+                const J * const jetA, const J * const jetB) 
+#ifdef INSTRUMENT2
+    {
+    _ncall++; // GPS tmp
+#else
+    const {
+#endif 
+    double dphi = std::abs(jetA->phi - jetB->phi);
+    double deta = (jetA->eta - jetB->eta);
+    if (dphi > pi) {dphi = twopi - dphi;}
+    return dphi*dphi + deta*deta;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist_not_periodic(
+                const J * const jetA, const J * const jetB)
+#ifdef INSTRUMENT2
+    {
+    _ncall++; // GPS tmp
+#else
+    const {
+#endif 
+    //_ncall++; // GPS tmp
+    double dphi = jetA->phi - jetB->phi;
+    double deta = (jetA->eta - jetB->eta);
+    return dphi*dphi + deta*deta;
+  }
+
+};
+
+
+FASTJET_END_NAMESPACE
+
+#endif // __FASTJET_LAZYTILING25_HH__
Index: external/fastjet/internal/LazyTiling9.hh
===================================================================
--- external/fastjet/internal/LazyTiling9.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
+++ external/fastjet/internal/LazyTiling9.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -0,0 +1,240 @@
+#ifndef __FASTJET_LAZYTILING9_HH__
+#define __FASTJET_LAZYTILING9_HH__
+
+//#define INSTRUMENT2 1
+
+//FJSTARTHEADER
+// $Id: LazyTiling9.hh 3477 2014-07-29 14:34:39Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//
+//----------------------------------------------------------------------
+// This file is part of FastJet.
+//
+//  FastJet is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  The algorithms that underlie FastJet have required considerable
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
+//  FastJet as part of work towards a scientific publication, please
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
+//
+//  FastJet is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
+//----------------------------------------------------------------------
+//FJENDHEADER
+
+//#include "fastjet/PseudoJet.hh"
+#include "fastjet/internal/MinHeap.hh"
+#include "fastjet/ClusterSequence.hh"
+#include "fastjet/internal/LazyTiling9Alt.hh"
+
+
+FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
+template<int NN>
+class Tile2Base {
+public:
+  /// pointers to neighbouring tiles, including self
+  Tile2Base *   begin_tiles[NN]; 
+  /// neighbouring tiles, excluding self
+  Tile2Base **  surrounding_tiles; 
+  /// half of neighbouring tiles, no self
+  Tile2Base **  RH_tiles;  
+  /// just beyond end of tiles
+  Tile2Base **  end_tiles; 
+  /// start of list of BriefJets contained in this tile
+  TiledJet * head;    
+  /// sometimes useful to be able to tag a tile
+  bool     tagged;    
+  /// true for tiles where the delta phi calculation needs
+  /// potentially to account for periodicity in phi
+  bool     use_periodic_delta_phi;
+  /// for all particles in the tile, this stores the largest of the
+  /// (squared) nearest-neighbour distances.
+  double max_NN_dist;
+  double eta_centre, phi_centre;
+
+  /// returns the number of jets in the tile; useful principally for
+  /// diagnostics
+  int jet_count() const {
+    int count = 0;
+    const TiledJet * jet = head;
+    while (jet != 0) {
+      count++;
+      jet = jet->next;
+    }
+    return count;
+  }
+};
+
+
+typedef Tile2Base<9> Tile2;
+
+// class Tile2 : public Tile2Base {
+// public:
+//   /// pointers to neighbouring tiles, including self
+//   Tile2 *   begin_tiles[n_tile_neighbours]; 
+//   bool is_near_zero_phi(double tile_size_phi) const {
+//     return phi_centre < tile_size_phi || (twopi-phi_centre) < tile_size_phi;
+//   }
+// };
+
+// class Tile2  {
+// public:
+//   /// pointers to neighbouring tiles, including self
+//   Tile2 *   begin_tiles[n_tile_neighbours]; 
+//   /// neighbouring tiles, excluding self
+//   Tile2 **  surrounding_tiles; 
+//   /// half of neighbouring tiles, no self
+//   Tile2 **  RH_tiles;  
+//   /// just beyond end of tiles
+//   Tile2 **  end_tiles; 
+//   /// start of list of BriefJets contained in this tile
+//   TiledJet * head;    
+//   /// sometimes useful to be able to tag a tile
+//   bool     tagged;    
+//   /// for all particles in the tile, this stores the largest of the
+//   /// (squared) nearest-neighbour distances.
+//   double max_NN_dist;
+//   double eta_centre, phi_centre;
+//   bool is_near_zero_phi(double tile_size_phi) const {
+//     return phi_centre < tile_size_phi || (twopi-phi_centre) < tile_size_phi;
+//   }
+// };
+
+
+
+//----------------------------------------------------------------------
+class LazyTiling9 {
+public:
+  LazyTiling9(ClusterSequence & cs);
+
+  void run();
+
+  //void get_next_clustering(int & jetA_index, int & jetB_index, double & dij);
+  
+
+protected:
+  ClusterSequence & _cs;
+  const std::vector<PseudoJet> & _jets;
+  std::vector<Tile2> _tiles;
+
+#ifdef INSTRUMENT2
+  int _ncall; // GPS tmp
+  int _ncall_dtt; // GPS tmp
+#endif // INSTRUMENT2
+
+  double _Rparam, _R2, _invR2;
+  double _tiles_eta_min, _tiles_eta_max;
+  double _tile_size_eta, _tile_size_phi;
+  double _tile_half_size_eta, _tile_half_size_phi;
+  int    _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
+
+  std::vector<TiledJet *> _jets_for_minheap;
+  
+  //MinHeap _minheap;
+
+  void _initialise_tiles();
+
+  // reasonably robust return of tile index given ieta and iphi, in particular
+  // it works even if iphi is negative
+  inline int _tile_index (int ieta, int iphi) const {
+    // note that (-1)%n = -1 so that we have to add _n_tiles_phi
+    // before performing modulo operation
+    return (ieta-_tiles_ieta_min)*_n_tiles_phi
+                  + (iphi+_n_tiles_phi) % _n_tiles_phi;
+  }
+
+  void  _bj_remove_from_tiles(TiledJet * const jet);
+
+  /// returns the tile index given the eta and phi values of a jet
+  int _tile_index(const double eta, const double phi) const;
+
+  // sets up information regarding the tiling of the given jet
+  void _tj_set_jetinfo(TiledJet * const jet, const int _jets_index);
+
+  void _print_tiles(TiledJet * briefjets ) const;
+  void _add_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles) const;
+  void _add_untagged_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  void _add_untagged_neighbours_to_tile_union_using_max_info(const TiledJet * const jet, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  double _distance_to_tile(const TiledJet * bj, const Tile2 *) 
+#ifdef INSTRUMENT2
+    ;
+#else
+    const;
+#endif 
+  void _update_jetX_jetI_NN(TiledJet * jetX, TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
+
+  void _set_NN(TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
+
+  // return the diJ (multiplied by _R2) for this jet assuming its NN
+  // info is correct
+  template <class J> double _bj_diJ(const J * const jet) const {
+    double kt2 = jet->kt2;
+    if (jet->NN != NULL) {if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
+    return jet->NN_dist * kt2;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline void _bj_set_jetinfo(
+                            J * const jetA, const int _jets_index) const {
+    jetA->eta  = _jets[_jets_index].rap();
+    jetA->phi  = _jets[_jets_index].phi_02pi();
+    jetA->kt2  = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
+    jetA->_jets_index = _jets_index;
+    // initialise NN info as well
+    jetA->NN_dist = _R2;
+    jetA->NN      = NULL;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist(
+                const J * const jetA, const J * const jetB) 
+#ifdef INSTRUMENT2
+    {
+    _ncall++; // GPS tmp
+#else
+    const {
+#endif 
+    double dphi = std::abs(jetA->phi - jetB->phi);
+    double deta = (jetA->eta - jetB->eta);
+    if (dphi > pi) {dphi = twopi - dphi;}
+    return dphi*dphi + deta*deta;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist_not_periodic(
+                const J * const jetA, const J * const jetB)
+#ifdef INSTRUMENT2
+    {
+    _ncall++; // GPS tmp
+#else
+    const {
+#endif 
+    //_ncall++; // GPS tmp
+    double dphi = jetA->phi - jetB->phi;
+    double deta = (jetA->eta - jetB->eta);
+    return dphi*dphi + deta*deta;
+  }
+
+};
+
+
+FASTJET_END_NAMESPACE
+
+#endif // __FASTJET_LAZYTILING9_HH__
Index: external/fastjet/internal/LazyTiling9Alt.hh
===================================================================
--- external/fastjet/internal/LazyTiling9Alt.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
+++ external/fastjet/internal/LazyTiling9Alt.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -0,0 +1,226 @@
+#ifndef __FASTJET_LAZYTILING9ALT_HH__
+#define __FASTJET_LAZYTILING9ALT_HH__
+
+//FJSTARTHEADER
+// $Id: LazyTiling9Alt.hh 3477 2014-07-29 14:34:39Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//
+//----------------------------------------------------------------------
+// This file is part of FastJet.
+//
+//  FastJet is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  The algorithms that underlie FastJet have required considerable
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
+//  FastJet as part of work towards a scientific publication, please
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
+//
+//  FastJet is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
+//----------------------------------------------------------------------
+//FJENDHEADER
+
+//#include "fastjet/PseudoJet.hh"
+#include "fastjet/internal/MinHeap.hh"
+#include "fastjet/ClusterSequence.hh"
+
+FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
+
+/// structure analogous to BriefJet, but with the extra information
+/// needed for dealing with tiles
+class TiledJet {
+public:
+  double     eta, phi, kt2, NN_dist;
+  TiledJet * NN, *previous, * next; 
+  int        _jets_index, tile_index;
+  bool _minheap_update_needed;
+
+  // indicate whether jets need to have their minheap entries
+  // updated).
+  inline void label_minheap_update_needed() {_minheap_update_needed = true;}
+  inline void label_minheap_update_done()   {_minheap_update_needed = false;}
+  inline bool minheap_update_needed() const {return _minheap_update_needed;}
+};
+
+const int n_tile_neighbours = 9;
+
+class Tile {
+public:
+  typedef double (Tile::*DistToTileFn)(const TiledJet*) const;
+  typedef std::pair<Tile *, DistToTileFn> TileFnPair;
+  /// pointers to neighbouring tiles, including self
+  TileFnPair begin_tiles[n_tile_neighbours]; 
+  /// neighbouring tiles, excluding self
+  TileFnPair *  surrounding_tiles; 
+  /// half of neighbouring tiles, no self
+  TileFnPair *  RH_tiles;  
+  /// just beyond end of tiles
+  TileFnPair *  end_tiles; 
+  /// start of list of BriefJets contained in this tile
+  TiledJet * head;    
+  /// sometimes useful to be able to tag a tile
+  bool     tagged;    
+  /// true for tiles where the delta phi calculation needs
+  /// potentially to account for periodicity in phi
+  bool     use_periodic_delta_phi;
+  /// for all particles in the tile, this stores the largest of the
+  /// (squared) nearest-neighbour distances.
+  double max_NN_dist;
+  double eta_min, eta_max, phi_min, phi_max;
+
+  double distance_to_centre(const TiledJet *) const {return 0;}
+  double distance_to_left(const TiledJet * jet) const {
+    double deta = jet->eta - eta_min;
+    return deta*deta;
+  }
+  double distance_to_right(const TiledJet * jet) const {
+    double deta = jet->eta - eta_max;
+    return deta*deta;
+  }
+  double distance_to_bottom(const TiledJet * jet) const {
+    double dphi = jet->phi - phi_min;
+    return dphi*dphi;
+  }
+  double distance_to_top(const TiledJet * jet) const {
+    double dphi = jet->phi - phi_max;
+    return dphi*dphi;
+  }
+
+  double distance_to_left_top(const TiledJet * jet) const {
+    double deta = jet->eta - eta_min;
+    double dphi = jet->phi - phi_max;
+    return deta*deta + dphi*dphi;
+  }
+  double distance_to_left_bottom(const TiledJet * jet) const {
+    double deta = jet->eta - eta_min;
+    double dphi = jet->phi - phi_min;
+    return deta*deta + dphi*dphi;
+  }
+  double distance_to_right_top(const TiledJet * jet) const {
+    double deta = jet->eta - eta_max;
+    double dphi = jet->phi - phi_max;
+    return deta*deta + dphi*dphi;
+  }
+  double distance_to_right_bottom(const TiledJet * jet) const {
+    double deta = jet->eta - eta_max;
+    double dphi = jet->phi - phi_min;
+    return deta*deta + dphi*dphi;
+  }
+
+  
+};
+
+//----------------------------------------------------------------------
+class LazyTiling9Alt {
+public:
+  LazyTiling9Alt(ClusterSequence & cs);
+
+  void run();
+
+  //void get_next_clustering(int & jetA_index, int & jetB_index, double & dij);
+  
+
+protected:
+  ClusterSequence & _cs;
+  const std::vector<PseudoJet> & _jets;
+  std::vector<Tile> _tiles;
+
+
+  double _Rparam, _R2, _invR2;
+  double _tiles_eta_min, _tiles_eta_max;
+  double _tile_size_eta, _tile_size_phi;
+  double _tile_half_size_eta, _tile_half_size_phi;
+  int    _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
+
+  std::vector<TiledJet *> _jets_for_minheap;
+  
+  //MinHeap _minheap;
+
+  void _initialise_tiles();
+
+  // reasonably robust return of tile index given ieta and iphi, in particular
+  // it works even if iphi is negative
+  inline int _tile_index (int ieta, int iphi) const {
+    // note that (-1)%n = -1 so that we have to add _n_tiles_phi
+    // before performing modulo operation
+    return (ieta-_tiles_ieta_min)*_n_tiles_phi
+                  + (iphi+_n_tiles_phi) % _n_tiles_phi;
+  }
+
+  void  _bj_remove_from_tiles(TiledJet * const jet);
+
+  /// returns the tile index given the eta and phi values of a jet
+  int _tile_index(const double eta, const double phi) const;
+
+  // sets up information regarding the tiling of the given jet
+  void _tj_set_jetinfo(TiledJet * const jet, const int _jets_index);
+
+  void _print_tiles(TiledJet * briefjets ) const;
+  void _add_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles) const;
+  void _add_untagged_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  void _add_untagged_neighbours_to_tile_union_using_max_info(const TiledJet * const jet, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  //double _distance_to_tile(const TiledJet * bj, const Tile *) const;
+  void _update_jetX_jetI_NN(TiledJet * jetX, TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
+
+  void _set_NN(TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
+
+  // return the diJ (multiplied by _R2) for this jet assuming its NN
+  // info is correct
+  template <class J> double _bj_diJ(const J * const jet) const {
+    double kt2 = jet->kt2;
+    if (jet->NN != NULL) {if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
+    return jet->NN_dist * kt2;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline void _bj_set_jetinfo(
+                            J * const jetA, const int _jets_index) const {
+    jetA->eta  = _jets[_jets_index].rap();
+    jetA->phi  = _jets[_jets_index].phi_02pi();
+    jetA->kt2  = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
+    jetA->_jets_index = _jets_index;
+    // initialise NN info as well
+    jetA->NN_dist = _R2;
+    jetA->NN      = NULL;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist(
+                const J * const jetA, const J * const jetB) const {
+    double dphi = std::abs(jetA->phi - jetB->phi);
+    double deta = (jetA->eta - jetB->eta);
+    if (dphi > pi) {dphi = twopi - dphi;}
+    return dphi*dphi + deta*deta;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist_not_periodic(
+                const J * const jetA, const J * const jetB) const {
+    double dphi = jetA->phi - jetB->phi;
+    double deta = (jetA->eta - jetB->eta);
+    return dphi*dphi + deta*deta;
+  }
+
+};
+
+
+FASTJET_END_NAMESPACE
+
+#endif // __FASTJET_LAZYTILING9ALT_HH__
Index: external/fastjet/internal/LazyTiling9SeparateGhosts.hh
===================================================================
--- external/fastjet/internal/LazyTiling9SeparateGhosts.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
+++ external/fastjet/internal/LazyTiling9SeparateGhosts.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -0,0 +1,195 @@
+#ifndef __FASTJET_LAZYTILING9SEPARATEGHOSTS_HH__
+#define __FASTJET_LAZYTILING9SEPARATEGHOSTS_HH__
+
+//FJSTARTHEADER
+// $Id: LazyTiling9SeparateGhosts.hh 3596 2014-08-12 15:27:19Z soyez $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//
+//----------------------------------------------------------------------
+// This file is part of FastJet.
+//
+//  FastJet is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  The algorithms that underlie FastJet have required considerable
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
+//  FastJet as part of work towards a scientific publication, please
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
+//
+//  FastJet is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
+//----------------------------------------------------------------------
+//FJENDHEADER
+
+//#include "fastjet/PseudoJet.hh"
+#include "fastjet/internal/MinHeap.hh"
+#include "fastjet/ClusterSequence.hh"
+#include "fastjet/internal/LazyTiling9Alt.hh"
+
+FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
+
+class TiledJet3 {
+public:
+  double     eta, phi, kt2, NN_dist;
+  TiledJet3 * NN, *previous, * next; 
+  int        _jets_index, tile_index;
+  bool _minheap_update_needed;
+  bool is_ghost;
+
+  // indicate whether jets need to have their minheap entries
+  // updated).
+  inline void label_minheap_update_needed() {_minheap_update_needed = true;}
+  inline void label_minheap_update_done()   {_minheap_update_needed = false;}
+  inline bool minheap_update_needed() const {return _minheap_update_needed;}
+};
+
+
+class Tile3 {
+public:
+  /// pointers to neighbouring tiles, including self
+  Tile3 *   begin_tiles[n_tile_neighbours]; 
+  /// neighbouring tiles, excluding self
+  Tile3 **  surrounding_tiles; 
+  /// half of neighbouring tiles, no self
+  Tile3 **  RH_tiles;  
+  /// just beyond end of tiles
+  Tile3 **  end_tiles; 
+  /// start of list of BriefJets contained in this tile
+  TiledJet3 * head;    
+  /// start of list of BriefJets contained in this tile
+  TiledJet3 * ghost_head;    
+  /// sometimes useful to be able to tag a tile
+  bool     tagged;    
+  /// for all particles in the tile, this stores the largest of the
+  /// (squared) nearest-neighbour distances.
+  double max_NN_dist;
+  double eta_centre, phi_centre;
+
+  bool is_near_zero_phi(double tile_size_phi) const {
+    return phi_centre < tile_size_phi || (twopi-phi_centre) < tile_size_phi;
+  }
+};
+
+
+//----------------------------------------------------------------------
+class LazyTiling9SeparateGhosts {
+public:
+  LazyTiling9SeparateGhosts(ClusterSequence & cs);
+
+  void run();
+
+  //void get_next_clustering(int & jetA_index, int & jetB_index, double & dij);
+
+  /// this is the pt2 threshold below which particles will be
+  /// considered as ghosts.
+  ///
+  /// Note that as it stands, a user can decide to change that
+  /// value. Note however that this has to be done at the user's own
+  /// risk (this is an internal part of fastjet).In a similar spirit,
+  /// the interface to access this valus might also change in a future
+  /// release of FastJet.
+  static double ghost_pt2_threshold;
+
+protected:
+  ClusterSequence & _cs;
+  const std::vector<PseudoJet> & _jets;
+  std::vector<Tile3> _tiles;
+
+
+  double _Rparam, _R2, _invR2;
+  double _tiles_eta_min, _tiles_eta_max;
+  double _tile_size_eta, _tile_size_phi;
+  double _tile_half_size_eta, _tile_half_size_phi;
+  int    _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
+
+  std::vector<TiledJet3 *> _jets_for_minheap;
+  
+  //MinHeap _minheap;
+
+  void _initialise_tiles();
+
+  // reasonably robust return of tile index given ieta and iphi, in particular
+  // it works even if iphi is negative
+  inline int _tile_index (int ieta, int iphi) const {
+    // note that (-1)%n = -1 so that we have to add _n_tiles_phi
+    // before performing modulo operation
+    return (ieta-_tiles_ieta_min)*_n_tiles_phi
+                  + (iphi+_n_tiles_phi) % _n_tiles_phi;
+  }
+
+  void  _bj_remove_from_tiles(TiledJet3 * const jet);
+
+  /// returns the tile index given the eta and phi values of a jet
+  int _tile_index(const double eta, const double phi) const;
+
+  // sets up information regarding the tiling of the given jet
+  void _tj_set_jetinfo(TiledJet3 * const jet, const int _jets_index, bool is_ghost);
+
+  void _print_tiles(TiledJet3 * briefjets ) const;
+  void _add_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles) const;
+  void _add_untagged_neighbours_to_tile_union(const int tile_index, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  void _add_untagged_neighbours_to_tile_union_using_max_info(const TiledJet3 * const jet, 
+		 std::vector<int> & tile_union, int & n_near_tiles);
+  double _distance_to_tile(const TiledJet3 * bj, const Tile3 *) const;
+  void _update_jetX_jetI_NN(TiledJet3 * jetX, TiledJet3 * jetI, std::vector<TiledJet3 *> & jets_for_minheap);
+
+  void _set_NN(TiledJet3 * jetI, std::vector<TiledJet3 *> & jets_for_minheap);
+
+  // return the diJ (multiplied by _R2) for this jet assuming its NN
+  // info is correct
+  template <class J> double _bj_diJ(const J * const jet) const {
+    double kt2 = jet->kt2;
+    if (jet->NN != NULL) {if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
+    return jet->NN_dist * kt2;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline void _bj_set_jetinfo(
+                            J * const jetA, const int _jets_index) const {
+    jetA->eta  = _jets[_jets_index].rap();
+    jetA->phi  = _jets[_jets_index].phi_02pi();
+    jetA->kt2  = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
+    jetA->_jets_index = _jets_index;
+    // initialise NN info as well
+    jetA->NN_dist = _R2;
+    jetA->NN      = NULL;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist(
+                const J * const jetA, const J * const jetB) const {
+    double dphi = std::abs(jetA->phi - jetB->phi);
+    double deta = (jetA->eta - jetB->eta);
+    if (dphi > pi) {dphi = twopi - dphi;}
+    return dphi*dphi + deta*deta;
+  }
+
+
+  //----------------------------------------------------------------------
+  template <class J> inline double _bj_dist_not_periodic(
+                const J * const jetA, const J * const jetB) const {
+    double dphi = jetA->phi - jetB->phi;
+    double deta = (jetA->eta - jetB->eta);
+    return dphi*dphi + deta*deta;
+  }
+
+};
+
+
+FASTJET_END_NAMESPACE
+
+#endif // __FASTJET_LAZYTILING9SEPARATEGHOSTS_HH__
Index: external/fastjet/internal/LimitedWarning.hh
===================================================================
--- external/fastjet/internal/LimitedWarning.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/LimitedWarning.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -2,8 +2,8 @@
 #define __FASTJET_INTERNALLIMITEDWARNING_HH__
 
-//STARTHEADER
-// $Id: LimitedWarning.hh 2577 2011-09-13 15:11:38Z salam $
+//FJSTARTHEADER
+// $Id: LimitedWarning.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -16,7 +16,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -28,5 +30,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
Index: external/fastjet/internal/MinHeap.hh
===================================================================
--- external/fastjet/internal/MinHeap.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/MinHeap.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: MinHeap.hh 2577 2011-09-13 15:11:38Z salam $
+//FJSTARTHEADER
+// $Id: MinHeap.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 #ifndef __FASTJET_MINHEAP__HH__
@@ -50,18 +52,26 @@
   /// expansion to a maximum size max_size;
   MinHeap (const std::vector<double> & values, unsigned int max_size) :
-    _heap(max_size) {_initialise(values);};
+    _heap(max_size) {initialise(values);}
+
+  /// do the minimal setup for a MinHeap that can reach max_size;
+  /// initialisation must be performed later with the actual values.
+  MinHeap (unsigned int max_size) : _heap(max_size) {}
 
   /// constructor in which the the maximum size is the size of the values array
   MinHeap (const std::vector<double> & values) :
-    _heap(values.size()) {_initialise(values);};
-  
+    _heap(values.size()) {initialise(values);}
+
+  /// initialise the heap with the supplied values. Should only be called if
+  /// the constructor did not supply values.
+  void initialise(const std::vector<double> & values);
+
   /// return the location of the minimal value on the heap
   inline unsigned int minloc() const {
-    return (_heap[0].minloc) - &(_heap[0]);};
+    return (_heap[0].minloc) - &(_heap[0]);}
   
   /// return the minimal value on the heap
-  inline double       minval() const {return _heap[0].minloc->value;};
+  inline double       minval() const {return _heap[0].minloc->value;}
 
-  inline double operator[](int i) const {return _heap[i].value;};
+  inline double operator[](int i) const {return _heap[i].value;}
 
   /// remove the value at the specified location (i.e. replace it with
@@ -82,5 +92,4 @@
   std::vector<ValueLoc> _heap;
 
-  void _initialise(const std::vector<double> & values);
 
 
Index: external/fastjet/internal/SearchTree.hh
===================================================================
--- external/fastjet/internal/SearchTree.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/SearchTree.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: SearchTree.hh 3107 2013-05-03 15:47:47Z salam $
+//FJSTARTHEADER
+// $Id: SearchTree.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
@@ -188,7 +190,12 @@
 public:
 
-  // so that it can access out _node object;
+  // so that it can access our _node object;
   // note: "class U" needed for clang (v1.1 branches/release_27) compilation
-  template<class U> friend class SearchTree<U>::const_circulator;
+  // 2014-07-22: as reported by Torbjorn Sjostrand,
+  // the next line was giving a warning with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
+  // (dependent nested name specifier 'SearchTree<U>::' for friend class declaration is not supported)
+  // Just commenting it out, things still seem to work; same with a template of type T
+  //template<class U> friend class SearchTree<U>::const_circulator;
+  friend class SearchTree<T>::const_circulator;
   friend class SearchTree<T>;
 
Index: external/fastjet/internal/TilingExtent.hh
===================================================================
--- external/fastjet/internal/TilingExtent.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
+++ external/fastjet/internal/TilingExtent.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -0,0 +1,69 @@
+#ifndef __FASTJET_TILINGEXTENT_HH__
+#define __FASTJET_TILINGEXTENT_HH__
+
+#include "fastjet/ClusterSequence.hh"
+
+//FJSTARTHEADER
+// $Id: TilingExtent.hh 3433 2014-07-23 08:17:03Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//
+//----------------------------------------------------------------------
+// This file is part of FastJet.
+//
+//  FastJet is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  The algorithms that underlie FastJet have required considerable
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
+//  FastJet as part of work towards a scientific publication, please
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
+//
+//  FastJet is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
+//----------------------------------------------------------------------
+//FJENDHEADER
+
+FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
+
+//----------------------------------------------------------------------
+/// class to perform a fast analysis of the appropriate rapidity range
+/// in which to perform tiling
+class TilingExtent {
+public:
+  /// constructor that takes a ClusterSequence in a state where the
+  /// initial particles have been set up, but before clustering has
+  /// started.
+  TilingExtent(ClusterSequence & cs);
+
+  /// returns the suggested minimum rapidity for the tiling
+  double minrap() const {return _minrap;}
+  /// returns the suggested maximum rapidity for the tiling
+  double maxrap() const {return _maxrap;}
+
+  /// internally, the class bins the particle multiplicity versus
+  /// rapidity, in bins of size 1 running roughly from minrap to maxrap
+  /// (including overflows); this function returns the sum of squares
+  /// of bin contents, which may be informative for deciding strategy
+  /// choices.
+  double sum_of_binned_squared_multiplicity() const {return _cumul2;}
+
+private:
+  double _minrap, _maxrap, _cumul2;
+
+  /// attempts to calculate a sensible rapidity extent for the tiling
+  void _determine_rapidity_extent(const std::vector<PseudoJet> & particles);
+};
+
+FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
+
+#endif // __FASTJET_TILINGEXTENT_HH__
Index: external/fastjet/internal/Triangulation.hh
===================================================================
--- external/fastjet/internal/Triangulation.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/Triangulation.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -3,8 +3,8 @@
 #define __FASTJET_TRIANGULATION__
 
-//STARTHEADER
-// $Id: Triangulation.hh 2595 2011-09-23 09:05:04Z salam $
+//FJSTARTHEADER
+// $Id: Triangulation.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -17,7 +17,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -29,5 +31,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
Index: external/fastjet/internal/Voronoi.hh
===================================================================
--- external/fastjet/internal/Voronoi.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/Voronoi.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -2,28 +2,33 @@
 #define __FASTJET__VORONOI_H__
 
-//STARTHEADER
-// $Id: Voronoi.hh 2686 2011-11-14 09:28:22Z soyez $
-//
-// Copyright (c) 1994 by AT&T Bell Laboratories (see below)
-//
+//FJSTARTHEADER
+// $Id: Voronoi.hh 3433 2014-07-23 08:17:03Z salam $
+//
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
-// This file is included as part of FastJet but was mostly written by
-// S. Fortune in C, put into C++ with memory management by S
-// O'Sullivan, and with further interface and memeory management
-// modifications by Gregory Soyez.
-//
-// Permission to use, copy, modify, and distribute this software for
-// any purpose without fee is hereby granted, provided that this
-// entire notice is included in all copies of any software which is or
-// includes a copy or modification of this software and in all copies
-// of the supporting documentation for such software. THIS SOFTWARE IS
-// BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY.
-// IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY REPRESENTATION
-// OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
-// SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
-//
+// This file is part of FastJet.
+//
+//  FastJet is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  The algorithms that underlie FastJet have required considerable
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
+//  FastJet as part of work towards a scientific publication, please
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
+//
+//  FastJet is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
Index: external/fastjet/internal/base.hh
===================================================================
--- external/fastjet/internal/base.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/base.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,7 +1,7 @@
 
-//STARTHEADER
-// $Id: base.hh 2717 2011-11-17 14:15:46Z salam $
+//FJSTARTHEADER
+// $Id: base.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -14,7 +14,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -26,5 +28,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 #ifndef __FASTJET_FASTJET_BASE_HH__
Index: external/fastjet/internal/numconsts.hh
===================================================================
--- external/fastjet/internal/numconsts.hh	(revision d69dfe4aebfe1009f10ecbbabd92ce813ba93f3e)
+++ external/fastjet/internal/numconsts.hh	(revision 7f12612f929223b34f3414cb67376700b31bc728)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: numconsts.hh 2577 2011-09-13 15:11:38Z salam $
+//FJSTARTHEADER
+// $Id: numconsts.hh 3433 2014-07-23 08:17:03Z salam $
 //
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
 //
 //----------------------------------------------------------------------
@@ -13,7 +13,9 @@
 //
 //  The algorithms that underlie FastJet have required considerable
-//  development and are described in hep-ph/0512210. If you use
+//  development. They are described in the original FastJet paper,
+//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
 //  FastJet as part of work towards a scientific publication, please
-//  include a citation to the FastJet paper.
+//  quote the version you use and include a citation to the manual and
+//  optionally also to hep-ph/0512210.
 //
 //  FastJet is distributed in the hope that it will be useful,
@@ -25,5 +27,5 @@
 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
 //----------------------------------------------------------------------
-//ENDHEADER
+//FJENDHEADER
 
 
