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