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