FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
WrappedStructure.hh
1 //FJSTARTHEADER
2 // $Id: WrappedStructure.hh 3433 2014-07-23 08:17:03Z salam $
3 //
4 // Copyright (c) 2005-2014, 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 
38 FASTJET_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 ///
54 public:
55  /// default ctor
56  /// the argument is the structure we need to wrap
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{
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 {
79  return _structure->has_associated_cluster_sequence();
80  }
81 
82  /// get a (const) pointer to the parent ClusterSequence (NULL if
83  /// inexistent)
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 {
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{
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{
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{
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{
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, PseudoJet &parent1, PseudoJet &parent2) const{
141  return _structure->has_parents(reference, parent1, parent2);
142  }
143 
144  /// check if the reference PseudoJet is contained the second one
145  /// passed as argument.
146  ///
147  /// By default, throws an Error
148  virtual bool object_in_jet(const PseudoJet &reference, const PseudoJet &jet) const{
149  return _structure->object_in_jet(reference, jet);
150  }
151 
152 
153  /// return true if the structure supports constituents.
154  ///
155  /// false by default
156  virtual bool has_constituents() const {
157  return _structure->has_constituents();
158  }
159 
160  /// retrieve the constituents.
161  ///
162  /// By default, throws an Error
163  virtual std::vector<PseudoJet> constituents(const PseudoJet &reference) const{
164  return _structure->constituents(reference);
165  }
166 
167  /// return true if the structure supports exclusive_subjets.
168  virtual bool has_exclusive_subjets() const {
169  return _structure->has_exclusive_subjets();
170  }
171 
172  /// return a vector of all subjets of the current jet (in the sense
173  /// of the exclusive algorithm) that would be obtained when running
174  /// the algorithm with the given dcut.
175  ///
176  /// Time taken is O(m ln m), where m is the number of subjets that
177  /// are found. If m gets to be of order of the total number of
178  /// constituents in the jet, this could be substantially slower than
179  /// just getting that list of constituents.
180  ///
181  /// By default, throws an Error
182  virtual std::vector<PseudoJet> exclusive_subjets(const PseudoJet &reference, const double & dcut) const{
183  return _structure->exclusive_subjets(reference, dcut);
184  }
185 
186  /// return the size of exclusive_subjets(...); still n ln n with same
187  /// coefficient, but marginally more efficient than manually taking
188  /// exclusive_subjets.size()
189  ///
190  /// By default, throws an Error
191  virtual int n_exclusive_subjets(const PseudoJet &reference, const double & dcut) const{
192  return _structure->n_exclusive_subjets(reference, dcut);
193  }
194 
195  /// return the list of subjets obtained by unclustering the supplied
196  /// jet down to n subjets (or all constituents if there are fewer
197  /// than n).
198  ///
199  /// By default, throws an Error
200  virtual std::vector<PseudoJet> exclusive_subjets_up_to (const PseudoJet &reference, int nsub) const{
201  return _structure->exclusive_subjets_up_to (reference, nsub);
202  }
203 
204  /// return the dij that was present in the merging nsub+1 -> nsub
205  /// subjets inside this jet.
206  ///
207  /// By default, throws an Error
208  virtual double exclusive_subdmerge(const PseudoJet &reference, int nsub) const{
209  return _structure->exclusive_subdmerge(reference, nsub);
210  }
211 
212  /// return the maximum dij that occurred in the whole event at the
213  /// stage that the nsub+1 -> nsub merge of subjets occurred inside
214  /// this jet.
215  ///
216  /// By default, throws an Error
217  virtual double exclusive_subdmerge_max(const PseudoJet &reference, int nsub) const{
218  return _structure->exclusive_subdmerge_max(reference, nsub);
219  }
220 
221 
222  //-------------------------------------------------------------------
223  // information related to the pieces of the jet
224  //-------------------------------------------------------------------
225  /// return true if the structure supports pieces.
226  ///
227  /// false by default
228  virtual bool has_pieces(const PseudoJet &reference) const {
229  return _structure->has_pieces(reference);
230  }
231 
232  /// retrieve the pieces building the jet.
233  ///
234  /// By default, throws an Error
235  virtual std::vector<PseudoJet> pieces(const PseudoJet &reference) const{
236  return _structure->pieces(reference);
237  }
238 
239  // the following ones require a computation of the area in the
240  // parent ClusterSequence (See ClusterSequenceAreaBase for details)
241  //------------------------------------------------------------------
242 
243  /// check if it has a defined area
244  ///
245  /// false by default
246  virtual bool has_area() const {
247  return _structure->has_area();
248  }
249 
250  /// return the jet (scalar) area.
251  ///
252  /// By default, throws an Error
253  virtual double area(const PseudoJet &reference) const{
254  return _structure->area(reference);
255  }
256 
257  /// return the error (uncertainty) associated with the determination
258  /// of the area of this jet.
259  ///
260  /// By default, throws an Error
261  virtual double area_error(const PseudoJet &reference) const{
262  return _structure->area_error(reference);
263  }
264 
265  /// return the jet 4-vector area.
266  ///
267  /// By default, throws an Error
268  virtual PseudoJet area_4vector(const PseudoJet &reference) const{
269  return _structure->area_4vector(reference);
270  }
271 
272  /// true if this jet is made exclusively of ghosts.
273  ///
274  /// By default, throws an Error
275  virtual bool is_pure_ghost(const PseudoJet &reference) const{
276  return _structure->is_pure_ghost(reference);
277  }
278 
279  //\} --- end of jet structure -------------------------------------
280 
281 protected:
282  SharedPtr<PseudoJetStructureBase> _structure; ///< the wrapped structure
283 };
284 
285 FASTJET_END_NAMESPACE
286 
287 #endif // __FASTJET_PSEUDOJET_STRUCTURE_BASE_HH__
virtual std::string description() const
description
virtual PseudoJet area_4vector(const PseudoJet &reference) const
return the jet 4-vector area.
WrappedStructure(const SharedPtr< PseudoJetStructureBase > &to_be_shared)
default ctor the argument is the structure we need to wrap
virtual bool object_in_jet(const PseudoJet &reference, const PseudoJet &jet) const
check if the reference PseudoJet is contained the second one passed as argument.
virtual std::vector< PseudoJet > exclusive_subjets(const PseudoJet &reference, const double &dcut) const
return a vector of all subjets of the current jet (in the sense of the exclusive algorithm) that woul...
deals with clustering
virtual double area(const PseudoJet &reference) const
return the jet (scalar) area.
virtual const ClusterSequence * validated_cs() const
if the jet has a valid associated cluster sequence then return a pointer to it; otherwise throw an er...
virtual int n_exclusive_subjets(const PseudoJet &reference, const double &dcut) const
return the size of exclusive_subjets(...); still n ln n with same coefficient, but marginally more ef...
virtual ~WrappedStructure()
default (virtual) dtor
virtual const ClusterSequenceAreaBase * validated_csab() const
if the jet has valid area information then return a pointer to the associated ClusterSequenceAreaBase...
This wraps a (shared) pointer to an underlying structure.
Contains any information related to the clustering that should be directly accessible to PseudoJet...
virtual bool has_parents(const PseudoJet &reference, PseudoJet &parent1, PseudoJet &parent2) const
check if it is the product of a recombination, in which case return the 2 parents through the 'parent...
virtual bool has_valid_cluster_sequence() const
returns true if this PseudoJet has an associated and still valid ClusterSequence. ...
virtual std::vector< PseudoJet > pieces(const PseudoJet &reference) const
retrieve the pieces building the jet.
virtual bool has_associated_cluster_sequence() const
returns true if there is an associated ClusterSequence
virtual bool has_constituents() const
return true if the structure supports constituents.
virtual std::vector< PseudoJet > exclusive_subjets_up_to(const PseudoJet &reference, int nsub) const
return the list of subjets obtained by unclustering the supplied jet down to n subjets (or all consti...
base class that sets interface for extensions of ClusterSequence that provide information about the a...
virtual double exclusive_subdmerge_max(const PseudoJet &reference, int nsub) const
return the maximum dij that occurred in the whole event at the stage that the nsub+1 -> nsub merge of...
base class corresponding to errors that can be thrown by FastJet
Definition: Error.hh:47
virtual double area_error(const PseudoJet &reference) const
return the error (uncertainty) associated with the determination of the area of this jet...
virtual double exclusive_subdmerge(const PseudoJet &reference, int nsub) const
return the dij that was present in the merging nsub+1 -> nsub subjets inside this jet...
virtual bool has_child(const PseudoJet &reference, PseudoJet &child) const
check if it has been recombined with another PseudoJet in which case, return its child through the ar...
an implementation of C++0x shared pointers (or boost's)
Definition: SharedPtr.hh:116
virtual const ClusterSequence * associated_cluster_sequence() const
get a (const) pointer to the parent ClusterSequence (NULL if inexistent)
virtual std::vector< PseudoJet > constituents(const PseudoJet &reference) const
retrieve the constituents.
virtual bool is_pure_ghost(const PseudoJet &reference) const
true if this jet is made exclusively of ghosts.
virtual bool has_area() const
check if it has a defined area
SharedPtr< PseudoJetStructureBase > _structure
the wrapped structure
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
Definition: PseudoJet.hh:67
virtual bool has_pieces(const PseudoJet &reference) const
return true if the structure supports pieces.
virtual bool has_partner(const PseudoJet &reference, PseudoJet &partner) const
check if it has been recombined with another PseudoJet in which case, return its partner through the ...
virtual PseudoJet area_4vector() const
return the jet 4-vector area.
Definition: PseudoJet.cc:732
virtual bool has_exclusive_subjets() const
return true if the structure supports exclusive_subjets.