|
[Rivet-svn] r4120 - in trunk: . doc include/Rivet include/Rivet/Math srcblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Feb 1 17:32:58 GMT 2013
Author: buckley Date: Fri Feb 1 17:32:57 2013 New Revision: 4120 Log: Fixes to Vector3::azimuthalAngle and Vector3::polarAngle calculation (using the mapAngle functions). Adding an element to the PhiMapping enum and a new mapAngle(angle, mapping) function. Modified: trunk/ChangeLog trunk/configure.ac trunk/doc/mk-analysis-html trunk/include/Rivet/Exceptions.hh trunk/include/Rivet/Math/MathHeader.hh trunk/include/Rivet/Math/MathUtils.hh trunk/include/Rivet/Math/Vector3.hh trunk/src/Makefile.am Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/ChangeLog Fri Feb 1 17:32:57 2013 (r4120) @@ -1,3 +1,9 @@ +2013-02-01 Andy Buckley <andy.buckley at cern.ch> + + * Adding an element to the PhiMapping enum and a new mapAngle(angle, mapping) function. + + * Fixes to Vector3::azimuthalAngle and Vector3::polarAngle calculation (using the mapAngle functions). + 2013-01-25 Frank Siegert <frank.siegert at cern.ch> * Split MC_*JETS analyses into three separate bits: Modified: trunk/configure.ac ============================================================================== --- trunk/configure.ac Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/configure.ac Fri Feb 1 17:32:57 2013 (r4120) @@ -66,7 +66,7 @@ AC_CHECK_HEADER([boost/smart_ptr.hpp], [], [AC_MSG_ERROR([Boost smart_ptr not found. $BOOSTERRMSG])]) AC_CHECK_HEADER([boost/lexical_cast.hpp], [], [AC_MSG_ERROR([Boost lexical_cast not found. $BOOSTERRMSG])]) AC_CHECK_HEADER([boost/assign.hpp], [], [AC_MSG_ERROR([Boost assign not found. $BOOSTERRMSG])]) -AC_CHECK_HEADER([boost/random.hpp], [], [AC_MSG_ERROR([Boost random numbers not found. $BOOSTERRMSG])]) +#AC_CHECK_HEADER([boost/random.hpp], [], [AC_MSG_ERROR([Boost random numbers not found. $BOOSTERRMSG])]) CPPFLAGS=$oldCPPFLAGS ## YODA library Modified: trunk/doc/mk-analysis-html ============================================================================== --- trunk/doc/mk-analysis-html Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/doc/mk-analysis-html Fri Feb 1 17:32:57 2013 (r4120) @@ -45,6 +45,7 @@ def htmlify(s, para=False): # TODO: also replace LaTeX like \text, $$, \le, \ge, \mathrm, \emph, etc. + # TODO: replace the &, <, > etc. with .encode("xmlcharrefreplace")? Or does that encode *all* characters? t = s \ .replace("&", "&") \ .replace(">", ">") \ Modified: trunk/include/Rivet/Exceptions.hh ============================================================================== --- trunk/include/Rivet/Exceptions.hh Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/include/Rivet/Exceptions.hh Fri Feb 1 17:32:57 2013 (r4120) @@ -41,6 +41,7 @@ /// @brief Errors relating to event/bin weights + /// /// Arises in computing statistical quantities because e.g. the bin /// weight is zero or negative. class WeightError : public Error { @@ -49,6 +50,13 @@ }; + /// @brief Error specialisation for where the problem is between the chair and computer. + class UserError : public Error { + public: + UserError(const std::string& what) : Error(what) {} + }; + + } #endif Modified: trunk/include/Rivet/Math/MathHeader.hh ============================================================================== --- trunk/include/Rivet/Math/MathHeader.hh Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/include/Rivet/Math/MathHeader.hh Fri Feb 1 17:32:57 2013 (r4120) @@ -1,6 +1,7 @@ #ifndef RIVET_Math_MathHeader #define RIVET_Math_MathHeader +#include "Rivet/Exceptions.hh" #include <stdexcept> #include <string> #include <ostream> @@ -59,7 +60,7 @@ enum RapScheme { PSEUDORAPIDITY = 0, ETA = 0, RAPIDITY = 1, YRAP = 1 }; /// Enum for range of \f$ \phi \f$ to be mapped into - enum PhiMapping { MINUSPI_PLUSPI, ZERO_2PI }; + enum PhiMapping { MINUSPI_PLUSPI, ZERO_2PI, ZERO_PI }; } Modified: trunk/include/Rivet/Math/MathUtils.hh ============================================================================== --- trunk/include/Rivet/Math/MathUtils.hh Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/include/Rivet/Math/MathUtils.hh Fri Feb 1 17:32:57 2013 (r4120) @@ -399,6 +399,20 @@ return rtn; } + /// Map an angle into the enum-specified range. + inline double mapAngle(double angle, PhiMapping mapping) { + switch (mapping) { + case MINUSPI_PLUSPI: + return mapAngleMPiToPi(angle); + case ZERO_2PI: + return mapAngle0To2Pi(angle); + case ZERO_PI: + return mapAngle0To2Pi(angle); + default: + throw Rivet::UserError("The specified phi mapping scheme is not implemented"); + } + } + //@} Modified: trunk/include/Rivet/Math/Vector3.hh ============================================================================== --- trunk/include/Rivet/Math/Vector3.hh Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/include/Rivet/Math/Vector3.hh Fri Feb 1 17:32:57 2013 (r4120) @@ -124,34 +124,9 @@ // If this is a null vector, return zero rather than let atan2 set an error state if (Rivet::isZero(mod2())) return 0.0; - // Calculate the arctan and correct for numerical boundary cases - double value = atan2( y(), x() ); - if (value > 2*PI || value < -2*PI){ - value = fmod(value, 2*PI); - } - if (value <= -PI) value += 2*PI; - if (value > PI) value -= 2*PI; - - // Return in the requested range - switch (mapping) { - case MINUSPI_PLUSPI: - assert(value > -PI && value <= PI); - return value; - case ZERO_2PI: - if (value >= 0) { - assert(value >= 0 && value < 2*PI); - return value; - } else if (Rivet::isZero(value)) { - value = 0.0; - return value; - } else { - value = 2*PI + value; - assert(value >= 0 && value < 2*PI); - return value; - } - default: - throw std::runtime_error("The specified phi mapping scheme is not yet implemented"); - } + // Calculate the arctan and return in the requested range + const double value = atan2( y(), x() ); + return mapAngle(value, mapping); } /// Synonym for azimuthalAngle. @@ -162,9 +137,8 @@ /// Angle subtended by the vector and the z-axis. double polarAngle() const { // Get number beween [0,PI] - double polarangle = atan2(polarRadius(), z()); - assert(polarangle >= -PI && polarangle <= PI); - return polarangle; + const double polarangle = atan2(polarRadius(), z()); + return mapAngle0ToPi(polarangle); } /// Synonym for polarAngle Modified: trunk/src/Makefile.am ============================================================================== --- trunk/src/Makefile.am Fri Feb 1 11:27:34 2013 (r4119) +++ trunk/src/Makefile.am Fri Feb 1 17:32:57 2013 (r4120) @@ -14,11 +14,10 @@ -L$(HEPMCLIBPATH) -R$(HEPMCLIBPATH) \ -export-dynamic $(VERSIONINFOFLAGS) -libRivet_la_LIBADD = \ +libRivet_la_LIBADD = \ Core/libRivetCore.la \ Projections/libRivetProjections.la \ Tools/libRivetTools.la \ Analyses/libRivetAnalysisTools.la \ - -ldl -lm -lYODA -lHepMC \ + -ldl -lm -lYODA -lHepMC \ $(GSL_LDFLAGS) $(FASTJETCONFIGLIBADD) -
More information about the Rivet-svn mailing list |