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