[Rivet] reading a YODA file in a Rivet Routine

Andy Buckley andy.buckley at cern.ch
Fri Oct 30 21:13:12 GMT 2015


Hi Patrick,

I could add a multiply method to a new YODA version quite easily. But 
the integration into Rivet would take a bit more work. It'd probably 
take longer than you want.

As I mentioned, it's not clear that a histogram is the data type that 
you want for the binned correction factors -- they unavoidably come with 
errors and then you need to decide how you want those errors to be 
combined. Quadrature or linear addition would be obvious approaches; 
what would you want to do?

For the approach you suggested with the post-processing script, in the 
absence of an automatic multiply method, you can just make the resulting 
scatter by hand. Something like this in Python:

assert len(h_data.bins) == len(h_corr.bins)
s = yoda.Scatter2D("/out")
for b_data, b_corr in zip(h_data.bins, h_corr.bins):
     xedges = b_data.xEdges
     xmid = 0.5*sum(xedges)
     xerrs = [abs(x - xmid) for x in xedges]
     y = b_data.height*b_corr.height
     yerrs = [b_data.heightErr*b_corr.height for _ in xrange(2)]
     p = yoda.Point2D(xmid, y, xerrs, yerrs)
     s.addPoint(p)

Sorry, not hugely elegant! I've ignored the correction factor error -- 
do whatever you like.

Andy


On 30/10/15 15:21, Patrick L.S. Connor wrote:
> Hi Andy,
>
> Thanks a lot for your answer.
>
> It could be indeed very nice if such a method as multiply() could exist,
> but I need some solution quite fast, so I can code some script on my own.
>
> What I want to do is to compute some kind of correction factor and apply
> it to some data:
>
>     data = correction factor * measurement
>
> where the correction factor and the "measurement" are produced from
> different MC events.
>
> What I am thinking to do is to write a script that would extract and
> multiply the respective histograms from two .yoda files, and store the
> result in a third .yoda file.
>
> As you obviously know much better the framework, please tell me if you
> have any suggestion.
>
> Thanks again and cheers,
>
> Patrick
>
>
>
>
>
> On Wed, 28 Oct 2015, Andy Buckley wrote:
>
>> Hi Patrick,
>>
>> As it happens, we don't have multiply functions between histograms,
>> because until now nobody had a use-case for it: histogram divisions
>> yes, multiplications... not that I've seen.
>>
>> What exactly is it that you're doing? Note that histograms in YODA are
>> objects with fill history, not e.g. lookup tables of efficiencies or
>> similar... although a future version will contain such objects, too.
>>
>> We can add such methods to YODA quite easily, but just preferred not
>> to fill it up with "for completeness" functions that wouldn't be used.
>>
>> If we add these multiply methods, you would be able to call them on
>> the YODA objects loaded into Rivet... modulo the detail that the
>> histogram handles that you get in Rivet are smart pointers, and we
>> provide dedicated divide() functions to handle the registration and
>> path setting on the resulting Scatter2D.
>>
>> Andy
>>
>>
>> On 28/10/15 11:53, Patrick L.S. Connor wrote:
>>> Dear Rivet Programmers,
>>>
>>> I would like to multiply some YODA histograms from different Rivet
>>> routines, but I could not find any way. Would there be anything like
>>> this already implemented?
>>>
>>> I thought of two ideas:
>>>   - either mutliply histograms from the YODA files just before running
>>> make-plots,
>>>   - or load the YODA file from the routine A inside the routine B and
>>> apply the multiplication there,
>>>   but unsuccessfully...
>>>
>>> Could you please help me?
>>> Thanks in advance.
>>>
>>> Regards,
>>>
>>> Patrick
>>>
>>>
>>>
>>>
>>> ----
>>> Patrick L.S. Connor
>>> Doktorand - CMS Team
>>> Deutsches Elektronen-Synchrotron
>>> Tel.: +49 40 8998-2617
>>> Geb.: 01b/O2.208
>>> _______________________________________________
>>> Rivet mailing list
>>> Rivet at projects.hepforge.org
>>> https://www.hepforge.org/lists/listinfo/rivet
>>
>>
>> --
>> Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
>> Particle Physics Expt Group, University of Glasgow
>>
>
>
>
>
> ----
> Patrick L.S. Connor
> Doktorand - CMS Team
> Deutsches Elektronen-Synchrotron
> Tel.: +49 40 8998-2617
> Geb.: 01b/O2.208


-- 
Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
Particle Physics Expt Group, University of Glasgow


More information about the Rivet mailing list