[d7d2da3] | 1 | //STARTHEADER
|
---|
| 2 | // $Id: ClusterSequenceArea.hh 2690 2011-11-14 14:57:54Z soyez $
|
---|
| 3 | //
|
---|
| 4 | // Copyright (c) 2006-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
|
---|
| 5 | //
|
---|
| 6 | //----------------------------------------------------------------------
|
---|
| 7 | // This file is part of FastJet.
|
---|
| 8 | //
|
---|
| 9 | // FastJet is free software; you can redistribute it and/or modify
|
---|
| 10 | // it under the terms of the GNU General Public License as published by
|
---|
| 11 | // the Free Software Foundation; either version 2 of the License, or
|
---|
| 12 | // (at your option) any later version.
|
---|
| 13 | //
|
---|
| 14 | // The algorithms that underlie FastJet have required considerable
|
---|
| 15 | // development and are described in hep-ph/0512210. If you use
|
---|
| 16 | // FastJet as part of work towards a scientific publication, please
|
---|
| 17 | // include a citation to the FastJet paper.
|
---|
| 18 | //
|
---|
| 19 | // FastJet is distributed in the hope that it will be useful,
|
---|
| 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 22 | // GNU General Public License for more details.
|
---|
| 23 | //
|
---|
| 24 | // You should have received a copy of the GNU General Public License
|
---|
| 25 | // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 26 | //----------------------------------------------------------------------
|
---|
| 27 | //ENDHEADER
|
---|
| 28 |
|
---|
| 29 | #ifndef __FASTJET_CLUSTERSEQUENCEAREA_HH__
|
---|
| 30 | #define __FASTJET_CLUSTERSEQUENCEAREA_HH__
|
---|
| 31 |
|
---|
| 32 | #include "fastjet/ClusterSequenceAreaBase.hh"
|
---|
| 33 | #include "fastjet/ClusterSequenceActiveArea.hh"
|
---|
| 34 | #include "fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh"
|
---|
| 35 | #include "fastjet/ClusterSequencePassiveArea.hh"
|
---|
| 36 | #include "fastjet/ClusterSequenceVoronoiArea.hh"
|
---|
| 37 | #include "fastjet/AreaDefinition.hh"
|
---|
| 38 |
|
---|
| 39 | FASTJET_BEGIN_NAMESPACE
|
---|
| 40 |
|
---|
| 41 | /// @ingroup area_classes
|
---|
| 42 | /// \class ClusterSequenceArea
|
---|
| 43 | /// General class for user to obtain ClusterSequence with additional
|
---|
| 44 | /// area information.
|
---|
| 45 | ///
|
---|
| 46 | /// Based on the area_def, it automatically dispatches the work to the
|
---|
| 47 | /// appropriate actual ClusterSequenceAreaBase-derived-class to do the
|
---|
| 48 | /// real work.
|
---|
| 49 | class ClusterSequenceArea : public ClusterSequenceAreaBase {
|
---|
| 50 | public:
|
---|
| 51 | /// main constructor
|
---|
| 52 | template<class L> ClusterSequenceArea
|
---|
| 53 | (const std::vector<L> & pseudojets,
|
---|
| 54 | const JetDefinition & jet_def_in,
|
---|
| 55 | const AreaDefinition & area_def_in) : _area_def(area_def_in) {
|
---|
| 56 | initialize_and_run_cswa(pseudojets, jet_def_in);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | /// constructor with a GhostedAreaSpec
|
---|
| 60 | template<class L> ClusterSequenceArea
|
---|
| 61 | (const std::vector<L> & pseudojets,
|
---|
| 62 | const JetDefinition & jet_def_in,
|
---|
| 63 | const GhostedAreaSpec & ghost_spec) : _area_def(ghost_spec){
|
---|
| 64 | initialize_and_run_cswa(pseudojets, jet_def_in);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /// constructor with a VoronoiAreaSpec
|
---|
| 68 | template<class L> ClusterSequenceArea
|
---|
| 69 | (const std::vector<L> & pseudojets,
|
---|
| 70 | const JetDefinition & jet_def_in,
|
---|
| 71 | const VoronoiAreaSpec & voronoi_spec) : _area_def(voronoi_spec){
|
---|
| 72 | initialize_and_run_cswa(pseudojets, jet_def_in);
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /// return a reference to the area definition
|
---|
| 76 | const AreaDefinition & area_def() const {return _area_def;}
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | /// return the area associated with the given jet
|
---|
| 80 | virtual double area (const PseudoJet & jet) const {
|
---|
| 81 | return _area_base->area(jet);}
|
---|
| 82 |
|
---|
| 83 | /// return the error (uncertainty) associated with the determination
|
---|
| 84 | /// of the area of this jet
|
---|
| 85 | virtual double area_error (const PseudoJet & jet) const {
|
---|
| 86 | return _area_base->area_error(jet);}
|
---|
| 87 |
|
---|
| 88 | /// return the 4-vector area
|
---|
| 89 | virtual PseudoJet area_4vector(const PseudoJet & jet) const {
|
---|
| 90 | return _area_base->area_4vector(jet);}
|
---|
| 91 |
|
---|
| 92 | // /// return the total area, up to |y|<maxrap, that is free of jets
|
---|
| 93 | // virtual double empty_area(double maxrap) const {
|
---|
| 94 | // return _area_base->empty_area(maxrap);}
|
---|
| 95 | //
|
---|
| 96 | // /// return something similar to the number of pure ghost jets
|
---|
| 97 | // /// in the given rapidity range in an active area case.
|
---|
| 98 | // /// For the local implementation we return empty_area/(0.55 pi R^2),
|
---|
| 99 | // /// based on measured properties of ghost jets with kt and cam. Note
|
---|
| 100 | // /// that the number returned is a double.
|
---|
| 101 | // virtual double n_empty_jets(double maxrap) const {
|
---|
| 102 | // return _area_base->n_empty_jets(maxrap);
|
---|
| 103 |
|
---|
| 104 | /// return the total area, corresponding to the given selector, that
|
---|
| 105 | /// is free of jets
|
---|
| 106 | ///
|
---|
| 107 | /// The selector needs to have a finite area and be applicable jet by
|
---|
| 108 | /// jet (see the BackgroundEstimator and Subtractor tools for more
|
---|
| 109 | /// advanced usage)
|
---|
| 110 | virtual double empty_area(const Selector & selector) const {
|
---|
| 111 | return _area_base->empty_area(selector);}
|
---|
| 112 |
|
---|
| 113 | /// return something similar to the number of pure ghost jets
|
---|
| 114 | /// in the given rap-phi range in an active area case.
|
---|
| 115 | /// For the local implementation we return empty_area/(0.55 pi R^2),
|
---|
| 116 | /// based on measured properties of ghost jets with kt and cam. Note
|
---|
| 117 | /// that the number returned is a double.
|
---|
| 118 | ///
|
---|
| 119 | /// The selector needs to have a finite area and be applicable jet by
|
---|
| 120 | /// jet (see the BackgroundEstimator and Subtractor tools for more
|
---|
| 121 | /// advanced usage)
|
---|
| 122 | virtual double n_empty_jets(const Selector & selector) const {
|
---|
| 123 | return _area_base->n_empty_jets(selector);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | /// true if a jet is made exclusively of ghosts
|
---|
| 127 | virtual bool is_pure_ghost(const PseudoJet & jet) const {
|
---|
| 128 | return _area_base->is_pure_ghost(jet);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /// true if this ClusterSequence has explicit ghosts
|
---|
| 132 | virtual bool has_explicit_ghosts() const {
|
---|
| 133 | return _area_base->has_explicit_ghosts();
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | /// overload version of what's in the ClusterSequenceAreaBase class, which
|
---|
| 138 | /// additionally checks compatibility between "selector" and region in which
|
---|
| 139 | /// ghosts are thrown.
|
---|
| 140 | ///
|
---|
| 141 | /// The selector needs to have a finite area and be applicable jet by
|
---|
| 142 | /// jet (see the BackgroundEstimator and Subtractor tools for more
|
---|
| 143 | /// advanced usage)
|
---|
| 144 | virtual void get_median_rho_and_sigma(const std::vector<PseudoJet> & all_jets,
|
---|
| 145 | const Selector & selector,
|
---|
| 146 | bool use_area_4vector,
|
---|
| 147 | double & median, double & sigma,
|
---|
| 148 | double & mean_area,
|
---|
| 149 | bool all_are_incl = false) const {
|
---|
| 150 | _warn_if_range_unsuitable(selector);
|
---|
| 151 | ClusterSequenceAreaBase::get_median_rho_and_sigma(
|
---|
| 152 | all_jets, selector, use_area_4vector,
|
---|
| 153 | median, sigma, mean_area, all_are_incl);
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | /// overload version of what's in the ClusterSequenceAreaBase class,
|
---|
| 157 | /// which actually just does the same thing as the base version (but
|
---|
| 158 | /// since we've overridden the 5-argument version above, we have to
|
---|
| 159 | /// override the 4-argument version too.
|
---|
| 160 | virtual void get_median_rho_and_sigma(const Selector & selector,
|
---|
| 161 | bool use_area_4vector,
|
---|
| 162 | double & median, double & sigma) const {
|
---|
| 163 | ClusterSequenceAreaBase::get_median_rho_and_sigma(selector,use_area_4vector,
|
---|
| 164 | median,sigma);
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | /// overload version of what's in the ClusterSequenceAreaBase class,
|
---|
| 168 | /// which actually just does the same thing as the base version (but
|
---|
| 169 | /// since we've overridden the multi-argument version above, we have to
|
---|
| 170 | /// override the 5-argument version too.
|
---|
| 171 | virtual void get_median_rho_and_sigma(const Selector & selector,
|
---|
| 172 | bool use_area_4vector,
|
---|
| 173 | double & median, double & sigma,
|
---|
| 174 | double & mean_area) const {
|
---|
| 175 | ClusterSequenceAreaBase::get_median_rho_and_sigma(selector,use_area_4vector,
|
---|
| 176 | median,sigma, mean_area);
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | /// overload version of what's in the ClusterSequenceAreaBase class, which
|
---|
| 181 | /// additionally checks compatibility between "range" and region in which
|
---|
| 182 | /// ghosts are thrown.
|
---|
| 183 | virtual void parabolic_pt_per_unit_area(double & a, double & b,
|
---|
| 184 | const Selector & selector,
|
---|
| 185 | double exclude_above=-1.0,
|
---|
| 186 | bool use_area_4vector=false) const {
|
---|
| 187 | _warn_if_range_unsuitable(selector);
|
---|
| 188 | ClusterSequenceAreaBase::parabolic_pt_per_unit_area(
|
---|
| 189 | a,b,selector, exclude_above, use_area_4vector);
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 | private:
|
---|
| 194 |
|
---|
| 195 | /// print a warning if the range is unsuitable for the current
|
---|
| 196 | /// calculation of the area (e.g. because ghosts do not extend
|
---|
| 197 | /// far enough).
|
---|
| 198 | void _warn_if_range_unsuitable(const Selector & selector) const;
|
---|
| 199 |
|
---|
| 200 | template<class L> void initialize_and_run_cswa (
|
---|
| 201 | const std::vector<L> & pseudojets,
|
---|
| 202 | const JetDefinition & jet_def);
|
---|
| 203 |
|
---|
| 204 | std::auto_ptr<ClusterSequenceAreaBase> _area_base;
|
---|
| 205 | AreaDefinition _area_def;
|
---|
| 206 | static LimitedWarning _range_warnings;
|
---|
| 207 | static LimitedWarning _explicit_ghosts_repeats_warnings;
|
---|
| 208 |
|
---|
| 209 | };
|
---|
| 210 |
|
---|
| 211 | //----------------------------------------------------------------------
|
---|
| 212 | template<class L> void ClusterSequenceArea::initialize_and_run_cswa(
|
---|
| 213 | const std::vector<L> & pseudojets,
|
---|
| 214 | const JetDefinition & jet_def_in)
|
---|
| 215 | {
|
---|
| 216 |
|
---|
| 217 | ClusterSequenceAreaBase * _area_base_ptr;
|
---|
| 218 | switch(_area_def.area_type()) {
|
---|
| 219 | case active_area:
|
---|
| 220 | _area_base_ptr = new ClusterSequenceActiveArea(pseudojets,
|
---|
| 221 | jet_def_in,
|
---|
| 222 | _area_def.ghost_spec());
|
---|
| 223 | break;
|
---|
| 224 | case active_area_explicit_ghosts:
|
---|
| 225 | if (_area_def.ghost_spec().repeat() != 1)
|
---|
| 226 | _explicit_ghosts_repeats_warnings.warn("Requested active area with explicit ghosts with repeat != 1; only 1 set of ghosts will be used");
|
---|
| 227 | _area_base_ptr = new ClusterSequenceActiveAreaExplicitGhosts(pseudojets,
|
---|
| 228 | jet_def_in,
|
---|
| 229 | _area_def.ghost_spec());
|
---|
| 230 | break;
|
---|
| 231 | case voronoi_area:
|
---|
| 232 | _area_base_ptr = new ClusterSequenceVoronoiArea(pseudojets,
|
---|
| 233 | jet_def_in,
|
---|
| 234 | _area_def.voronoi_spec());
|
---|
| 235 | break;
|
---|
| 236 | case one_ghost_passive_area:
|
---|
| 237 | _area_base_ptr = new ClusterSequence1GhostPassiveArea(pseudojets,
|
---|
| 238 | jet_def_in,
|
---|
| 239 | _area_def.ghost_spec());
|
---|
| 240 | break;
|
---|
| 241 | case passive_area:
|
---|
| 242 | _area_base_ptr = new ClusterSequencePassiveArea(pseudojets,
|
---|
| 243 | jet_def_in,
|
---|
| 244 | _area_def.ghost_spec());
|
---|
| 245 | break;
|
---|
| 246 | default:
|
---|
| 247 | std::cerr << "Error: unrecognized area_type in ClusterSequenceArea:"
|
---|
| 248 | << _area_def.area_type() << std::endl;
|
---|
| 249 | exit(-1);
|
---|
| 250 | }
|
---|
| 251 | // now copy across the information from the area base class
|
---|
| 252 | _area_base = std::auto_ptr<ClusterSequenceAreaBase>(_area_base_ptr);
|
---|
| 253 | transfer_from_sequence(*_area_base);
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | FASTJET_END_NAMESPACE
|
---|
| 257 |
|
---|
| 258 | #endif // __FASTJET_CLUSTERSEQUENCEAREA_HH__
|
---|
| 259 |
|
---|
| 260 |
|
---|