ATLAS Offline Software
Loading...
Searching...
No Matches
BPHY28.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#====================================================================
4# BPHY28.py
5#====================================================================
6
7from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8from AthenaConfiguration.ComponentFactory import CompFactory
9from AthenaConfiguration.Enums import MetadataCategory
10
11
12BPHYDerivationName = "BPHY28"
13streamName = "StreamDAOD_BPHY28"
14
15MuMuContainerName = "BPHY28MuMuCandidates"
16BsPhiMuMuContainerName = "BPHY28BsKKMuMuCandidates"
17
18
19def BPHY28Kernel(flags):
20
21 # Lists for better code organization
22 augList = [] # List of active augmentation tools
23 skimList = [] # List of active skimming algorithms
24 thinList = [] # List of active thinning algorithms
25 thinTrkVtxList = [] # List of reconstructed candidates to use for the thinning of tracks from vertices
26
27
28 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (
29 BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg,
30 BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg,
31 AugOriginalCountsCfg)
32 from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
33 acc = ComponentAccumulator()
34 isSimulation = flags.Input.isMC
35 V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, BPHYDerivationName))
36 vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName)) # VKalVrt vertex fitter
37 acc.addPublicTool(vkalvrt)
38 acc.addPublicTool(V0Tools)
39 trackselect = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, BPHYDerivationName))
40 acc.addPublicTool(trackselect)
41 vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, BPHYDerivationName))
42 acc.addPublicTool(vpest)
43 PVrefit = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags))
44 acc.addPublicTool(PVrefit)
45
46 # LRT
47 doLRT = flags.Tracking.doLargeD0
48 if not doLRT : print("BPHY28: LRT tracks disabled")
49 mainMuonInput = "StdWithLRTMuons" if doLRT else "Muons"
50 mainIDInput = "InDetWithLRTTrackParticles" if doLRT else "InDetTrackParticles"
51 if doLRT:
52 from DerivationFrameworkLLP.LLPToolsConfig import LRTMuonMergerAlg
53 from AthenaConfiguration.Enums import LHCPeriod
54 acc.merge(LRTMuonMergerAlg( flags,
55 PromptMuonLocation = "Muons",
56 LRTMuonLocation = "MuonsLRT",
57 OutputMuonLocation = mainMuonInput,
58 CreateViewCollection = True,
59 UseRun3WP = flags.GeoModel.Run == LHCPeriod.Run3))
60 from DerivationFrameworkInDet.InDetToolsConfig import InDetLRTMergeCfg
61 acc.merge(InDetLRTMergeCfg(flags))
62 toRelink = ["InDetTrackParticles", "InDetLargeD0TrackParticles"] if doLRT else []
63 MuonReLink = [ "Muons", "MuonsLRT" ] if doLRT else []
64
65 BPHY28_AugOriginalCounts = acc.popToolsAndMerge(
66 AugOriginalCountsCfg(flags, name = "BPHY28_AugOriginalCounts"))
67 augList += [ BPHY28_AugOriginalCounts ]
68
69 BPHY28MuMuFinder = CompFactory.Analysis.JpsiFinder(
70 name = "BPHY28MuMuFinder",
71 muAndMu = True,
72 muAndTrack = False,
73 TrackAndTrack = False,
74 assumeDiMuons = True,
75 invMassUpper = 100000.0,
76 invMassLower = 0.0,
77 Chi2Cut = 100.,
78 oppChargesOnly = True,
79 combOnly = True,
80 atLeastOneComb = False,
81 useCombinedMeasurement = False, # Only takes effect if combOnly=True
82 muonCollectionKey = mainMuonInput,
83 TrackParticleCollection = mainIDInput,
84 TrkVertexFitterTool = vkalvrt,
85 TrackSelectorTool = trackselect,
86 VertexPointEstimator = vpest,
87 useMCPCuts = False )
88
89 BPHY28MuMuSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(name = "BPHY28MuMuSelectAndWrite",
90 VertexSearchTool = BPHY28MuMuFinder,
91 OutputVtxContainerName = MuMuContainerName,
92 PVContainerName = "PrimaryVertices",
93 V0Tools = V0Tools,
94 PVRefitter = PVrefit,
95 RefPVContainerName = "SHOULDNOTBEUSED",
96 RelinkTracks = toRelink,
97 RelinkMuons = MuonReLink,
98 DoVertexType = 7)
99 augList += [ BPHY28MuMuSelectAndWrite ]
100 thinTrkVtxList += [ MuMuContainerName ]
101
102
103 BPHY28_Select_Jpsi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
104 name = "BPHY28_Select_Jpsi2mumu",
105 HypothesisName = "Jpsi",
106 InputVtxContainerName = MuMuContainerName,
107 V0Tools = V0Tools,
108 VtxMassHypo = 3096.916,
109 MassMin = 2000.0,
110 MassMax = 3600.0,
111 Chi2Max = 100, Do3d = False,
112 DoVertexType = 7)
113 augList += [ BPHY28_Select_Jpsi2mumu ]
114
115
116 BPHY28BsKKMuMu = CompFactory.Analysis.JpsiPlus2Tracks(name = "BPHY28BsKKMuMu",
117 kaonkaonHypothesis = True,
118 pionpionHypothesis = False,
119 kaonpionHypothesis = False,
120 trkThresholdPt = 500.0,
121 trkMaxEta = 3.0,
122 BMassUpper = 5900.0,
123 BMassLower = 4900.0,
124 DiTrackMassUpper = 1220,
125 DiTrackMassLower = 820,
126 Chi2Cut = 100.0, # this is chi2/ndf cut
127 TrkQuadrupletMassUpper = 6000.0,
128 TrkQuadrupletMassLower = 4800.0,
129 JpsiContainerKey = MuMuContainerName,
130 TrackParticleCollection = mainIDInput,
131 MuonsUsedInJpsi = mainMuonInput,
132 TrkVertexFitterTool = vkalvrt,
133 TrackSelectorTool = trackselect,
134 UseMassConstraint = False)
135
136
137 BPHY28BsKKSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(name = "BPHY28BsKKSelectAndWrite",
138 VertexSearchTool = BPHY28BsKKMuMu,
139 OutputVtxContainerName = BsPhiMuMuContainerName,
140 PVContainerName = "PrimaryVertices",
141 V0Tools = V0Tools,
142 PVRefitter = PVrefit,
143 RefPVContainerName = "BPHY28RefittedPrimaryVertices",
144 RefitPV = True, Do3d = False,
145 RelinkTracks = toRelink,
146 MaxPVrefit = 10000, DoVertexType = 7)
147 augList += [ BPHY28BsKKSelectAndWrite ]
148 thinTrkVtxList += [ BsPhiMuMuContainerName ]
149
150
151 BPHY28_Select_Bs2KKMuMu = CompFactory.DerivationFramework.Select_onia2mumu(
152 name = "BPHY28_Select_Bs2KKMuMu",
153 HypothesisName = "Bs",
154 InputVtxContainerName = BsPhiMuMuContainerName,
155 V0Tools = V0Tools,
156 TrkMasses = [105.658, 105.658, 493.677, 493.677],
157 VtxMassHypo = 5366.3,
158 MassMin = 4900.0,
159 MassMax = 5900.0, Do3d = False,
160 Chi2Max = 100)
161 augList += [ BPHY28_Select_Bs2KKMuMu ]
162
163
164 if not isSimulation: #Only Skim Data
165 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
166 xAODStringSkimmingToolCfg)
167 BPHY28_SelectBsKKMuMuEvent = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
168 flags, name = "BPHY28_SelectBsKKMuMuEvent",
169 expression = "count(BPHY28BsKKMuMuCandidates.passed_Bs) > 0"))
170 skimList += [ BPHY28_SelectBsKKMuMuEvent ]
171
172
173
175 BPHY28_Thin_VtxTracks = CompFactory.DerivationFramework.Thin_vtxTrk( name = "BPHY28_Thin_VtxTracks",
176 StreamName = streamName,
177 TrackParticleContainerName = "InDetTrackParticles",
178 VertexContainerNames = thinTrkVtxList,
179 IgnoreFlags = True )
180 thinList += [ BPHY28_Thin_VtxTracks ]
181
182 # LRT ID tracks
183 if doLRT:
184 BPHY28_Thin_VtxTracks_LRT = CompFactory.DerivationFramework.Thin_vtxTrk( name = "BPHY28_Thin_VtxTracks_LRT",
185 StreamName = streamName,
186 TrackParticleContainerName = "InDetLargeD0TrackParticles",
187 VertexContainerNames = thinTrkVtxList,
188 IgnoreFlags = True )
189 thinList += [ BPHY28_Thin_VtxTracks_LRT ]
190
191
192 for t in augList + skimList + thinList : acc.addPublicTool(t)
193 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY28Kernel",
194 AugmentationTools = augList,
195 #Only skim if not MC
196 SkimmingTools = skimList,
197 ThinningTools = thinList))
198
199 return acc
200
201
202def BPHY28Cfg(flags):
203 doLRT = flags.Tracking.doLargeD0
204 isSimulation = flags.Input.isMC
205 acc = BPHY28Kernel(flags)
206 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
207 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
208 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
209 BPHY28SlimmingHelper = SlimmingHelper("BPHY28SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
210 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
211 AllVariables = getDefaultAllVariables()
212 StaticContent = []
213
214 # Needed for trigger objects
215 BPHY28SlimmingHelper.IncludeMuonTriggerContent = True
216 BPHY28SlimmingHelper.IncludeBPhysTriggerContent = True
217
218
219 AllVariables += ["PrimaryVertices"]
220 StaticContent += ["xAOD::VertexContainer#BPHY28RefittedPrimaryVertices"]
221 StaticContent += ["xAOD::VertexAuxContainer#BPHY28RefittedPrimaryVerticesAux."]
222
223
224
225 AllVariables += ["InDetTrackParticles", "InDetLargeD0TrackParticles"] if doLRT else ["InDetTrackParticles"]
226
227
230 AllVariables += ["CombinedMuonTrackParticles"]
231 AllVariables += ["ExtrapolatedMuonTrackParticles"]
232
233
234 AllVariables += ["Muons", "MuonsLRT"] if doLRT else ["Muons"]
235
236
237
238 StaticContent += ["xAOD::VertexContainer#%s" % MuMuContainerName]
239
240 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % MuMuContainerName]
241
242 StaticContent += ["xAOD::VertexContainer#%s" % BsPhiMuMuContainerName]
243 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BsPhiMuMuContainerName]
244
245
246 # Tagging information (in addition to that already requested by usual algorithms)
247 AllVariables += [ "MuonSpectrometerTrackParticles" ]
248 SmartVar = ["Photons", "Electrons", "LRTElectrons"] if doLRT else ["Photons", "Electrons"] #[ tagJetCollections ]
249
250
251 # Truth information for MC only
252 if isSimulation:
253 AllVariables += ["TruthEvents","TruthParticles","TruthVertices","MuonTruthParticles", "egammaTruthParticles" ]
254
255
256 AllVariables = list(set(AllVariables)) # remove duplicates
257
258 BPHY28SlimmingHelper.AllVariables = AllVariables
259 BPHY28SlimmingHelper.StaticContent = StaticContent
260 BPHY28SlimmingHelper.SmartCollections = SmartVar
261 BPHY28ItemList = BPHY28SlimmingHelper.GetItemList()
262 acc.merge(OutputStreamCfg(flags, "DAOD_BPHY28", ItemList=BPHY28ItemList, AcceptAlgs=["BPHY28Kernel"]))
263 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY28", AcceptAlgs=["BPHY28Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
264 acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True)
265 return acc
void print(char *figname, TCanvas *c1)
STL class.
BPHY28Cfg(flags)
Definition BPHY28.py:202
BPHY28Kernel(flags)
Definition BPHY28.py:19