bool histos_equal(const Histogram1D & h1, const Histogram1D & h2){ if(h1.get_nbins()!=h2.get_nbins()) return false; if(h1.get_xmin()!=h2.get_xmin()) return false; if(h1.get_xmax()!=h2.get_xmax()) return false; const size_t n = h1.get_nbins(); for(size_t i=0; i<n; i++){ if(h1.get(i)!=h2.get(i)) return false; } return true; }
void Histogram1D::fail_check_compatibility(const Histogram1D & h) const { std::stringstream s; s << "Histogram1D::check_compatibility: Histograms are not compatible (nbins, xmin, xmax) are: " " (" << get_nbins() << ", " << xmin << ", " << xmax << ") and " " (" << h.get_nbins() << ", " << h.xmin << ", " << h.xmax << ")"; throw invalid_argument(s.str()); }
//note: this is split into checking and reporting in another routine fail_check_compatibility // to increase inlining probability void check_compatibility(const Histogram1D & h) const{ if (get_nbins() != h.get_nbins() || xmin!=h.xmin || xmax != h.xmax){ fail_check_compatibility(h); } }