|
[Rivet-svn] r3380 - in trunk: include/Rivet include/Rivet/Math src/Analysesblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Sep 22 11:23:27 BST 2011
Author: buckley Date: Thu Sep 22 11:23:27 2011 New Revision: 3380 Log: Use std::pow in place of intpow Modified: trunk/include/Rivet/Math/MathUtils.hh trunk/include/Rivet/RivetSTL.hh trunk/src/Analyses/ATLAS_2010_S8894728.cc Modified: trunk/include/Rivet/Math/MathUtils.hh ============================================================================== --- trunk/include/Rivet/Math/MathUtils.hh Thu Sep 22 08:13:50 2011 (r3379) +++ trunk/include/Rivet/Math/MathUtils.hh Thu Sep 22 11:23:27 2011 (r3380) @@ -175,12 +175,10 @@ } /// A more efficient version of pow for raising numbers to integer powers. + /// @deprecated Use std::pow instead template <typename Num> inline Num intpow(Num val, unsigned int exp) { - assert(exp >= 0); - if (exp == 0) return (Num) 1; - else if (exp == 1) return val; - else return val * intpow(val, exp-1); + return std::pow(val, exp); } /// Find the sign of a number Modified: trunk/include/Rivet/RivetSTL.hh ============================================================================== --- trunk/include/Rivet/RivetSTL.hh Thu Sep 22 08:13:50 2011 (r3379) +++ trunk/include/Rivet/RivetSTL.hh Thu Sep 22 11:23:27 2011 (r3380) @@ -43,6 +43,7 @@ using std::cin; using std::cerr; using std::setw; + using std::pow; using std::endl; } Modified: trunk/src/Analyses/ATLAS_2010_S8894728.cc ============================================================================== --- trunk/src/Analyses/ATLAS_2010_S8894728.cc Thu Sep 22 08:13:50 2011 (r3379) +++ trunk/src/Analyses/ATLAS_2010_S8894728.cc Thu Sep 22 11:23:27 2011 (r3380) @@ -165,8 +165,8 @@ const double dEtadPhi = (2*2.5 * 2*PI/3.0); // Transverse profiles need 4 orders of moments for stddev with errors for (int i = 0; i < 4; ++i) { - _hist_nch_transverse_500[i]->fill(pTlead/GeV, intpow(num500[1]/dEtadPhi, i+1), weight); - _hist_ptsum_transverse_500[i]->fill(pTlead/GeV, intpow(ptSum500[1]/GeV/dEtadPhi, i+1), weight); + _hist_nch_transverse_500[i]->fill(pTlead/GeV, pow(num500[1]/dEtadPhi, i+1), weight); + _hist_ptsum_transverse_500[i]->fill(pTlead/GeV, pow(ptSum500[1]/GeV/dEtadPhi, i+1), weight); } // Toward and away profiles only need the first moment (the mean) _hist_nch_toward_500->fill(pTlead/GeV, num500[0]/dEtadPhi, weight); @@ -259,7 +259,7 @@ for (int b = 0; b < target_dps->size(); ++b) { // loop over bins /// @todo Assuming unit weights here! Should use N_effective = sumW**2/sumW2? How? const double numentries = moment_profiles[0]->binEntries(b); - const double var = moment_profiles[1]->binHeight(b) - intpow(moment_profiles[0]->binHeight(b), 2); + const double var = moment_profiles[1]->binHeight(b) - pow(moment_profiles[0]->binHeight(b), 2); const double sd = isZero(var) ? 0 : sqrt(var); //< Numerical safety check target_dps->point(b)->coordinate(1)->setValue(sd); if (sd == 0 || numentries < 3) { @@ -272,9 +272,9 @@ // c2(y) = m4(x) - 4 m3(x) m1(x) - m2(x)^2 + 8 m2(x) m1(x)^2 - 4 m1(x)^4 const double var_on_var = moment_profiles[3]->binHeight(b) - 4 * moment_profiles[2]->binHeight(b) * moment_profiles[0]->binHeight(b) - - intpow(moment_profiles[1]->binHeight(b), 2) - + 8 * moment_profiles[1]->binHeight(b) * intpow(moment_profiles[0]->binHeight(b), 2) - - 4 * intpow(moment_profiles[0]->binHeight(b), 4); + - pow(moment_profiles[1]->binHeight(b), 2) + + 8 * moment_profiles[1]->binHeight(b) * pow(moment_profiles[0]->binHeight(b), 2) + - 4 * pow(moment_profiles[0]->binHeight(b), 4); const double stderr_on_var = sqrt(var_on_var/(numentries-2.0)); const double stderr_on_sd = stderr_on_var / (2.0*sd); target_dps->point(b)->coordinate(1)->setErrorPlus(stderr_on_sd);
More information about the Rivet-svn mailing list |