|
[Rivet-svn] rivet: 4 new changesetsRivet Mercurial rivet at projects.hepforge.orgWed Apr 6 17:15:02 BST 2016
details: https://rivet.hepforge.org/hg/rivet/rev/f32dd8ceb704 branches: changeset: 5099:f32dd8ceb704 user: Andy Buckley <andy at insectnation.org> date: Tue Apr 05 21:47:22 2016 +0100 description: Improve binIndex function, with an optional argument to allow overflow lookup, and add it to testMath. details: https://rivet.hepforge.org/hg/rivet/rev/08d434e8c701 branches: changeset: 5100:08d434e8c701 user: Andy Buckley <andy at insectnation.org> date: Wed Apr 06 10:49:12 2016 +0100 description: Use improved binIndex function to implement electron smearing details: https://rivet.hepforge.org/hg/rivet/rev/beec2971712e branches: changeset: 5101:beec2971712e user: Andy Buckley <andy at insectnation.org> date: Wed Apr 06 15:39:37 2016 +0100 description: More smearing & efficiency functions details: https://rivet.hepforge.org/hg/rivet/rev/6c8bf18254dd branches: changeset: 5102:6c8bf18254dd user: Andy Buckley <andy at insectnation.org> date: Wed Apr 06 17:12:46 2016 +0100 description: Add some electron smearing and jet/electron multiplicity plots to EXAMPLE_SMEAR diffs (truncated from 380 to 50 lines): --- a/ChangeLog Tue Apr 05 15:08:45 2016 +0100 +++ b/ChangeLog Wed Apr 06 17:12:46 2016 +0100 @@ -1,5 +1,8 @@ 2016-04-05 Andy Buckley <andy.buckley at cern.ch> + * Improve binIndex function, with an optional argument to allow + overflow lookup, and add it to testMath. + * Adding setPE, setPM, setPtEtaPhiM, etc. methods and corresponding mk* static methods to FourMomentum, as well as adding more convenience aliases and vector attributes for --- a/include/Rivet/Math/MathUtils.hh Tue Apr 05 15:08:45 2016 +0100 +++ b/include/Rivet/Math/MathUtils.hh Wed Apr 06 17:12:46 2016 +0100 @@ -331,22 +331,24 @@ /// @brief Return the bin index of the given value, @a val, given a vector of bin edges /// - /// NB. The @a binedges vector must be sorted + /// @note The @a binedges vector must be sorted + /// @todo Use std::common_type<NUM1, NUM2>::type x = val; ? template <typename NUM1, typename NUM2> inline typename std::enable_if<std::is_arithmetic<NUM1>::value && std::is_floating_point<NUM2>::value, int>::type - binIndex(NUM1 val, const vector<NUM2>& binedges) { - /// @todo Use std::common_type<NUM1, NUM2>::type x = val; ? - /// @todo Add linear & log guesses, and binary split via upper_bound for large binnings - if (!inRange(val, binedges.front(), binedges.back())) return -1; ///< Out of histo range - int index = -1; - for (size_t i = 1; i < binedges.size(); ++i) { - if (val < binedges[i]) { - index = i-1; - break; - } - } - assert(inRange(index, -1, int(binedges.size())-1)); - return index; + binIndex(NUM1 val, const vector<NUM2>& binedges, bool allow_overflow=false) { + if (val < binedges.front()) return -1; ///< Below/out of histo range + if (val >= binedges.back()) return allow_overflow ? int(binedges.size())-1 : -1; ///< Above/out of histo range + return std::distance(binedges.begin(), --std::upper_bound(binedges.begin(), binedges.end(), val)); + // + // int index = -1; + // for (size_t i = 1; i < binedges.size(); ++i) { + // if (val < binedges[i]) { + // index = i-1; + // break; + // } + // } + // assert(inRange(index, -1, int(binedges.size())-1)); + // return index; }
More information about the Rivet-svn mailing list |