Fork me on GitHub

source: git/external/fastjet/RangeDefinition.hh@ f9517a5

Last change on this file since f9517a5 was b7b836a, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

update FastJet library to 3.3.1 and FastJet Contrib library to 1.036

  • Property mode set to 100644
File size: 6.6 KB
Line 
1//FJSTARTHEADER
2// $Id: RangeDefinition.hh 4354 2018-04-22 07:12:37Z salam $
3//
4// Copyright (c) 2005-2018, 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#ifndef __FASTJET_RANGEDEFINITION_HH__
32#define __FASTJET_RANGEDEFINITION_HH__
33
34#include "fastjet/PseudoJet.hh"
35#include "fastjet/Error.hh"
36#include "fastjet/LimitedWarning.hh"
37#include "fastjet/internal/deprecated.hh"
38#include<sstream>
39#include<iostream>
40#include<string>
41
42FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
43
44//----------------------------------------------------------------------
45//
46/// @ingroup area_classes
47/// \class RangeDefinition
48/// class for holding a range definition specification, given by limits
49/// on rapidity and azimuth.
50///
51class RangeDefinition {
52public:
53 /// default constructor
54 FASTJET_DEPRECATED_MSG("RangeDefinition is deprecated since FastJet 3.0. Use the Selector mechanism instead")
55 RangeDefinition() { _warn_deprecated(); }
56
57 /// constructor for a range definition given by |y|<rapmax
58 FASTJET_DEPRECATED_MSG("RangeDefinition is deprecated since FastJet 3.0. Use the Selector mechanism instead")
59 RangeDefinition(double rapmax) { _warn_deprecated();
60 assert ( rapmax > 0.0 );
61 _rapmax = rapmax;
62 _rapmin = -rapmax;
63 _phimin = 0.0;
64 _phimax = twopi;
65 _total_area = 2.0*rapmax*twopi;
66 _phispan = _phimax-_phimin; }
67
68 /// destructor does nothing
69 virtual ~RangeDefinition() {}
70
71 /// constructor for a range definition given by
72 /// rapmin <= y <= rapmax, phimin <= phi <= phimax
73 RangeDefinition(double rapmin, double rapmax,
74 double phimin = 0.0, double phimax = twopi) {
75 _warn_deprecated();
76 assert ( rapmin < rapmax);
77 assert ( phimin < phimax);
78 assert ( phimin > -twopi );
79 assert ( phimax < 2*twopi);
80 _rapmax = rapmax;
81 _rapmin = rapmin;
82 _phimin = phimin;
83 _phimax = phimax;
84 if (_phimax-_phimin > twopi)
85 _total_area = (_rapmax - _rapmin)*twopi;
86 else
87 _total_area = (_rapmax - _rapmin)*(_phimax - _phimin);
88 _phispan = _phimax-_phimin; }
89
90 /// returns true if the range is localizable (i.e. set_position is
91 /// meant to do something meaningful).
92 ///
93 /// This version of the class is not localizable and so it returns
94 /// false.
95 ///
96 /// For localizable classes override this function with a function
97 /// that returns true
98 virtual inline bool is_localizable() const { return false; }
99
100
101 /// place the range on the rap-phi position
102 ///
103 /// THIS DOES NOT DO ANYTHING FOR THIS CLASS AND IS ONLY THERE
104 /// TO FACILITATE DERIVED CLASSES
105 ///
106 /// DON'T NECESSARILY COUNT ON IT IN THE FUTURE EITHER???
107 inline void set_position(const double & rap, const double & phi) {
108 if (! is_localizable() ) {
109 std::ostringstream err;
110 err << description() <<
111 "\nThis range is not localizable. set_position() should not be used on it.";
112 throw Error(err.str());
113 } else {
114 _rapjet = rap;
115 _phijet = phi;
116 }
117 }
118
119 /// place the range on the jet position
120 inline void set_position(const PseudoJet & jet) {
121 set_position(jet.rap(),jet.phi());
122 }
123
124 /// return bool according to whether the jet is within the given range
125 inline bool is_in_range(const PseudoJet & jet) const {
126 double rap = jet.rap();
127 double phi = jet.phi();
128 return is_in_range(rap,phi);
129 }
130
131 /// return bool according to whether a (rap,phi) point is in range
132 virtual inline bool is_in_range(double rap, double phi) const {
133 double dphi=phi-_phimin;
134 if (dphi >= twopi) dphi -= twopi;
135 if (dphi < 0) dphi += twopi;
136 return ( rap >= _rapmin &&
137 rap <= _rapmax &&
138 dphi <= _phispan );
139 }
140
141 /// return the minimal and maximal rapidity of this range; remember to
142 /// replace this if you write a derived class with more complex ranges;
143 virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
144 rapmin = _rapmin;
145 rapmax = _rapmax;
146 }
147
148 /// area of the range region
149 virtual inline double area() const { return _total_area; }
150
151 /// textual description of range
152 virtual inline std::string description() const {
153 std::ostringstream ostr;
154 ostr << "Range: " << _rapmin << " <= y <= " << _rapmax << ", "
155 << _phimin << " <= phi <= " << _phimax ;
156 return ostr.str();
157}
158
159protected:
160 double _total_area; // total area of specified range
161
162 /// calculate, and set _total_area, by calculating which of points on
163 /// a grid (npoints * npoints from -rapmax..rapmax,0..2pi) are contained
164 /// in the range; it takes a reasonable time with rapmax = 10,
165 /// npoints = 100.
166 void _numerical_total_area(double rapmax, int npoints) ;
167 double _rapjet,_phijet; // jet position. only used in localizable derived classes
168
169private:
170 double _rapmin,_rapmax,_phimin,_phimax,_phispan;
171
172 static LimitedWarning _warnings_deprecated;
173
174 /// the use of RangeDefinition is deprecated since FastJet version
175 /// 3.0 onwards. Please use Selector instead.
176 /// RangeDefinition is only provided for backward compatibility
177 /// reasons and is not guaranteed to work in future releases of
178 /// FastJet.
179 void _warn_deprecated() const;
180};
181
182FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
183
184#endif // __FASTJET_RANGEDEFINITION_HH__
Note: See TracBrowser for help on using the repository browser.