1 | //STARTHEADER
|
---|
2 | // $Id: CircularRange.hh 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 |
|
---|
30 | #ifndef __FASTJET_CIRCULARRANGE_HH__
|
---|
31 | #define __FASTJET_CIRCULARRANGE_HH__
|
---|
32 |
|
---|
33 | #include "fastjet/RangeDefinition.hh"
|
---|
34 | #include "fastjet/Error.hh"
|
---|
35 |
|
---|
36 | // for backwards compatibility: one should now use SelectorCircle,
|
---|
37 | // defined in fastjet/Selector.hh, instead CircularRange
|
---|
38 | #warning This file includes fastjet/CircularRange.hh, \
|
---|
39 | a deprecated FastJet header provided only for backward compatibility. \
|
---|
40 | This is not guaranteed to work in future releases of FastJet. \
|
---|
41 | From FastJet 3.0 onwards, please consider using Selector, defined in \
|
---|
42 | fastjet/Selector.hh, instead of RangeDefinition and, in particular, \
|
---|
43 | SelectorCircle instead of CircularRange.
|
---|
44 |
|
---|
45 | FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
|
---|
46 |
|
---|
47 | class CircularRange : public fastjet::RangeDefinition {
|
---|
48 | public:
|
---|
49 | /// constructor
|
---|
50 | CircularRange() {_set_invalid_rapphi();}
|
---|
51 |
|
---|
52 | /// initialise CircularRange with a jet
|
---|
53 | CircularRange(const fastjet::PseudoJet & jet, double distance) {
|
---|
54 | _distance = distance;
|
---|
55 | _rapjet = jet.rap();
|
---|
56 | _phijet = jet.phi();
|
---|
57 | _total_area = fastjet::pi*_distance*_distance; }
|
---|
58 |
|
---|
59 | /// initialise CircularRange with a (rap,phi) point
|
---|
60 | CircularRange(double rap, double phi, double distance) {
|
---|
61 | _distance = distance;
|
---|
62 | _rapjet = rap;
|
---|
63 | _phijet = phi;
|
---|
64 | _total_area = fastjet::pi*_distance*_distance; }
|
---|
65 |
|
---|
66 | /// initialise CircularRange with just the radius parameter
|
---|
67 | CircularRange(double distance) {
|
---|
68 | _set_invalid_rapphi();
|
---|
69 | _distance = distance;
|
---|
70 | _total_area = fastjet::pi*_distance*_distance; }
|
---|
71 |
|
---|
72 | /// destructor
|
---|
73 | virtual ~CircularRange() {}
|
---|
74 |
|
---|
75 | /// return description of range
|
---|
76 | virtual inline std::string description() const {
|
---|
77 | std::ostringstream ostr;
|
---|
78 | ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ;
|
---|
79 | return ostr.str(); }
|
---|
80 |
|
---|
81 | /// returns true since this range is localizable (i.e. set_position
|
---|
82 | /// does something meaningful)
|
---|
83 | virtual inline bool is_localizable() const { return true; }
|
---|
84 |
|
---|
85 | /// return bool according to whether (rap,phi) is in range
|
---|
86 | virtual inline bool is_in_range(double rap, double phi) const {
|
---|
87 | if (! _rapphi_are_valid()) {
|
---|
88 | throw Error("Circular range used without a center having being defined (use set_position())");
|
---|
89 | }
|
---|
90 | double deltaphi = _phijet - phi;
|
---|
91 | if ( deltaphi > pi) { deltaphi -= twopi; }
|
---|
92 | else if ( deltaphi < -pi) { deltaphi += twopi; }
|
---|
93 | bool inrange = ( (rap-_rapjet)*(rap-_rapjet) +
|
---|
94 | deltaphi*deltaphi <= _distance*_distance );
|
---|
95 | return inrange; }
|
---|
96 |
|
---|
97 | /// return the minimal and maximal rapidity of this range
|
---|
98 | virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
|
---|
99 | rapmin = _rapjet - _distance;
|
---|
100 | rapmax = _rapjet + _distance; }
|
---|
101 |
|
---|
102 | private:
|
---|
103 | double _distance;
|
---|
104 |
|
---|
105 | /// value for phi that marks it as invalid
|
---|
106 | const static double _invalid_phi = -1000.0;
|
---|
107 | /// set internal phi so as to mark things as invalid
|
---|
108 | void _set_invalid_rapphi() {_phijet = _invalid_phi;}
|
---|
109 | /// true if rap,phi are valid (tests only phi)
|
---|
110 | bool _rapphi_are_valid() const {return _phijet != _invalid_phi;}
|
---|
111 | };
|
---|
112 |
|
---|
113 | FASTJET_END_NAMESPACE
|
---|
114 |
|
---|
115 | #endif // __FASTJET_CIRCULARRANGE_HH__
|
---|