Possible breaking change to RooResolutionModel in ROOT 6.22

Dear experts,
I have encountered a breaking change in ROOT 6.22 and would like to hear your opinion on this issue. In ROOT 6.22, RooResolutionModel got an update where the convolution variable x is not a RooRealProxy, but a RooTemplateProxy<RooAbsRealLValue>. The associated changes actually break some user code because constant resolution models cannot return a reference to their proxy any more and const instances of classes inheriting from RooResolutionModel cannot obtain references to their own Proxies. This is illustrated in the following example code:

#include "RooRealVar.h"
#include "RooTemplateProxy.h"
#include "RooAbsPdf.h"
#include "RooRealProxy.h"
#include "RooAbsRealLValue.h"

struct ResolutionModel_6_20 {
    RooRealProxy x;
    RooRealVar& convVar() const { return (RooRealVar&) x.arg(); }
};

struct ResolutionModel_6_22 {
    RooTemplateProxy<RooAbsRealLValue> x;
    const RooAbsRealLValue& convVar() const { return *x; }
    RooAbsRealLValue& convVar() { return *x; }
};

int main()
{
    const ResolutionModel_6_20 r620;
    const ResolutionModel_6_22 r622;

    RooRealVar& xref620 = static_cast<RooRealVar&>(r620.convVar());
    RooRealVar& xref622 = static_cast<RooRealVar&>(r622.convVar()); // Does not compile
}

The last line in main() does not compile. The code compiles if the Resolution models are not marked as const as I said, but fixing that in some library I use is not that straight forward because of classes that are derived from RooResolutionModel who modify their own proxies in methods marked as const etc etc . So my question is: Are these changes here to stay and was it intended to effectively stop treating the dependent Proxy variable as a mutable, or has something been overlooked?
Thank you in advance!

Hi Vukan,

that’s a good point.

Actually, these are not references to the proxies, but they are references to the proxied object. Given that these proxies more or less act like smart pointers, you are right in pointing out that you should be allowed to mutate the pointed-to object even if the owning proxy is in a const instance. I’ll remove this limitation for 6.22.02 and 6.24.

Thank you for the quick response and for looking into this, it is very much appreciated! :slight_smile:

Coming to a branch near you tomorrow:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.