150 config: ConfigAccumulator,
153 triggerSuffix: str =
''
155 alg = config.createAlgorithm(
"CP::TrigGlobalEfficiencyAlg",
"TrigGlobalSFAlg" + triggerSuffix)
156 if config.geometry()
is LHCPeriod.Run3:
162 if not alg.triggers_2022:
163 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2022!')
165 if not alg.triggers_2023:
166 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2023!')
173 if not (alg.triggers_2015
and alg.triggers_2016):
174 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the years 2015 and 2016!')
176 if not alg.triggers_2015:
177 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2015!')
179 if not alg.triggers_2016:
180 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2016!')
182 if not alg.triggers_2017:
183 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2017!')
185 if not alg.triggers_2018:
186 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2018!')
188 triggerMatchingChains =
set()
192 triggerMatchingChains.update(trig.replace(
' || ',
'_OR_').
split(
'_OR_'))
193 alg.separateMatchingTriggers = list(triggerMatchingChains)
194 alg.separateMatchingDecorationSuffix = triggerSuffix + self.
postfix
196 alg.matchingTool =
'%s/%s' % ( matchingTool.getType(), matchingTool.getName() )
197 alg.isRun3Geo = config.geometry()
is LHCPeriod.Run3
198 alg.campaign = config.campaign().value
199 alg.numberOfToys = self.numberOfToys
200 alg.scaleFactorDecoration =
'globalTriggerEffSF' + triggerSuffix + self.
postfix +
'_%SYS%'
201 alg.matchingDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_%SYS%'
202 alg.eventDecisionOutputDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_dontsave_%SYS%'
203 alg.doMatchingOnly = config.dataType()
is DataType.Data
or noSF
204 alg.noFilter = self.noFilter
205 alg.electronID = self.electronID
206 alg.electronIsol = self.electronIsol
207 alg.photonIsol = self.photonIsol
208 alg.muonID = self.muonID
210 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.
electrons)
212 alg.muons, alg.muonSelection = config.readNameAndSelection(self.
muons)
214 alg.photons, alg.photonSelection = config.readNameAndSelection(self.
photons)
216 raise ValueError(
'TriggerAnalysisConfig: at least one object collection must be provided! (electrons, muons, photons)' )
218 if config.dataType()
is not DataType.Data
and not alg.doMatchingOnly:
219 config.addOutputVar(
'EventInfo', alg.scaleFactorDecoration,
'globalTriggerEffSF' + triggerSuffix + self.
postfix)
220 config.addOutputVar(
'EventInfo', alg.matchingDecoration,
'globalTriggerMatch' + triggerSuffix + self.
postfix, noSys=
False)
222 for trig
in triggerMatchingChains:
223 var = f
'triggerMatch_{trig.replace("-", "_").replace(".", "p")}{alg.separateMatchingDecorationSuffix}'
224 config.addOutputVar(
'EventInfo', f
'{var}_%SYS%', var, noSys=
False)
230 config: ConfigAccumulator,
233 trig_string: str =
"",
234 trig_chains: set =
None,
235 trig_chains_dummy: set =
None,
237 if not particles
or (
not trig_chains
and not trig_chains_dummy):
240 if not any(trig_string
in trig
for trig
in trig_chains) \
241 and not any(trig_string
in trig
for trig
in trig_chains_dummy):
244 alg = config.createAlgorithm(
"CP::TrigMatchingAlg", f
"TrigMatchingAlg_{trig_string}")
245 alg.matchingTool = f
"{matchingTool.getType()}/{matchingTool.getName()}"
246 alg.matchingDecoration = f
"trigMatched{self.postfix}"
247 alg.trigSingleMatchingList = [trig
for trig
in trig_chains
if trig_string
in trig]
248 alg.trigSingleMatchingListDummy = [trig
for trig
in trig_chains_dummy
if trig_string
in trig]
249 alg.particles, _ = config.readNameAndSelection(particles)
251 for trig
in list(alg.trigSingleMatchingList) + list(alg.trigSingleMatchingListDummy):
253 if trig_string
in trig:
254 config.addOutputVar(particles.split(
".")[0], f
"trigMatched{self.postfix}_{trig}", f
"trigMatched{self.postfix}_{trig}", noSys=
True, auxType=
"char")
258 config: ConfigAccumulator,
263 triggerMatchingChains =
set()
264 triggerMatchingChainsDummy =
set()
267 trig = trig.replace(
' || ',
'_OR_')
268 triggerMatchingChains.update(trig.split(
'_OR_'))
270 triggerMatchingChainsAll =
set()
272 if not is_year_in_current_period(config, year):
275 trig = trig.replace(
' || ',
'_OR_')
276 triggerMatchingChainsAll.update(trig.split(
'_OR_'))
277 triggerMatchingChainsDummy = triggerMatchingChainsAll - triggerMatchingChains
280 self.
createTrigMatching(config, matchingTool, self.
muons,
'HLT_mu', triggerMatchingChains, triggerMatchingChainsDummy)