Fork me on GitHub

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

ImprovedOutputFile Timing dual_readout llp
Last change on this file since c0f9b5b was 1f1f858, checked in by Michele Selvaggi <michele.selvaggi@…>, 10 years ago

added RecursiveTools package from fastjet contribs

  • Property mode set to 100644
File size: 12.2 KB
Line 
1// $Id: RecursiveSymmetryCutBase.hh 700 2014-07-07 12:50:05Z 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 <fastjet/internal/base.hh>
27#include "fastjet/tools/Transformer.hh"
28#include "fastjet/WrappedStructure.hh"
29
30#include "Recluster.hh"
31
32/** \mainpage RecursiveTools contrib
33
34 The aims RecursiveTools contrib to provide a set of tools for
35 recursive investigation of the substructure of jets.
36
37 Currently it includes:
38 - fastjet::contrib::ModifiedMassDropTagger
39 - fastjet::contrib::SoftDrop
40 - the two above classes derive from fastjet::contrib::RecursiveSymmetryCutBase
41 - fastjet::contrib::Recluster provides a reclustering transformer
42 - example*.cc provides a usage examples
43 */
44
45
46FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
47
48namespace contrib{
49
50//------------------------------------------------------------------------
51/// \class RecursiveSymmetryCutBase
52/// A base class for all the tools that de-cluster a jet until a
53/// sufficiently symmetric configuration if found.
54///
55/// Derived classes (so far, ModifiedMassDropTagger and SoftDrop) have to
56/// implement the symmetry cut and its description
57///
58/// Note that by default, the jet will be reculstered with
59/// Cambridge/Aachen before applying the de-clustering procedure. This
60/// behaviour can be changed using set_clustering (see below).
61///
62/// By default, this class behaves as a tagger, i.e. returns an empty
63/// PseudoJet if no substructure is found. While the derived
64/// ModifiedMassDropTagger is a tagger, the derived SoftDrop is a groomer
65/// (i.e. it returns a non-zero jet even if no substructure is found).
66///
67/// This class provides support for
68/// - an optional mass-drop cut (see ctor)
69/// - options to select which symmetry measure should be used (see ctor)
70/// - options to select how the recursion proceeds (see ctor)
71/// - options for reclustering the jet before running the de-clustering
72/// (see set_reclustering)
73/// - an optional subtractor (see ctor and other methods below)
74class RecursiveSymmetryCutBase : public Transformer {
75public:
76 // ctors and dtors
77 //----------------------------------------------------------------------
78
79 /// an enum of the different (a)symmetry measures that can be used
80 enum SymmetryMeasure{scalar_z, ///< \f$ \min(p_{ti}, p_{tj})/(p_{ti} + p_{tj}) \f$
81 vector_z, ///< \f$ \min(p_{ti}, p_{tj})/p_{t(i+j)} \f$
82 y /// \f$ \min(p_{ti}^2,p_{tj}^2) \Delta R_{ij}^2 / m_{ij}^2 \f$
83
84 };
85
86 /// an enum for the options of how to choose which of two subjets to recurse into
87 enum RecursionChoice{larger_pt, ///< choose the subjet with larger \f$ p_t \f$
88 larger_mt, ///< choose the subjet with larger \f$ m_t \equiv (m^2+p_t^2)^{\frac12}] \f$
89 larger_m /// choose the subjet with larger mass (deprecated)
90 };
91
92 /// Full constructor, which takes the following parameters:
93 ///
94 /// \param symmetry_measure the choice of measure to use to estimate the symmetry
95 /// \param mu_cut the maximal allowed value of mass drop variable mu = m_heavy/m_parent
96 /// \param recursion_choice the strategy used to decide which subjet to recurse into
97 /// \param subtractor an optional pointer to a pileup subtractor (ignored if zero)
98 ///
99 /// If the (optional) pileup subtractor is supplied, then, by
100 /// default, the input jet is assumed unsubtracted and the
101 /// RecursiveSymmetryCutBase returns a subtracted 4-vector. [see
102 /// also the set_input_jet_is_subtracted() member function].
103 ///
104 RecursiveSymmetryCutBase(SymmetryMeasure symmetry_measure = scalar_z,
105 double mu_cut = std::numeric_limits<double>::infinity(),
106 RecursionChoice recursion_choice = larger_pt,
107 const FunctionOfPseudoJet<PseudoJet> * subtractor = 0
108 ) :
109 _symmetry_measure(symmetry_measure),
110 _mu_cut(mu_cut),
111 _recursion_choice(recursion_choice),
112 _subtractor(subtractor), _input_jet_is_subtracted(false),
113 _do_reclustering(true), _recluster(0),
114 _grooming_mode(false),
115 _verbose_structure(false) // by default, don't story verbose information
116 {}
117
118 /// default destructor
119 virtual ~RecursiveSymmetryCutBase(){}
120
121 // internal subtraction configuration
122 //----------------------------------------------------------------------
123
124 /// This tells the tagger whether to assume that the input jet has
125 /// already been subtracted. This is relevant only if a non-null
126 /// subtractor pointer has been supplied, and the default assymption
127 /// is that the input jet is passed unsubtracted.
128 ///
129 /// Note: given that subtractors usually change the momentum of the
130 /// main jet, but not that of the subjets, subjets will continue to
131 /// have subtraction applied to them.
132 void set_input_jet_is_subtracted(bool is_subtracted) {_input_jet_is_subtracted = is_subtracted;}
133
134 /// returns a bool to indicate if the input jet is assumed already subtracted
135 bool input_jet_is_subtracted() const {return _input_jet_is_subtracted;}
136
137 /// an alternative way to set the subtractor
138 ///
139 /// Note that when a subtractor is provided, the result of the
140 /// RecursiveSymmetryCutBase will be a subtracted jet.
141 void set_subtractor(const FunctionOfPseudoJet<PseudoJet> * subtractor_) {_subtractor = subtractor_;}
142
143 /// returns a pointer to the subtractor
144 const FunctionOfPseudoJet<PseudoJet> * subtractor() const {return _subtractor;}
145
146 // reclustering behaviour
147 //----------------------------------------------------------------------
148
149 /// configure the reclustering prior to the SoftDrop de-clustering
150 /// \param do_reclustering recluster the jet or not?
151 /// \param recluster how to recluster the jet
152 /// (only if do_recluster is true;
153 /// Cambridge/Aachen used if NULL)
154 ///
155 /// Note that the ModifiedMassDropTagger and SoftDrop are designed
156 /// to work with a Cambridge/Aachen clustering. Use any other option
157 /// at your own risk!
158 void set_reclustering(bool do_reclustering=true, const Recluster *recluster=0){
159 _do_reclustering = do_reclustering;
160 _recluster = recluster;
161 }
162
163 // what to do when no substructure is found
164 //----------------------------------------------------------------------
165 /// specify the behaviour adopted when no substructure is found
166 /// - in tagging mode, an empty PseudoJet will be returned
167 /// - in grooming mode, a single particle is returned
168 /// for clarity, we provide both function although they are redundant
169 void set_grooming_mode(bool enable=true){ _grooming_mode = enable;}
170 void set_tagging_mode(bool enable=true){ _grooming_mode = !enable;}
171
172
173 /// Allows access to verbose information about recursive declustering,
174 /// in particular values of symmetry, delta_R, and mu of dropped branches
175 void set_verbose_structure(bool enable=true) { _verbose_structure = enable; }
176
177
178 // inherited from the Transformer base
179 //----------------------------------------------------------------------
180
181 /// the function that carries out the tagging; if a subtractor is
182 /// being used, then this function assumes that input jet is
183 /// unsubtracted (unless set_input_jet_is_subtracted(true) has been
184 /// explicitly called before) and the result of the MMDT will be a
185 /// subtracted jet.
186 virtual PseudoJet result(const PseudoJet & j) const;
187
188 /// description of the tool
189 virtual std::string description() const;
190
191 /// the type of the associated structure
192 //typedef RecursiveSymmetryCutBaseStructure StructureType;
193
194 class StructureType;
195
196 /// for testing
197 static bool _verbose;
198
199protected:
200 // the methods below have to be defined by deerived classes
201 //----------------------------------------------------------------------
202 /// the cut on the symmetry measure (typically z) that one need to
203 /// apply for a given pair of subjets p1 and p2
204 virtual double symmetry_cut_fn(const PseudoJet & /* p1 */,
205 const PseudoJet & /* p2 */) const = 0;
206 /// the associated dwescription
207 virtual std::string symmetry_cut_description() const = 0;
208
209private:
210 SymmetryMeasure _symmetry_measure;
211 double _mu_cut;
212 RecursionChoice _recursion_choice;
213 const FunctionOfPseudoJet<PseudoJet> * _subtractor;
214 bool _input_jet_is_subtracted;
215
216 bool _do_reclustering; ///< start with a reclustering
217 const Recluster *_recluster; ///< how to recluster the jet
218
219 bool _grooming_mode; ///< grooming or tagging mode
220
221 static LimitedWarning _negative_mass_warning;
222 static LimitedWarning _mu2_gt1_warning;
223 //static LimitedWarning _nonca_warning;
224 static LimitedWarning _explicit_ghost_warning;
225
226 // additional verbose structure information
227 bool _verbose_structure;
228
229 /// decide what to return when no substructure has been found
230 PseudoJet _result_no_substructure(const PseudoJet &last_parent) const;
231};
232
233
234
235//----------------------------------------------------------------------
236/// class to hold the structure of a jet tagged by RecursiveSymmetryCutBase.
237class RecursiveSymmetryCutBase::StructureType : public WrappedStructure {
238public:
239 StructureType(const PseudoJet & j) :
240 WrappedStructure(j.structure_shared_ptr()),
241 _has_verbose(false) // by default, do not store verbose structure
242 {}
243
244 // information about kept branch
245 double delta_R() const {return _delta_R;};
246 double symmetry() const {return _symmetry;};
247 double mu() const {return _mu;};
248
249 // additional verbose information about dropped branches
250 bool has_verbose() const { return _has_verbose;}
251
252 // number of dropped branches
253 int dropped_count() const {
254 if (!_has_verbose) throw Error("RecursiveSymmetryCutBase::StructureType: Verbose structure must be turned on to get dropped_count() values.");
255 return _dropped_delta_R.size();
256 }
257
258 // delta_R of dropped branches
259 std::vector<double> dropped_delta_R() const {
260 if (!_has_verbose) throw Error("RecursiveSymmetryCutBase::StructureType: Verbose structure must be turned on to get dropped_delta_R() values.");
261 return _dropped_delta_R;
262 }
263
264 // symmetry values of dropped branches
265 std::vector<double> dropped_symmetry() const {
266 if (!_has_verbose) throw Error("RecursiveSymmetryCutBase::StructureType: Verbose structure must be turned on to get dropped_symmetry() values.");
267 return _dropped_symmetry;
268 }
269
270 // mass drop values of dropped branches
271 std::vector<double> dropped_mu() const {
272 if (!_has_verbose) throw Error("RecursiveSymmetryCutBase::StructureType: Verbose structure must be turned on to get dropped_mu() values.");
273 return _dropped_mu;
274 }
275
276 // maximum symmetry value dropped
277 double max_dropped_symmetry() const {
278 if (!_has_verbose) throw Error("RecursiveSymmetryCutBase::StructureType: Verbose structure must be turned on to get max_dropped_symmetry().");
279 if (_dropped_symmetry.size() == 0) return 0.0;
280 return *std::max_element(_dropped_symmetry.begin(),_dropped_symmetry.end());
281 }
282
283private:
284 double _delta_R, _symmetry, _mu;
285 friend class RecursiveSymmetryCutBase;
286
287 // additional verbose information
288 bool _has_verbose;
289 // information about dropped values
290 std::vector<double> _dropped_delta_R;
291 std::vector<double> _dropped_symmetry;
292 std::vector<double> _dropped_mu;
293
294};
295
296} // namespace contrib
297
298FASTJET_END_NAMESPACE
299
300#endif // __FASTJET_CONTRIB_RECURSIVESYMMETRYCUTBASE_HH__
Note: See TracBrowser for help on using the repository browser.