FastJet 3.0beta1
|
00001 //STARTHEADER 00002 // $Id: CircularRange.hh 2366 2011-07-06 09:57:52Z soyez $ 00003 // 00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam 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, write to the Free Software 00026 // Foundation, Inc.: 00027 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 //---------------------------------------------------------------------- 00029 //ENDHEADER 00030 00031 00032 #ifndef __FASTJET_CIRCULARRANGE_HH__ 00033 #define __FASTJET_CIRCULARRANGE_HH__ 00034 00035 #include "fastjet/RangeDefinition.hh" 00036 #include "fastjet/Error.hh" 00037 00038 // for backwards compatibility: one should now use SelectorCircle, 00039 // defined in fastjet/Selector.hh, instead CircularRange 00040 #warning This file includes fastjet/CircularRange.hh, \ 00041 a deprecated FastJet header provided only for backward compatibility. \ 00042 This is not guaranteed to work in future releases of FastJet. \ 00043 From FastJet 3.0 onwards, please consider using Selector, defined in \ 00044 fastjet/Selector.hh, instead of RangeDefinition and, in particular, \ 00045 SelectorCircle instead of CircularRange. 00046 00047 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00048 00049 class CircularRange : public fastjet::RangeDefinition { 00050 public: 00051 /// constructor 00052 CircularRange() {_set_invalid_rapphi();} 00053 00054 /// initialise CircularRange with a jet 00055 CircularRange(const fastjet::PseudoJet & jet, double distance) { 00056 _distance = distance; 00057 _rapjet = jet.rap(); 00058 _phijet = jet.phi(); 00059 _total_area = fastjet::pi*_distance*_distance; } 00060 00061 /// initialise CircularRange with a (rap,phi) point 00062 CircularRange(double rap, double phi, double distance) { 00063 _distance = distance; 00064 _rapjet = rap; 00065 _phijet = phi; 00066 _total_area = fastjet::pi*_distance*_distance; } 00067 00068 /// initialise CircularRange with just the radius parameter 00069 CircularRange(double distance) { 00070 _set_invalid_rapphi(); 00071 _distance = distance; 00072 _total_area = fastjet::pi*_distance*_distance; } 00073 00074 /// destructor 00075 virtual ~CircularRange() {} 00076 00077 /// return description of range 00078 virtual inline std::string description() const { 00079 std::ostringstream ostr; 00080 ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ; 00081 return ostr.str(); } 00082 00083 /// returns true since this range is localizable (i.e. set_position 00084 /// does something meaningful) 00085 virtual inline bool is_localizable() const { return true; } 00086 00087 /// return bool according to whether (rap,phi) is in range 00088 virtual inline bool is_in_range(double rap, double phi) const { 00089 if (! _rapphi_are_valid()) { 00090 throw Error("Circular range used without a center having being defined (use set_position())"); 00091 } 00092 double deltaphi = _phijet - phi; 00093 if ( deltaphi > pi) { deltaphi -= twopi; } 00094 else if ( deltaphi < -pi) { deltaphi += twopi; } 00095 bool inrange = ( (rap-_rapjet)*(rap-_rapjet) + 00096 deltaphi*deltaphi <= _distance*_distance ); 00097 return inrange; } 00098 00099 /// return the minimal and maximal rapidity of this range 00100 virtual inline void get_rap_limits(double & rapmin, double & rapmax) const { 00101 rapmin = _rapjet - _distance; 00102 rapmax = _rapjet + _distance; } 00103 00104 private: 00105 double _distance; 00106 00107 /// value for phi that marks it as invalid 00108 const static double _invalid_phi = -1000.0; 00109 /// set internal phi so as to mark things as invalid 00110 void _set_invalid_rapphi() {_phijet = _invalid_phi;} 00111 /// true if rap,phi are valid (tests only phi) 00112 bool _rapphi_are_valid() const {return _phijet != _invalid_phi;} 00113 }; 00114 00115 FASTJET_END_NAMESPACE 00116 00117 #endif // __FASTJET_CIRCULARRANGE_HH__