158 config: ConfigAccumulator,
161 triggerSuffix: str =
''
163 alg = config.createAlgorithm(
"CP::TrigGlobalEfficiencyAlg",
"TrigGlobalSFAlg" + triggerSuffix)
164 if config.geometry()
is LHCPeriod.Run3:
170 if not alg.triggers_2022:
171 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2022!')
173 if not alg.triggers_2023:
174 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2023!')
181 if not (alg.triggers_2015
and alg.triggers_2016):
182 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the years 2015 and 2016!')
184 if not alg.triggers_2015:
185 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2015!')
187 if not alg.triggers_2016:
188 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2016!')
190 if not alg.triggers_2017:
191 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2017!')
193 if not alg.triggers_2018:
194 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2018!')
196 triggerMatchingChains =
set()
200 triggerMatchingChains.update(trig.replace(
' || ',
'_OR_').
split(
'_OR_'))
201 alg.separateMatchingTriggers = list(triggerMatchingChains)
202 alg.separateMatchingDecorationSuffix = triggerSuffix + self.
postfix
204 alg.matchingTool =
'%s/%s' % ( matchingTool.getType(), matchingTool.getName() )
205 alg.isRun3Geo = config.geometry()
is LHCPeriod.Run3
206 alg.campaign = config.campaign().value
207 alg.numberOfToys = self.numberOfToys
208 alg.scaleFactorDecoration =
'globalTriggerEffSF' + triggerSuffix + self.
postfix +
'_%SYS%'
209 alg.matchingDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_%SYS%'
210 alg.eventDecisionOutputDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_dontsave_%SYS%'
211 alg.doMatchingOnly = config.dataType()
is DataType.Data
or noSF
212 alg.noFilter = self.noFilter
213 alg.electronID = self.electronID
214 alg.electronIsol = self.electronIsol
215 alg.photonIsol = self.photonIsol
216 alg.muonID = self.muonID
218 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.
electrons)
220 alg.muons, alg.muonSelection = config.readNameAndSelection(self.
muons)
222 alg.photons, alg.photonSelection = config.readNameAndSelection(self.
photons)
224 raise ValueError(
'TriggerAnalysisConfig: at least one object collection must be provided! (electrons, muons, photons)' )
226 if config.dataType()
is not DataType.Data
and not alg.doMatchingOnly:
227 config.addOutputVar(
'EventInfo', alg.scaleFactorDecoration,
'globalTriggerEffSF' + triggerSuffix + self.
postfix)
228 config.addOutputVar(
'EventInfo', alg.matchingDecoration,
'globalTriggerMatch' + triggerSuffix + self.
postfix, noSys=
False)
230 for trig
in triggerMatchingChains:
231 var = f
'triggerMatch_{trig.replace("-", "_").replace(".", "p")}{alg.separateMatchingDecorationSuffix}'
232 config.addOutputVar(
'EventInfo', f
'{var}_%SYS%', var, noSys=
False)
238 config: ConfigAccumulator,
241 trig_string: str =
"",
242 trig_chains: set =
None,
243 trig_chains_dummy: set =
None,
245 if not particles
or (
not trig_chains
and not trig_chains_dummy):
248 if not any(trig_string
in trig
for trig
in trig_chains) \
249 and not any(trig_string
in trig
for trig
in trig_chains_dummy):
252 alg = config.createAlgorithm(
"CP::TrigMatchingAlg", f
"TrigMatchingAlg_{trig_string}")
253 alg.matchingTool = f
"{matchingTool.getType()}/{matchingTool.getName()}"
254 alg.matchingDecoration = f
"trigMatched{self.postfix}"
255 alg.trigSingleMatchingList = [trig
for trig
in trig_chains
if trig_string
in trig]
256 alg.trigSingleMatchingListDummy = [trig
for trig
in trig_chains_dummy
if trig_string
in trig]
257 alg.particles, _ = config.readNameAndSelection(particles)
259 for trig
in list(alg.trigSingleMatchingList) + list(alg.trigSingleMatchingListDummy):
261 if trig_string
in trig:
262 config.addOutputVar(particles.split(
".")[0], f
"trigMatched{self.postfix}_{trig}", f
"trigMatched{self.postfix}_{trig}", noSys=
True, auxType=
"char")
266 config: ConfigAccumulator,
271 triggerMatchingChains =
set()
272 triggerMatchingChainsDummy =
set()
275 trig = trig.replace(
' || ',
'_OR_')
276 triggerMatchingChains.update(trig.split(
'_OR_'))
278 triggerMatchingChainsAll =
set()
280 if not is_year_in_current_period(config, year):
283 trig = trig.replace(
' || ',
'_OR_')
284 triggerMatchingChainsAll.update(trig.split(
'_OR_'))
285 triggerMatchingChainsDummy = triggerMatchingChainsAll - triggerMatchingChains
288 self.
createTrigMatching(config, matchingTool, self.
muons,
'HLT_mu', triggerMatchingChains, triggerMatchingChainsDummy)