Index: external/fastjet/tools/Subtractor.hh
===================================================================
--- external/fastjet/tools/Subtractor.hh	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
+++ external/fastjet/tools/Subtractor.hh	(revision 35cdc461e095e63247ab9dded070d76bc2c888e2)
@@ -1,6 +1,6 @@
-//STARTHEADER
-// $Id: Subtractor.hh 2577 2011-09-13 15:11:38Z salam $
-//
-// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
+//FJSTARTHEADER
+// $Id: Subtractor.hh 3584 2014-08-12 12:40:10Z 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_TOOLS_SUBTRACTOR_HH__
@@ -61,5 +63,5 @@
   /// define a subtractor based on a BackgroundEstimator
   Subtractor(BackgroundEstimatorBase * bge) : 
-    _bge(bge), _rho(-1.0) {}
+    _bge(bge), _rho(-1.0) { set_defaults(); }
 
   /// define a subtractor that uses a fixed value of rho, the background
@@ -68,8 +70,91 @@
 
   /// default constructor
-  Subtractor() : _bge(0), _rho(_invalid_rho) {}
+  Subtractor() : _bge(0), _rho(_invalid_rho) { set_defaults(); }
 
   /// default dtor
   virtual ~Subtractor(){};
+
+  /// @name configuring the behaviour
+  //\{
+  //----------------------------------------------------------------
+
+  /// reset all parameters to default values
+  ///
+  /// Note: by default, the rho_m term is not included and the safety
+  /// test for the mass is not done. This is mostly for backwards
+  /// compatibility with FastJet 3.0 and is highly likely to change in
+  /// a future release of FastJet
+  void set_defaults();
+
+  /// when 'use_rho_m' is true, include in the subtraction the
+  /// correction from rho_m, the purely longitudinal,
+  /// particle-mass-induced component of the background density per
+  /// unit area
+  ///
+  /// Note: this will be switched off by default (for backwards
+  /// compatibility with FastJet 3.0) but is highly likely to change
+  /// in a future release of FastJet
+  void set_use_rho_m(bool use_rho_m_in = true){
+    if (_bge == 0) {
+      throw Error("Subtractor: rho_m support works only for Subtractors constructed with background estimator");
+    }
+    _use_rho_m=use_rho_m_in;
+  }
+  
+  /// returns whether or not the rho_m component is used
+  bool use_rho_m() const{ return _use_rho_m;}
+
+  /// when 'safe_mass' is true, ensure that the mass of the subtracted
+  /// 4-vector remain positive
+  ///
+  /// when true, if the subtracted mass is negative, we return a
+  /// 4-vector with 0 mass, pt and phi from the subtracted 4-vector
+  /// and the rapidity of the original, unsubtracted jet.
+  ///
+  /// Note: this will be switched off by default (for backwards
+  /// compatibility with FastJet 3.0) but is highly likely to change
+  /// in a future release of FastJet
+  void set_safe_mass(bool safe_mass_in=true){ _safe_mass=safe_mass_in;}
+
+  /// returns whether or not safety tests on the mass are included
+  bool safe_mass() const{ return _safe_mass;}
+
+  /// This is mostly intended for cherge-hadron-subtracted type of
+  /// events where we wich to use vertex information to improve the
+  /// subtraction.
+  ///
+  /// Given the following parameters:
+  ///   \param sel_known_vertex    selects the particles with a
+  ///                              known vertex origin
+  ///   \param sel_leading_vertex  amongst the particles with a
+  ///                              known vertex origin, select those
+  ///                              coming from the leading vertex
+  /// Momentum identified as coming from the leading vertex will be
+  /// kept, momentum identified as coming from a non-leading vertex
+  /// will be eliminated and a regular area-median subtraction will be
+  /// applied on the 4-vector sum of the particles with unknown vertex
+  /// origin.
+  ///
+  /// When this is set, we shall ensure that the pt of the subtracted
+  /// 4-vector is at least the pt of the particles that are known to
+  /// come from the leading vertex (if it fails, subtraction returns
+  /// the component that is known to come from the leading vertex ---
+  /// or, the original unsubtracted jet if it contains no particles
+  /// from the leading vertex).  Furthermore, when safe_mass() is on, we
+  /// also impose a similar constraint on the mass of the subtracted
+  /// 4-vector (if the test fails, the longitudinal part of the
+  /// subtracted 4-vector is taken from the component that is known to
+  /// come from the leading vertex).
+  void set_known_selectors(const Selector &sel_known_vertex,
+			   const Selector &sel_leading_vertex){
+    _sel_known_vertex   = sel_known_vertex;
+    _sel_leading_vertex = sel_leading_vertex;
+  }
+
+  //\}
+
+  /// @name description and action
+  //\{
+  //----------------------------------------------------------------
 
   /// returns a jet that's subtracted
@@ -82,5 +167,9 @@
   virtual std::string description() const;
 
+  //\}
 protected:
+  /// compute the 4-vector that should be subtracted from the given
+  /// jet
+  PseudoJet _amount_to_subtract(const PseudoJet &jet) const;
 
   /// the tool used to estimate the background
@@ -89,4 +178,14 @@
   /// the fixed value of rho to use if the user has selected that option
   double _rho;
+
+  // configuration parameters/flags
+  bool _use_rho_m;   ///< include the rho_m correction
+  bool _safe_mass;   ///< ensures that the subtracted mass is +ve
+
+  Selector _sel_known_vertex;   ///< selects the particles with a
+				///< known vertex origin
+  Selector _sel_leading_vertex; ///< amongst the particles with a
+				///< known vertex origin, select those
+				///< coming from the leading vertex
 
   /// a value of rho that is used as a default to label that the stored
@@ -98,4 +197,6 @@
   // that's not allowed in an include file.
   static const double _invalid_rho;
+
+  mutable LimitedWarning _unused_rho_m_warning;
 };
 
