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