102 if config.isPhyslite() :
103 metSuffix =
'AnalysisMET'
105 jetContainer = config.originalName (self.jets)
106 btIndex = jetContainer.find(
'_BTagging')
108 jetContainer = jetContainer[:btIndex]
109 if not jetContainer.endswith(
'Jets'):
110 raise ValueError(f
"MissingET: jet container name \"{jetContainer}\" does not end in \"Jets\", cannot determine MET suffix.")
111 metSuffix = jetContainer.removesuffix(
'Jets')
116 alg = config.createAlgorithm(
'CP::MetMakerAlg',
'MetMakerAlg' )
119 raise ValueError(
"MissingET: useNN=True requires 'networkFile'.")
120 config.addPrivateTool(
'makerTool',
'met::METNet' )
122 alg.makerTool.JetContainer = config.readName (self.jets)
123 alg.evaluateNNMET =
True
124 alg.doJetJVT = self.
useJVT
128 config.addPrivateTool(
'makerTool',
'met::METMaker' )
129 alg.makerTool.skipSystematicJetSelection = self.skipSystematicJetSelection
131 alg.doJetJVT = self.
useJVT
133 config.addPrivateTool(
'makerTool.JvtSelTool',
'CP::NNJvtSelectionTool' )
134 alg.makerTool.JvtSelTool.JetContainer = config.readName (self.jets)
135 alg.makerTool.JvtSelTool.JvtMomentName =
"NNJvt"
139 alg.makerTool.JetRejectionDec =
'fjvt_selection'
143 alg.makerTool.JetRejectionDec = fjvt_decoration
145 alg.makerTool.JetSelection = self.metWP
146 alg.makerTool.DoPFlow =
'PFlow' in metSuffix
or metSuffix==
"AnalysisMET"
147 alg.makerTool.DoSetMuonJetEMScale = self.setMuonJetEMScale
if self.muons
else False
148 alg.switchTauMu = self.switchTauMuOrder
150 if config.dataType()
is not DataType.Data :
151 config.addPrivateTool(
'systematicsTool',
'met::METSystematicsTool' )
153 alg.metCore =
'MET_Core_' + metSuffix
154 alg.metAssociation =
'METAssoc_' + metSuffix
155 alg.jets = config.readName (self.jets)
156 alg.softTermKey =
"PVSoftTrk" if not self.useCaloSoftTerm
else "SoftClus"
157 if self.muons !=
"" :
158 alg.muons, alg.muonsSelection = config.readNameAndSelection (self.muons, excludeFrom={
'or'})
159 if self.electrons !=
"" :
160 alg.electrons, alg.electronsSelection = config.readNameAndSelection (self.electrons, excludeFrom={
'or'})
161 if self.photons !=
"" :
162 alg.photons, alg.photonsSelection = config.readNameAndSelection (self.photons, excludeFrom={
'or'})
164 alg.taus, alg.tausSelection = config.readNameAndSelection (self.taus, excludeFrom={
'or'})
167 invisibleContainers, invisibleSelections = zip(*[config.readNameAndSelection (container, excludeFrom={
'or'})
for container
in invisible])
168 alg.invisible = list(invisibleContainers)
169 alg.invisibleSelection = list(invisibleSelections)
170 alg.met = config.writeName (self.
containerName, isMet =
True)
175 config.addOutputVar (self.
containerName,
'phi',
'phi', auxType=
'float')
176 config.addOutputVar (self.
containerName,
'name',
'name', noSys=
True, enabled=
False)
184 config.addOutputVar (self.
containerName,
'sumet',
'sumet', auxType=
'float')
187 alg = config.createAlgorithm(
'CP::MetBuilderAlg',
'MetBuilderAlg' )
188 alg.softTerm =
"PVSoftTrk" if not self.useCaloSoftTerm
else "SoftClus"
194 alg = config.createAlgorithm(
'CP::MetSignificanceAlg',
'MetSignificanceAlg' )
195 config.addPrivateTool(
'significanceTool',
'met::METSignificance' )
196 if self.muons !=
"" :
197 config.addPrivateTool(
'significanceTool.MuonCalibTool',
'CP::MuonCalibTool' )
199 alg.significanceTool.MuonCalibTool.calibMode = (
200 config.getContainerMeta(self.muons.
split(
".")[0],
'calibMode', failOnMiss=
True))
204 jetCalibConfig = self.jetCalibConfig
205 jetCalibSequence = self.jetCalibSequence
206 jetCalibArea = self.jetCalibArea
207 if jetCalibConfig ==
"":
208 jetCalibConfig =
"JES_data2017_2016_2015_Recommendation_PFlow_Aug2018_rel21.config"
209 jetCalibArea =
"00-04-81"
212 jetCalibSequence =
'JetArea_Residual_EtaJES_GSC_Smear'
215 egammaESModel = self.egammaESModel
216 egammaDecorrelationModel = self.egammaDecorrelationModel
217 if self.electrons !=
"" :
218 if egammaESModel ==
"":
220 config.getContainerMeta(self.electrons.
split(
".")[0],
'ESModel', failOnMiss=
True))
221 if egammaDecorrelationModel ==
"":
222 egammaDecorrelationModel = (
223 config.getContainerMeta(self.electrons.
split(
".")[0],
'decorrelationModel', failOnMiss=
True))
225 alg.significanceTool.SoftTermParam = 0
226 if self.softTermResolution > 0:
227 alg.significanceTool.SoftTermReso = self.softTermResolution
228 alg.significanceTool.TreatPUJets = self.treatPUJets
229 alg.significanceTool.JetCalibConfig = jetCalibConfig
230 alg.significanceTool.JetCalibSequence = jetCalibSequence
231 alg.significanceTool.JetCalibArea = jetCalibArea
232 alg.significanceTool.EgammaESModel = egammaESModel
233 alg.significanceTool.EgammaDecorrelationModel = egammaDecorrelationModel
234 alg.significanceTool.EgammaUseFastsim = (config.dataType()
is DataType.FastSim)
235 alg.significanceTool.TauTESConfig = self.tauTESConfig
237 config.addOutputVar (self.
containerName,
'significance_%SYS%',
'significance', auxType=
'float')
239 alg.sigDirectionalDecoration =
"sigDirectional_%SYS%"
240 alg.METOverSqrtSumETDecoration =
"METOverSqrtSumET_%SYS%"
241 alg.METOverSqrtHTDecoration =
"METOverSqrtHT_%SYS%"
242 config.addOutputVar (self.
containerName,
'sigDirectional_%SYS%',
'sigDirectional', auxType=
'float')
243 config.addOutputVar (self.
containerName,
'METOverSqrtSumET_%SYS%',
'METOverSqrtSumET', auxType=
'float')
244 config.addOutputVar (self.
containerName,
'METOverSqrtHT_%SYS%',
'METOverSqrtHT', auxType=
'float')