ATLAS Offline Software
Loading...
Searching...
No Matches
python.MetAnalysisConfig.MetAnalysisConfig Class Reference
Inheritance diagram for python.MetAnalysisConfig.MetAnalysisConfig:
Collaboration diagram for python.MetAnalysisConfig.MetAnalysisConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeAlgs (self, config)

Public Attributes

 useLRT
 useNN
 networkFile
 useJVT
 useFJVT
 selectionNameFJVT
list invisible
 containerName
 saveSignificance
str jetCalibConfig = "":
str jetCalibArea = "00-04-81"
str jetCalibSequence = 'JetArea_Residual_EtaJES_GSC_Smear'
str egammaESModel = "":
str egammaDecorrelationModel = "":
 addExtraSignificanceVars

Detailed Description

the ConfigBlock for the MET configuration

Definition at line 8 of file MetAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MetAnalysisConfig.MetAnalysisConfig.__init__ ( self)

Definition at line 11 of file MetAnalysisConfig.py.

11 def __init__ (self) :
12 super (MetAnalysisConfig, self).__init__ ()
13 self.addOption('containerName', '', type=str,
14 noneAction='error',
15 info="the name of the output 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 ('selectionNameFJVT', "", type=str,
21 info="name of the forward JVT selection to be used if `useFJVT` is activated.")
22 self.addOption ('treatPUJets', False, type=bool,
23 info="whether to treat pile-up jets in the MET significance calculation.")
24 self.addOption ('setMuonJetEMScale', True, type=bool,
25 info="enables the handling of muons in jets for the MET calculation. "
26 "Should be turned off for analyses where muons are not reconstructed "
27 "at all.")
28 self.addOption ('jets', "", type=str,
29 info="the input jet container.")
30 self.addOption ('electrons', "", type=str,
31 info="the input electron container, with a possible selection, in "
32 "the format `container` or `container.selection`.")
33 self.addOption ('muons', "", type=str,
34 info="the input muon container, with a possible selection, in the "
35 "format `container` or `container.selection`.")
36 self.addOption ('photons', "", type=str,
37 info="the input photon container, with a possible selection, in "
38 "the format `container` or `container.selection`.")
39 self.addOption ('taus', "", type=str,
40 info="the input tau-jet container, with a possible selection, in "
41 "the format `container` or `container.selection`.")
42 self.addOption ('invisible', [], type=None,
43 info="any input containers to be treated as invisible particles, "
44 "as a single string or a list of strings in the format `container` or `container.selection`.")
45 self.addOption ('metWP', "Tight", type=str,
46 info="the MET working point to use: `Loose`, `Tight`, `Tighter`, "
47 "`Tenacious`.")
48 self.addOption ('skipSystematicJetSelection', False, type=bool,
49 info="EXPERIMENTAL: whether to use simplified OR based on nominal jets "
50 "and for jet-related systematics only. "
51 "WARNING: this option is strictly for doing physics studies of the feasibility "
52 "of this OR scheme, it should not be used in a regular analysis.",
53 expertMode=True)
54 self.addOption ('saveSignificance', True, type=bool,
55 info="whether to save the MET significance.")
56 self.addOption ('jetCalibConfig', "", type=str,
57 info="config file used in jet calibration (for MET significance).")
58 self.addOption ('jetCalibSequence', "", type=str,
59 info="jet calibration sequence (for MET significance).")
60 self.addOption ('jetCalibArea', "", type=str,
61 info="name of the CalibArea used in jet calibration (for MET significance).")
62 self.addOption ('egammaESModel', "", type=str,
63 info="ESModel for EGamma calibration (for MET significance).")
64 self.addOption ('egammaDecorrelationModel', "", type=str,
65 info="decorrelation model for EGamma calibration (for MET significance).")
66 self.addOption ('tauTESConfig', "CombinedTES_R22_Round2.5_v2.root", type=str,
67 info="config file for tau energy scale calibration (for MET significance).")
68 self.addOption ('tauUseMVAResolution', True, type=bool,
69 info="whether to use MVA resolution for taus-jets (for MET significance).")
70 self.addOption ('addExtraSignificanceVars', False, type=bool,
71 info="whether to save some additional (event-based) MET significance variables.")
72 self.addOption ('useLRT', False, type=bool,
73 info="whether to use LRT MET Core and association map.")
74 self.addOption ('useCaloSoftTerm', False, type=bool,
75 info="whether to use calo- instead of track-based soft term.",
76 expertMode=True)
77 self.addOption ('softTermResolution', -1.0, type=float,
78 info="override the default soft term resolution in METSignificance.",
79 expertMode=True)
80 self.addOption ('switchTauMuOrder', False, type=bool,
81 info="whether to switch order of taus and muons",
82 expertMode=True)
83 self.addOption ('useNN', False, type=bool,
84 info="use the METNet neural-network MET tool (met::METNet) instead of "
85 "met::METMaker. Produces the NN MET as the container's Final term.")
86 self.addOption ('networkFile', "", type=str,
87 info="path to the METNet ONNX network file (required when useNN=True).")
88

Member Function Documentation

◆ instanceName()

python.MetAnalysisConfig.MetAnalysisConfig.instanceName ( self)
Return the instance name for this block

Definition at line 89 of file MetAnalysisConfig.py.

89 def instanceName (self) :
90 """Return the instance name for this block"""
91 return self.containerName
92

◆ makeAlgs()

python.MetAnalysisConfig.MetAnalysisConfig.makeAlgs ( self,
config )

Definition at line 93 of file MetAnalysisConfig.py.

93 def makeAlgs (self, config) :
94
95 if config.isPhyslite() :
96 metSuffix = 'AnalysisMET'
97 else :
98 jetContainer = config.originalName (self.jets)
99 metSuffix = jetContainer.removesuffix('Jets')
100 if self.useLRT:
101 metSuffix += "_LRT"
102
103 # Remove b-tagging calibration from the MET suffix name
104 btIndex = metSuffix.find('_BTagging')
105 if btIndex != -1:
106 metSuffix = metSuffix[:btIndex]
107
108 # Set up the met maker algorithm:
109 alg = config.createAlgorithm( 'CP::MetMakerAlg', 'MetMakerAlg' )
110 if self.useNN:
111 if not self.networkFile:
112 raise ValueError("MissingET: useNN=True requires 'networkFile'.")
113 config.addPrivateTool( 'makerTool', 'met::METNet' )
114 alg.makerTool.NetworkFile = self.networkFile
115 alg.makerTool.JetContainer = config.readName (self.jets)
116 alg.evaluateNNMET = True
117 alg.doJetJVT = self.useJVT
118 # NOTE: no met::METSystematicsTool for the NN path — soft-term
119 # systematics are not defined for the network output.
120 else:
121 config.addPrivateTool( 'makerTool', 'met::METMaker' )
122 alg.makerTool.skipSystematicJetSelection = self.skipSystematicJetSelection
123
124 alg.doJetJVT = self.useJVT
125 if self.useJVT:
126 config.addPrivateTool( 'makerTool.JvtSelTool', 'CP::NNJvtSelectionTool' )
127 alg.makerTool.JvtSelTool.JetContainer = config.readName (self.jets)
128 alg.makerTool.JvtSelTool.JvtMomentName = "NNJvt"
129 if self.useFJVT:
130 # for backwards compatibility with "old" FJVT handling in JetAnalysisConfig.py
131 if not self.selectionNameFJVT:
132 alg.makerTool.JetRejectionDec = 'fjvt_selection'
133 # otherwise get the decoration from the selection
134 else:
135 fjvt_decoration = config.getFullSelection(self.jets, self.selectionNameFJVT, skipBase=True).replace(",as_char", "")
136 alg.makerTool.JetRejectionDec = fjvt_decoration
137
138 alg.makerTool.JetSelection = self.metWP
139 alg.makerTool.DoPFlow = 'PFlow' in metSuffix or metSuffix=="AnalysisMET"
140 alg.makerTool.DoSetMuonJetEMScale = self.setMuonJetEMScale if self.muons else False
141 alg.switchTauMu = self.switchTauMuOrder
142
143 if config.dataType() is not DataType.Data :
144 config.addPrivateTool( 'systematicsTool', 'met::METSystematicsTool' )
145
146 alg.metCore = 'MET_Core_' + metSuffix
147 alg.metAssociation = 'METAssoc_' + metSuffix
148 alg.jets = config.readName (self.jets)
149 alg.softTermKey = "PVSoftTrk" if not self.useCaloSoftTerm else "SoftClus"
150 if self.muons != "" :
151 alg.muons, alg.muonsSelection = config.readNameAndSelection (self.muons, excludeFrom={'or'})
152 if self.electrons != "" :
153 alg.electrons, alg.electronsSelection = config.readNameAndSelection (self.electrons, excludeFrom={'or'})
154 if self.photons != "" :
155 alg.photons, alg.photonsSelection = config.readNameAndSelection (self.photons, excludeFrom={'or'})
156 if self.taus != "" :
157 alg.taus, alg.tausSelection = config.readNameAndSelection (self.taus, excludeFrom={'or'})
158 if self.invisible:
159 if isinstance(self.invisible, str):
160 self.invisible = [self.invisible]
161 invisibleContainers, invisibleSelections = zip(*[config.readNameAndSelection (container, excludeFrom={'or'}) for container in self.invisible])
162 alg.invisible = list(invisibleContainers)
163 alg.invisibleSelection = list(invisibleSelections)
164 alg.met = config.writeName (self.containerName, isMet = True)
165
166 # met/phi are decorated on every term by the maker alg (for the NN path
167 # directly via evaluateNNMET), so they are output on both paths.
168 config.addOutputVar (self.containerName, 'met', 'met')
169 config.addOutputVar (self.containerName, 'phi', 'phi')
170 config.addOutputVar (self.containerName, 'name', 'name', noSys=True, enabled=False)
171
172 # The NN path writes the Final term directly (a builder sum would clobber
173 # it) and produces no meaningful sumet/significance, so it needs neither
174 # the met builder nor the significance algorithm.
175 if self.useNN:
176 return
177
178 config.addOutputVar (self.containerName, 'sumet', 'sumet')
179
180 # Set up the met builder algorithm:
181 alg = config.createAlgorithm( 'CP::MetBuilderAlg', 'MetBuilderAlg' )
182 alg.softTerm = "PVSoftTrk" if not self.useCaloSoftTerm else "SoftClus"
183 alg.met = config.readName (self.containerName)
184
185
186 # Set up the met significance algorithm:
187 if self.saveSignificance:
188 alg = config.createAlgorithm( 'CP::MetSignificanceAlg', 'MetSignificanceAlg' )
189 config.addPrivateTool( 'significanceTool', 'met::METSignificance' )
190 if self.muons != "" :
191 config.addPrivateTool( 'significanceTool.MuonCalibTool', 'CP::MuonCalibTool' )
192 # Retrieve the calibMode from the container name.selections
193 alg.significanceTool.MuonCalibTool.calibMode = (
194 config.getContainerMeta(self.muons.split(".")[0], 'calibMode', failOnMiss=True))
195
196 # Preliminary R22 recommendation is to use R21 jet resolutions from 2018 for MET significance.
197 # See Jet/Etmiss recommendation documentation for details.
198 if self.jetCalibConfig == "":
199 self.jetCalibConfig = "JES_data2017_2016_2015_Recommendation_PFlow_Aug2018_rel21.config"
200 self.jetCalibArea = "00-04-81"
201 # Include Smear and not InSitu, even when running on data.
202 # This is for technical reasons and allows access to the correct resolutions for both data and MC.
203 self.jetCalibSequence = 'JetArea_Residual_EtaJES_GSC_Smear'
204
205 # Standard e/gamma calibration. Must be kept in agreement with ElectronAnalysisConfig.py
206 if self.egammaESModel == "":
207 self.egammaESModel = (
208 config.getContainerMeta(self.electrons.split(".")[0], 'ESModel', failOnMiss=True))
209 if self.egammaDecorrelationModel == "":
210 self.egammaDecorrelationModel = (
211 config.getContainerMeta(self.electrons.split(".")[0], 'decorrelationModel', failOnMiss=True))
212
213 alg.significanceTool.SoftTermParam = 0
214 if self.softTermResolution > 0:
215 alg.significanceTool.SoftTermReso = self.softTermResolution
216 alg.significanceTool.TreatPUJets = self.treatPUJets
217 alg.significanceTool.JetCalibConfig = self.jetCalibConfig
218 alg.significanceTool.JetCalibSequence = self.jetCalibSequence
219 alg.significanceTool.JetCalibArea = self.jetCalibArea
220 alg.significanceTool.EgammaESModel = self.egammaESModel
221 alg.significanceTool.EgammaDecorrelationModel = self.egammaDecorrelationModel
222 alg.significanceTool.EgammaUseFastsim = (config.dataType() is DataType.FastSim)
223 alg.significanceTool.TauTESConfig = self.tauTESConfig
224 alg.significanceTool.TauUseMVAResolution = self.tauUseMVAResolution
225 alg.met = config.readName (self.containerName)
226 config.addOutputVar (self.containerName, 'significance_%SYS%', 'significance')
227 if self.addExtraSignificanceVars:
228 alg.sigDirectionalDecoration = "sigDirectional_%SYS%"
229 alg.METOverSqrtSumETDecoration = "METOverSqrtSumET_%SYS%"
230 alg.METOverSqrtHTDecoration = "METOverSqrtHT_%SYS%"
231 config.addOutputVar (self.containerName, 'sigDirectional_%SYS%', 'sigDirectional')
232 config.addOutputVar (self.containerName, 'METOverSqrtSumET_%SYS%', 'METOverSqrtSumET')
233 config.addOutputVar (self.containerName, 'METOverSqrtHT_%SYS%', 'METOverSqrtHT')
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

Member Data Documentation

◆ addExtraSignificanceVars

python.MetAnalysisConfig.MetAnalysisConfig.addExtraSignificanceVars

Definition at line 227 of file MetAnalysisConfig.py.

◆ containerName

python.MetAnalysisConfig.MetAnalysisConfig.containerName

Definition at line 168 of file MetAnalysisConfig.py.

◆ egammaDecorrelationModel

str python.MetAnalysisConfig.MetAnalysisConfig.egammaDecorrelationModel = "":

Definition at line 209 of file MetAnalysisConfig.py.

◆ egammaESModel

str python.MetAnalysisConfig.MetAnalysisConfig.egammaESModel = "":

Definition at line 206 of file MetAnalysisConfig.py.

◆ invisible

python.MetAnalysisConfig.MetAnalysisConfig.invisible

Definition at line 158 of file MetAnalysisConfig.py.

◆ jetCalibArea

str python.MetAnalysisConfig.MetAnalysisConfig.jetCalibArea = "00-04-81"

Definition at line 200 of file MetAnalysisConfig.py.

◆ jetCalibConfig

str python.MetAnalysisConfig.MetAnalysisConfig.jetCalibConfig = "":

Definition at line 198 of file MetAnalysisConfig.py.

◆ jetCalibSequence

str python.MetAnalysisConfig.MetAnalysisConfig.jetCalibSequence = 'JetArea_Residual_EtaJES_GSC_Smear'

Definition at line 203 of file MetAnalysisConfig.py.

◆ networkFile

python.MetAnalysisConfig.MetAnalysisConfig.networkFile

Definition at line 111 of file MetAnalysisConfig.py.

◆ saveSignificance

python.MetAnalysisConfig.MetAnalysisConfig.saveSignificance

Definition at line 187 of file MetAnalysisConfig.py.

◆ selectionNameFJVT

python.MetAnalysisConfig.MetAnalysisConfig.selectionNameFJVT

Definition at line 131 of file MetAnalysisConfig.py.

◆ useFJVT

python.MetAnalysisConfig.MetAnalysisConfig.useFJVT

Definition at line 129 of file MetAnalysisConfig.py.

◆ useJVT

python.MetAnalysisConfig.MetAnalysisConfig.useJVT

Definition at line 125 of file MetAnalysisConfig.py.

◆ useLRT

python.MetAnalysisConfig.MetAnalysisConfig.useLRT

Definition at line 100 of file MetAnalysisConfig.py.

◆ useNN

python.MetAnalysisConfig.MetAnalysisConfig.useNN

Definition at line 110 of file MetAnalysisConfig.py.


The documentation for this class was generated from the following file: