FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
CircularRange.hh
1 //FJSTARTHEADER
2 // $Id: CircularRange.hh 3433 2014-07-23 08:17:03Z salam $
3 //
4 // Copyright (c) 2005-2014, 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. They are described in the original FastJet paper,
16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17 // FastJet as part of work towards a scientific publication, please
18 // quote the version you use and include a citation to the manual and
19 // optionally also to hep-ph/0512210.
20 //
21 // FastJet is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28 //----------------------------------------------------------------------
29 //FJENDHEADER
30 
31 
32 #ifndef __FASTJET_CIRCULARRANGE_HH__
33 #define __FASTJET_CIRCULARRANGE_HH__
34 
35 #include "fastjet/RangeDefinition.hh"
36 #include "fastjet/Error.hh"
37 
38 // for backwards compatibility: one should now use SelectorCircle,
39 // defined in fastjet/Selector.hh, instead CircularRange
40 #warning This file includes fastjet/CircularRange.hh, \
41 a deprecated FastJet header provided only for backward compatibility. \
42 This is not guaranteed to work in future releases of FastJet. \
43 From FastJet 3.0 onwards, please consider using Selector, defined in \
44 fastjet/Selector.hh, instead of RangeDefinition and, in particular, \
45 SelectorCircle instead of CircularRange.
46 
47 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
48 
49 class CircularRange : public fastjet::RangeDefinition {
50 public:
51  /// constructor
52  CircularRange() {_set_invalid_rapphi();}
53 
54  /// initialise CircularRange with a jet
55  CircularRange(const fastjet::PseudoJet & jet, double distance) {
56  _distance = distance;
57  _rapjet = jet.rap();
58  _phijet = jet.phi();
59  _total_area = fastjet::pi*_distance*_distance; }
60 
61  /// initialise CircularRange with a (rap,phi) point
62  CircularRange(double rap, double phi, double distance) {
63  _distance = distance;
64  _rapjet = rap;
65  _phijet = phi;
66  _total_area = fastjet::pi*_distance*_distance; }
67 
68  /// initialise CircularRange with just the radius parameter
69  CircularRange(double distance) {
70  _set_invalid_rapphi();
71  _distance = distance;
72  _total_area = fastjet::pi*_distance*_distance; }
73 
74  /// destructor
75  virtual ~CircularRange() {}
76 
77  /// return description of range
78  virtual inline std::string description() const {
79  std::ostringstream ostr;
80  ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ;
81  return ostr.str(); }
82 
83  /// returns true since this range is localizable (i.e. set_position
84  /// does something meaningful)
85  virtual inline bool is_localizable() const { return true; }
86 
87  /// return bool according to whether (rap,phi) is in range
88  virtual inline bool is_in_range(double rap, double phi) const {
89  if (! _rapphi_are_valid()) {
90  throw Error("Circular range used without a center having being defined (use set_position())");
91  }
92  double deltaphi = _phijet - phi;
93  if ( deltaphi > pi) { deltaphi -= twopi; }
94  else if ( deltaphi < -pi) { deltaphi += twopi; }
95  bool inrange = ( (rap-_rapjet)*(rap-_rapjet) +
96  deltaphi*deltaphi <= _distance*_distance );
97  return inrange; }
98 
99  /// return the minimal and maximal rapidity of this range
100  virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
101  rapmin = _rapjet - _distance;
102  rapmax = _rapjet + _distance; }
103 
104 private:
105  double _distance;
106 
107  /// value for phi that marks it as invalid
108  const static double _invalid_phi = -1000.0;
109  /// set internal phi so as to mark things as invalid
110  void _set_invalid_rapphi() {_phijet = _invalid_phi;}
111  /// true if rap,phi are valid (tests only phi)
112  bool _rapphi_are_valid() const {return _phijet != _invalid_phi;}
113 };
114 
115 FASTJET_END_NAMESPACE
116 
117 #endif // __FASTJET_CIRCULARRANGE_HH__
double rap() const
returns the rapidity or some large value when the rapidity is infinite
Definition: PseudoJet.hh:123
virtual void get_rap_limits(double &rapmin, double &rapmax) const
return the minimal and maximal rapidity of this range; remember to replace this if you write a derive...
class for holding a range definition specification, given by limits on rapidity and azimuth...
virtual bool is_localizable() const
returns true if the range is localizable (i.e.
bool is_in_range(const PseudoJet &jet) const
return bool according to whether the jet is within the given range
double phi() const
returns phi (in the range 0..2pi)
Definition: PseudoJet.hh:108
virtual std::string description() const
textual description of range
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
Definition: PseudoJet.hh:67