3 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
4 from FTagAnalysisAlgorithms.FTagHelpers
import getRecommendedBTagCalib
8 """ConfigBlock for KLFitter algorithms"""
11 super(KLFitterBlock, self).
__init__()
17 info=
"the input electron container, with a possible selection, in the format container or container.selection. The default is '' (empty string).",
23 info=
"the input muon container, with a possible selection, in the format container or container.selection. The default is '' (empty string).",
29 info=
"the input jet container, with a possible selection, in the format container or container.selection. The default is '' (empty string).",
35 info=
"the input MET container. The default is '' (empty string).",
41 info=
"KLFitter likelihood, if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
47 info=
"type of lepton to use (only relevant to certain likelihood types), if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
53 info=
"jet selection mode to use, if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
59 info=
"strategy to handle b-jets, if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
65 info=
"CDI file to pass to the b-tagging efficiency tool",
71 info=
"b-tagging algorithm to use, if only one is needed. The default is 'GN2v01'.",
77 info=
"b-tagging efficiency WP to use, if only one is needed.",
80 "btagIgnoreOutOfValidityRange",
83 info=
"whether or not the b-tagger should ignore (and not fail) when a jet is outside the calibration range. The default is False.",
86 "selectionRegionsConfig",
89 info=
"string of the form 'selectionName: sel1, optionA: opA, optionB: opB; selectionName: sel2, ...' where options can be likelihoodType, leptonType, jetSelectionMode, btaggingMethod, btagger or btagWP. The default is '' (empty string).",
92 "saveAllPermutations",
95 info=
"whether to save all permutations, or just the best one. The default is False (only save the best one).",
101 regions = self.selectionRegionsConfig.
split(
";")
102 if len(regions) == 0:
104 "KLFitterConfig: Could not determine any regions in your SelectionRegionsConfig"
107 regstrip = reg.replace(
" ",
"")
109 tuple(option.split(
":"))
for option
in regstrip.split(
",")
111 if "selectionName" not in regionopts:
113 "KLFitterConfig: Could not parse SelectionRegionsConfig selectionName for region ",
116 if "likelihoodType" in regionopts:
118 "KLFitterConfig: likelihoodType cannot be overriden per region. Create a separate instance of KLFitter block with different likelihoodType instead."
126 selectionName = perRegionConfig[
"selectionName"]
127 alg = config.createAlgorithm(
128 "EventReco::RunKLFitterAlg",
129 f
"RunKLFitterAlg_{self.containerName}_{selectionName}",
132 alg.electrons, alg.electronSelection = config.readNameAndSelection(
135 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
136 alg.jets, alg.jetSelection = config.readNameAndSelection(self.jets)
137 alg.met = config.readName(self.met)
141 alg.SaveAllPermutations = self.saveAllPermutations
144 alg.selectionDecorationName = selectionName +
"_%SYS%,as_char"
146 alg.LeptonType = perRegionConfig.get(
"leptonType", self.leptonType)
147 alg.JetSelectionMode = perRegionConfig.get(
148 "jetSelectionMode", self.jetSelectionMode
150 btagAlgo = perRegionConfig.get(
"btagger", self.btagger)
151 btagWP = perRegionConfig.get(
"btagWP", self.btagWP)
152 alg.BTaggingDecoration = f
"ftag_select_{btagAlgo}_{btagWP}"
154 alg.BTaggingMethod = perRegionConfig.get(
155 "btaggingMethod", self.btaggingMethod
157 if alg.BTaggingMethod ==
"kWorkingPoint":
158 config.addPrivateTool(
"btagEffTool",
"BTaggingEfficiencyTool")
159 alg.btagEffTool.TaggerName = self.btagger
160 alg.btagEffTool.OperatingPoint = self.btagWP
161 jetCollection = config.originalName(self.jets.
split(
".")[0])
162 alg.btagEffTool.JetAuthor = jetCollection
163 alg.btagEffTool.ScaleFactorFileName = (
165 if self.bTagCDIFile
is None
166 else self.bTagCDIFile
168 alg.btagEffTool.IgnoreOutOfValidityRange = (
169 self.btagIgnoreOutOfValidityRange
171 alg.btagEffTool.MinPt = (
177 finalizeAlg = config.createAlgorithm(
178 "EventReco::KLFitterFinalizeOutputAlg",
181 finalizeAlg.resultContainerToCheck = self.
containerName +
"_%SYS%"
182 finalizeAlg.resultContainerToWrite = self.
containerName +
"_%SYS%"
187 config.addOutputVar(self.
containerName,
"eventProbability",
"eventProbability")
188 config.addOutputVar(self.
containerName,
"logLikelihood",
"logLikelihood")
189 if self.saveAllPermutations:
190 config.addOutputVar(self.
containerName,
"selected",
"selected")
208 self.
containerName,
"model_Higgs_b1_jetIndex",
"Higgs_b1_jetIndex"
211 self.
containerName,
"model_Higgs_b2_jetIndex",
"Higgs_b2_jetIndex"
214 config.addOutputVar(self.
containerName,
"model_nu_pt",
"nu_pt")
215 config.addOutputVar(self.
containerName,
"model_nu_eta",
"nu_eta")
216 config.addOutputVar(self.
containerName,
"model_nu_phi",
"nu_phi")
217 config.addOutputVar(self.
containerName,
"model_nu_E",
"nu_E")
220 config.addOutputVar(self.
containerName,
"model_lep_index",
"lep_index")
229 self.
containerName,
"model_b_from_top1_jetIndex",
"b_from_top1_jetIndex"
232 self.
containerName,
"model_b_from_top2_jetIndex",
"b_from_top2_jetIndex"
236 "model_lj1_from_top1_jetIndex",
237 "lj1_from_top1_jetIndex",
241 "model_lj2_from_top1_jetIndex",
242 "lj2_from_top1_jetIndex",
246 "model_lj1_from_top2_jetIndex",
247 "lj1_from_top2_jetIndex",
251 "model_lj2_from_top2_jetIndex",
252 "lj2_from_top2_jetIndex",