Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:06:42

0001 // $Id: JetFFMoments.hh 3602 2012-09-25 13:03:36Z salam $
0002 //
0003 // Copyright (c) 2012-, Matteo Cacciari, Paloma Quiroga-Arias, Gavin P. Salam and Gregory Soyez
0004 //
0005 //----------------------------------------------------------------------
0006 // This file is part of FastJet contrib.
0007 //
0008 // It is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU General Public License as published by the
0010 // Free Software Foundation; either version 2 of the License, or (at
0011 // your option) any later version.
0012 //
0013 // It is distributed in the hope that it will be useful, but WITHOUT
0014 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0015 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
0016 // License for more details.
0017 //
0018 // You should have received a copy of the GNU General Public License
0019 // along with this code. If not, see <http://www.gnu.org/licenses/>.
0020 //----------------------------------------------------------------------
0021 
0022 #ifndef __FASTJET_CONTRIB_JET_FF_MOMENTS_HH__
0023 #define __FASTJET_CONTRIB_JET_FF_MOMENTS_HH__
0024 
0025 #include "fastjet/PseudoJet.hh"
0026 #include "fastjet/FunctionOfPseudoJet.hh"
0027 #include "fastjet/ClusterSequenceAreaBase.hh"
0028 #include "fastjet/tools/JetMedianBackgroundEstimator.hh"
0029 #include "fastjet/config.h"
0030 
0031 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0032 
0033 namespace contrib{
0034 
0035 /// \class JetFFMoments 
0036 /// class that computes the moments of a jet fragmentation function,
0037 /// optionally including background subtraction as described in
0038 /// arXiv:1209.6086.
0039 ///
0040 /// This class computes the moments of the jet fragmentation function
0041 /// \f[
0042 ///   M_N = \frac{\sum_i p_{t,i}^N}{({\rm norm})^N}
0043 /// \f]
0044 /// where the sum runs over the jet constituents and several options
0045 /// exist for the normalisation:
0046 ///
0047 ///  - by default, 'norm' is the scalar pt sum of the jet constituents.
0048 ///
0049 ///  - calling use_scalar_sum(false) causes the transverse momentum of
0050 ///    the jet to be used, instead of the scalar pt sum.
0051 //
0052 ///  - calling set_return_numerator(true) causes the numerator only to be
0053 ///    returned i.e. norm=1.
0054 ///
0055 ///  - calling set_denominator(norm) with 'norm' positive, causes that
0056 ///    value to be used as the normalisation. This is particularly
0057 ///    useful e.g. in photon+jet events where the transverse momentum of the
0058 ///    photon is used to normalise the moments.
0059 ///
0060 /// The values of 'N' at which one wants the computation to be performed
0061 /// are passed as a constructor argument, and the result of this class
0062 /// will be a vector containing the jet fragmentation moments computed
0063 /// at these values of N.
0064 ///
0065 /// When an optional JetMedianBackgroundEstimator is passed to the
0066 /// constructor, the returned moments are subtracted according to the
0067 /// method described in arXiv:1209.6086. The subtraction can include an "improvement" 
0068 /// corrects for the effect of fluctuations when the jet spectrum
0069 /// is some steeply function (.
0070 ///
0071 /// Additional remarks:
0072 ///
0073 ///  - jets are required to have constituents. If subtraction is to be
0074 ///    performed, jets are also required to have area.
0075 ///
0076 ///  - FastJet version compatibility: this class is meant to be
0077 ///    compatible with FastJet 3.0 and higher. However it uses features 
0078 ///    that are still preliminary in FastJet 3.0.
0079 ///     . For usage with FastJet 3.0, please make sure that both the
0080 ///       jets and the background estimator have (or do not have)
0081 ///       explicit ghosts if you want to compute multiplicities (M_0).
0082 ///     . The interface may evolve in future versions of FastJet.
0083 ///
0084 class JetFFMoments : public FunctionOfPseudoJet<std::vector<double> >{
0085 public:
0086   /// constructor from a vector of N values
0087   ///  \param ns   the vector of N values
0088   ///  \param bge  an optional background estimator
0089   JetFFMoments(const std::vector<double> & ns, 
0090                JetMedianBackgroundEstimator *bge=0);
0091 
0092   /// constructor using regularly-spaced values of N
0093   ///  \param nmin the minimum N value 
0094   ///  \param nmax the maximum N value (must be larger than nmin)
0095   ///  \param nn   the number of N values (at least 1, nmin used if nn==1)
0096   ///  \param bge  an optional background estimator
0097   JetFFMoments(double nmin, double nmax, unsigned int nn, 
0098                JetMedianBackgroundEstimator *bge=0);
0099 
0100   /// default destructor (virtual to allow safe polymorphism)
0101   virtual ~JetFFMoments(){}
0102 
0103   // configuration handles
0104   //--------------------------------------------------
0105 
0106   /// when 'return_numerator' is set to true, just compute (and
0107   /// return) the numerator of the moments
0108   inline void set_return_numerator(bool return_numerator){
0109     _return_numerator=return_numerator;
0110   }
0111 
0112   /// Set a fixed value ('norm') for the denominator instead of
0113   /// calculating it from the jet.
0114   ///
0115   /// When 'norm' is specified (and positive) and subtraction is
0116   /// requested, no subtraction is applied to the denominator.
0117   ///
0118   /// A negative value for 'norm' means that the denominator is
0119   /// calculated internally from the jet, typically as its (scalar)
0120   /// transverse momentum. This is the default behaviour.
0121   inline void set_denominator(double norm){ _norm = norm;}
0122 
0123   /// Use a scalar sum of the pt of the jet consituents to calculate
0124   /// the denominator (when appropriate). This is the default.
0125   /// The alternative is to use the transverse component of the full 
0126   /// jet momentum. 
0127   inline void use_scalar_sum(bool use_scalar_sum = true){
0128     _use_scalar_sum = use_scalar_sum;
0129   }
0130 
0131 #if (FASTJET_VERSION_NUMBER >= 30100)
0132   /// Turn on "improved" subtraction and provide the information that
0133   /// it requires.
0134   ///
0135   /// - mu is the \mu of d\sigma/dpt parametrised as sigma_0
0136   ///   exp(-pt/mu) in the neighbourhood of the pt of the jet (see
0137   ///   Section 5 of arXiv:1209.6086).
0138   ///
0139   /// If mu is negative, improved subtraction is turned off (the default).
0140   ///
0141   /// NB: with versions of FJ prior to FJ3.1, the improved subtraction
0142   /// also needs explicit information about the jets used for
0143   /// background estimation; this can be supplied with the alternative
0144   /// set_improved_subtraction(...) given below.
0145   inline void set_improved_subtraction(double mu){
0146     _mu = mu;
0147     _jets_for_improved_sub.clear();
0148   }
0149 #endif
0150 
0151   
0152   /// Turn on "improved" subtraction and provide the information that
0153   /// it requires.
0154   ///
0155   /// - mu is the \mu of d\sigma/dpt parametrised as sigma_0
0156   ///   exp(-pt/mu) in the neighbourhood of the pt of the jet (see
0157   ///   Section 5 of arXiv:1209.6086).
0158   ///
0159   /// If mu is negative, improved subtraction is turned off (the default).
0160   ///
0161   /// The other inputs are needed so that the class can establish
0162   /// which jets were used in estimating the background subtraction,
0163   /// so that they can be used to determine the correlation between
0164   /// numerator and denominator of the FF moment.
0165   ///
0166   /// From FJ v 3.1 upwards, the information about the jets used for
0167   /// background estimation is available automatically from the bge
0168   /// provided in the constructor, and so this version of
0169   /// set_improved_subtraction is usually redundant.
0170   void set_improved_subtraction(double mu,
0171                 const Selector &rho_range,
0172                 const ClusterSequenceAreaBase &csa);
0173 
0174 
0175   /// Turn on "improved" subtraction and provide the information that
0176   /// it requires.
0177   ///
0178   /// - mu is the \mu of d\sigma/dpt parametrised as sigma_0
0179   ///   exp(-pt/mu) in the neighbourhood of the pt of the jet (see
0180   ///   Section 5 of arXiv:1209.6086).
0181   ///
0182   /// If mu is negative, improved subtraction is turned off (the default).
0183   ///
0184   /// The other parameters are needed so that the class can establish
0185   /// which jets were used in estimating the background subtraction,
0186   /// so that they can be used to determine the correlation between
0187   /// numerator and denominator of the FF moment.
0188   ///
0189   /// If correcting FF's for multiple jets in the same event, the
0190   /// version that takes a rho_range and csa will be more efficient.
0191   ///
0192   /// From FJ v 3.1 upwards, the information about the jets used for
0193   /// background estimation is available automatically from the bge
0194   /// provided in the constructor, and so this version of
0195   /// set_improved_subtraction is usually redundant.
0196   void set_improved_subtraction(double mu,
0197                 const Selector & rho_range,
0198                 const std::vector<PseudoJet> & particles,
0199                 const JetDefinition  & rho_jet_def,
0200                 const AreaDefinition & rho_area_def);
0201 
0202   // basic methods from FunctionOfPseudoJet (+ variants)
0203   //--------------------------------------------------
0204 
0205   /// description of the class
0206   virtual std::string description() const;
0207 
0208   // pre-declaration of subclass Info
0209   class Info;
0210 
0211   /// the computation for a given jet
0212   ///
0213   /// Requirement: the jet 'jet' needs to have constituents. If
0214   /// subtraction is requested (bge!=0) it also needs to have an area
0215   virtual std::vector<double> result(const PseudoJet &jet) const {
0216     Info dummy_info;
0217     return (*this)(jet, dummy_info);
0218   }
0219 
0220   virtual std::vector<double> operator()(const PseudoJet &jet, Info & info) const;
0221 
0222   // because we've introduced a new operator() with an "info" argument, we
0223   // also need to redefine the other operator() members
0224   virtual std::vector<double> operator()(const PseudoJet &jet) const {return result(jet);}
0225   virtual std::vector<std::vector<double> > operator()(const std::vector<PseudoJet> & jets) const {
0226     return FunctionOfPseudoJet<std::vector<double> >::operator()(jets);
0227   }
0228 
0229   // access to extra information
0230   //--------------------------------------------------
0231   /// return the moment N value for the i^{th} moment
0232   inline double N(unsigned int i) const{
0233     if (i>=_Ns.size())
0234       throw Error("JetFFMoments: out-of-range value of n requested");
0235     return _Ns[i];
0236   }
0237 
0238   /// return the vector of the values of N
0239   inline std::vector<double> Ns() const{ return _Ns;}
0240 
0241   // internal class to store bits of info that might be of "diagnostic"
0242   // interest
0243   class Info {
0244   public:
0245     const std::vector<double> & rhoNs()        const {return _rhoNs;}
0246     const std::vector<double> & sigmaNs()      const {return _sigmaNs;}
0247     const std::vector<double> & rNs()          const {return _rNs;}
0248     const std::vector<double> & ptshift_term() const {return _ptshift_term;};
0249     const std::vector<double> & correl_term()  const {return _correl_term ;};
0250     
0251     double rho()   const {return _rho;}
0252     double sigma() const {return _sigma;}
0253 
0254     void resize(unsigned int n) {
0255       _rhoNs.resize(n);
0256       _sigmaNs.resize(n);
0257       _rNs.resize(n, 0.0);
0258       _ptshift_term.resize(n, 0.0);
0259       _correl_term.resize(n, 0.0);
0260     }
0261 
0262   protected:
0263     std::vector<double> _rhoNs;
0264     std::vector<double> _sigmaNs;
0265     std::vector<double> _rNs;
0266     std::vector<double> _ptshift_term;
0267     std::vector<double> _correl_term;
0268     double _rho, _sigma;
0269 
0270     friend class JetFFMoments;
0271   };
0272 
0273 private:
0274   std::vector<double> _Ns;
0275   JetMedianBackgroundEstimator *_bge;
0276   bool _return_numerator; ///< just compute the numerator
0277   double _norm;         ///< use a user-provided (unsubtracted) denominator
0278   bool _use_scalar_sum;   ///< use scalar pt sum for the denominator
0279 
0280   double _mu;             ///< use this value of mu for the improved_sub correction
0281   std::vector<PseudoJet> _jets_for_improved_sub;
0282   mutable Selector _rho_range_for_improved_sub; // mutable as it can take a reference
0283 
0284   static LimitedWarning _warnings_negative_pt;
0285 
0286   /// initialisation of the internal behaviour
0287   void _initialise();
0288 
0289   /// This function returns the transverse momentum to be used in the denominator
0290   /// of the definition of the moments of a fragmentation function for a jet, e.g.
0291   /// in eq.(3) of arXiv:1209.6086
0292   /// This can be 
0293   ///   1. the (subtracted) jet pt
0294   ///   2. the (subtracted) scalar sum of the pt of the constituents of the jet [this is the default]
0295   ///   3. just the number 1, in case one is interested only in the numerator.
0296   double _compute_normalisation(const PseudoJet &jet, 
0297                                 const std::vector<PseudoJet> &constituents,
0298                                 double &rho, double &sigma) const;
0299 };
0300 
0301 } // contrib namespace
0302 
0303 FASTJET_END_NAMESPACE
0304 
0305 #endif // __FASTJET_CONTRIB_JET_FF_MOMENTS_HH__