|
[Rivet-svn] r4016 - in branches/2012-06-aidarivet: . include/Rivet include/Rivet/Math src/Analyses src/Core src/Projections testblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Nov 14 19:06:44 GMT 2012
Author: buckley Date: Wed Nov 14 19:06:44 2012 New Revision: 4016 Log: Converting the argument order of logspace, clarifying the arguments, updating affected code, and deprecating Analysis::logBinEdges. Modified: branches/2012-06-aidarivet/ChangeLog branches/2012-06-aidarivet/include/Rivet/Analysis.hh branches/2012-06-aidarivet/include/Rivet/Math/MathUtils.hh branches/2012-06-aidarivet/src/Analyses/MC_PDFS.cc branches/2012-06-aidarivet/src/Analyses/MC_TTBAR.cc branches/2012-06-aidarivet/src/Core/Analysis.cc branches/2012-06-aidarivet/src/Projections/JetShape.cc branches/2012-06-aidarivet/test/testMath.cc Modified: branches/2012-06-aidarivet/ChangeLog ============================================================================== --- branches/2012-06-aidarivet/ChangeLog Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/ChangeLog Wed Nov 14 19:06:44 2012 (r4016) @@ -4,6 +4,9 @@ 2012-11-14 Andy Buckley <andy.buckley at cern.ch> + * Converting the argument order of logspace, clarifying the + arguments, updating affected code, and deprecating Analysis::logBinEdges. + * Merging updates from the AIDA maintenance branch up to r3974 (latest revision for next merges is r4009). Modified: branches/2012-06-aidarivet/include/Rivet/Analysis.hh ============================================================================== --- branches/2012-06-aidarivet/include/Rivet/Analysis.hh Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/include/Rivet/Analysis.hh Wed Nov 14 19:06:44 2012 (r4016) @@ -392,7 +392,9 @@ /// Get bin edges for a numbered histo (using ref AIDA caching) const BinEdges& binEdges(size_t datasetId, size_t xAxisId, size_t yAxisId) const; - /// Get bin edges with logarithmic widths + /// @brief Get bin edges with logarithmic widths + /// + /// @deprecated Prefer logspace. This will disappear in Rivet 2.0.0 BinEdges logBinEdges(size_t nbins, double lower, double upper); /// Book a 1D histogram with @a nbins uniformly distributed across the range @a lower - @a upper . Modified: branches/2012-06-aidarivet/include/Rivet/Math/MathUtils.hh ============================================================================== --- branches/2012-06-aidarivet/include/Rivet/Math/MathUtils.hh Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/include/Rivet/Math/MathUtils.hh Wed Nov 14 19:06:44 2012 (r4016) @@ -208,8 +208,11 @@ /// @name Binning helper functions //@{ - /// Make a list of @a nbins + 1 values equally spaced between @a start and @a end inclusive. - inline vector<double> linspace(double start, double end, size_t nbins) { + /// @brief Make a list of @a nbins + 1 values equally spaced between @a start and @a end inclusive. + /// + /// NB. The arg ordering and the meaning of the nbins variable is "histogram-like", + /// as opposed to the Numpy/Matlab version. + inline vector<double> linspace(size_t nbins, double start, double end) { assert(end >= start); assert(nbins > 0); vector<double> rtn; @@ -224,14 +227,18 @@ } - /// Make a list of @a nbins + 1 values exponentially spaced between @a start and @a end inclusive. - inline vector<double> logspace(double start, double end, size_t nbins) { + /// @brief Make a list of @a nbins + 1 values exponentially spaced between @a start and @a end inclusive. + /// + /// NB. The arg ordering and the meaning of the nbins variable is "histogram-like", + /// as opposed to the Numpy/Matlab version, and the start and end arguments are expressed + /// in "normal" space, rather than as the logarithms of the start/end values as in Numpy/Matlab. + inline vector<double> logspace(size_t nbins, double start, double end) { assert(end >= start); assert(start > 0); assert(nbins > 0); const double logstart = std::log(start); const double logend = std::log(end); - const vector<double> logvals = linspace(logstart, logend, nbins); + const vector<double> logvals = linspace(nbins, logstart, logend); assert(logvals.size() == nbins+1); vector<double> rtn; foreach (double logval, logvals) { Modified: branches/2012-06-aidarivet/src/Analyses/MC_PDFS.cc ============================================================================== --- branches/2012-06-aidarivet/src/Analyses/MC_PDFS.cc Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/src/Analyses/MC_PDFS.cc Wed Nov 14 19:06:44 2012 (r4016) @@ -28,12 +28,12 @@ // addProjection(ChargedFinalState(-5.0, 5.0, 500*MeV), "CFS"); // Histograms - _histPdfX = bookHistogram1D("PdfX", logspace(0.000001, 1.0, 50)); - _histPdfXmin = bookHistogram1D("PdfXmin", logspace(0.000001, 1.0, 50)); - _histPdfXmax = bookHistogram1D("PdfXmax", logspace(0.000001, 1.0, 50)); + _histPdfX = bookHistogram1D("PdfX", logspace(50, 0.000001, 1.0)); + _histPdfXmin = bookHistogram1D("PdfXmin", logspace(50, 0.000001, 1.0)); + _histPdfXmax = bookHistogram1D("PdfXmax", logspace(50, 0.000001, 1.0)); _histPdfQ = bookHistogram1D("PdfQ", 50, 0.0, 30.0); - // _histPdfXQ = bookHistogram2D("PdfXQ", logspace(0.000001, 1.0, 50), linspace(0.0, 30.0, 50)); - // _histPdfTrackptVsX = bookProfile1D("PdfTrackptVsX", logspace(0.000001, 1.0, 50)); + // _histPdfXQ = bookHistogram2D("PdfXQ", logspace(50, 0.000001, 1.0), linspace(50, 0.0, 30.0)); + // _histPdfTrackptVsX = bookProfile1D("PdfTrackptVsX", logspace(50, 0.000001, 1.0)); // _histPdfTrackptVsQ = bookProfile1D("PdfTrackptVsQ", 50, 0.0, 30.0); } Modified: branches/2012-06-aidarivet/src/Analyses/MC_TTBAR.cc ============================================================================== --- branches/2012-06-aidarivet/src/Analyses/MC_TTBAR.cc Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/src/Analyses/MC_TTBAR.cc Wed Nov 14 19:06:44 2012 (r4016) @@ -41,17 +41,17 @@ // Booking of histograms _h_njets = bookHistogram1D("jet_mult", 11, -0.5, 10.5); // - _h_jet_1_pT = bookHistogram1D("jet_1_pT", logspace(20.0, 500.0, 50)); - _h_jet_2_pT = bookHistogram1D("jet_2_pT", logspace(20.0, 400.0, 50)); - _h_jet_3_pT = bookHistogram1D("jet_3_pT", logspace(20.0, 300.0, 50)); - _h_jet_4_pT = bookHistogram1D("jet_4_pT", logspace(20.0, 200.0, 50)); - _h_jet_HT = bookHistogram1D("jet_HT", logspace(100.0, 2000.0, 50)); + _h_jet_1_pT = bookHistogram1D("jet_1_pT", logspace(50, 20.0, 500.0)); + _h_jet_2_pT = bookHistogram1D("jet_2_pT", logspace(50, 20.0, 400.0)); + _h_jet_3_pT = bookHistogram1D("jet_3_pT", logspace(50, 20.0, 300.0)); + _h_jet_4_pT = bookHistogram1D("jet_4_pT", logspace(50, 20.0, 200.0)); + _h_jet_HT = bookHistogram1D("jet_HT", logspace(50, 100.0, 2000.0)); // - _h_bjet_1_pT = bookHistogram1D("jetb_1_pT", logspace(20.0, 400.0, 50)); - _h_bjet_2_pT = bookHistogram1D("jetb_2_pT", logspace(20.0, 300.0, 50)); + _h_bjet_1_pT = bookHistogram1D("jetb_1_pT", logspace(50, 20.0, 400.0)); + _h_bjet_2_pT = bookHistogram1D("jetb_2_pT", logspace(50, 20.0, 300.0)); // - _h_ljet_1_pT = bookHistogram1D("jetl_1_pT", logspace(20.0, 400.0, 50)); - _h_ljet_2_pT = bookHistogram1D("jetl_2_pT", logspace(20.0, 300.0, 50)); + _h_ljet_1_pT = bookHistogram1D("jetl_1_pT", logspace(50, 20.0, 400.0)); + _h_ljet_2_pT = bookHistogram1D("jetl_2_pT", logspace(50, 20.0, 300.0)); // _h_W_mass = bookHistogram1D("W_mass", 75, 30, 180); _h_t_mass = bookHistogram1D("t_mass", 150, 130, 430); Modified: branches/2012-06-aidarivet/src/Core/Analysis.cc ============================================================================== --- branches/2012-06-aidarivet/src/Core/Analysis.cc Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/src/Core/Analysis.cc Wed Nov 14 19:06:44 2012 (r4016) @@ -227,18 +227,10 @@ BinEdges Analysis::logBinEdges(size_t nbins, double lower, double upper) { - assert(lower>0.0); - assert(upper>lower); - double loglower=log10(lower); - double logupper=log10(upper); - vector<double> binedges; - double stepwidth=(logupper-loglower)/double(nbins); - for (size_t i=0; i<=nbins; ++i) { - binedges.push_back(pow(10.0, loglower+double(i)*stepwidth)); - } - return binedges; + return logspace(nbins, lower, upper); } + IHistogram1D* Analysis::bookHistogram1D(size_t datasetId, size_t xAxisId, size_t yAxisId, const string& title, const string& xtitle, const string& ytitle) Modified: branches/2012-06-aidarivet/src/Projections/JetShape.cc ============================================================================== --- branches/2012-06-aidarivet/src/Projections/JetShape.cc Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/src/Projections/JetShape.cc Wed Nov 14 19:06:44 2012 (r4016) @@ -14,7 +14,7 @@ : _rapscheme(rapscheme) { setName("JetShape"); - _binedges = linspace(rmin, rmax, nbins); + _binedges = linspace(nbins, rmin, rmax); _ptcuts = make_pair(ptmin, ptmax); _rapcuts = make_pair(absrapmin, absrapmax); addProjection(jetalg, "Jets"); Modified: branches/2012-06-aidarivet/test/testMath.cc ============================================================================== --- branches/2012-06-aidarivet/test/testMath.cc Wed Nov 14 19:01:56 2012 (r4015) +++ branches/2012-06-aidarivet/test/testMath.cc Wed Nov 14 19:06:44 2012 (r4016) @@ -21,18 +21,18 @@ //////////// - linspace(0, 10, 50); - logspace(0.000001, 1.0, 50); + linspace(50, 0, 10); + logspace(50, 0.000001, 1.0); -// // These tests are disabled, because they trigger compiler warnings on SL5 -// inRange(1, 0, 2); -// inRange(1, 0.0, 2); -// inRange(1, 0, 2.0); -// inRange(1, 0.0, 2.0); -// inRange(1.0, 0, 2); -// inRange(1.0, 0.0, 2); -// inRange(1.0, 0, 2.0); -// inRange(1.0, 0.0, 2.0); + /// @todo Compiler warnings on SLC5... reinstate + // inRange(1, 0, 2); + // inRange(1, 0.0, 2); + // inRange(1, 0, 2.0); + // inRange(1, 0.0, 2.0); + // inRange(1.0, 0, 2); + // inRange(1.0, 0.0, 2); + // inRange(1.0, 0, 2.0); + // inRange(1.0, 0.0, 2.0); assert(isZero(1e-15)); assert(fuzzyEquals(1e-15, 0.0));
More information about the Rivet-svn mailing list |