|
[Rivet] Question about YODA Profile1D: how to show RMS instead of errors of the meanAndy Buckley andy.buckley at cern.chSat Jun 13 16:49:45 BST 2015
On 13/06/15 11:37, Adrian Buzatu wrote: > Hi RIVET/YODA authors, > > For the studies I am doing on the jet energy scale it was suggested to > me to reproduce some YODA Profile1D where instead of the error bars on > the mean to show the RMS of the distribution, as we already have the > mean on the Y axis. Do you know how to do that? > > On a different, but maybe related note, do you know if I can interface > ROOT with RIVET to use ROOT insted of YODA? I am familiar with how to do > this in ROOT, and then use PyROOT, maybe that can help. But I hope plan > A with YODA has a feature for this. Hi Adrian, There's some confusion here about what YODA does: it mostly just handles the statistical definition of histograms, but the plotting is external. rivet-cmphistos converts to the simple make-histos format, and the decision about what size to give to error bars is built into the converter code. It doesn't have a simple flag to change the profile error bar plotting, though. Our future direction for Rivet and YODA plotting is to use the Python matplotlib (mpl) library. There's the start of some helper functions in the yoda.plotting Python module, but even without touching those it's pretty easy to do mpl plotting of YODA objects: ## Load a profile histo import yoda aos = yoda.read("/home/andy/proj/hep/rivet/Rivet.yoda") p = aos["/MC_GENERIC/EtaSumEt"] assert type(p) is yoda.Profile1D ## Get data points and errors xs, ys, exs, eys, sigys = [], [], [], [], [] for b in p.bins: if b.sumW: xs.append(b.xMid) exs.append(b.xWidth/2) ys.append(b.mean) eys.append(b.stdErr) sigys.append(b.stdDev) ## Plot import pylab as pl pl.hold(True) pl.errorbar(xs, ys, xerr=exs, yerr=sigys, marker="None", ls="None", ecolor="black") pl.errorbar(xs, ys, xerr=exs, yerr=eys, marker="None", ls="None", ecolor="red") pl.plot(xs, ys, "o", color="black") pl.savefig("rmsprofile.pdf") With the demo Rivet.yoda file that I had lying around, this produced the attached PDF (note that I used the standard deviation rather than RMS for this plot, since b.rms() wouldn't subtract the mean value in the calculation of the distribution width). It should be pretty easy to extend that script, and I can help you to use the yoda.plotting tools if you like. I'm also going to add an optional argument to the Profile1D mkScatter, function, which will make it possible to do this sort of plotting in just a few lines. There's also a yoda2root script, which makes use of converter functions in the YODA/ROOTCnv.h header... I'm not sure if it works completely for profiles, though, since ROOT's interface for populating those is very odd. If you go that route, let us know how you get on! Andy -- Dr Andy Buckley, Lecturer / Royal Society University Research Fellow Particle Physics Expt Group, University of Glasgow -------------- next part -------------- A non-text attachment was scrubbed... Name: plotprofile.py Type: text/x-python Size: 703 bytes Desc: not available URL: <https://www.hepforge.org/lists-archive/rivet/attachments/20150613/1e76166e/attachment.py> -------------- next part -------------- A non-text attachment was scrubbed... Name: rmsprofile.pdf Type: application/pdf Size: 33307 bytes Desc: not available URL: <https://www.hepforge.org/lists-archive/rivet/attachments/20150613/1e76166e/attachment.pdf>
More information about the Rivet mailing list |