Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,20 @@ jobs:
- name: nominal fit
run: >-
rabbit_fit.py $RABBIT_OUTDIR/test_tensor.hdf5 -o $RABBIT_OUTDIR/ --postfix composite
-t 0 --unblind '.*' --doImpacts --globalImpacts
-t -1 0 --unblind '.*' --doImpacts --globalImpacts
--saveHists --saveHistsPerProcess --computeHistErrors --computeHistErrorsPerProcess
--computeHistCov --computeHistImpacts --computeVariations
--compositeMapping -m Project ch1 a -m Project ch1 b

- name: nominal fit blinded
run: >-
rabbit_fit.py $RABBIT_OUTDIR/test_tensor.hdf5 -o $RABBIT_OUTDIR/
-t 0 --postfix blinded --doImpacts --globalImpacts
-t 0 --postfix blinded --setConstraintMinimum bkg_2_norm 0.5 --doImpacts --globalImpacts

- name: sparse tensor fit
run: >-
rabbit_fit.py $RABBIT_OUTDIR/test_tensor_sparse.hdf5 -o $RABBIT_OUTDIR/ --postfix sparse
-t -0 --noBinByBinStat --doImpacts --globalImpacts --computeVariations
-t 0 --noBinByBinStat --doImpacts --globalImpacts --computeVariations
--saveHists --saveHistsPerProcess --computeHistErrors --computeHistErrorsPerProcess
-m Project ch1 a -m Project ch1 b

Expand Down
25 changes: 20 additions & 5 deletions rabbit/fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,27 @@ def __init__(

self.parms = np.concatenate([self.poi_model.pois, self.indata.systs])

# tf tensor containing default constraint minima
theta0default = np.zeros(self.indata.nsyst)
for parm, val in options.setConstraintMinimum:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I get correctly that setConstraintMinimum sets the initial central value of the parameter (i.e. what we would consider the "pull"?). In that case the option name seems misleading, because Constraints makes me think about the width of the prior of the parameter. Maybe --setParameterMinimum or --setPrefitParameterPull ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constraint minimum is what we usually call this. This sets the $\theta_0$ value which appears in the Gaussian constraint term $(\theta-\theta_0)^2$, i.e. it changes the value where $\theta$ minimizes the constraint term of the likelihood.

idx = np.where(self.indata.systs.astype(str) == parm)[0]
if len(idx) != 1:
raise RuntimeError(
f"Expect to find exactly one match for {parm} to set constraint minimum, but found {len(idx)}"
)
theta0default[idx[0]] = val

self.theta0default = tf.convert_to_tensor(
theta0default, dtype=self.indata.dtype
)

# tf variable containing all fit parameters
thetadefault = tf.zeros([self.indata.nsyst], dtype=self.indata.dtype)
if self.poi_model.npoi > 0:
xdefault = tf.concat([self.poi_model.xpoidefault, thetadefault], axis=0)
xdefault = tf.concat(
[self.poi_model.xpoidefault, self.theta0default], axis=0
)
else:
xdefault = thetadefault
xdefault = self.theta0default

self.x = tf.Variable(xdefault, trainable=True, name="x")

Expand Down Expand Up @@ -186,7 +201,7 @@ def __init__(

# constraint minima for nuisance parameters
self.theta0 = tf.Variable(
tf.zeros([self.indata.nsyst], dtype=self.indata.dtype),
self.theta0default,
trainable=False,
name="theta0",
)
Expand Down Expand Up @@ -475,7 +490,7 @@ def set_beta0(self, values):
self.logbeta0.assign(tf.math.log(beta0safe))

def theta0defaultassign(self):
self.theta0.assign(tf.zeros([self.indata.nsyst], dtype=self.theta0.dtype))
self.theta0.assign(self.theta0default)

def xdefaultassign(self):
if self.poi_model.npoi == 0:
Expand Down
7 changes: 7 additions & 0 deletions rabbit/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ def common_parser():
E.g. use '--unblind ^signal$' to unblind a parameter named signal or '--unblind' to unblind all.
""",
)
parser.add_argument(
"--setConstraintMinimum",
default=[],
nargs=2,
action="append",
help="Set the constraint minima of specified parameter to specified value",
)
parser.add_argument(
"--freezeParameters",
type=str,
Expand Down