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

Constructor & Destructor Documentation

◆ __init__()

def python.ElectronAnalysisConfig.ElectronWorkingPointConfig.__init__ (   self)

Definition at line 278 of file ElectronAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 360 of file ElectronAnalysisConfig.py.

360  def instanceName (self) :
361  """Return the instance name for this block"""
362  if self.postfix is not None :
363  return self.containerName + '_' + self.selectionName + self.postfix
364  return self.containerName + '_' + self.selectionName
365 

◆ makeAlgs()

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

Definition at line 366 of file ElectronAnalysisConfig.py.

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

Member Data Documentation

◆ convSelection

python.ElectronAnalysisConfig.ElectronWorkingPointConfig.convSelection

Definition at line 521 of file ElectronAnalysisConfig.py.

◆ identificationWP

python.ElectronAnalysisConfig.ElectronWorkingPointConfig.identificationWP

Definition at line 469 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:310
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