5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from AthenaMonitoringKernel.GenericMonitoringTool
import GenericMonitoringTool
11 return [val]*( len( tool.EtaBins ) - 1 )
19 HistPath =
'PrecisionElectronHypo/'+name)
25 acc.merge(acc_ElectronCBSelectorTools)
26 acc.merge(acc_ElectronLHSelectorTools)
27 acc.merge(acc_ElectronDNNSelectorTools)
29 thePrecisionElectronHypo = CompFactory.TrigEgammaPrecisionElectronHypoAlg(name)
30 thePrecisionElectronHypo.Electrons =
str(sequenceOut)
31 thePrecisionElectronHypo.RunInView =
True
32 thePrecisionElectronHypo.ElectronCBSelectorTools = acc_ElectronCBSelectorTools.getPublicTools()
33 thePrecisionElectronHypo.ElectronLHSelectorTools = acc_ElectronLHSelectorTools.getPublicTools()
34 thePrecisionElectronHypo.ElectronDNNSelectorTools = acc_ElectronDNNSelectorTools.getPublicTools()
35 thePrecisionElectronHypo.CBNames = [
"medium",
"loose",
"mergedtight"]
36 thePrecisionElectronHypo.LHNames = [
"lhtight",
"lhmedium",
"lhloose",
"lhvloose",
37 "lhtight_nopix",
"lhmedium_nopix",
"lhloose_nopix",
"lhvloose_nopix",
38 "lhtight_nogsf",
"lhmedium_nogsf",
"lhloose_nogsf",
"lhvloose_nogsf",
39 "lhtight_nogsf_nopix",
"lhmedium_nogsf_nopix",
"lhloose_nogsf_nopix",
"lhvloose_nogsf_nopix"]
40 thePrecisionElectronHypo.DNNNames = [
"dnntight",
"dnnmedium",
"dnnloose"]
41 monTool.defineHistogram(
'TIME_exec', type=
'TH1F', path=
'EXPERT', title=
"Precision Electron Hypo Algtime; time [ us ] ; Nruns", xbins=80, xmin=0.0, xmax=8000.0)
42 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)
43 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)
45 thePrecisionElectronHypo.MonTool=monTool
47 return thePrecisionElectronHypo, acc
52 hypo_alg = hypo_tuple[0]
53 hypo_acc = hypo_tuple[1]
54 acc.addEventAlgo( hypo_alg )
61 __operation_points = [
'tight' ,
77 'lhtight_nogsf_nopix' ,
78 'lhmedium_nogsf_nopix' ,
79 'lhloose_nogsf_nopix' ,
80 'lhvloose_nogsf_nopix' ,
88 __operation_points_lhInfo = [
92 __operation_points_gsfInfo = [
116 def __init__(self, name, monGroups, cpart, tool=None):
118 from AthenaCommon.Logging
import logging
119 self.
__log = logging.getLogger(
'TrigEgammaPrecisionElectronHypoTool')
122 self.
__sel = cpart[
'addInfo'][0]
if cpart[
'addInfo']
else cpart[
'IDinfo']
130 from AthenaConfiguration.ComponentFactory
import CompFactory
131 tool = CompFactory.TrigEgammaPrecisionElectronHypoTool( name )
133 tool.EtaBins = [0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47]
135 tool.dETACLUSTERthr = 0.1
136 tool.dPHICLUSTERthr = 0.1
137 tool.RelPtConeCut = -999
140 tool.AcceptAll =
False
142 tool.UseRelptvarcone30 =
False
143 tool.UseTopoetcone20 =
False
189 self.
tool().dETACLUSTERthr = 9999.
190 self.
tool().dPHICLUSTERthr = 9999.
194 self.
tool().DoNoPid =
True
198 self.
tool().dETACLUSTERthr = 9999.
199 self.
tool().dPHICLUSTERthr = 9999.
206 self.
__log.fatal(f
"Bad LRT selection name: {self.d0Info()}")
210 self.
tool().AcceptAll =
True
216 valIsoCut = {
None:
None,
'ivarloose':flags.Trigger.egamma.isoWPs[0],
'ivarmedium':flags.Trigger.egamma.isoWPs[1],
'ivartight':flags.Trigger.egamma.isoWPs[2]}
217 topoIsoCut = {
None:
None,
'ivarloose':flags.Trigger.egamma.topoIsoWPs[0],
'ivarmedium':flags.Trigger.egamma.topoIsoWPs[1],
'ivartight':flags.Trigger.egamma.topoIsoWPs[2]}
218 if not self.
isoInfo()
in valIsoCut:
219 self.
__log.fatal(f
"Bad Iso selection name: {self.isoInfo()}")
220 self.
tool().UseRelptvarcone30 = flags.Trigger.egamma.useRelptvarcone30
221 self.
tool().RelPtConeCut = valIsoCut[self.
isoInfo()]
222 self.
tool().UseTopoetcone20 = flags.Trigger.egamma.useTopoetcone20
223 self.
tool().TopoEtConeCut = topoIsoCut[self.
isoInfo()]
230 self.
__log.fatal(
"Bad selection name: %s" % self.
pidname())
241 elif 'nopid' == self.
pidname():
254 if hasattr(self.
tool(),
"MonTool"):
256 doValidationMonitoring = flags.Trigger.doValidationMonitoring
259 if (any(
'egammaMon:online' in group
for group
in monGroups)
or doValidationMonitoring):
269 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)
270 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)
271 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)
272 monTool.defineHistogram(
'Eta', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo entries per Eta;Eta", xbins=100, xmin=-2.5, xmax=2.5)
273 monTool.defineHistogram(
'Phi', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
274 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)
275 monTool.defineHistogram(
'LikelihoodRatio', type=
'TH1F', path=
'EXPERT', title=
"PrecisionElectron Hypo LH", xbins=100, xmin=-5, xmax=5)
276 monTool.defineHistogram(
'mu', type=
'TH1F', path=
'EXPERT', title=
"Average interaction per crossing", xbins=100, xmin=0, xmax=100)
277 monTool.defineHistogram(
'relptvarcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo; ptvarcone20/pt;", xbins=50, xmin=0, xmax=2)
278 monTool.defineHistogram(
'relptvarcone30',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo; ptvarcone30/pt;", xbins=50, xmin=0, xmax=2)
279 monTool.defineHistogram(
'ptvarcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo ptvarcone20; ptvarcone20;", xbins=50, xmin=0, xmax=5.0)
280 monTool.defineHistogram(
'ptvarcone30',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo ptvarcone30; ptvarcone30;", xbins=50, xmin=0, xmax=5.0)
283 cuts=[
'Input',
'#Delta #eta EF-L1',
'#Delta #phi EF-L1',
'eta',
'E_{T}^{EM}',
'LH',
'Isolation']
284 monTool.defineHistogram(
'CutCounter', type=
'TH1I', path=
'EXPERT', title=
"PrecisionElectron Hypo Cut Counter;Cut Counter", xbins=7, xmin=0, xmax=7, opt=
"kCumulative",xlabels=cuts)
288 if flags.Trigger.doValidationMonitoring:
289 monTool.defineHistogram(
'relptcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo; ptcone20/pt;", xbins=50, xmin=0, xmax=2)
290 monTool.defineHistogram(
'relptcone30',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo; ptcone30/pt;", xbins=50, xmin=0, xmax=2)
291 monTool.defineHistogram(
'ptcone20',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo ptcone20; ptcone20;", xbins=50, xmin=0, xmax=5.0)
292 monTool.defineHistogram(
'ptcone30',type=
'TH1F',path=
'EXPERT',title=
"PrecisionElectron Hypo ptcone30; ptcone30;", xbins=50, xmin=0, xmax=5.0)
293 monTool.defineHistogram(
'trk_d0', type=
"TH1F", path=
'EXPERT', title=
"PrecisionElectron Hypo Track d0; d0 [mm]", xbins=100, xmin=-1, xmax=1)
295 self.
tool().MonTool = monTool
298 def _IncTool(flags, name, monGroups, cpart, tool=None):
300 config.compile(flags)
306 """ Use menu decoded chain dictionary to configure the tool """
307 cparts = [i
for i
in d[
'chainParts']
if ((i[
'signature']==
'Electron')
or (i[
'signature']==
'Electron'))]
308 return _IncTool( flags, d[
'chainName'], d[
'monGroups'], cparts[0] , tool=tool )
319 if not ConfigFilePath:
320 ConfigFilePath = flags.Trigger.egamma.dnnVersion
323 'dnntight' :
'AsgElectronDNNTightSelector',
324 'dnnmedium' :
'AsgElectronDNNMediumSelector',
325 'dnnloose' :
'AsgElectronDNNLooseSelector',
328 ElectronToolConfigFile = {
329 'dnntight' :
'ElectronDNNMulticlassTight.conf',
330 'dnnmedium' :
'ElectronDNNMulticlassMedium.conf',
331 'dnnloose' :
'ElectronDNNMulticlassLoose.conf',
334 for dnnname, name
in SelectorNames.items():
335 SelectorTool = CompFactory.AsgElectronSelectorTool(name)
336 SelectorTool.ConfigFile = ConfigFilePath +
'/' + ElectronToolConfigFile[dnnname]
337 SelectorTool.skipDeltaPoverP =
True
338 acc.addPublicTool(SelectorTool)
351 SelectorConfigFiles = {
352 'lhtight' :
'ElectronLikelihoodTightTriggerConfig',
353 'lhmedium' :
'ElectronLikelihoodMediumTriggerConfig',
354 'lhloose' :
'ElectronLikelihoodLooseTriggerConfig',
355 'lhvloose' :
'ElectronLikelihoodVeryLooseTriggerConfig'
358 VariationConfigInfos = {
365 VariationConfigInfos[
'_default'][
'postfix'] =
''
366 VariationConfigInfos[
'_nopix'][
'postfix'] =
'_NoPix'
367 VariationConfigInfos[
'_nogsf'][
'postfix'] =
''
368 VariationConfigInfos[
'_nogsf_nopix'][
'postfix'] =
'_NoPix'
370 VariationConfigInfos[
'_default'][
'path'] = ConfigFilePath
if ConfigFilePath
else flags.Trigger.egamma.electronPidVersion
371 VariationConfigInfos[
'_nopix'][
'path'] = ConfigFileNoPixPath
if ConfigFileNoPixPath
else flags.Trigger.egamma.electronNoPixPidVersion
372 VariationConfigInfos[
'_nogsf'][
'path'] = ConfigFileNoGSFPath
if ConfigFileNoGSFPath
else flags.Trigger.egamma.electronNoGSFPidVersion
373 VariationConfigInfos[
'_nogsf_nopix'][
'path'] = ConfigFileNoGSFNoPixPath
if ConfigFileNoGSFNoPixPath
else flags.Trigger.egamma.electronNoGSFNoPixPidVersion
375 from AthenaCommon.Logging
import logging
376 log = logging.getLogger(
'TrigEgammaPrecisionElectronHypoTool')
377 log.debug(
'TrigEgammaPrecisionElectronLHSelectorCfg, order of LH tools:' )
379 for pidvar, config
in VariationConfigInfos.items():
380 for pidname, configfilebase
in SelectorConfigFiles.items():
381 fullpidname = pidname
if pidvar ==
'_default' else pidname + pidvar
382 toolname =
'AsgElectronSelector_' + fullpidname
383 configfile = config[
'path'] +
'/' + configfilebase + config[
'postfix'] +
'.conf'
384 skipdeltapcheck =
True if 'nogsf' in pidvar
else False
386 log.debug(
' --> %s, config file: %s', fullpidname, configfile )
388 SelectorTool = CompFactory.AsgElectronLikelihoodTool(toolname)
389 SelectorTool.ConfigFile = configfile
390 SelectorTool.usePVContainer =
False
391 SelectorTool.skipDeltaPoverP = skipdeltapcheck
392 acc.addPublicTool(SelectorTool)
403 from ElectronPhotonSelectorTools.TrigEGammaPIDdefs
import BitDefElectron
404 from ROOT
import egammaPID
407 | 1 << BitDefElectron.ClusterEtaRange_Electron
408 | 1 << BitDefElectron.ClusterHadronicLeakage_Electron
409 | 1 << BitDefElectron.ClusterMiddleEnergy_Electron
410 | 1 << BitDefElectron.ClusterMiddleEratio37_Electron
411 | 1 << BitDefElectron.ClusterMiddleWidth_Electron
412 | 1 << BitDefElectron.ClusterStripsWtot_Electron
415 ElectronMediumHI = (ElectronLooseHI
416 | 1 << BitDefElectron.ClusterMiddleEratio33_Electron
417 | 1 << BitDefElectron.ClusterBackEnergyFraction_Electron
418 | 1 << BitDefElectron.ClusterStripsEratio_Electron
419 | 1 << BitDefElectron.ClusterStripsDeltaEmax2_Electron
420 | 1 << BitDefElectron.ClusterStripsDeltaE_Electron
421 | 1 << BitDefElectron.ClusterStripsFracm_Electron
422 | 1 << BitDefElectron.ClusterStripsWeta1c_Electron
425 if not ConfigFilePath:
426 ConfigFilePath = flags.Trigger.egamma.electronHIPidVersion
429 'medium':
'AsgElectronIsEMSelectorHIMedium',
430 'loose':
'AsgElectronIsEMSelectorHILoose',
431 'mergedtight' :
'AsgElectronIsEMSelectorMergedTight',
434 ElectronToolConfigFile = {
435 'medium':
'ElectronIsEMMediumSelectorCutDefs.conf',
436 'loose':
'ElectronIsEMLooseSelectorCutDefs.conf',
437 'mergedtight' :
'ElectronIsEMMergedTightSelectorCutDefs.conf',
441 'medium': ElectronMediumHI,
442 'loose': ElectronLooseHI,
443 'mergedtight' : egammaPID.ElectronTightHLT,
446 for sel, name
in SelectorNames.items():
447 SelectorTool = CompFactory.AsgElectronIsEMSelector(name)
448 SelectorTool.ConfigFile = ConfigFilePath +
'/' + ElectronToolConfigFile[sel]
449 SelectorTool.isEMMask = ElectronMaskBits[sel]
450 acc.addPublicTool(SelectorTool)