ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.MuonAnalysisConfig.MuonWorkingPointConfig Class Reference
Inheritance diagram for python.MuonAnalysisConfig.MuonWorkingPointConfig:
Collaboration diagram for python.MuonAnalysisConfig.MuonWorkingPointConfig:

Public Member Functions

def __init__ (self, containerName='', selectionName='')
 
def makeAlgs (self, config)
 

Public Attributes

 quality
 

Detailed Description

the ConfigBlock for the muon working point

This may at some point be split into multiple blocks (10 Mar 22).

Definition at line 121 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.MuonAnalysisConfig.MuonWorkingPointConfig.__init__ (   self,
  containerName = '',
  selectionName = '' 
)

Definition at line 126 of file MuonAnalysisConfig.py.

126  def __init__ (self, containerName='', selectionName='') :
127  super (MuonWorkingPointConfig, self).__init__ ()
128  self.setBlockName('MuonsWorkingPoint')
129  self.addOption ('containerName', containerName, type=str,
130  noneAction='error',
131  info="the name of the input container.")
132  self.addOption ('selectionName', selectionName, type=str,
133  noneAction='error',
134  info="the name of the muon selection to define (e.g. tight or loose).")
135  self.addOption ('postfix', selectionName, type=str,
136  info="a postfix to apply to decorations and algorithm names. "
137  "Typically not needed here as selectionName is used internally.")
138  self.addOption ('trackSelection', True, type=bool,
139  info="whether or not to set up an instance of "
140  "CP::AsgLeptonTrackSelectionAlg, with the recommended d_0 and "
141  "z_0 sin(theta) cuts. The default is True.")
142  self.addOption ('maxD0Significance', 3, type=float,
143  info="maximum d0 significance used for the trackSelection"
144  "The default is 3")
145  self.addOption ('maxDeltaZ0SinTheta', 0.5, type=float,
146  info="maximum Delta z0sinTheta in mm used for the trackSelection"
147  "The default is 0.5 mm")
148  self.addOption ('writeTrackD0Z0', False, type = bool,
149  info="save the d0 significance and z0sinTheta variables so they can be written out")
150  self.addOption ('quality', None, type=str,
151  info="the ID WP (string) to use. Supported ID WPs: Tight, Medium, "
152  "Loose, LowPt, HighPt.")
153  self.addOption ('isolation', None, type=str,
154  info="the isolation WP (string) to use. Supported isolation WPs: "
155  "PflowLoose_VarRad, PflowTight_VarRad, Loose_VarRad, "
156  "Tight_VarRad, NonIso.")
157  self.addOption ('addSelectionToPreselection', True, type=bool,
158  info="whether to retain only muons satisfying the working point "
159  "requirements. The default is True.")
160  self.addOption ('closeByCorrection', False, type=bool,
161  info="whether to use close-by-corrected isolation working points.")
162  self.addOption ('systematicBreakdown', False, type=bool,
163  info="enables the full breakdown of efficiency SF systematics "
164  "(1 NP per uncertainty source, instead of 1 NP in total). "
165  "The default is False.")
166  self.addOption ('onlyRecoEffSF', False, type=bool,
167  info="same as noEffSF, but retains the ID scale factor. "
168  "Experimental! only useful for CI tests. The default is False.")
169  self.addOption ('noEffSF', False, type=bool,
170  info="disables the calculation of efficiencies and scale factors. "
171  "Experimental! only useful to test a new WP for which scale "
172  "factors are not available. The default is False.")
173  self.addOption ('excludeNSWFromPrecisionLayers', False, type=bool,
174  info="only for testing purposes, turn on to ignore NSW hits and "
175  "fix a crash with older derivations (p-tag <p5834)")
176 

Member Function Documentation

◆ makeAlgs()

def python.MuonAnalysisConfig.MuonWorkingPointConfig.makeAlgs (   self,
  config 
)

Definition at line 177 of file MuonAnalysisConfig.py.

177  def makeAlgs (self, config) :
178  from xAODMuon.xAODMuonEnums import xAODMuonEnums
179  if self.quality == 'Tight' :
180  quality = xAODMuonEnums.Quality.Tight
181  elif self.quality == 'Medium' :
182  quality = xAODMuonEnums.Quality.Medium
183  elif self.quality == 'Loose' :
184  quality = xAODMuonEnums.Quality.Loose
185  elif self.quality == 'VeryLoose' :
186  quality = xAODMuonEnums.Quality.VeryLoose
187  elif self.quality == 'HighPt' :
188  quality = 4
189  elif self.quality == 'LowPtEfficiency' :
190  quality = 5
191  else :
192  raise ValueError ("invalid muon quality: \"" + self.quality +
193  "\", allowed values are Tight, Medium, Loose, " +
194  "VeryLoose, HighPt, LowPtEfficiency")
195 
196  # The setup below is inappropriate for Run 1
197  if config.geometry() is LHCPeriod.Run1:
198  raise ValueError ("Can't set up the MuonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
199 
200  postfix = self.postfix
201  if postfix != '' and postfix[0] != '_' :
202  postfix = '_' + postfix
203 
204  # Set up the track selection algorithm:
205  if self.writeTrackD0Z0 or self.trackSelection:
206  alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
207  'MuonTrackSelectionAlg' + postfix )
208  alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
209  alg.decorateTTVAVars = self.writeTrackD0Z0
210  alg.maxD0Significance = self.maxD0Significance
211  alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
212  alg.particles = config.readName (self.containerName)
213  alg.preselection = config.getPreselection (self.containerName, '')
214  if self.trackSelection :
215  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
216  if self.writeTrackD0Z0 :
217  alg.d0sigDecoration = 'd0sig' + postfix
218  alg.z0sinthetaDecoration = 'z0sintheta' + postfix
219  config.addOutputVar (self.containerName, alg.d0sigDecoration, alg.d0sigDecoration,noSys=True)
220  config.addOutputVar (self.containerName, alg.z0sinthetaDecoration, alg.z0sinthetaDecoration,noSys=True)
221 
222  # Setup the muon quality selection
223  alg = config.createAlgorithm( 'CP::MuonSelectionAlgV2',
224  'MuonSelectionAlg' + postfix )
225  config.addPrivateTool( 'selectionTool', 'CP::MuonSelectionTool' )
226  alg.selectionTool.MuQuality = quality
227  alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
228  if config.geometry() is LHCPeriod.Run4:
229  logging.warning("MuonCalibrationConfig: disabling NSW hits for Run4 geometry")
230  alg.selectionTool.ExcludeNSWFromPrecisionLayers = True
231  else:
232  alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
233  alg.selectionDecoration = 'good_muon' + postfix + ',as_char'
234  alg.badMuonVetoDecoration = 'is_bad' + postfix + ',as_char'
235  alg.muons = config.readName (self.containerName)
236  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
237  config.addSelection (self.containerName, self.selectionName,
238  alg.selectionDecoration,
239  preselection=self.addSelectionToPreselection)
240 
241  # Set up the isolation calculation algorithm:
242  if self.isolation != 'NonIso' :
243  alg = config.createAlgorithm( 'CP::MuonIsolationAlg',
244  'MuonIsolationAlg' + postfix )
245  config.addPrivateTool( 'isolationTool', 'CP::IsolationSelectionTool' )
246  alg.isolationTool.MuonWP = self.isolation
247  if self.closeByCorrection:
248  alg.isolationTool.IsoDecSuffix = "CloseByCorr"
249  alg.isolationDecoration = 'isolated_muon' + postfix + ',as_char'
250  alg.muons = config.readName (self.containerName)
251  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
252  config.addSelection (self.containerName, self.selectionName,
253  alg.isolationDecoration,
254  preselection=self.addSelectionToPreselection)
255 
256  # Set up the reco/ID efficiency scale factor calculation algorithm:
257  if config.dataType() is not DataType.Data and (not self.noEffSF or self.onlyRecoEffSF):
258  alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
259  'MuonEfficiencyScaleFactorAlgReco' + postfix )
260  config.addPrivateTool( 'efficiencyScaleFactorTool',
261  'CP::MuonEfficiencyScaleFactors' )
262  alg.scaleFactorDecoration = 'muon_reco_effSF' + postfix + "_%SYS%"
263  alg.outOfValidity = 2 #silent
264  alg.outOfValidityDeco = 'muon_reco_bad_eff' + postfix
265  alg.efficiencyScaleFactorTool.WorkingPoint = self.quality
266  if config.geometry() >= LHCPeriod.Run3:
267  alg.efficiencyScaleFactorTool.CalibrationRelease = '240711_Preliminary_r24run3'
268  alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
269  alg.muons = config.readName (self.containerName)
270  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
271  config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'reco_effSF' + postfix)
272 
273  # Set up the HighPt-specific BadMuonVeto efficiency scale factor calculation algorithm:
274  if config.dataType() is not DataType.Data and self.quality == 'HighPt' and not self.onlyRecoEffSF and not self.noEffSF:
275  alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
276  'MuonEfficiencyScaleFactorAlgBMVHighPt' + postfix )
277  config.addPrivateTool( 'efficiencyScaleFactorTool',
278  'CP::MuonEfficiencyScaleFactors' )
279  alg.scaleFactorDecoration = 'muon_BadMuonVeto_effSF' + postfix + "_%SYS%"
280  alg.outOfValidity = 2 #silent
281  alg.outOfValidityDeco = 'muon_BadMuonVeto_bad_eff' + postfix
282  alg.efficiencyScaleFactorTool.WorkingPoint = 'BadMuonVeto_HighPt'
283  if config.geometry() >= LHCPeriod.Run3:
284  alg.efficiencyScaleFactorTool.CalibrationRelease = '220817_Preliminary_r22run3' # not available as part of '230123_Preliminary_r22run3'!
285  alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
286  alg.muons = config.readName (self.containerName)
287  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
288  config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'BadMuonVeto_effSF' + postfix)
289 
290  # Set up the isolation efficiency scale factor calculation algorithm:
291  if config.dataType() is not DataType.Data and self.isolation != 'NonIso' and not self.onlyRecoEffSF and not self.noEffSF:
292  alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
293  'MuonEfficiencyScaleFactorAlgIsol' + postfix )
294  config.addPrivateTool( 'efficiencyScaleFactorTool',
295  'CP::MuonEfficiencyScaleFactors' )
296  alg.scaleFactorDecoration = 'muon_isol_effSF' + postfix + "_%SYS%"
297  alg.outOfValidity = 2 #silent
298  alg.outOfValidityDeco = 'muon_isol_bad_eff' + postfix
299  alg.efficiencyScaleFactorTool.WorkingPoint = self.isolation + 'Iso'
300  if config.geometry() >= LHCPeriod.Run3:
301  alg.efficiencyScaleFactorTool.CalibrationRelease = '240711_Preliminary_r24run3'
302  alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
303  alg.muons = config.readName (self.containerName)
304  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
305  config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'isol_effSF' + postfix)
306 
307  # Set up the TTVA scale factor calculation algorithm:
308  if config.dataType() is not DataType.Data and not self.onlyRecoEffSF and not self.noEffSF:
309  alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
310  'MuonEfficiencyScaleFactorAlgTTVA' + postfix )
311  config.addPrivateTool( 'efficiencyScaleFactorTool',
312  'CP::MuonEfficiencyScaleFactors' )
313  alg.scaleFactorDecoration = 'muon_TTVA_effSF' + postfix + "_%SYS%"
314  alg.outOfValidity = 2 #silent
315  alg.outOfValidityDeco = 'muon_TTVA_bad_eff' + postfix
316  alg.efficiencyScaleFactorTool.WorkingPoint = 'TTVA'
317  if config.geometry() >= LHCPeriod.Run3:
318  alg.efficiencyScaleFactorTool.CalibrationRelease = '240711_Preliminary_r24run3'
319  alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
320  alg.muons = config.readName (self.containerName)
321  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
322  config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'TTVA_effSF' + postfix)
323 
324 

Member Data Documentation

◆ quality

python.MuonAnalysisConfig.MuonWorkingPointConfig.quality

Definition at line 179 of file MuonAnalysisConfig.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18