|
FastJet 3.0alpha3
|
00001 //STARTHEADER 00002 // $Id: RangeDefinition.hh 2039 2011-04-12 08:29:13Z soyez $ 00003 // 00004 // Copyright (c) 2005-2007, Matteo Cacciari and Gavin Salam 00005 // 00006 //---------------------------------------------------------------------- 00007 // This file is part of FastJet. 00008 // 00009 // FastJet is free software; you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // The algorithms that underlie FastJet have required considerable 00015 // development and are described in hep-ph/0512210. If you use 00016 // FastJet as part of work towards a scientific publication, please 00017 // include a citation to the FastJet paper. 00018 // 00019 // FastJet is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with FastJet; if not, write to the Free Software 00026 // Foundation, Inc.: 00027 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 //---------------------------------------------------------------------- 00029 //ENDHEADER 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 // defined in fastjet/internal/base.hh 00041 00042 //---------------------------------------------------------------------- 00043 // 00044 /// @ingroup area_classes 00045 /// \class RangeDefinition 00046 /// class for holding a range definition specification, given by limits 00047 /// on rapidity and azimuth. 00048 /// 00049 class RangeDefinition { 00050 public: 00051 /// default constructor 00052 RangeDefinition() {} 00053 00054 /// constructor for a range definition given by |y|<rapmax 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 00064 /// destructor does nothing 00065 virtual ~RangeDefinition() {} 00066 00067 /// constructor for a range definition given by 00068 /// rapmin <= y <= rapmax, phimin <= phi <= phimax 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 00085 /// returns true if the range is localizable (i.e. set_position is 00086 /// meant to do something meaningful). 00087 /// 00088 /// This version of the class is not localizable and so it returns 00089 /// false. 00090 /// 00091 /// For localizable classes override this function with a function 00092 /// that returns true 00093 virtual inline bool is_localizable() const { return false; } 00094 00095 00096 /// place the range on the rap-phi position 00097 /// 00098 /// THIS DOES NOT DO ANYTHING FOR THIS CLASS AND IS ONLY THERE 00099 /// TO FACILITATE DERIVED CLASSES 00100 /// 00101 /// DON'T NECESSARILY COUNT ON IT IN THE FUTURE EITHER??? 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 00114 /// place the range on the jet position 00115 inline void set_position(const PseudoJet & jet) { 00116 set_position(jet.rap(),jet.phi()); 00117 } 00118 00119 /// return bool according to whether the jet is within the given range 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 00126 /// return bool according to whether a (rap,phi) point is in range 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 00136 /// return the minimal and maximal rapidity of this range; remember to 00137 /// replace this if you write a derived class with more complex ranges; 00138 virtual inline void get_rap_limits(double & rapmin, double & rapmax) const { 00139 rapmin = _rapmin; 00140 rapmax = _rapmax; 00141 } 00142 00143 /// area of the range region 00144 virtual inline double area() const { return _total_area; } 00145 00146 /// textual description of range 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; // total area of specified range 00156 00157 /// calculate, and set _total_area, by calculating which of points on 00158 /// a grid (npoints * npoints from -rapmax..rapmax,0..2pi) are contained 00159 /// in the range; it takes a reasonable time with rapmax = 10, 00160 /// npoints = 100. 00161 void _numerical_total_area(double rapmax, int npoints) ; 00162 double _rapjet,_phijet; // jet position. only used in localizable derived classes 00163 00164 private: 00165 double _rapmin,_rapmax,_phimin,_phimax,_phispan; 00166 00167 }; 00168 00169 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh 00170 00171 #endif // __FASTJET_RANGEDEFINITION_HH__
1.7.4