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  self.addOption ('decorateTruth', False, type=bool,
63  info="decorate truth particle information on the reconstructed one")
64 
65 

Member Function Documentation

◆ makeAlgs()

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

Definition at line 100 of file ElectronAnalysisConfig.py.

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

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

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

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