Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | List of all members
KLFitterConfig.KLFitterBlock Class Reference
Inheritance diagram for KLFitterConfig.KLFitterBlock:
Collaboration diagram for KLFitterConfig.KLFitterBlock:

Public Member Functions

def __init__ (self, containerName)
 
def parseSelectionRegionsConfig (self)
 
def makeAlgs (self, config)
 

Public Attributes

 containerName
 
 perRegionConfiguration
 
 likelihoodType
 

Detailed Description

ConfigBlock for KLFitter algorithms

Definition at line 7 of file KLFitterConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def KLFitterConfig.KLFitterBlock.__init__ (   self,
  containerName 
)

Definition at line 10 of file KLFitterConfig.py.

10  def __init__(self, containerName):
11  super(KLFitterBlock, self).__init__()
12  self.containerName = containerName
13  self.addOption(
14  "electrons",
15  "",
16  type=str,
17  info="the input electron container, with a possible selection, in the format container or container.selection. The default is '' (empty string).",
18  )
19  self.addOption(
20  "muons",
21  "",
22  type=str,
23  info="the input muon container, with a possible selection, in the format container or container.selection. The default is '' (empty string).",
24  )
25  self.addOption(
26  "jets",
27  "",
28  type=str,
29  info="the input jet container, with a possible selection, in the format container or container.selection. The default is '' (empty string).",
30  )
31  self.addOption(
32  "met",
33  "",
34  type=str,
35  info="the input MET container. The default is '' (empty string).",
36  )
37  self.addOption(
38  "likelihoodType",
39  "",
40  type=str,
41  info="KLFitter likelihood, if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
42  )
43  self.addOption(
44  "leptonType",
45  "",
46  type=str,
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).",
48  )
49  self.addOption(
50  "jetSelectionMode",
51  "",
52  type=str,
53  info="jet selection mode to use, if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
54  )
55  self.addOption(
56  "btaggingMethod",
57  "kNoTag",
58  type=str,
59  info="strategy to handle b-jets, if only one is needed. See KLFitterEnums.h for possible values. The default is '' (empty string).",
60  )
61  self.addOption(
62  "bTagCDIFile",
63  None,
64  type=str,
65  info="CDI file to pass to the b-tagging efficiency tool",
66  )
67  self.addOption(
68  "btagger",
69  "GN2v01",
70  type=str,
71  info="b-tagging algorithm to use, if only one is needed. The default is 'GN2v01'.",
72  )
73  self.addOption(
74  "btagWP",
75  "",
76  type=str,
77  info="b-tagging efficiency WP to use, if only one is needed.",
78  )
79  self.addOption(
80  "btagIgnoreOutOfValidityRange",
81  False,
82  type=bool,
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.",
84  )
85  self.addOption(
86  "selectionRegionsConfig",
87  "",
88  type=str,
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).",
90  )
91  self.addOption(
92  "saveAllPermutations",
93  False,
94  type=bool,
95  info="whether to save all permutations, or just the best one. The default is False (only save the best one).",
96  )
97  # list of dictionaries for the per-region config options
98  self.perRegionConfiguration = list()
99 

Member Function Documentation

◆ makeAlgs()

def KLFitterConfig.KLFitterBlock.makeAlgs (   self,
  config 
)

Definition at line 123 of file KLFitterConfig.py.

123  def makeAlgs(self, config):
124  self.parseSelectionRegionsConfig()
125  for perRegionConfig in self.perRegionConfiguration:
126  selectionName = perRegionConfig["selectionName"]
127  alg = config.createAlgorithm(
128  "EventReco::RunKLFitterAlg",
129  f"RunKLFitterAlg_{self.containerName}_{selectionName}",
130  )
131  # input objects and their object selections
132  alg.electrons, alg.electronSelection = config.readNameAndSelection(
133  self.electrons
134  )
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)
138  alg.result = self.containerName + "_%SYS%"
139 
140  # global settings, in future expect to expose more options for configuration
141  alg.SaveAllPermutations = self.saveAllPermutations
142 
143  # these settings can be defined per-region, but if not, we fallback to global setting
144  alg.selectionDecorationName = selectionName + "_%SYS%,as_char"
145  alg.LHType = self.likelihoodType
146  alg.LeptonType = perRegionConfig.get("leptonType", self.leptonType)
147  alg.JetSelectionMode = perRegionConfig.get(
148  "jetSelectionMode", self.jetSelectionMode
149  )
150  btagAlgo = perRegionConfig.get("btagger", self.btagger)
151  btagWP = perRegionConfig.get("btagWP", self.btagWP)
152  alg.BTaggingDecoration = f"ftag_select_{btagAlgo}_{btagWP}"
153 
154  alg.BTaggingMethod = perRegionConfig.get(
155  "btaggingMethod", self.btaggingMethod
156  )
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 = (
164  getRecommendedBTagCalib(config.geometry())
165  if self.bTagCDIFile is None
166  else self.bTagCDIFile
167  )
168  alg.btagEffTool.IgnoreOutOfValidityRange = (
169  self.btagIgnoreOutOfValidityRange
170  )
171  alg.btagEffTool.MinPt = (
172  20e3 # hardcoded to the recommendation for EMPFlow at the moment
173  )
174  # NOTE the efficiency tool is simply set to the default generator,
175  # meaning the results are not correct for alternative showering generators!!
176 
177  finalizeAlg = config.createAlgorithm(
178  "EventReco::KLFitterFinalizeOutputAlg",
179  "KLFitterFinalizeOutputAlg_" + self.containerName,
180  )
181  finalizeAlg.resultContainerToCheck = self.containerName + "_%SYS%"
182  finalizeAlg.resultContainerToWrite = self.containerName + "_%SYS%"
183 
184  config.setSourceName(self.containerName, self.containerName)
185  config.addOutputContainer(self.containerName, self.containerName + "_%SYS%")
186 
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")
191 
192  if self.likelihoodType != "ttbar_AllHad":
193  config.addOutputVar(
194  self.containerName, "model_bhad_jetIndex", "bhad_jetIndex"
195  )
196  config.addOutputVar(
197  self.containerName, "model_blep_jetIndex", "blep_jetIndex"
198  )
199  config.addOutputVar(
200  self.containerName, "model_lq1_jetIndex", "lq1_jetIndex"
201  )
202  if self.likelihoodType != "ttbar_BoostedLJets":
203  config.addOutputVar(
204  self.containerName, "model_lq2_jetIndex", "lq2_jetIndex"
205  )
206  if self.likelihoodType == "ttH":
207  config.addOutputVar(
208  self.containerName, "model_Higgs_b1_jetIndex", "Higgs_b1_jetIndex"
209  )
210  config.addOutputVar(
211  self.containerName, "model_Higgs_b2_jetIndex", "Higgs_b2_jetIndex"
212  )
213 
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")
218 
219  if self.likelihoodType == "ttZTrilepton":
220  config.addOutputVar(self.containerName, "model_lep_index", "lep_index")
221  config.addOutputVar(
222  self.containerName, "model_lepZ1_index", "lepZ1_index"
223  )
224  config.addOutputVar(
225  self.containerName, "model_lepZ2_index", "lepZ2_index"
226  )
227  else:
228  config.addOutputVar(
229  self.containerName, "model_b_from_top1_jetIndex", "b_from_top1_jetIndex"
230  )
231  config.addOutputVar(
232  self.containerName, "model_b_from_top2_jetIndex", "b_from_top2_jetIndex"
233  )
234  config.addOutputVar(
235  self.containerName,
236  "model_lj1_from_top1_jetIndex",
237  "lj1_from_top1_jetIndex",
238  )
239  config.addOutputVar(
240  self.containerName,
241  "model_lj2_from_top1_jetIndex",
242  "lj2_from_top1_jetIndex",
243  )
244  config.addOutputVar(
245  self.containerName,
246  "model_lj1_from_top2_jetIndex",
247  "lj1_from_top2_jetIndex",
248  )
249  config.addOutputVar(
250  self.containerName,
251  "model_lj2_from_top2_jetIndex",
252  "lj2_from_top2_jetIndex",
253  )

◆ parseSelectionRegionsConfig()

def KLFitterConfig.KLFitterBlock.parseSelectionRegionsConfig (   self)

Definition at line 100 of file KLFitterConfig.py.

100  def parseSelectionRegionsConfig(self):
101  regions = self.selectionRegionsConfig.split(";")
102  if len(regions) == 0:
103  raise Exception(
104  "KLFitterConfig: Could not determine any regions in your SelectionRegionsConfig"
105  )
106  for reg in regions:
107  regstrip = reg.replace(" ", "")
108  regionopts = dict(
109  tuple(option.split(":")) for option in regstrip.split(",")
110  )
111  if "selectionName" not in regionopts:
112  raise Exception(
113  "KLFitterConfig: Could not parse SelectionRegionsConfig selectionName for region ",
114  reg,
115  )
116  if "likelihoodType" in regionopts:
117  raise Exception(
118  "KLFitterConfig: likelihoodType cannot be overriden per region. Create a separate instance of KLFitter block with different likelihoodType instead."
119  )
120 
121  self.perRegionConfiguration.append(regionopts)
122 

Member Data Documentation

◆ containerName

KLFitterConfig.KLFitterBlock.containerName

Definition at line 12 of file KLFitterConfig.py.

◆ likelihoodType

KLFitterConfig.KLFitterBlock.likelihoodType

Definition at line 206 of file KLFitterConfig.py.

◆ perRegionConfiguration

KLFitterConfig.KLFitterBlock.perRegionConfiguration

Definition at line 98 of file KLFitterConfig.py.


The documentation for this class was generated from the following file:
python.FTagHelpers.getRecommendedBTagCalib
def getRecommendedBTagCalib(geometry)
Definition: FTagHelpers.py:11
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::split
@ split
Definition: LayerMaterialProperties.h:38