FastJet 3.0.5
Subtractor.cc
00001 //STARTHEADER
00002 // $Id: Subtractor.cc 2577 2011-09-13 15:11:38Z salam $
00003 //
00004 // Copyright (c) 2005-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 #include "fastjet/tools/Subtractor.hh"
00030 #include <cassert>
00031 #include <sstream>
00032 #include <limits>
00033 using namespace std;
00034 
00035 FASTJET_BEGIN_NAMESPACE     // defined in fastjet/internal/base.hh
00036 
00037 const double Subtractor::_invalid_rho = -numeric_limits<double>::infinity();
00038 
00039 
00040 Subtractor::Subtractor(double rho) : _bge(0), _rho(rho) {
00041   assert(_rho>0.0);
00042 }
00043 
00044 PseudoJet Subtractor::result(const PseudoJet & jet) const {
00045   if (!jet.has_area()){
00046     throw Error("Trying to subtract a jet without area support");
00047   }
00048   
00049   double rho;
00050   if (_bge != 0) {
00051     rho = _bge->rho(jet);
00052   } else if (_rho != _invalid_rho) {
00053     rho = _rho;
00054   } else {
00055     throw Error("default Subtractor does not have any information about the background, which is needed to perform the subtraction");
00056   }
00057 
00058   PseudoJet subtracted_jet = jet;
00059   PseudoJet area4vect = jet.area_4vector();
00060   // sanity check
00061   if (rho*area4vect.perp() < jet.perp() ) { 
00062     // this subtraction should retain the jet's structural
00063     // information
00064     subtracted_jet -= rho*area4vect;
00065   } else { 
00066     // this sets the jet's momentum to zero while
00067     // maintaining all of the jet's structural information
00068     subtracted_jet *= 0;
00069   }
00070   return subtracted_jet;
00071 }
00072 
00073 //----------------------------------------------------------------------
00074 std::string Subtractor::description() const{
00075   if (_bge != 0) {
00076     return "Subtractor that uses the following background estimator to determine rho: "+_bge->description();
00077   } else if (_rho != _invalid_rho) {
00078     ostringstream ostr;
00079     ostr << "Subtractor that uses a fixed value of rho = " << _rho;
00080     return ostr.str();
00081   } else {
00082     return "Uninitialised subtractor";
00083   }
00084 }
00085 
00086 FASTJET_END_NAMESPACE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends