Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //FJSTARTHEADER
0002 // $Id$
0003 //
0004 // Copyright (c) 2005-2021, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
0005 //
0006 //----------------------------------------------------------------------
0007 // This file is part of FastJet.
0008 //
0009 //  FastJet is free software; you can redistribute it and/or modify
0010 //  it under the terms of the GNU General Public License as published by
0011 //  the Free Software Foundation; either version 2 of the License, or
0012 //  (at your option) any later version.
0013 //
0014 //  The algorithms that underlie FastJet have required considerable
0015 //  development. They are described in the original FastJet paper,
0016 //  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
0017 //  FastJet as part of work towards a scientific publication, please
0018 //  quote the version you use and include a citation to the manual and
0019 //  optionally also to hep-ph/0512210.
0020 //
0021 //  FastJet is distributed in the hope that it will be useful,
0022 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
0023 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0024 //  GNU General Public License for more details.
0025 //
0026 //  You should have received a copy of the GNU General Public License
0027 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
0028 //----------------------------------------------------------------------
0029 //FJENDHEADER
0030 
0031 #ifndef __FASTJET_CLUSTERSEQUENCEAREABASE_HH__
0032 #define __FASTJET_CLUSTERSEQUENCEAREABASE_HH__
0033 
0034 #include "fastjet/ClusterSequence.hh"
0035 #include "fastjet/LimitedWarning.hh"
0036 #include "fastjet/Selector.hh"
0037 #include "fastjet/internal/deprecated.hh"
0038 
0039 FASTJET_BEGIN_NAMESPACE
0040 
0041 /// @ingroup area_classes
0042 /// \class ClusterSequenceAreaBase
0043 /// base class that sets interface for extensions of ClusterSequence
0044 /// that provide information about the area of each jet
0045 ///
0046 /// the virtual functions here all return 0, since no area determination
0047 /// is implemented.
0048 class ClusterSequenceAreaBase : public ClusterSequence {
0049 public:
0050   
0051   /// a constructor which just carries out the construction of the
0052   /// parent class
0053   template<class L> ClusterSequenceAreaBase
0054          (const std::vector<L> & pseudojets, 
0055       const JetDefinition & jet_def_in,
0056       const bool & writeout_combinations = false) :
0057            ClusterSequence(pseudojets, jet_def_in, writeout_combinations) {}
0058 
0059 
0060   /// default constructor
0061   ClusterSequenceAreaBase() {}
0062 
0063 
0064   /// destructor
0065   virtual ~ClusterSequenceAreaBase() {}
0066 
0067 
0068   /// return the area associated with the given jet; this base class
0069   /// returns 0.
0070   virtual double area       (const PseudoJet & ) const {return 0.0;}
0071 
0072   /// return the error (uncertainty) associated with the determination
0073   /// of the area of this jet; this base class returns 0.
0074   virtual double area_error (const PseudoJet & ) const {return 0.0;}
0075 
0076   /// return a PseudoJet whose 4-vector is defined by the following integral
0077   ///
0078   ///       \int drap d\phi PseudoJet("rap,phi,pt=one") *
0079   ///                           * Theta("rap,phi inside jet boundary")
0080   ///
0081   /// where PseudoJet("rap,phi,pt=one") is a 4-vector with the given
0082   /// rapidity (rap), azimuth (phi) and pt=1, while Theta("rap,phi
0083   /// inside jet boundary") is a function that is 1 when rap,phi
0084   /// define a direction inside the jet boundary and 0 otherwise.
0085   ///
0086   /// This base class returns a null 4-vector.
0087   virtual PseudoJet area_4vector(const PseudoJet & ) const {
0088     return PseudoJet(0.0,0.0,0.0,0.0);}
0089 
0090   /// true if a jet is made exclusively of ghosts
0091   ///
0092   /// NB: most area classes do not give any explicit ghost jets, but
0093   /// some do, and they should replace this function with their own
0094   /// version.
0095   virtual bool is_pure_ghost(const PseudoJet & ) const {
0096     return false;
0097   }
0098 
0099   /// returns true if ghosts are explicitly included within 
0100   /// jets for this ClusterSequence; 
0101   ///
0102   /// Derived classes that do include explicit ghosts should provide
0103   /// an alternative version of this routine and set it properly.
0104   virtual bool has_explicit_ghosts() const {
0105     return false;
0106   }
0107 
0108   /// return the total area, corresponding to the given Selector, that
0109   /// is free of jets, in general based on the inclusive jets.
0110   /// 
0111   /// The selector passed as an argument has to have a finite area and
0112   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0113   /// tools for more generic usages)
0114   virtual double empty_area(const Selector & selector) const;
0115 
0116   /// return the total area, corresponding to the given Selector, that
0117   /// is free of jets, based on the supplied all_jets
0118   /// 
0119   /// The selector passed as an argument has to have a finite area and
0120   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0121   /// tools for more generic usages)
0122   double empty_area_from_jets(const std::vector<PseudoJet> & all_jets,
0123                   const Selector & selector) const;
0124 
0125   /// return something similar to the number of pure ghost jets
0126   /// in the given selector's range in an active area case.
0127   /// For the local implementation we return empty_area/(0.55 pi R^2),
0128   /// based on measured properties of ghost jets with kt and cam
0129   /// (cf arXiv:0802.1188).
0130   ///
0131   /// Note that the number returned is a double.
0132   /// 
0133   /// The selector passed as an argument has to have a finite area and
0134   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0135   /// tools for more generic usages)
0136   virtual double n_empty_jets(const Selector & selector) const {
0137     double R = jet_def().R();
0138     return empty_area(selector)/(0.55*pi*R*R);
0139   }
0140 
0141   /// the median of (pt/area) for jets contained within the selector
0142   /// range, making use also of the info on n_empty_jets
0143   /// 
0144   /// The selector passed as an argument has to have a finite area and
0145   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0146   /// tools for more generic usages)
0147   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::median_pt_per_unit_area(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead",
0148   double median_pt_per_unit_area(const Selector & selector) const);
0149 
0150   /// the median of (pt/area_4vector) for jets contained within the
0151   /// selector range, making use also of the info on n_empty_jets
0152   /// 
0153   /// The selector passed as an argument has to have a finite area and
0154   /// apply jet-by-jet
0155   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::median_pt_per_unit_area_4vector(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead",
0156   double median_pt_per_unit_area_4vector(const Selector & selector) const);
0157   
0158   /// the function that does the work for median_pt_per_unit_area and 
0159   /// median_pt_per_unit_area_4vector: 
0160   /// - something_is_area_4vect = false -> use plain area
0161   /// - something_is_area_4vect = true  -> use 4-vector area
0162   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::median_pt_per_unit_something(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead",
0163   double median_pt_per_unit_something(const Selector & selector,
0164                                       bool use_area_4vector) const);
0165 
0166   /// using jets withing the selector range (and with 4-vector areas if
0167   /// use_area_4vector), calculate the median pt/area, as well as an
0168   /// "error" (uncertainty), which is defined as the 1-sigma
0169   /// half-width of the distribution of pt/A, obtained by looking for
0170   /// the point below which we have (1-0.6827)/2 of the jets
0171   /// (including empty jets).
0172   ///
0173   /// The subtraction for a jet with uncorrected pt pt^U and area A is
0174   ///
0175   ///   pt^S = pt^U - median*A +- sigma*sqrt(A)
0176   ///
0177   /// where the error is only that associated with the fluctuations
0178   /// in the noise and not that associated with the noise having 
0179   /// caused changes in the hard-particle content of the jet.
0180   /// 
0181   /// The selector passed as an argument has to have a finite area and
0182   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0183   /// tools for more generic usages)
0184   ///
0185   /// NB: subtraction may also be done with 4-vector area of course,
0186   /// and this is recommended for jets with larger values of R, as
0187   /// long as rho has also been determined with a 4-vector area;
0188   /// using a scalar area causes one to neglect terms of relative
0189   /// order $R^2/8$ in the jet $p_t$.
0190   //FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::get_median_rho_and_sigma(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead")
0191   virtual void get_median_rho_and_sigma(const Selector & selector, 
0192                                         bool use_area_4vector,
0193                                         double & median, double & sigma,
0194                                         double & mean_area) const;
0195 
0196   /// a more advanced version of get_median_rho_and_sigma, which allows
0197   /// one to use any "view" of the event containing all jets (so that, 
0198   /// e.g. one might use Cam on a different resolution scale without
0199   /// have to rerun the algorithm).
0200   ///
0201   /// By default it will assume that "all" are not inclusive jets, 
0202   /// so that in dealing with empty area it has to calculate
0203   /// the number of empty jets based on the empty area and the
0204   /// the observed <area> of jets rather than a surmised area
0205   ///
0206   /// Note that for small effective radii, this can cause problems
0207   /// because the harder jets get an area >> <ghost-jet-area>
0208   /// and so the estimate comes out all wrong. In these situations
0209   /// it is highly advisable to use an area with explicit ghosts, since
0210   /// then the "empty" jets are actually visible.
0211   /// 
0212   /// The selector passed as an argument has to have a finite area and
0213   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0214   /// tools for more generic usages)
0215   //FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::get_median_rho_and_sigma(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead")
0216   virtual void get_median_rho_and_sigma(const std::vector<PseudoJet> & all_jets,
0217                     const Selector & selector, 
0218                                         bool use_area_4vector,
0219                                         double & median, double & sigma,
0220                                         double & mean_area,
0221                     bool all_are_inclusive = false) const;
0222 
0223   /// same as the full version of get_median_rho_and_error, but without
0224   /// access to the mean_area
0225   /// 
0226   /// The selector passed as an argument has to have a finite area and
0227   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0228   /// tools for more generic usages)
0229   //FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::get_median_rho_and_sigma(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead")
0230   virtual void get_median_rho_and_sigma(const Selector & selector, 
0231                                         bool use_area_4vector,
0232                                         double & median, double & sigma) const{
0233     return _get_median_rho_and_sigma(selector, use_area_4vector, median, sigma);
0234   }
0235   
0236 
0237   /// fits a form pt_per_unit_area(y) = a + b*y^2 in the selector range. 
0238   /// exclude_above allows one to exclude large values of pt/area from fit. 
0239   ///               (if negative, the cut is discarded)
0240   /// use_area_4vector = true uses the 4vector areas.
0241   /// 
0242   /// The selector passed as an argument has to have a finite area and
0243   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0244   /// tools for more generic usages)
0245   //FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::parabolic_pt_per_unit_area(...) is deprecated since FastJet 3.0. Use the BackgroundEstimator series of tools instead")
0246   virtual void parabolic_pt_per_unit_area(double & a, double & b, 
0247                                           const Selector & selector, 
0248                                           double exclude_above=-1.0, 
0249                                           bool use_area_4vector=false) const;
0250 
0251   /// return a vector of all subtracted jets, using area_4vector, given rho.
0252   /// Only inclusive_jets above ptmin are subtracted and returned.
0253   /// the ordering is the same as that of sorted_by_pt(cs.inclusive_jets()),
0254   /// i.e. not necessarily ordered in pt once subtracted
0255   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::subtracted_jets(...) is deprecated since FastJet 3.0. Use the Subtractor tool (with the BackgroundEstimator series of tools) instead",
0256   std::vector<PseudoJet> subtracted_jets(const double rho,
0257                                          const double ptmin=0.0) const);
0258 
0259   /// return a vector of subtracted jets, using area_4vector.
0260   /// Only inclusive_jets above ptmin are subtracted and returned.
0261   /// the ordering is the same as that of sorted_by_pt(cs.inclusive_jets()),
0262   /// i.e. not necessarily ordered in pt once subtracted
0263   /// 
0264   /// The selector passed as an argument has to have a finite area and
0265   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0266   /// tools for more generic usages)
0267   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::subtracted_jets(...) is deprecated since FastJet 3.0. Use the Subtractor tool (with the BackgroundEstimator series of tools) instead",
0268   std::vector<PseudoJet> subtracted_jets(const Selector & selector, 
0269                                          const double ptmin=0.0) const);
0270 
0271   /// return a subtracted jet, using area_4vector, given rho
0272   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::subtracted_jet(...) is deprecated since FastJet 3.0. Use the Subtractor tool (with the BackgroundEstimator series of tools) instead",
0273   PseudoJet subtracted_jet(const PseudoJet & jet,
0274                            const double rho) const);
0275 
0276   /// return a subtracted jet, using area_4vector; note
0277   /// that this is potentially inefficient if repeatedly used for many
0278   /// different jets, because rho will be recalculated each time
0279   /// around.
0280   /// 
0281   /// The selector passed as an argument has to have a finite area and
0282   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0283   /// tools for more generic usages)
0284   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::subtracted_jet(...) is deprecated since FastJet 3.0. Use the Subtractor tool (with the BackgroundEstimator series of tools) instead",
0285   PseudoJet subtracted_jet(const PseudoJet & jet,
0286                            const Selector & selector) const);
0287 
0288   /// return the subtracted pt, given rho
0289   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::subtracted_pt(...) is deprecated since FastJet 3.0. Use the Subtractor tool (with the BackgroundEstimator series of tools) instead",
0290   double subtracted_pt(const PseudoJet & jet,
0291                        const double rho,
0292                    bool use_area_4vector=false) const);
0293 
0294   /// return the subtracted pt; note that this is
0295   /// potentially inefficient if repeatedly used for many different
0296   /// jets, because rho will be recalculated each time around.
0297   /// 
0298   /// The selector passed as an argument has to have a finite area and
0299   /// apply jet-by-jet (see the BackgroundEstimator and Subtractor
0300   /// tools for more generic usages)
0301   FASTJET_DEPRECATED_MSG("ClusterSequenceAreaBase::subtracted_pt(...) is deprecated since FastJet 3.0. Use the Subtractor tool (with the BackgroundEstimator series of tools) instead",
0302   double subtracted_pt(const PseudoJet & jet,
0303                        const Selector & selector,
0304                    bool use_area_4vector=false) const);
0305 
0306 protected:
0307   /// check the selector is suited for the computations i.e. applies jet by jet and has a finite area
0308   void _check_selector_good_for_median(const Selector &selector) const;
0309 
0310   // the following set of protected methods are all deprecated. Their
0311   // role is simply to hide the corresponding methods (without the
0312   // first underscore) from the public interface so that they can be
0313   // used internally until all the deprecated methods are removed.
0314   // DO NOT USE ANY OF THESE METHODS: THEY ARE DEPRECATED AND WILL BE
0315   // REMOVED.
0316   virtual void _get_median_rho_and_sigma(const Selector & selector, 
0317                                          bool use_area_4vector,
0318                                          double & median, double & sigma,
0319                                          double & mean_area) const;
0320   virtual void _get_median_rho_and_sigma(const std::vector<PseudoJet> & all_jets,
0321                                          const Selector & selector, 
0322                                          bool use_area_4vector,
0323                                          double & median, double & sigma,
0324                                          double & mean_area,
0325                                          bool all_are_inclusive = false) const;
0326   virtual void _get_median_rho_and_sigma(const Selector & selector, 
0327                                          bool use_area_4vector,
0328                                          double & median, double & sigma) const {
0329     double mean_area;
0330     _get_median_rho_and_sigma(selector,  use_area_4vector,
0331                               median,  sigma, mean_area);
0332   }
0333   virtual void _parabolic_pt_per_unit_area(double & a, double & b, 
0334                                            const Selector & selector, 
0335                                            double exclude_above=-1.0, 
0336                                            bool use_area_4vector=false) const;
0337 
0338 private:
0339   /// handle warning messages
0340   static LimitedWarning _warnings;
0341   static LimitedWarning _warnings_zero_area;
0342   static LimitedWarning _warnings_empty_area;
0343 
0344   /// check the jet algorithm is suitable (and if not issue a warning)
0345   void _check_jet_alg_good_for_median() const;
0346 
0347   // the following set of private methods are all deprecated. Their
0348   // role is simply to hide the corresponding methods (without the
0349   // first underscore) from the public interface so that they can be
0350   // used internally until all the deprecated methods are removed.
0351   // DO NOT USE ANY OF THESE METHODS: THEY ARE DEPRECATED AND WILL BE
0352   // REMOVED.
0353   double _median_pt_per_unit_area(const Selector & selector) const;
0354   double _median_pt_per_unit_area_4vector(const Selector & selector) const;
0355   double _median_pt_per_unit_something(const Selector & selector,
0356                                        bool use_area_4vector) const;
0357   std::vector<PseudoJet> _subtracted_jets(const double rho,
0358                                           const double ptmin=0.0) const;
0359   PseudoJet _subtracted_jet(const PseudoJet & jet,
0360                             const double rho) const;
0361   PseudoJet _subtracted_jet(const PseudoJet & jet,
0362                             const Selector & selector) const;
0363   double _subtracted_pt(const PseudoJet & jet,
0364                         const double rho,
0365                         bool use_area_4vector=false) const;
0366 };
0367 
0368 
0369 
0370 FASTJET_END_NAMESPACE
0371 
0372 #endif // __FASTJET_CLUSTERSEQUENCEAREABASE_HH__