|
37 | 37 |
|
38 | 38 | # Construct Gaussian constraint pdf on parameter f at 0.8 with |
39 | 39 | # resolution of 0.1 |
40 | | -fconstraint = ROOT.RooGaussian("fconstraint", "fconstraint", f, ROOT.RooFit.RooConst(0.8), ROOT.RooFit.RooConst(0.1)) |
| 40 | +fconstraint = ROOT.RooGaussian("fconstraint", "fconstraint", ROOT.RooFit.RooConst(0.8), f, ROOT.RooFit.RooConst(0.1)) |
41 | 41 |
|
42 | 42 | # Method 1 - add internal constraint to model |
43 | 43 | # ------------------------------------------------------------------------------------- |
44 | 44 |
|
45 | | -# Multiply constraint term with regular pdf using ROOT.RooProdPdf |
46 | | -# Specify in fitTo() that internal constraints on parameter f should be |
47 | | -# used |
| 45 | +# Multiply constraint term with regular pdf using ROOT.RooProdPdf Specify in |
| 46 | +# fitTo() that internal constraints on parameter f should be used |
48 | 47 |
|
49 | 48 | # Multiply constraint with pdf |
50 | 49 | modelc = ROOT.RooProdPdf("modelc", "model with constraint", [model, fconstraint]) |
51 | 50 |
|
52 | 51 | # Fit model (without use of constraint term) |
53 | | -r1 = model.fitTo(d, Save=True) |
| 52 | +r1 = model.fitTo(d, Save=True, PrintLevel=-1) |
54 | 53 |
|
55 | 54 | # Fit modelc with constraint term on parameter f |
56 | | -r2 = modelc.fitTo(d, Constrain={f}, Save=True) |
| 55 | +r2 = modelc.fitTo(d, Constrain={f}, Save=True, PrintLevel=-1) |
57 | 56 |
|
58 | 57 | # Method 2 - specify external constraint when fitting |
59 | 58 | # ------------------------------------------------------------------------------------------ |
60 | 59 |
|
61 | 60 | # Construct another Gaussian constraint pdf on parameter f at 0.8 with |
62 | 61 | # resolution of 0.1 |
63 | | -fconstext = ROOT.RooGaussian("fconstext", "fconstext", f, ROOT.RooFit.RooConst(0.2), ROOT.RooFit.RooConst(0.1)) |
| 62 | +fconstext = ROOT.RooGaussian("fconstext", "fconstext", ROOT.RooFit.RooConst(0.2), f, ROOT.RooFit.RooConst(0.1)) |
64 | 63 |
|
65 | 64 | # Fit with external constraint |
66 | | -r3 = model.fitTo(d, ExternalConstraints={fconstext}, Save=True) |
| 65 | +r3 = model.fitTo(d, ExternalConstraints={fconstext}, Save=True, PrintLevel=-1) |
67 | 66 |
|
68 | 67 | # Print the fit results |
69 | 68 | print("fit result without constraint (data generated at f=0.5)") |
|
0 commit comments