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 14 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonCalibrationConfig.__init__ ( self)

Definition at line 17 of file MuonAnalysisConfig.py.

17 def __init__ (self) :
18 super (MuonCalibrationConfig, self).__init__ ()
19 self.setBlockName('Muons')
20 self.addOption ('inputContainer', '', type=str,
21 info="select muon input container, by default set to Muons")
22 self.addOption ('containerName', '', type=str,
23 noneAction='error',
24 info="the name of the output container after calibration.")
25 self.addOption ('postfix', "", type=str,
26 info="a postfix to apply to decorations and algorithm names. "
27 "Typically not needed here since the calibration is common to "
28 "all muons.")
29 self.addOption ('minPt', 3.0*GeV, type=float,
30 info="pT cut to apply to calibrated muons, in MeV. "
31 "The default is 3.0 GeV.")
32 self.addOption ('recalibratePhyslite', True, type=bool,
33 info="whether to run the CP::EgammaCalibrationAndSmearingAlg on "
34 "PHYSLITE derivations. The default is True.")
35 self.addOption ('maxEta', 2.7, type=float,
36 info="maximum muon |eta| (float). The default is 2.7.")
37 self.addOption ('excludeNSWFromPrecisionLayers', False, type=bool,
38 info="only for testing purposes, turn on to ignore NSW hits and "
39 "fix a crash with older derivations (p-tag <p5834)")
40 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')
41 self.addOption ('decorateTruth', False, type=bool,
42 info="decorate truth particle information on the reconstructed one")
43 self.addOption ('writeTrackD0Z0', False, type = bool,
44 info="save the d0 significance and z0sinTheta variables so they can be written out")
45 self.addOption ('writeColumnarToolVariables', False, type=bool,
46 info="whether to add variables needed for running the columnar muon tool(s) on the output n-tuple. (EXPERIMENTAL)",
47 expertMode=True)
48 self.addOption ('runTrackBiasing', False, type=bool,
49 info="EXPERIMENTAL: This enables the InDetTrackBiasingTool, for tracks "
50 "associated to Muons. The the tool does not have run 3 recommendations yet.",
51 expertMode=True)
52

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonCalibrationConfig.instanceName ( self)

Definition at line 53 of file MuonAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 59 of file MuonAnalysisConfig.py.

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

Member Data Documentation

◆ calibMode

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

Definition at line 65 of file MuonAnalysisConfig.py.

◆ containerName

python.MuonAnalysisConfig.MuonCalibrationConfig.containerName

Definition at line 79 of file MuonAnalysisConfig.py.

◆ inputContainer

python.MuonAnalysisConfig.MuonCalibrationConfig.inputContainer

Definition at line 77 of file MuonAnalysisConfig.py.

◆ recalibratePhyslite

python.MuonAnalysisConfig.MuonCalibrationConfig.recalibratePhyslite

Definition at line 114 of file MuonAnalysisConfig.py.

◆ runTrackBiasing

python.MuonAnalysisConfig.MuonCalibrationConfig.runTrackBiasing

Definition at line 133 of file MuonAnalysisConfig.py.

◆ writeTrackD0Z0

python.MuonAnalysisConfig.MuonCalibrationConfig.writeTrackD0Z0

Definition at line 129 of file MuonAnalysisConfig.py.


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