Fork me on GitHub

source: git/external/fastjet/contribs/RecursiveTools/RecursiveSymmetryCutBase.hh@ dd64cff

ImprovedOutputFile Timing llp
Last change on this file since dd64cff was b7b836a, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

update FastJet library to 3.3.1 and FastJet Contrib library to 1.036

  • Property mode set to 100644
File size: 16.2 KB
Line 
1// $Id: RecursiveSymmetryCutBase.hh 1074 2017-09-18 15:15:20Z gsoyez $
2//
3// Copyright (c) 2014-, Gavin P. Salam, Gregory Soyez, Jesse Thaler
4//
5//----------------------------------------------------------------------
6// This file is part of FastJet contrib.
7//
8// It is free software; you can redistribute it and/or modify it under
9// the terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 2 of the License, or (at
11// your option) any later version.
12//
13// It is distributed in the hope that it will be useful, but WITHOUT
14// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16// License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this code. If not, see <http://www.gnu.org/licenses/>.
20//----------------------------------------------------------------------
21
22#ifndef __FASTJET_CONTRIB_RECURSIVESYMMETRYCUTBASE_HH__
23#define __FASTJET_CONTRIB_RECURSIVESYMMETRYCUTBASE_HH__
24
25#include <limits>
26#include <cassert>
27#include <fastjet/internal/base.hh>
28#include "fastjet/tools/Transformer.hh"
29#include "fastjet/WrappedStructure.hh"
30#include "fastjet/CompositeJetStructure.hh"
31
32#include "fastjet/config.h"
33
34// we'll use the native FJ class for reculstering if available
35#if FASTJET_VERSION_NUMBER >= 30100
36#include "fastjet/tools/Recluster.hh"
37#else
38#include "Recluster.hh"
39#endif
40
41/** \mainpage RecursiveTools contrib
42
43 The RecursiveTools contrib provides a set of tools for
44 recursive investigation jet substructure. Currently it includes:
45 - fastjet::contrib::ModifiedMassDropTagger
46 - fastjet::contrib::SoftDrop
47 - fastjet::contrib::RecursiveSymmetryCutBase (from which the above two classes derive)
48 - fastjet::contrib::IteratedSoftDropSymmetryFactors (defines ISD procedure)
49 - fastjet::contrib::IteratedSoftDropMultiplicity (defines a useful observable using ISD)
50 - example*.cc provides usage examples
51 */
52
53
54FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
55
56namespace contrib{
57
58//------------------------------------------------------------------------
59/// \class RecursiveSymmetryCutBase
60/// A base class for all the tools that de-cluster a jet until a
61/// sufficiently symmetric configuration if found.
62///
63/// Derived classes (so far, ModifiedMassDropTagger and SoftDrop) have to
64/// implement the symmetry cut and its description
65///
66/// Note that by default, the jet will be reculstered with
67/// Cambridge/Aachen before applying the de-clustering procedure. This
68/// behaviour can be changed using set_clustering (see below).
69///
70/// By default, this class behaves as a tagger, i.e. returns an empty
71/// PseudoJet if no substructure is found. While the derived
72/// ModifiedMassDropTagger is a tagger, the derived SoftDrop is a groomer
73/// (i.e. it returns a non-zero jet even if no substructure is found).
74///
75/// This class provides support for
76/// - an optional mass-drop cut (see ctor)
77/// - options to select which symmetry measure should be used (see ctor)
78/// - options to select how the recursion proceeds (see ctor)
79/// - options for reclustering the jet before running the de-clustering
80/// (see set_reclustering)
81/// - an optional subtractor (see ctor and other methods below)
82class RecursiveSymmetryCutBase : public Transformer {
83public:
84 // ctors and dtors
85 //----------------------------------------------------------------------
86
87 /// an enum of the different (a)symmetry measures that can be used
88 enum SymmetryMeasure{scalar_z, ///< \f$ \min(p_{ti}, p_{tj})/(p_{ti} + p_{tj}) \f$
89 vector_z, ///< \f$ \min(p_{ti}, p_{tj})/p_{t(i+j)} \f$
90 y, ///< \f$ \min(p_{ti}^2,p_{tj}^2) \Delta R_{ij}^2 / m_{ij}^2 \f$
91 theta_E, ///< \f$ \min(E_i,E_j)/(E_i+E_j) \f$ with 3d angle (ee collisions)
92 cos_theta_E ///< \f$ \min(E_i,E_j)/(E_i+E_j) \f$ with
93 /// \f$ \sqrt{2[1-cos(theta)]}\f$ for angles (ee collisions)
94 };
95
96 /// an enum for the options of how to choose which of two subjets to recurse into
97 enum RecursionChoice{larger_pt, ///< choose the subjet with larger \f$ p_t \f$
98 larger_mt, ///< choose the subjet with larger \f$ m_t \equiv (m^2+p_t^2)^{\frac12}] \f$
99 larger_m, ///< choose the subjet with larger mass (deprecated)
100 larger_E ///< choose the subjet with larger energy (meant for ee collisions)
101 };
102
103 /// Full constructor, which takes the following parameters:
104 ///
105 /// \param symmetry_measure the choice of measure to use to estimate the symmetry
106 /// \param mu_cut the maximal allowed value of mass drop variable mu = m_heavy/m_parent
107 /// \param recursion_choice the strategy used to decide which subjet to recurse into
108 /// \param subtractor an optional pointer to a pileup subtractor (ignored if zero)
109 ///
110 /// If the (optional) pileup subtractor is supplied, then, by
111 /// default, the input jet is assumed unsubtracted and the
112 /// RecursiveSymmetryCutBase returns a subtracted 4-vector. [see
113 /// also the set_input_jet_is_subtracted() member function].
114 ///
115 RecursiveSymmetryCutBase(SymmetryMeasure symmetry_measure = scalar_z,
116 double mu_cut = std::numeric_limits<double>::infinity(),
117 RecursionChoice recursion_choice = larger_pt,
118 const FunctionOfPseudoJet<PseudoJet> * subtractor = 0
119 ) :
120 _symmetry_measure(symmetry_measure),
121 _mu_cut(mu_cut),
122 _recursion_choice(recursion_choice),
123 _subtractor(subtractor), _input_jet_is_subtracted(false),
124 _do_reclustering(true), _recluster(0),
125 _grooming_mode(false),
126 _verbose_structure(false) // by default, don't story verbose information
127 {}
128
129 /// default destructor
130 virtual ~RecursiveSymmetryCutBase(){}
131
132 // access to class info
133 //----------------------------------------------------------------------
134 SymmetryMeasure symmetry_measure() const { return _symmetry_measure; }
135 double mu_cut() const { return _mu_cut; }
136 RecursionChoice recursion_choice() const { return _recursion_choice; }
137
138 // internal subtraction configuration
139 //----------------------------------------------------------------------
140
141 /// This tells the tagger whether to assume that the input jet has
142 /// already been subtracted. This is relevant only if a non-null
143 /// subtractor pointer has been supplied, and the default assymption
144 /// is that the input jet is passed unsubtracted.
145 ///
146 /// Note: given that subtractors usually change the momentum of the
147 /// main jet, but not that of the subjets, subjets will continue to
148 /// have subtraction applied to them.
149 void set_input_jet_is_subtracted(bool is_subtracted) {_input_jet_is_subtracted = is_subtracted;}
150
151 /// returns a bool to indicate if the input jet is assumed already subtracted
152 bool input_jet_is_subtracted() const {return _input_jet_is_subtracted;}
153
154 /// an alternative way to set the subtractor
155 ///
156 /// Note that when a subtractor is provided, the result of the
157 /// RecursiveSymmetryCutBase will be a subtracted jet.
158 void set_subtractor(const FunctionOfPseudoJet<PseudoJet> * subtractor_) {_subtractor = subtractor_;}
159
160 /// returns a pointer to the subtractor
161 const FunctionOfPseudoJet<PseudoJet> * subtractor() const {return _subtractor;}
162
163 // reclustering behaviour
164 //----------------------------------------------------------------------
165
166 /// configure the reclustering prior to the recursive de-clustering
167 /// \param do_reclustering recluster the jet or not?
168 /// \param recluster how to recluster the jet
169 /// (only if do_recluster is true;
170 /// Cambridge/Aachen used if NULL)
171 ///
172 /// Note that the ModifiedMassDropTagger and SoftDrop are designed
173 /// to work with a Cambridge/Aachen clustering. Use any other option
174 /// at your own risk!
175 void set_reclustering(bool do_reclustering=true, const Recluster *recluster=0){
176 _do_reclustering = do_reclustering;
177 _recluster = recluster;
178 }
179
180 // what to do when no substructure is found
181 //----------------------------------------------------------------------
182 /// specify the behaviour adopted when no substructure is found
183 /// - in tagging mode, an empty PseudoJet will be returned
184 /// - in grooming mode, a single particle is returned
185 /// for clarity, we provide both function although they are redundant
186 void set_grooming_mode(bool enable=true){ _grooming_mode = enable;}
187 void set_tagging_mode(bool enable=true){ _grooming_mode = !enable;}
188
189
190 /// Allows access to verbose information about recursive declustering,
191 /// in particular values of symmetry, delta_R, and mu of dropped branches
192 void set_verbose_structure(bool enable=true) { _verbose_structure = enable; }
193 bool has_verbose_structure() const { return _verbose_structure; }
194
195
196 // inherited from the Transformer base
197 //----------------------------------------------------------------------
198
199 /// the function that carries out the tagging; if a subtractor is
200 /// being used, then this function assumes that input jet is
201 /// unsubtracted (unless set_input_jet_is_subtracted(true) has been
202 /// explicitly called before) and the result of the MMDT will be a
203 /// subtracted jet.
204 virtual PseudoJet result(const PseudoJet & j) const;
205
206 /// description of the tool
207 virtual std::string description() const;
208
209 /// returns the gepometrical distance between the two particles
210 /// depending on the symmetry measure used
211 double squared_geometric_distance(const PseudoJet &j1,
212 const PseudoJet &j2) const;
213
214
215 class StructureType;
216
217 /// for testing
218 static bool _verbose;
219
220protected:
221 // the methods below have to be defined by deerived classes
222 //----------------------------------------------------------------------
223 /// the cut on the symmetry measure (typically z) that one need to
224 /// apply for a given pair of subjets p1 and p2
225 virtual double symmetry_cut_fn(const PseudoJet & /* p1 */,
226 const PseudoJet & /* p2 */,
227 void *extra_parameters = 0) const = 0;
228 /// the associated dwescription
229 virtual std::string symmetry_cut_description() const = 0;
230
231 //----------------------------------------------------------------------
232 /// this defines status codes when checking for substructure
233 enum RecursionStatus{
234 recursion_success=0, //< found some substructure
235 recursion_dropped, //< dropped softest prong; recursion continues
236 recursion_no_parents, //< down to constituents; bottom of recursion
237 recursion_issue //< something went wrong; recursion stops
238 };
239
240 //----------------------------------------------------------------------
241 /// the method below is the one actually performing one step of the
242 /// recursion.
243 ///
244 /// It returns a status code (defined above)
245 ///
246 /// In case of success, all the information is filled
247 /// In case of "no parents", piee1 is the same subjet
248 /// In case of trouble, piece2 will be a 0 PJ and piece1 is the PJ we
249 /// should return (either 0 itself if the issue was critical, or
250 /// non-wero in case of a minor issue just causing the recursion to
251 /// stop)
252 ///
253 /// The extra_parameter argument allows one to pass extra agruments
254 /// to the symmetry condition
255 RecursionStatus recurse_one_step(const PseudoJet & subjet,
256 PseudoJet &piece1, PseudoJet &piece2,
257 double &sym, double &mu2,
258 void *extra_parameters = 0) const;
259
260 //----------------------------------------------------------------------
261 /// helper for handling the reclustering
262 PseudoJet _recluster_if_needed(const PseudoJet &jet) const;
263
264 //----------------------------------------------------------------------
265 // helpers for selecting between ee and pp cases
266 bool is_ee() const{
267 return ((_symmetry_measure==theta_E) || (_symmetry_measure==cos_theta_E));
268 }
269
270private:
271 SymmetryMeasure _symmetry_measure;
272 double _mu_cut;
273 RecursionChoice _recursion_choice;
274 const FunctionOfPseudoJet<PseudoJet> * _subtractor;
275 bool _input_jet_is_subtracted;
276
277 bool _do_reclustering; ///< start with a reclustering
278 const Recluster *_recluster; ///< how to recluster the jet
279
280 bool _grooming_mode; ///< grooming or tagging mode
281
282 static LimitedWarning _negative_mass_warning;
283 static LimitedWarning _mu2_gt1_warning;
284 //static LimitedWarning _nonca_warning;
285 static LimitedWarning _explicit_ghost_warning;
286
287 // additional verbose structure information
288 bool _verbose_structure;
289
290 /// decide what to return when no substructure has been found
291 PseudoJet _result_no_substructure(const PseudoJet &last_parent) const;
292};
293
294
295
296//----------------------------------------------------------------------
297/// class to hold the structure of a jet tagged by RecursiveSymmetryCutBase.
298class RecursiveSymmetryCutBase::StructureType : public WrappedStructure {
299public:
300 StructureType(const PseudoJet & j) :
301 WrappedStructure(j.structure_shared_ptr()), _delta_R(-1.0), _symmetry(-1.0), _mu(-1.0),
302 _is_composite(false), _has_verbose(false) // by default, do not store verbose structure
303 {}
304
305 /// construct a structure with
306 /// - basic info inherited from the reference jet "j"
307 /// - a given deltaR for substructure
308 /// - a given symmetry for substructure
309 /// - a given mu parameter for substructure
310 /// If j is a "copmposite jet", it means that it has further
311 /// substructure to potentially recurse into
312 StructureType(const PseudoJet & j, double delta_R_in, double symmetry_in, double mu_in=-1.0) :
313 WrappedStructure(j.structure_shared_ptr()), _delta_R(delta_R_in), _symmetry(symmetry_in), _mu(mu_in),
314 _is_composite(dynamic_cast<const CompositeJetStructure*>(j.structure_ptr()) != NULL),
315 _has_verbose(false) // by default, do not store verbose structure
316 {}
317
318 // information about kept branch
319 double delta_R() const {return _delta_R;}
320 double thetag() const {return _delta_R;} // alternative name
321 double symmetry() const {return _symmetry;}
322 double zg() const {return _symmetry;} // alternative name
323 double mu() const {return _mu;}
324
325 // additional verbose information about dropped branches
326 bool has_verbose() const { return _has_verbose;}
327 void set_verbose(bool value) { _has_verbose = value;}
328
329 /// returns true if the current jet has some substructure (i.e. has
330 /// been tagged by the resursion) or not
331 ///
332 /// Note that this should include deltaR==0 (e.g. a perfectly
333 /// collinear branching with SoftDrop)
334 bool has_substructure() const { return _delta_R>=0; }
335
336 /// number of dropped branches
337 int dropped_count(bool global=true) const;
338
339 /// delta_R of dropped branches
340 /// when "global" is set, recurse into possile further substructure
341 std::vector<double> dropped_delta_R(bool global=true) const;
342 void set_dropped_delta_R(const std::vector<double> &v) { _dropped_delta_R = v; }
343
344 /// symmetry values of dropped branches
345 std::vector<double> dropped_symmetry(bool global=true) const;
346 void set_dropped_symmetry(const std::vector<double> &v) { _dropped_symmetry = v; }
347
348 /// mass drop values of dropped branches
349 std::vector<double> dropped_mu(bool global=true) const;
350 void set_dropped_mu(const std::vector<double> &v) { _dropped_mu = v; }
351
352 /// maximum symmetry value dropped
353 double max_dropped_symmetry(bool global=true) const;
354
355 /// (global) list of groomed away elements as zg and thetag
356 /// sorted from largest to smallest anlge
357 std::vector<std::pair<double,double> > sorted_zg_and_thetag() const;
358
359private:
360 double _delta_R, _symmetry, _mu;
361 friend class RecursiveSymmetryCutBase;
362
363 bool _is_composite;
364
365 // additional verbose information
366 bool _has_verbose;
367 // information about dropped values
368 std::vector<double> _dropped_delta_R;
369 std::vector<double> _dropped_symmetry;
370 std::vector<double> _dropped_mu;
371
372 bool check_verbose(const std::string &what) const{
373 if (!_has_verbose){
374 throw Error("RecursiveSymmetryCutBase::StructureType: Verbose structure must be turned on to get "+what+".");
375 return false;
376 }
377 return true;
378 }
379
380
381};
382
383} // namespace contrib
384
385FASTJET_END_NAMESPACE
386
387#endif // __FASTJET_CONTRIB_RECURSIVESYMMETRYCUTBASE_HH__
Note: See TracBrowser for help on using the repository browser.