FastJet 3.0beta1
|
00001 //STARTHEADER 00002 // $Id: WrappedStructure.hh 2361 2011-07-06 07:21:47Z soyez $ 00003 // 00004 // Copyright (c) 2005-2010, Matteo Cacciari, Gavin Salam and Gregory Soyez 00005 // 00006 //---------------------------------------------------------------------- 00007 // This file is part of FastJet. 00008 // 00009 // FastJet is free software; you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // The algorithms that underlie FastJet have required considerable 00015 // development and are described in hep-ph/0512210. If you use 00016 // FastJet as part of work towards a scientific publication, please 00017 // include a citation to the FastJet paper. 00018 // 00019 // FastJet is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with FastJet; if not, write to the Free Software 00026 // Foundation, Inc.: 00027 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 //---------------------------------------------------------------------- 00029 //ENDHEADER 00030 00031 00032 #ifndef __FASTJET_WRAPPED_STRUCTURE_HH__ 00033 #define __FASTJET_WRAPPED_STRUCTURE_HH__ 00034 00035 #include "fastjet/PseudoJetStructureBase.hh" 00036 #include "fastjet/Error.hh" 00037 00038 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00039 00040 /// @ingroup extra_info 00041 /// \class WrappedStructure 00042 /// 00043 /// This wraps a (shared) pointer to an underlying structure 00044 /// 00045 /// The typical use-case is when a PseusoJet needs to share its 00046 /// structure with another PseudoJet but also include extra 00047 /// information in its structure. For the memory management to be 00048 /// handled properly, it should hold a shared pointer to the shared 00049 /// structure. This is what this class ensures. Deriving a structure 00050 /// from this class would then allow for the implementation of the 00051 /// extra features. 00052 /// 00053 class WrappedStructure : public PseudoJetStructureBase{ 00054 public: 00055 /// default ctor 00056 /// the argument is the structure we need to wrap 00057 WrappedStructure(const SharedPtr<PseudoJetStructureBase> & to_be_shared) 00058 : _structure(to_be_shared){ 00059 if (!_structure()) 00060 throw Error("Trying to construct a wrapped structure around an empty (NULL) structure"); 00061 } 00062 00063 /// default (virtual) dtor 00064 virtual ~WrappedStructure(){} 00065 00066 /// description 00067 virtual std::string description() const{ 00068 return "PseudoJet wrapping the structure ("+_structure->description()+")"; 00069 } 00070 00071 //------------------------------------------------------------- 00072 /// @name Direct access to the associated ClusterSequence object. 00073 /// 00074 /// Get access to the associated ClusterSequence (if any) 00075 //\{ 00076 //------------------------------------------------------------- 00077 /// returns true if there is an associated ClusterSequence 00078 virtual bool has_associated_cluster_sequence() const { 00079 return _structure->has_associated_cluster_sequence(); 00080 } 00081 00082 /// get a (const) pointer to the parent ClusterSequence (NULL if 00083 /// inexistent) 00084 virtual const ClusterSequence* associated_cluster_sequence() const{ 00085 return _structure->associated_cluster_sequence(); 00086 } 00087 00088 /// returns true if this PseudoJet has an associated and still 00089 /// valid ClusterSequence. 00090 virtual bool has_valid_cluster_sequence() const { 00091 return _structure->has_valid_cluster_sequence(); 00092 } 00093 00094 /// if the jet has a valid associated cluster sequence then return a 00095 /// pointer to it; otherwise throw an error 00096 virtual const ClusterSequence * validated_cs() const{ 00097 return _structure->validated_cs(); 00098 } 00099 00100 /// if the jet has valid area information then return a pointer to 00101 /// the associated ClusterSequenceAreaBase object; otherwise throw an error 00102 virtual const ClusterSequenceAreaBase * validated_csab() const{ 00103 return _structure->validated_csab(); 00104 } 00105 00106 //\} 00107 00108 //------------------------------------------------------------- 00109 /// @name Methods for access to information about jet structure 00110 /// 00111 /// These allow access to jet constituents, and other jet 00112 /// subtructure information. They only work if the jet is associated 00113 /// with a ClusterSequence. 00114 //------------------------------------------------------------- 00115 //\{ 00116 00117 /// check if it has been recombined with another PseudoJet in which 00118 /// case, return its partner through the argument. Otherwise, 00119 /// 'partner' is set to 0. 00120 /// 00121 /// By default, throws an Error 00122 virtual bool has_partner(const PseudoJet &reference, PseudoJet &partner) const{ 00123 return _structure->has_partner(reference, partner); 00124 } 00125 00126 /// check if it has been recombined with another PseudoJet in which 00127 /// case, return its child through the argument. Otherwise, 'child' 00128 /// is set to 0. 00129 /// 00130 /// By default, throws an Error 00131 virtual bool has_child(const PseudoJet &reference, PseudoJet &child) const{ 00132 return _structure->has_child(reference, child); 00133 } 00134 00135 /// check if it is the product of a recombination, in which case 00136 /// return the 2 parents through the 'parent1' and 'parent2' 00137 /// arguments. Otherwise, set these to 0. 00138 /// 00139 /// By default, throws an Error 00140 virtual bool has_parents(const PseudoJet &reference, PseudoJet &parent1, PseudoJet &parent2) const{ 00141 return _structure->has_parents(reference, parent1, parent2); 00142 } 00143 00144 /// check if the reference PseudoJet is contained the second one 00145 /// passed as argument. 00146 /// 00147 /// By default, throws an Error 00148 virtual bool object_in_jet(const PseudoJet &reference, const PseudoJet &jet) const{ 00149 return _structure->object_in_jet(reference, jet); 00150 } 00151 00152 00153 /// return true if the structure supports constituents. 00154 /// 00155 /// false by default 00156 virtual bool has_constituents() const { 00157 return _structure->has_constituents(); 00158 } 00159 00160 /// retrieve the constituents. 00161 /// 00162 /// By default, throws an Error 00163 virtual std::vector<PseudoJet> constituents(const PseudoJet &reference) const{ 00164 return _structure->constituents(reference); 00165 } 00166 00167 /// return true if the structure supports exclusive_subjets. 00168 virtual bool has_exclusive_subjets() const { 00169 return _structure->has_exclusive_subjets(); 00170 } 00171 00172 /// return a vector of all subjets of the current jet (in the sense 00173 /// of the exclusive algorithm) that would be obtained when running 00174 /// the algorithm with the given dcut. 00175 /// 00176 /// Time taken is O(m ln m), where m is the number of subjets that 00177 /// are found. If m gets to be of order of the total number of 00178 /// constituents in the jet, this could be substantially slower than 00179 /// just getting that list of constituents. 00180 /// 00181 /// By default, throws an Error 00182 virtual std::vector<PseudoJet> exclusive_subjets(const PseudoJet &reference, const double & dcut) const{ 00183 return _structure->exclusive_subjets(reference, dcut); 00184 } 00185 00186 /// return the size of exclusive_subjets(...); still n ln n with same 00187 /// coefficient, but marginally more efficient than manually taking 00188 /// exclusive_subjets.size() 00189 /// 00190 /// By default, throws an Error 00191 virtual int n_exclusive_subjets(const PseudoJet &reference, const double & dcut) const{ 00192 return _structure->n_exclusive_subjets(reference, dcut); 00193 } 00194 00195 /// return the list of subjets obtained by unclustering the supplied 00196 /// jet down to n subjets (or all constituents if there are fewer 00197 /// than n). 00198 /// 00199 /// By default, throws an Error 00200 virtual std::vector<PseudoJet> exclusive_subjets_up_to (const PseudoJet &reference, int nsub) const{ 00201 return _structure->exclusive_subjets_up_to (reference, nsub); 00202 } 00203 00204 /// return the dij that was present in the merging nsub+1 -> nsub 00205 /// subjets inside this jet. 00206 /// 00207 /// By default, throws an Error 00208 virtual double exclusive_subdmerge(const PseudoJet &reference, int nsub) const{ 00209 return _structure->exclusive_subdmerge(reference, nsub); 00210 } 00211 00212 /// return the maximum dij that occurred in the whole event at the 00213 /// stage that the nsub+1 -> nsub merge of subjets occurred inside 00214 /// this jet. 00215 /// 00216 /// By default, throws an Error 00217 virtual double exclusive_subdmerge_max(const PseudoJet &reference, int nsub) const{ 00218 return _structure->exclusive_subdmerge_max(reference, nsub); 00219 } 00220 00221 00222 //------------------------------------------------------------------- 00223 // information related to the pieces of the jet 00224 //------------------------------------------------------------------- 00225 /// return true if the structure supports pieces. 00226 /// 00227 /// false by default 00228 virtual bool has_pieces(const PseudoJet &reference) const { 00229 return _structure->has_pieces(reference); 00230 } 00231 00232 /// retrieve the pieces building the jet. 00233 /// 00234 /// By default, throws an Error 00235 virtual std::vector<PseudoJet> pieces(const PseudoJet &reference) const{ 00236 return _structure->pieces(reference); 00237 } 00238 00239 // the following ones require a computation of the area in the 00240 // parent ClusterSequence (See ClusterSequenceAreaBase for details) 00241 //------------------------------------------------------------------ 00242 00243 /// check if it has a defined area 00244 /// 00245 /// false by default 00246 virtual bool has_area() const { 00247 return _structure->has_area(); 00248 } 00249 00250 /// return the jet (scalar) area. 00251 /// 00252 /// By default, throws an Error 00253 virtual double area(const PseudoJet &reference) const{ 00254 return _structure->area(reference); 00255 } 00256 00257 /// return the error (uncertainty) associated with the determination 00258 /// of the area of this jet. 00259 /// 00260 /// By default, throws an Error 00261 virtual double area_error(const PseudoJet &reference) const{ 00262 return _structure->area_error(reference); 00263 } 00264 00265 /// return the jet 4-vector area. 00266 /// 00267 /// By default, throws an Error 00268 virtual PseudoJet area_4vector(const PseudoJet &reference) const{ 00269 return _structure->area_4vector(reference); 00270 } 00271 00272 /// true if this jet is made exclusively of ghosts. 00273 /// 00274 /// By default, throws an Error 00275 virtual bool is_pure_ghost(const PseudoJet &reference) const{ 00276 return _structure->is_pure_ghost(reference); 00277 } 00278 00279 //\} --- end of jet structure ------------------------------------- 00280 00281 protected: 00282 SharedPtr<PseudoJetStructureBase> _structure; ///< the wrapped structure 00283 }; 00284 00285 FASTJET_END_NAMESPACE 00286 00287 #endif // __FASTJET_PSEUDOJET_STRUCTURE_BASE_HH__