207 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
208 selectionPostfix =
'_' + selectionPostfix
210 postfix = self.postfix
213 if postfix !=
'' and postfix[0] !=
'_' :
214 postfix =
'_' + postfix
218 nameFormat =
'TauAnalysisAlgorithms/tau_selection_'
220 nameFormat = nameFormat +
'nopt_'
222 nameFormat = nameFormat +
'lowpt_'
224 nameFormat = nameFormat +
'gntau_'
225 nameFormat = nameFormat +
'{}_'
227 nameFormat = nameFormat +
'eleid'
229 nameFormat = nameFormat +
'noeleid'
231 nameFormat = nameFormat +
'_muonolr'
232 nameFormat = nameFormat +
'.conf'
234 if self.
quality not in [
'Tight',
'Medium',
'Loose',
'VeryLoose',
'Baseline',
'BaselineForFakes'] :
235 raise ValueError (
"invalid tau quality: \"" + self.
quality +
236 "\", allowed values are Tight, Medium, Loose, " +
237 "VeryLoose, Baseline, BaselineForFakes")
240 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'TauSelectionAlg' )
241 config.addPrivateTool(
'selectionTool',
'TauAnalysisTools::TauSelectionTool' )
243 inputfile = nameFormat.format(self.
quality.lower())
244 alg.selectionTool.ConfigPath = inputfile
247 from ROOT
import TauAnalysisTools
248 selectioncuts = TauAnalysisTools.SelectionCuts
249 alg.selectionTool.ConfigPath =
""
250 alg.selectionTool.SelectionCuts = int(selectioncuts.CutPt |
251 selectioncuts.CutAbsEta |
252 selectioncuts.CutAbsCharge |
253 selectioncuts.CutNTrack |
254 selectioncuts.CutJetRNNScoreSigTrans |
255 selectioncuts.CutGNTauScoreSigTrans |
256 selectioncuts.CutJetIDWP |
257 selectioncuts.CutEleIDWP |
258 selectioncuts.CutMuonOLR)
260 alg.selectionTool.PtMin = self.manual_sel_minpt
261 alg.selectionTool.AbsEtaRegion = self.manual_sel_absetaregion
262 alg.selectionTool.AbsCharges = self.manual_sel_abscharges
263 alg.selectionTool.NTracks = self.manual_sel_ntracks
264 alg.selectionTool.JetRNNSigTransMin = self.manual_sel_minrnnscore
265 alg.selectionTool.GNTauSigTransMin = self.manual_sel_mingntauscore
267 if self.manual_sel_minrnnscore != -1
and self.manual_sel_mingntauscore != -1:
268 raise RuntimeError(
"manual_sel_minrnnscore and manual_sel_mingntauscore have been both set; please choose only one type of ID: RNN or GNTau, not both")
271 alg.selectionTool.JetIDWP = 1
273 alg.selectionTool.JetIDWP = 6
275 alg.selectionTool.JetIDWP = 7
277 alg.selectionTool.JetIDWP = 8
279 alg.selectionTool.JetIDWP = 9
281 raise ValueError (
"invalid RNN TauID WP: \"" + self.
manual_sel_rnnwp +
"\". Allowed values are None, veryloose, loose, medium, tight")
285 raise RuntimeError(
"manual_sel_minrnnscore and manual_sel_rnnwp have been both set; please set only one of them")
289 alg.selectionTool.JetIDWP = 1
291 alg.selectionTool.JetIDWP = 10
293 alg.selectionTool.JetIDWP = 11
295 alg.selectionTool.JetIDWP = 12
297 alg.selectionTool.JetIDWP = 13
299 raise ValueError (
"invalid GNN Tau ID WP: \"" + self.
manual_sel_gntauwp +
"\". Allowed values are None, veryloose, loose, medium, tight")
303 raise RuntimeError(
"manual_sel_mingntauscore and manual_sel_gntauwp have been both set; please set only one of them")
307 alg.selectionTool.EleIDWP = 1
309 alg.selectionTool.EleIDWP = 2
311 alg.selectionTool.EleIDWP = 3
313 alg.selectionTool.EleIDWP = 4
315 raise ValueError (
"invalid eVeto WP: \"" + self.
manual_sel_evetowp +
"\". Allowed values are None, loose, medium, tight")
318 alg.selectionTool.MuonOLR = self.manual_sel_muonolr
320 alg.selectionDecoration =
'selected_tau' + selectionPostfix +
',as_char'
324 preselection=self.addSelectionToPreselection)
329 if config.dataType()
is not DataType.Data
and not self.
noEffSF:
330 log = logging.getLogger(
'TauJetSFConfig')
336 alg = config.createAlgorithm(
'CP::TauEfficiencyCorrectionsAlg',
337 'TauEfficiencyCorrectionsAlgReco' )
338 config.addPrivateTool(
'efficiencyCorrectionsTool',
339 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
340 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [0]
341 alg.efficiencyCorrectionsTool.Campaign =
"mc23" if config.geometry()
is LHCPeriod.Run3
else "mc20"
342 alg.efficiencyCorrectionsTool.useFastSim = config.dataType()
is DataType.FastSim
343 alg.scaleFactorDecoration =
'tau_Reco_effSF' + selectionPostfix +
'_%SYS%'
344 alg.outOfValidity = 2
345 alg.outOfValidityDeco =
'bad_Reco_eff' + selectionPostfix
349 config.addOutputVar (self.
containerName, alg.scaleFactorDecoration,
350 'Reco_effSF' + postfix)
351 sfList += [alg.scaleFactorDecoration]
354 if self.
quality not in (
'VeryLoose',
'Baseline',
'BaselineForFakes'):
357 alg = config.createAlgorithm(
'CP::TauEfficiencyCorrectionsAlg',
358 'TauEfficiencyCorrectionsAlgID' )
359 config.addPrivateTool(
'efficiencyCorrectionsTool',
360 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
361 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [4]
369 raise ValueError (
"invalid tauID: \"" + self.
quality +
"\". Allowed values are loose, medium, tight")
371 alg.efficiencyCorrectionsTool.JetIDLevel = JetIDLevel
372 alg.efficiencyCorrectionsTool.useFastSim = config.dataType()
is DataType.FastSim
373 alg.efficiencyCorrectionsTool.Campaign =
"mc23" if config.geometry()
is LHCPeriod.Run3
else "mc20"
374 alg.scaleFactorDecoration =
'tau_ID_effSF' + selectionPostfix +
'_%SYS%'
375 alg.outOfValidity = 2
376 alg.outOfValidityDeco =
'bad_ID_eff' + selectionPostfix
380 config.addOutputVar (self.
containerName, alg.scaleFactorDecoration,
381 'ID_effSF' + postfix)
382 sfList += [alg.scaleFactorDecoration]
388 alg = config.createAlgorithm(
'CP::TauEfficiencyCorrectionsAlg',
389 'TauEfficiencyCorrectionsAlgEvetoFakeTau' )
390 config.addPrivateTool(
'efficiencyCorrectionsTool',
391 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
392 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [10]
394 alg.efficiencyCorrectionsTool.EleIDLevel = 2
397 alg.efficiencyCorrectionsTool.EleIDLevel = 2
399 alg.efficiencyCorrectionsTool.EleIDLevel = 3
401 alg.efficiencyCorrectionsTool.useFastSim = config.dataType()
is DataType.FastSim
402 alg.efficiencyCorrectionsTool.Campaign =
"mc23" if config.geometry()
is LHCPeriod.Run3
else "mc20"
403 alg.scaleFactorDecoration =
'tau_EvetoFakeTau_effSF' + selectionPostfix +
'_%SYS%'
410 log.warning(
"eVeto SFs are not available for Tight WP -> fallback to Medium WP")
412 alg.efficiencyCorrectionsTool.JetIDLevel = JetIDLevel
413 alg.outOfValidity = 2
414 alg.outOfValidityDeco =
'bad_EvetoFakeTau_eff' + selectionPostfix
418 config.addOutputVar (self.
containerName, alg.scaleFactorDecoration,
419 'EvetoFakeTau_effSF' + postfix)
420 sfList += [alg.scaleFactorDecoration]
423 alg = config.createAlgorithm(
'CP::TauEfficiencyCorrectionsAlg',
424 'TauEfficiencyCorrectionsAlgEvetoTrueTau' )
425 config.addPrivateTool(
'efficiencyCorrectionsTool',
426 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
427 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [8]
428 alg.efficiencyCorrectionsTool.useFastSim = config.dataType()
is DataType.FastSim
429 alg.efficiencyCorrectionsTool.Campaign =
"mc23" if config.geometry()
is LHCPeriod.Run3
else "mc20"
430 alg.scaleFactorDecoration =
'tau_EvetoTrueTau_effSF' + selectionPostfix +
'_%SYS%'
431 alg.outOfValidity = 2
432 alg.outOfValidityDeco =
'bad_EvetoTrueTau_eff' + selectionPostfix
436 config.addOutputVar (self.
containerName, alg.scaleFactorDecoration,
437 'EvetoTrueTau_effSF' + postfix)
438 sfList += [alg.scaleFactorDecoration]
441 alg = config.createAlgorithm(
'CP::AsgObjectScaleFactorAlg',
442 'TauCombinedEfficiencyScaleFactorAlg' )
444 alg.inScaleFactors = sfList
445 alg.outScaleFactor =
'effSF' + postfix +
'_%SYS%'