ATLAS Offline Software
MetAnalysisConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 # AnaAlgorithm import(s):
4 from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
6 
7 
8 class MetAnalysisConfig (ConfigBlock):
9  """the ConfigBlock for the MET configuration"""
10 
11  def __init__ (self) :
12  super (MetAnalysisConfig, self).__init__ ()
13  self.addOption('containerName', '', type=str,
14  noneAction='error',
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 "
25  "at all.")
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, "
45  "Tenacious")
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")
61 
62  def instanceName (self) :
63  """Return the instance name for this block"""
64  return self.containerName
65 
66  def makeAlgs (self, config) :
67 
68  if config.isPhyslite() :
69  metSuffix = 'AnalysisMET'
70  else :
71  jetContainer = config.originalName (self.jets)
72  metSuffix = jetContainer[:-4]
73  if self.useLRT:
74  metSuffix += "_LRT"
75 
76  # Remove b-tagging calibration from the MET suffix name
77  btIndex = metSuffix.find('_BTagging')
78  if btIndex != -1:
79  metSuffix = metSuffix[:btIndex]
80 
81  # Set up the met maker algorithm:
82  alg = config.createAlgorithm( 'CP::MetMakerAlg', 'MetMakerAlg' )
83  config.addPrivateTool( 'makerTool', 'met::METMaker' )
84  alg.makerTool.skipSystematicJetSelection = self.skipSystematicJetSelection
85 
86  alg.doJetJVT = self.useJVT
87  if self.useJVT:
88  config.addPrivateTool( 'makerTool.JvtSelTool', 'CP::NNJvtSelectionTool' )
89  alg.makerTool.JvtSelTool.JetContainer = config.readName (self.jets)
90  if self.useFJVT:
91  alg.makerTool.JetRejectionDec = 'fjvt_selection'
92 
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
96 
97  if config.dataType() is not DataType.Data :
98  config.addPrivateTool( 'systematicsTool', 'met::METSystematicsTool' )
99 
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'})
110  if self.taus != "" :
111  alg.taus, alg.tausSelection = config.readNameAndSelection (self.taus, excludeFrom={'or'})
112  if self.invisible:
113  if isinstance(self.invisible, str):
114  self.invisible = [self.invisible]
115  alg.invisible, alg.invisibleSelection = [config.readNameAndSelection (container, excludeFrom={'or'}) for container in self.invisible]
116  alg.met = config.writeName (self.containerName, isMet = True)
117 
118 
119  # Set up the met builder algorithm:
120  alg = config.createAlgorithm( 'CP::MetBuilderAlg', 'MetBuilderAlg' )
121  alg.softTerm = "PVSoftTrk" if not self.useCaloSoftTerm else "SoftClus"
122  alg.met = config.readName (self.containerName)
123 
124 
125  # Set up the met significance algorithm:
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' )
131  # Retrieve the calibMode from the container name.selections
132  alg.significanceTool.MuonCalibTool.calibMode = (
133  config.getContainerMeta(self.muons.split(".")[0], 'calibMode', failOnMiss=True))
134 
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')
149 
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)
python.MetAnalysisConfig.MetAnalysisConfig.invisible
invisible
Definition: MetAnalysisConfig.py:114
python.MetAnalysisConfig.MetAnalysisConfig.instanceName
def instanceName(self)
Definition: MetAnalysisConfig.py:62
python.MetAnalysisConfig.MetAnalysisConfig.makeAlgs
def makeAlgs(self, config)
Definition: MetAnalysisConfig.py:66
python.MetAnalysisConfig.MetAnalysisConfig
Definition: MetAnalysisConfig.py:8
python.MetAnalysisConfig.MetAnalysisConfig.__init__
def __init__(self)
Definition: MetAnalysisConfig.py:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38