|
[Rivet-svn] r2567 - trunk/include/LWHblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Jul 7 11:06:37 BST 2010
Author: dgrell Date: Wed Jul 7 11:06:40 2010 New Revision: 2567 Log: Reverted [2456]. Need normalize() in ThePEG. Modified: trunk/include/LWH/Histogram1D.h Modified: trunk/include/LWH/Histogram1D.h ============================================================================== --- trunk/include/LWH/Histogram1D.h Wed Jul 7 09:58:08 2010 (r2566) +++ trunk/include/LWH/Histogram1D.h Wed Jul 7 11:06:40 2010 (r2567) @@ -394,6 +394,40 @@ } /** + * Scale the given histogram so that the integral over all bins + * (including overflow) gives \a intg. This function also corrects + * for the bin-widths, which means that it should only be run once + * for each histogram. Further rescaling must be done with the + * scale(double) function. + */ + void normalize(double intg) { + double oldintg = sumAllBinHeights(); + if ( oldintg == 0.0 ) return; + for ( int i = 0; i < ax->bins() + 2; ++i ) { + double fac = intg/oldintg; + if ( i >= 2 ) fac /= (ax->binUpperEdge(i - 2) - ax->binLowerEdge(i - 2)); + sumw[i] *= fac; + sumxw[i] *= fac; + sumx2w[i] *= fac; + sumw2[i] *= fac*fac; + } + } + + /** + * Return the integral over the histogram bins assuming it has been + * normalize()d. + */ + // double integral() const { + // double intg = sumw[0] + sumw[1]; + // for ( int i = 2; i < ax->bins() + 2; ++i ) + + // is this right? Leave out bin width factor? + + // intg += sumw[i]*(ax->binUpperEdge(i - 2) - ax->binLowerEdge(i - 2)); + // return intg; + // } + + /** * Not implemented in LWH. * @return null pointer always. */
More information about the Rivet-svn mailing list |