157def EGAM2KernelCfg(flags, name="EGAM2Kernel", **kwargs):
158 """Configure the derivation framework driving algorithm (kernel)
159 for EGAM2"""
160 acc = ComponentAccumulator()
161
162
163 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
164
165 acc.merge(
166 PhysCommonAugmentationsCfg(
167 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
168 )
169 )
170
171
172 augmentationTools = []
173
174
175
176
177 EGAM2JpsieeMassTool1 = acc.popToolsAndMerge(EGAM2JpsieeMassTool1Cfg(flags))
178 acc.addPublicTool(EGAM2JpsieeMassTool1)
179 augmentationTools.append(EGAM2JpsieeMassTool1)
180
181 EGAM2JpsieeMassTool2 = acc.popToolsAndMerge(EGAM2JpsieeMassTool2Cfg(flags))
182 acc.addPublicTool(EGAM2JpsieeMassTool2)
183 augmentationTools.append(EGAM2JpsieeMassTool2)
184
185
186
187
188 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
189 CaloDecoratorKernelCfg,
190 )
191
192 acc.merge(CaloDecoratorKernelCfg(flags))
193
194
195 thinningTools = []
196 streamName = kwargs["StreamName"]
197
198
199 if flags.Derivation.Egamma.doTrackThinning:
200 from DerivationFrameworkInDet.InDetToolsConfig import (
201 TrackParticleThinningCfg,
202 MuonTrackParticleThinningCfg,
203 TauTrackParticleThinningCfg,
204 )
205
206 TrackThinningKeepElectronTracks = True
207 TrackThinningKeepPhotonTracks = True
208 TrackThinningKeepAllElectronTracks = False
209 TrackThinningKeepJetTracks = False
210 TrackThinningKeepMuonTracks = False
211 TrackThinningKeepTauTracks = False
212 TrackThinningKeepPVTracks = False
213
214
215 if TrackThinningKeepElectronTracks:
216 EGAM2ElectronTPThinningTool = (
217 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
218 name="EGAM2ElectronTPThinningTool",
219 StreamName=streamName,
220 SGKey="Electrons",
221 GSFTrackParticlesKey="GSFTrackParticles",
222 InDetTrackParticlesKey="InDetTrackParticles",
223 SelectionString="Electrons.pt > 0*GeV",
224 BestMatchOnly=True,
225 ConeSize=0.3,
226 )
227 )
228 acc.addPublicTool(EGAM2ElectronTPThinningTool)
229 thinningTools.append(EGAM2ElectronTPThinningTool)
230
231
232
233 if TrackThinningKeepAllElectronTracks:
234 EGAM2ElectronTPThinningTool2 = (
235 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
236 name="EGAM2ElectronTPThinningTool2",
237 StreamName=streamName,
238 SGKey="Electrons",
239 GSFTrackParticlesKey="GSFTrackParticles",
240 InDetTrackParticlesKey="InDetTrackParticles",
241 SelectionString="Electrons.pt > 4*GeV",
242 BestMatchOnly=False,
243 ConeSize=0.6,
244 )
245 )
246 acc.addPublicTool(EGAM2ElectronTPThinningTool2)
247 thinningTools.append(EGAM2ElectronTPThinningTool2)
248
249
250 if TrackThinningKeepPhotonTracks:
251 EGAM2PhotonTPThinningTool = (
252 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
253 name="EGAM2PhotonTPThinningTool",
254 StreamName=streamName,
255 SGKey="Photons",
256 GSFTrackParticlesKey="GSFTrackParticles",
257 InDetTrackParticlesKey="InDetTrackParticles",
258 GSFConversionVerticesKey="GSFConversionVertices",
259 SelectionString="Photons.pt > 0*GeV",
260 BestMatchOnly=True,
261 ConeSize=0.3,
262 )
263 )
264 acc.addPublicTool(EGAM2PhotonTPThinningTool)
265 thinningTools.append(EGAM2PhotonTPThinningTool)
266
267
268 if TrackThinningKeepJetTracks:
269 EGAM2JetTPThinningTool = (
270 CompFactory.DerivationFramework.JetTrackParticleThinning(
271 name="EGAM2JetTPThinningTool",
272 StreamName=streamName,
273 JetKey="AntiKt4EMPFlowJets",
274 InDetTrackParticlesKey="InDetTrackParticles",
275 )
276 )
277 acc.addPublicTool(EGAM2JetTPThinningTool)
278 thinningTools.append(EGAM2JetTPThinningTool)
279
280
281 if TrackThinningKeepMuonTracks:
282 EGAM2MuonTPThinningTool = acc.getPrimaryAndMerge(
283 MuonTrackParticleThinningCfg(
284 flags,
285 name="EGAM2MuonTPThinningTool",
286 StreamName=streamName,
287 MuonKey="Muons",
288 InDetTrackParticlesKey="InDetTrackParticles",
289 )
290 )
291 thinningTools.append(EGAM2MuonTPThinningTool)
292
293
294 if TrackThinningKeepTauTracks:
295 EGAM2TauTPThinningTool = acc.getPrimaryAndMerge(
296 TauTrackParticleThinningCfg(
297 flags,
298 name="EGAM2TauTPThinningTool",
299 StreamName=streamName,
300 TauKey="TauJets",
301 ConeSize=0.6,
302 InDetTrackParticlesKey="InDetTrackParticles",
303 DoTauTracksThinning=True,
304 TauTracksKey="TauTracks",
305 )
306 )
307 thinningTools.append(EGAM2TauTPThinningTool)
308
309
310 thinning_expression = " && ".join(
311 [
312 "(InDetTrackParticles.DFCommonTightPrimary)",
313 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
314 "(InDetTrackParticles.pt > 10*GeV)",
315 ]
316 )
317 if TrackThinningKeepPVTracks:
318 EGAM2TPThinningTool = acc.getPrimaryAndMerge(
319 TrackParticleThinningCfg(
320 flags,
321 name="EGAM2TPThinningTool",
322 StreamName=streamName,
323 SelectionString=thinning_expression,
324 InDetTrackParticlesKey="InDetTrackParticles",
325 )
326 )
327 thinningTools.append(EGAM2TPThinningTool)
328
329
330 skimmingTool = acc.getPrimaryAndMerge(EGAM2SkimmingToolCfg(flags))
331
332
333 acc.addEventAlgo(
334 CompFactory.DerivationFramework.DerivationKernel(
335 name,
336 SkimmingTools=[skimmingTool],
337 AugmentationTools=augmentationTools,
338 ThinningTools=thinningTools,
339 )
340 )
341
342 return acc
343
344