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.campaign = config.campaign().value
196 alg.numberOfToys = self.numberOfToys
197 alg.scaleFactorDecoration =
'globalTriggerEffSF' + triggerSuffix + self.
postfix +
'_%SYS%'
198 alg.matchingDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_%SYS%'
199 alg.eventDecisionOutputDecoration =
'globalTriggerMatch' + triggerSuffix + self.
postfix +
'_dontsave_%SYS%'
200 alg.doMatchingOnly = config.dataType()
is DataType.Data
or noSF
201 alg.noFilter = self.noFilter
202 alg.electronID = self.electronID
203 alg.electronIsol = self.electronIsol
204 alg.photonIsol = self.photonIsol
205 alg.muonID = self.muonID
207 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.
electrons)
209 alg.muons, alg.muonSelection = config.readNameAndSelection(self.
muons)
211 alg.photons, alg.photonSelection = config.readNameAndSelection(self.
photons)
213 raise ValueError(
'TriggerAnalysisConfig: at least one object collection must be provided! (electrons, muons, photons)' )
215 if config.dataType()
is not DataType.Data
and not alg.doMatchingOnly:
216 config.addOutputVar(
'EventInfo', alg.scaleFactorDecoration,
'globalTriggerEffSF' + triggerSuffix + self.
postfix)
217 config.addOutputVar(
'EventInfo', alg.matchingDecoration,
'globalTriggerMatch' + triggerSuffix + self.
postfix, noSys=
False)
219 for trig
in triggerMatchingChains:
220 var = f
'triggerMatch_{trig.replace("-", "_").replace(".", "p")}{alg.separateMatchingDecorationSuffix}'
221 config.addOutputVar(
'EventInfo', f
'{var}_%SYS%', var, noSys=
False)
227 config: ConfigAccumulator,
230 trig_string: str =
"",
231 trig_chains: set =
None,
232 trig_chains_dummy: set =
None,
234 if not particles
or (
not trig_chains
and not trig_chains_dummy):
237 if not any(trig_string
in trig
for trig
in trig_chains) \
238 and not any(trig_string
in trig
for trig
in trig_chains_dummy):
241 alg = config.createAlgorithm(
"CP::TrigMatchingAlg", f
"TrigMatchingAlg_{trig_string}{self.postfix}")
242 alg.matchingTool = f
"{matchingTool.getType()}/{matchingTool.getName()}"
243 alg.matchingDecoration = f
"trigMatched{self.postfix}"
244 alg.trigSingleMatchingList = [trig
for trig
in trig_chains
if trig_string
in trig]
245 alg.trigSingleMatchingListDummy = [trig
for trig
in trig_chains_dummy
if trig_string
in trig]
246 alg.particles, alg.particleSelection = config.readNameAndSelection(particles)
248 for trig
in list(alg.trigSingleMatchingList) + list(alg.trigSingleMatchingListDummy):
250 if trig_string
in trig:
251 config.addOutputVar(particles.split(
".")[0], f
"trigMatched_{self.postfix}{trig}", f
"trigMatched_{self.postfix}{trig}", noSys=
True)
255 config: ConfigAccumulator,
260 triggerMatchingChains =
set()
261 triggerMatchingChainsDummy =
set()
264 trig = trig.replace(
' || ',
'_OR_')
265 triggerMatchingChains.update(trig.split(
'_OR_'))
267 triggerMatchingChainsAll =
set()
269 if not is_year_in_current_period(config, year):
272 trig = trig.replace(
' || ',
'_OR_')
273 triggerMatchingChainsAll.update(trig.split(
'_OR_'))
274 triggerMatchingChainsDummy = triggerMatchingChainsAll - triggerMatchingChains
277 self.
createTrigMatching(config, matchingTool, self.
muons,
'HLT_mu', triggerMatchingChains, triggerMatchingChainsDummy)