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

Public Member Functions

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

Public Attributes

 convSelection
 
 identificationWP
 

Detailed Description

the ConfigBlock for the electron working point

This may at some point be split into multiple blocks (29 Aug 22).

Definition at line 268 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ElectronAnalysisConfig.ElectronWorkingPointConfig.__init__ (   self)

Definition at line 273 of file ElectronAnalysisConfig.py.

273  def __init__ (self) :
274  super (ElectronWorkingPointConfig, self).__init__ ()
275  self.addOption ('containerName', '', type=str,
276  noneAction='error',
277  info="the name of the input container.")
278  self.addOption ('selectionName', '', type=str,
279  noneAction='error',
280  info="the name of the electron selection to define (e.g. tight or "
281  "loose).")
282  self.addOption ('postfix', None, type=str,
283  info="a postfix to apply to decorations and algorithm names. "
284  "Typically not needed here as selectionName is used internally.")
285  self.addOption ('trackSelection', True, type=bool,
286  info="whether or not to set up an instance of "
287  "CP::AsgLeptonTrackSelectionAlg, with the recommended d_0 and "
288  "z_0 sin(theta) cuts. The default is True.")
289  self.addOption ('maxD0Significance', 5, type=float,
290  info="maximum d0 significance used for the trackSelection"
291  "The default is 5")
292  self.addOption ('maxDeltaZ0SinTheta', 0.5, type=float,
293  info="maximum z0sinTheta in mm used for the trackSelection"
294  "The default is 0.5 mm")
295  self.addOption ('identificationWP', None, type=str,
296  info="the ID WP (string) to use. Supported ID WPs: TightLH, "
297  "MediumLH, LooseBLayerLH, TightDNN, MediumDNN, LooseDNN, "
298  "TightNoCFDNN, MediumNoCFDNN, VeryLooseNoCF97DNN.")
299  self.addOption ('isolationWP', None, type=str,
300  info="the isolation WP (string) to use. Supported isolation WPs: "
301  "HighPtCaloOnly, Loose_VarRad, Tight_VarRad, TightTrackOnly_"
302  "VarRad, TightTrackOnly_FixedRad, NonIso.")
303  self.addOption ('convSelection', None, type=str,
304  info="enter additional selection (string) to use. To be used with "
305  "TightLH or will crash. Supported keywords:"
306  "Veto, MatConv, GammaStar.")
307  self.addOption ('addSelectionToPreselection', True, type=bool,
308  info="whether to retain only electrons satisfying the working point "
309  "requirements. The default is True.")
310  self.addOption ('closeByCorrection', False, type=bool,
311  info="whether to use close-by-corrected isolation working points")
312  self.addOption ('recomputeID', False, type=bool,
313  info="whether to rerun the ID LH/DNN. The default is False, i.e. to use "
314  "derivation flags.")
315  self.addOption ('chargeIDSelectionRun2', False, type=bool,
316  info="whether to run the ECIDS tool. Only available for run 2. "
317  "The default is False.")
318  self.addOption ('recomputeChargeID', False, type=bool,
319  info="whether to rerun the ECIDS. The default is False, i.e. to use "
320  "derivation flags.")
321  self.addOption ('doFSRSelection', False, type=bool,
322  info="whether to accept additional electrons close to muons for "
323  "the purpose of FSR corrections to these muons. Expert feature "
324  "requested by the H4l analysis running on PHYSLITE. "
325  "The default is False.")
326  self.addOption ('noEffSF', False, type=bool,
327  info="disables the calculation of efficiencies and scale factors. "
328  "Experimental! only useful to test a new WP for which scale "
329  "factors are not available. The default is False.")
330  self.addOption ('saveDetailedSF', True, type=bool,
331  info="save all the independent detailed object scale factors. "
332  "The default is True.")
333  self.addOption ('saveCombinedSF', False, type=bool,
334  info="save the combined object scale factor. "
335  "The default is False.")
336  self.addOption ('forceFullSimConfig', False, type=bool,
337  info="whether to force the tool to use the configuration meant for "
338  "full simulation samples. Only for testing purposes. "
339  "The default is False.")
340  self.addOption ('correlationModelId', 'SIMPLIFIED', type=str,
341  info="the correlation model (string) to use for ID scale factors "
342  "Supported models: SIMPLIFIED (default), FULL, TOTAL, TOYS")
343  self.addOption ('correlationModelIso', 'SIMPLIFIED', type=str,
344  info="the correlation model (string) to use for isolation scale factors "
345  "Supported models: SIMPLIFIED (default), FULL, TOTAL, TOYS")
346  self.addOption ('correlationModelReco', 'SIMPLIFIED', type=str,
347  info="the correlation model (string) to use for reconstruction scale factors "
348  "Supported models: SIMPLIFIED (default), FULL, TOTAL, TOYS")
349  self.addOption('addChargeMisIDSF', False, type=bool,
350  info="Adds scale factors for charge-misID.")
351 

Member Function Documentation

◆ instanceName()

def python.ElectronAnalysisConfig.ElectronWorkingPointConfig.instanceName (   self)
Return the instance name for this block

Definition at line 352 of file ElectronAnalysisConfig.py.

352  def instanceName (self) :
353  """Return the instance name for this block"""
354  if self.postfix is not None :
355  return self.containerName + '_' + self.selectionName + self.postfix
356  return self.containerName + '_' + self.selectionName
357 

◆ makeAlgs()

def python.ElectronAnalysisConfig.ElectronWorkingPointConfig.makeAlgs (   self,
  config 
)

Definition at line 358 of file ElectronAnalysisConfig.py.

358  def makeAlgs (self, config) :
359 
360  log = logging.getLogger('ElectronWorkingPointConfig')
361 
362  if self.forceFullSimConfig:
363  log.warning("You are running ElectronWorkingPointConfig forcing full sim config")
364  log.warning("This is only intended to be used for testing purposes")
365 
366  selectionPostfix = self.selectionName
367  if selectionPostfix != '' and selectionPostfix[0] != '_' :
368  selectionPostfix = '_' + selectionPostfix
369 
370  # The setup below is inappropriate for Run 1
371  if config.geometry() is LHCPeriod.Run1:
372  raise ValueError ("Can't set up the ElectronWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
373 
374  postfix = self.postfix
375  if postfix is None :
376  postfix = self.selectionName
377  if postfix != '' and postfix[0] != '_' :
378  postfix = '_' + postfix
379 
380  # Set up the track selection algorithm:
381  if self.trackSelection :
382  alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
383  'ElectronTrackSelectionAlg',
384  reentrant=True )
385  alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
386  alg.maxD0Significance = self.maxD0Significance
387  alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
388  alg.particles = config.readName (self.containerName)
389  alg.preselection = config.getPreselection (self.containerName, '')
390  if self.trackSelection :
391  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
392  preselection=self.addSelectionToPreselection)
393 
394  if 'LH' in self.identificationWP:
395  # Set up the likelihood ID selection algorithm
396  # It is safe to do this before calibration, as the cluster E is used
397  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronLikelihoodAlg' )
398  alg.selectionDecoration = 'selectLikelihood' + selectionPostfix + ',as_char'
399  if self.recomputeID:
400  # Rerun the likelihood ID
401  config.addPrivateTool( 'selectionTool', 'AsgElectronLikelihoodTool' )
402  alg.selectionTool.primaryVertexContainer = 'PrimaryVertices'
403  # Here we have to match the naming convention of EGSelectorConfigurationMapping.h
404  # which differ from the one used for scale factors
405  if config.geometry() >= LHCPeriod.Run3:
406  if 'HI' not in self.identificationWP:
407  alg.selectionTool.WorkingPoint = self.identificationWP.replace("BLayer","BL") + 'Electron'
408  else:
409  alg.selectionTool.WorkingPoint = self.identificationWP.replace('_HI', 'Electron_HI')
410  elif config.geometry() is LHCPeriod.Run2:
411  alg.selectionTool.WorkingPoint = self.identificationWP.replace("BLayer","BL") + 'Electron_Run2'
412  else:
413  # Select from Derivation Framework flags
414  config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
415  dfFlag = "DFCommonElectronsLH" + self.identificationWP.split('LH')[0]
416  dfFlag = dfFlag.replace("BLayer","BL")
417  alg.selectionTool.selectionFlags = [dfFlag]
418  elif 'SiHit' in self.identificationWP:
419  # Only want SiHit electrons, so veto loose LH electrons
420  algVeto = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronLikelihoodAlgVeto')
421  algVeto.selectionDecoration = 'selectLikelihoodVeto' + postfix + ',as_char'
422  config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
423  algVeto.selectionTool.selectionFlags = ["DFCommonElectronsLHLoose"]
424  algVeto.selectionTool.invertFlags = [True]
425  algVeto.particles = config.readName (self.containerName)
426  algVeto.preselection = config.getPreselection (self.containerName, self.selectionName)
427  # add the veto as a selection
428  config.addSelection (self.containerName, self.selectionName, algVeto.selectionDecoration,
429  preselection=self.addSelectionToPreselection)
430 
431  # Select SiHit electrons using IsEM bits
432  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronLikelihoodAlg' )
433  alg.selectionDecoration = 'selectSiHit' + selectionPostfix + ',as_char'
434  # Select from Derivation Framework IsEM bits
435  config.addPrivateTool( 'selectionTool', 'CP::AsgMaskSelectionTool' )
436  dfVar = "DFCommonElectronsLHLooseBLIsEMValue"
437  alg.selectionTool.selectionVars = [dfVar]
438  mask = int( 0 | 0x1 << 1 | 0x1 << 2)
439  alg.selectionTool.selectionMasks = [mask]
440  elif 'DNN' in self.identificationWP:
441  if self.chargeIDSelectionRun2:
442  raise ValueError('DNN is not intended to be used with '
443  '`chargeIDSelectionRun2` option as there are '
444  'DNN WPs containing charge flip rejection.')
445  # Set up the DNN ID selection algorithm
446  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronDNNAlg' )
447  alg.selectionDecoration = 'selectDNN' + selectionPostfix + ',as_char'
448  if self.recomputeID:
449  # Rerun the DNN ID
450  config.addPrivateTool( 'selectionTool', 'AsgElectronSelectorTool' )
451  # Here we have to match the naming convention of EGSelectorConfigurationMapping.h
452  if config.geometry() is LHCPeriod.Run3:
453  raise ValueError ( "DNN working points are not available for Run 3 yet.")
454  else:
455  alg.selectionTool.WorkingPoint = self.identificationWP + 'Electron'
456  else:
457  # Select from Derivation Framework flags
458  config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
459  dfFlag = "DFCommonElectronsDNN" + self.identificationWP.split('DNN')[0]
460  alg.selectionTool.selectionFlags = [dfFlag]
461 
462  alg.particles = config.readName (self.containerName)
463  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
464  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
465  preselection=self.addSelectionToPreselection)
466 
467  # maintain order of selections
468  if 'SiHit' in self.identificationWP:
469  # Set up the ElectronSiHitDecAlg algorithm to decorate SiHit electrons with a minimal amount of information:
470  algDec = config.createAlgorithm( 'CP::ElectronSiHitDecAlg', 'ElectronSiHitDecAlg' )
471  selDec = 'siHitEvtHasLeptonPair' + selectionPostfix + ',as_char'
472  algDec.selectionName = selDec.split(",")[0]
473  algDec.ElectronContainer = config.readName (self.containerName)
474  # Set flag to only collect SiHit electrons for events with an electron or muon pair to minimize size increase from SiHit electrons
475  algDec.RequireTwoLeptons = True
476  config.addSelection (self.containerName, self.selectionName, selDec,
477  preselection=self.addSelectionToPreselection)
478 
479  # Additional selection for conversions and gamma*
480  if self.convSelection is not None:
481  # skip if not applied together with TightLH
482  if self.identificationWP != 'TightLH':
483  raise ValueError(f"convSelection can only be used with TightLH ID, "
484  f"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
485  # check if allowed value
486  allowedValues = ["Veto", "GammaStar", "MatConv"]
487  if self.convSelection not in allowedValues:
488  raise ValueError(f"convSelection has been set to {self.convSelection}, which is not a valid option. "
489  f"convSelection option must be one of {allowedValues}.")
490 
491  # ambiguityType == 0
492  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronAmbiguityTypeAlg' )
493  alg.selectionDecoration = 'selectAmbiguityType' + selectionPostfix + ',as_char'
494  config.addPrivateTool( 'selectionTool', 'CP::AsgNumDecorationSelectionToolUInt8' )
495  alg.selectionTool.decorationName = "ambiguityType"
496  alg.selectionTool.doEqual = True
497  alg.selectionTool.equal = 0
498  alg.particles = config.readName (self.containerName)
499  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
500  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
501  preselection=self.addSelectionToPreselection)
502 
503  # DFCommonAddAmbiguity selection
504  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronDFCommonAddAmbiguityAlg' )
505  alg.selectionDecoration = 'selectDFCommonAddAmbiguity' + selectionPostfix + ',as_char'
506  config.addPrivateTool( 'selectionTool', 'CP::AsgNumDecorationSelectionToolInt' )
507  alg.selectionTool.decorationName = "DFCommonAddAmbiguity"
508  if self.convSelection == "Veto":
509  alg.selectionTool.doMax = True
510  alg.selectionTool.max = 1
511  elif self.convSelection == "GammaStar":
512  alg.selectionTool.doEqual = True
513  alg.selectionTool.equal = 1
514  elif self.convSelection == "MatConv":
515  alg.selectionTool.doEqual = True
516  alg.selectionTool.equal = 2
517  alg.particles = config.readName (self.containerName)
518  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
519  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
520  preselection=self.addSelectionToPreselection)
521 
522  # Set up the FSR selection
523  if self.doFSRSelection :
524  # save the flag set for the WP
525  wpFlag = alg.selectionDecoration.split(",")[0]
526  alg = config.createAlgorithm( 'CP::EgammaFSRForMuonsCollectorAlg', 'EgammaFSRForMuonsCollectorAlg' )
527  alg.selectionDecoration = wpFlag
528  alg.ElectronOrPhotonContKey = config.readName (self.containerName)
529  # For SiHit electrons, set flag to remove FSR electrons.
530  # For standard electrons, FSR electrons need to be added as they may be missed by the standard selection.
531  # For SiHit electrons FSR electrons are generally always selected, so they should be removed since they will be in the standard electron container.
532  if 'SiHit' in self.identificationWP:
533  alg.vetoFSR = True
534 
535  # Set up the isolation selection algorithm:
536  if self.isolationWP != 'NonIso' :
537  alg = config.createAlgorithm( 'CP::EgammaIsolationSelectionAlg',
538  'ElectronIsolationSelectionAlg' )
539  alg.selectionDecoration = 'isolated' + selectionPostfix + ',as_char'
540  config.addPrivateTool( 'selectionTool', 'CP::IsolationSelectionTool' )
541  alg.selectionTool.ElectronWP = self.isolationWP
542  if self.closeByCorrection:
543  alg.selectionTool.IsoDecSuffix = "CloseByCorr"
544  alg.egammas = config.readName (self.containerName)
545  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
546  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
547  preselection=self.addSelectionToPreselection)
548 
549  if self.chargeIDSelectionRun2 and config.geometry() >= LHCPeriod.Run3:
550  log.warning("ECIDS is only available for Run 2 and will not have any effect in Run 3.")
551 
552  # Select electrons only if they don't appear to have flipped their charge.
553  if self.chargeIDSelectionRun2 and config.geometry() < LHCPeriod.Run3:
554  alg = config.createAlgorithm( 'CP::AsgSelectionAlg',
555  'ElectronChargeIDSelectionAlg' )
556  alg.selectionDecoration = 'chargeID' + selectionPostfix + ',as_char'
557  if self.recomputeChargeID:
558  # Rerun the ECIDS BDT
559  config.addPrivateTool( 'selectionTool',
560  'AsgElectronChargeIDSelectorTool' )
561  alg.selectionTool.TrainingFile = \
562  'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
563  alg.selectionTool.WorkingPoint = 'Loose'
564  alg.selectionTool.CutOnBDT = -0.337671 # Loose 97%
565  else:
566  # Select from Derivation Framework flags
567  config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
568  alg.selectionTool.selectionFlags = ["DFCommonElectronsECIDS"]
569 
570  alg.particles = config.readName (self.containerName)
571  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
572  config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
573  preselection=self.addSelectionToPreselection)
574 
575  correlationModels = ["SIMPLIFIED", "FULL", "TOTAL", "TOYS"]
576  map_file = 'ElectronEfficiencyCorrection/2015_2025/rel22.2/2025_Run2Rel22_Recommendation_v3/map0.txt' \
577  if config.geometry() is LHCPeriod.Run2 else \
578  'ElectronEfficiencyCorrection/2015_2025/rel22.2/2025_Run3_Consolidated_Prerecom_v3/map1.txt'
579  sfList = []
580  # Set up the RECO electron efficiency correction algorithm:
581  if config.dataType() is not DataType.Data and not self.noEffSF:
582  if 'DNN' in self.identificationWP:
583  raise ValueError('DNN does not yet have efficiency correction, '
584  'please disable it by setting `noEffSF` to True.')
585 
586  alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg',
587  'ElectronEfficiencyCorrectionAlgReco' )
588  config.addPrivateTool( 'efficiencyCorrectionTool',
589  'AsgElectronEfficiencyCorrectionTool' )
590  alg.scaleFactorDecoration = 'el_reco_effSF' + selectionPostfix + '_%SYS%'
591  alg.efficiencyCorrectionTool.MapFilePath = map_file
592  alg.efficiencyCorrectionTool.RecoKey = "Reconstruction"
593  if self.correlationModelReco not in correlationModels:
594  raise ValueError('Invalid correlation model for reconstruction efficiency, '
595  f'has to be one of: {", ".join(correlationModels)}')
596  if config.geometry() >= LHCPeriod.Run3 and self.correlationModelReco != "TOTAL":
597  log.warning("Only TOTAL correlation model is currently supported "
598  "for reconstruction efficiency correction in Run 3.")
599  alg.efficiencyCorrectionTool.CorrelationModel = "TOTAL"
600  else:
601  alg.efficiencyCorrectionTool.CorrelationModel = self.correlationModelReco
602  if config.dataType() is DataType.FastSim:
603  alg.efficiencyCorrectionTool.ForceDataType = (
604  PATCore.ParticleDataType.Full if self.forceFullSimConfig
605  else PATCore.ParticleDataType.Fast)
606  elif config.dataType() is DataType.FullSim:
607  alg.efficiencyCorrectionTool.ForceDataType = \
608  PATCore.ParticleDataType.Full
609  alg.outOfValidity = 2 #silent
610  alg.outOfValidityDeco = 'el_reco_bad_eff' + selectionPostfix
611  alg.electrons = config.readName (self.containerName)
612  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
613  if self.saveDetailedSF:
614  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
615  'reco_effSF' + postfix)
616  sfList += [alg.scaleFactorDecoration]
617 
618  # Set up the ID electron efficiency correction algorithm:
619  if config.dataType() is not DataType.Data and not self.noEffSF:
620  alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg',
621  'ElectronEfficiencyCorrectionAlgID' )
622  config.addPrivateTool( 'efficiencyCorrectionTool',
623  'AsgElectronEfficiencyCorrectionTool' )
624  alg.scaleFactorDecoration = 'el_id_effSF' + selectionPostfix + '_%SYS%'
625  alg.efficiencyCorrectionTool.MapFilePath = map_file
626  alg.efficiencyCorrectionTool.IdKey = self.identificationWP.replace("LH","")
627  if self.correlationModelId not in correlationModels:
628  raise ValueError('Invalid correlation model for identification efficiency, '
629  f'has to be one of: {", ".join(correlationModels)}')
630  alg.efficiencyCorrectionTool.CorrelationModel = self.correlationModelId
631  if config.dataType() is DataType.FastSim:
632  alg.efficiencyCorrectionTool.ForceDataType = (
633  PATCore.ParticleDataType.Full if self.forceFullSimConfig
634  else PATCore.ParticleDataType.Fast)
635  elif config.dataType() is DataType.FullSim:
636  alg.efficiencyCorrectionTool.ForceDataType = \
637  PATCore.ParticleDataType.Full
638  alg.outOfValidity = 2 #silent
639  alg.outOfValidityDeco = 'el_id_bad_eff' + selectionPostfix
640  alg.electrons = config.readName (self.containerName)
641  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
642  if self.saveDetailedSF:
643  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
644  'id_effSF' + postfix)
645  sfList += [alg.scaleFactorDecoration]
646 
647  # Set up the ISO electron efficiency correction algorithm:
648  if config.dataType() is not DataType.Data and self.isolationWP != 'NonIso' and not self.noEffSF:
649  alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg',
650  'ElectronEfficiencyCorrectionAlgIsol' )
651  config.addPrivateTool( 'efficiencyCorrectionTool',
652  'AsgElectronEfficiencyCorrectionTool' )
653  alg.scaleFactorDecoration = 'el_isol_effSF' + selectionPostfix + '_%SYS%'
654  alg.efficiencyCorrectionTool.MapFilePath = map_file
655  alg.efficiencyCorrectionTool.IdKey = self.identificationWP.replace("LH","")
656  alg.efficiencyCorrectionTool.IsoKey = self.isolationWP
657  if self.correlationModelIso not in correlationModels:
658  raise ValueError('Invalid correlation model for isolation efficiency, '
659  f'has to be one of: {", ".join(correlationModels)}')
660  if self.correlationModelIso != 'TOTAL':
661  log.warning("Only TOTAL correlation model is currently supported "
662  "for isolation efficiency correction in Run 3.")
663  alg.efficiencyCorrectionTool.CorrelationModel = "TOTAL"
664  if config.dataType() is DataType.FastSim:
665  alg.efficiencyCorrectionTool.ForceDataType = (
666  PATCore.ParticleDataType.Full if self.forceFullSimConfig
667  else PATCore.ParticleDataType.Fast)
668  elif config.dataType() is DataType.FullSim:
669  alg.efficiencyCorrectionTool.ForceDataType = \
670  PATCore.ParticleDataType.Full
671  alg.outOfValidity = 2 #silent
672  alg.outOfValidityDeco = 'el_isol_bad_eff' + selectionPostfix
673  alg.electrons = config.readName (self.containerName)
674  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
675  if self.saveDetailedSF:
676  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
677  'isol_effSF' + postfix)
678  sfList += [alg.scaleFactorDecoration]
679 
680  if (self.chargeIDSelectionRun2 and config.geometry() < LHCPeriod.Run3 and
681  config.dataType() is not DataType.Data and not self.noEffSF):
682  alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg',
683  'ElectronEfficiencyCorrectionAlgEcids' )
684  config.addPrivateTool( 'efficiencyCorrectionTool',
685  'AsgElectronEfficiencyCorrectionTool' )
686  alg.scaleFactorDecoration = 'el_ecids_effSF' + selectionPostfix + '_%SYS%'
687  if self.isolationWP != 'Tight_VarRad':
688  raise ValueError('ECIDS SFs are supported only for Tight_VarRad isolation.')
689  if self.identificationWP == 'LooseBLayerLH':
690  ecids_lh = 'loose'
691  elif self.identificationWP == 'MediumLH':
692  ecids_lh = 'medium'
693  elif self.identificationWP == 'TightLH':
694  ecids_lh = 'tight'
695  else:
696  raise ValueError('ECIDS SFs are supported only for ID LooseBLayerLH, MediumLH, or TightLH')
697 
698  alg.efficiencyCorrectionTool.CorrelationModel = "TOTAL"
699  alg.efficiencyCorrectionTool.CorrectionFileNameList = \
700  [f'ElectronEfficiencyCorrection/2015_2025/rel22.2/2025_Run2Rel22_Recommendation_v2/ecids/efficiencySF.ChargeID.{ecids_lh}_ECIDS_Tight_VarRad.root']
701  if config.dataType() is DataType.FastSim:
702  alg.efficiencyCorrectionTool.ForceDataType = (
703  PATCore.ParticleDataType.Full if self.forceFullSimConfig
704  else PATCore.ParticleDataType.Fast)
705  elif config.dataType() is DataType.FullSim:
706  alg.efficiencyCorrectionTool.ForceDataType = \
707  PATCore.ParticleDataType.Full
708  alg.outOfValidity = 2 #silent
709  alg.outOfValidityDeco = 'el_ecids_bad_eff' + selectionPostfix
710  alg.electrons = config.readName (self.containerName)
711  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
712  if self.saveDetailedSF:
713  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
714  'ecids_effSF' + postfix)
715  sfList += [alg.scaleFactorDecoration]
716 
717  if self.addChargeMisIDSF and config.dataType() is not DataType.Data and not self.noEffSF:
718  if config.geometry() >= LHCPeriod.Run3:
719  raise ValueError('Run 3 does not yet have charge mis-ID correction, '
720  'please disable it by setting `noEffSF` to False.')
721 
722  alg = config.createAlgorithm( 'CP::ElectronEfficiencyCorrectionAlg',
723  'ElectronEfficiencyCorrectionAlgMisid' )
724  config.addPrivateTool( 'efficiencyCorrectionTool',
725  'CP::ElectronChargeEfficiencyCorrectionTool' )
726  alg.scaleFactorDecoration = 'el_charge_misid_effSF' + selectionPostfix + '_%SYS%'
727  if self.isolationWP != 'Tight_VarRad':
728  raise ValueError('Charge mis-ID SFs are supported only for Tight_VarRad isolation.')
729  if self.identificationWP == 'LooseBLayerLH':
730  misid_lh = 'LooseAndBLayerLLH'
731  elif self.identificationWP == 'MediumLH':
732  misid_lh = 'MediumLLH'
733  elif self.identificationWP == 'TightLH':
734  misid_lh = 'TightLLH'
735  else:
736  raise ValueError('Charge mis-ID SFs are supported only for ID LooseBLayerLH, MediumLH, or TightLH')
737  misid_suffix = '_ECIDSloose' if self.chargeIDSelectionRun2 else ''
738 
739  alg.efficiencyCorrectionTool.CorrectionFileName = \
740  f'ElectronEfficiencyCorrection/2015_2025/rel22.2/2025_Run2Rel22_Recommendation_v2/charge_misID/chargeEfficiencySF.{misid_lh}_d0z0_TightVarRad{misid_suffix}.root'
741  if config.dataType() is DataType.FastSim:
742  alg.efficiencyCorrectionTool.ForceDataType = (
743  PATCore.ParticleDataType.Full if self.forceFullSimConfig
744  else PATCore.ParticleDataType.Fast)
745  elif config.dataType() is DataType.FullSim:
746  alg.efficiencyCorrectionTool.ForceDataType = \
747  PATCore.ParticleDataType.Full
748  alg.outOfValidity = 2 #silent
749  alg.outOfValidityDeco = 'el_misid_bad_eff' + selectionPostfix
750  alg.electrons = config.readName (self.containerName)
751  alg.preselection = config.getPreselection (self.containerName, self.selectionName)
752  if self.saveDetailedSF:
753  config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
754  'charge_misid_effSF' + postfix)
755  sfList += [alg.scaleFactorDecoration]
756 
757  if config.dataType() is not DataType.Data and not self.noEffSF and self.saveCombinedSF:
758  alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
759  'ElectronCombinedEfficiencyScaleFactorAlg' )
760  alg.particles = config.readName (self.containerName)
761  alg.inScaleFactors = sfList
762  alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
763  config.addOutputVar (self.containerName, alg.outScaleFactor, 'effSF' + postfix)
764 
765 
766 

Member Data Documentation

◆ convSelection

python.ElectronAnalysisConfig.ElectronWorkingPointConfig.convSelection

Definition at line 508 of file ElectronAnalysisConfig.py.

◆ identificationWP

python.ElectronAnalysisConfig.ElectronWorkingPointConfig.identificationWP

Definition at line 689 of file ElectronAnalysisConfig.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
Trk::split
@ split
Definition: LayerMaterialProperties.h:38