Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 ('inputContainer', '', type=str,
25  info="select electron input container, by default set to Electrons")
26  self.addOption ('containerName', containerName, type=str,
27  noneAction='error',
28  info="the name of the output container after calibration.")
29  self.addOption ('ESModel', '', type=str,
30  info="flag of egamma calibration recommendation.")
31  self.addOption ('decorrelationModel', '1NP_v1', type=str,
32  info="egamma energy scale decorrelationModel. The default is 1NP_v1. "
33  "Supported Model: 1NP_v1, FULL_v1.")
34  self.addOption ('postfix', '', type=str,
35  info="a postfix to apply to decorations and algorithm names. Typically "
36  "not needed here since the calibration is common to all electrons.")
37  self.addOption ('crackVeto', False, type=bool,
38  info="whether to perform LAr crack veto based on the cluster eta, "
39  "i.e. remove electrons within 1.37<|eta|<1.52. The default "
40  "is False.")
41  self.addOption ('isolationCorrection', False, type=bool,
42  info="whether or not to perform isolation corrections (leakage "
43  "corrections), i.e. set up an instance of "
44  "CP::EgammaIsolationCorrectionAlg.")
45  self.addOption ('recalibratePhyslite', True, type=bool,
46  info="whether to run the CP::EgammaCalibrationAndSmearingAlg on "
47  "PHYSLITE derivations. The default is True.")
48  self.addOption ('minPt', 4.5*GeV, type=float,
49  info="the minimum pT cut to apply to calibrated electrons. "
50  "The default is 4.5 GeV.")
51  self.addOption ('maxEta', 2.47, type=float,
52  info="maximum electron |eta| (float). The default is 2.47.")
53  self.addOption ('forceFullSimConfig', False, type=bool,
54  info="whether to force the tool to use the configuration meant for "
55  "full simulation samples. Only for testing purposes. The default "
56  "is False.")
57 
58  self.addOption ('splitCalibrationAndSmearing', False, type=bool,
59  info="EXPERIMENTAL: This splits the EgammaCalibrationAndSmearingTool "
60  " into two steps. The first step applies a baseline calibration that "
61  "is not affected by systematics. The second step then applies the "
62  "systematics dependent corrections. The net effect is that the "
63  "slower first step only has to be run once, while the second is run "
64  "once per systematic. ATLASG-2358")
65 
66  self.addOption ('decorateTruth', False, type=bool,
67  info="decorate truth particle information on the reconstructed one")
68  self.addOption ('decorateCaloClusterEta', False, type=bool,
69  info="decorate the calo cluster eta on the reconstructed one")
70  self.addOption ('writeTrackD0Z0', False, type = bool,
71  info="save the d0 significance and z0sinTheta variables so they can be written out")
72  self.addOption ('decorateEmva', False, type=bool,
73  info="decorate E_mva_only on the objects (needed for columnar tools/PHYSLITE)")
74 
75  self.addOption ('decorateSamplingPattern', False, type=bool,
76  info="add samplingPattern decorations to clusters as part of PHYSLITE")
77 
78 

Member Function Documentation

◆ makeAlgs()

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

Definition at line 116 of file ElectronAnalysisConfig.py.

116  def makeAlgs (self, config) :
117 
118  log = logging.getLogger('ElectronCalibrationConfig')
119 
120  if self.forceFullSimConfig:
121  log.warning("You are running ElectronCalibrationConfig forcing full sim config")
122  log.warning(" This is only intended to be used for testing purposes")
123 
124  inputContainer = "AnalysisElectrons" if config.isPhyslite() else "Electrons"
125  if self.inputContainer:
126  inputContainer = self.inputContainer
127  config.setSourceName (self.containerName, inputContainer)
128 
129  # Decorate calo cluster eta if required
130  if self.decorateCaloClusterEta:
131  alg = config.createAlgorithm( 'CP::EgammaCaloClusterEtaAlg',
132  'ElectronEgammaCaloClusterEtaAlg' + self.postfix,
133  reentrant=True )
134  alg.particles = config.readName(self.containerName)
135  config.addOutputVar (self.containerName, 'caloEta2', 'caloEta2', noSys=True)
136 
137  if self.decorateSamplingPattern:
138  config.createAlgorithm( 'CP::EgammaSamplingPatternDecoratorAlg', 'EgammaSamplingPatternDecoratorAlg' + self.postfix )
139 
140  # Set up a shallow copy to decorate
141  if config.wantCopy (self.containerName) :
142  alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'ElectronShallowCopyAlg' + self.postfix )
143  alg.input = config.readName (self.containerName)
144  alg.output = config.copyName (self.containerName)
145 
146  # Set up the eta-cut on all electrons prior to everything else
147  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronEtaCutAlg' + self.postfix )
148  alg.selectionDecoration = 'selectEta' + self.postfix + ',as_bits'
149  config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
150  alg.selectionTool.maxEta = self.maxEta
151  if self.crackVeto:
152  alg.selectionTool.etaGapLow = 1.37
153  alg.selectionTool.etaGapHigh = 1.52
154  alg.selectionTool.useClusterEta = True
155  alg.particles = config.readName (self.containerName)
156  alg.preselection = config.getPreselection (self.containerName, '')
157  config.addSelection (self.containerName, '', alg.selectionDecoration)
158 
159  # Select electrons only with good object quality.
160  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronObjectQualityAlg' + self.postfix )
161  alg.selectionDecoration = 'goodOQ' + self.postfix + ',as_bits'
162  config.addPrivateTool( 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
163  alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSELECTRON
164  alg.particles = config.readName (self.containerName)
165  alg.preselection = config.getPreselection (self.containerName, '')
166  config.addSelection (self.containerName, '', alg.selectionDecoration)
167 
168  if not self.splitCalibrationAndSmearing :
169  # Set up the calibration and smearing algorithm:
170  alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationAndSmearingAlg')
171  if config.isPhyslite() and not self.recalibratePhyslite :
172  alg.skipNominal = True
173  else:
174  # This splits the EgammaCalibrationAndSmearingTool into two
175  # steps. The first step applies a baseline calibration that
176  # is not affected by systematics. The second step then
177  # applies the systematics dependent corrections. The net
178  # effect is that the slower first step only has to be run
179  # once, while the second is run once per systematic.
180  #
181  # For now (22 May 24) this has to happen in the same job, as
182  # the output of the first step is not part of PHYSLITE, and
183  # even for the nominal the output of the first and second
184  # step are different. In the future the plan is to put both
185  # the output of the first and second step into PHYSLITE,
186  # allowing to skip the first step when running on PHYSLITE.
187  #
188  # WARNING: All of this is experimental, see: ATLASG-2358
189 
190  # Set up the calibration algorithm:
191  alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronBaseCalibrationAlg')
192  # turn off systematics for the calibration step
193  alg.noToolSystematics = True
194  # turn off smearing for the calibration step
195  alg.calibrationAndSmearingTool.doSmearing = False
196 
197  # Set up the smearing algorithm:
198  alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationSystematicsAlg')
199  # turn off scale corrections for the smearing step
200  alg.calibrationAndSmearingTool.doScaleCorrection = False
201  alg.calibrationAndSmearingTool.useMVACalibration = False
202  alg.calibrationAndSmearingTool.decorateEmva = False
203 
204  if self.minPt > 0 :
205  # Set up the the pt selection
206  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronPtCutAlg' + self.postfix )
207  alg.selectionDecoration = 'selectPt' + self.postfix + ',as_bits'
208  config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
209  alg.selectionTool.minPt = self.minPt
210  alg.particles = config.readName (self.containerName)
211  alg.preselection = config.getPreselection (self.containerName, '')
212  config.addSelection (self.containerName, '', alg.selectionDecoration,
213  preselection=True)
214 
215  # Set up the isolation correction algorithm:
216  if self.isolationCorrection:
217  alg = config.createAlgorithm( 'CP::EgammaIsolationCorrectionAlg',
218  'ElectronIsolationCorrectionAlg' + self.postfix )
219  config.addPrivateTool( 'isolationCorrectionTool',
220  'CP::IsolationCorrectionTool' )
221  alg.isolationCorrectionTool.IsMC = config.dataType() is not DataType.Data
222  alg.isolationCorrectionTool.AFII_corr = (
223  0 if self.forceFullSimConfig
224  else config.dataType() is DataType.FastSim)
225  alg.egammas = config.readName (self.containerName)
226  alg.egammasOut = config.copyName (self.containerName)
227  alg.preselection = config.getPreselection (self.containerName, '')
228 
229  # Additional decorations
230  if self.writeTrackD0Z0:
231  alg = config.createAlgorithm( 'CP::AsgLeptonTrackDecorationAlg',
232  'LeptonTrackDecorator' + self.containerName + self.postfix,
233  reentrant=True )
234  alg.particles = config.readName (self.containerName)
235 
236  alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' + self.containerName + self.postfix )
237  alg.particles = config.readName(self.containerName)
238 
239  config.addOutputVar (self.containerName, 'pt', 'pt')
240  config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
241  config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
242  config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
243  config.addOutputVar (self.containerName, 'charge', 'charge', noSys=True)
244 
245  if self.writeTrackD0Z0:
246  config.addOutputVar (self.containerName, 'd0_%SYS%', 'd0', noSys=True)
247  config.addOutputVar (self.containerName, 'd0sig_%SYS%', 'd0sig', noSys=True)
248  config.addOutputVar (self.containerName, 'z0sintheta_%SYS%', 'z0sintheta', noSys=True)
249  config.addOutputVar (self.containerName, 'z0sinthetasig_%SYS%', 'z0sinthetasig', noSys=True)
250 
251  # decorate truth information on the reconstructed object:
252  if self.decorateTruth and config.dataType() is not DataType.Data:
253  config.addOutputVar (self.containerName, "truthType", "truth_type", noSys=True)
254  config.addOutputVar (self.containerName, "truthOrigin", "truth_origin", noSys=True)
255 
256  config.addOutputVar (self.containerName, "firstEgMotherPdgId", "truth_firstEgMotherPdgId", noSys=True)
257  config.addOutputVar (self.containerName, "firstEgMotherTruthOrigin", "truth_firstEgMotherTruthOrigin", noSys=True)
258  config.addOutputVar (self.containerName, "firstEgMotherTruthType", "truth_firstEgMotherTruthType", noSys=True)
259 
260 

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

79  def makeCalibrationAndSmearingAlg (self, config, name) :
80  """Create the calibration and smearing algorithm
81 
82  Factoring this out into its own function, as we want to
83  instantiate it in multiple places"""
84  log = logging.getLogger('ElectronCalibrationConfig')
85 
86  # Set up the calibration and smearing algorithm:
87  alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg', name + self.postfix )
88  config.addPrivateTool( 'calibrationAndSmearingTool',
89  'CP::EgammaCalibrationAndSmearingTool' )
90  # Set default ESModel per period
91  if self.ESModel:
92  alg.calibrationAndSmearingTool.ESModel = self.ESModel
93  else:
94  if config.geometry() is LHCPeriod.Run2:
95  alg.calibrationAndSmearingTool.ESModel = 'es2023_R22_Run2_v1'
96  elif config.geometry() is LHCPeriod.Run3:
97  alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
98  elif config.geometry() is LHCPeriod.Run4:
99  log.warning("No ESModel set for Run4, using Run 3 model instead")
100  alg.calibrationAndSmearingTool.ESModel = 'es2022_R22_PRE'
101  else:
102  raise ValueError (f"Can't set up the ElectronCalibrationConfig with {config.geometry().value}, "
103  "there must be something wrong!")
104 
105  alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
106  alg.calibrationAndSmearingTool.useFastSim = (
107  0 if self.forceFullSimConfig
108  else int( config.dataType() is DataType.FastSim ))
109  alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
110  alg.egammas = config.readName (self.containerName)
111  alg.egammasOut = config.copyName (self.containerName)
112  alg.preselection = config.getPreselection (self.containerName, '')
113  return alg
114 
115 

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