FastJet  3.0.6
Subtractor.cc
1 //STARTHEADER
2 // $Id: Subtractor.cc 2577 2011-09-13 15:11:38Z salam $
3 //
4 // Copyright (c) 2005-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 #include "fastjet/tools/Subtractor.hh"
30 #include <cassert>
31 #include <sstream>
32 #include <limits>
33 using namespace std;
34 
35 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
36 
37 const double Subtractor::_invalid_rho = -numeric_limits<double>::infinity();
38 
39 
40 Subtractor::Subtractor(double rho) : _bge(0), _rho(rho) {
41  assert(_rho>0.0);
42 }
43 
44 PseudoJet Subtractor::result(const PseudoJet & jet) const {
45  if (!jet.has_area()){
46  throw Error("Trying to subtract a jet without area support");
47  }
48 
49  double rho;
50  if (_bge != 0) {
51  rho = _bge->rho(jet);
52  } else if (_rho != _invalid_rho) {
53  rho = _rho;
54  } else {
55  throw Error("default Subtractor does not have any information about the background, which is needed to perform the subtraction");
56  }
57 
58  PseudoJet subtracted_jet = jet;
59  PseudoJet area4vect = jet.area_4vector();
60  // sanity check
61  if (rho*area4vect.perp() < jet.perp() ) {
62  // this subtraction should retain the jet's structural
63  // information
64  subtracted_jet -= rho*area4vect;
65  } else {
66  // this sets the jet's momentum to zero while
67  // maintaining all of the jet's structural information
68  subtracted_jet *= 0;
69  }
70  return subtracted_jet;
71 }
72 
73 //----------------------------------------------------------------------
74 std::string Subtractor::description() const{
75  if (_bge != 0) {
76  return "Subtractor that uses the following background estimator to determine rho: "+_bge->description();
77  } else if (_rho != _invalid_rho) {
78  ostringstream ostr;
79  ostr << "Subtractor that uses a fixed value of rho = " << _rho;
80  return ostr.str();
81  } else {
82  return "Uninitialised subtractor";
83  }
84 }
85 
86 FASTJET_END_NAMESPACE
double _rho
the fixed value of rho to use if the user has selected that option
Definition: Subtractor.hh:90
virtual std::string description() const
class description
Definition: Subtractor.cc:74
virtual PseudoJet result(const PseudoJet &jet) const
returns a jet that&#39;s subtracted
Definition: Subtractor.cc:44
Subtractor()
default constructor
Definition: Subtractor.hh:70
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:99
BackgroundEstimatorBase * _bge
the tool used to estimate the background if has to be mutable in case its underlying selector takes a...
Definition: Subtractor.hh:88