<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi all!<br>
<br>
</p>
<p>Few weeks ago, there was a mailing discussion about adding the number of Monte Carlo event generator attempts as an output to yodafiles. In last days I have been working on the patch for Rivet 2.4.0 and YODA 1.5.5 to manage this. Anyway I think that I have
bumped on something in the YODA code that could be considered as a bug...<br>
</p>
<p><br>
</p>
<p>The function that returns number of entries in Counter.h is of the type of double<br>
</p>
<p><br>
</p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><strong>Counter.h: line</strong></span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><strong>114:</strong></span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><strong>double
numEntries() const { return _dbn.numEntries(); }</strong></span><br>
</p>
<p><br>
</p>
<p>which by itself is probably no big deal. The only thing that is affected is the format of the total number of entries in yodafile (section YODA_COUNTER), which is because of that printed out in scientific format (e.g. for 150 events generated, there is something
like 1.500000e+05).<br>
</p>
<p><br>
</p>
<p>The problem comes in the moment, when one wants to read generated yodafile by some of the tools that come with rivet - for example yodamerge. Lets stick to the yodamerge example and lets say that we want to merge outputs of two runs - run1.yoda, which contains
information about 150 total entries and run2.yoda which contains information about 300 total entries. yodamerge tries to read input files by<br>
</p>
<p><br>
</p>
<p><strong>yodamerge: line129: </strong><strong>aos = yoda.read(filename)</strong><br>
</p>
<p><br>
</p>
<p>Long story short, if I understand it well, this yoda.read(filename) function calls another chain of read functions and the file <span style="font-size: 12pt;">is at the end </span><span style="font-size: 12pt;">read </span><span style="font-size: 12pt;">by </span>ReaderYODA.cc<span style="font-size: 12pt;">.</span><span style="font-size: 12pt;"> At </span><span style="font-size: 12pt;">some</span><span style="font-size: 12pt;"> </span><span style="font-size: 12pt;">point </span>ReaderYODA.cc<span style="font-size: 12pt;">
tries to read</span><span style="font-size: 12pt;"> </span>numEntries from YODA_COUNTER section (which is in scientific format).</p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><strong>ReaderYODA.cc: line173: iss >> sumw >> sumw2 >> n;</strong></span><br>
</p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">But here the numEntries (in the code denoted as n) is assumed to be unsigned long and <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">is </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">parsed
to iss istringstream</span> by >> operator. Now I don't understand it well, but I think that >> is just not awaiting anything else than a number in int format and can not parse int (resp. unsigned long) in a scientific format. Unfortunately what happens now is
that <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">just the part of the number before the decimal dot</span> is parsed without throwing any error.</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">If we get back to our example with two runs which are yodamerged, it leads to the final output with total number of entries 4 instead
of 450 in <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">YODA_COUNTER,</span> which is of course incorrect.</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">The way how I have fixed it is very simple. I think that it is sufficient to change type of numEntries() in Couter.h from double to unsigned
long. After this fixing I am getting numEntries as a ordinary int number (non-scientific format) in output file and thanks to that also correct results after merging.</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">I am sorry that you had to read such a long story because of just one wrong type, but to me it was quite a puzzle to find out why yodamerge
is giving incorrect numEntries. That is the reason why I felt that I also should explain why I think that it would be nice to fix it.<br>
<br>
Best,</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Radek<br>
<br>
PS: I am not sure, but to me it also seems that there is some another inconsistency in yodamerge itself. Shouldn't be there (line 204)</span></p>
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> </span></p>
<p><strong>if opts.S1D_MODE == "assume_mean":</strong> <br>
</p>
<p><br>
</p>
<p>instead of </p>
<p><strong><br>
</strong></p>
<p><strong>if opts.S2D_MODE == "assume_mean":</strong><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
<br>
</p>
</body>
</html>