fastjet 2.4.5
|
00001 //STARTHEADER 00002 // $Id: RangeDefinition.hh 1404 2009-01-21 18:43:57Z salam $ 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 // 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; // total area of specified range 00154 00159 void _numerical_total_area(double rapmax, int npoints) ; 00160 double _rapjet,_phijet; // jet position. only used in localizable derived classes 00161 00162 private: 00163 double _rapmin,_rapmax,_phimin,_phimax,_phispan; 00164 00165 }; 00166 00167 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh 00168 00169 #endif // __FASTJET_RANGEDEFINITION_HH__