Fork me on GitHub

source: git/external/fastjet/WrappedStructure.hh@ 7bca620

Last change on this file since 7bca620 was cb80e6f, checked in by Pavel Demin <pavel.demin@…>, 4 years ago

update FastJet library to 3.3.4 and FastJet Contrib library to 1.045

  • Property mode set to 100644
File size: 10.8 KB
Line 
1//FJSTARTHEADER
2// $Id: WrappedStructure.hh 4442 2020-05-05 07:50:11Z soyez $
3//
4// Copyright (c) 2005-2020, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
5//
6//----------------------------------------------------------------------
7// This file is part of FastJet.
8//
9// FastJet is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 2 of the License, or
12// (at your option) any later version.
13//
14// The algorithms that underlie FastJet have required considerable
15// development. They are described in the original FastJet paper,
16// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17// FastJet as part of work towards a scientific publication, please
18// quote the version you use and include a citation to the manual and
19// optionally also to hep-ph/0512210.
20//
21// FastJet is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28//----------------------------------------------------------------------
29//FJENDHEADER
30
31
32#ifndef __FASTJET_WRAPPED_STRUCTURE_HH__
33#define __FASTJET_WRAPPED_STRUCTURE_HH__
34
35#include "fastjet/PseudoJetStructureBase.hh"
36#include "fastjet/Error.hh"
37
38FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
39
40/// @ingroup extra_info
41/// \class WrappedStructure
42///
43/// This wraps a (shared) pointer to an underlying structure
44///
45/// The typical use-case is when a PseusoJet needs to share its
46/// structure with another PseudoJet but also include extra
47/// information in its structure. For the memory management to be
48/// handled properly, it should hold a shared pointer to the shared
49/// structure. This is what this class ensures. Deriving a structure
50/// from this class would then allow for the implementation of the
51/// extra features.
52///
53class WrappedStructure : public PseudoJetStructureBase{
54public:
55 /// default ctor
56 /// the argument is the structure we need to wrap
57 WrappedStructure(const SharedPtr<PseudoJetStructureBase> & to_be_shared)
58 : _structure(to_be_shared){
59 if (!_structure)
60 throw Error("Trying to construct a wrapped structure around an empty (NULL) structure");
61 }
62
63 /// default (virtual) dtor
64 virtual ~WrappedStructure(){}
65
66 /// description
67 virtual std::string description() const FASTJET_OVERRIDE{
68 return "PseudoJet wrapping the structure ("+_structure->description()+")";
69 }
70
71 //-------------------------------------------------------------
72 /// @name Direct access to the associated ClusterSequence object.
73 ///
74 /// Get access to the associated ClusterSequence (if any)
75 //\{
76 //-------------------------------------------------------------
77 /// returns true if there is an associated ClusterSequence
78 virtual bool has_associated_cluster_sequence() const FASTJET_OVERRIDE {
79 return _structure->has_associated_cluster_sequence();
80 }
81
82 /// get a (const) pointer to the parent ClusterSequence (NULL if
83 /// inexistent)
84 virtual const ClusterSequence* associated_cluster_sequence() const FASTJET_OVERRIDE{
85 return _structure->associated_cluster_sequence();
86 }
87
88 /// returns true if this PseudoJet has an associated and still
89 /// valid ClusterSequence.
90 virtual bool has_valid_cluster_sequence() const FASTJET_OVERRIDE {
91 return _structure->has_valid_cluster_sequence();
92 }
93
94 /// if the jet has a valid associated cluster sequence then return a
95 /// pointer to it; otherwise throw an error
96 virtual const ClusterSequence * validated_cs() const FASTJET_OVERRIDE{
97 return _structure->validated_cs();
98 }
99
100 /// if the jet has valid area information then return a pointer to
101 /// the associated ClusterSequenceAreaBase object; otherwise throw an error
102 virtual const ClusterSequenceAreaBase * validated_csab() const FASTJET_OVERRIDE{
103 return _structure->validated_csab();
104 }
105
106 //\}
107
108 //-------------------------------------------------------------
109 /// @name Methods for access to information about jet structure
110 ///
111 /// These allow access to jet constituents, and other jet
112 /// subtructure information. They only work if the jet is associated
113 /// with a ClusterSequence.
114 //-------------------------------------------------------------
115 //\{
116
117 /// check if it has been recombined with another PseudoJet in which
118 /// case, return its partner through the argument. Otherwise,
119 /// 'partner' is set to 0.
120 ///
121 /// By default, throws an Error
122 virtual bool has_partner(const PseudoJet &reference, PseudoJet &partner) const FASTJET_OVERRIDE{
123 return _structure->has_partner(reference, partner);
124 }
125
126 /// check if it has been recombined with another PseudoJet in which
127 /// case, return its child through the argument. Otherwise, 'child'
128 /// is set to 0.
129 ///
130 /// By default, throws an Error
131 virtual bool has_child(const PseudoJet &reference, PseudoJet &child) const FASTJET_OVERRIDE{
132 return _structure->has_child(reference, child);
133 }
134
135 /// check if it is the product of a recombination, in which case
136 /// return the 2 parents through the 'parent1' and 'parent2'
137 /// arguments. Otherwise, set these to 0.
138 ///
139 /// By default, throws an Error
140 virtual bool has_parents(const PseudoJet &reference,
141 PseudoJet &parent1, PseudoJet &parent2) const FASTJET_OVERRIDE{
142 return _structure->has_parents(reference, parent1, parent2);
143 }
144
145 /// check if the reference PseudoJet is contained the second one
146 /// passed as argument.
147 ///
148 /// By default, throws an Error
149 virtual bool object_in_jet(const PseudoJet &reference,
150 const PseudoJet &jet) const FASTJET_OVERRIDE{
151 return _structure->object_in_jet(reference, jet);
152 }
153
154
155 /// return true if the structure supports constituents.
156 ///
157 /// false by default
158 virtual bool has_constituents() const FASTJET_OVERRIDE{
159 return _structure->has_constituents();
160 }
161
162 /// retrieve the constituents.
163 ///
164 /// By default, throws an Error
165 virtual std::vector<PseudoJet> constituents(const PseudoJet &reference) const FASTJET_OVERRIDE{
166 return _structure->constituents(reference);
167 }
168
169 /// return true if the structure supports exclusive_subjets.
170 virtual bool has_exclusive_subjets() const FASTJET_OVERRIDE{
171 return _structure->has_exclusive_subjets();
172 }
173
174 /// return a vector of all subjets of the current jet (in the sense
175 /// of the exclusive algorithm) that would be obtained when running
176 /// the algorithm with the given dcut.
177 ///
178 /// Time taken is O(m ln m), where m is the number of subjets that
179 /// are found. If m gets to be of order of the total number of
180 /// constituents in the jet, this could be substantially slower than
181 /// just getting that list of constituents.
182 ///
183 /// By default, throws an Error
184 virtual std::vector<PseudoJet> exclusive_subjets(const PseudoJet &reference,
185 const double & dcut) const FASTJET_OVERRIDE{
186 return _structure->exclusive_subjets(reference, dcut);
187 }
188
189 /// return the size of exclusive_subjets(...); still n ln n with same
190 /// coefficient, but marginally more efficient than manually taking
191 /// exclusive_subjets.size()
192 ///
193 /// By default, throws an Error
194 virtual int n_exclusive_subjets(const PseudoJet &reference,
195 const double & dcut) const FASTJET_OVERRIDE{
196 return _structure->n_exclusive_subjets(reference, dcut);
197 }
198
199 /// return the list of subjets obtained by unclustering the supplied
200 /// jet down to n subjets (or all constituents if there are fewer
201 /// than n).
202 ///
203 /// By default, throws an Error
204 virtual std::vector<PseudoJet> exclusive_subjets_up_to (const PseudoJet &reference,
205 int nsub) const FASTJET_OVERRIDE{
206 return _structure->exclusive_subjets_up_to (reference, nsub);
207 }
208
209 /// return the dij that was present in the merging nsub+1 -> nsub
210 /// subjets inside this jet.
211 ///
212 /// By default, throws an Error
213 virtual double exclusive_subdmerge(const PseudoJet &reference, int nsub) const FASTJET_OVERRIDE{
214 return _structure->exclusive_subdmerge(reference, nsub);
215 }
216
217 /// return the maximum dij that occurred in the whole event at the
218 /// stage that the nsub+1 -> nsub merge of subjets occurred inside
219 /// this jet.
220 ///
221 /// By default, throws an Error
222 virtual double exclusive_subdmerge_max(const PseudoJet &reference, int nsub) const FASTJET_OVERRIDE{
223 return _structure->exclusive_subdmerge_max(reference, nsub);
224 }
225
226
227 //-------------------------------------------------------------------
228 // information related to the pieces of the jet
229 //-------------------------------------------------------------------
230 /// return true if the structure supports pieces.
231 ///
232 /// false by default
233 virtual bool has_pieces(const PseudoJet &reference) const FASTJET_OVERRIDE {
234 return _structure->has_pieces(reference);
235 }
236
237 /// retrieve the pieces building the jet.
238 ///
239 /// By default, throws an Error
240 virtual std::vector<PseudoJet> pieces(const PseudoJet &reference) const FASTJET_OVERRIDE {
241 return _structure->pieces(reference);
242 }
243
244 // the following ones require a computation of the area in the
245 // parent ClusterSequence (See ClusterSequenceAreaBase for details)
246 //------------------------------------------------------------------
247
248 /// check if it has a defined area
249 ///
250 /// false by default
251 virtual bool has_area() const FASTJET_OVERRIDE {
252 return _structure->has_area();
253 }
254
255 /// return the jet (scalar) area.
256 ///
257 /// By default, throws an Error
258 virtual double area(const PseudoJet &reference) const FASTJET_OVERRIDE{
259 return _structure->area(reference);
260 }
261
262 /// return the error (uncertainty) associated with the determination
263 /// of the area of this jet.
264 ///
265 /// By default, throws an Error
266 virtual double area_error(const PseudoJet &reference) const FASTJET_OVERRIDE{
267 return _structure->area_error(reference);
268 }
269
270 /// return the jet 4-vector area.
271 ///
272 /// By default, throws an Error
273 virtual PseudoJet area_4vector(const PseudoJet &reference) const FASTJET_OVERRIDE{
274 return _structure->area_4vector(reference);
275 }
276
277 /// true if this jet is made exclusively of ghosts.
278 ///
279 /// By default, throws an Error
280 virtual bool is_pure_ghost(const PseudoJet &reference) const FASTJET_OVERRIDE{
281 return _structure->is_pure_ghost(reference);
282 }
283
284 //\} --- end of jet structure -------------------------------------
285
286protected:
287 SharedPtr<PseudoJetStructureBase> _structure; ///< the wrapped structure
288};
289
290FASTJET_END_NAMESPACE
291
292#endif // __FASTJET_PSEUDOJET_STRUCTURE_BASE_HH__
Note: See TracBrowser for help on using the repository browser.