FastJet 3.4.1
Subtractor.hh
1//FJSTARTHEADER
2// $Id$
3//
4// Copyright (c) 2005-2023, 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. They are described in the original FastJet paper,
16// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17// FastJet as part of work towards a scientific publication, please
18// quote the version you use and include a citation to the manual and
19// optionally also to hep-ph/0512210.
20//
21// FastJet is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28//----------------------------------------------------------------------
29//FJENDHEADER
30
31#ifndef __FASTJET_TOOLS_SUBTRACTOR_HH__
32#define __FASTJET_TOOLS_SUBTRACTOR_HH__
33
34#include "fastjet/internal/base.hh" // namespace macros (include explicitly to help Doxygen)
35#include "fastjet/tools/Transformer.hh" // to derive Subtractor from Transformer
36#include "fastjet/tools/BackgroundEstimatorBase.hh" // used as a ctor argument
37
38FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
39
40
41//----------------------------------------------------------------------
42/// @ingroup tools_background
43/// \class Subtractor
44/// Class that helps perform jet background subtraction.
45///
46/// This class derives from Transformer and makes use of a pointer to
47/// a BackgroundEstimatorBase object in order to determine the background
48/// in the vicinity of a given jet and then subtract area*background from
49/// the jet. It can also be initialised with a specific fixed value for the
50/// background pt density.
51///
52/// \section input Input conditions
53///
54/// The original jet must have area support (4-vector)
55///
56/// \section output Output/interface
57///
58/// The underlying structure of the returned, subtracted jet
59/// (i.e. constituents, pieces, etc.) is identical to that of the
60/// original jet.
61///
62class Subtractor : public Transformer{
63public:
64 /// define a subtractor based on a BackgroundEstimator
66 _bge(bge), _rho(-1.0) { set_defaults(); }
67
68 /// define a subtractor that uses a fixed value of rho, the background
69 /// pt density per unit area (which must be positive)
70 Subtractor(double rho);
71
72 /// define a subtractor that uses a fixed value of rho and rho_m;
73 /// both must be >= 0;
74 Subtractor(double rho, double rho_m);
75
76 /// default constructor
77 Subtractor() : _bge(0), _rho(_invalid_rho) { set_defaults(); }
78
79 /// default dtor
80 virtual ~Subtractor(){};
81
82 /// @name configuring the behaviour
83 //\{
84 //----------------------------------------------------------------
85
86 /// reset all parameters to default values
87 ///
88 /// Note: by default, the rho_m term is not included and the safety
89 /// test for the mass is not done. This is mostly for backwards
90 /// compatibility with FastJet 3.0 and is highly likely to change in
91 /// a future release of FastJet
92 void set_defaults();
93
94 void set_background_estimator(const BackgroundEstimatorBase * bge) {
95 _bge = bge;
96 _rho = _invalid_rho;
97 }
98
99 /// when 'use_rho_m' is true, include in the subtraction the
100 /// correction from rho_m, the purely longitudinal,
101 /// particle-mass-induced component of the background density per
102 /// unit area
103 ///
104 /// Note: this will be switched off by default (for backwards
105 /// compatibility with FastJet 3.0) but is highly likely to change
106 /// in a future release of FastJet
107 void set_use_rho_m(bool use_rho_m_in = true){
108 if (_bge == 0 && _rho_m < 0) {
109 throw Error("Subtractor: rho_m support works only for Subtractors constructed with a background estimator or an explicit rho_m value");
110 }
111 _use_rho_m=use_rho_m_in;
112 }
113
114 /// returns whether or not the rho_m component is used
115 bool use_rho_m() const{ return _use_rho_m;}
116
117 /// when 'safe_mass' is true, ensure that the mass of the subtracted
118 /// 4-vector remain positive
119 ///
120 /// when true, if the subtracted mass is negative, we return a
121 /// 4-vector with 0 mass, pt and phi from the subtracted 4-vector
122 /// and the rapidity of the original, unsubtracted jet.
123 ///
124 /// Note: this will be switched off by default (for backwards
125 /// compatibility with FastJet 3.0) but is highly likely to change
126 /// in a future release of FastJet
127 void set_safe_mass(bool safe_mass_in=true){ _safe_mass=safe_mass_in;}
128
129 /// returns whether or not safety tests on the mass are included
130 bool safe_mass() const{ return _safe_mass;}
131
132 /// This is mostly intended for cherge-hadron-subtracted type of
133 /// events where we wich to use vertex information to improve the
134 /// subtraction.
135 ///
136 /// Given the following parameters:
137 /// \param sel_known_vertex selects the particles with a
138 /// known vertex origin
139 /// \param sel_leading_vertex amongst the particles with a
140 /// known vertex origin, select those
141 /// coming from the leading vertex
142 /// Momentum identified as coming from the leading vertex will be
143 /// kept, momentum identified as coming from a non-leading vertex
144 /// will be eliminated and a regular area-median subtraction will be
145 /// applied on the 4-vector sum of the particles with unknown vertex
146 /// origin.
147 ///
148 /// When this is set, we shall ensure that the pt of the subtracted
149 /// 4-vector is at least the pt of the particles that are known to
150 /// come from the leading vertex (if it fails, subtraction returns
151 /// the component that is known to come from the leading vertex ---
152 /// or, the original unsubtracted jet if it contains no particles
153 /// from the leading vertex). Furthermore, when safe_mass() is on, we
154 /// also impose a similar constraint on the mass of the subtracted
155 /// 4-vector (if the test fails, the longitudinal part of the
156 /// subtracted 4-vector is taken from the component that is known to
157 /// come from the leading vertex).
158 void set_known_selectors(const Selector &sel_known_vertex,
159 const Selector &sel_leading_vertex){
160 _sel_known_vertex = sel_known_vertex;
161 _sel_leading_vertex = sel_leading_vertex;
162 }
163
164 //\}
165
166 /// @name description and action
167 //\{
168 //----------------------------------------------------------------
169
170 /// returns a jet that's subtracted
171 ///
172 /// \param jet the jet that is to be subtracted
173 /// \return the subtracted jet
174 virtual PseudoJet result(const PseudoJet & jet) const;
175
176 /// class description
177 virtual std::string description() const;
178
179 //\}
180protected:
181 /// compute the 4-vector that should be subtracted from the given
182 /// jet
183 PseudoJet _amount_to_subtract(const PseudoJet &jet) const;
184
185 /// the tool used to estimate the background
186 /// if has to be mutable in case its underlying selector takes a reference jet
188 /// the fixed value of rho and/or rho_m to use if the user has selected that option
189 double _rho, _rho_m;
190
191 // configuration parameters/flags
192 bool _use_rho_m; ///< include the rho_m correction
193 bool _safe_mass; ///< ensures that the subtracted mass is +ve
194
195 Selector _sel_known_vertex; ///< selects the particles with a
196 ///< known vertex origin
197 Selector _sel_leading_vertex; ///< amongst the particles with a
198 ///< known vertex origin, select those
199 ///< coming from the leading vertex
200
201 /// a value of rho that is used as a default to label that the stored
202 /// rho is not valid for subtraction.
203 //
204 // NB: there are two reasons for not having the value written here:
205 // 1) that it caused problems on karnak with g++ 4.0.1 and 2) that
206 // we anyway like -infinity as a default, and since that's a function,
207 // that's not allowed in an include file.
208 static const double _invalid_rho;
209
210 static LimitedWarning _unused_rho_m_warning;
211};
212
213FASTJET_END_NAMESPACE
214
215#endif // __FASTJET_TOOLS_SUBTRACTOR_HH__
216
Abstract base class that provides the basic interface for classes that estimate levels of background ...
base class corresponding to errors that can be thrown by FastJet
Definition: Error.hh:52
class to provide facilities for giving warnings up to some maximum number of times and to provide glo...
Class to contain pseudojets, including minimal information of use to jet-clustering routines.
Definition: PseudoJet.hh:68
Class that encodes information about cuts and other selection criteria that can be applied to PseudoJ...
Definition: Selector.hh:149
Class that helps perform jet background subtraction.
Definition: Subtractor.hh:62
bool use_rho_m() const
returns whether or not the rho_m component is used
Definition: Subtractor.hh:115
Subtractor(const BackgroundEstimatorBase *bge)
define a subtractor based on a BackgroundEstimator
Definition: Subtractor.hh:65
void set_safe_mass(bool safe_mass_in=true)
when 'safe_mass' is true, ensure that the mass of the subtracted 4-vector remain positive
Definition: Subtractor.hh:127
virtual ~Subtractor()
default dtor
Definition: Subtractor.hh:80
Subtractor()
default constructor
Definition: Subtractor.hh:77
static const double _invalid_rho
a value of rho that is used as a default to label that the stored rho is not valid for subtraction.
Definition: Subtractor.hh:208
double _rho
the fixed value of rho and/or rho_m to use if the user has selected that option
Definition: Subtractor.hh:189
bool _safe_mass
ensures that the subtracted mass is +ve
Definition: Subtractor.hh:193
void set_known_selectors(const Selector &sel_known_vertex, const Selector &sel_leading_vertex)
This is mostly intended for cherge-hadron-subtracted type of events where we wich to use vertex infor...
Definition: Subtractor.hh:158
bool safe_mass() const
returns whether or not safety tests on the mass are included
Definition: Subtractor.hh:130
void set_use_rho_m(bool use_rho_m_in=true)
when 'use_rho_m' is true, include in the subtraction the correction from rho_m, the purely longitudin...
Definition: Subtractor.hh:107
const BackgroundEstimatorBase * _bge
the tool used to estimate the background if has to be mutable in case its underlying selector takes a...
Definition: Subtractor.hh:187
bool _use_rho_m
include the rho_m correction
Definition: Subtractor.hh:192
Selector _sel_leading_vertex
amongst the particles with a known vertex origin, select those coming from the leading vertex
Definition: Subtractor.hh:197
Selector _sel_known_vertex
selects the particles with a known vertex origin
Definition: Subtractor.hh:195
Base (abstract) class for a jet transformer.
Definition: Transformer.hh:71