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

Public Member Functions

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

Detailed Description

the ConfigBlock for the photon four-momentum correction

Definition at line 17 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.PhotonAnalysisConfig.PhotonCalibrationConfig.__init__ (   self,
  containerName = '' 
)

Definition at line 20 of file PhotonAnalysisConfig.py.

20  def __init__ (self, containerName='') :
21  super (PhotonCalibrationConfig, self).__init__ ()
22  self.setBlockName('Photons')
23  self.addOption ('containerName', containerName, type=str,
24  noneAction='error',
25  info="the name of the output container after calibration.")
26  self.addOption ('ESModel', '', type=str,
27  info="flag of egamma calibration recommendation.")
28  self.addOption ('decorrelationModel', '1NP_v1', type=str,
29  info="egamma energy scale decorrelationModel. The default is 1NP_v1. "
30  "Supported Model: 1NP_v1, FULL_v1.")
31  self.addOption ('postfix', '', type=str,
32  info="a postfix to apply to decorations and algorithm names. "
33  "Typically not needed here since the calibration is common to "
34  "all photons.")
35  self.addOption ('crackVeto', False, type=bool,
36  info="whether to perform LAr crack veto based on the cluster eta, "
37  "i.e. remove photons within 1.37<|eta|<1.52. "
38  "The default is False.")
39  self.addOption ('enableCleaning', True, type=bool,
40  info="whether to enable photon cleaning (DFCommonPhotonsCleaning). "
41  "The default is True.")
42  self.addOption ('cleaningAllowLate', False, type=bool,
43  info="whether to ignore timing information in cleaning "
44  "(DFCommonPhotonsCleaningNoTime). The default is False.")
45  self.addOption ('recomputeIsEM', False, type=bool,
46  info="whether to recompute the photon shower shape fudge "
47  "corrections (sets up an instance of CP::PhotonShowerShapeFudgeAlg). "
48  "The default is False, i.e. to use derivation variables.")
49  self.addOption ('recalibratePhyslite', True, type=bool,
50  info="whether to run the CP::EgammaCalibrationAndSmearingAlg on "
51  "PHYSLITE derivations. The default is True.")
52  self.addOption ('minPt', 10*GeV, type=float,
53  info="the minimum pT cut to apply to calibrated photons. "
54  "The default is 10 GeV.")
55  self.addOption ('forceFullSimConfig', False, type=bool,
56  info="whether to force the tool to use the configuration meant for "
57  "full simulation samples. Only for testing purposes. "
58  "The default is False.")
59  self.addOption ('splitCalibrationAndSmearing', False, type=bool,
60  info="EXPERIMENTAL: This splits the EgammaCalibrationAndSmearingTool "
61  " into two steps. The first step applies a baseline calibration that "
62  "is not affected by systematics. The second step then applies the "
63  "systematics dependent corrections. The net effect is that the "
64  "slower first step only has to be run once, while the second is run "
65  "once per systematic. ATLASG-2358")
66  self.addOption ('decorateTruth', False, type=bool,
67  info="decorate truth particle information on the reconstructed one")
68 
69 

Member Function Documentation

◆ makeAlgs()

def python.PhotonAnalysisConfig.PhotonCalibrationConfig.makeAlgs (   self,
  config 
)

Definition at line 104 of file PhotonAnalysisConfig.py.

104  def makeAlgs (self, config) :
105 
106  log = logging.getLogger('PhotonCalibrationConfig')
107 
108  postfix = self.postfix
109  if postfix != '' and postfix[0] != '_' :
110  postfix = '_' + postfix
111 
112  if self.forceFullSimConfig:
113  log.warning("You are running PhotonCalibrationConfig forcing full sim config")
114  log.warning("This is only intended to be used for testing purposes")
115 
116  if config.isPhyslite() :
117  config.setSourceName (self.containerName, "AnalysisPhotons")
118  else :
119  config.setSourceName (self.containerName, "Photons")
120 
121  cleaningWP = 'NoTime' if self.cleaningAllowLate else ''
122 
123  # Set up a shallow copy to decorate
124  if config.wantCopy (self.containerName) :
125  alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'PhotonShallowCopyAlg' + postfix )
126  alg.input = config.readName (self.containerName)
127  alg.output = config.copyName (self.containerName)
128 
129  # Set up the eta-cut on all photons prior to everything else
130  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonEtaCutAlg' + postfix )
131  alg.selectionDecoration = 'selectEta' + postfix + ',as_bits'
132  config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
133  alg.selectionTool.maxEta = 2.37
134  if self.crackVeto:
135  alg.selectionTool.etaGapLow = 1.37
136  alg.selectionTool.etaGapHigh = 1.52
137  alg.selectionTool.useClusterEta = True
138  alg.particles = config.readName (self.containerName)
139  alg.preselection = config.getPreselection (self.containerName, '')
140  config.addSelection (self.containerName, '', alg.selectionDecoration)
141 
142  # Setup shower shape fudge
143  if self.recomputeIsEM and config.dataType() is DataType.FullSim:
144  alg = config.createAlgorithm( 'CP::PhotonShowerShapeFudgeAlg',
145  'PhotonShowerShapeFudgeAlg' + postfix )
146  config.addPrivateTool( 'showerShapeFudgeTool',
147  'ElectronPhotonVariableCorrectionTool' )
148  if config.geometry is LHCPeriod.Run2:
149  alg.showerShapeFudgeTool.ConfigFile = \
150  'EGammaVariableCorrection/TUNE25/ElPhVariableNominalCorrection.conf'
151  if config.geometry is LHCPeriod.Run3:
152  alg.showerShapeFudgeTool.ConfigFile = \
153  'EGammaVariableCorrection/TUNE23/ElPhVariableNominalCorrection.conf'
154  alg.photons = config.readName (self.containerName)
155  alg.photonsOut = config.copyName (self.containerName)
156  alg.preselection = config.getPreselection (self.containerName, '')
157 
158  # Select photons only with good object quality.
159  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonObjectQualityAlg' + postfix )
160  alg.selectionDecoration = 'goodOQ,as_bits'
161  config.addPrivateTool( 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
162  alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
163  alg.particles = config.readName (self.containerName)
164  alg.preselection = config.getPreselection (self.containerName, '')
165  config.addSelection (self.containerName, '', alg.selectionDecoration)
166 
167  # Select clean photons
168  if self.enableCleaning:
169  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonCleaningAlg' + postfix)
170  config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
171  alg.selectionDecoration = 'isClean,as_bits'
172  alg.selectionTool.selectionFlags = ['DFCommonPhotonsCleaning' + cleaningWP]
173  alg.particles = config.readName (self.containerName)
174  alg.preselection = config.getPreselection (self.containerName, '')
175  config.addSelection (self.containerName, '', alg.selectionDecoration)
176 
177  # Change the origin of Photons from (0,0,0) to (0,0,z)
178  # where z comes from the position of a vertex
179  # Default the one tagged as Primary
180  alg = config.createAlgorithm( 'CP::PhotonOriginCorrectionAlg',
181  'PhotonOriginCorrectionAlg' + postfix )
182  alg.photons = config.readName (self.containerName)
183  alg.photonsOut = config.copyName (self.containerName)
184  alg.preselection = config.getPreselection (self.containerName, '')
185 
186  if not self.splitCalibrationAndSmearing :
187  # Set up the calibration and smearing algorithm:
188  alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonCalibrationAndSmearingAlg')
189  if config.isPhyslite() and not self.recalibratePhyslite :
190  alg.skipNominal = True
191  else:
192  # This splits the EgammaCalibrationAndSmearingTool into two
193  # steps. The first step applies a baseline calibration that
194  # is not affected by systematics. The second step then
195  # applies the systematics dependent corrections. The net
196  # effect is that the slower first step only has to be run
197  # once, while the second is run once per systematic.
198  #
199  # For now (22 May 24) this has to happen in the same job, as
200  # the output of the first step is not part of PHYSLITE, and
201  # even for the nominal the output of the first and second
202  # step are different. In the future the plan is to put both
203  # the output of the first and second step into PHYSLITE,
204  # allowing to skip the first step when running on PHYSLITE.
205  #
206  # WARNING: All of this is experimental, see: ATLASG-2358
207 
208  # Set up the calibration algorithm:
209  alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonBaseCalibrationAlg')
210  # turn off systematics for the calibration step
211  alg.noToolSystematics = True
212  # turn off smearing for the calibration step
213  alg.calibrationAndSmearingTool.doSmearing = False
214 
215  # Set up the smearing algorithm:
216  alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonCalibrationSystematicsAlg')
217  # turn off scale corrections for the smearing step
218  alg.calibrationAndSmearingTool.doScaleCorrection = False
219  alg.calibrationAndSmearingTool.useMVACalibration = False
220 
221  if self.minPt > 0:
222  # Set up the the pt selection
223  alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonPtCutAlg' + postfix )
224  alg.selectionDecoration = 'selectPt' + postfix + ',as_bits'
225  config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
226  alg.selectionTool.minPt = self.minPt
227  alg.particles = config.readName (self.containerName)
228  alg.preselection = config.getPreselection (self.containerName, '')
229  config.addSelection (self.containerName, '', alg.selectionDecoration,
230  preselection=True)
231 
232  # Set up the isolation correction algorithm.
233  alg = config.createAlgorithm( 'CP::EgammaIsolationCorrectionAlg',
234  'PhotonIsolationCorrectionAlg' + postfix )
235  config.addPrivateTool( 'isolationCorrectionTool',
236  'CP::IsolationCorrectionTool' )
237  alg.isolationCorrectionTool.IsMC = config.dataType() is not DataType.Data
238  alg.isolationCorrectionTool.AFII_corr = (
239  0 if self.forceFullSimConfig
240  else config.dataType() is DataType.FastSim)
241  alg.egammas = config.readName (self.containerName)
242  alg.egammasOut = config.copyName (self.containerName)
243  alg.preselection = config.getPreselection (self.containerName, '')
244 
245  # Additional decorations
246  alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' + self.containerName + self.postfix )
247  alg.particles = config.readName (self.containerName)
248 
249  config.addOutputVar (self.containerName, 'pt', 'pt')
250  config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
251  config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
252  config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
253 
254  # decorate truth information on the reconstructed object:
255  if self.decorateTruth and config.dataType() is not DataType.Data:
256  config.addOutputVar (self.containerName, "truthType", "truth_type", noSys=True)
257  config.addOutputVar (self.containerName, "truthOrigin", "truth_origin", noSys=True)
258 
259 

◆ makeCalibrationAndSmearingAlg()

def python.PhotonAnalysisConfig.PhotonCalibrationConfig.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 70 of file PhotonAnalysisConfig.py.

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

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