Fork me on GitHub

source: git/external/fastjet/contribs/RecursiveTools/Recluster.hh@ 45d8342

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 45d8342 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: 8.3 KB
RevLine 
[1f1f858]1#ifndef __FASTJET_TOOLS_RECLUSTER_HH__
2#define __FASTJET_TOOLS_RECLUSTER_HH__
3
4// $Id: Recluster.hh 700 2014-07-07 12:50:05Z gsoyez $
5//
6// Copyright (c) 2014-, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
7//
8//----------------------------------------------------------------------
9// This file is part of FastJet contrib.
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/CompositeJetStructure.hh> // to derive the ReclusterStructure from CompositeJetStructure
27#include <fastjet/tools/Transformer.hh> // to derive Recluster from Transformer
28#include <iostream>
29#include <string>
30
31FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
32
33namespace contrib{
34
35//----------------------------------------------------------------------
36/// \class Recluster
37/// Class that helps reclustering a jet with a new jet definition
38///
39/// The result of the reclustering is returned as a single PseudoJet
40/// with a CompositeJet structure. The pieces of that PseudoJet will
41/// be the individual subjets
42///
43/// When constructed from a JetDefinition, that definition will be
44/// used to obtain the subjets. When constructed from a JetAlgorithm
45/// and parameters (0 parameters for e+e-, just R or R and an extra
46/// parameter for others) the recombination scheme will be taken as
47/// the same one used to initially cluster the original jet.
48///
49/// The result of this transformer depends on its usage. There are two
50/// typical use-cases: either we recluster one fat jet into subjets,
51/// OR, we recluster the jet with a different jet alg. When Recluster
52/// is created from a full jet definition. The last parameter of the
53/// constructors below dicatate that behaviour: if "single" is true
54/// (the default), a single jet, issued from a regular clustering is
55/// returned (if there are more than one, the hardest is taken);
56/// otherwise (single==false), the result will be a composite jet with
57/// each subjet as pieces
58///
59/// Open points for discussion:
60///
61/// - do we add an option to force area support? [could be useful
62/// e.g. for the filter with a subtractor where area support is
63/// mandatory]
64///
65class Recluster : public Transformer {
66public:
67 /// define a recluster that decomposes a jet into subjets using a
68 /// generic JetDefinition
69 ///
70 /// \param subjet_def the jet definition applied to obtain the subjets
71 /// \param single when true, cluster the jet in a single jet (the
72 /// hardest one) with an associated ClusterSequence,
73 /// otherwise return a composite jet with subjets
74 /// as pieces.
75 Recluster(const JetDefinition & subjet_def, bool single=true)
76 : _subjet_def(subjet_def), _use_full_def(true), _single(single) {}
77
78 /// define a recluster that decomposes a jet into subjets using a
79 /// JetAlgorithm and its parameters
80 ///
81 /// \param subjet_alg the jet algorithm applied to obtain the subjets
82 /// \param subjet_radius the jet radius if required
83 /// \param subjet_extra optional extra parameters for the jet algorithm (only when needed)
84 /// \param single when true, cluster the jet in a single jet (the
85 /// hardest one) with an associated ClusterSequence,
86 /// otherwise return a composite jet with subjets
87 /// as pieces.
88 ///
89 /// Typically, for e+e- algoriothm you should use the third version
90 /// below with no parameters, for "standard" pp algorithms, just the
91 /// clustering radius has to be specified and for genkt-type of
92 /// algorithms, both the radius and the extra parameter have to be
93 /// specified.
94 Recluster(JetAlgorithm subjet_alg, double subjet_radius, double subjet_extra,
95 bool single=true)
96 : _subjet_alg(subjet_alg), _use_full_def(false),
97 _subjet_radius(subjet_radius), _has_subjet_radius(true),
98 _subjet_extra(subjet_extra), _has_subjet_extra(true), _single(single) {}
99 Recluster(JetAlgorithm subjet_alg, double subjet_radius, bool single=true)
100 : _subjet_alg(subjet_alg), _use_full_def(false),
101 _subjet_radius(subjet_radius), _has_subjet_radius(true),
102 _has_subjet_extra(false), _single(single) {}
103 Recluster(JetAlgorithm subjet_alg, bool single=true)
104 : _subjet_alg(subjet_alg), _use_full_def(false),
105 _has_subjet_radius(false), _has_subjet_extra(false), _single(single) {}
106
107 /// default dtor
108 virtual ~Recluster(){};
109
110 //----------------------------------------------------------------------
111 // standard Transformer behaviour inherited from the base class
112 // (i.e. result(), description() and structural info)
113
114 /// runs the reclustering and sets kept and rejected to be the jets of interest
115 /// (with non-zero rho, they will have been subtracted).
116 ///
117 /// \param jet the jet that gets reclustered
118 /// \return the reclustered jet
119 virtual PseudoJet result(const PseudoJet & jet) const;
120
121 /// class description
122 virtual std::string description() const;
123
124 // the type of the associated structure
125 typedef CompositeJetStructure StructureType;
126
127private:
128 /// set the reclustered elements in the simple case of C/A+C/A
129 void _recluster_cafilt(const std::vector<PseudoJet> & all_pieces,
130 std::vector<PseudoJet> & subjets,
131 double Rfilt) const;
132
133 /// set the reclustered elements in the generic re-clustering case
134 void _recluster_generic(const PseudoJet & jet,
135 std::vector<PseudoJet> & subjets,
136 const JetDefinition & subjet_def,
137 bool do_areas) const;
138
139 // a series of checks
140 //--------------------------------------------------------------------
141 /// get the pieces down to the fundamental pieces
142 bool _get_all_pieces(const PseudoJet &jet, std::vector<PseudoJet> &all_pieces) const;
143
144 /// get the common recombiner to all pieces (NULL if none)
145 const JetDefinition::Recombiner* _get_common_recombiner(const std::vector<PseudoJet> &all_pieces) const;
146
147 /// construct the proper jet definition ensuring that the recombiner
148 /// is taken from the underlying pieces (an error is thrown if the
149 /// pieces do no share a common recombiner)
150 void _build_jet_def_with_recombiner(const std::vector<PseudoJet> &all_pieces,
151 JetDefinition &subjet_def) const;
152
153 /// check if one can apply the simplified trick for C/A subjets
154 bool _check_ca(const std::vector<PseudoJet> &all_pieces,
155 const JetDefinition &subjet_def) const;
156
157 /// check if the jet (or all its pieces) have explicit ghosts
158 /// (assuming the jet has area support
159 ///
160 /// Note that if the jet has an associated cluster sequence that is no
161 /// longer valid, an error will be thrown
162 bool _check_explicit_ghosts(const std::vector<PseudoJet> &all_pieces) const;
163
164 JetDefinition _subjet_def; ///< the jet definition to use to extract the subjets
165 JetAlgorithm _subjet_alg; ///< the jet algorithm to be used
166 bool _use_full_def; ///< true when the full JetDefinition is supplied to the ctor
167 double _subjet_radius; ///< the jet radius (only if needed for the jet alg)
168 bool _has_subjet_radius; ///< the subjet radius has been specified
169 double _subjet_extra; ///< the jet alg extra param (only if needed)
170 bool _has_subjet_extra; ///< the extra param has been specified
171
172 bool _single; ///< (true) return a single jet with a
173 ///< regular clustering or (false) a
174 ///< composite jet with subjets as pieces
175
176 static LimitedWarning _explicit_ghost_warning;
177};
178
179} // namespace contrib
180
181FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
182
183#endif // __FASTJET_TOOLS_RECLUSTER_HH__
Note: See TracBrowser for help on using the repository browser.