FastJet 3.0.2
CompositeJetStructure.hh
00001 //STARTHEADER
00002 // $Id: CompositeJetStructure.hh 2684 2011-11-14 07:41:44Z soyez $
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_COMPOSITEJET_STRUCTURE_HH__
00031 #define __FASTJET_COMPOSITEJET_STRUCTURE_HH__
00032 
00033 #include <fastjet/PseudoJet.hh>
00034 #include <fastjet/PseudoJetStructureBase.hh>
00035 
00036 // to have access to the recombiner we need to include the JetDefinition header
00037 #include <fastjet/JetDefinition.hh>
00038 
00039 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00040 
00041 /// @ingroup extra_info
00042 /// \class CompositeJetStructure
00043 /// The structure for a jet made of pieces
00044 ///
00045 /// This stores the vector of the pieces that make the jet and provide
00046 /// the methods to access them
00047 class CompositeJetStructure : public PseudoJetStructureBase{
00048 public:
00049   // basic class info
00050   //-------------------------------------------------------------------
00051   /// default ctor
00052   CompositeJetStructure() : _area_4vector_ptr(0){};
00053 
00054   /// ctor with initialisation
00055   CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces, 
00056                         const JetDefinition::Recombiner * recombiner = 0);
00057 
00058   /// default dtor
00059   virtual ~CompositeJetStructure(){
00060     if (_area_4vector_ptr) delete _area_4vector_ptr;
00061   };
00062 
00063   /// description
00064   virtual std::string description() const;
00065 
00066   // things reimplemented from the base structure
00067   //-------------------------------------------------------------------
00068   /// true unless the jet has no pieces (see also the description of
00069   /// constituents() below)
00070   virtual bool has_constituents() const;
00071 
00072   /// return the constituents (i.e. the union of the constituents of each piece)
00073   /// 
00074   /// If any of the pieces has no constituent, the piece itself is
00075   /// considered as a constituent
00076   /// Note that as a consequence, a composite jet with no pieces will
00077   /// have an empty vector as constituents
00078   virtual std::vector<PseudoJet> constituents(const PseudoJet &jet) const;
00079 
00080   //-------------------------------------------------------------------
00081   // information related to the pieces of the jet
00082   //-------------------------------------------------------------------
00083   /// true if it has pieces (always the case)
00084   virtual bool has_pieces(const PseudoJet & /*jet*/) const {return true;}
00085 
00086   /// returns the pieces
00087   virtual std::vector<PseudoJet> pieces(const PseudoJet &jet) const;
00088 
00089   // area-related material
00090 
00091   /// check if it has a well-defined area
00092   virtual bool has_area() const;
00093 
00094   /// return the jet (scalar) area.
00095   virtual double area(const PseudoJet &reference) const;
00096 
00097   /// return the error (uncertainty) associated with the determination
00098   /// of the area of this jet.
00099   ///
00100   /// Be conservative: return the sum of the errors
00101   virtual double area_error(const PseudoJet &reference) const;
00102 
00103   /// return the jet 4-vector area.
00104   virtual PseudoJet area_4vector(const PseudoJet &reference) const;
00105 
00106   /// true if this jet is made exclusively of ghosts.
00107   ///
00108   /// In this case, it will be true if all pieces are pure ghost
00109   virtual bool is_pure_ghost(const PseudoJet &reference) const;
00110 
00111   // allow to modify the area information
00112   // (for use in join())
00113   //------------------------------------------------------------------------------
00114   void set_area_information(PseudoJet *area_4vector_ptr){
00115     _area_4vector_ptr = area_4vector_ptr;
00116   }
00117 
00118 
00119 protected:
00120   std::vector<PseudoJet> _pieces;  ///< the pieces building the jet
00121   PseudoJet * _area_4vector_ptr;   ///< pointer to the 4-vector jet area
00122 };
00123 
00124 
00125 
00126 // helpers to "join" jets and produce a structure derived from
00127 // CompositeJetStructure
00128 //
00129 // The template structure T must have a constructor accepting as
00130 // argument the pieces and of the composite jet
00131 // ------------------------------------------------------------------------
00132 
00133 /// build a "CompositeJet" from the vector of its pieces with an
00134 /// extended structure of type T derived from CompositeJetStructure
00135 template<typename T> PseudoJet join(const std::vector<PseudoJet> & pieces){
00136   PseudoJet result(0.0,0.0,0.0,0.0);
00137   for (unsigned int i=0; i<pieces.size(); i++){
00138     const PseudoJet it = pieces[i];
00139     result += it;
00140   }
00141 
00142   T *cj_struct = new T(pieces);
00143   result.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(cj_struct));
00144 
00145   return result;
00146 }
00147 
00148 
00149 /// build a "CompositeJet" from a single PseudoJet with an extended
00150 /// structure of type T derived from CompositeJetStructure
00151 template<typename T> PseudoJet join(const PseudoJet & j1){
00152   return join<T>(std::vector<PseudoJet>(1,j1));
00153 }
00154 
00155 /// build a "CompositeJet" from two PseudoJet with an extended
00156 /// structure of type T derived from CompositeJetStructure
00157 template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2){
00158   std::vector<PseudoJet> pieces;
00159   pieces.push_back(j1);
00160   pieces.push_back(j2);
00161   return join<T>(pieces);
00162 }
00163 
00164 /// build a "CompositeJet" from 3 PseudoJet with an extended structure
00165 /// of type T derived from CompositeJetStructure
00166 template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
00167                                     const PseudoJet & j3){
00168   std::vector<PseudoJet> pieces;
00169   pieces.push_back(j1);
00170   pieces.push_back(j2);
00171   pieces.push_back(j3);
00172   return join<T>(pieces);
00173 }
00174 
00175 /// build a "CompositeJet" from 4 PseudoJet with an extended structure
00176 /// of type T derived from CompositeJetStructure
00177 template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
00178                                     const PseudoJet & j3, const PseudoJet & j4){
00179   std::vector<PseudoJet> pieces;
00180   pieces.push_back(j1);
00181   pieces.push_back(j2);
00182   pieces.push_back(j3);
00183   pieces.push_back(j4);
00184   return join<T>(pieces);
00185 }
00186 
00187 
00188 // the same as above with an additional argument for a
00189 // user-defined recombiner
00190 //
00191 // The template structure T must be derived from CompositeJetStructure
00192 // and have a constructor accepting as arguments the pieces and a
00193 // pointer to the recombination scheme
00194 // ----------------------------------------------------------------------
00195 
00196 /// build a "CompositeJet" from the vector of its pieces with an
00197 /// extended structure of type T derived from CompositeJetStructure
00198 template<typename T> PseudoJet join(const std::vector<PseudoJet> & pieces, 
00199                                     const JetDefinition::Recombiner & recombiner){
00200   PseudoJet result;
00201   if (pieces.size()>0){
00202     result = pieces[0];
00203     for (unsigned int i=1; i<pieces.size(); i++){
00204       recombiner.plus_equal(result, pieces[i]);
00205     }
00206   }
00207 
00208   T *cj_struct = new T(pieces, &recombiner);
00209   result.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(cj_struct));
00210 
00211   return result;
00212 }
00213 
00214 /// build a "CompositeJet" from a single PseudoJet with an extended
00215 /// structure of type T derived from CompositeJetStructure
00216 template<typename T> PseudoJet join(const PseudoJet & j1, 
00217                                     const JetDefinition::Recombiner & recombiner){
00218   return join<T>(std::vector<PseudoJet>(1,j1), recombiner);
00219 }
00220 
00221 /// build a "CompositeJet" from two PseudoJet with an extended
00222 /// structure of type T derived from CompositeJetStructure
00223 template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
00224                                     const JetDefinition::Recombiner & recombiner){
00225   std::vector<PseudoJet> pieces;
00226   pieces.push_back(j1);
00227   pieces.push_back(j2);
00228   return join<T>(pieces, recombiner);
00229 }
00230 
00231 /// build a "CompositeJet" from 3 PseudoJet with an extended structure
00232 /// of type T derived from CompositeJetStructure
00233 template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
00234                                     const PseudoJet & j3, 
00235                                     const JetDefinition::Recombiner & recombiner){
00236   std::vector<PseudoJet> pieces;
00237   pieces.push_back(j1);
00238   pieces.push_back(j2);
00239   pieces.push_back(j3);
00240   return join<T>(pieces, recombiner);
00241 }
00242 
00243 /// build a "CompositeJet" from 4 PseudoJet with an extended structure
00244 /// of type T derived from CompositeJetStructure
00245 template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
00246                                     const PseudoJet & j3, const PseudoJet & j4, 
00247                                     const JetDefinition::Recombiner & recombiner){
00248   std::vector<PseudoJet> pieces;
00249   pieces.push_back(j1);
00250   pieces.push_back(j2);
00251   pieces.push_back(j3);
00252   pieces.push_back(j4);
00253   return join<T>(pieces, recombiner);
00254 }
00255 
00256 
00257 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
00258 
00259 #endif // __FASTJET_MERGEDJET_STRUCTURE_HH__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends