Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef __FASTJET_CONTRIB_TOOLS_RECLUSTER_HH__
0002 #define __FASTJET_CONTRIB_TOOLS_RECLUSTER_HH__
0003 
0004 // $Id: Recluster.hh 723 2014-07-30 09:11:01Z gsoyez $
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 /// The result of the reclustering is returned as a single PseudoJet
0040 /// with a CompositeJet structure. The pieces of that PseudoJet will
0041 /// be the individual subjets
0042 ///
0043 /// When constructed from a JetDefinition, that definition will be
0044 /// used to obtain the subjets.  When constructed from a JetAlgorithm
0045 /// and parameters (0 parameters for e+e-, just R or R and an extra
0046 /// parameter for others) the recombination scheme will be taken as
0047 /// the same one used to initially cluster the original jet.
0048 ///
0049 /// The result of this transformer depends on its usage. There are two
0050 /// typical use-cases: either we recluster one fat jet into subjets,
0051 /// OR, we recluster the jet with a different jet alg. When Recluster
0052 /// is created from a full jet definition. The last parameter of the
0053 /// constructors below dicatate that behaviour: if "single" is true
0054 /// (the default), a single jet, issued from a regular clustering is
0055 /// returned (if there are more than one, the hardest is taken);
0056 /// otherwise (single==false), the result will be a composite jet with
0057 /// each subjet as pieces
0058 /// 
0059 /// Open points for discussion:
0060 ///
0061 ///  - do we add an option to force area support? [could be useful
0062 ///    e.g. for the filter with a subtractor where area support is
0063 ///    mandatory]
0064 ///
0065 class Recluster : public Transformer {
0066 public:
0067   /// define a recluster that decomposes a jet into subjets using a
0068   /// generic JetDefinition
0069   ///
0070   ///  \param subjet_def   the jet definition applied to obtain the subjets
0071   ///  \param single       when true, cluster the jet in a single jet (the
0072   ///                      hardest one) with an associated ClusterSequence, 
0073   ///                      otherwise return a composite jet with subjets
0074   ///                      as pieces.
0075   Recluster(const JetDefinition & subjet_def, bool single=true)
0076     : _subjet_def(subjet_def), _use_full_def(true), _single(single) {}
0077 
0078   /// define a recluster that decomposes a jet into subjets using a
0079   /// JetAlgorithm and its parameters
0080   ///
0081   ///  \param subjet_alg    the jet algorithm applied to obtain the subjets
0082   ///  \param subjet_radius the jet radius if required
0083   ///  \param subjet_extra  optional extra parameters for the jet algorithm (only when needed)
0084   ///  \param single        when true, cluster the jet in a single jet (the
0085   ///                       hardest one) with an associated ClusterSequence, 
0086   ///                       otherwise return a composite jet with subjets
0087   ///                       as pieces.
0088   /// 
0089   /// Typically, for e+e- algoriothm you should use the third version
0090   /// below with no parameters, for "standard" pp algorithms, just the
0091   /// clustering radius has to be specified and for genkt-type of
0092   /// algorithms, both the radius and the extra parameter have to be
0093   /// specified.
0094   Recluster(JetAlgorithm subjet_alg, double subjet_radius, double subjet_extra,
0095             bool single=true)
0096     : _subjet_alg(subjet_alg), _use_full_def(false), 
0097       _subjet_radius(subjet_radius), _has_subjet_radius(true), 
0098       _subjet_extra(subjet_extra), _has_subjet_extra(true), _single(single) {}
0099   Recluster(JetAlgorithm subjet_alg, double subjet_radius, bool single=true)
0100     : _subjet_alg(subjet_alg), _use_full_def(false), 
0101       _subjet_radius(subjet_radius), _has_subjet_radius(true),
0102       _has_subjet_extra(false), _single(single) {}
0103   Recluster(JetAlgorithm subjet_alg, bool single=true)
0104     : _subjet_alg(subjet_alg), _use_full_def(false), 
0105       _has_subjet_radius(false), _has_subjet_extra(false), _single(single) {}
0106 
0107   /// default dtor
0108   virtual ~Recluster(){};
0109 
0110   //----------------------------------------------------------------------
0111   // standard Transformer behaviour inherited from the base class
0112   // (i.e. result(), description() and structural info)
0113 
0114   /// runs the reclustering and sets kept and rejected to be the jets of interest
0115   /// (with non-zero rho, they will have been subtracted).
0116   ///
0117   /// \param jet    the jet that gets reclustered
0118   /// \return the reclustered jet
0119   virtual PseudoJet result(const PseudoJet & jet) const;
0120 
0121   /// class description
0122   virtual std::string description() const;
0123 
0124   // the type of the associated structure
0125   typedef CompositeJetStructure StructureType;
0126 
0127 private:
0128   /// set the reclustered elements in the simple case of C/A+C/A
0129   void _recluster_cafilt(const std::vector<PseudoJet> & all_pieces,
0130                          std::vector<PseudoJet> & subjets,
0131                          double Rfilt) const;
0132 
0133   /// set the reclustered elements in the generic re-clustering case
0134   void _recluster_generic(const PseudoJet & jet, 
0135                           std::vector<PseudoJet> & subjets,
0136                           const JetDefinition & subjet_def,
0137                           bool do_areas) const;
0138   
0139   // a series of checks
0140   //--------------------------------------------------------------------
0141   /// get the pieces down to the fundamental pieces
0142   bool _get_all_pieces(const PseudoJet &jet, std::vector<PseudoJet> &all_pieces) const;
0143 
0144   /// get the common recombiner to all pieces (NULL if none)
0145   const JetDefinition::Recombiner* _get_common_recombiner(const std::vector<PseudoJet> &all_pieces) const;
0146 
0147   /// construct the proper jet definition ensuring that the recombiner
0148   /// is taken from the underlying pieces (an error is thrown if the
0149   /// pieces do no share a common recombiner)
0150   void _build_jet_def_with_recombiner(const std::vector<PseudoJet> &all_pieces, 
0151                                       JetDefinition &subjet_def) const;
0152 
0153   /// check if one can apply the simplified trick for C/A subjets
0154   bool _check_ca(const std::vector<PseudoJet> &all_pieces, 
0155                  const JetDefinition &subjet_def) const;
0156 
0157   /// check if the jet (or all its pieces) have explicit ghosts
0158   /// (assuming the jet has area support
0159   ///
0160   /// Note that if the jet has an associated cluster sequence that is no
0161   /// longer valid, an error will be thrown
0162   bool _check_explicit_ghosts(const std::vector<PseudoJet> &all_pieces) const;
0163 
0164   JetDefinition _subjet_def;   ///< the jet definition to use to extract the subjets
0165   JetAlgorithm  _subjet_alg;   ///< the jet algorithm to be used
0166   bool _use_full_def;          ///< true when the full JetDefinition is supplied to the ctor
0167   double _subjet_radius;       ///< the jet radius (only if needed for the jet alg)
0168   bool _has_subjet_radius;     ///< the subjet radius has been specified
0169   double _subjet_extra;        ///< the jet alg extra param (only if needed)
0170   bool _has_subjet_extra;      ///< the extra param has been specified
0171 
0172   bool _single;                ///< (true) return a single jet with a
0173                                ///< regular clustering or (false) a
0174                                ///< composite jet with subjets as pieces
0175 
0176   static LimitedWarning   _explicit_ghost_warning;
0177 };
0178 
0179 } // namespace contrib
0180 
0181 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
0182 
0183 #endif   // __FASTJET_CONTRIB_TOOLS_RECLUSTER_HH__