Signal injection - elliot-hughes/fatjet_theta GitHub Wiki

Example

This snippet of code runs MLE with each signal set to a strength of 1. It then reads the resulting signal strengths (beta_signal) and associated pulls and writes them out in histograms.

mle_options = Options()
mle_options.set("global", "debug", "True")
signal_process_groups = None	#{'': []}
signal_strength = "1.0"

# Run MLE:
fit = mle(
	model,
	'toys:' + signal_strength,
	n=1000,
	with_error=True,
	with_covariance=True,
	signal_process_groups=signal_process_groups,
	options=mle_options
)

# Write out results:
ms = ["100", "150", "200", "250", "300", "400", "500"]
from ROOT import TH1F
tf_inj = TFile(INPUTFILE + "_injection.root", "recreate")
for m in ms:
	entries = fit["Ms" + m]["beta_signal"]
	name = "injection_" + m
	h = TH1F("hinj" + m, "", 15, 0, 2*float(signal_strength))
	he = TH1F("hinje" + m, "", 15, -3*float(signal_strength), 3*float(signal_strength))
	[h.Fill(mean) for mean, sigma in entries]
	[he.Fill((mean-float(signal_strength))/sigma) for mean, sigma in entries if mean and sigma]
	tf_inj.WriteTObject(h)
	tf_inj.WriteTObject(he)