5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from AthenaMonitoringKernel.GenericMonitoringTool
import GenericMonitoringTool
9 from ROOT
import egammaPID
12 return [val]*( len( tool.EtaBins ) - 1 )
20 HistPath =
'PrecisionElectronHypo/'+name)
26 acc.merge(acc_ElectronCBSelectorTools)
27 acc.merge(acc_ElectronLHSelectorTools)
28 acc.merge(acc_ElectronDNNSelectorTools)
30 thePrecisionElectronHypo = CompFactory.TrigEgammaPrecisionElectronHypoAlg(name)
31 thePrecisionElectronHypo.Electrons =
str(sequenceOut)
32 thePrecisionElectronHypo.RunInView =
True
33 thePrecisionElectronHypo.ElectronCBSelectorTools = acc_ElectronCBSelectorTools.getPublicTools()
34 thePrecisionElectronHypo.ElectronLHSelectorTools = acc_ElectronLHSelectorTools.getPublicTools()
35 thePrecisionElectronHypo.ElectronDNNSelectorTools = acc_ElectronDNNSelectorTools.getPublicTools()
36 thePrecisionElectronHypo.CBNames = [
"medium",
"loose",
"mergedtight"]
37 thePrecisionElectronHypo.LHNames = [
"lhtight",
"lhmedium",
"lhloose",
"lhvloose",
38 "lhtight_nopix",
"lhmedium_nopix",
"lhloose_nopix",
"lhvloose_nopix",
39 "lhtight_nogsf",
"lhmedium_nogsf",
"lhloose_nogsf",
"lhvloose_nogsf",
40 "lhtight_nogsf_nopix",
"lhmedium_nogsf_nopix",
"lhloose_nogsf_nopix",
"lhvloose_nogsf_nopix"]
41 thePrecisionElectronHypo.DNNNames = [
"dnntight",
"dnnmedium",
"dnnloose"]
42 monTool.defineHistogram(
'TIME_exec', type=
'TH1F', path=
'EXPERT', title=
"Precision Electron Hypo Algtime; time [ us ] ; Nruns", xbins=80, xmin=0.0, xmax=8000.0)
43 monTool.defineHistogram(
'TIME_LH_exec', type=
'TH1F', path=
'EXPERT', title=
"Precision Electron Hypo LH Algtime; time [ us ] ; Nruns", xbins=20, xmin=0.0, xmax=2000)
44 monTool.defineHistogram(
'TIME_DNN_exec', type=
'TH1F', path=
'EXPERT', title=
"Precision Electron Hypo DNN Algtime; time [ us ] ; Nruns", xbins=20, xmin=0.0, xmax=2000)
46 thePrecisionElectronHypo.MonTool=monTool
48 return thePrecisionElectronHypo, acc
53 hypo_alg = hypo_tuple[0]
54 hypo_acc = hypo_tuple[1]
55 acc.addEventAlgo( hypo_alg )
62 __operation_points = [
'tight' ,
78 'lhtight_nogsf_nopix' ,
79 'lhmedium_nogsf_nopix' ,
80 'lhloose_nogsf_nopix' ,
81 'lhvloose_nogsf_nopix' ,
89 __operation_points_lhInfo = [
93 __operation_points_gsfInfo = [
117 def __init__(self, name, monGroups, cpart, tool=None):
119 from AthenaCommon.Logging
import logging
120 self.
__log = logging.getLogger(
'TrigEgammaPrecisionElectronHypoTool')
123 self.
__sel = cpart[
'addInfo'][0]
if cpart[
'addInfo']
else cpart[
'IDinfo']
131 from AthenaConfiguration.ComponentFactory
import CompFactory
132 tool = CompFactory.TrigEgammaPrecisionElectronHypoTool( name )
134 tool.EtaBins = [0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47]
136 tool.dETACLUSTERthr = 0.1
137 tool.dPHICLUSTERthr = 0.1
138 tool.RelPtConeCut = -999
141 tool.AcceptAll =
False
188 self.
tool().dETACLUSTERthr = 9999.
189 self.
tool().dPHICLUSTERthr = 9999.
193 self.
tool().DoNoPid =
True
197 self.
tool().dETACLUSTERthr = 9999.
198 self.
tool().dPHICLUSTERthr = 9999.
205 self.
__log.fatal(f
"Bad LRT selection name: {self.d0Info()}")
209 self.
tool().AcceptAll =
True
215 self.
__log.fatal(f
"Bad Iso selection name: {self.isoInfo()}")
222 self.
__log.fatal(
"Bad selection name: %s" % self.
pidname())
233 elif 'nopid' == self.
pidname():
246 if hasattr(self.
tool(),
"MonTool"):
248 doValidationMonitoring = flags.Trigger.doValidationMonitoring
251 if (any(
'egammaMon:online' in group
for group
in monGroups)
or doValidationMonitoring):
261 HistPath =
'PrecisionElectronHypo/'+self.
chain())
262 monTool.defineHistogram(
'dEta', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo #Delta#eta_{EF L1}; #Delta#eta_{EF L1}", xbins=80, xmin=-0.01, xmax=0.01)
263 monTool.defineHistogram(
'dPhi', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo #Delta#phi_{EF L1}; #Delta#phi_{EF L1}", xbins=80, xmin=-0.01, xmax=0.01)
264 monTool.defineHistogram(
'Et_em', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo cluster E_{T}^{EM};E_{T}^{EM} [MeV]", xbins=50, xmin=-2000, xmax=100000)
265 monTool.defineHistogram(
'Eta', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo entries per Eta;Eta", xbins=100, xmin=-2.5, xmax=2.5)
266 monTool.defineHistogram(
'Phi', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
267 monTool.defineHistogram(
'EtaBin', type=
'TH1I', path=
'EXPERT', title=
"PrecisionElectron Hypo entries per Eta bin;Eta bin no.", xbins=11, xmin=-0.5, xmax=10.5)
268 monTool.defineHistogram(
'LikelihoodRatio', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo LH", xbins=100, xmin=-5, xmax=5)
269 monTool.defineHistogram(
'mu', type=
'TH1F', path=
'EXPERT', title=
"Average interaction per crossing", xbins=100, xmin=0, xmax=100)
271 cuts=[
'Input',
'#Delta #eta EF-L1',
'#Delta #phi EF-L1',
'eta',
'E_{T}^{EM}']
273 monTool.defineHistogram(
'CutCounter', type=
'TH1I', path=
'EXPERT', title=
"PrecisionElectron Hypo Passed Cuts;Cut",
274 xbins=13, xmin=-1.5, xmax=12.5, opt=
"kCumulative", xlabels=cuts)
277 if flags.Trigger.doValidationMonitoring:
278 monTool.defineHistogram(
'ptcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo ptcone20; ptcone20;", xbins=50, xmin=0, xmax=5.0)
279 monTool.defineHistogram(
'relptcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo; ptcone20/pt;", xbins=50, xmin=0, xmax=1)
280 monTool.defineHistogram(
'ptvarcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo ptvarcone20; ptvarcone20;", xbins=50, xmin=0, xmax=5.0)
281 monTool.defineHistogram(
'relptvarcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo; ptvarcone20/pt;", xbins=50, xmin=0, xmax=0.5)
282 monTool.defineHistogram(
'trk_d0', type=
"TH1F", path=
'EXPERT', title=
"PrecisionElectron Hypo Track d0; d0 [mm]", xbins=100, xmin=-1, xmax=1)
284 self.
tool().MonTool = monTool
287 def _IncTool(flags, name, monGroups, cpart, tool=None):
289 config.compile(flags)
295 """ Use menu decoded chain dictionary to configure the tool """
296 cparts = [i
for i
in d[
'chainParts']
if ((i[
'signature']==
'Electron')
or (i[
'signature']==
'Electron'))]
297 return _IncTool( flags, d[
'chainName'], d[
'monGroups'], cparts[0] , tool=tool )
308 if not ConfigFilePath:
309 ConfigFilePath = flags.Trigger.egamma.dnnVersion
311 import collections.abc
312 SelectorNames = collections.OrderedDict({
313 'dnntight' :
'AsgElectronDNNTightSelector',
314 'dnnmedium' :
'AsgElectronDNNMediumSelector',
315 'dnnloose' :
'AsgElectronDNNLooseSelector',
318 ElectronToolConfigFile = collections.OrderedDict({
319 'dnntight' :
'ElectronDNNMulticlassTight.conf',
320 'dnnmedium' :
'ElectronDNNMulticlassMedium.conf',
321 'dnnloose' :
'ElectronDNNMulticlassLoose.conf',
324 for dnnname, name
in SelectorNames.items():
325 SelectorTool = CompFactory.AsgElectronSelectorTool(name)
326 SelectorTool.ConfigFile = ConfigFilePath +
'/' + ElectronToolConfigFile[dnnname]
327 SelectorTool.skipDeltaPoverP =
True
328 acc.addPublicTool(SelectorTool)
341 import collections.abc
342 SelectorConfigFiles = collections.OrderedDict({
343 'lhtight' :
'ElectronLikelihoodTightTriggerConfig',
344 'lhmedium' :
'ElectronLikelihoodMediumTriggerConfig',
345 'lhloose' :
'ElectronLikelihoodLooseTriggerConfig',
346 'lhvloose' :
'ElectronLikelihoodVeryLooseTriggerConfig'
349 VariationConfigInfos = collections.OrderedDict({
356 VariationConfigInfos[
'_default'][
'postfix'] =
''
357 VariationConfigInfos[
'_nopix'][
'postfix'] =
'_NoPix'
358 VariationConfigInfos[
'_nogsf'][
'postfix'] =
''
359 VariationConfigInfos[
'_nogsf_nopix'][
'postfix'] =
'_NoPix'
361 VariationConfigInfos[
'_default'][
'path'] = ConfigFilePath
if ConfigFilePath
else flags.Trigger.egamma.electronPidVersion
362 VariationConfigInfos[
'_nopix'][
'path'] = ConfigFileNoPixPath
if ConfigFileNoPixPath
else flags.Trigger.egamma.electronNoPixPidVersion
363 VariationConfigInfos[
'_nogsf'][
'path'] = ConfigFileNoGSFPath
if ConfigFileNoGSFPath
else flags.Trigger.egamma.electronNoGSFPidVersion
364 VariationConfigInfos[
'_nogsf_nopix'][
'path'] = ConfigFileNoGSFNoPixPath
if ConfigFileNoGSFNoPixPath
else flags.Trigger.egamma.electronNoGSFNoPixPidVersion
366 from AthenaCommon.Logging
import logging
367 log = logging.getLogger(
'TrigEgammaPrecisionElectronHypoTool')
368 log.debug(
'TrigEgammaPrecisionElectronLHSelectorCfg, order of LH tools:' )
370 for pidvar, config
in VariationConfigInfos.items():
371 for pidname, configfilebase
in SelectorConfigFiles.items():
372 fullpidname = pidname
if pidvar ==
'_default' else pidname + pidvar
373 toolname =
'AsgElectronSelector_' + fullpidname
374 configfile = config[
'path'] +
'/' + configfilebase + config[
'postfix'] +
'.conf'
375 skipdeltapcheck =
True if 'nogsf' in pidvar
else False
377 log.debug(
' --> %s, config file: %s', fullpidname, configfile )
379 SelectorTool = CompFactory.AsgElectronLikelihoodTool(toolname)
380 SelectorTool.ConfigFile = configfile
381 SelectorTool.usePVContainer =
False
382 SelectorTool.skipDeltaPoverP = skipdeltapcheck
383 acc.addPublicTool(SelectorTool)
394 from ElectronPhotonSelectorTools.TrigEGammaPIDdefs
import BitDefElectron
397 | 1 << BitDefElectron.ClusterEtaRange_Electron
398 | 1 << BitDefElectron.ClusterHadronicLeakage_Electron
399 | 1 << BitDefElectron.ClusterMiddleEnergy_Electron
400 | 1 << BitDefElectron.ClusterMiddleEratio37_Electron
401 | 1 << BitDefElectron.ClusterMiddleWidth_Electron
402 | 1 << BitDefElectron.ClusterStripsWtot_Electron
405 ElectronMediumHI = (ElectronLooseHI
406 | 1 << BitDefElectron.ClusterMiddleEratio33_Electron
407 | 1 << BitDefElectron.ClusterBackEnergyFraction_Electron
408 | 1 << BitDefElectron.ClusterStripsEratio_Electron
409 | 1 << BitDefElectron.ClusterStripsDeltaEmax2_Electron
410 | 1 << BitDefElectron.ClusterStripsDeltaE_Electron
411 | 1 << BitDefElectron.ClusterStripsFracm_Electron
412 | 1 << BitDefElectron.ClusterStripsWeta1c_Electron
415 if not ConfigFilePath:
416 ConfigFilePath = flags.Trigger.egamma.electronHIPidVersion
418 from collections
import OrderedDict
419 SelectorNames = OrderedDict({
420 'medium':
'AsgElectronIsEMSelectorHIMedium',
421 'loose':
'AsgElectronIsEMSelectorHILoose',
422 'mergedtight' :
'AsgElectronIsEMSelectorMergedTight',
425 ElectronToolConfigFile = {
426 'medium':
'ElectronIsEMMediumSelectorCutDefs.conf',
427 'loose':
'ElectronIsEMLooseSelectorCutDefs.conf',
428 'mergedtight' :
'ElectronIsEMMergedTightSelectorCutDefs.conf',
432 'medium': ElectronMediumHI,
433 'loose': ElectronLooseHI,
434 'mergedtight' : egammaPID.ElectronTightHLT,
437 for sel, name
in SelectorNames.items():
438 SelectorTool = CompFactory.AsgElectronIsEMSelector(name)
439 SelectorTool.ConfigFile = ConfigFilePath +
'/' + ElectronToolConfigFile[sel]
440 SelectorTool.isEMMask = ElectronMaskBits[sel]
441 acc.addPublicTool(SelectorTool)