|
[Rivet] yodamerge for Histo1DFrank Siegert frank.siegert at cern.chThu Jul 4 14:56:55 BST 2013
Hi Leif and all (especially the YODA devs), For the completely general solution to run merging we'll have to wait for the Rivet improvements discussed during the dev meeting and summarised in Andy's mail. But what I was referring to is the "hack-ish" intermediate solution of using yodamerge for histograms that Andy suggested: since we store sumW, sumW2 and ScaledBy we can do a reasonable merging for dsigma/dX type distributions. But currently, yodamerge (and implicitly the YODA::Histo1D::operator+) does not take into account the ScaledBy property at all. Instead it simply adds the sumW(2)'s and uses the last(?) ScaledBy encountered. Thus the final normalisation is obviously arbitrary. To fix that, I'm suggesting the following change to the YODA::Histo1D::operator+: /// Add another histogram to this Histo1D& operator += (const Histo1D& toAdd) { - _axis += toAdd._axis; + + // Undo scaling of both histograms + double scaledBy = annotation<double>("ScaledBy", 1.0); + _axis.scaleW(1.0/scaledBy); + + double toAddScaledBy = toAdd.annotation<double>("ScaledBy", 1.0); + Axis1D<HistoBin1D, Dbn1D> toAddAxis = toAdd._axis; + toAddAxis.scaleW(1.0/toAddScaledBy); + + // Add + _axis += toAddAxis; + + // Re-apply combined scaling + double newScaledBy = scaledBy*toAddScaledBy/(scaledBy+toAddScaledBy); + _axis.scaleW(newScaledBy); + setAnnotation("ScaledBy", newScaledBy); + return *this; } I have tested this by merging Histo1D's from different runs with very different numbers of events in them, and it looks like it's working nicely. If there are no objections, and since I seem to have YODA write permissions, I would push this into the central repo. Cheers, Frank -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.hepforge.org/lists-archive/rivet/attachments/20130704/d96746bf/attachment.html>
More information about the Rivet mailing list |