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

 identificationWP
 
 convSelection
 

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 269 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ElectronAnalysisConfig.ElectronWorkingPointConfig.__init__ (   self)

Definition at line 274 of file ElectronAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 356 of file ElectronAnalysisConfig.py.

356  def instanceName (self) :
357  """Return the instance name for this block"""
358  if self.postfix is not None :
359  return self.containerName + '_' + self.selectionName + self.postfix
360  return self.containerName + '_' + self.selectionName
361 

◆ makeAlgs()

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

Definition at line 362 of file ElectronAnalysisConfig.py.

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

Member Data Documentation

◆ convSelection

python.ElectronAnalysisConfig.ElectronWorkingPointConfig.convSelection

Definition at line 517 of file ElectronAnalysisConfig.py.

◆ identificationWP

python.ElectronAnalysisConfig.ElectronWorkingPointConfig.identificationWP

Definition at line 465 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.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
Trk::split
@ split
Definition: LayerMaterialProperties.h:38