Fork me on GitHub

source: git/external/fastjet/tools/Recluster.hh@ 35cdc46

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 35cdc46 was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

  • Property mode set to 100644
File size: 11.5 KB
Line 
1#ifndef __FASTJET_TOOLS_RECLUSTER_HH__
2#define __FASTJET_TOOLS_RECLUSTER_HH__
3
4// $Id: Recluster.hh 3632 2014-08-15 10:42:53Z salam $
5//
6// Copyright (c) 2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
7//
8//----------------------------------------------------------------------
9// This file is part of FastJet
10//
11// It is free software; you can redistribute it and/or modify it under
12// the terms of the GNU General Public License as published by the
13// Free Software Foundation; either version 2 of the License, or (at
14// your option) any later version.
15//
16// It is distributed in the hope that it will be useful, but WITHOUT
17// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19// License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this code. If not, see <http://www.gnu.org/licenses/>.
23//----------------------------------------------------------------------
24
25#include <fastjet/JetDefinition.hh>
26#include <fastjet/FunctionOfPseudoJet.hh> // to derive Recluster from FOfPJ<PJ>
27#include <iostream>
28#include <string>
29
30// TODO:
31//
32// - maintain Voronoi areas? Requires CSAB:has_voronoi_area() {->UNASSIGNED}
33// - make sure the description of the class is OK
34
35
36
37FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
38
39//----------------------------------------------------------------------
40/// \class Recluster
41/// Recluster a jet's constituents with a new jet definition.
42///
43/// When Recluster is constructed from a JetDefinition, it is that
44/// definition that will be used to obtain the new jets. The user may
45/// then decide if the recombiner should be the one from that jet
46/// definition or if it should be acquired from the jet being
47/// processed (the default).
48///
49/// Alternatively, Recluster can be constructed from a jet algorithm
50/// and an optional radius. In that case the recombiner is
51/// systematically obtained fromn the jet being processed (unless you
52/// call set_acquire_recombiner(false)). If only the jet algorithm is
53/// specified, a default radius of max_allowable_R will be assumed if
54/// needed.
55///
56/// Recluster has two possible behaviours:
57///
58/// - if it is constructed with keep=keep_only_hardest the hardest
59/// inclusive jet is returned as a "standard" jet with an
60/// associated cluster sequence (unless there were no inclusive
61/// jets, in which case a zero jet is returned, with no associated
62/// cluster sequence)
63///
64/// - if it is constructed with keep=keep_all
65/// all the inclusive jets are joined into a composite jet
66///
67/// [Note that since the structure of the resulting PseudoJet depends
68/// on its usage, this class inherits from
69/// FunctionOfPseudoJet<PseudoJet> (including a description) rather
70/// than being a full-fledged Transformer]
71///
72class Recluster : public FunctionOfPseudoJet<PseudoJet> {
73public:
74 /// the various options for the output of Recluster
75 enum Keep{
76 /// keep only the hardest inclusive jet and return a "standard" jet with
77 /// an associated ClusterSequence [this will be the default]
78 keep_only_hardest,
79 /// keep all the inclusive jets. result() will join them into a composite
80 /// jet
81 keep_all
82 };
83
84 /// default constructor (uses an undefined JetDefinition, and so cannot
85 /// be used directly).
86 Recluster() : _new_jet_def(), _acquire_recombiner(true),
87 _keep(keep_only_hardest), _cambridge_optimisation_enabled(true){}
88
89 /// Constructs a Recluster object that reclusters a jet into a new jet
90 /// using a generic JetDefinition
91 ///
92 /// \param new_jet_def the jet definition applied to do the reclustering
93 /// \param acquire_recombiner
94 /// when true, the reclustering will guess the
95 /// recombiner from the input jet instead of
96 /// the one in new_jet_def. An error is then
97 /// thrown if no consistent recombiner is found
98 /// \param keep_in Recluster::keep_only_hardest: the result is
99 /// the hardest inclusive jet after reclustering,
100 /// returned as a "standard" jet.
101 /// Recluster::keep_all: the result is a
102 /// composite jet with the inclusive jets as pieces.
103 Recluster(const JetDefinition & new_jet_def,
104 bool acquire_recombiner_in = false,
105 Keep keep_in = keep_only_hardest)
106 : _new_jet_def(new_jet_def), _acquire_recombiner(acquire_recombiner_in),
107 _keep(keep_in), _cambridge_optimisation_enabled(true) {}
108
109 /// Constructs a Recluster object that reclusters a jet into a new jet
110 /// using a JetAlgorithm and its parameters
111 ///
112 /// \param new_jet_alg the jet algorithm applied to obtain the new clustering
113 /// \param new_jet_radius the jet radius
114 /// \param keep_in Recluster::keep_only_hardest: the result is
115 /// the hardest inclusive jet after reclustering,
116 /// returned as a "standard" jet.
117 /// Recluster::keep_all: the result is a
118 /// composite jet with the inclusive jets as pieces.
119 ///
120 /// This ctor will always acquire the recombiner from the jet being
121 /// reclustered (it will throw if none can be found). If you wish
122 /// to use Recluster with an algorithm that requires an extra
123 /// parameter (like the genkt algorithm), please specify the jet
124 /// definition fully using the constructor above.
125 Recluster(JetAlgorithm snew_jet_alg, double new_jet_radius, Keep keep_in = keep_only_hardest);
126
127 /// constructor with just a jet algorithm, but no jet radius. If the
128 /// algorithm requires a jet radius, JetDefinition::max_allowable_R will be used.
129 ///
130 Recluster(JetAlgorithm new_jet_alg, Keep keep_in = keep_only_hardest);
131
132 /// default dtor
133 virtual ~Recluster(){}
134
135 //----------------------------------------------------------------------
136 // tweaking the behaviour and corresponding enquiry functions
137
138 /// set whether the reclustering should attempt to acquire a
139 /// recombiner from the input jet
140 void set_acquire_recombiner(bool acquire) {_acquire_recombiner = acquire;}
141
142 /// returns true if this reclusterer is set to acquire the
143 /// recombiner from the input jet
144 bool acquire_recombiner() const{ return _acquire_recombiner;}
145
146
147 /// sets whether to try to optimise reclustering with
148 /// Cambridge/Aachen algorithms (by not reclustering if the
149 /// requested C/A reclustering can be obtained by using subjets of
150 /// an input C/A jet or one composed of multiple C/A pieces from the
151 /// same clustering sequence). By default this is enabled, and
152 /// _should_ always be correct; disable it to test this statement!
153 void set_cambridge_optimisation(bool enabled){ _cambridge_optimisation_enabled = enabled;}
154 /// sets whether to try to optimise reclustering with Cambridge/Aachen algorithms (US spelling!)
155 void set_cambridge_optimization(bool enabled){ _cambridge_optimisation_enabled = enabled;}
156
157 /// returns true if the reclusterer tries to optimise reclustering
158 /// with Cambridge/Aachen algorithms
159 bool cambridge_optimization(){return _cambridge_optimisation_enabled;}
160 bool cambridge_optimisation(){return _cambridge_optimisation_enabled;}
161
162 /// set the behaviour with regards to keeping all resulting jets or
163 /// just the hardest.
164 void set_keep(Keep keep_in) {_keep = keep_in;}
165
166 /// returns the current "keep" mode i.e. whether only the hardest
167 /// inclusive jet is returned or all of them (see the Keep enum above)
168 Keep keep() const{ return _keep;}
169
170
171 //----------------------------------------------------------------------
172 // retrieving info about the behaviour
173
174 /// class description
175 virtual std::string description() const;
176
177
178 //----------------------------------------------------------------------
179 // core action of ths class
180
181 /// runs the reclustering and sets kept and rejected to be the jets
182 /// of interest (with non-zero rho, they will have been
183 /// subtracted). Normally this will be accessed through the base
184 /// class's operator().
185 ///
186 /// \param jet the jet that gets reclustered
187 /// \return the reclustered jet
188 virtual PseudoJet result(const PseudoJet & jet) const;
189
190 /// A lower-level method that does the actual work of reclustering
191 /// the input jet. The resulting jets are stored in output_jets.
192 /// The jet definition that has been used can be accessed from the
193 /// output_jets' ClusterSequence.
194 ///
195 /// \param input_jet the (input) jet that one wants to recluster
196 /// \param output_jets inclusive jets resulting from the new clustering
197 ///
198 /// Returns true if the C/A optimisation has been used (this means
199 /// that generate_output_jet then has to watch out for non-explicit-ghost
200 /// areas that might be leftover)
201 bool get_new_jets_and_def(const PseudoJet & input_jet,
202 std::vector<PseudoJet> & output_jets) const;
203
204 /// given a set of inclusive jets and a jet definition used, create the
205 /// resulting PseudoJet;
206 ///
207 /// If ca_optimisation_used then special care will be taken in
208 /// deciding whether the final jet can legitimately have an area.
209 PseudoJet generate_output_jet(std::vector<PseudoJet> & incljets,
210 bool ca_optimisation_used) const;
211
212
213private:
214 /// set the reclustered elements in the simple case of C/A+C/A
215 void _recluster_ca(const std::vector<PseudoJet> & all_pieces,
216 std::vector<PseudoJet> & incljets,
217 double Rfilt) const;
218
219 /// set the reclustered elements in the generic re-clustering case
220 void _recluster_generic(const PseudoJet & jet,
221 std::vector<PseudoJet> & incljets,
222 const JetDefinition & new_jet_def,
223 bool do_areas) const;
224
225 // a series of checks
226 //--------------------------------------------------------------------
227 /// get the pieces down to the fundamental pieces
228 bool _get_all_pieces(const PseudoJet &jet, std::vector<PseudoJet> &all_pieces) const;
229
230 /// associate the proper recombiner taken from the underlying pieces
231 /// (an error is thrown if the pieces do no share a common
232 /// recombiner)
233 void _acquire_recombiner_from_pieces(const std::vector<PseudoJet> &all_pieces,
234 JetDefinition &new_jet_def) const;
235
236 /// check if one can apply the simplified trick for C/A subjets
237 bool _check_ca(const std::vector<PseudoJet> &all_pieces,
238 const JetDefinition &new_jet_def) const;
239
240 /// check if the jet (or all its pieces) have explicit ghosts
241 /// (assuming the jet has area support
242 ///
243 /// Note that if the jet has an associated cluster sequence that is no
244 /// longer valid, an error will be thrown
245 bool _check_explicit_ghosts(const std::vector<PseudoJet> &all_pieces) const;
246
247 JetDefinition _new_jet_def; ///< the jet definition to use to extract the jets
248 bool _acquire_recombiner; ///< get the recombiner from the input
249 ///< jet rather than from _new_jet_def
250 Keep _keep; ///< dictates which inclusive jets are kept and
251 ///< which are returned (see Keep above)
252
253 bool _cambridge_optimisation_enabled; ///<enable the checks to
254 ///< perform optimisation when
255 ///< C/A reclustering is asked
256
257 static LimitedWarning _explicit_ghost_warning;
258};
259
260FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
261
262#endif // __FASTJET_TOOLS_RECLUSTER_HH__
Note: See TracBrowser for help on using the repository browser.