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)
 
def instanceName (self)
 
def makeCalibrationAndSmearingAlg (self, config, name)
 
def makeAlgs (self, config)
 

Detailed Description

the ConfigBlock for the electron four-momentum correction

Definition at line 17 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ElectronAnalysisConfig.ElectronCalibrationConfig.__init__ (   self)

Definition at line 20 of file ElectronAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 81 of file ElectronAnalysisConfig.py.

81  def instanceName (self) :
82  """Return the instance name for this block"""
83  return self.containerName + self.postfix
84 

◆ makeAlgs()

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

Definition at line 122 of file ElectronAnalysisConfig.py.

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

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

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

The documentation for this class was generated from the following file:
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