132def EGAM5KernelCfg(flags, name="EGAM5Kernel", **kwargs):
133 """Configure the derivation framework driving algorithm (kernel)
134 for EGAM5"""
135 acc = ComponentAccumulator()
136
137
138 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
139
140 acc.merge(
141 PhysCommonAugmentationsCfg(
142 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
143 )
144 )
145
146
147 augmentationTools = []
148
149
150
151
152 EGAM5enuTransverseMassTool = acc.popToolsAndMerge(
153 EGAM5enuTransverseMassToolCfg(flags)
154 )
155 acc.addPublicTool(EGAM5enuTransverseMassTool)
156 augmentationTools.append(EGAM5enuTransverseMassTool)
157
158
159
160
161 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
162 CaloDecoratorKernelCfg)
163 acc.merge(CaloDecoratorKernelCfg(flags))
164
165
166 thinningTools = []
167 streamName = kwargs["StreamName"]
168
169
170 if flags.Derivation.Egamma.doTrackThinning:
171 from DerivationFrameworkInDet.InDetToolsConfig import (
172 TrackParticleThinningCfg,
173 MuonTrackParticleThinningCfg,
174 TauTrackParticleThinningCfg,
175 )
176
177 TrackThinningKeepElectronTracks = True
178 TrackThinningKeepPhotonTracks = True
179 TrackThinningKeepAllElectronTracks = False
180 TrackThinningKeepJetTracks = False
181 TrackThinningKeepMuonTracks = False
182 TrackThinningKeepTauTracks = False
183 TrackThinningKeepPVTracks = True
184
185
186 if TrackThinningKeepElectronTracks:
187 EGAM5ElectronTPThinningTool = (
188 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
189 name="EGAM5ElectronTPThinningTool",
190 StreamName=streamName,
191 SGKey="Electrons",
192 GSFTrackParticlesKey="GSFTrackParticles",
193 InDetTrackParticlesKey="InDetTrackParticles",
194 SelectionString="Electrons.pt > 0*GeV",
195 BestMatchOnly=True,
196 ConeSize=0.3,
197 )
198 )
199 acc.addPublicTool(EGAM5ElectronTPThinningTool)
200 thinningTools.append(EGAM5ElectronTPThinningTool)
201
202
203
204 if TrackThinningKeepAllElectronTracks:
205 EGAM5ElectronTPThinningTool2 = (
206 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
207 name="EGAM5ElectronTPThinningTool2",
208 StreamName=streamName,
209 SGKey="Electrons",
210 GSFTrackParticlesKey="GSFTrackParticles",
211 InDetTrackParticlesKey="InDetTrackParticles",
212 SelectionString="Electrons.pt > 4*GeV",
213 BestMatchOnly=False,
214 ConeSize=0.6,
215 )
216 )
217 acc.addPublicTool(EGAM5ElectronTPThinningTool2)
218 thinningTools.append(EGAM5ElectronTPThinningTool2)
219
220
221 if TrackThinningKeepPhotonTracks:
222 EGAM5PhotonTPThinningTool = (
223 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
224 name="EGAM5PhotonTPThinningTool",
225 StreamName=streamName,
226 SGKey="Photons",
227 GSFTrackParticlesKey="GSFTrackParticles",
228 InDetTrackParticlesKey="InDetTrackParticles",
229 GSFConversionVerticesKey="GSFConversionVertices",
230 SelectionString="Photons.pt > 0*GeV",
231 BestMatchOnly=True,
232 ConeSize=0.3,
233 )
234 )
235 acc.addPublicTool(EGAM5PhotonTPThinningTool)
236 thinningTools.append(EGAM5PhotonTPThinningTool)
237
238
239 if TrackThinningKeepJetTracks:
240 EGAM5JetTPThinningTool = (
241 CompFactory.DerivationFramework.JetTrackParticleThinning(
242 name="EGAM5JetTPThinningTool",
243 StreamName=streamName,
244 JetKey="AntiKt4EMPFlowJets",
245 InDetTrackParticlesKey="InDetTrackParticles",
246 )
247 )
248 acc.addPublicTool(EGAM5JetTPThinningTool)
249 thinningTools.append(EGAM5JetTPThinningTool)
250
251
252 if TrackThinningKeepMuonTracks:
253 EGAM5MuonTPThinningTool = acc.getPrimaryAndMerge(
254 MuonTrackParticleThinningCfg(
255 flags,
256 name="EGAM5MuonTPThinningTool",
257 StreamName=streamName,
258 MuonKey="Muons",
259 InDetTrackParticlesKey="InDetTrackParticles",
260 )
261 )
262 thinningTools.append(EGAM5MuonTPThinningTool)
263
264
265 if TrackThinningKeepTauTracks:
266 EGAM5TauTPThinningTool = acc.getPrimaryAndMerge(
267 TauTrackParticleThinningCfg(
268 flags,
269 name="EGAM5TauTPThinningTool",
270 StreamName=streamName,
271 TauKey="TauJets",
272 ConeSize=0.6,
273 InDetTrackParticlesKey="InDetTrackParticles",
274 DoTauTracksThinning=True,
275 TauTracksKey="TauTracks",
276 )
277 )
278 thinningTools.append(EGAM5TauTPThinningTool)
279
280
281 thinning_expression = " && ".join(
282 [
283 "(InDetTrackParticles.DFCommonTightPrimary)",
284 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
285 "(InDetTrackParticles.pt>10*GeV)",
286 ]
287 )
288 if TrackThinningKeepPVTracks:
289 EGAM5TPThinningTool = acc.getPrimaryAndMerge(
290 TrackParticleThinningCfg(
291 flags,
292 name="EGAM5TPThinningTool",
293 StreamName=streamName,
294 SelectionString=thinning_expression,
295 InDetTrackParticlesKey="InDetTrackParticles",
296 )
297 )
298 thinningTools.append(EGAM5TPThinningTool)
299
300
301 skimmingTool = acc.getPrimaryAndMerge(EGAM5SkimmingToolCfg(flags))
302
303
304 acc.addEventAlgo(
305 CompFactory.DerivationFramework.DerivationKernel(
306 name,
307 SkimmingTools=[skimmingTool],
308 AugmentationTools=augmentationTools,
309 ThinningTools=thinningTools,
310 )
311 )
312
313 return acc
314
315