Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
farakiko committed Feb 21, 2024
1 parent e954917 commit 6cc2a73
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions combine/create_datacard.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,9 @@ def create_datacard(hists_templates, years, lep_channels, add_ttbar_constraint=T
model = rl.Model("testModel")

# define the signal and control regions
# SIG_regions = ["SRVBF95", "SRggF97pt250to300", "SRggF97pt300to450", "SRggF97pt450toInf"]
SIG_regions = list(hists_templates.axes["Region"])
SIG_regions.remove("TopCR")
SIG_regions.remove("WJetsCR")
SIG_regions = ["VBF97", "ggF975pt250to300", "ggF975pt300to450", "ggF975pt450toInf"]
CONTROL_regions = ["TopCR", "WJetsCR97"]

# SIG_regions = ["VBF97", "ggF975pt250to300", "ggF975pt300to450", "ggF98pt450toInf"]
SIG_regions = ["VBF97", "ggF975pt250to300", "ggF975pt300to450"]
# SIG_regions = ["VBF97", "ggF98"]

# SIG_regions = ["ggF975pt300to450"]

CONTROL_regions = ["TopCR", "WJetsCR"]
if add_ttbar_constraint:
ttbarnormSF = rl.IndependentParameter("ttbarnormSF", 1.0, 0, 10)

Expand All @@ -76,7 +67,8 @@ def create_datacard(hists_templates, years, lep_channels, add_ttbar_constraint=T
stype = rl.Sample.SIGNAL if sName in sigs else rl.Sample.BACKGROUND
sample = rl.TemplateSample(ch.name + "_" + labels[sName], stype, templ)

# sample.autoMCStats(lnN=True)
if "CR" in ChName:
sample.autoMCStats(lnN=True)

# SYSTEMATICS NOT FROM PARQUETS
for syst_on_sample in ["all_samples", sName]: # apply common systs and per sample systs
Expand Down Expand Up @@ -116,7 +108,8 @@ def create_datacard(hists_templates, years, lep_channels, add_ttbar_constraint=T
data_obs = get_template(hists_templates, "Data", ChName)
ch.setObservation(data_obs)

ch.autoMCStats()
if "CR" not in ChName:
ch.autoMCStats()

if add_ttbar_constraint:
failCh = model["TopCR"]
Expand All @@ -132,7 +125,7 @@ def create_datacard(hists_templates, years, lep_channels, add_ttbar_constraint=T
ttbarpass.setParamEffect(ttbarnormSF, 1 * ttbarnormSF)

if add_wjets_constraint:
failCh = model["WJetsCR"]
failCh = model["WJetsCR95"]

wjetsfail = failCh["wjets"]
wjetsfail.setParamEffect(wjetsnormSF, 1 * wjetsnormSF)
Expand All @@ -159,7 +152,7 @@ def main(args):

if __name__ == "__main__":
# e.g.
# python create_datacard.py --years 2016,2016APV,2017,2018 --channels mu,ele --outdir templates/v3
# python create_datacard.py --years 2016,2016APV,2017,2018 --channels mu,ele --outdir templates/v4

parser = argparse.ArgumentParser()
parser.add_argument("--years", default="2017", help="years separated by commas")
Expand Down

0 comments on commit 6cc2a73

Please sign in to comment.