147 def makeTriggerGlobalEffCorrAlg(
149 config: ConfigAccumulator,
152 triggerSuffix: str =
''
154 alg = config.createAlgorithm(
'CP::TrigGlobalEfficiencyAlg',
'TrigGlobalSFAlg' + triggerSuffix + self.postfix)
155 if config.geometry()
is LHCPeriod.Run3:
156 alg.triggers_2022 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2022)]
157 alg.triggers_2023 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2023)]
158 alg.triggers_2024 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2024)]
159 alg.triggers_2025 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2025)]
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!')
167 alg.triggers_2015 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2015)]
168 alg.triggers_2016 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2016)]
169 alg.triggers_2017 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2017)]
170 alg.triggers_2018 = [trig.replace(
"HLT_",
"").
replace(
" || ",
"_OR_")
for trig
in get_year_data(self.triggerChainsPerYear, 2018)]
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()
188 if self.separateChainMatching:
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)
213 if not (self.electrons
or self.muons
or 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)