FastJet 3.0.5
CompositeJetStructure.hh
00001 //STARTHEADER
00002 // $Id: CompositeJetStructure.hh 3071 2013-04-01 12:52:46Z cacciari $
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 #ifndef __FJCORE__
00091 
00092   /// check if it has a well-defined area
00093   virtual bool has_area() const;
00094 
00095   /// return the jet (scalar) area.
00096   virtual double area(const PseudoJet &reference) const;
00097 
00098   /// return the error (uncertainty) associated with the determination
00099   /// of the area of this jet.
00100   ///
00101   /// Be conservative: return the sum of the errors
00102   virtual double area_error(const PseudoJet &reference) const;
00103 
00104   /// return the jet 4-vector area.
00105   virtual PseudoJet area_4vector(const PseudoJet &reference) const;
00106 
00107   /// true if this jet is made exclusively of ghosts.
00108   ///
00109   /// In this case, it will be true if all pieces are pure ghost
00110   virtual bool is_pure_ghost(const PseudoJet &reference) const;
00111 
00112   // allow to modify the area information
00113   // (for use in join())
00114   //------------------------------------------------------------------------------
00115   void set_area_information(PseudoJet *area_4vector_ptr){
00116     _area_4vector_ptr = area_4vector_ptr;
00117   }
00118 
00119 #endif  // __FJCORE__
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