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.")
26 self.addOption (
'decorateTruth',
False, type=bool,
27 info=
"decorate truth particle information on the reconstructed one")
28 self.addOption (
'decorateExtraVariables',
True, type=bool,
29 info=
"decorate extra variables for the reconstructed ditau")
32 """Return the instance name for this block"""
33 return self.containerName + self.postfix
37 postfix = self.postfix
38 if postfix !=
'' and postfix[0] !=
'_' :
39 postfix =
'_' + postfix
41 inputContainer =
"DiTauJets"
42 if self.inputContainer:
43 inputContainer = self.inputContainer
44 config.setSourceName (self.containerName, inputContainer)
47 if self.rerunTruthMatching
and config.dataType()
is not DataType.Data:
48 alg = config.createAlgorithm(
'CP::DiTauTruthMatchingAlg',
49 'DiTauTruthMatchingAlg' )
50 config.addPrivateTool(
'matchingTool',
51 'TauAnalysisTools::DiTauTruthMatchingTool' )
52 alg.taus = config.readName (self.containerName)
53 alg.preselection = config.getPreselection (self.containerName,
'')
57 if self.decorateTruth
and self.rerunTruthMatching
and config.dataType()
is not DataType.Data:
60 config.addOutputVar (self.containerName,
'TruthVisLeadPt',
'TruthVisLeadPt', noSys=
True)
61 config.addOutputVar (self.containerName,
'TruthVisLeadEta',
'TruthVisLeadEta', noSys=
True)
62 config.addOutputVar (self.containerName,
'TruthVisLeadPhi',
'TruthVisLeadPhi', noSys=
True)
63 config.addOutputVar (self.containerName,
'TruthVisLeadM',
'TruthVisLeadM', noSys=
True)
64 config.addOutputVar (self.containerName,
'TruthLeadPdgID',
'TruthLeadPdgID', noSys=
True)
65 config.addOutputVar (self.containerName,
'TruthVisSubleadPt',
'TruthVisSubleadPt', noSys=
True)
66 config.addOutputVar (self.containerName,
'TruthVisSubleadEta',
'TruthVisSubleadEta', noSys=
True)
67 config.addOutputVar (self.containerName,
'TruthVisSubleadPhi',
'TruthVisSubleadPhi', noSys=
True)
68 config.addOutputVar (self.containerName,
'TruthVisSubleadM',
'TruthVisSubleadM', noSys=
True)
69 config.addOutputVar (self.containerName,
'TruthSubleadPdgID',
'TruthSubleadPdgID', noSys=
True)
70 config.addOutputVar (self.containerName,
'TruthVisDeltaR',
'TruthVisDeltaR', noSys=
True)
71 config.addOutputVar (self.containerName,
'TruthVisMass',
'TruthVisMass', noSys=
True)
72 config.addOutputVar (self.containerName,
'IsTruthMatched',
'IsTruthMatched', noSys=
True)
73 config.addOutputVar (self.containerName,
'IsTruthHadronic',
'IsTruthHadronic', noSys=
True)
76 if self.decorateExtraVariables:
77 alg = config.createAlgorithm(
'CP::DiTauExtraVariablesAlg',
78 'DiTauExtraVariablesAlg',
80 alg.ditaus = config.readName (self.containerName)
81 config.addOutputVar (self.containerName,
'leadSubjetPt',
'leadSubjetPt', noSys=
True)
82 config.addOutputVar (self.containerName,
'leadSubjetEta',
'leadSubjetEta', noSys=
True)
83 config.addOutputVar (self.containerName,
'leadSubjetPhi',
'leadSubjetPhi', noSys=
True)
84 config.addOutputVar (self.containerName,
'leadSubjetE',
'leadSubjetE', noSys=
True)
85 config.addOutputVar (self.containerName,
'subleadSubjetPt',
'subleadSubjetPt', noSys=
True)
86 config.addOutputVar (self.containerName,
'subleadSubjetEta',
'subleadSubjetEta', noSys=
True)
87 config.addOutputVar (self.containerName,
'subleadSubjetPhi',
'subleadSubjetPhi', noSys=
True)
88 config.addOutputVar (self.containerName,
'subleadSubjetE',
'subleadSubjetE', noSys=
True)
91 alg = config.createAlgorithm(
'CP::DiTauSmearingAlg',
'DiTauSmearingAlg' )
92 config.addPrivateTool(
'smearingTool',
'TauAnalysisTools::DiTauSmearingTool' )
93 alg.taus = config.readName (self.containerName)
94 alg.tausOut = config.copyName (self.containerName)
95 alg.preselection = config.getPreselection (self.containerName,
'')
98 config.addOutputVar (self.containerName,
'pt',
'pt')
99 config.addOutputVar (self.containerName,
'eta',
'eta', noSys=
True)
100 config.addOutputVar (self.containerName,
'phi',
'phi', noSys=
True)
101 config.addOutputVar (self.containerName,
'm',
'm', noSys=
True)
106 """the ConfigBlock for the tau working point
108 This may at some point be split into multiple blocks (16 Mar 22)."""
111 super (DiTauWorkingPointConfig, self).__init__ ()
112 self.addOption (
'containerName',
'', type=str,
114 info=
"the name of the input container.")
115 self.addOption (
'selectionName',
'', type=str,
117 info=
"the name of the tau-jet selection to define (e.g. tight or "
119 self.addOption (
'postfix',
None, type=str,
120 info=
"a postfix to apply to decorations and algorithm names. "
121 "Typically not needed here as selectionName is used internally.")
122 self.addOption (
'quality',
None, type=str,
123 info=
"the ID WP (string) to use. Supported ID WPs: Tight, Medium, "
124 "Loose, VeryLoose, Baseline, BaselineForFakes.")
125 self.addOption (
'addSelectionToPreselection',
True, type=bool,
126 info=
"whether to retain only ditau-jets satisfying the working point "
127 "requirements. The default is True.")
130 """Return the instance name for this block"""
131 if self.postfix
is not None:
132 return self.containerName +
'_' + self.selectionName + self.postfix
134 return self.containerName +
'_' + self.selectionName
138 selectionPostfix = self.selectionName
139 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
140 selectionPostfix =
'_' + selectionPostfix
142 postfix = self.postfix
144 postfix = self.selectionName
145 if postfix !=
'' and postfix[0] !=
'_' :
146 postfix =
'_' + postfix
152 elif self.
quality ==
'Medium' :
157 raise ValueError (
"invalid tau quality: \"" + self.
quality +
158 "\", allowed values are Tight, Medium, Loose")
160 inputfile =
'TauAnalysisAlgorithms/ditau_selection_highpt.conf'
161 if "DiTauJetsLowPt" in self.containerName:
162 inputfile =
'TauAnalysisAlgorithms/ditau_selection_lowpt.conf'
165 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'DiTauSelectionAlg' )
166 config.addPrivateTool(
'selectionTool',
'TauAnalysisTools::DiTauSelectionTool' )
167 alg.selectionTool.ConfigPath = inputfile
168 alg.selectionDecoration =
'selected_ditau' + selectionPostfix +
',as_char'
169 alg.particles = config.readName (self.containerName)
170 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
171 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
172 preselection=self.addSelectionToPreselection)
177 if config.dataType()
is not DataType.Data:
178 alg = config.createAlgorithm(
'CP::DiTauEfficiencyCorrectionsAlg',
179 'DiTauEfficiencyCorrectionsAlg' )
180 config.addPrivateTool(
'efficiencyCorrectionsTool',
181 'TauAnalysisTools::DiTauEfficiencyCorrectionsTool' )
182 alg.efficiencyCorrectionsTool.JetIDLevel = IDLevel
183 alg.scaleFactorDecoration =
'tau_effSF' + postfix +
'_%SYS%'
186 alg.taus = config.readName (self.containerName)
187 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
188 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,