Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:14

0001 // $Id: RecursiveSoftDrop.hh 1192 2018-10-30 16:08:36Z gsoyez $
0002 //
0003 // Copyright (c) 2014-, Gavin P. Salam, Gregory Soyez, Jesse Thaler,
0004 // Kevin Zhou, Frederic Dreyer
0005 //
0006 //----------------------------------------------------------------------
0007 // This file is part of FastJet contrib.
0008 //
0009 // It is free software; you can redistribute it and/or modify it under
0010 // the terms of the GNU General Public License as published by the
0011 // Free Software Foundation; either version 2 of the License, or (at
0012 // your option) any later version.
0013 //
0014 // It is distributed in the hope that it will be useful, but WITHOUT
0015 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0016 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
0017 // License for more details.
0018 //
0019 // You should have received a copy of the GNU General Public License
0020 // along with this code. If not, see <http://www.gnu.org/licenses/>.
0021 //----------------------------------------------------------------------
0022 
0023 #ifndef __RECURSIVESOFTDROP_HH__
0024 #define __RECURSIVESOFTDROP_HH__
0025 
0026 // we'll use the native FJ class for reculstering if available
0027 #if FASTJET_VERSION_NUMBER >= 30100
0028 #include "fastjet/tools/Recluster.hh"
0029 #else
0030 #include "Recluster.hh"
0031 #endif
0032 #include "SoftDrop.hh"
0033 #include "fastjet/WrappedStructure.hh"
0034 
0035 #include <iostream>
0036 #include <queue>
0037 #include <vector>
0038 
0039 FASTJET_BEGIN_NAMESPACE
0040 
0041 namespace contrib{
0042 
0043 //------------------------------------------------------------------------
0044 /// \class RecursiveSoftDrop
0045 /// An implementation of the RecursiveSoftDrop.
0046 ///
0047 /// Recursive Soft Drop will recursively groom a jet, removing
0048 /// particles that fail the criterion
0049 /// \f[
0050 ///     z > z_{\rm cut} (\theta/R0)^\beta
0051 /// \f]
0052 /// until n subjets have been found.
0053 ///
0054 /// Several variants are supported:
0055 ///  - set_fixed_depth_mode() switches to fixed depth on all branches
0056 ///    of the clustering tree
0057 ///  - set_dynamical_R0() switches to dynamical R0 implementation of
0058 ///    RSD
0059 ///  - set_hardest_branch_only() switches to following only the
0060 ///    hardest branch (e.g. for Iterated Soft Drop)
0061 ///  - set_min_deltaR_square(val) sets a minimum angle considered for
0062 ///    substructure (e.g. for Iterated Soft Drop)
0063 ///
0064 /// Notes:
0065 ///
0066 ///  - Even though the calls to "set_tagging_mode()" or
0067 ///    "set_grooming_mode(false)" are allowed, they should not be used
0068 ///    with n=-1, and the default grooming_mode has to remain
0069 ///    untouched (except for beta<0 and finite n).
0070 ///
0071 //----------------------------------------------------------------------
0072 class RecursiveSoftDrop : public SoftDrop {
0073 public:
0074   /// Simplified constructor. This takes the value of the "beta"
0075   /// parameter and the symmetry cut (applied by default on the
0076   /// scalar_z variable, as for the mMDT). It also takes an optional
0077   /// subtractor.
0078   ///
0079   /// n is the number of times we require the SoftDrop condition to be
0080   /// satisfied. n=-1 means infinity, i.e. we recurse into the jet
0081   /// until individual constituents
0082   ///
0083   /// If the (optional) pileup subtractor can be supplied, then see
0084   /// also the documentation for the set_input_jet_is_subtracted() member
0085   /// function.
0086   ///
0087   /// \param beta               the value of the beta parameter
0088   /// \param symmetry_cut       the value of the cut on the symmetry measure
0089   /// \param n                  the requested number of iterations
0090   /// \param R0                 the angular distance normalisation [1 by default]
0091   RecursiveSoftDrop(double beta,
0092                     double symmetry_cut,
0093                     int n = -1,
0094                     double R0 = 1,
0095                     const FunctionOfPseudoJet<PseudoJet> * subtractor = 0) : 
0096     SoftDrop(beta, symmetry_cut, R0, subtractor), _n(n) { set_defaults(); }
0097 
0098   /// Full constructor, which takes the following parameters:
0099   ///
0100   /// \param beta               the value of the beta parameter
0101   /// \param symmetry_cut       the value of the cut on the symmetry measure
0102   /// \param symmetry_measure   the choice of measure to use to estimate the symmetry
0103   /// \param n                  the requested number of iterations
0104   /// \param R0                 the angular distance normalisation [1 by default]
0105   /// \param mu_cut             the maximal allowed value of mass drop variable mu = m_heavy/m_parent 
0106   /// \param recursion_choice   the strategy used to decide which subjet to recurse into
0107   /// \param subtractor         an optional pointer to a pileup subtractor (ignored if zero)
0108   RecursiveSoftDrop(double           beta,
0109                     double           symmetry_cut, 
0110                     SymmetryMeasure  symmetry_measure,
0111                     int              n = -1,
0112                     double           R0 = 1.0,
0113                     double           mu_cut = std::numeric_limits<double>::infinity(), 
0114                     RecursionChoice  recursion_choice = larger_pt,
0115                     const FunctionOfPseudoJet<PseudoJet> * subtractor = 0) : 
0116     SoftDrop(beta, symmetry_cut, symmetry_measure, R0, mu_cut, recursion_choice, subtractor),
0117     _n(n) { set_defaults(); }
0118 
0119   /// default destructor
0120   virtual ~RecursiveSoftDrop(){}
0121 
0122   //----------------------------------------------------------------------
0123   // access to class info
0124   int n() const { return _n; }
0125   
0126   //----------------------------------------------------------------------
0127   // on top of the tweaks that we inherit from SoftDrop (via
0128   // RecursiveSymmetryBase):
0129   //  - set_verbose_structure()
0130   //  - set_subtractor()
0131   //  - set_input_jet_is_subtracted()
0132   // we provide several other knobs, given below
0133 
0134   /// initialise all the flags below to their default value
0135   void set_defaults();
0136   
0137   /// switch to using the "same depth" variant where instead of
0138   /// recursing from large to small angles and requiring n SD
0139   /// conditions to be met (our default), we recurse simultaneously in
0140   /// all the branches found during the previous iteration, up to a
0141   /// maximum depth of n.
0142   /// default: false
0143   void set_fixed_depth_mode(bool value=true) { _fixed_depth = value; }
0144   bool fixed_depth_mode() const { return _fixed_depth; }
0145   
0146   /// switch to using a dynamical R0 (used for the normalisation of
0147   /// the symmetry measure) set by the last deltaR at which some
0148   /// substructure was found.
0149   /// default: false
0150   void set_dynamical_R0(bool value=true) { _dynamical_R0 = value; }
0151   bool use_dynamical_R0() const { return _dynamical_R0; }
0152 
0153   /// when finding some substructure, only follow the hardest branch
0154   /// for the recursion
0155   /// default: false (i.e. recurse in both branches)
0156   void set_hardest_branch_only(bool value=true) { _hardest_branch_only = value; }
0157   bool use_hardest_branch_only() const { return _hardest_branch_only; }
0158 
0159   /// set the minimum angle (squared) that we should consider for
0160   /// substructure
0161   /// default: -1.0 (i.e. no minimum)
0162   void set_min_deltaR_squared(double value=-1.0) { _min_dR2 = value; }
0163   double   min_deltaR_squared() const { return _min_dR2; }
0164 
0165   /// description of the tool
0166   virtual std::string description() const;
0167 
0168   //----------------------------------------------------------------------
0169   /// action on a single jet with RecursiveSoftDrop.
0170   ///
0171   /// uses "result_fixed_tags" by default (i.e. recurse from R0 to
0172   /// smaller angles until n SD conditions have been met), or
0173   /// "result_fixed_depth" where each of the previous SD branches are
0174   /// recirsed into down to a depth of n.
0175   virtual PseudoJet result(const PseudoJet &jet) const;
0176 
0177   /// this routine applies the Soft Drop criterion recursively on the
0178   /// CA tree until we find n subjets (or until it converges), and
0179   /// adds them together into a groomed PseudoJet
0180   PseudoJet result_fixed_tags(const PseudoJet &jet) const;
0181 
0182   /// this routine applies the Soft Drop criterion recursively on the
0183   /// CA tree, recursing into all the branches found during the previous iteration
0184   /// until n layers have been found (or until it converges)
0185   PseudoJet result_fixed_depth(const PseudoJet &jet) const;
0186     
0187 protected:  
0188   /// return false if we reached desired layer of grooming _n
0189   bool continue_grooming(int current_n) const {
0190     return ((_n < 0) or (current_n < _n));
0191   }
0192   
0193 private:
0194   int    _n;            ///< the value of n
0195 
0196   // behaviour tweaks
0197   bool _fixed_depth;         ///< look in parallel into each all branches until depth n
0198   bool _dynamical_R0;        ///< when true, use the last deltaR with substructure as D0
0199   bool _hardest_branch_only; ///< recurse only in the hardest branch
0200                              ///  when substructure is found
0201   double _min_dR2;           ///< the min allowed angle to search for substructure
0202 };
0203 
0204 // helper to get the (linear) list of prongs inside a jet resulting
0205 // from RecursiveSoftDrop. This would avoid having amnually to go
0206 // through the successive pairwise compositeness
0207 std::vector<PseudoJet> recursive_soft_drop_prongs(const PseudoJet & rsd_jet);
0208 
0209 }
0210 
0211 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
0212 #endif // __RECURSIVESOFTDROP_HH__