90def EGAM4KernelCfg(flags, name="EGAM4Kernel", **kwargs):
91 """Configure the derivation framework driving algorithm (kernel)
92 for EGAM4"""
93 acc = ComponentAccumulator()
94
95
96 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
97
98 acc.merge(
99 PhysCommonAugmentationsCfg(
100 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
101 )
102 )
103
104
105 augmentationTools = []
106
107
108
109
110 EGAM4mumuMassTool = acc.popToolsAndMerge(EGAM4mumuMassToolCfg(flags))
111 acc.addPublicTool(EGAM4mumuMassTool)
112 augmentationTools.append(EGAM4mumuMassTool)
113
114
115
116
117 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
118 CaloDecoratorKernelCfg)
119 acc.merge(CaloDecoratorKernelCfg(flags))
120
121
122 thinningTools = []
123 streamName = kwargs["StreamName"]
124
125
126 if flags.Derivation.Egamma.doTrackThinning:
127 from DerivationFrameworkInDet.InDetToolsConfig import (
128 TrackParticleThinningCfg,
129 MuonTrackParticleThinningCfg,
130 TauTrackParticleThinningCfg,
131 )
132
133 TrackThinningKeepElectronTracks = True
134 TrackThinningKeepAllElectronTracks = False
135 TrackThinningKeepPhotonTracks = True
136 TrackThinningKeepAllPhotonTracks = True
137 TrackThinningKeepJetTracks = False
138 TrackThinningKeepMuonTracks = False
139 TrackThinningKeepTauTracks = False
140 TrackThinningKeepPVTracks = True
141
142
143 if TrackThinningKeepElectronTracks:
144 EGAM4ElectronTPThinningTool = (
145 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
146 name="EGAM4ElectronTPThinningTool",
147 StreamName=streamName,
148 SGKey="Electrons",
149 GSFTrackParticlesKey="GSFTrackParticles",
150 InDetTrackParticlesKey="InDetTrackParticles",
151 SelectionString="Electrons.pt > 0*GeV",
152 BestMatchOnly=True,
153 ConeSize=0.3,
154 )
155 )
156 acc.addPublicTool(EGAM4ElectronTPThinningTool)
157 thinningTools.append(EGAM4ElectronTPThinningTool)
158
159
160
161 if TrackThinningKeepAllElectronTracks:
162 EGAM4ElectronTPThinningTool2 = (
163 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
164 name="EGAM4ElectronTPThinningTool2",
165 StreamName=streamName,
166 SGKey="Electrons",
167 GSFTrackParticlesKey="GSFTrackParticles",
168 InDetTrackParticlesKey="InDetTrackParticles",
169 SelectionString="Electrons.pt > 4*GeV",
170 BestMatchOnly=False,
171 ConeSize=0.6,
172 )
173 )
174 acc.addPublicTool(EGAM4ElectronTPThinningTool2)
175 thinningTools.append(EGAM4ElectronTPThinningTool2)
176
177
178 if TrackThinningKeepPhotonTracks:
179 EGAM4PhotonTPThinningTool = (
180 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
181 name="EGAM4PhotonTPThinningTool",
182 StreamName=streamName,
183 SGKey="Photons",
184 GSFTrackParticlesKey="GSFTrackParticles",
185 InDetTrackParticlesKey="InDetTrackParticles",
186 GSFConversionVerticesKey="GSFConversionVertices",
187 SelectionString="Photons.pt > 0*GeV",
188 BestMatchOnly=True,
189 ConeSize=0.3,
190 )
191 )
192 acc.addPublicTool(EGAM4PhotonTPThinningTool)
193 thinningTools.append(EGAM4PhotonTPThinningTool)
194
195
196
197 if TrackThinningKeepAllPhotonTracks:
198 EGAM4PhotonTPThinningTool2 = (
199 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
200 name="EGAM4PhotonTPThinningTool2",
201 StreamName=streamName,
202 SGKey="Photons",
203 GSFTrackParticlesKey="GSFTrackParticles",
204 InDetTrackParticlesKey="InDetTrackParticles",
205 GSFConversionVerticesKey="GSFConversionVertices",
206 SelectionString="Photons.pt > 9.5*GeV",
207 BestMatchOnly=False,
208 ConeSize=0.6,
209 )
210 )
211 acc.addPublicTool(EGAM4PhotonTPThinningTool2)
212 thinningTools.append(EGAM4PhotonTPThinningTool2)
213
214
215 if TrackThinningKeepJetTracks:
216 EGAM4JetTPThinningTool = (
217 CompFactory.DerivationFramework.JetTrackParticleThinning(
218 name="EGAM4JetTPThinningTool",
219 StreamName=streamName,
220 JetKey="AntiKt4EMPFlowJets",
221 InDetTrackParticlesKey="InDetTrackParticles",
222 )
223 )
224 acc.addPublicTool(EGAM4JetTPThinningTool)
225 thinningTools.append(EGAM4JetTPThinningTool)
226
227
228 if TrackThinningKeepMuonTracks:
229 EGAM4MuonTPThinningTool = acc.getPrimaryAndMerge(
230 MuonTrackParticleThinningCfg(
231 flags,
232 name="EGAM4MuonTPThinningTool",
233 StreamName=streamName,
234 MuonKey="Muons",
235 InDetTrackParticlesKey="InDetTrackParticles",
236 )
237 )
238 thinningTools.append(EGAM4MuonTPThinningTool)
239
240
241 if TrackThinningKeepTauTracks:
242 EGAM4TauTPThinningTool = acc.getPrimaryAndMerge(
243 TauTrackParticleThinningCfg(
244 flags,
245 name="EGAM4TauTPThinningTool",
246 StreamName=streamName,
247 TauKey="TauJets",
248 ConeSize=0.6,
249 InDetTrackParticlesKey="InDetTrackParticles",
250 DoTauTracksThinning=True,
251 TauTracksKey="TauTracks",
252 )
253 )
254 thinningTools.append(EGAM4TauTPThinningTool)
255
256
257 thinning_expression = " && ".join(
258 [
259 "(InDetTrackParticles.DFCommonTightPrimary)",
260 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
261 "(InDetTrackParticles.pt>10*GeV)",
262 ]
263 )
264 if TrackThinningKeepPVTracks:
265 EGAM4TPThinningTool = acc.getPrimaryAndMerge(
266 TrackParticleThinningCfg(
267 flags,
268 name="EGAM4TPThinningTool",
269 StreamName=streamName,
270 SelectionString=thinning_expression,
271 InDetTrackParticlesKey="InDetTrackParticles",
272 )
273 )
274 thinningTools.append(EGAM4TPThinningTool)
275
276
277 skimmingTool = acc.popToolsAndMerge(EGAM4SkimmingToolCfg(flags))
278 acc.addPublicTool(skimmingTool)
279
280
281 acc.addEventAlgo(
282 CompFactory.DerivationFramework.DerivationKernel(
283 name,
284 SkimmingTools=[skimmingTool],
285 AugmentationTools=augmentationTools,
286 ThinningTools=thinningTools,
287 )
288 )
289
290 return acc
291
292