2 // $Id: CircularRange.hh 1502 2009-04-06 10:33:14Z salam $
4 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
6 //----------------------------------------------------------------------
7 // This file is part of FastJet.
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.
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.
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.
24 // You should have received a copy of the GNU General Public License
25 // along with FastJet; if not, write to the Free Software
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 //----------------------------------------------------------------------
32 #ifndef __FASTJET_CIRCULARRANGE_HH__
33 #define __FASTJET_CIRCULARRANGE_HH__
35 #include "fastjet/RangeDefinition.hh"
36 #include "fastjet/Error.hh"
38 namespace fastjet { // defined in fastjet/internal/base.hh
40 class CircularRange : public fastjet::RangeDefinition {
43 CircularRange() {_set_invalid_rapphi();}
45 /// initialise CircularRange with a jet
46 CircularRange(const fastjet::PseudoJet & jet, double distance) {
50 _total_area = fastjet::pi*_distance*_distance; }
52 /// initialise CircularRange with a (rap,phi) point
53 CircularRange(double rap, double phi, double distance) {
57 _total_area = fastjet::pi*_distance*_distance; }
59 /// initialise CircularRange with just the radius parameter
60 CircularRange(double distance) {
61 _set_invalid_rapphi();
63 _total_area = fastjet::pi*_distance*_distance; }
66 virtual ~CircularRange() {}
68 /// return description of range
69 virtual inline std::string description() const {
70 std::ostringstream ostr;
71 ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ;
74 /// returns true since this range is localizable (i.e. set_position
75 /// does something meaningful)
76 virtual inline bool is_localizable() const { return true; }
78 /// return bool according to whether (rap,phi) is in range
79 virtual inline bool is_in_range(double rap, double phi) const {
80 if (! _rapphi_are_valid()) {
81 throw Error("Circular range used without a center having being defined (use set_position())");
83 double deltaphi = _phijet - phi;
84 if ( deltaphi > pi) { deltaphi -= twopi; }
85 else if ( deltaphi < -pi) { deltaphi += twopi; }
86 bool inrange = ( (rap-_rapjet)*(rap-_rapjet) +
87 deltaphi*deltaphi <= _distance*_distance );
90 /// return the minimal and maximal rapidity of this range
91 virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
92 rapmin = _rapjet - _distance;
93 rapmax = _rapjet + _distance; }
98 /// value for phi that marks it as invalid
99 const static double _invalid_phi = -1000.0;
100 /// set internal phi so as to mark things as invalid
101 void _set_invalid_rapphi() {_phijet = _invalid_phi;}
102 /// true if rap,phi are valid (tests only phi)
103 bool _rapphi_are_valid() const {return _phijet != _invalid_phi;}
107 } // fastjet namespace
109 #endif // __FASTJET_CIRCULARRANGE_HH__