00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __FASTJET_RANGEDEFINITION_HH__
00032 #define __FASTJET_RANGEDEFINITION_HH__
00033
00034 #include "fastjet/PseudoJet.hh"
00035 #include "fastjet/Error.hh"
00036 #include<sstream>
00037 #include<iostream>
00038 #include<string>
00039
00040 FASTJET_BEGIN_NAMESPACE
00041
00042
00043
00049 class RangeDefinition {
00050 public:
00052 RangeDefinition() {}
00053
00055 RangeDefinition(double rapmax) {
00056 assert ( rapmax > 0.0 );
00057 _rapmax = rapmax;
00058 _rapmin = -rapmax;
00059 _phimin = 0.0;
00060 _phimax = twopi;
00061 _total_area = 2.0*rapmax*twopi;
00062 _phispan = _phimax-_phimin; }
00063
00065 virtual ~RangeDefinition() {}
00066
00069 RangeDefinition(double rapmin, double rapmax,
00070 double phimin = 0.0, double phimax = twopi) {
00071 assert ( rapmin < rapmax);
00072 assert ( phimin < phimax);
00073 assert ( phimin > -twopi );
00074 assert ( phimax < 2*twopi);
00075 _rapmax = rapmax;
00076 _rapmin = rapmin;
00077 _phimin = phimin;
00078 _phimax = phimax;
00079 if (_phimax-_phimin > twopi)
00080 _total_area = (_rapmax - _rapmin)*twopi;
00081 else
00082 _total_area = (_rapmax - _rapmin)*(_phimax - _phimin);
00083 _phispan = _phimax-_phimin; }
00084
00093 virtual inline bool is_localizable() const { return false; }
00094
00095
00102 inline void set_position(const double & rap, const double & phi) {
00103 if (! is_localizable() ) {
00104 std::ostringstream err;
00105 err << description() <<
00106 "\nThis range is not localizable. set_position() should not be used on it.";
00107 throw fastjet::Error(err.str());
00108 } else {
00109 _rapjet = rap;
00110 _phijet = phi;
00111 }
00112 }
00113
00115 inline void set_position(const PseudoJet & jet) {
00116 set_position(jet.rap(),jet.phi());
00117 }
00118
00120 inline bool is_in_range(const PseudoJet & jet) const {
00121 double rap = jet.rap();
00122 double phi = jet.phi();
00123 return is_in_range(rap,phi);
00124 }
00125
00127 virtual inline bool is_in_range(double rap, double phi) const {
00128 double dphi=phi-_phimin;
00129 if (dphi >= twopi) dphi -= twopi;
00130 if (dphi < 0) dphi += twopi;
00131 return ( rap >= _rapmin &&
00132 rap <= _rapmax &&
00133 dphi <= _phispan );
00134 }
00135
00138 virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
00139 rapmin = _rapmin;
00140 rapmax = _rapmax;
00141 }
00142
00144 virtual inline double area() const { return _total_area; }
00145
00147 virtual inline std::string description() const {
00148 std::ostringstream ostr;
00149 ostr << "Range: " << _rapmin << " <= y <= " << _rapmax << ", "
00150 << _phimin << " <= phi <= " << _phimax ;
00151 return ostr.str();
00152 }
00153
00154 protected:
00155 double _total_area;
00156
00161 void _numerical_total_area(double rapmax, int npoints) ;
00162 double _rapjet,_phijet;
00163
00164 private:
00165 double _rapmin,_rapmax,_phimin,_phimax,_phispan;
00166
00167 };
00168
00169 FASTJET_END_NAMESPACE
00170
00171 #endif // __FASTJET_RANGEDEFINITION_HH__