Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // $Id: BottomUpSoftDrop.hh 1085 2017-10-11 02:16:59Z jthaler $
0002 //
0003 // Copyright (c) 2017-, 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 __BOTTOMUPSOFTDROP_HH__
0024 #define __BOTTOMUPSOFTDROP_HH__
0025 
0026 #include "fastjet/ClusterSequence.hh"
0027 #include "fastjet/WrappedStructure.hh"
0028 #include "fastjet/tools/Transformer.hh"
0029 
0030 #include <iostream>
0031 #include <string>
0032 
0033 // TODO
0034 //
0035 //  - missing class description
0036 //
0037 //  - check what to do when pta=ptb=0
0038 //    for the moment, we recombine both for multiple reasons
0039 //     . this avois breakingteh symemtry between pa and pb
0040 //     . it would be groomed in later steps anyway
0041 //    Note that this is slightly inconsistent with our use of
0042 //    > (instead of >=) in the cdt 
0043 
0044 FASTJET_BEGIN_NAMESPACE
0045 
0046 namespace contrib{
0047   
0048 // fwd declarations
0049 class BottomUpSoftDrop;
0050 class BottomUpSoftDropStructure;
0051 class BottomUpSoftDropRecombiner;
0052 class BottomUpSoftDropPlugin;
0053 
0054 //----------------------------------------------------------------------
0055 /// \class BottomUpSoftDrop
0056 /// Implementation of the BottomUpSoftDrop transformer
0057 ///
0058 /// Bottom-Up Soft drop grooms a jet by applying a modified
0059 /// recombination scheme, where particles are recombined only if they
0060 /// pass the Soft Drop condition
0061 ///
0062 /// \f[
0063 ///   z < z_{\rm cut} (\theta/R0)^\beta
0064 /// \f]
0065 ///
0066 /// the groomed jet contains the particles remaining after this
0067 /// pair-wise recombination
0068 ///
0069 /// Note:
0070 ///  - one can use BottomUpSoftDrop on a full event with the
0071 ///    global_grooming(event) method.
0072 ///  - if two recombined particles a and b have momentum pta=ptb=0,
0073 ///    we recombine both.
0074 /// 
0075 
0076   
0077 class BottomUpSoftDrop : public Transformer {
0078 public:
0079   /// minimal constructor, which the jet algorithm to CA, sets the radius
0080   /// to JetDefinition::max_allowable_R (practically equivalent to
0081   /// infinity) and also tries to use a recombiner based on the one in
0082   /// the jet definition of the particular jet being Soft Dropped.
0083   ///
0084   ///  \param beta           the value for beta
0085   ///  \param symmetry_cut   the value for symmetry_cut
0086   ///  \param R0             the value for R0
0087   BottomUpSoftDrop(double beta, double symmetry_cut, double R0 = 1.0) 
0088     : _jet_def(cambridge_algorithm, JetDefinition::max_allowable_R),
0089       _beta(beta),_symmetry_cut(symmetry_cut), _R0(R0),
0090       _get_recombiner_from_jet(true) {}
0091 
0092   /// alternative constructor which takes a specified jet algorithm
0093   ///
0094   ///  \param jet_alg        the jet algorithm for the internal clustering (uses R=infty)
0095   ///  \param symmetry_cut   the value of symmetry_cut
0096   ///  \param beta           the value for beta
0097   ///  \param R0             the value for R0
0098   BottomUpSoftDrop(const JetAlgorithm jet_alg, double beta, double symmetry_cut,
0099            double R0 = 1.0) 
0100     : _jet_def(jet_alg, JetDefinition::max_allowable_R),
0101       _beta(beta), _symmetry_cut(symmetry_cut), _R0(R0),
0102       _get_recombiner_from_jet(true) {}
0103 
0104 
0105   /// alternative ctor in which the full reclustering jet definition can
0106   /// be specified.
0107   ///
0108   ///  \param jet_def        the jet definition for the internal clustering
0109   ///  \param symmetry_cut   the value of symmetry_cut
0110   ///  \param beta           the value for beta
0111   ///  \param R0             the value for R0
0112   BottomUpSoftDrop(const JetDefinition &jet_def, double beta, double symmetry_cut,
0113            double R0 = 1.0)
0114     : _jet_def(jet_def), _beta(beta), _symmetry_cut(symmetry_cut), _R0(R0),
0115       _get_recombiner_from_jet(false) {}
0116 
0117   /// action on a single jet
0118   virtual PseudoJet result(const PseudoJet &jet) const;
0119 
0120   /// global grooming on a full event
0121   /// note: does not support jet areas
0122   virtual std::vector<PseudoJet> global_grooming(const std::vector<PseudoJet> & event) const;
0123   
0124   /// description
0125   virtual std::string description() const;
0126   
0127   // the type of the associated structure
0128   typedef BottomUpSoftDropStructure StructureType;
0129 
0130 private:
0131   /// check if the jet has explicit_ghosts (knowing that there is an
0132   /// area support)
0133   bool _check_explicit_ghosts(const PseudoJet &jet) const;
0134   
0135   /// see if there is a common recombiner among the pieces; if there
0136   /// is return true and set jet_def_for_recombiner so that the
0137   /// recombiner can be taken from that JetDefinition. Otherwise,
0138   /// return false. 'assigned' is initially false; when true, each
0139   /// time we meet a new jet definition, we'll check it shares the
0140   /// same recombiner as jet_def_for_recombiner.
0141   bool _check_common_recombiner(const PseudoJet &jet, 
0142                 JetDefinition &jet_def_for_recombiner,
0143                 bool assigned=false) const;
0144 
0145 
0146   JetDefinition _jet_def; ///< the internal jet definition
0147   double _beta;           ///< the value of beta
0148   double _symmetry_cut;   ///< the value of symmetry_cut
0149   double _R0;             ///< the value of R0
0150   bool   _get_recombiner_from_jet; ///< true for minimal constructor,
0151                                    ///< causes recombiner to be set equal 
0152                                    ///< to that already used in the jet 
0153                                    ///< (if it can be deduced)
0154 };
0155 
0156 //----------------------------------------------------------------------
0157 /// The structure associated with a PseudoJet thas has gone through a
0158 /// bottom/up SoftDrop transformer
0159 class BottomUpSoftDropStructure : public WrappedStructure{
0160 public:
0161   /// default ctor
0162   ///  \param result_jet  the jet for which we have to keep the structure
0163   BottomUpSoftDropStructure(const PseudoJet & result_jet)
0164     : WrappedStructure(result_jet.structure_shared_ptr()){}
0165 
0166   /// description
0167   virtual std::string description() const{
0168     return "Bottom/Up Soft Dropped PseudoJet";
0169   }
0170 
0171   /// return the constituents that have been rejected
0172   std::vector<PseudoJet> rejected() const{ 
0173     return validated_cs()->childless_pseudojets();
0174   }
0175 
0176   /// return the other jets that may have been found along with the
0177   /// result of the bottom/up Soft Drop
0178   /// The resulting vector is sorted in pt
0179   std::vector<PseudoJet> extra_jets() const {
0180     return sorted_by_pt((!SelectorNHardest(1))(validated_cs()->inclusive_jets()));
0181   }
0182 
0183   /// return the value of beta that was used for this specific Soft Drop.
0184   double beta() const {return _beta;}
0185 
0186   /// return the value of symmetry_cut that was used for this specific Soft Drop.
0187   double symmetry_cut() const {return _symmetry_cut;}
0188 
0189   /// return the value of R0 that was used for this specific Soft Drop.
0190   double R0() const {return _R0;}
0191 
0192 protected:
0193   friend class BottomUpSoftDrop; ///< to allow setting the internal information
0194 
0195 private:
0196   double _beta, _symmetry_cut, _R0;
0197 };
0198 
0199 //----------------------------------------------------------------------
0200 /// Class for Soft Drop recombination
0201 /// recombines the objects that are not vetoed by Bottom-Up SoftDrop
0202 ///
0203 /// This recombiner only recombines, using the provided 'recombiner',
0204 /// objects (i and j) that pass the following SoftDrop criterion:
0205 ///
0206 ///   min(pti, ptj) > zcut (pti+ptj) (theta_ij/R0)^beta
0207 ///
0208 /// If the criterion fail, the hardest of i and j is kept and the
0209 /// softest is rejected.
0210 ///
0211 /// Note that this in not meant for standalone use [in particular
0212 /// because it could lead to memory issues due to the rejected indices
0213 /// stored internally].
0214 ///
0215 /// This class is a direct adaptation of PruningRecombiner in Fastjet tools
0216 class BottomUpSoftDropRecombiner : public JetDefinition::Recombiner {
0217 public:
0218   /// ctor
0219   ///  \param symmetry_cut   value of cut on symmetry measure
0220   ///  \param beta   avalue of beta parameter
0221   ///  \param recomb pointer to a recombiner to use to cluster pairs
0222   BottomUpSoftDropRecombiner(double beta, double symmetry_cut, double R0,
0223                              const JetDefinition::Recombiner *recombiner)
0224     : _beta(beta), _symmetry_cut(symmetry_cut), _R0sqr(R0*R0),
0225       _recombiner(recombiner) {}
0226 
0227   /// perform a recombination taking into account the Soft Drop
0228   /// conditions
0229   virtual void recombine(const PseudoJet &pa, 
0230              const PseudoJet &pb,
0231              PseudoJet &pab) const;
0232 
0233   /// returns the description of the recombiner
0234   virtual std::string description() const {
0235     std::ostringstream oss;
0236     oss << "SoftDrop recombiner with symmetry_cut = " << _symmetry_cut
0237     << ", beta = " << _beta
0238     << ", and underlying recombiner = " << _recombiner->description();
0239     return oss.str();    
0240   }
0241 
0242   /// return the history indices that have been soft dropped away
0243   const std::vector<unsigned int> & rejected() const{ return _rejected;}
0244 
0245   /// clears the list of rejected indices
0246   ///
0247   /// If one decides to use this recombiner standalone, one has to
0248   /// call this after each clustering in order for the rejected() vector
0249   /// to remain sensible and not grow to infinite size.
0250   void clear_rejected(){ _rejected.clear();}
0251 
0252 private:
0253   double _beta;          ///< beta parameter
0254   double _symmetry_cut;  ///< value of symmetry_cut
0255   double _R0sqr;         ///< normalisation of the angular distance
0256   const JetDefinition::Recombiner *_recombiner; ///< the underlying recombiner to use
0257   mutable std::vector<unsigned int> _rejected;  ///< list of rejected history indices
0258 };
0259 
0260 //----------------------------------------------------------------------
0261 /// \class BottomUpSoftDropPlugin
0262 /// Class for a bottom/up Soft Drop algorithm, based on the Pruner plugin
0263 ///
0264 /// This is an internal plugin that clusters the particles using the
0265 /// BottomUpRecombiner. 
0266 ///
0267 /// See BottomUpRecombiner for a description of what bottom-up
0268 /// SoftDrop does.
0269 ///
0270 /// Note that this is an internal class used by the BottomUpSoftDrop
0271 /// transformer and it is not meant to be used as a standalone
0272 /// clustering tool.
0273 class BottomUpSoftDropPlugin : public JetDefinition::Plugin {
0274 public:
0275   /// ctor
0276   ///  \param jet_def the jet definition to be used for the 
0277   ///                 internal clustering
0278   ///  \param symmetry_cut    value of cut on symmetry measure
0279   ///  \param beta    value of beta parameter
0280   BottomUpSoftDropPlugin(const JetDefinition &jet_def, double beta, double symmetry_cut,
0281                          double R0 = 1.0)
0282     : _jet_def(jet_def), _beta(beta), _symmetry_cut(symmetry_cut), _R0(R0) {}
0283 
0284   /// the actual clustering work for the plugin
0285   virtual void run_clustering(ClusterSequence &input_cs) const;
0286 
0287   /// description of the plugin
0288   virtual std::string description() const;
0289 
0290   /// returns the radius
0291   virtual double R() const {return _jet_def.R();}
0292 
0293 private:
0294   JetDefinition _jet_def; ///< the internal jet definition
0295   double _beta;           ///< beta parameter
0296   double _symmetry_cut;   ///< value of symmetry_cut 
0297   double _R0;             ///< normalisation of the angular distance
0298 };
0299 
0300 }
0301 
0302 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
0303 #endif // __BOTTOMUPSOFTDROP_HH__