ATLAS Offline Software
Loading...
Searching...
No Matches
BPHY2.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#====================================================================
4# BPHY2.py
5#====================================================================
6
7from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8from AthenaConfiguration.ComponentFactory import CompFactory
9from AthenaConfiguration.Enums import MetadataCategory
10
11BPHYDerivationName = "BPHY2"
12streamName = "StreamDAOD_BPHY2"
13
14
15def BPHY2Cfg(flags):
16 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (
17 BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg,
18 BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg,
19 AugOriginalCountsCfg)
20 from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
21 acc = ComponentAccumulator()
22 isSimulation = flags.Input.isMC
23
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 BPHY2JpsiFinder = CompFactory.Analysis.JpsiFinder(name = "BPHY2JpsiFinder",
33 muAndMu = True,
34 muAndTrack = False,
35 TrackAndTrack = False,
36 assumeDiMuons = True,
37 invMassUpper = 4700.0,
38 invMassLower = 2600.0,
39 Chi2Cut = 15.,
40 oppChargesOnly = True,
41 combOnly = True,
42 atLeastOneComb = False,
43 useCombinedMeasurement = False, # Only takes effect if combOnly=True
44 muonCollectionKey = "Muons",
45 TrackParticleCollection = "InDetTrackParticles",
46 V0VertexFitterTool = None, # V0 vertex fitter
47 useV0Fitter = False, # if False a TrkVertexFitterTool will be used
48 TrkVertexFitterTool = vkalvrt, # VKalVrt vertex fitter
49 TrackSelectorTool = trackselect,
50 VertexPointEstimator = vpest,
51 useMCPCuts = False)
52
53 BPHY2JpsiSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(name = "BPHY2JpsiSelectAndWrite",
54 VertexSearchTool = BPHY2JpsiFinder,
55 OutputVtxContainerName = "BPHY2JpsiCandidates",
56 PVContainerName = "PrimaryVertices",
57 RefPVContainerName = "SHOULDNOTBEUSED",
58 V0Tools = V0Tools,
59 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
60 DoVertexType =1)
61
62 BPHY2BsJpsiKK = CompFactory.Analysis.JpsiPlus2Tracks(name = "BPHY2BsJpsiKK",
63 kaonkaonHypothesis = True,
64 pionpionHypothesis = False,
65 kaonpionHypothesis = False,
66 trkThresholdPt = 800.0,
67 trkMaxEta = 3.0,
68 BMassUpper = 5800.0,
69 BMassLower = 5000.0,
70 DiTrackMassUpper = 1019.445 + 100.,
71 DiTrackMassLower = 1019.445 - 100.,
72 Chi2Cut = 8.0,
73 TrkQuadrupletMassUpper = 6000.0,
74 TrkQuadrupletMassLower = 4800.0,
75 JpsiContainerKey = "BPHY2JpsiCandidates",
76 TrackParticleCollection = "InDetTrackParticles",
77 MuonsUsedInJpsi = "Muons",
78 TrkVertexFitterTool = vkalvrt,
79 TrackSelectorTool = trackselect,
80 UseMassConstraint = False)
81
82 BPHY2BsKKSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(name = "BPHY2BsKKSelectAndWrite",
83 VertexSearchTool = BPHY2BsJpsiKK,
84 OutputVtxContainerName = "BPHY2BsJpsiKKCandidates",
85 PVContainerName = "PrimaryVertices",
86 RefPVContainerName = "BPHY2RefittedPrimaryVertices",
87 RefitPV = True,
88 V0Tools = V0Tools,
89 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
90 MaxPVrefit = 10000, DoVertexType = 7)
91
92 BPHY2_Select_Psi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
93 name = "BPHY2_Select_Psi2mumu",
94 HypothesisName = "Psi",
95 InputVtxContainerName = "BPHY2JpsiCandidates",
96 V0Tools = V0Tools,
97 VtxMassHypo = 3686.09,
98 MassMin = 3300.0,
99 MassMax = 4500.0,
100 Chi2Max = 200,
101 DoVertexType = 7)
102
103 BPHY2_Select_Jpsi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
104 name = "BPHY2_Select_Jpsi2mumu",
105 HypothesisName = "Jpsi",
106 InputVtxContainerName = "BPHY2JpsiCandidates",
107 V0Tools = V0Tools,
108 VtxMassHypo = 3096.916,
109 MassMin = 2000.0,
110 MassMax = 3600.0,
111 Chi2Max = 200,
112 DoVertexType = 7)
113
114 BPHY2_Select_Bs2JpsiKK = CompFactory.DerivationFramework.Select_onia2mumu(
115 name = "BPHY2_Select_Bs2JpsiKK",
116 HypothesisName = "Bs",
117 InputVtxContainerName = "BPHY2BsJpsiKKCandidates",
118 V0Tools = V0Tools,
119 TrkMasses = [105.658, 105.658, 493.677, 493.677],
120 VtxMassHypo = 5366.3,
121 MassMin = 5000.0,
122 MassMax = 5800.0,
123 Chi2Max = 200)
124
125 BPHY2_AugOriginalCounts = acc.popToolsAndMerge(
126 AugOriginalCountsCfg(flags, name = "BPHY2_AugOriginalCounts"))
127
128 #Thinning tools
129
130 BPHY2_thinningTool_Tracks = CompFactory.DerivationFramework.Thin_vtxTrk(
131 name = "BPHY2_thinningTool_Tracks",
132 TrackParticleContainerName = "InDetTrackParticles",
133 StreamName = streamName,
134 VertexContainerNames = ["BPHY2BsJpsiKKCandidates"],
135 PassFlags = ["passed_Bs"] )
136
137
138 BPHY2_thinningTool_TracksPsi = CompFactory.DerivationFramework.Thin_vtxTrk(
139 name = "BPHY2_thinningTool_TracksPsi",
140 TrackParticleContainerName = "InDetTrackParticles",
141 StreamName = streamName,
142 VertexContainerNames = ["BPHY2JpsiCandidates"],
143 PassFlags = ["passed_Psi", "passed_Jpsi"] )
144
145 BPHY2_thinningTool_PV = CompFactory.DerivationFramework.BPhysPVThinningTool(
146 name = "BPHY2_thinningTool_PV",
147 CandidateCollections = ["BPHY2BsJpsiKKCandidates"],
148 StreamName = streamName,
149 KeepPVTracks =True)
150
151 BPHY2MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(name = "BPHY2MuonTPThinningTool",
152 MuonKey = "Muons",
153 StreamName = streamName,
154 InDetTrackParticlesKey = "InDetTrackParticles")
155
156 if not isSimulation: #Only Skim Data
157 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
158 xAODStringSkimmingToolCfg)
159 BPHY2_SelectBsJpsiKKEvent = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
160 flags, name = "BPHY2_SelectBsJpsiKKEvent",
161 expression = "count(BPHY2BsJpsiKKCandidates.passed_Bs > 0) > 0"))
162
163 #====================================================================
164 # Make event selection based on an OR of the input skimming tools
165 #====================================================================
166 BPHY2SkimmingOR = CompFactory.DerivationFramework.FilterCombinationOR(
167 "BPHY2SkimmingOR",
168 FilterList = [BPHY2_SelectBsJpsiKKEvent ])
169 acc.addPublicTool(BPHY2SkimmingOR)
170
171
172 thiningCollection = [BPHY2_thinningTool_Tracks, BPHY2_thinningTool_TracksPsi, BPHY2_thinningTool_PV, BPHY2MuonTPThinningTool]
173 augCollection = [BPHY2JpsiSelectAndWrite, BPHY2BsKKSelectAndWrite,
174 BPHY2_Select_Psi2mumu, BPHY2_Select_Jpsi2mumu,
175 BPHY2_Select_Bs2JpsiKK, BPHY2_AugOriginalCounts]
176 for t in augCollection + thiningCollection : acc.addPublicTool(t)
177
178 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY2Kernel",
179 AugmentationTools = augCollection,
180 #Only skim if not MC
181 SkimmingTools = [BPHY2SkimmingOR] if not isSimulation else [],
182 ThinningTools = thiningCollection))
183
184 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
185 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
186 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
187 BPHY2SlimmingHelper = SlimmingHelper("BPHY2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
188 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
189 AllVariables = getDefaultAllVariables()
190 StaticContent = []
191
192 # Needed for trigger objects
193 BPHY2SlimmingHelper.IncludeMuonTriggerContent = True
194 BPHY2SlimmingHelper.IncludeBPhysTriggerContent = True
195 SmartVar = []
196
197 SmartVar += ["PrimaryVertices"]
198 StaticContent += ["xAOD::VertexContainer#BPHY2RefittedPrimaryVertices"]
199 StaticContent += ["xAOD::VertexAuxContainer#BPHY2RefittedPrimaryVerticesAux."]
200
201
202 AllVariables += ["InDetTrackParticles"]
203
204
207 AllVariables += ["CombinedMuonTrackParticles"]
208
209
210 SmartVar += ["Muons"]
211
212
213 StaticContent += ["xAOD::VertexContainer#%s" % BPHY2JpsiSelectAndWrite.OutputVtxContainerName]
214
215 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY2JpsiSelectAndWrite.OutputVtxContainerName]
216
217 StaticContent += ["xAOD::VertexContainer#%s" % BPHY2BsKKSelectAndWrite.OutputVtxContainerName]
218 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY2BsKKSelectAndWrite.OutputVtxContainerName]
219
220 # Tagging information (in addition to that already requested by usual algorithms)
221 AllVariables += ["MuonSpectrometerTrackParticles" ]
222
223 # Truth information for MC only
224 if isSimulation:
225 AllVariables += ["TruthEvents","TruthParticles","TruthVertices","MuonTruthParticles" ]
226
227 BPHY2SlimmingHelper.AllVariables = AllVariables
228 BPHY2SlimmingHelper.StaticContent = StaticContent
229 BPHY2SlimmingHelper.SmartCollections = SmartVar
230 BPHY2ItemList = BPHY2SlimmingHelper.GetItemList()
231 acc.merge(OutputStreamCfg(flags, "DAOD_BPHY2", ItemList=BPHY2ItemList, AcceptAlgs=["BPHY2Kernel"]))
232 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY2", AcceptAlgs=["BPHY2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
233 acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True)
234 return acc
235
BPHY2Cfg(flags)
Definition BPHY2.py:15