Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:03:33

0001 #ifndef __FASTJET_CONTRIB_TOOLS_RECLUSTER_HH__
0002 #define __FASTJET_CONTRIB_TOOLS_RECLUSTER_HH__
0003 
0004 // $Id: Recluster.hh 1444 2024-12-09 18:15:56Z salam $
0005 //
0006 // Copyright (c) 2014-, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
0007 //
0008 //----------------------------------------------------------------------
0009 // This file is part of FastJet contrib.
0010 //
0011 // It is free software; you can redistribute it and/or modify it under
0012 // the terms of the GNU General Public License as published by the
0013 // Free Software Foundation; either version 2 of the License, or (at
0014 // your option) any later version.
0015 //
0016 // It is distributed in the hope that it will be useful, but WITHOUT
0017 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0018 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
0019 // License for more details.
0020 //
0021 // You should have received a copy of the GNU General Public License
0022 // along with this code. If not, see <http://www.gnu.org/licenses/>.
0023 //----------------------------------------------------------------------
0024 
0025 #include <fastjet/JetDefinition.hh>
0026 #include <fastjet/CompositeJetStructure.hh> // to derive the ReclusterStructure from CompositeJetStructure
0027 #include <fastjet/tools/Transformer.hh>     // to derive Recluster from Transformer
0028 #include <iostream>
0029 #include <string>
0030 
0031 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0032 
0033 namespace contrib{
0034 
0035 //----------------------------------------------------------------------
0036 /// \class Recluster
0037 /// Class that helps reclustering a jet with a new jet definition. 
0038 ///
0039 /// **This class is DEPRECATED and you are advised to use the
0040 /// fastjet::Recluster class instead, from "fastjet/tools/Recluster.hh".**
0041 ///
0042 /// The result of the reclustering is returned as a single PseudoJet
0043 /// with a CompositeJet structure. The pieces of that PseudoJet will
0044 /// be the individual subjets
0045 ///
0046 /// When constructed from a JetDefinition, that definition will be
0047 /// used to obtain the subjets.  When constructed from a JetAlgorithm
0048 /// and parameters (0 parameters for e+e-, just R or R and an extra
0049 /// parameter for others) the recombination scheme will be taken as
0050 /// the same one used to initially cluster the original jet.
0051 ///
0052 /// The result of this transformer depends on its usage. There are two
0053 /// typical use-cases: either we recluster one fat jet into subjets,
0054 /// OR, we recluster the jet with a different jet alg. When Recluster
0055 /// is created from a full jet definition. The last parameter of the
0056 /// constructors below dicatate that behaviour: if "single" is true
0057 /// (the default), a single jet, issued from a regular clustering is
0058 /// returned (if there are more than one, the hardest is taken);
0059 /// otherwise (single==false), the result will be a composite jet with
0060 /// each subjet as pieces
0061 /// 
0062 /// Open points for discussion:
0063 ///
0064 ///  - do we add an option to force area support? [could be useful
0065 ///    e.g. for the filter with a subtractor where area support is
0066 ///    mandatory]
0067 ///
0068 class Recluster : public Transformer {
0069 public:
0070   /// define a recluster that decomposes a jet into subjets using a
0071   /// generic JetDefinition
0072   ///
0073   ///  \param subjet_def   the jet definition applied to obtain the subjets
0074   ///  \param single       when true, cluster the jet in a single jet (the
0075   ///                      hardest one) with an associated ClusterSequence, 
0076   ///                      otherwise return a composite jet with subjets
0077   ///                      as pieces.
0078   Recluster(const JetDefinition & subjet_def, bool single=true)
0079     : _subjet_def(subjet_def), _use_full_def(true), _single(single) {}
0080 
0081   /// define a recluster that decomposes a jet into subjets using a
0082   /// JetAlgorithm and its parameters
0083   ///
0084   ///  \param subjet_alg    the jet algorithm applied to obtain the subjets
0085   ///  \param subjet_radius the jet radius if required
0086   ///  \param subjet_extra  optional extra parameters for the jet algorithm (only when needed)
0087   ///  \param single        when true, cluster the jet in a single jet (the
0088   ///                       hardest one) with an associated ClusterSequence, 
0089   ///                       otherwise return a composite jet with subjets
0090   ///                       as pieces.
0091   /// 
0092   /// Typically, for e+e- algoriothm you should use the third version
0093   /// below with no parameters, for "standard" pp algorithms, just the
0094   /// clustering radius has to be specified and for genkt-type of
0095   /// algorithms, both the radius and the extra parameter have to be
0096   /// specified.
0097   Recluster(JetAlgorithm subjet_alg, double subjet_radius, double subjet_extra,
0098             bool single=true)
0099     : _subjet_alg(subjet_alg), _use_full_def(false), 
0100       _subjet_radius(subjet_radius), _has_subjet_radius(true), 
0101       _subjet_extra(subjet_extra), _has_subjet_extra(true), _single(single) {}
0102   Recluster(JetAlgorithm subjet_alg, double subjet_radius, bool single=true)
0103     : _subjet_alg(subjet_alg), _use_full_def(false), 
0104       _subjet_radius(subjet_radius), _has_subjet_radius(true),
0105       _has_subjet_extra(false), _single(single) {}
0106   Recluster(JetAlgorithm subjet_alg, bool single=true)
0107     : _subjet_alg(subjet_alg), _use_full_def(false), 
0108       _has_subjet_radius(false), _has_subjet_extra(false), _single(single) {}
0109 
0110   /// default dtor
0111   virtual ~Recluster(){};
0112 
0113   //----------------------------------------------------------------------
0114   // standard Transformer behaviour inherited from the base class
0115   // (i.e. result(), description() and structural info)
0116 
0117   /// runs the reclustering and sets kept and rejected to be the jets of interest
0118   /// (with non-zero rho, they will have been subtracted).
0119   ///
0120   /// \param jet    the jet that gets reclustered
0121   /// \return the reclustered jet
0122   virtual PseudoJet result(const PseudoJet & jet) const;
0123 
0124   /// class description
0125   virtual std::string description() const;
0126 
0127   // the type of the associated structure
0128   typedef CompositeJetStructure StructureType;
0129 
0130 private:
0131   /// set the reclustered elements in the simple case of C/A+C/A
0132   void _recluster_cafilt(const std::vector<PseudoJet> & all_pieces,
0133                          std::vector<PseudoJet> & subjets,
0134                          double Rfilt) const;
0135 
0136   /// set the reclustered elements in the generic re-clustering case
0137   void _recluster_generic(const PseudoJet & jet, 
0138                           std::vector<PseudoJet> & subjets,
0139                           const JetDefinition & subjet_def,
0140                           bool do_areas) const;
0141   
0142   // a series of checks
0143   //--------------------------------------------------------------------
0144   /// get the pieces down to the fundamental pieces
0145   bool _get_all_pieces(const PseudoJet &jet, std::vector<PseudoJet> &all_pieces) const;
0146 
0147   /// get the common recombiner to all pieces (NULL if none)
0148   const JetDefinition::Recombiner* _get_common_recombiner(const std::vector<PseudoJet> &all_pieces) const;
0149 
0150   /// construct the proper jet definition ensuring that the recombiner
0151   /// is taken from the underlying pieces (an error is thrown if the
0152   /// pieces do no share a common recombiner)
0153   void _build_jet_def_with_recombiner(const std::vector<PseudoJet> &all_pieces, 
0154                                       JetDefinition &subjet_def) const;
0155 
0156   /// check if one can apply the simplified trick for C/A subjets
0157   bool _check_ca(const std::vector<PseudoJet> &all_pieces, 
0158                  const JetDefinition &subjet_def) const;
0159 
0160   /// check if the jet (or all its pieces) have explicit ghosts
0161   /// (assuming the jet has area support
0162   ///
0163   /// Note that if the jet has an associated cluster sequence that is no
0164   /// longer valid, an error will be thrown
0165   bool _check_explicit_ghosts(const std::vector<PseudoJet> &all_pieces) const;
0166 
0167   JetDefinition _subjet_def;   ///< the jet definition to use to extract the subjets
0168   JetAlgorithm  _subjet_alg;   ///< the jet algorithm to be used
0169   bool _use_full_def;          ///< true when the full JetDefinition is supplied to the ctor
0170   double _subjet_radius;       ///< the jet radius (only if needed for the jet alg)
0171   bool _has_subjet_radius;     ///< the subjet radius has been specified
0172   double _subjet_extra;        ///< the jet alg extra param (only if needed)
0173   bool _has_subjet_extra;      ///< the extra param has been specified
0174 
0175   bool _single;                ///< (true) return a single jet with a
0176                                ///< regular clustering or (false) a
0177                                ///< composite jet with subjets as pieces
0178 
0179   static LimitedWarning   _explicit_ghost_warning;
0180 };
0181 
0182 } // namespace contrib
0183 
0184 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
0185 
0186 #endif   // __FASTJET_CONTRIB_TOOLS_RECLUSTER_HH__