Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:15

0001 // $Id: ShapeWithComponents.hh 859 2015-09-21 10:11:32Z gsalam $
0002 //
0003 // Copyright (c) 2012-, Matteo Cacciari, Jihun Kim, Gavin P. Salam and Gregory Soyez
0004 //
0005 //----------------------------------------------------------------------
0006 // This file is part of the GenericSubtractor package of FastJet
0007 // Contrib.
0008 //
0009 // It is free software; you can redistribute it and/or modify it under
0010 // the terms of the GNU General Public License as published by the
0011 // Free Software Foundation; either version 2 of the License, or (at
0012 // your option) any later version.
0013 //
0014 // It is distributed in the hope that it will be useful, but WITHOUT
0015 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0016 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
0017 // License for more details.
0018 //
0019 // You should have received a copy of the GNU General Public License
0020 // along with this code. If not, see <http://www.gnu.org/licenses/>.
0021 //----------------------------------------------------------------------
0022 
0023 #ifndef __FASTJET_CONTRIB_SHAPE_WITH_COMPONENTS_HH__
0024 #define __FASTJET_CONTRIB_SHAPE_WITH_COMPONENTS_HH__
0025 
0026 #include "fastjet/FunctionOfPseudoJet.hh"
0027 
0028 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0029 
0030 namespace contrib{
0031 
0032 /// \class ShapeWithComponents
0033 /// base class for jet shapes that provide extra information about
0034 /// about separate components from which they are composed.
0035 /// 
0036 /// Many jet shapes involve ratios or more complicated combinations of
0037 /// different components. E.g. a jet broadening is given by a ratio
0038 ///
0039 ///     B = (\sum_i p_ti DeltaR_{i,jet}) / (\sum_i p_ti)
0040 ///
0041 /// The ShapeWithComponents class provides an interface that allows
0042 /// access not just to the shape but also to the individual
0043 /// components, as well as a mechanism for calculating the components
0044 /// individually and combining them back into the overall shape.  This
0045 /// can be of interest, for example, in pileup subtraction, providing
0046 /// a structure to allow subtraction to be performed automatically on
0047 /// the invidividual components.
0048 ///
0049 class ShapeWithComponents : public FunctionOfPseudoJet<double> {
0050 public:
0051   //------------------------------------------------------------------
0052   //------- first, a reminder of the standard functions for a FoPJ ---
0053 
0054   /// the result of computing the shape from a given PseudoJet
0055   virtual double result(const PseudoJet &jet) const{
0056     return result_from_components(components(jet));
0057   }
0058 
0059   /// the description that has to be defined in derived classes
0060   virtual std::string description() const = 0;
0061 
0062   //------------------------------------------------------------------
0063   //------- below, the functions that provide "hinting" --------------
0064 
0065   /// returns the number of components 
0066   virtual unsigned int n_components() const = 0;
0067 
0068   /// Returns a vector containing the different components which go
0069   /// into the calculation of the shape. The vector will be of size
0070   /// n_components().
0071   virtual std::vector<double> components(const PseudoJet &jet) const = 0;
0072 
0073   /// Return component i of the shape for the given jet. The numbering
0074   /// of components is 0...(n_components()-1).
0075   ///
0076   /// The default implementation of this function evaluates all
0077   /// components and then returns the requested one. Derived classes
0078   /// may wish to proceed differently.
0079   virtual double component(int i, const PseudoJet &jet) const {
0080     assert(i < int(n_components()));
0081     return components(jet)[i];
0082   }
0083 
0084   /// given a vector of components, determine the result of the event
0085   /// shape
0086   virtual double result_from_components(const std::vector <double> &) const = 0;
0087 
0088   /// return a pointer to a new instance of a ComponentShape that
0089   /// calculates component i of this shape. It is the caller's
0090   /// responsibility to delete the pointer when it is no longer
0091   /// needed.
0092   ///
0093   /// Note: the generic implementation included below should be adequate
0094   /// for most uses.
0095   virtual const FunctionOfPseudoJet<double> * component_shape(unsigned index) const;
0096 
0097 
0098   /// a helper class intended to contain a single component of a
0099   /// composite shape.
0100   class ComponentShape : public FunctionOfPseudoJet<double> {
0101   public:
0102     ComponentShape(const ShapeWithComponents * shape, unsigned index) : 
0103       _shape(shape), _index(index) {}
0104 
0105     double result(const PseudoJet & jet) const {
0106       return _shape->component(_index, jet);
0107     }
0108   private:
0109     const ShapeWithComponents * _shape;
0110     const unsigned _index;
0111   };
0112 
0113 
0114 };
0115   
0116 /// generic implementation of component_shape -- note, this
0117 /// implementation will hide properties of component shapes, e.g. if
0118 /// the underlying shape class derives from ShapeWithPartition, the
0119 /// result of component_shape will not; If that's a problem, you
0120 /// should reimplement component_shape.
0121 inline const FunctionOfPseudoJet<double> * ShapeWithComponents::component_shape(unsigned index) const {
0122   return new ComponentShape(this, index);
0123 }
0124 
0125 
0126 } // namespace contrib
0127 
0128 FASTJET_END_NAMESPACE
0129 
0130 
0131 #endif // __FASTJET_CONTRIB_SHAPE_WITH_COMPONENTS_HH__