Fork me on GitHub

source: git/external/fastjet/contribs/RecursiveTools/BottomUpSoftDrop.hh@ 5eb063e

Last change on this file since 5eb063e was b7b836a, checked in by Pavel Demin <pavel-demin@…>, 7 years ago

update FastJet library to 3.3.1 and FastJet Contrib library to 1.036

  • Property mode set to 100644
File size: 11.3 KB
Line 
1// $Id: BottomUpSoftDrop.hh 1085 2017-10-11 02:16:59Z jthaler $
2//
3// Copyright (c) 2017-, Gavin P. Salam, Gregory Soyez, Jesse Thaler,
4// Kevin Zhou, Frederic Dreyer
5//
6//----------------------------------------------------------------------
7// This file is part of FastJet contrib.
8//
9// It is free software; you can redistribute it and/or modify it under
10// the terms of the GNU General Public License as published by the
11// Free Software Foundation; either version 2 of the License, or (at
12// your option) any later version.
13//
14// It is distributed in the hope that it will be useful, but WITHOUT
15// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17// License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this code. If not, see <http://www.gnu.org/licenses/>.
21//----------------------------------------------------------------------
22
23#ifndef __BOTTOMUPSOFTDROP_HH__
24#define __BOTTOMUPSOFTDROP_HH__
25
26#include "fastjet/ClusterSequence.hh"
27#include "fastjet/WrappedStructure.hh"
28#include "fastjet/tools/Transformer.hh"
29
30#include <iostream>
31#include <string>
32
33// TODO
34//
35// - missing class description
36//
37// - check what to do when pta=ptb=0
38// for the moment, we recombine both for multiple reasons
39// . this avois breakingteh symemtry between pa and pb
40// . it would be groomed in later steps anyway
41// Note that this is slightly inconsistent with our use of
42// > (instead of >=) in the cdt
43
44FASTJET_BEGIN_NAMESPACE
45
46namespace contrib{
47
48// fwd declarations
49class BottomUpSoftDrop;
50class BottomUpSoftDropStructure;
51class BottomUpSoftDropRecombiner;
52class BottomUpSoftDropPlugin;
53
54//----------------------------------------------------------------------
55/// \class BottomUpSoftDrop
56/// Implementation of the BottomUpSoftDrop transformer
57///
58/// Bottom-Up Soft drop grooms a jet by applying a modified
59/// recombination scheme, where particles are recombined only if they
60/// pass the Soft Drop condition
61///
62/// \f[
63/// z < z_{\rm cut} (\theta/R0)^\beta
64/// \f]
65///
66/// the groomed jet contains the particles remaining after this
67/// pair-wise recombination
68///
69/// Note:
70/// - one can use BottomUpSoftDrop on a full event with the
71/// global_grooming(event) method.
72/// - if two recombined particles a and b have momentum pta=ptb=0,
73/// we recombine both.
74///
75
76
77class BottomUpSoftDrop : public Transformer {
78public:
79 /// minimal constructor, which the jet algorithm to CA, sets the radius
80 /// to JetDefinition::max_allowable_R (practically equivalent to
81 /// infinity) and also tries to use a recombiner based on the one in
82 /// the jet definition of the particular jet being Soft Dropped.
83 ///
84 /// \param beta the value for beta
85 /// \param symmetry_cut the value for symmetry_cut
86 /// \param R0 the value for R0
87 BottomUpSoftDrop(double beta, double symmetry_cut, double R0 = 1.0)
88 : _jet_def(cambridge_algorithm, JetDefinition::max_allowable_R),
89 _beta(beta),_symmetry_cut(symmetry_cut), _R0(R0),
90 _get_recombiner_from_jet(true) {}
91
92 /// alternative constructor which takes a specified jet algorithm
93 ///
94 /// \param jet_alg the jet algorithm for the internal clustering (uses R=infty)
95 /// \param symmetry_cut the value of symmetry_cut
96 /// \param beta the value for beta
97 /// \param R0 the value for R0
98 BottomUpSoftDrop(const JetAlgorithm jet_alg, double beta, double symmetry_cut,
99 double R0 = 1.0)
100 : _jet_def(jet_alg, JetDefinition::max_allowable_R),
101 _beta(beta), _symmetry_cut(symmetry_cut), _R0(R0),
102 _get_recombiner_from_jet(true) {}
103
104
105 /// alternative ctor in which the full reclustering jet definition can
106 /// be specified.
107 ///
108 /// \param jet_def the jet definition for the internal clustering
109 /// \param symmetry_cut the value of symmetry_cut
110 /// \param beta the value for beta
111 /// \param R0 the value for R0
112 BottomUpSoftDrop(const JetDefinition &jet_def, double beta, double symmetry_cut,
113 double R0 = 1.0)
114 : _jet_def(jet_def), _beta(beta), _symmetry_cut(symmetry_cut), _R0(R0),
115 _get_recombiner_from_jet(false) {}
116
117 /// action on a single jet
118 virtual PseudoJet result(const PseudoJet &jet) const;
119
120 /// global grooming on a full event
121 /// note: does not support jet areas
122 virtual std::vector<PseudoJet> global_grooming(const std::vector<PseudoJet> & event) const;
123
124 /// description
125 virtual std::string description() const;
126
127 // the type of the associated structure
128 typedef BottomUpSoftDropStructure StructureType;
129
130private:
131 /// check if the jet has explicit_ghosts (knowing that there is an
132 /// area support)
133 bool _check_explicit_ghosts(const PseudoJet &jet) const;
134
135 /// see if there is a common recombiner among the pieces; if there
136 /// is return true and set jet_def_for_recombiner so that the
137 /// recombiner can be taken from that JetDefinition. Otherwise,
138 /// return false. 'assigned' is initially false; when true, each
139 /// time we meet a new jet definition, we'll check it shares the
140 /// same recombiner as jet_def_for_recombiner.
141 bool _check_common_recombiner(const PseudoJet &jet,
142 JetDefinition &jet_def_for_recombiner,
143 bool assigned=false) const;
144
145
146 JetDefinition _jet_def; ///< the internal jet definition
147 double _beta; ///< the value of beta
148 double _symmetry_cut; ///< the value of symmetry_cut
149 double _R0; ///< the value of R0
150 bool _get_recombiner_from_jet; ///< true for minimal constructor,
151 ///< causes recombiner to be set equal
152 ///< to that already used in the jet
153 ///< (if it can be deduced)
154};
155
156//----------------------------------------------------------------------
157/// The structure associated with a PseudoJet thas has gone through a
158/// bottom/up SoftDrop transformer
159class BottomUpSoftDropStructure : public WrappedStructure{
160public:
161 /// default ctor
162 /// \param result_jet the jet for which we have to keep the structure
163 BottomUpSoftDropStructure(const PseudoJet & result_jet)
164 : WrappedStructure(result_jet.structure_shared_ptr()){}
165
166 /// description
167 virtual std::string description() const{
168 return "Bottom/Up Soft Dropped PseudoJet";
169 }
170
171 /// return the constituents that have been rejected
172 std::vector<PseudoJet> rejected() const{
173 return validated_cs()->childless_pseudojets();
174 }
175
176 /// return the other jets that may have been found along with the
177 /// result of the bottom/up Soft Drop
178 /// The resulting vector is sorted in pt
179 std::vector<PseudoJet> extra_jets() const {
180 return sorted_by_pt((!SelectorNHardest(1))(validated_cs()->inclusive_jets()));
181 }
182
183 /// return the value of beta that was used for this specific Soft Drop.
184 double beta() const {return _beta;}
185
186 /// return the value of symmetry_cut that was used for this specific Soft Drop.
187 double symmetry_cut() const {return _symmetry_cut;}
188
189 /// return the value of R0 that was used for this specific Soft Drop.
190 double R0() const {return _R0;}
191
192protected:
193 friend class BottomUpSoftDrop; ///< to allow setting the internal information
194
195private:
196 double _beta, _symmetry_cut, _R0;
197};
198
199//----------------------------------------------------------------------
200/// Class for Soft Drop recombination
201/// recombines the objects that are not vetoed by Bottom-Up SoftDrop
202///
203/// This recombiner only recombines, using the provided 'recombiner',
204/// objects (i and j) that pass the following SoftDrop criterion:
205///
206/// min(pti, ptj) > zcut (pti+ptj) (theta_ij/R0)^beta
207///
208/// If the criterion fail, the hardest of i and j is kept and the
209/// softest is rejected.
210///
211/// Note that this in not meant for standalone use [in particular
212/// because it could lead to memory issues due to the rejected indices
213/// stored internally].
214///
215/// This class is a direct adaptation of PruningRecombiner in Fastjet tools
216class BottomUpSoftDropRecombiner : public JetDefinition::Recombiner {
217public:
218 /// ctor
219 /// \param symmetry_cut value of cut on symmetry measure
220 /// \param beta avalue of beta parameter
221 /// \param recomb pointer to a recombiner to use to cluster pairs
222 BottomUpSoftDropRecombiner(double beta, double symmetry_cut, double R0,
223 const JetDefinition::Recombiner *recombiner)
224 : _beta(beta), _symmetry_cut(symmetry_cut), _R0sqr(R0*R0),
225 _recombiner(recombiner) {}
226
227 /// perform a recombination taking into account the Soft Drop
228 /// conditions
229 virtual void recombine(const PseudoJet &pa,
230 const PseudoJet &pb,
231 PseudoJet &pab) const;
232
233 /// returns the description of the recombiner
234 virtual std::string description() const {
235 std::ostringstream oss;
236 oss << "SoftDrop recombiner with symmetry_cut = " << _symmetry_cut
237 << ", beta = " << _beta
238 << ", and underlying recombiner = " << _recombiner->description();
239 return oss.str();
240 }
241
242 /// return the history indices that have been soft dropped away
243 const std::vector<unsigned int> & rejected() const{ return _rejected;}
244
245 /// clears the list of rejected indices
246 ///
247 /// If one decides to use this recombiner standalone, one has to
248 /// call this after each clustering in order for the rejected() vector
249 /// to remain sensible and not grow to infinite size.
250 void clear_rejected(){ _rejected.clear();}
251
252private:
253 double _beta; ///< beta parameter
254 double _symmetry_cut; ///< value of symmetry_cut
255 double _R0sqr; ///< normalisation of the angular distance
256 const JetDefinition::Recombiner *_recombiner; ///< the underlying recombiner to use
257 mutable std::vector<unsigned int> _rejected; ///< list of rejected history indices
258};
259
260//----------------------------------------------------------------------
261/// \class BottomUpSoftDropPlugin
262/// Class for a bottom/up Soft Drop algorithm, based on the Pruner plugin
263///
264/// This is an internal plugin that clusters the particles using the
265/// BottomUpRecombiner.
266///
267/// See BottomUpRecombiner for a description of what bottom-up
268/// SoftDrop does.
269///
270/// Note that this is an internal class used by the BottomUpSoftDrop
271/// transformer and it is not meant to be used as a standalone
272/// clustering tool.
273class BottomUpSoftDropPlugin : public JetDefinition::Plugin {
274public:
275 /// ctor
276 /// \param jet_def the jet definition to be used for the
277 /// internal clustering
278 /// \param symmetry_cut value of cut on symmetry measure
279 /// \param beta value of beta parameter
280 BottomUpSoftDropPlugin(const JetDefinition &jet_def, double beta, double symmetry_cut,
281 double R0 = 1.0)
282 : _jet_def(jet_def), _beta(beta), _symmetry_cut(symmetry_cut), _R0(R0) {}
283
284 /// the actual clustering work for the plugin
285 virtual void run_clustering(ClusterSequence &input_cs) const;
286
287 /// description of the plugin
288 virtual std::string description() const;
289
290 /// returns the radius
291 virtual double R() const {return _jet_def.R();}
292
293private:
294 JetDefinition _jet_def; ///< the internal jet definition
295 double _beta; ///< beta parameter
296 double _symmetry_cut; ///< value of symmetry_cut
297 double _R0; ///< normalisation of the angular distance
298};
299
300}
301
302FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
303#endif // __BOTTOMUPSOFTDROP_HH__
Note: See TracBrowser for help on using the repository browser.