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