[Rivet] Compatibility question

Andy Buckley andy.buckley at ed.ac.uk
Wed Dec 7 16:03:50 GMT 2011


On 07/12/11 13:02, Frank Siegert wrote:
> Hi Riveters,
>
> I had recently added the option of specifying an input final state in
> the W/ZFinder constructor e.g. like this:
> WFinder(..., FinalState inputfs=FinalState());
> (
> http://projects.hepforge.org/rivet/trac/browser/trunk/include/Rivet/Projections/WFinder.hh#L37
> )
>
> Only now I realised, that this won't work in all cases, as code like
> VetoedFinalState vfs;
> WFinder wfinder(..., vfs);
> will upcast the VetoedFinalState to a FinalState and loose any
> VetoedFinalState functionality (in particular its project method).
>
> The proper solution to avoid the upcast is to pass by reference,
> WFinder(..., const FinalState& inputfs);
> but then I can't specify a default argument to keep backwards
> compatibility.
>
> So here my questions about which solution you would prefer:
>
> 1. Break backwards compatibility and move the inputfs argument to the
> front without default argument.
> (This would bring the W/ZFinder more in line with other projections like
> FastJets)
>
> 2. Introduce such alternative constructors for each of the two already
> existing constructors, but also keep the old ones around as deprecated?
>
> 3. Or is there any other trick that avoids upcasting but allows a
> default argument? Anything with smart pointers that we would want to use
> at this place?

If I understand correctly, I think there's no syntactic sugar for a 
default argument passed by reference, but you can do it manually with 
two constructors:

WFinder(..., const FinalState& inputfs);
WFinder(...);

In the body of the second one, create a local default FinalState and use 
it by reference (sadly you can't chain the constructors... until C++ 
0x11 (or whatever it's called) is supported, but I'm sure you can work 
that out ;)

Does that help? As far as API compatibility goes, I've already made 
sufficiently many changes to the Jet  and FastJets interfaces in the 
head that the next version will have to be another major bounce, this 
time to 1.8.0 (or 2.0.0... Hendrik's got a working basic parser of the 
YODA data format now :) )

Andy

-- 
Dr Andy Buckley
SUPA Advanced Research Fellow
Particle Physics Experiment Group, University of Edinburgh

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the Rivet mailing list