Wrong comparisons in `include/Rivet/Tools/RHICCommon.hh` projections
In the BRAHMSCentrality
projection implemented in include/Rivet/Tools/RHICCommon.hh
the compare
member functions are implemented incorrectly. Currently we have
// Compare to another projection.
virtual CmpState compare(const Projection& p) const {
return mkNamedPCmp(p, "BRAHMSCentrality");
}
(line 67).
The member function Rivet::Projection::mkNamedPCmp
(which delegates to template specialisation template <> Rivet::Cmp<Projection>
tries to retrieve the projection named in the second argument from both this
and the passed projection p
. If that succeeds, then the Cmp
specialisation compares the typeid
ordering of the two retrieved projections.
In the case at hand - when a BRAHMSCentrality
object is compared to another object of that class, the above implementation tries to retrieve the sub-projection named "BRAHMSCentrality"
from the current and other projection. Since none of these objects have these internal sub-projections, the comparison fails and causes ProjectionHandler::getProjection
to throw an exception.
The intent of Rivet::Projection::mkNamedPCmp
is to facilitate easy comparison of two projections of the same class which may only differ in how sub-projections of that class are configured. That is, the above code could be
// Compare to another projection.
virtual CmpState compare(const Projection& p) const {
return mkNamedPCmp(p, "ChargedFinalState");
}
since that is the embedded projection name. However, since Rivet::Projection::compare
is never called on objects of different types, and since Rivet::BRAHMSCentrality
is always the same, there's really no reason to do this. Instead this member function should always return Rivet::CmpState::EQ
.
Yours,
Christian