RangeDefinition.hh
Go to the documentation of this file.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
00047 class RangeDefinition {
00048 public:
00050 RangeDefinition() {}
00051
00053 RangeDefinition(double rapmax) {
00054 assert ( rapmax > 0.0 );
00055 _rapmax = rapmax;
00056 _rapmin = -rapmax;
00057 _phimin = 0.0;
00058 _phimax = twopi;
00059 _total_area = 2.0*rapmax*twopi;
00060 _phispan = _phimax-_phimin; }
00061
00063 virtual ~RangeDefinition() {}
00064
00067 RangeDefinition(double rapmin, double rapmax,
00068 double phimin = 0.0, double phimax = twopi) {
00069 assert ( rapmin < rapmax);
00070 assert ( phimin < phimax);
00071 assert ( phimin > -twopi );
00072 assert ( phimax < 2*twopi);
00073 _rapmax = rapmax;
00074 _rapmin = rapmin;
00075 _phimin = phimin;
00076 _phimax = phimax;
00077 if (_phimax-_phimin > twopi)
00078 _total_area = (_rapmax - _rapmin)*twopi;
00079 else
00080 _total_area = (_rapmax - _rapmin)*(_phimax - _phimin);
00081 _phispan = _phimax-_phimin; }
00082
00091 virtual inline bool is_localizable() const { return false; }
00092
00093
00100 inline void set_position(const double & rap, const double & phi) {
00101 if (! is_localizable() ) {
00102 std::ostringstream err;
00103 err << description() <<
00104 "\nThis range is not localizable. set_position() should not be used on it.";
00105 throw fastjet::Error(err.str());
00106 } else {
00107 _rapjet = rap;
00108 _phijet = phi;
00109 }
00110 }
00111
00113 inline void set_position(const PseudoJet & jet) {
00114 set_position(jet.rap(),jet.phi());
00115 }
00116
00118 inline bool is_in_range(const PseudoJet & jet) const {
00119 double rap = jet.rap();
00120 double phi = jet.phi();
00121 return is_in_range(rap,phi);
00122 }
00123
00125 virtual inline bool is_in_range(double rap, double phi) const {
00126 double dphi=phi-_phimin;
00127 if (dphi >= twopi) dphi -= twopi;
00128 if (dphi < 0) dphi += twopi;
00129 return ( rap >= _rapmin &&
00130 rap <= _rapmax &&
00131 dphi <= _phispan );
00132 }
00133
00136 virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
00137 rapmin = _rapmin;
00138 rapmax = _rapmax;
00139 }
00140
00142 virtual inline double area() const { return _total_area; }
00143
00145 virtual inline std::string description() const {
00146 std::ostringstream ostr;
00147 ostr << "Range: " << _rapmin << " <= y <= " << _rapmax << ", "
00148 << _phimin << " <= phi <= " << _phimax ;
00149 return ostr.str();
00150 }
00151
00152 protected:
00153 double _total_area;
00154
00159 void _numerical_total_area(double rapmax, int npoints) ;
00160 double _rapjet,_phijet;
00161
00162 private:
00163 double _rapmin,_rapmax,_phimin,_phimax,_phispan;
00164
00165 };
00166
00167 FASTJET_END_NAMESPACE
00168
00169 #endif // __FASTJET_RANGEDEFINITION_HH__