93 enableCleaning = True,
94 cleaningAllowLate = False,
95 recomputeIsEM = False,
96 ptSelectionOutput = False,
97 forceFullSimConfig = False):
98 """Create photon calibration analysis algorithms
100 This makes all the algorithms that need to be run first befor
101 all working point specific algorithms and that can be shared
102 between the working points.
105 dataType -- The data type to run on ("data", "mc" or "afii")
106 postfix -- a postfix to apply to decorations and algorithm
107 names. this is mostly used/needed when using this
108 sequence with multiple working points to ensure all
110 crackVeto -- Whether or not to perform eta crack veto
111 enableCleaning -- Enable photon cleaning
112 cleaningAllowLate -- Whether to ignore timing information in cleaning.
113 recomputeIsEM -- Whether to rerun the cut-based selection. If not, use derivation flags
114 ptSelectionOutput -- Whether or not to apply pt selection when creating
119 if dataType
not in [
'data',
'mc',
'afii' ]:
120 raise ValueError(
'Invalid data type: %s' % dataType )
122 if forceFullSimConfig:
123 print(
"WARNING! You are running makePhotonCalibrationSequence forcing full sim config")
124 print(
"WARNING! This is only intended to be used for testing purposes")
126 cleaningWP =
'NoTime' if cleaningAllowLate
else ''
129 alg =
createAlgorithm(
'CP::AsgShallowCopyAlg',
'PhotonShallowCopyAlg' + postfix )
130 seq.append( alg, inputPropName =
'input',
131 outputPropName =
'output',
132 stageName =
'prepare')
135 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonEtaCutAlg' + postfix )
136 alg.selectionDecoration =
'selectEta' + postfix +
',as_bits'
137 addPrivateTool( alg,
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
138 alg.selectionTool.maxEta = 2.37
140 alg.selectionTool.etaGapLow = 1.37
141 alg.selectionTool.etaGapHigh = 1.52
142 alg.selectionTool.useClusterEta =
True
143 seq.append( alg, inputPropName =
'particles',
144 stageName =
'calibration',
145 metaConfig = {
'selectionDecorNames' : [alg.selectionDecoration],
146 'selectionDecorNamesOutput' : [alg.selectionDecoration],
147 'selectionDecorCount' : [5
if crackVeto
else 4]},
148 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
151 if recomputeIsEM
and dataType ==
'mc':
153 'PhotonShowerShapeFudgeAlg' + postfix )
155 'ElectronPhotonVariableCorrectionTool' )
156 alg.showerShapeFudgeTool.ConfigFile = \
157 'EGammaVariableCorrection/TUNE23/ElPhVariableNominalCorrection.conf'
158 seq.append( alg, inputPropName =
'photons', outputPropName =
'photonsOut',
159 stageName =
'calibration',
160 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
164 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonObjectQualityAlg' + postfix )
165 alg.selectionDecoration =
'goodOQ,as_bits'
166 addPrivateTool( alg,
'selectionTool',
'CP::EgammaIsGoodOQSelectionTool' )
167 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
168 seq.append( alg, inputPropName =
'particles',
169 stageName =
'calibration',
170 metaConfig = {
'selectionDecorNames' : [alg.selectionDecoration],
171 'selectionDecorNamesOutput' : [alg.selectionDecoration],
172 'selectionDecorCount' : [1]},
173 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
177 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonCleaningAlg' + postfix)
178 addPrivateTool( alg,
'selectionTool',
'CP::AsgFlagSelectionTool' )
179 alg.selectionDecoration =
'isClean,as_bits'
180 alg.selectionTool.selectionFlags = [
'DFCommonPhotonsCleaning' + cleaningWP]
181 seq.append( alg, inputPropName =
'particles',
182 stageName =
'calibration',
183 metaConfig = {
'selectionDecorNames' : [alg.selectionDecoration],
184 'selectionDecorNamesOutput' : [alg.selectionDecoration],
185 'selectionDecorCount' : [1]},
186 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
192 'PhotonOriginCorrectionAlg' + postfix)
193 seq.append( alg, inputPropName =
'photons', outputPropName =
'photonsOut',
194 stageName =
'calibration',
195 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
199 'PhotonCalibrationAndSmearingAlg' + postfix )
201 'CP::EgammaCalibrationAndSmearingTool' )
202 alg.calibrationAndSmearingTool.ESModel =
'es2022_R22_PRE'
203 alg.calibrationAndSmearingTool.decorrelationModel =
'1NP_v1'
204 alg.calibrationAndSmearingTool.useFastSim = (0
if forceFullSimConfig
205 else int(dataType ==
'afii'))
206 seq.append( alg, inputPropName =
'egammas', outputPropName =
'egammasOut',
207 stageName =
'calibration',
208 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
211 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonPtCutAlg' + postfix )
212 alg.selectionDecoration =
'selectPt' + postfix +
',as_bits'
213 addPrivateTool( alg,
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
214 alg.selectionTool.minPt = 10e3
215 seq.append( alg, inputPropName =
'particles',
216 stageName =
'selection',
217 metaConfig = {
'selectionDecorNames' : [alg.selectionDecoration],
218 'selectionDecorNamesOutput' : [alg.selectionDecoration]
if ptSelectionOutput
else [],
219 'selectionDecorCount' : [2]},
220 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )
224 'PhotonIsolationCorrectionAlg' + postfix )
226 'CP::IsolationCorrectionTool' )
227 alg.isolationCorrectionTool.IsMC =
int(dataType !=
'data')
228 alg.isolationCorrectionTool.AFII_corr = (0
if forceFullSimConfig
229 else dataType ==
'afii')
230 seq.append( alg, inputPropName =
'egammas', outputPropName =
'egammasOut',
231 stageName =
'selection',
232 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNamesOutput"])} )