Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ActionImportSystematics.cxx 18.89 KiB
#include "QFramework/TQFolder.h"
#include "QFramework/TQIterator.h"
#include "QFramework/TQUtils.h"
#include "QFramework/TQHistogramUtils.h"
#include "QFramework/TQSampleDataReader.h"

#include "SFramework/TSStatisticsManager.h"
#include "SFramework/TSSystematicsManager.h"

/*<cafdoc name=ImportSystematics>
  ImportSystematics
  ===========================
  
  Import a set of externally defined systematic variations into a
  model.  This can be used to add systematics obtained by external
  sources, e.g. theory systematics, generator variations, systematics
  evaluated on truth samples, etc.

  Usage:
  ---------------

  This action is most commonly used with the `$include` keyword, importing the systematics from external files. These can be `txt` or `root` files.

  ```
  +ImportSystematics {
    +HWWRun2GGF {
      # new run2 ggH systematics
      $include("./auxData/theorySystematics/ggF/ggH.txt");
    }
  }
  ```

  The aforementioned file `./auxData/theorySystematics/ggF/ggH.txt` would in this case be formatted like this:

  ```
  # any top-level folder will be added as a new systematic uncertainty
  +theo_QCD_scale {
    +SR_0j_DF_all {
      # the "Region" selector can be used to define on which regions
      # this systematic should act. If not given, the folder name
      # ("SR_0j_DF_all") is used as a region selector.
      <Region = "Sample.sigGGF*jet*">
      +ggf {
        # the "Sample" selector can be used to define on which samples
        # this systematic should act. If not given, the folder name
        # ("ggf") is used as a sample selector.
        <Sample = "Sample.sigGGF*jet*">
        # the most basic type of systematic is an overall systematic,
        # providing a "High" and "Low" variation as well as a nominal
        # "Val"
        <IsOverallSys = true>
        <Val = 1, High = 1.0014, Low = 0.99875> 
        # some additional information can be provided to enable some
        # of the more advanced plotting and pruning methods of the
        # framework, but are not needed if the aim is to just have
        # this systematic included in the fit "as-is"
        <HighErr = 0.00522428, LowErr = 0.00519054, Percent = 5.26967, Entries = 57697>
        # additionally, shape systematics ("HistoSys") can be added as histograms
        <IsHistoSys = true>
        # histograms are added with the names "HistoHigh", "HistoLow" and "HistoNominal" in the typical TQFolder syntax
        TH1F("HistoHigh", "sometitle", 50, 80, 130) << 57697@{27.7231+-0.604252,2.91253+-0.177788,...};
        TH1F("HistoLow",  "sometitle", 50, 80, 130) << ...;
        TH1F("HistoNominal",  "sometitle", 50, 80, 130) << ...;
      }
      +vbf {
        ...
      }
    }
    +SR_1j_DF_all {
      ...