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 if not isSimulation: #Only Skim Data
156 BPHY2_SelectBsJpsiKKEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(
157 name = "BPHY2_SelectBsJpsiKKEvent",
158 expression = "count(BPHY2BsJpsiKKCandidates.passed_Bs > 0) > 0")
159
160 #====================================================================
161 # Make event selection based on an OR of the input skimming tools
162 #====================================================================
163 BPHY2SkimmingOR = CompFactory.DerivationFramework.FilterCombinationOR("BPHY2SkimmingOR",
164 FilterList = [BPHY2_SelectBsJpsiKKEvent ])
165 acc.addPublicTool(BPHY2SkimmingOR)
166
167
168 thiningCollection = [BPHY2_thinningTool_Tracks, BPHY2_thinningTool_TracksPsi, BPHY2_thinningTool_PV, BPHY2MuonTPThinningTool]
169 augCollection = [BPHY2JpsiSelectAndWrite, BPHY2BsKKSelectAndWrite,
170 BPHY2_Select_Psi2mumu, BPHY2_Select_Jpsi2mumu,
171 BPHY2_Select_Bs2JpsiKK, BPHY2_AugOriginalCounts]
172 for t in augCollection + thiningCollection : acc.addPublicTool(t)
173
174 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY2Kernel",
175 AugmentationTools = augCollection,
176 #Only skim if not MC
177 SkimmingTools = [BPHY2SkimmingOR] if not isSimulation else [],
178 ThinningTools = thiningCollection))
179
180 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
181 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
182 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
183 BPHY2SlimmingHelper = SlimmingHelper("BPHY2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
184 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
185 AllVariables = getDefaultAllVariables()
186 StaticContent = []
187
188 # Needed for trigger objects
189 BPHY2SlimmingHelper.IncludeMuonTriggerContent = True
190 BPHY2SlimmingHelper.IncludeBPhysTriggerContent = True
191 SmartVar = []
192
193 SmartVar += ["PrimaryVertices"]
194 StaticContent += ["xAOD::VertexContainer#BPHY2RefittedPrimaryVertices"]
195 StaticContent += ["xAOD::VertexAuxContainer#BPHY2RefittedPrimaryVerticesAux."]
196
197
198 AllVariables += ["InDetTrackParticles"]
199
200
203 AllVariables += ["CombinedMuonTrackParticles"]
204
205
206 SmartVar += ["Muons"]
207
208
209 StaticContent += ["xAOD::VertexContainer#%s" % BPHY2JpsiSelectAndWrite.OutputVtxContainerName]
210
211 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY2JpsiSelectAndWrite.OutputVtxContainerName]
212
213 StaticContent += ["xAOD::VertexContainer#%s" % BPHY2BsKKSelectAndWrite.OutputVtxContainerName]
214 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY2BsKKSelectAndWrite.OutputVtxContainerName]
215
216 # Tagging information (in addition to that already requested by usual algorithms)
217 AllVariables += ["MuonSpectrometerTrackParticles" ]
218
219 # Truth information for MC only
220 if isSimulation:
221 AllVariables += ["TruthEvents","TruthParticles","TruthVertices","MuonTruthParticles" ]
222
223 BPHY2SlimmingHelper.AllVariables = AllVariables
224 BPHY2SlimmingHelper.StaticContent = StaticContent
225 BPHY2SlimmingHelper.SmartCollections = SmartVar
226 BPHY2ItemList = BPHY2SlimmingHelper.GetItemList()
227 acc.merge(OutputStreamCfg(flags, "DAOD_BPHY2", ItemList=BPHY2ItemList, AcceptAlgs=["BPHY2Kernel"]))
228 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY2", AcceptAlgs=["BPHY2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
229 acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True)
230 return acc
231
BPHY2Cfg(flags)
Definition BPHY2.py:15