ATLAS Offline Software
Loading...
Searching...
No Matches
BPHY18.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2#====================================================================
3# BPHY18.py
4#====================================================================
5
6from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7from AthenaConfiguration.ComponentFactory import CompFactory
8from AthenaConfiguration.Enums import MetadataCategory
9
10
11BPHYDerivationName = "BPHY18"
12streamName = "StreamDAOD_BPHY18"
13
14def BPHY18Cfg(flags):
15 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
16 from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
17 from DerivationFrameworkEGamma.EGammaCommonConfig import EGammaCommonCfg
18 from AthenaServices.PartPropSvcConfig import PartPropSvcCfg
19
20 acc = ComponentAccumulator()
21 PartPropSvcName = acc.getPrimaryAndMerge(PartPropSvcCfg(flags))
22 acc.merge(EGammaCommonCfg(flags))
23 isSimulation = flags.Input.isMC
24 V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, BPHYDerivationName))
25 vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName)) # VKalVrt vertex fitter
26 acc.addPublicTool(vkalvrt)
27 acc.addPublicTool(V0Tools)
28 trackselect = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, BPHYDerivationName))
29 acc.addPublicTool(trackselect)
30 vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, BPHYDerivationName))
31 acc.addPublicTool(vpest)
32
33 skimmingTools = []
34
35 if flags.Trigger.EDMVersion >= 0:
36 BPHY18TriggerSkim = CompFactory.DerivationFramework.TriggerSkimmingTool(
37 name = "BPHY18TriggerSkim",
38 TriggerListOR = [
39 "HLT_e5_lhvloose_e3_lhvloose_bBeeM6000_L1BKeePrimary",
40 "HLT_2e5_bBeeM6000_L1BKeePrimary",
41 "HLT_e5_lhvloose_bBeeM6000_L1BKeePrimary",
42 "HLT_e5_lhvloose_e3_lhvloose_bBeeM6000_L1BKeePrescaled",
43 "HLT_2e5_bBeeM6000_L1BKeePrescaled",
44 "HLT_e5_lhvloose_bBeeM6000_L1BKeePrescaled"
45 ]
46 )
47 skimmingTools += [BPHY18TriggerSkim]
48
49 ElectronLHSelectorLHvloose_nod0 = CompFactory.AsgElectronLikelihoodTool("ElectronLHSelectorLHvloosenod0",
50 primaryVertexContainer = "PrimaryVertices",
51 ConfigFile="ElectronPhotonSelectorTools/offline/mc20_20230321/ElectronLikelihoodVeryLooseOfflineConfig2017_Smooth_NoD0_NoPix.conf")
52
53 # decorate electrons with the output of LH
54 from DerivationFrameworkEGamma.EGammaToolsConfig import EGElectronLikelihoodToolWrapperCfg
55 ElectronPassLHvloosenod0 = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(flags, name = "ElectronPassLHvloosenod0",
56 EGammaElectronLikelihoodTool = ElectronLHSelectorLHvloose_nod0,
57 EGammaFudgeMCTool = "",
58 CutType = "",
59 StoreGateEntryName = "DFCommonElectronsLHVeryLoosenod0",
60 ContainerName = "Electrons",
61 StoreTResult=False)))
62
63 BPHY18DiElectronFinder = CompFactory.Analysis.JpsiFinder_ee(
64 name = "BPHY18DiElectronFinder",
65 elAndEl = True,
66 elAndTrack = False,
67 TrackAndTrack = False,
68 assumeDiElectrons = True,
69 elThresholdPt = 4000.0,
70 invMassUpper = 7000.0,
71 invMassLower = 1.0,
72 Chi2Cut = 30.,
73 oppChargesOnly = False,
74 allChargeCombinations = True,
75 useElectronTrackMeasurement = True,
76 electronCollectionKey = "Electrons",
77 TrackParticleCollection = "GSFTrackParticles",
78 useEgammaCuts = True,
79 V0VertexFitterTool = None,
80 useV0Fitter = False,
81 TrkVertexFitterTool = vkalvrt,
82 TrackSelectorTool = trackselect,
83 VertexPointEstimator = vpest,
84 ElectronSelection = "d0_or_nod0",
85 PartPropSvc = PartPropSvcName
86 )
87 extraTools = [BPHY18DiElectronFinder]
88 BPHY18DiElectronSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
89 name = "BPHY18DiElectronSelectAndWrite",
90 VertexSearchTool = BPHY18DiElectronFinder,
91 OutputVtxContainerName = "BPHY18DiElectronCandidates",
92 PVContainerName = "PrimaryVertices",
93 V0Tools = V0Tools,
94 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
95 RefPVContainerName = "SHOULDNOTBEUSED",
96 DoVertexType = 7
97 )
98
99 BPHY18_Select_DiElectrons = CompFactory.DerivationFramework.Select_onia2mumu(
100 name = "BPHY18_Select_DiElectrons",
101 HypothesisName = "Jpsi",
102 InputVtxContainerName = "BPHY18DiElectronCandidates",
103 V0Tools = V0Tools,
104 VtxMassHypo = 3096.916,
105 MassMin = 1.0,
106 MassMax = 7000.0,
107 Chi2Max = 30,
108 DoVertexType = 7
109 )
110
111 BPHY18BeeKst = CompFactory.Analysis.JpsiPlus2Tracks(
112 name = "BPHY18BeeKstFinder",
113 kaonkaonHypothesis = False,
114 pionpionHypothesis = False,
115 kaonpionHypothesis = True,
116 oppChargesOnly = False,
117 SameChargesOnly = False,
118 trkThresholdPt = 500.0,
119 trkMaxEta = 3.0,
120 BThresholdPt = 1000.,
121 BMassLower = 3000.0,
122 BMassUpper = 6500.0,
123 JpsiContainerKey = "BPHY18DiElectronCandidates",
124 TrackParticleCollection = "InDetTrackParticles",
125 ExcludeCrossJpsiTracks = False,
126 TrkVertexFitterTool = vkalvrt,
127 TrackSelectorTool = trackselect,
128 UseMassConstraint = False,
129 DiTrackMassUpper = 1110.,
130 DiTrackMassLower = 690.,
131 Chi2Cut = 15.0,
132 DiTrackPt = 500.,
133 TrkQuadrupletMassLower = 1000.0,
134 TrkQuadrupletMassUpper = 10000.0,
135 FinalDiTrackPt = 500.,
136 UseGSFTrackIndices = [0,1]
137 )
138 BPHY18BeeKstSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
139 name = "BPHY18BeeKstSelectAndWrite",
140 VertexSearchTool = BPHY18BeeKst,
141 OutputVtxContainerName = "BeeKstCandidates",
142 PVContainerName = "PrimaryVertices",
143 RefPVContainerName = "BPHY18RefittedPrimaryVertices",
144 RefitPV = True,
145 V0Tools = V0Tools,
146 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
147 MaxPVrefit = 10000,
148 DoVertexType = 7
149 )
150
151 BPHY18_Select_BeeKst = CompFactory.DerivationFramework.Select_onia2mumu(
152 name = "BPHY18_Select_BeeKst",
153 HypothesisName = "Bd",
154 InputVtxContainerName = "BeeKstCandidates",
155 V0Tools = V0Tools,
156 TrkMasses = [0.511, 0.511, 493.677, 139.570],
157 VtxMassHypo = 5279.6,
158 MassMin = 1.0,
159 MassMax = 10000.0,
160 Chi2Max = 30.0
161 )
162
163 BPHY18_Select_BeeKstbar = CompFactory.DerivationFramework.Select_onia2mumu(
164 name = "BPHY18_Select_Bd2JpsiKstbar",
165 HypothesisName = "Bdbar",
166 InputVtxContainerName = "BeeKstCandidates",
167 V0Tools = V0Tools,
168 TrkMasses = [0.511, 0.511, 139.570, 493.677],
169 VtxMassHypo = 5279.6,
170 MassMin = 1.0,
171 MassMax = 10000.0,
172 Chi2Max = 30.0
173 )
174
175
176 BPHY18_diMeson_revertex = CompFactory.DerivationFramework.ReVertex(
177 name = "BPHY18_diMeson_revertex",
178 InputVtxContainerName = "BeeKstCandidates",
179 V0Tools = V0Tools,
180 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
181 TrackIndices = [ 2, 3 ],
182 TrkVertexFitterTool = vkalvrt,
183 OutputVtxContainerName = "BPHY18DiMeson"
184 )
185
186 BPHY18_Select_Kpi = CompFactory.DerivationFramework.Select_onia2mumu(
187 name = "BPHY18_Select_Kpi",
188 HypothesisName = "Kpi",
189 InputVtxContainerName = "BPHY18DiMeson",
190 V0Tools = V0Tools,
191 TrkMasses = [ 493.677, 139.570 ],
192 VtxMassHypo = 891.66,
193 MassMin = 1.0,
194 MassMax = 100000.0,
195 Chi2Max = 100.0
196 )
197
198 BPHY18_Select_piK = CompFactory.DerivationFramework.Select_onia2mumu(
199 name = "BPHY18_Select_piK",
200 HypothesisName = "piK",
201 InputVtxContainerName = "BPHY18DiMeson",
202 V0Tools = V0Tools,
203 TrkMasses = [ 139.570, 493.677 ],
204 VtxMassHypo = 891.66,
205 MassMin = 1.0,
206 MassMax = 100000.0,
207 Chi2Max = 100.0
208 )
209
210 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
211 xAODStringSkimmingToolCfg)
212 BPHY18_SelectBeeKstEvent = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
213 flags, name = "BPHY18_SelectBeeKstEvent",
214 expression = "(count(BeeKstCandidates.passed_Bd > 0) + count(BeeKstCandidates.passed_Bdbar > 0)) > 0"))
215 skimmingTools += [BPHY18_SelectBeeKstEvent]
216
217 BPHY18SkimmingAND = CompFactory.DerivationFramework.FilterCombinationAND(
218 "BPHY18SkimmingAND", FilterList = skimmingTools)
219
220 BPHY18_thinningTool_Tracks = CompFactory.DerivationFramework.Thin_vtxTrk(
221 name = "BPHY18_thinningTool_Tracks",
222 TrackParticleContainerName = "InDetTrackParticles",
223 StreamName = streamName,
224 VertexContainerNames = ["BeeKstCandidates"],
225 PassFlags = ["passed_Bd", "passed_Bdbar"] )
226
227 BPHY18_thinningTool_GSFTracks = CompFactory.DerivationFramework.Thin_vtxTrk(
228 name = "BPHY18_thinningTool_GSFTracks",
229 TrackParticleContainerName = "GSFTrackParticles",
230 StreamName = streamName,
231 VertexContainerNames = ["BeeKstCandidates"],
232 PassFlags = ["passed_Bd", "passed_Bdbar"] )
233
234 BPHY18_thinningTool_PV = CompFactory.DerivationFramework.BPhysPVThinningTool(
235 name = "BPHY18_thinningTool_PV",
236 StreamName = streamName,
237 CandidateCollections = ["BeeKstCandidates"],
238 KeepPVTracks = True
239 )
240
241 BPHY18MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(
242 name = "BPHY18MuonTPThinningTool",
243 StreamName = streamName,
244 MuonKey = "Muons",
245 InDetTrackParticlesKey = "InDetTrackParticles")
246
247 BPHY18EgammaTPThinningTool = CompFactory.DerivationFramework.EgammaTrackParticleThinning(
248 name = "BPHY18EgammaTPThinningTool",
249 StreamName = streamName,
250 SGKey = "Electrons",
251 InDetTrackParticlesKey = "InDetTrackParticles")
252
253 BPHY18TruthThinTool = CompFactory.DerivationFramework.GenericTruthThinning(name = "BPHY18TruthThinTool",
254 ParticleSelectionString = "abs(TruthParticles.pdgId) == 11 || abs(TruthParticles.pdgId) == 13 || abs(TruthParticles.pdgId) == 10311 || abs(TruthParticles.pdgId) == 521 || abs(TruthParticles.pdgId) == 523 || abs(TruthParticles.pdgId) == 511 || abs(TruthParticles.pdgId) == 513",
255 PreserveDescendants = True,
256 StreamName = streamName,
257 PreserveAncestors = True)
258
259 BPHY18TruthThinNoChainTool = CompFactory.DerivationFramework.GenericTruthThinning(name = "BPHY18TruthThinNoChainTool",
260 ParticleSelectionString = "abs(TruthParticles.pdgId) == 5 || abs(TruthParticles.pdgId) == 12 || abs(TruthParticles.pdgId) == 14",
261 PreserveDescendants = False,
262 StreamName = streamName,
263 PreserveAncestors = False)
264
265 thinningCollection = [ BPHY18_thinningTool_Tracks, BPHY18_thinningTool_GSFTracks,
266 BPHY18_thinningTool_PV, #BPHY18_thinningTool_PV_GSF,
267 BPHY18EgammaTPThinningTool, BPHY18MuonTPThinningTool
268 ]
269
270
271 augTools = [ElectronPassLHvloosenod0,
272 BPHY18DiElectronSelectAndWrite, BPHY18_Select_DiElectrons,
273 BPHY18BeeKstSelectAndWrite, BPHY18_Select_BeeKst, BPHY18_Select_BeeKstbar,
274 BPHY18_diMeson_revertex, BPHY18_Select_Kpi, BPHY18_Select_piK]
275 skimTools = [BPHY18SkimmingAND]
276
277 if isSimulation:
278 thinningCollection += [BPHY18TruthThinTool,BPHY18TruthThinNoChainTool]
279
280 for t in (augTools + skimTools + skimmingTools + thinningCollection +
281 extraTools):
282 acc.addPublicTool(t)
283
284 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY18Kernel",
285 AugmentationTools = augTools,
286 #Only skim if not MC
287 SkimmingTools = skimTools,
288 ThinningTools = thinningCollection))
289
290 from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
291 acc.merge(DerivationTrackIsoCfg(flags, object_types=("Electrons", "Muons")))
292
293
294 #====================================================================
295 # Slimming
296 #====================================================================
297
298 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
299 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
300 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
301 BPHY18SlimmingHelper = SlimmingHelper("BPHY18SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
302 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
303 AllVariables = getDefaultAllVariables()
304 StaticContent = []
305 ExtraVariables = []
306 BPHY18SlimmingHelper.SmartCollections = ["Electrons", "Muons", "InDetTrackParticles" ]
307
308 # Needed for trigger objects
309 BPHY18SlimmingHelper.IncludeMuonTriggerContent = False
310 BPHY18SlimmingHelper.IncludeBPhysTriggerContent = False
311 BPHY18SlimmingHelper.IncludeEGammaTriggerContent = True
312
313 AllVariables += ["PrimaryVertices"]
314 StaticContent += ["xAOD::VertexContainer#BPHY18RefittedPrimaryVertices"]
315 StaticContent += ["xAOD::VertexAuxContainer#BPHY18RefittedPrimaryVerticesAux."]
316
317 ExtraVariables += ["Muons.etaLayer1Hits.etaLayer2Hits.etaLayer3Hits.etaLayer4Hits.phiLayer1Hits.phiLayer2Hits.phiLayer3Hits.phiLayer4Hits",
318 "Muons.numberOfTriggerEtaLayers.numberOfPhiLayers",
319 "InDetTrackParticles.numberOfTRTHits.numberOfTRTHighThresholdHits.vx.vy.vz.pixeldEdx",
320 "PrimaryVertices.chiSquared.covariance",
321 "Electrons.deltaEta1.DFCommonElectronsLHVeryLoosenod0.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt1000.ptvarcone20_Nonprompt_All_MaxWeightTTVA_pt1000.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt500.ptvarcone40_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.ptvarcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000",
322 "egammaClusters.calE.calEta.calPhi.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME",
323 "HLT_xAOD__ElectronContainer_egamma_ElectronsAuxDyn.charge"]
324
325
326 StaticContent += ["xAOD::VertexContainer#%s" % BPHY18DiElectronSelectAndWrite.OutputVtxContainerName]
327 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY18DiElectronSelectAndWrite.OutputVtxContainerName]
328
329 StaticContent += ["xAOD::VertexContainer#%s" % BPHY18BeeKstSelectAndWrite.OutputVtxContainerName]
330 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY18BeeKstSelectAndWrite.OutputVtxContainerName]
331
332 StaticContent += ["xAOD::VertexContainer#%s" % BPHY18_diMeson_revertex.OutputVtxContainerName]
333 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY18_diMeson_revertex.OutputVtxContainerName]
334
335 AllVariables += [ "GSFTrackParticles"]
336
337
338 # Truth information for MC only
339 if isSimulation:
340 AllVariables += ["TruthEvents","TruthParticles","TruthVertices", "ElectronTruthParticles"]
341
342 AllVariables = list(set(AllVariables)) # remove duplicates
343
344 BPHY18SlimmingHelper.AllVariables = AllVariables
345 BPHY18SlimmingHelper.ExtraVariables = ExtraVariables
346
347 BPHY18SlimmingHelper.StaticContent = StaticContent
348
349 from DerivationFrameworkEGamma.ElectronsCPDetailedContent import ElectronsCPDetailedContent, GSFTracksCPDetailedContent
350 BPHY18SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
351 BPHY18SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
352
353 BPHY18ItemList = BPHY18SlimmingHelper.GetItemList()
354 acc.merge(OutputStreamCfg(flags, "DAOD_BPHY18", ItemList=BPHY18ItemList, AcceptAlgs=["BPHY18Kernel"]))
355 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY18", AcceptAlgs=["BPHY18Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
356 acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True)
357 return acc
STL class.
BPHY18Cfg(flags)
Definition BPHY18.py:14