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

Public Member Functions

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

Public Attributes

str calibMode = 'correctData_CB':
 inputContainer
 containerName
 recalibratePhyslite
 writeTrackD0Z0
 runTrackBiasing

Detailed Description

the ConfigBlock for the muon four-momentum correction

Definition at line 15 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonCalibrationConfig.__init__ ( self)

Definition at line 18 of file MuonAnalysisConfig.py.

18 def __init__ (self) :
19 super (MuonCalibrationConfig, self).__init__ ()
20 self.setBlockName('Muons')
21 self.addOption ('inputContainer', '', type=str,
22 info="the name of the input muon container. If left empty, automatically defaults "
23 "to `AnalysisMuons` for PHYSLITE or `Muons` otherwise.")
24 self.addOption ('containerName', '', type=str,
25 noneAction='error',
26 info="the name of the output container after calibration.")
27 self.addOption ('postfix', "", type=str,
28 info="a postfix to apply to decorations and algorithm names. "
29 "Typically not needed here since the calibration is common to "
30 "all muons.")
31 self.addOption ('minPt', 3.0*GeV, type=float,
32 info=r"$p_\mathrm{T}$ cut (in MeV) to apply to calibrated muons.")
33 self.addOption ('recalibratePhyslite', True, type=bool,
34 info="whether to run the `CP::MuonCalibrationAndSmearingAlg` on "
35 "PHYSLITE derivations.")
36 self.addOption ('maxEta', 2.7, type=float,
37 info=r"maximum muon $\vert\eta\vert$.")
38 self.addOption ('excludeNSWFromPrecisionLayers', False, type=bool,
39 info="only for testing purposes, turn on to ignore NSW hits and "
40 "fix a crash with older derivations (p-tag <p5834).")
41 self.addOption ('calibMode', 'correctData_CB', type=str, info='calibration mode of the `MuonCalibTool` needed to turn on the sagitta bias corrections and to select the muon track calibration type (CB or ID+MS), see https://atlas-mcp.docs.cern.ch/guidelines/muonmomentumcorrections/index.html#cpmuoncalibtool-tool.')
42 self.addOption ('decorateTruth', False, type=bool,
43 info="decorate truth particle information on the reconstructed one.")
44 self.addOption ('writeTrackD0Z0', False, type = bool,
45 info=r"save the $d_0$ significance and $z_0\sin\theta$ variables.")
46 self.addOption ('writeColumnarToolVariables', False, type=bool,
47 info="whether to add variables needed for running the columnar muon tool(s) on the output n-tuple (EXPERIMENTAL).",
48 expertMode=True)
49 self.addOption ('runTrackBiasing', False, type=bool,
50 info="EXPERIMENTAL: This enables the `InDetTrackBiasingTool`, for tracks "
51 "associated to muons. The tool does not have Run 3 recommendations yet.",
52 expertMode=True)
53

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonCalibrationConfig.instanceName ( self)

Definition at line 54 of file MuonAnalysisConfig.py.

54 def instanceName (self) :
55 if self.postfix != "":
56 return self.postfix
57 else :
58 return self.containerName
59

◆ makeAlgs()

python.MuonAnalysisConfig.MuonCalibrationConfig.makeAlgs ( self,
config )

Definition at line 60 of file MuonAnalysisConfig.py.

60 def makeAlgs (self, config) :
61
62 log = logging.getLogger('MuonCalibrationConfig')
63
64 #make sure that this is sync with
65 #PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h#L31-37
66 if self.calibMode == 'correctData_CB':
67 calibMode = 0
68 elif self.calibMode == 'correctData_IDMS':
69 calibMode = 1
70 elif self.calibMode == 'notCorrectData_IDMS':
71 calibMode = 2
72 elif self.calibMode == 'notCorrectData_CB':
73 calibMode = 3
74 else :
75 raise ValueError ("invalid calibMode: \"" + self.calibMode + "\". Allowed values are correctData_CB, correctData_IDMS, notCorrectData_IDMS, notCorrectData_CB")
76
77 inputContainer = "AnalysisMuons" if config.isPhyslite() else "Muons"
78 if self.inputContainer:
79 inputContainer = self.inputContainer
80 config.setSourceName (self.containerName, inputContainer)
81 config.setContainerMeta (self.containerName, 'calibMode', calibMode)
82
83 # Set up a shallow copy to decorate
84 if config.wantCopy (self.containerName) :
85 alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'MuonShallowCopyAlg' )
86 alg.input = config.readName (self.containerName)
87 alg.output = config.copyName (self.containerName)
88
89 # Set up the eta-cut on all muons prior to everything else
90 alg = config.createAlgorithm( 'CP::AsgSelectionAlg',
91 'MuonEtaCutAlg' )
92 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
93 alg.selectionTool.maxEta = self.maxEta
94 alg.selectionDecoration = 'selectEta' + self.postfix + ',as_bits'
95 alg.particles = config.readName (self.containerName)
96 alg.preselection = config.getPreselection (self.containerName, '')
97 config.addSelection (self.containerName, '', alg.selectionDecoration)
98
99 # Set up the muon calibration and smearing algorithm:
100 alg = config.createAlgorithm( 'CP::MuonCalibrationAndSmearingAlg',
101 'MuonCalibrationAndSmearingAlg' )
102 config.addPrivateTool( 'calibrationAndSmearingTool',
103 'CP::MuonCalibTool' )
104
105 alg.calibrationAndSmearingTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
106 alg.calibrationAndSmearingTool.calibMode = calibMode
107 if config.geometry() is LHCPeriod.Run4:
108 log.warning("Disabling NSW hits for Run4 geometry")
109 alg.calibrationAndSmearingTool.ExcludeNSWFromPrecisionLayers = True
110 else:
111 alg.calibrationAndSmearingTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
112 alg.muons = config.readName (self.containerName)
113 alg.muonsOut = config.copyName (self.containerName)
114 alg.preselection = config.getPreselection (self.containerName, '')
115 if config.isPhyslite() and not self.recalibratePhyslite :
116 alg.skipNominal = True
117
118 # Set up the the pt selection
119 if self.minPt > 0:
120 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'MuonPtCutAlg' )
121 alg.selectionDecoration = 'selectPt' + self.postfix + ',as_bits'
122 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
123 alg.particles = config.readName (self.containerName)
124 alg.selectionTool.minPt = self.minPt
125 alg.preselection = config.getPreselection (self.containerName, '')
126 config.addSelection (self.containerName, '', alg.selectionDecoration,
127 preselection = True)
128
129 # Additional decorations
130 if self.writeTrackD0Z0:
131 alg = config.createAlgorithm( 'CP::AsgLeptonTrackDecorationAlg',
132 'LeptonTrackDecorator' )
133 if config.dataType() is not DataType.Data:
134 if self.runTrackBiasing:
135 InDetTrackCalibrationConfig.makeTrackBiasingTool(config, alg)
136 InDetTrackCalibrationConfig.makeTrackSmearingTool(config, alg)
137 alg.particles = config.readName (self.containerName)
138
139 alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' )
140 alg.particles = config.readName (self.containerName)
141
142 config.addOutputVar (self.containerName, 'pt', 'pt')
143 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
144 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
145 config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
146 config.addOutputVar (self.containerName, 'charge', 'charge', noSys=True)
147
148 if self.writeTrackD0Z0:
149 config.addOutputVar (self.containerName, 'd0_%SYS%', 'd0')
150 config.addOutputVar (self.containerName, 'd0sig_%SYS%', 'd0sig')
151 config.addOutputVar (self.containerName, 'z0_%SYS%', 'z0')
152 config.addOutputVar (self.containerName, 'z0sintheta_%SYS%', 'z0sintheta')
153 config.addOutputVar (self.containerName, 'z0sinthetasig_%SYS%', 'z0sinthetasig')
154
155 # decorate truth information on the reconstructed object:
156 if self.decorateTruth and config.dataType() is not DataType.Data:
157 config.addOutputVar (self.containerName, "truthType", "truth_type", noSys=True)
158 config.addOutputVar (self.containerName, "truthOrigin", "truth_origin", noSys=True)
159
160 config.addOutputVar (self.containerName, 'muonType', 'muonType', noSys=True, enabled=self.writeColumnarToolVariables)
161

Member Data Documentation

◆ calibMode

str python.MuonAnalysisConfig.MuonCalibrationConfig.calibMode = 'correctData_CB':

Definition at line 66 of file MuonAnalysisConfig.py.

◆ containerName

python.MuonAnalysisConfig.MuonCalibrationConfig.containerName

Definition at line 80 of file MuonAnalysisConfig.py.

◆ inputContainer

python.MuonAnalysisConfig.MuonCalibrationConfig.inputContainer

Definition at line 78 of file MuonAnalysisConfig.py.

◆ recalibratePhyslite

python.MuonAnalysisConfig.MuonCalibrationConfig.recalibratePhyslite

Definition at line 115 of file MuonAnalysisConfig.py.

◆ runTrackBiasing

python.MuonAnalysisConfig.MuonCalibrationConfig.runTrackBiasing

Definition at line 134 of file MuonAnalysisConfig.py.

◆ writeTrackD0Z0

python.MuonAnalysisConfig.MuonCalibrationConfig.writeTrackD0Z0

Definition at line 130 of file MuonAnalysisConfig.py.


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