Fork me on GitHub

source: svn/trunk/external/fastjet/RangeDefinition.hh@ 1379

Last change on this file since 1379 was 859, checked in by Pavel Demin, 12 years ago

update fastjet to version 3.0.3

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