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