4 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigAccumulator
import DataType
9 """the ConfigBlock for the MET configuration"""
12 super (MetAnalysisConfig, self).__init__ ()
13 self.addOption(
'containerName',
'', type=str,
15 info=
"the name of the input container")
16 self.addOption (
'useJVT',
True, type=bool,
17 info=
"whether to use the JVT decision in the MET calculation")
18 self.addOption (
'useFJVT',
False, type=bool,
19 info=
"whether to use the forward JVT decision in the MET calculation")
20 self.addOption (
'treatPUJets',
False, type=bool,
21 info=
"whether to treat pile-up jets in the MET significance calculation")
22 self.addOption (
'setMuonJetEMScale',
True, type=bool,
23 info=
"enables the handling of muons in jets for the MET calculation. "
24 "Should be turned off for analyses where muons are not reconstructed "
26 self.addOption (
'jets',
"", type=str,
27 info=
"the input jet container")
28 self.addOption (
'electrons',
"", type=str,
29 info=
"the input electron container, with a possible selection, in "
30 "the format `container` or `container.selection`")
31 self.addOption (
'muons',
"", type=str,
32 info=
"the input muon container, with a possible selection, in the "
33 "format `container` or `container.selection`")
34 self.addOption (
'photons',
"", type=str,
35 info=
"the input photon container, with a possible selection, in "
36 "the format `container` or `container.selection`")
37 self.addOption (
'taus',
"", type=str,
38 info=
"the input tau-jet container, with a possible selection, in "
39 "the format `container` or `container.selection`")
40 self.addOption (
'invisible', [], type=
None,
41 info=
"any input containers to be treated as invisible particles, "
42 "as a single string or a list of strings in the format `container` or `container.selection`")
43 self.addOption (
'metWP',
"Tight", type=str,
44 info=
"the MET working point to use: Loose, Tight, Tighter, "
46 self.addOption (
'skipSystematicJetSelection',
False, type=bool,
47 info=
"EXPERIMENTAL: whether to use simplified OR based on nominal jets "
48 "and for jet-related systematics only. "
49 "WARNING: this option is strictly for doing physics studies of the feasibility "
50 "of this OR scheme, it should not be used in a regular analysis")
51 self.addOption (
'saveSignificance',
True, type=bool,
52 info=
"whether to save the MET significance (default=True)")
53 self.addOption (
'addExtraSignificanceVars',
False, type=bool,
54 info=
"whether to save some additional (event-based) MET significance variables (default=False)")
55 self.addOption (
'useLRT',
False, type=bool,
56 info=
"whether to use LRT MET Core and association map")
57 self.addOption (
'useCaloSoftTerm',
False, type=bool,
58 info=
"(expert) use calo- instead of track-based soft term")
59 self.addOption (
'softTermResolution', -1.0, type=float,
60 info=
"(expert) override the default soft term resolution in METSignificance")
63 """Return the instance name for this block"""
64 return self.containerName
68 if config.isPhyslite() :
69 metSuffix =
'AnalysisMET'
71 jetContainer = config.originalName (self.jets)
72 metSuffix = jetContainer[:-4]
77 btIndex = metSuffix.find(
'_BTagging')
79 metSuffix = metSuffix[:btIndex]
82 alg = config.createAlgorithm(
'CP::MetMakerAlg',
'MetMakerAlg' )
83 config.addPrivateTool(
'makerTool',
'met::METMaker' )
84 alg.makerTool.skipSystematicJetSelection = self.skipSystematicJetSelection
86 alg.doJetJVT = self.useJVT
88 config.addPrivateTool(
'makerTool.JvtSelTool',
'CP::NNJvtSelectionTool' )
89 alg.makerTool.JvtSelTool.JetContainer = config.readName (self.jets)
91 alg.makerTool.JetRejectionDec =
'fjvt_selection'
93 alg.makerTool.JetSelection = self.metWP
94 alg.makerTool.DoPFlow =
'PFlow' in metSuffix
or metSuffix==
"AnalysisMET"
95 alg.makerTool.DoSetMuonJetEMScale = self.setMuonJetEMScale
if self.muons
else False
97 if config.dataType()
is not DataType.Data :
98 config.addPrivateTool(
'systematicsTool',
'met::METSystematicsTool' )
100 alg.metCore =
'MET_Core_' + metSuffix
101 alg.metAssociation =
'METAssoc_' + metSuffix
102 alg.jets = config.readName (self.jets)
103 alg.softTermKey =
"PVSoftTrk" if not self.useCaloSoftTerm
else "SoftClus"
104 if self.muons !=
"" :
105 alg.muons, alg.muonsSelection = config.readNameAndSelection (self.muons, excludeFrom={
'or'})
106 if self.electrons !=
"" :
107 alg.electrons, alg.electronsSelection = config.readNameAndSelection (self.electrons, excludeFrom={
'or'})
108 if self.photons !=
"" :
109 alg.photons, alg.photonsSelection = config.readNameAndSelection (self.photons, excludeFrom={
'or'})
111 alg.taus, alg.tausSelection = config.readNameAndSelection (self.taus, excludeFrom={
'or'})
115 alg.invisible, alg.invisibleSelection = [config.readNameAndSelection (container, excludeFrom={
'or'})
for container
in self.
invisible]
116 alg.met = config.writeName (self.containerName, isMet =
True)
120 alg = config.createAlgorithm(
'CP::MetBuilderAlg',
'MetBuilderAlg' )
121 alg.softTerm =
"PVSoftTrk" if not self.useCaloSoftTerm
else "SoftClus"
122 alg.met = config.readName (self.containerName)
126 if self.saveSignificance:
127 alg = config.createAlgorithm(
'CP::MetSignificanceAlg',
'MetSignificanceAlg' )
128 config.addPrivateTool(
'significanceTool',
'met::METSignificance' )
129 if self.muons !=
"" :
130 config.addPrivateTool(
'significanceTool.MuonCalibTool',
'CP::MuonCalibTool' )
132 alg.significanceTool.MuonCalibTool.calibMode = (
133 config.getContainerMeta(self.muons.
split(
".")[0],
'calibMode', failOnMiss=
True))
135 alg.significanceTool.SoftTermParam = 0
136 if self.softTermResolution > 0:
137 alg.significanceTool.SoftTermReso = self.softTermResolution
138 alg.significanceTool.TreatPUJets = self.treatPUJets
139 alg.significanceTool.IsAFII = config.dataType()
is DataType.FastSim
140 alg.met = config.readName (self.containerName)
141 config.addOutputVar (self.containerName,
'significance_%SYS%',
'significance')
142 if self.addExtraSignificanceVars:
143 alg.sigDirectionalDecoration =
"sigDirectional_%SYS%"
144 alg.METOverSqrtSumETDecoration =
"METOverSqrtSumET_%SYS%"
145 alg.METOverSqrtHTDecoration =
"METOverSqrtHT_%SYS%"
146 config.addOutputVar (self.containerName,
'sigDirectional_%SYS%',
'sigDirectional')
147 config.addOutputVar (self.containerName,
'METOverSqrtSumET_%SYS%',
'METOverSqrtSumET')
148 config.addOutputVar (self.containerName,
'METOverSqrtHT_%SYS%',
'METOverSqrtHT')
150 config.addOutputVar (self.containerName,
'met',
'met')
151 config.addOutputVar (self.containerName,
'phi',
'phi')
152 config.addOutputVar (self.containerName,
'sumet',
'sumet')
153 config.addOutputVar (self.containerName,
'name',
'name', noSys=
True, enabled=
False)