Skip to content

Making datacards

Luca Cadamuro edited this page Apr 13, 2020 · 3 revisions

Datacards are created from the outputs of fill_histogram with the steps below. Run from limits/prepareModels Steps 2 and 3 on are included in runpreparation.sh

  1. run fill_histograms with the final variable, selection, and all the systematics needed
  2. run prepareHistos.py, that will select the histograms needed, translate their names into the final format, and combine those that need to be combined. More info below.
  3. run makeDatacardsAndWorkspaces.py that will create the txt card, make the combined datacards (disable this with --no-comb) and make the workspaces (disable this with --card-only).

About prepareHistos.py

The code is configured from a config file under config/. The main options to pass are :

  • directory : points to the place containing outPlotter.root
  • processes : the list of processes to parse
  • categandobs : a list of pairs [category name, variable to use]
  • folder : where to save the output
  • replacements : a dictionary to optionally rename an input process (key : old process name, value : new process name)

In the block systematics you can configure the systematics parsing:

  • syst_list : the list of systematic histograms to be parsed for each process (if available). Each entry is formatted with these entries
0 : name of input systematic name
1 : list of directions, normally ['up', 'down']
2 : how to access the histogram name created by fill_histograms.
    'wsyst' for a systematic computed with an alternative weight
    'altsample' for a systematic computed with an alternative sample
    'wsyst_nodir' for a systematic computed with an alternative that has no direction. In this case the list of directions must be [None]
3 : optional, a string to rename this systematics

The list to_combine lists groups of systematic histograms that are combined into a single one.

name    : how to call the output systematic
inputs  : name of the individual histograms to combine
read_as : how to format the name of individual histograms (NOTE: no direction is expected in the name)
combine : how to combine them.
          'quadrature' for sum in quadrature of positive / negative deviations in each bin (separately)
          'maxmin' for min / max value in each bin (separately)

About makeDatacardsAndWorkspaces.py

Parameters to pass from the config:

  • datas, sigs and bkgs. Note that if a replacement of name was done, this is applied to the input names.
  • combinations : a list of items to combine (everything in a sub-list will be combined in a single datacard)
  • dataset : will give the name to the card

Input systematics are configured in the systs list. The first value is the type, the others are tuples that contain the processes the systematic applies to (with wildcards) and the value. Note that if the type contains fromInput an action is performed:

  • fromInput:lnN : the alternative histograms up/down are read and the difference in yield is applied as a lnN uncertainty. Uncertainties that are below syst_lnN_prune_value (both up and down below this threshold in abs value) are ignored. Use syst_lnN_prune_value = None to keep all uncertainties.
  • fromInput:shape : the alternative histograms are used as shape uncertainties

Clone this wiki locally