4 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigSequence
import groupBlocks
6 from AnalysisAlgorithmsConfig.ConfigAccumulator
import DataType
7 from AthenaConfiguration.Enums
import LHCPeriod
11 """the ConfigBlock for trigger analysis"""
15 super (TriggerAnalysisBlock, self).__init__ ()
16 self.addOption (
'triggerChainsPerYear', {}, type=
None,
17 info=
"a dictionary with key (string) the year and value (list of "
18 "strings) the trigger chains. You can also use || within a string "
19 "to enforce an OR of triggers without looking up the individual "
20 "triggers. Used for both trigger selection and SFs. "
21 "The default is {} (empty dictionary).")
22 self.addOption (
'multiTriggerChainsPerYear', {}, type=
None,
23 info=
"a dictionary with key (string) a trigger set name and value a "
24 "triggerChainsPerYear dictionary, following the previous convention. "
25 "Relevant for analyses using different triggers in different categories, "
26 "where the trigger global scale factors shouldn't be combined. "
27 "The default is {} (empty dictionary).")
28 self.addOption (
'triggerChainsForSelection', [], type=
None,
29 info=
"a list of trigger chains (list of strings) to be used for "
30 "trigger selection. Only set it if you need a different setup "
31 "than for trigger SFs. The default is [] (empty list).")
32 self.addOption (
'prescaleLumiCalcFiles', [], type=
None,
33 info=
"a list of lumical files (list of strings) to calculate "
34 "trigger prescales. The default is [] (empty list).")
35 self.addOption (
'prescaleTriggersFormula',
'', type=str,
36 info=
"a formula used in (un)prescaling, producing overall prescale "
37 "factor instead of prescale per trigger.")
38 self.addOption (
'prescaleMC',
False, type=bool,
39 info=
"prescale MC instead of unprescaling of data.")
40 self.addOption (
'noFilter',
False, type=bool,
41 info=
"do not apply an event filter. The default is False, i.e. "
42 "remove events not passing trigger selection and matching.")
44 self.addOption (
'noL1',
False, type=bool,
50 xAODConfTool = config.createPublicTool(
'TrigConf::xAODConfigTool',
'xAODConfigTool' )
51 decisionTool = config.createPublicTool(
'Trig::TrigDecisionTool',
'TrigDecisionTool' )
52 decisionTool.ConfigTool =
'%s/%s' % \
53 ( xAODConfTool.getType(), xAODConfTool.getName() )
54 decisionTool.HLTSummary = config.hltSummary()
55 if config.geometry()
is LHCPeriod.Run3:
56 decisionTool.NavigationFormat =
'TrigComposite'
64 alg = config.createAlgorithm(
'CP::TrigEventSelectionAlg',
'TrigEventSelectionAlg' )
65 alg.tool =
'%s/%s' % \
66 ( decisionTool.getType(), decisionTool.getName() )
68 alg.selectionDecoration =
'trigPassed'
69 alg.noFilter = self.noFilter
73 t = t.replace(
".",
"p").
replace(
"-",
"_")
74 config.addOutputVar (
'EventInfo',
'trigPassed_' + t,
'trigPassed_' + t, noSys=
True)
77 if ((config.dataType()
is DataType.Data) != self.prescaleMC)
and self.prescaleLumiCalcFiles:
79 alg = config.createAlgorithm(
'CP::TrigPrescalesAlg',
'TrigPrescalesAlg' )
80 config.addPrivateTool(
'pileupReweightingTool',
'CP::PileupReweightingTool' )
81 alg.pileupReweightingTool.LumiCalcFiles = self.prescaleLumiCalcFiles
82 alg.pileupReweightingTool.TrigDecisionTool =
'%s/%s' % \
83 ( decisionTool.getType(), decisionTool.getName() )
84 if self.prescaleTriggersFormula !=
'':
85 alg.prescaleTriggersFormula = self.prescaleTriggersFormula
87 alg.triggers = [lumicalc.split(
':')[-1]
for lumicalc
in self.prescaleLumiCalcFiles
if ':' in lumicalc]
89 alg.prescaleMC = self.prescaleMC
90 alg.prescaleDecoration =
'prescale'
99 raise Exception(
'multiTriggerChainsPerYear and triggerChainsPerYear cannot be configured at the same time!')
108 for chain_list
in self.triggerChainsPerYear.
values():
109 for chain
in chain_list:
111 chains = chain.split(
'||')
112 triggers.update(map(str.strip, chains))
114 triggers.add(chain.strip())
130 from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig
import TriggerAnalysisSFBlock
131 seq.append(TriggerAnalysisSFBlock())