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

Public Member Functions

def __init__ (self, containerName='')
 
def makeCalibrationAndSmearingAlg (self, config, name)
 
def makeAlgs (self, config)
 

Detailed Description

the ConfigBlock for the electron four-momentum correction

Definition at line 18 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ElectronAnalysisConfig.ElectronCalibrationConfig.__init__ (   self,
  containerName = '' 
)

Definition at line 21 of file ElectronAnalysisConfig.py.

21  def __init__ (self, containerName='') :
22  super (ElectronCalibrationConfig, self).__init__ ()
23  self.setBlockName('Electrons')
24  self.addOption ('containerName', containerName, type=str,
25  noneAction='error',
26  info="the name of the output container after calibration.")
27  self.addOption ('ESModel', '', type=str,
28  info="flag of egamma calibration recommendation.")
29  self.addOption ('decorrelationModel', '1NP_v1', type=str,
30  info="egamma energy scale decorrelationModel. The default is 1NP_v1. "
31  "Supported Model: 1NP_v1, FULL_v1.")
32  self.addOption ('postfix', '', type=str,
33  info="a postfix to apply to decorations and algorithm names. Typically "
34  "not needed here since the calibration is common to all electrons.")
35  self.addOption ('crackVeto', False, type=bool,
36  info="whether to perform LAr crack veto based on the cluster eta, "
37  "i.e. remove electrons within 1.37<|eta|<1.52. The default "
38  "is False.")
39  self.addOption ('isolationCorrection', False, type=bool,
40  info="whether or not to perform isolation corrections (leakage "
41  "corrections), i.e. set up an instance of "
42  "CP::EgammaIsolationCorrectionAlg.")
43  self.addOption ('recalibratePhyslite', True, type=bool,
44  info="whether to run the CP::EgammaCalibrationAndSmearingAlg on "
45  "PHYSLITE derivations. The default is True.")
46  self.addOption ('minPt', 4.5*GeV, type=float,
47  info="the minimum pT cut to apply to calibrated electrons. "
48  "The default is 4.5 GeV.")
49  self.addOption ('forceFullSimConfig', False, type=bool,
50  info="whether to force the tool to use the configuration meant for "
51  "full simulation samples. Only for testing purposes. The default "
52  "is False.")
53 
54  self.addOption ('splitCalibrationAndSmearing', False, type=bool,
55  info="EXPERIMENTAL: This splits the EgammaCalibrationAndSmearingTool "
56  " into two steps. The first step applies a baseline calibration that "
57  "is not affected by systematics. The second step then applies the "
58  "systematics dependent corrections. The net effect is that the "
59  "slower first step only has to be run once, while the second is run "
60  "once per systematic. ATLASG-2358")
61 
62 

Member Function Documentation

◆ makeAlgs()

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

Definition at line 97 of file ElectronAnalysisConfig.py.

97  def makeAlgs (self, config) :
98 
99  log = logging.getLogger('ElectronCalibrationConfig')
100 
101  if self.forceFullSimConfig:
102  log.warning("You are running ElectronCalibrationConfig forcing full sim config")
103  log.warning(" This is only intended to be used for testing purposes")
104 
105  if config.isPhyslite() :
106  config.setSourceName (self.containerName, "AnalysisElectrons")
107  else :
108  config.setSourceName (self.containerName, "Electrons")
109 
110  # Set up a shallow copy to decorate
111  if config.wantCopy (self.containerName) :
112  alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'ElectronShallowCopyAlg' + self.postfix )
113  alg.input = config.readName (self.containerName)
114  alg.output = config.copyName (self.containerName)
115 
116 
117  # Set up the eta-cut on all electrons prior to everything else
118  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronEtaCutAlg' + self.postfix )
119  alg.selectionDecoration = 'selectEta' + self.postfix + ',as_bits'
120  config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
121  alg.selectionTool.maxEta = 2.47
122  if self.crackVeto:
123  alg.selectionTool.etaGapLow = 1.37
124  alg.selectionTool.etaGapHigh = 1.52
125  alg.selectionTool.useClusterEta = True
126  alg.particles = config.readName (self.containerName)
127  alg.preselection = config.getPreselection (self.containerName, '')
128  config.addSelection (self.containerName, '', alg.selectionDecoration)
129 
130  # Select electrons only with good object quality.
131  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronObjectQualityAlg' + self.postfix )
132  alg.selectionDecoration = 'goodOQ' + self.postfix + ',as_bits'
133  config.addPrivateTool( 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
134  alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSELECTRON
135  alg.particles = config.readName (self.containerName)
136  alg.preselection = config.getPreselection (self.containerName, '')
137  config.addSelection (self.containerName, '', alg.selectionDecoration)
138 
139  if not self.splitCalibrationAndSmearing :
140  # Set up the calibration and smearing algorithm:
141  alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationAndSmearingAlg')
142  if config.isPhyslite() and not self.recalibratePhyslite :
143  alg.skipNominal = True
144  else:
145  # This splits the EgammaCalibrationAndSmearingTool into two
146  # steps. The first step applies a baseline calibration that
147  # is not affected by systematics. The second step then
148  # applies the systematics dependent corrections. The net
149  # effect is that the slower first step only has to be run
150  # once, while the second is run once per systematic.
151  #
152  # For now (22 May 24) this has to happen in the same job, as
153  # the output of the first step is not part of PHYSLITE, and
154  # even for the nominal the output of the first and second
155  # step are different. In the future the plan is to put both
156  # the output of the first and second step into PHYSLITE,
157  # allowing to skip the first step when running on PHYSLITE.
158  #
159  # WARNING: All of this is experimental, see: ATLASG-2358
160 
161  # Set up the calibration algorithm:
162  alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronBaseCalibrationAlg')
163  # turn off systematics for the calibration step
164  alg.noToolSystematics = True
165  # turn off smearing for the calibration step
166  alg.calibrationAndSmearingTool.doSmearing = False
167 
168  # Set up the smearing algorithm:
169  alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationSystematicsAlg')
170  # turn off scale corrections for the smearing step
171  alg.calibrationAndSmearingTool.doScaleCorrection = False
172  alg.calibrationAndSmearingTool.useMVACalibration = False
173 
174  if self.minPt > 0 :
175  # Set up the the pt selection
176  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronPtCutAlg' + self.postfix )
177  alg.selectionDecoration = 'selectPt' + self.postfix + ',as_bits'
178  config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
179  alg.selectionTool.minPt = self.minPt
180  alg.particles = config.readName (self.containerName)
181  alg.preselection = config.getPreselection (self.containerName, '')
182  config.addSelection (self.containerName, '', alg.selectionDecoration,
183  preselection=True)
184 
185  # Set up the isolation correction algorithm:
186  if self.isolationCorrection:
187  alg = config.createAlgorithm( 'CP::EgammaIsolationCorrectionAlg',
188  'ElectronIsolationCorrectionAlg' + self.postfix )
189  config.addPrivateTool( 'isolationCorrectionTool',
190  'CP::IsolationCorrectionTool' )
191  alg.isolationCorrectionTool.IsMC = config.dataType() is not DataType.Data
192  alg.isolationCorrectionTool.AFII_corr = (
193  0 if self.forceFullSimConfig
194  else config.dataType() is DataType.FastSim)
195  alg.egammas = config.readName (self.containerName)
196  alg.egammasOut = config.copyName (self.containerName)
197  alg.preselection = config.getPreselection (self.containerName, '')
198 
199  # Additional decorations
200  alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' + self.containerName + self.postfix )
201  alg.particles = config.readName(self.containerName)
202 
203  config.addOutputVar (self.containerName, 'pt', 'pt')
204  config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
205  config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
206  config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
207  config.addOutputVar (self.containerName, 'charge', 'charge', noSys=True)
208 
209 
210 

◆ makeCalibrationAndSmearingAlg()

def python.ElectronAnalysisConfig.ElectronCalibrationConfig.makeCalibrationAndSmearingAlg (   self,
  config,
  name 
)
Create the calibration and smearing algorithm

Factoring this out into its own function, as we want to
instantiate it in multiple places

Definition at line 63 of file ElectronAnalysisConfig.py.

63  def makeCalibrationAndSmearingAlg (self, config, name) :
64  """Create the calibration and smearing algorithm
65 
66  Factoring this out into its own function, as we want to
67  instantiate it in multiple places"""
68  # Set up the calibration and smearing algorithm:
69  alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg', name + self.postfix )
70  config.addPrivateTool( 'calibrationAndSmearingTool',
71  'CP::EgammaCalibrationAndSmearingTool' )
72  # Set default ESModel per period
73  if self.ESModel:
74  alg.calibrationAndSmearingTool.ESModel = self.ESModel
75  else:
76  if config.geometry() is LHCPeriod.Run2:
77  alg.calibrationAndSmearingTool.ESModel = 'es2023_R22_Run2_v0'
78  elif config.geometry() is LHCPeriod.Run3:
79  alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
80  elif config.geometry() is LHCPeriod.Run4:
81  logging.warning("No ESModel set for Run4, using Run 3 model instead")
82  alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
83  else:
84  raise ValueError (f"Can't set up the ElectronCalibrationConfig with {config.geometry().value}, "
85  "there must be something wrong!")
86 
87  alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
88  alg.calibrationAndSmearingTool.useFastSim = (
89  0 if self.forceFullSimConfig
90  else int( config.dataType() is DataType.FastSim ))
91  alg.egammas = config.readName (self.containerName)
92  alg.egammasOut = config.copyName (self.containerName)
93  alg.preselection = config.getPreselection (self.containerName, '')
94  return alg
95 
96 

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