Skip to content

Commit

Permalink
Avoid invalid proxy constructor calls in HMuMuRooPdfs (cms-analysis#893)
Browse files Browse the repository at this point in the history
In the `HMuMuRooPdfs`, there was a classic dangerous RooFit mistake.

There were constructor calls like:
```c++
RooRealProxy m("m", "m", this, 91.2);
```

However, this is not doing what one would naively expect, which is
having proxy to a constant. Instead, it will hit this constructor by
converting the `double` to `bool`, which is used as the `valueServer`
parameter:

https://root.cern/doc/v626/classRooTemplateProxy.html#a9a550633b5336561b48eb313994a68e8

So it will create a proxy to nothing! In this particular case, this was
not a problem because in `evaluate()`, there is a fallback for empty
proxies.

But ROOT 6.30 makes some compile-time checks to prevent these mistakes,
so this commit is necessary to compile with newer ROOT versions.

See https://root.cern/doc/v626/classRooTemplateProxy.html.
  • Loading branch information
guitargeek authored and kcormi committed Jun 24, 2024
1 parent 147a3a9 commit 0a7c86f
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/HMuMuRooPdfs.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "HiggsAnalysis/CombinedLimit/interface/HMuMuRooPdfs.h"
#include "../interface/HMuMuRooPdfs.h"
//#include "HMuMuRooPdfs.h"
#include "RooRealVar.h"
#include "TMath.h"
Expand All @@ -16,10 +16,10 @@ RooModZPdf::RooModZPdf(const char *name, const char *title, RooAbsReal& _x, RooA
RooAbsPdf(name, title),
x("x", "x", this, _x),
a("a", "a", this, _a),
b("b", "b", this, 0.),
c("c", "c", this, 2.),
m("m", "m", this, 91.2),
w("w", "w", this, 2.5),
b{"b", "b", this},
c{"c", "c", this},
m{"m", "m", this},
w{"w", "w", this},
bernCoef("coefficients", "List of Bernstein coefficients", this)
{
}
Expand All @@ -30,8 +30,8 @@ RooModZPdf::RooModZPdf(const char *name, const char *title, RooAbsReal& _x, RooA
a("a", "a", this, _a),
b("b", "b", this, _b),
c("c", "c", this, _c),
m("m", "m", this, 91.2),
w("w", "w", this, 2.5),
m{"m", "m", this},
w{"w", "w", this},
bernCoef("coefficients", "List of Bernstein coefficients", this)
{
}
Expand All @@ -40,10 +40,10 @@ RooModZPdf::RooModZPdf(const char *name, const char *title, RooAbsReal& _x, RooA
RooAbsPdf(name, title),
x("x", "x", this, _x),
a("a", "a", this, _a),
b("b", "b", this, 0),
b{"b", "b", this},
c("c", "c", this, _c),
m("m", "m", this, 91.2),
w("w", "w", this, 2.5),
m{"m", "m", this},
w{"w", "w", this},
bernCoef("coefficients", "List of Bernstein coefficients", this)
{
}
Expand All @@ -52,10 +52,10 @@ RooModZPdf::RooModZPdf(const char *name, const char *title, RooAbsReal& _x, RooA
RooAbsPdf(name, title),
x("x", "x", this, _x),
a("a", "a", this, _a),
b("b", "b", this, 0.),
c("c", "c", this, 2.),
m("m", "m", this, 91.2),
w("w", "w", this, 2.5),
b{"b", "b", this},
c{"c", "c", this},
m{"m", "m", this},
w{"w", "w", this},
bernCoef("coefficients", "List of Bernstein coefficients", this)
{
TIterator* coefIter = _coef.createIterator() ;
Expand All @@ -76,8 +76,8 @@ RooModZPdf::RooModZPdf(const char *name, const char *title, RooAbsReal& _x, RooA
a("a", "a", this, _a),
b("b", "b", this, _b),
c("c", "c", this, _c),
m("m", "m", this, 91.2),
w("w", "w", this, 2.5),
m{"m", "m", this},
w{"w", "w", this},
bernCoef("coefficients", "List of Bernstein coefficients", this)
{
TIterator* coefIter = _coef.createIterator() ;
Expand All @@ -99,7 +99,7 @@ RooModZPdf::RooModZPdf(const char *name, const char *title, RooAbsReal& _x, RooA
b("b", "b", this, _b),
c("c", "c", this, _c),
m("m", "m", this, _m),
w("w", "w", this, 2.5),
w{"w", "w", this},
bernCoef("coefficients", "List of Bernstein coefficients", this)
{
}
Expand Down Expand Up @@ -174,7 +174,7 @@ RooExpPdf::RooExpPdf(const char *name, const char *title, RooAbsReal& _x, RooAbs
RooAbsPdf(name, title),
x ("x" , "x" , this, _x),
a1("a1", "a1", this, _a1),
m ("m" , "m" , this, 91.2),
m {"m" , "m" , this},
offset(_offset)
{
}
Expand Down Expand Up @@ -260,7 +260,7 @@ RooAbsPdf(name, title),
a1("a1", "a1", this, _a1),
a2("a2", "a2", this, _a2),
f ("f" , "f" , this, _f ),
m ("m" , "m" , this, 91.2),
m {"m" , "m" , this},
offset(_offset)
{
}
Expand Down Expand Up @@ -363,7 +363,7 @@ RooPowerLawPdf::RooPowerLawPdf(const char *name, const char *title, RooAbsReal&
RooAbsPdf(name, title),
x ("x" , "x" , this, _x),
a1("a1", "a1", this, _a1),
m("m", "m", this, 91.2),
m{"m", "m", this},
offset(_offset)
{}

Expand Down Expand Up @@ -445,7 +445,7 @@ RooAbsPdf(name, title),
a1("a1", "a1", this, _a1),
a2("a2", "a2", this, _a2),
f("f", "f", this, _f),
m("m", "m", this, 91.2),
m{"m", "m", this},
offset(_offset)
{
}
Expand Down

0 comments on commit 0a7c86f

Please sign in to comment.