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