FastJet 3.0.4
ClusterSequenceArea.hh
00001 //STARTHEADER
00002 // $Id: ClusterSequenceArea.hh 2690 2011-11-14 14:57:54Z soyez $
00003 //
00004 // Copyright (c) 2006-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 #ifndef __FASTJET_CLUSTERSEQUENCEAREA_HH__
00030 #define __FASTJET_CLUSTERSEQUENCEAREA_HH__
00031 
00032 #include "fastjet/ClusterSequenceAreaBase.hh"
00033 #include "fastjet/ClusterSequenceActiveArea.hh"
00034 #include "fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh"
00035 #include "fastjet/ClusterSequencePassiveArea.hh"
00036 #include "fastjet/ClusterSequenceVoronoiArea.hh"
00037 #include "fastjet/AreaDefinition.hh"
00038 
00039 FASTJET_BEGIN_NAMESPACE
00040 
00041 /// @ingroup area_classes
00042 /// \class ClusterSequenceArea
00043 /// General class for user to obtain ClusterSequence with additional
00044 /// area information.
00045 ///
00046 /// Based on the area_def, it automatically dispatches the work to the
00047 /// appropriate actual ClusterSequenceAreaBase-derived-class to do the
00048 /// real work.
00049 class ClusterSequenceArea : public ClusterSequenceAreaBase {
00050 public:
00051   /// main constructor
00052   template<class L> ClusterSequenceArea
00053          (const std::vector<L> & pseudojets, 
00054           const JetDefinition & jet_def_in,
00055           const AreaDefinition & area_def_in)  : _area_def(area_def_in) {
00056     initialize_and_run_cswa(pseudojets, jet_def_in);
00057   }
00058 
00059   /// constructor with a GhostedAreaSpec
00060   template<class L> ClusterSequenceArea
00061          (const std::vector<L> & pseudojets, 
00062           const JetDefinition & jet_def_in,
00063           const GhostedAreaSpec & ghost_spec)   : _area_def(ghost_spec){
00064     initialize_and_run_cswa(pseudojets, jet_def_in);
00065   }
00066 
00067   /// constructor with a VoronoiAreaSpec
00068   template<class L> ClusterSequenceArea
00069          (const std::vector<L> & pseudojets, 
00070           const JetDefinition & jet_def_in,
00071           const VoronoiAreaSpec & voronoi_spec)   : _area_def(voronoi_spec){
00072     initialize_and_run_cswa(pseudojets, jet_def_in);
00073   }
00074 
00075   /// return a reference to the area definition
00076   const AreaDefinition & area_def() const {return _area_def;}
00077 
00078 
00079   /// return the area associated with the given jet
00080   virtual double area       (const PseudoJet & jet) const {
00081     return _area_base->area(jet);}
00082 
00083   /// return the error (uncertainty) associated with the determination
00084   /// of the area of this jet
00085   virtual double area_error (const PseudoJet & jet) const {
00086     return _area_base->area_error(jet);}
00087 
00088   /// return the 4-vector area
00089   virtual PseudoJet area_4vector(const PseudoJet & jet) const {
00090     return _area_base->area_4vector(jet);}
00091 
00092   // /// return the total area, up to |y|<maxrap, that is free of jets
00093   // virtual double empty_area(double maxrap) const {
00094   //   return _area_base->empty_area(maxrap);}
00095   // 
00096   // /// return something similar to the number of pure ghost jets
00097   // /// in the given rapidity range in an active area case.
00098   // /// For the local implementation we return empty_area/(0.55 pi R^2),
00099   // /// based on measured properties of ghost jets with kt and cam. Note
00100   // /// that the number returned is a double.
00101   // virtual double n_empty_jets(double maxrap) const {
00102   //   return _area_base->n_empty_jets(maxrap);
00103 
00104   /// return the total area, corresponding to the given selector, that
00105   /// is free of jets
00106   ///
00107   /// The selector needs to have a finite area and be applicable jet by
00108   /// jet (see the BackgroundEstimator and Subtractor tools for more
00109   /// advanced usage)
00110   virtual double empty_area(const Selector & selector) const {
00111     return _area_base->empty_area(selector);}
00112 
00113   /// return something similar to the number of pure ghost jets
00114   /// in the given rap-phi range in an active area case.
00115   /// For the local implementation we return empty_area/(0.55 pi R^2),
00116   /// based on measured properties of ghost jets with kt and cam. Note
00117   /// that the number returned is a double.
00118   ///
00119   /// The selector needs to have a finite area and be applicable jet by
00120   /// jet (see the BackgroundEstimator and Subtractor tools for more
00121   /// advanced usage)
00122   virtual double n_empty_jets(const Selector & selector) const {
00123     return _area_base->n_empty_jets(selector);
00124   }
00125 
00126   /// true if a jet is made exclusively of ghosts
00127   virtual bool is_pure_ghost(const PseudoJet & jet) const {
00128     return _area_base->is_pure_ghost(jet);
00129   }
00130 
00131   /// true if this ClusterSequence has explicit ghosts
00132   virtual bool has_explicit_ghosts() const {
00133     return _area_base->has_explicit_ghosts();
00134   }
00135   
00136 
00137   /// overload version of what's in the ClusterSequenceAreaBase class, which 
00138   /// additionally checks compatibility between "selector" and region in which
00139   /// ghosts are thrown.
00140   ///
00141   /// The selector needs to have a finite area and be applicable jet by
00142   /// jet (see the BackgroundEstimator and Subtractor tools for more
00143   /// advanced usage)
00144   virtual void get_median_rho_and_sigma(const std::vector<PseudoJet> & all_jets,
00145                                         const Selector & selector, 
00146                                         bool use_area_4vector,
00147                                         double & median, double & sigma,
00148                                         double & mean_area,
00149                                         bool all_are_incl = false) const {
00150     _warn_if_range_unsuitable(selector);
00151     ClusterSequenceAreaBase::get_median_rho_and_sigma(
00152                                  all_jets, selector, use_area_4vector,
00153                                  median, sigma, mean_area, all_are_incl);
00154   }
00155 
00156   /// overload version of what's in the ClusterSequenceAreaBase class,
00157   /// which actually just does the same thing as the base version (but
00158   /// since we've overridden the 5-argument version above, we have to
00159   /// override the 4-argument version too.
00160   virtual void get_median_rho_and_sigma(const Selector & selector, 
00161                                         bool use_area_4vector,
00162                                         double & median, double & sigma) const {
00163     ClusterSequenceAreaBase::get_median_rho_and_sigma(selector,use_area_4vector,
00164                                                       median,sigma);
00165   }
00166 
00167   /// overload version of what's in the ClusterSequenceAreaBase class,
00168   /// which actually just does the same thing as the base version (but
00169   /// since we've overridden the multi-argument version above, we have to
00170   /// override the 5-argument version too.
00171   virtual void get_median_rho_and_sigma(const Selector & selector, 
00172                                         bool use_area_4vector,
00173                                         double & median, double & sigma,
00174                                         double & mean_area) const {
00175     ClusterSequenceAreaBase::get_median_rho_and_sigma(selector,use_area_4vector,
00176                                                       median,sigma, mean_area);
00177   }
00178 
00179 
00180   /// overload version of what's in the ClusterSequenceAreaBase class, which 
00181   /// additionally checks compatibility between "range" and region in which
00182   /// ghosts are thrown.
00183   virtual void parabolic_pt_per_unit_area(double & a, double & b, 
00184                                           const Selector & selector, 
00185                                           double exclude_above=-1.0, 
00186                                           bool use_area_4vector=false) const {
00187     _warn_if_range_unsuitable(selector);
00188     ClusterSequenceAreaBase::parabolic_pt_per_unit_area(
00189                                 a,b,selector, exclude_above, use_area_4vector);
00190   }
00191 
00192 
00193 private:
00194   
00195   /// print a warning if the range is unsuitable for the current
00196   /// calculation of the area (e.g. because ghosts do not extend
00197   /// far enough).
00198   void _warn_if_range_unsuitable(const Selector & selector) const;
00199 
00200   template<class L> void initialize_and_run_cswa (
00201                                  const std::vector<L> & pseudojets, 
00202                                  const JetDefinition & jet_def);
00203 
00204   std::auto_ptr<ClusterSequenceAreaBase> _area_base;
00205   AreaDefinition _area_def;
00206   static LimitedWarning _range_warnings;
00207   static LimitedWarning _explicit_ghosts_repeats_warnings;
00208 
00209 };
00210 
00211 //----------------------------------------------------------------------
00212 template<class L> void ClusterSequenceArea::initialize_and_run_cswa(
00213            const std::vector<L> & pseudojets, 
00214            const JetDefinition  & jet_def_in)
00215  {
00216   
00217   ClusterSequenceAreaBase * _area_base_ptr;
00218   switch(_area_def.area_type()) {
00219   case active_area:
00220     _area_base_ptr = new ClusterSequenceActiveArea(pseudojets, 
00221                                                    jet_def_in, 
00222                                                    _area_def.ghost_spec());
00223     break;
00224   case active_area_explicit_ghosts:
00225     if (_area_def.ghost_spec().repeat() != 1) 
00226       _explicit_ghosts_repeats_warnings.warn("Requested active area with explicit ghosts with repeat != 1; only 1 set of ghosts will be used");
00227     _area_base_ptr = new ClusterSequenceActiveAreaExplicitGhosts(pseudojets, 
00228                                                    jet_def_in, 
00229                                                    _area_def.ghost_spec());
00230     break;
00231   case voronoi_area:
00232     _area_base_ptr = new ClusterSequenceVoronoiArea(pseudojets, 
00233                                                    jet_def_in, 
00234                                                    _area_def.voronoi_spec());
00235     break;
00236   case one_ghost_passive_area:
00237     _area_base_ptr = new ClusterSequence1GhostPassiveArea(pseudojets, 
00238                                                     jet_def_in, 
00239                                                     _area_def.ghost_spec());
00240     break;
00241   case passive_area:
00242     _area_base_ptr = new ClusterSequencePassiveArea(pseudojets, 
00243                                                     jet_def_in, 
00244                                                     _area_def.ghost_spec());
00245     break;
00246   default:
00247     std::cerr << "Error: unrecognized area_type in ClusterSequenceArea:" 
00248               << _area_def.area_type() << std::endl;
00249     exit(-1);
00250   }
00251   // now copy across the information from the area base class
00252   _area_base = std::auto_ptr<ClusterSequenceAreaBase>(_area_base_ptr);
00253   transfer_from_sequence(*_area_base);
00254 }
00255 
00256 FASTJET_END_NAMESPACE
00257 
00258 #endif // __FASTJET_CLUSTERSEQUENCEAREA_HH__
00259 
00260 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends