cms-tau-pog / TauFW

Analysis framework for tau analysis at CMS using NanoAOD
9 stars 41 forks source link

Apply k-factor only once (Run 2) in stitching; cleaning comment & pri… #82

Closed IzaakWN closed 1 month ago

IzaakWN commented 1 month ago

This PR fixes an unfortunate bug where the k-factor was applied twice for Run 2 (cme=13).

  elif cme==13:
     xsec_incl_corrected = xsec_incl or getxsec_nlo(name,*searchterms) or xsec_incl_initial
     kfactor       = xsec_incl_corrected / xsec_incl_initial

  ...

  sample_incl.xsec=xsec_incl_corrected
  wIncl = sample_incl.lumi * kfactor * sample_incl.xsec * 1000. / sample_incl.sumweights

The fix in this PR is to simply disable sample_incl.xsec=xsec_incl_corrected. The inclusive sample will still be normalized via the wIncl weight below:

  conditionalWeight_incl = "(%.6g)"%(wIncl)
  ...
  sample_incl.norm = 1.0
  sample_incl.addweight(conditionalWeight_incl)

Run 3

It should not affect Run 3, because:

  xsec_incl_initial    = sample_incl.xsec
  if kfactor:
    xsec_incl_corrected = kfactor*xsec_incl_initial
  elif cme==13: # assume 13 TeV for Run 2
    ...
  else: # assume 13.6 TeV for Run 3
    xsec_incl_corrected = xsec_incl_initial
    kfactor = 1.

  ...

  #sample_incl.xsec = xsec_incl_corrected
  wIncl = sample_incl.lumi * kfactor * sample_incl.xsec * 1000. / sample_incl.sumweights

Side note:

The stitching has proven quite error prone. The k-factor is one of the major sources and we should factorize this like was done for Run 3, such that it is consistent and more transparent to users wether or not a k-factor is applied.

The other major source is the normalization and computation of stitching weight (e.g. if the weights, the number of MC events, or sum-of-weights are hardcoded, etc.). This should hopefully be addressed in a coming overthrow of the TauFW configuration, see https://gitlab.cern.ch/cms-tau-pog/tau-pog-coordination/-/issues/35