149 config: ConfigAccumulator,
152 triggerSuffix: str =
''
154 alg = config.createAlgorithm(
'CP::TrigGlobalEfficiencyAlg',
'TrigGlobalSFAlg' + triggerSuffix + self.
postfix)
155 if config.geometry()
is LHCPeriod.Run3:
161 if not alg.triggers_2022:
162 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2022!')
164 if not alg.triggers_2023:
165 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2023!')
172 if not (alg.triggers_2015
and alg.triggers_2016):
173 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the years 2015 and 2016!')
175 if not alg.triggers_2015:
176 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2015!')
178 if not alg.triggers_2016:
179 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2016!')
181 if not alg.triggers_2017:
182 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2017!')
184 if not alg.triggers_2018:
185 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2018!')
187 triggerMatchingChains =
set()
191 triggerMatchingChains.update(trig.replace(
' || ',
'_OR_').
split(
'_OR_'))
192 alg.separateMatchingTriggers = list(triggerMatchingChains)
193 alg.separateMatchingDecorationSuffix = triggerSuffix + self.
postfix
195 alg.matchingTool =
'%s/%s' % ( matchingTool.getType(), matchingTool.getName() )
196 alg.isRun3Geo = config.geometry()
is LHCPeriod.Run3
197 alg.numberOfToys = self.numberOfToys
198 alg.scaleFactorDecoration =
'globalTriggerEffSF' + triggerSuffix + self.
postfix +
'_%SYS%'
199 alg.matchingDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_%SYS%'
200 alg.eventDecisionOutputDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_dontsave_%SYS%'
201 alg.doMatchingOnly = config.dataType()
is DataType.Data
or noSF
202 alg.noFilter = self.noFilter
203 alg.electronID = self.electronID
204 alg.electronIsol = self.electronIsol
205 alg.photonIsol = self.photonIsol
206 alg.muonID = self.muonID
208 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.
electrons)
210 alg.muons, alg.muonSelection = config.readNameAndSelection(self.
muons)
212 alg.photons, alg.photonSelection = config.readNameAndSelection(self.
photons)
214 raise ValueError(
'TriggerAnalysisConfig: at least one object collection must be provided! (electrons, muons, photons)' )
216 if config.dataType()
is not DataType.Data
and not alg.doMatchingOnly:
217 config.addOutputVar(
'EventInfo', alg.scaleFactorDecoration,
'globalTriggerEffSF' + triggerSuffix + self.
postfix)
218 config.addOutputVar(
'EventInfo', alg.matchingDecoration,
'globalTriggerMatch' + triggerSuffix + self.
postfix, noSys=
False)
220 for trig
in triggerMatchingChains:
221 var = f
'triggerMatch_{trig.replace("-", "_").replace(".", "p")}{alg.separateMatchingDecorationSuffix}'
222 config.addOutputVar(
'EventInfo', f
'{var}_%SYS%', var, noSys=
False)
228 config: ConfigAccumulator,
231 trig_string: str =
"",
232 trig_chains: set =
None,
233 trig_chains_dummy: set =
None,
235 if not particles
or (
not trig_chains
and not trig_chains_dummy):
238 if not any(trig_string
in trig
for trig
in trig_chains) \
239 and not any(trig_string
in trig
for trig
in trig_chains_dummy):
242 alg = config.createAlgorithm(
"CP::TrigMatchingAlg", f
"TrigMatchingAlg_{trig_string}{self.postfix}")
243 alg.matchingTool = f
"{matchingTool.getType()}/{matchingTool.getName()}"
244 alg.matchingDecoration = f
"trigMatched{self.postfix}"
245 alg.trigSingleMatchingList = [trig
for trig
in trig_chains
if trig_string
in trig]
246 alg.trigSingleMatchingListDummy = [trig
for trig
in trig_chains_dummy
if trig_string
in trig]
247 alg.particles, alg.particleSelection = config.readNameAndSelection(particles)
249 for trig
in list(alg.trigSingleMatchingList) + list(alg.trigSingleMatchingListDummy):
251 if trig_string
in trig:
252 config.addOutputVar(particles.split(
".")[0], f
"trigMatched_{self.postfix}{trig}", f
"trigMatched_{self.postfix}{trig}", noSys=
True)
256 config: ConfigAccumulator,
261 triggerMatchingChains =
set()
262 triggerMatchingChainsDummy =
set()
265 trig = trig.replace(
' || ',
'_OR_')
266 triggerMatchingChains.update(trig.split(
'_OR_'))
268 triggerMatchingChainsAll =
set()
270 if not is_year_in_current_period(config, year):
273 trig = trig.replace(
' || ',
'_OR_')
274 triggerMatchingChainsAll.update(trig.split(
'_OR_'))
275 triggerMatchingChainsDummy = triggerMatchingChainsAll - triggerMatchingChains
278 self.
createTrigMatching(config, matchingTool, self.
muons,
'HLT_mu', triggerMatchingChains, triggerMatchingChainsDummy)