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