147 config: ConfigAccumulator,
150 triggerSuffix: str =
''
152 alg = config.createAlgorithm(
'CP::TrigGlobalEfficiencyAlg',
'TrigGlobalSFAlg' + triggerSuffix + self.
postfix)
153 if config.geometry()
is LHCPeriod.Run3:
159 if not alg.triggers_2022:
160 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2022!')
162 if not alg.triggers_2023:
163 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2023!')
170 if not (alg.triggers_2015
and alg.triggers_2016):
171 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the years 2015 and 2016!')
173 if not alg.triggers_2015:
174 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2015!')
176 if not alg.triggers_2016:
177 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2016!')
179 if not alg.triggers_2017:
180 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2017!')
182 if not alg.triggers_2018:
183 raise ValueError(
'TriggerAnalysisConfig: you must provide a set of triggers for the year 2018!')
185 triggerMatchingChains =
set()
189 triggerMatchingChains.update(trig.replace(
' || ',
'_OR_').
split(
'_OR_'))
190 alg.separateMatchingTriggers = list(triggerMatchingChains)
191 alg.separateMatchingDecorationSuffix = triggerSuffix + self.
postfix
193 alg.matchingTool =
'%s/%s' % ( matchingTool.getType(), matchingTool.getName() )
194 alg.isRun3Geo = config.geometry()
is LHCPeriod.Run3
195 alg.numberOfToys = self.numberOfToys
196 alg.scaleFactorDecoration =
'globalTriggerEffSF' + triggerSuffix + self.
postfix +
'_%SYS%'
197 alg.matchingDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_%SYS%'
198 alg.eventDecisionOutputDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_dontsave_%SYS%'
199 alg.doMatchingOnly = config.dataType()
is DataType.Data
or noSF
200 alg.noFilter = self.noFilter
201 alg.electronID = self.electronID
202 alg.electronIsol = self.electronIsol
203 alg.photonIsol = self.photonIsol
204 alg.muonID = self.muonID
206 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.
electrons)
208 alg.muons, alg.muonSelection = config.readNameAndSelection(self.
muons)
210 alg.photons, alg.photonSelection = config.readNameAndSelection(self.
photons)
212 raise ValueError(
'TriggerAnalysisConfig: at least one object collection must be provided! (electrons, muons, photons)' )
214 if config.dataType()
is not DataType.Data
and not alg.doMatchingOnly:
215 config.addOutputVar(
'EventInfo', alg.scaleFactorDecoration,
'globalTriggerEffSF' + triggerSuffix + self.
postfix)
216 config.addOutputVar(
'EventInfo', alg.matchingDecoration,
'globalTriggerMatch' + triggerSuffix + self.
postfix, noSys=
False)
218 for trig
in triggerMatchingChains:
219 var = f
'triggerMatch_{trig.replace("-", "_").replace(".", "p")}{alg.separateMatchingDecorationSuffix}'
220 config.addOutputVar(
'EventInfo', f
'{var}_%SYS%', var, noSys=
False)
226 config: ConfigAccumulator,
229 trig_string: str =
"",
230 trig_chains: set =
None,
231 trig_chains_dummy: set =
None,
233 if not particles
or (
not trig_chains
and not trig_chains_dummy):
236 if not any(trig_string
in trig
for trig
in trig_chains) \
237 and not any(trig_string
in trig
for trig
in trig_chains_dummy):
240 alg = config.createAlgorithm(
"CP::TrigMatchingAlg", f
"TrigMatchingAlg_{trig_string}{self.postfix}")
241 alg.matchingTool = f
"{matchingTool.getType()}/{matchingTool.getName()}"
242 alg.matchingDecoration = f
"trigMatched{self.postfix}"
243 alg.trigSingleMatchingList = [trig
for trig
in trig_chains
if trig_string
in trig]
244 alg.trigSingleMatchingListDummy = [trig
for trig
in trig_chains_dummy
if trig_string
in trig]
245 alg.particles, alg.particleSelection = config.readNameAndSelection(particles)
247 for trig
in list(alg.trigSingleMatchingList) + list(alg.trigSingleMatchingListDummy):
249 if trig_string
in trig:
250 config.addOutputVar(particles.split(
".")[0], f
"trigMatched_{self.postfix}{trig}", f
"trigMatched_{self.postfix}{trig}", noSys=
True)
254 config: ConfigAccumulator,
259 triggerMatchingChains =
set()
260 triggerMatchingChainsDummy =
set()
263 trig = trig.replace(
' || ',
'_OR_')
264 triggerMatchingChains.update(trig.split(
'_OR_'))
266 triggerMatchingChainsAll =
set()
268 if not is_year_in_current_period(config, year):
271 trig = trig.replace(
' || ',
'_OR_')
272 triggerMatchingChainsAll.update(trig.split(
'_OR_'))
273 triggerMatchingChainsDummy = triggerMatchingChainsAll - triggerMatchingChains
276 self.
createTrigMatching(config, matchingTool, self.
muons,
'HLT_mu', triggerMatchingChains, triggerMatchingChainsDummy)