HEP-KBFI / TallinnNtupleProducer

code, python scripts and config files for producing "plain" Tallinn Ntuples
3 stars 2 forks source link

Apply trigger SF, save weights for corresponding shifts in the SF #21

Closed ktht closed 2 years ago

ktht commented 2 years ago

Resolves https://github.com/HEP-KBFI/TallinnNtupleProducer/issues/17. Tested 2lss+1tau and 1l+1tau.

The trigger SF depend on the reconstructed lepton and taus but their number is not guaranteed to pass the nominal cut, which could result in "undefined" behavior. In order to avoid computing bogus SF, I've placed the trigger SF computation under these if blocks: https://github.com/HEP-KBFI/TallinnNtupleProducer/blob/288ddb7a2f8115bbfc9add1c97190591787e9840/Framework/bin/produceNtuple.cc#L482-L495

In other words, the trigger SF are calculated only if the number of fakeable leptons and taus matches their nominal number.

ktht commented 2 years ago

Forgot to mention (and implement) one more detail: the pT thresholds documented in JSON API are a bit misleading because the binning for the trigger efficiencies varies between different types of triggers. For instance, for ditau trigger it's 40 GeV while for lepton+tau cross-trigger it's 25 GeV: https://github.com/HEP-KBFI/TallinnNtupleProducer/blob/cd03457288306af1edc1917ad0ba6ae7fe348983/EvtWeightTools/src/Data_to_MC_CorrectionInterface_trigger_Base.cc#L15-L20 The actual binning in the JSON file starts slightly below these thresholds. The documentation claims that the pT binning is universal and starts from 20 GeV, which is incorrect. If the input tau has a pT less than the threshold, then the code returns 0 for the SF: https://github.com/HEP-KBFI/TallinnNtupleProducer/blob/cd03457288306af1edc1917ad0ba6ae7fe348983/EvtWeightTools/src/Data_to_MC_CorrectionInterface_trigger_Base.cc#L116-L117

I think the ideal solution would be that the SF of zero is returned by correctionlib itself if any of the input parameters have a value smaller than the starting edge of the first bin. Catching these errors can be expensive when it's done frequently. We can voice this concern on a different timescale, though.