4 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigAccumulator
import DataType
9 """the ConfigBlock for the tau four-momentum correction"""
12 super (DiTauCalibrationConfig, self).__init__ ()
13 self.setBlockName(
'DiTaus')
14 self.addOption (
'inputContainer',
'', type=str,
15 info=
"select ditau input container, by default set to DiTauJets")
16 self.addOption (
'containerName',
'', type=str,
18 info=
"the name of the output container after calibration.")
19 self.addOption (
'postfix',
'', type=str,
20 info=
"a postfix to apply to decorations and algorithm names. "
21 "Typically not needed here since the calibration is common to "
23 self.addOption (
'rerunTruthMatching',
True, type=bool,
24 info=
"whether to rerun truth matching (sets up an instance of "
25 "CP::DiTauTruthMatchingAlg). The default is True.")
28 """Return the instance name for this block"""
29 return self.containerName + self.postfix
33 postfix = self.postfix
34 if postfix !=
'' and postfix[0] !=
'_' :
35 postfix =
'_' + postfix
37 inputContainer =
"DiTauJets"
38 if self.inputContainer:
39 inputContainer = self.inputContainer
40 config.setSourceName (self.containerName, inputContainer)
43 if self.rerunTruthMatching
and config.dataType()
is not DataType.Data:
44 alg = config.createAlgorithm(
'CP::DiTauTruthMatchingAlg',
45 'DiTauTruthMatchingAlg' )
46 config.addPrivateTool(
'matchingTool',
47 'TauAnalysisTools::DiTauTruthMatchingTool' )
48 alg.taus = config.readName (self.containerName)
49 alg.preselection = config.getPreselection (self.containerName,
'')
52 alg = config.createAlgorithm(
'CP::DiTauSmearingAlg',
'DiTauSmearingAlg' )
53 config.addPrivateTool(
'smearingTool',
'TauAnalysisTools::DiTauSmearingTool' )
54 alg.taus = config.readName (self.containerName)
55 alg.tausOut = config.copyName (self.containerName)
56 alg.preselection = config.getPreselection (self.containerName,
'')
60 """the ConfigBlock for the tau working point
62 This may at some point be split into multiple blocks (16 Mar 22)."""
65 super (DiTauWorkingPointConfig, self).__init__ ()
66 self.addOption (
'containerName',
'', type=str,
68 info=
"the name of the input container.")
69 self.addOption (
'selectionName',
'', type=str,
71 info=
"the name of the tau-jet selection to define (e.g. tight or "
73 self.addOption (
'postfix',
None, type=str,
74 info=
"a postfix to apply to decorations and algorithm names. "
75 "Typically not needed here as selectionName is used internally.")
76 self.addOption (
'quality',
None, type=str,
77 info=
"the ID WP (string) to use. Supported ID WPs: Tight, Medium, "
78 "Loose, VeryLoose, Baseline, BaselineForFakes.")
79 self.addOption (
'addSelectionToPreselection',
True, type=bool,
80 info=
"whether to retain only ditau-jets satisfying the working point "
81 "requirements. The default is True.")
84 """Return the instance name for this block"""
85 if self.postfix
is not None:
86 return self.containerName +
'_' + self.selectionName + self.postfix
88 return self.containerName +
'_' + self.selectionName
92 selectionPostfix = self.selectionName
93 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
94 selectionPostfix =
'_' + selectionPostfix
96 postfix = self.postfix
98 postfix = self.selectionName
99 if postfix !=
'' and postfix[0] !=
'_' :
100 postfix =
'_' + postfix
106 elif self.
quality ==
'Medium' :
111 raise ValueError (
"invalid tau quality: \"" + self.
quality +
112 "\", allowed values are Tight, Medium, Loose")
114 inputfile =
'TauAnalysisAlgorithms/ditau_selection_highpt.conf'
115 if "DiTauJetsLowPt" in self.containerName:
116 inputfile =
'TauAnalysisAlgorithms/ditau_selection_lowpt.conf'
119 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'DiTauSelectionAlg' )
120 config.addPrivateTool(
'selectionTool',
'TauAnalysisTools::DiTauSelectionTool' )
121 alg.selectionTool.ConfigPath = inputfile
122 alg.selectionDecoration =
'selected_ditau' + selectionPostfix +
',as_char'
123 alg.particles = config.readName (self.containerName)
124 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
125 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
126 preselection=self.addSelectionToPreselection)
131 if config.dataType()
is not DataType.Data:
132 alg = config.createAlgorithm(
'CP::DiTauEfficiencyCorrectionsAlg',
133 'DiTauEfficiencyCorrectionsAlg' )
134 config.addPrivateTool(
'efficiencyCorrectionsTool',
135 'TauAnalysisTools::DiTauEfficiencyCorrectionsTool' )
136 alg.efficiencyCorrectionsTool.JetIDLevel = IDLevel
137 alg.scaleFactorDecoration =
'tau_effSF' + postfix +
'_%SYS%'
140 alg.taus = config.readName (self.containerName)
141 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
142 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,