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 
68  self.addOption ('decorateTruth', False, type=bool,
69  info="decorate truth particle information on the reconstructed one")
70  self.addOption ('decorateCaloClusterEta', False, type=bool,
71  info="decorate the calo cluster eta on the reconstructed one")
72  self.addOption ('writeTrackD0Z0', False, type = bool,
73  info="save the d0 significance and z0sinTheta variables so they can be written out")
74  self.addOption ('decorateEmva', False, type=bool,
75  info="decorate E_mva_only on the objects (needed for columnar tools/PHYSLITE)")
76 
77  self.addOption ('decorateSamplingPattern', False, type=bool,
78  info="add samplingPattern decorations to clusters as part of PHYSLITE")
79 

Member Function Documentation

◆ instanceName()

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

Definition at line 80 of file ElectronAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 121 of file ElectronAnalysisConfig.py.

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

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

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

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