Skip to content

Compute custom systematic variations

Tae Hyoun Park requested to merge systematic-variations-operator into master

Introduce the functionality to take as the up/down variation of a systematic the result of an "operation" of a set of variations.

Currently in SFramework, a sample in which a systematic variation is assumed to correspond to a single systematic variation in a one-to-one fashion, e.g. scale photon & electron calibration up/down, is present.:

+Variations{
  +EG_SCALE_ALL__1down {
    <Variation = "_EG_SCALE_ALL__1down">
  }
  +EG_SCALE_ALL__1up {
    <Variation = "_EG_SCALE_ALL__1up">
  }
}
# Make a single systematic consisting of its up & down variation out of the up/down-varied SFs
+Systematics{
  +ATLAS_EG_SCALE_ALL {
    <Down = "EG_SCALE_ALL__1down", Up = "EG_SCALE_ALL__1up", isP4Sys = true, Attributes.0 = "exp", Attributes.1 = "NP", isDetectorSys = true>
  }
}

There can exist systematics whose up/down should be taken from non-trivial operations of variations performed at the analyze.py step:

+Variations{
  # JER NPs must be considered in pairs, where the difference between MC/PseudoData-smeared distributions is to be applied as a systematic uncertainty
  +ATLAS_JER_EffectiveNP_1_MCsmear__1up {
    <Variation = "_JET_JER_EffectiveNP_1_MCsmear__1up">
  }
  +ATLAS_JER_EffectiveNP_1_MCsmear__1down {
    <Variation = "_JET_JER_EffectiveNP_1_MCsmear__1up">
  }
  +ATLAS_JER_EffectiveNP_1_PDsmear__1up {
    <Variation = "_JET_JER_EffectiveNP_1_MCsmear__1up">
  }
  +ATLAS_JER_EffectiveNP_1_PDsmear__1down {
    <Variation = "_JET_JER_EffectiveNP_1_MCsmear__1up">
  }
  # PDF error is often taken from the width of its spread around its *own* nominal, which is not necessarily the sample's
  +Ztt_PDF_0 {
    <Variation = "_PDF260000" >
  }
  +Ztt_PDF_1 {
    <Variation = "_PDF260001" >
  }
  ...
    +Ztt_PDF_100 {
    <Variation = "_PDF260100" >
  }
}

# How can we process these individual variations into the up/down pair that we want?
+Systematics{

  +ATLAS_JER_EffectiveNP_1 {
    <Up = "ATLAS_JER_EffectiveNP__1up", Down = "ATLAS_JER_EffectiveNP__1down",  # Want these to exist, but they don't yet...
     isP4Sys = true, Attributes.0 = "exp", Attributes.1 = "NP", isDetectorSys = true>,
    +Compute{  # Compute the variations we want ourselves!
      +Down{
        <Mode="Difference",  # 'Mode' specifies the operation
        Variations={"ATLAS_JER_EffectiveNP_1_MCsmear__1down","ATLAS_JER_EffectiveNP_1_PDsmear__1down"},
        Direction=+1>  # Could optionally flip the variation +/-1 if we wanted
      }  
      +Up{  #Apply a calculated delta w.r.t. 'Baseline' to "Nominal" as systematic variations
        <Mode="Difference",  # 'Mode' specifies the operation
        Variations={"ATLAS_JER_EffectiveNP_1_MCsmear__1down","ATLAS_JER_EffectiveNP_1_PDsmear__1down"},
        Baseline="Ztt_PDF_0">  # the nominal PDF error set is not necessarily the sample nominal   
      }
    }
  }

  +THEO_Ztt_PDF {
    <Up = "THEO_Ztt_PDF__1up",
    isSFSys = true, Attributes.0 = "theo", Attributes.1 = "NP", isDetectorSys = false>,
    +Compute/Up {  # apply a calculated delta w.r.t. 'Baseline' to "Nominal" as systematic variations
      <Mode="StdDev",  # take standard deviation of the Variations w.r.t. Baseline
      Variations={"ATLAS_JER_EffectiveNP_1_MCsmear__1down","ATLAS_JER_EffectiveNP_1_PDsmear__1down"},
      # The nominal PDF error set is not necessarily the sample nominal
      # so the Baseline(="Nominal" by default) defines from where to calculate the systematic variation's "delta",
      # which is subsequently applied on top of the sample's "Nominal".
      # Note: reserving "Nominal" as the name of the full sample nominal is consistent with other parts of the SFramework (i.e. hard-coded).
      Baseline="Ztt_PDF_0">
    }
    # If one direction does not exist, it is taken from the other and symmetrized. Makes sense in this case.
  }
}

This MR aims to add such a functionality detecting the optional processing to be on a set of variations, the resulting "delta" to be applied to the Nominal.

Edited by Tae Hyoun Park

Merge request reports