<div dir="ltr">Dear Andy and David,<br><br>I've done a bit more digging here and the problematic check is on the effective number of entries. <div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">I have two Histo1DPtr objects, </div><div class="gmail_default" style="display:inline"><font face="courier new, monospace">hist_denominator</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"> and </div><div class="gmail_default" style="display:inline"><font face="courier new, monospace">hist_numerator</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"> and </div>I'm filling both histograms with<br><br><font face="courier new, monospace">hist<div class="gmail_default" style="display:inline">-></div>fill( value, weight );</font><br><br>where sometimes I fill <font face="courier new, monospace">hist_denominator</font> and sometimes <font face="courier new, monospace">hist_numerator</font> AND <font face="courier new, monospace">hist_denominator</font><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">. If I print out every time a particular bin gets filled, you can see this.</div><br><br><font face="courier new, monospace">Rivet.Analysis.ATLAS_STDM_2012_17: INFO Filling hist_denominator with <div class="gmail_default" style="display:inline">weight </div>587738 at value = 3.00608<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO bin now contains actual entries: 4 / 16<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO bin now contains effective entries: 1.15024 / 1.195 => 0.962543<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO Filling hist_denominator with weight 107673 at <div class="gmail_default" style="display:inline">value</div> = 3.40704<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO Filling hist_numerator with weight <div class="gmail_default" style="display:inline"> </div>107673 at value = 3.40704<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO bin now contains actual entries: 5 / 17<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO bin now contains effective entries: 1.20029 / 1.19789 => 1.002</font><br><br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">The second fill here is the problematic one, causing the efficiency to go above 1.0. Adding a new value to both the numerator and denominator increases the number of effective entries in both cases (as would be expected) but increases effNumEntries in the numerator by more than the denominator. This is what's causing the problem.</div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">I don't think the logic in using sum(w)^2 / sum(w^2) to calculate nEntries is wrong, but I'm not sure exactly what's going on here. </div></font><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div>Any ideas<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">?</div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">I can give a more detailed breakdown of exactly what I fill these histograms with if needed (as you can see it's only 17 events).</div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">Thanks,<br>James</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 23 September 2014 20:16, James Robinson <span dir="ltr"><<a href="mailto:james.robinson@cern.ch" target="_blank">james.robinson@cern.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Andy,<br><br>I'm getting an error from Rivet complaining about an invalid efficiency calculation:<br><br><span style="font-family:'courier new',monospace">Rivet_i INFO Rivet_i finalizing</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">Rivet.Analysis.Handler: INFO Finalising analyses</span><br style="font-family:'courier new',monospace"><font face="courier new, monospace">Rivet_i FATAL Standard std::exception is caught<br>Rivet_i ERROR Attempt to calculate an efficiency when the numerator is not a subset of the denominator<br></font><br>However, if I get the code to print out the individual histograms, bin-by-bin, I can't see any bin where the numerator is larger than the denominator:<br><br><font face="courier new, monospace">Rivet.Analysis.ATLAS_STDM_2012_17: INFO There are 263 / 393 entri<div style="display:inline">es in the histograms</div><div style="display:inline"></div><div style="display:inline"> </div><br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 1.1726e+17, total: 1.23204e+17<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 1.01373e+17, total: 1.23149e+17<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 6.85239e+16, total: 1.2764e+17<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 8.20248e+16, total: 1.4139e+17<div style="font-family:arial,helvetica,sans-serif;display:inline"></div><br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 1.65158e+16, total: 4.2562e+16<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 7.17599e+15, total: 1.69049e+16<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 7.2618e+14, total: 2.16647e+16<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 9.2832e+15, total: 2.75894e+16<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 2.69685e+14, total: 3.10438e+14<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 9.55894e+14, total: 9.55894e+14<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 0, total: 1.66588e+15<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 0, total: 0<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 0, total: 0<br>Rivet.Analysis.ATLAS_STDM_2012_17: INFO dy accepted: 0, total: 0<br></font><br>Any idea what I'm doing wrong?<br><br>Thanks,<br>James</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 17 September 2014 11:13, Andy Buckley <span dir="ltr"><<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 17/09/14 10:38, James Robinson wrote:<br>
><br>
><br>
> On 17 September 2014 11:26, Andy Buckley <<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a><br>
</span><span>> <mailto:<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a>>> wrote:<br>
><br>
> On 16/09/14 22:53, James Robinson wrote:<br>
> > Dear Andy and David,<br>
> ><br>
> > On 16 September 2014 20:58, Andy Buckley <<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a> <mailto:<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a>><br>
</span><span>> > <mailto:<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a> <mailto:<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a>>>> wrote:<br>
> ><br>
> > In fact, there is even an efficiency(pass, tot) function that takes 1D<br>
> > histos and returns a Scatter2D with appropriate binomial statistics<br>
> > treatment!<br>
> ><br>
> > Andy<br>
> ><br>
> ><br>
> > I think this is exactly what I want! The binomial error treatment is<br>
> > important for this analysis as the efficiencies tend towards 1.0 in some<br>
> > parts of phase space. What is the appropriate class called?<br>
><br>
> It's a function rather than a bound method (so call it as above):<br>
><br>
> <a href="https://yoda.hepforge.org/trac/browser/include/YODA/Histo1D.h#L426" target="_blank">https://yoda.hepforge.org/trac/browser/include/YODA/Histo1D.h#L426</a><br>
><br>
> We don't yet have the equivalent for 2D histos, but it should be trivial<br>
> to put together from the 1D version. I'll add that to my TODO list, but<br>
> maybe someone else fancies doing it? ;-)<br>
><br>
><br>
> Ah OK. That makes sense. Presumably I still need to book it somehow to<br>
> get it written out? Is there another method to register existing YODA<br>
> objects? Or can the bookScatter2D() function accept an existing<br>
> Scatter2D as it's argument (instead of a bin descriptor)?<br>
<br>
</span>Good points -- I should provide helper methods for doing this in Rivet,<br>
with automatic registration of the output Scatter, like we have for<br>
YODA's divide(h_a,h_b) -> Rivet's divide(h_a,h_b,s_out). I'll add those<br>
to the 2.2.0 release candidate.<br>
<br>
For now I think you can use addAnalysisObject(aoptr) to register any<br>
YODA analysis object. But it's made a little fiddly because YODA returns<br>
a stack-allocated object and what is needed is a new'd heap object. You<br>
might need to do<br>
<br>
Scatter2D s = efficiency(*tmph1, *tmph2);<br>
s.setPath(histoPath("foo"));<br>
addAnalysisObject(s.newclone());<br>
<br>
or similar. It's not very pretty, which is why I should provide the<br>
cosmetic wrapper functions.<br>
<span><font color="#888888"><br>
Andy<br>
<br>
--<br>
Dr Andy Buckley, Royal Society University Research Fellow<br>
Particle Physics Expt Group, University of Glasgow / PH Dept, CERN<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>