134 def makeTriggerGlobalEffCorrAlg(
136 config: ConfigAccumulator,
139 triggerSuffix: str =
''
141 alg = config.createAlgorithm(
'CP::TrigGlobalEfficiencyAlg',
'TrigGlobalSFAlg' + triggerSuffix + self.postfix)
142 if config.geometry()
is LHCPeriod.Run3:
143 alg.triggers_2022 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2022)]
144 alg.triggers_2023 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2023)]
145 alg.triggers_2024 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2024)]
146 alg.triggers_2025 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2025)]
148 if not alg.triggers_2022:
149 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2022!')
151 if not alg.triggers_2023:
152 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2023!')
154 alg.triggers_2015 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2015)]
155 alg.triggers_2016 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2016)]
156 alg.triggers_2017 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2017)]
157 alg.triggers_2018 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2018)]
159 if not (alg.triggers_2015
and alg.triggers_2016):
160 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the years 2015 and 2016!')
162 if not alg.triggers_2015:
163 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2015!')
165 if not alg.triggers_2016:
166 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2016!')
168 if not alg.triggers_2017:
169 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2017!')
171 if not alg.triggers_2018:
172 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2018!')
174 triggerMatchingChains =
set()
175 if self.separateChainMatching:
178 triggerMatchingChains.update(trig.replace(
' || ',
'_OR_').
split(
'_OR_'))
179 alg.separateMatchingTriggers =
list(triggerMatchingChains)
180 alg.separateMatchingDecorationSuffix = triggerSuffix + self.postfix
182 alg.matchingTool =
'%s/%s' % ( matchingTool.getType(), matchingTool.getName() )
183 alg.isRun3Geo = config.geometry()
is LHCPeriod.Run3
184 alg.numberOfToys = self.numberOfToys
185 alg.scaleFactorDecoration =
'globalTriggerEffSF' + triggerSuffix + self.postfix +
'_%SYS%'
186 alg.matchingDecoration =
'globalTriggerMatch' + triggerSuffix + self.postfix +
'_%SYS%'
187 alg.eventDecisionOutputDecoration =
'globalTriggerMatch' + triggerSuffix + self.postfix +
'_dontsave_%SYS%'
188 alg.doMatchingOnly = config.dataType()
is DataType.Data
or noSF
189 alg.noFilter = self.noFilter
190 alg.electronID = self.electronID
191 alg.electronIsol = self.electronIsol
192 alg.photonIsol = self.photonIsol
193 alg.muonID = self.muonID
195 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
197 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
199 alg.photons, alg.photonSelection = config.readNameAndSelection(self.photons)
200 if not (self.electrons
or self.muons
or self.photons):
201 raise ValueError(
'TriggerAnalysisConfig: at least one object collection must be provided! (electrons, muons, photons)' )
203 if config.dataType()
is not DataType.Data
and not alg.doMatchingOnly:
204 config.addOutputVar(
'EventInfo', alg.scaleFactorDecoration,
'globalTriggerEffSF' + triggerSuffix + self.postfix)
205 config.addOutputVar(
'EventInfo', alg.matchingDecoration,
'globalTriggerMatch' + triggerSuffix + self.postfix, noSys=
False)
207 for trig
in triggerMatchingChains:
208 var = f
'triggerMatch_{trig.replace("-", "_").replace(".", "p")}{alg.separateMatchingDecorationSuffix}'
209 config.addOutputVar(
'EventInfo', f
'{var}_%SYS%', var, noSys=
False)