Fork me on GitHub

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

ImprovedOutputFile Timing dual_readout llp 3.2.0
Last change on this file since dca96ee was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

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