4 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigAccumulator
import DataType
6 from AthenaConfiguration.Enums
import LHCPeriod
10 """the ConfigBlock for the MET configuration"""
13 super (MetAnalysisConfig, self).__init__ ()
14 self.addOption(
'containerName',
'', type=str,
16 info=
"the name of the input container")
17 self.addOption (
'useJVT',
True, type=bool,
18 info=
"whether to use the JVT decision in the MET calculation")
19 self.addOption (
'useFJVT',
False, type=bool,
20 info=
"whether to use the forward JVT decision in the MET calculation")
21 self.addOption (
'treatPUJets',
False, type=bool,
22 info=
"whether to treat pile-up jets in the MET significance calculation")
23 self.addOption (
'setMuonJetEMScale',
True, type=bool,
24 info=
"enables the handling of muons in jets for the MET calculation. "
25 "Should be turned off for analyses where muons are not reconstructed "
27 self.addOption (
'jets',
"", type=str,
28 info=
"the input jet container")
29 self.addOption (
'electrons',
"", type=str,
30 info=
"the input electron container, with a possible selection, in "
31 "the format `container` or `container.selection`")
32 self.addOption (
'muons',
"", type=str,
33 info=
"the input muon container, with a possible selection, in the "
34 "format `container` or `container.selection`")
35 self.addOption (
'photons',
"", type=str,
36 info=
"the input photon container, with a possible selection, in "
37 "the format `container` or `container.selection`")
38 self.addOption (
'taus',
"", type=str,
39 info=
"the input tau-jet container, with a possible selection, in "
40 "the format `container` or `container.selection`")
41 self.addOption (
'invisible', [], type=
None,
42 info=
"any input containers to be treated as invisible particles, "
43 "as a single string or a list of strings in the format `container` or `container.selection`")
44 self.addOption (
'metWP',
"Tight", type=str,
45 info=
"the MET working point to use: Loose, Tight, Tighter, "
47 self.addOption (
'skipSystematicJetSelection',
False, type=bool,
48 info=
"EXPERIMENTAL: whether to use simplified OR based on nominal jets "
49 "and for jet-related systematics only. "
50 "WARNING: this option is strictly for doing physics studies of the feasibility "
51 "of this OR scheme, it should not be used in a regular analysis",
53 self.addOption (
'saveSignificance',
True, type=bool,
54 info=
"whether to save the MET significance (default=True)")
55 self.addOption (
'jetCalibConfig',
"", type=str,
56 info=
"config file used in jet calibration (for MET significance)")
57 self.addOption (
'jetCalibSequence',
"", type=str,
58 info=
"jet calibration sequence (for MET significance)")
59 self.addOption (
'jetCalibArea',
"", type=str,
60 info=
"CalibArea used in jet calibration (for MET significance)")
61 self.addOption (
'egammaESModel',
"", type=str,
62 info=
"ESModel for egamma calibration (for MET significance)")
63 self.addOption (
'egammaDecorrelationModel',
"1NP_v1", type=str,
64 info=
"Decorrelation model for egamma calibration (for MET significance)")
65 self.addOption (
'tauTESConfig',
"CombinedTES_R22_Round2.5_v2.root", type=str,
66 info=
"Config file for tau energy scale calibration (for MET significance)")
67 self.addOption (
'tauUseMVAResolution',
True, type=bool,
68 info=
"Use MVA resolution for taus? (for MET significance)")
69 self.addOption (
'addExtraSignificanceVars',
False, type=bool,
70 info=
"whether to save some additional (event-based) MET significance variables (default=False)")
71 self.addOption (
'useLRT',
False, type=bool,
72 info=
"whether to use LRT MET Core and association map")
73 self.addOption (
'useCaloSoftTerm',
False, type=bool,
74 info=
"(expert) use calo- instead of track-based soft term",
76 self.addOption (
'softTermResolution', -1.0, type=float,
77 info=
"(expert) override the default soft term resolution in METSignificance",
81 """Return the instance name for this block"""
82 return self.containerName
86 if config.isPhyslite() :
87 metSuffix =
'AnalysisMET'
89 jetContainer = config.originalName (self.jets)
90 metSuffix = jetContainer[:-4]
95 btIndex = metSuffix.find(
'_BTagging')
97 metSuffix = metSuffix[:btIndex]
100 alg = config.createAlgorithm(
'CP::MetMakerAlg',
'MetMakerAlg' )
101 config.addPrivateTool(
'makerTool',
'met::METMaker' )
102 alg.makerTool.skipSystematicJetSelection = self.skipSystematicJetSelection
104 alg.doJetJVT = self.useJVT
106 config.addPrivateTool(
'makerTool.JvtSelTool',
'CP::NNJvtSelectionTool' )
107 alg.makerTool.JvtSelTool.JetContainer = config.readName (self.jets)
109 alg.makerTool.JetRejectionDec =
'fjvt_selection'
111 alg.makerTool.JetSelection = self.metWP
112 alg.makerTool.DoPFlow =
'PFlow' in metSuffix
or metSuffix==
"AnalysisMET"
113 alg.makerTool.DoSetMuonJetEMScale = self.setMuonJetEMScale
if self.muons
else False
115 if config.dataType()
is not DataType.Data :
116 config.addPrivateTool(
'systematicsTool',
'met::METSystematicsTool' )
118 alg.metCore =
'MET_Core_' + metSuffix
119 alg.metAssociation =
'METAssoc_' + metSuffix
120 alg.jets = config.readName (self.jets)
121 alg.softTermKey =
"PVSoftTrk" if not self.useCaloSoftTerm
else "SoftClus"
122 if self.muons !=
"" :
123 alg.muons, alg.muonsSelection = config.readNameAndSelection (self.muons, excludeFrom={
'or'})
124 if self.electrons !=
"" :
125 alg.electrons, alg.electronsSelection = config.readNameAndSelection (self.electrons, excludeFrom={
'or'})
126 if self.photons !=
"" :
127 alg.photons, alg.photonsSelection = config.readNameAndSelection (self.photons, excludeFrom={
'or'})
129 alg.taus, alg.tausSelection = config.readNameAndSelection (self.taus, excludeFrom={
'or'})
133 invisibleContainers, invisibleSelections = zip(*[config.readNameAndSelection (container, excludeFrom={
'or'})
for container
in self.
invisible])
134 alg.invisible =
list(invisibleContainers)
135 alg.invisibleSelection =
list(invisibleSelections)
136 alg.met = config.writeName (self.containerName, isMet =
True)
140 alg = config.createAlgorithm(
'CP::MetBuilderAlg',
'MetBuilderAlg' )
141 alg.softTerm =
"PVSoftTrk" if not self.useCaloSoftTerm
else "SoftClus"
142 alg.met = config.readName (self.containerName)
146 if self.saveSignificance:
147 alg = config.createAlgorithm(
'CP::MetSignificanceAlg',
'MetSignificanceAlg' )
148 config.addPrivateTool(
'significanceTool',
'met::METSignificance' )
149 if self.muons !=
"" :
150 config.addPrivateTool(
'significanceTool.MuonCalibTool',
'CP::MuonCalibTool' )
152 alg.significanceTool.MuonCalibTool.calibMode = (
153 config.getContainerMeta(self.muons.
split(
".")[0],
'calibMode', failOnMiss=
True))
157 if config.geometry()
is LHCPeriod.Run2:
158 self.
jetCalibConfig =
"PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.config"
160 elif config.geometry() >= LHCPeriod.Run3:
161 self.
jetCalibConfig =
"AntiKt4EMPFlow_MC23a_PreRecR22_Phase2_CalibConfig_ResPU_EtaJES_GSC_241208_InSitu.config"
171 if config.geometry()
is LHCPeriod.Run2:
173 elif config.geometry()
is LHCPeriod.Run3:
176 alg.significanceTool.SoftTermParam = 0
177 if self.softTermResolution > 0:
178 alg.significanceTool.SoftTermReso = self.softTermResolution
179 alg.significanceTool.TreatPUJets = self.treatPUJets
184 alg.significanceTool.EgammaDecorrelationModel = self.egammaDecorrelationModel
185 alg.significanceTool.EgammaUseFastsim = (config.dataType()
is DataType.FastSim)
186 alg.significanceTool.TauTESConfig = self.tauTESConfig
187 alg.significanceTool.TauUseMVAResolution = self.tauUseMVAResolution
188 alg.met = config.readName (self.containerName)
189 config.addOutputVar (self.containerName,
'significance_%SYS%',
'significance')
190 if self.addExtraSignificanceVars:
191 alg.sigDirectionalDecoration =
"sigDirectional_%SYS%"
192 alg.METOverSqrtSumETDecoration =
"METOverSqrtSumET_%SYS%"
193 alg.METOverSqrtHTDecoration =
"METOverSqrtHT_%SYS%"
194 config.addOutputVar (self.containerName,
'sigDirectional_%SYS%',
'sigDirectional')
195 config.addOutputVar (self.containerName,
'METOverSqrtSumET_%SYS%',
'METOverSqrtSumET')
196 config.addOutputVar (self.containerName,
'METOverSqrtHT_%SYS%',
'METOverSqrtHT')
198 config.addOutputVar (self.containerName,
'met',
'met')
199 config.addOutputVar (self.containerName,
'phi',
'phi')
200 config.addOutputVar (self.containerName,
'sumet',
'sumet')
201 config.addOutputVar (self.containerName,
'name',
'name', noSys=
True, enabled=
False)