ATLAS Offline Software
Loading...
Searching...
No Matches
BPHY12.py
Go to the documentation of this file.
1# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3#====================================================================
4# BPHY12.py
5#====================================================================
6
7
8from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9from AthenaConfiguration.ComponentFactory import CompFactory
10from AthenaConfiguration.Enums import MetadataCategory
11
12
13BPHYDerivationName = "BPHY12"
14streamName = "StreamDAOD_BPHY12"
15#====================================================================
16# FLAGS TO PERSONALIZE THE DERIVATION
17#====================================================================
18
19skimTruth = False
20
21def BPHY12Cfg(flags):
22 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
23 from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
24 acc = ComponentAccumulator()
25 isSimulation = flags.Input.isMC
26
27 V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, BPHYDerivationName))
28 vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName)) # VKalVrt vertex fitter
29 acc.addPublicTool(vkalvrt)
30 acc.addPublicTool(V0Tools)
31 trackselect = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, BPHYDerivationName))
32 acc.addPublicTool(trackselect)
33 vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, BPHYDerivationName))
34 acc.addPublicTool(vpest)
35 BPHY12_Finder_DiMuon = CompFactory.Analysis.JpsiFinder(
36 name = "BPHY12_Finder_DiMuon",
37 muAndMu = True,
38 muAndTrack = False,
39 TrackAndTrack = False,
40 assumeDiMuons = True,
41 muonThresholdPt = 3000.,
42 higherPt = 3500.,
43 invMassUpper = 7000.,
44 invMassLower = 1.,
45 Chi2Cut = 30.,
46 oppChargesOnly = False,
47 allChargeCombinations = True,
48 atLeastOneComb = True,
49 useCombinedMeasurement = False,
50 muonCollectionKey = "Muons",
51 TrackParticleCollection = "InDetTrackParticles",
52 V0VertexFitterTool = None,
53 useV0Fitter = False,
54 TrkVertexFitterTool = vkalvrt,
55 TrackSelectorTool = trackselect,
56 VertexPointEstimator = vpest,
57 useMCPCuts = False )
58
59 extraTools = [BPHY12_Finder_DiMuon]
60
61
62
63 BPHY12_SelectAndWrite_DiMuon = CompFactory.DerivationFramework.Reco_Vertex(
64 name = "BPHY12_SelectAndWrite_DiMuon",
65 VertexSearchTool = BPHY12_Finder_DiMuon,
66 OutputVtxContainerName = "BPHY12_DiMuon_Candidates",
67 PVContainerName = "PrimaryVertices",
68 V0Tools = V0Tools,
69 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
70 RefPVContainerName = "SHOULDNOTBEUSED",
71 DoVertexType = 7)
72
73 BPHY12_Select_DiMuons = CompFactory.DerivationFramework.Select_onia2mumu(
74 name = "BPHY12_Select_DiMuons",
75 HypothesisName = "Jpsi",
76 V0Tools = V0Tools,
77 InputVtxContainerName = "BPHY12_DiMuon_Candidates",
78 VtxMassHypo = 3096.916,
79 MassMax = 10000.,
80 MassMin = 0.,
81 Chi2Max = 1000.,
82 DoVertexType = 7
83 )
84
85 BPHY12_Finder_BdKstarKpiMuMu = CompFactory.Analysis.JpsiPlus2Tracks(
86 name = "BPHY12_Finder_BdKstarKpiMuMu",
87 kaonkaonHypothesis = False,
88 pionpionHypothesis = False,
89 kaonpionHypothesis = True,
90 oppChargesOnly = False,
91 SameChargesOnly = False,
92 trkThresholdPt = 500.0,
93 trkMaxEta = 3.0,
94 DiTrackMassUpper = 1110.,
95 DiTrackMassLower = 690.,
96 DiTrackPt = 500.,
97 FinalDiTrackPt = 500.,
98 TrkQuadrupletMassUpper = 10000.0,
99 TrkQuadrupletMassLower = 1000.0,
100 BMassUpper = 6500.0,
101 BMassLower = 3000.0,
102 BThresholdPt = 1000.,
103 Chi2Cut = 30./5.,
104 JpsiContainerKey = "BPHY12_DiMuon_Candidates",
105 TrackParticleCollection = "InDetTrackParticles",
106 ExcludeCrossJpsiTracks = False, #setting this to False rejects the muons from J/psi candidate
107 TrkVertexFitterTool = vkalvrt,
108 TrackSelectorTool = trackselect,
109 UseMassConstraint = False,
110 CandidateLimit = 5000
111 )
112
113 BPHY12_SelectAndWrite_BdKstarKpiMuMu = CompFactory.DerivationFramework.Reco_Vertex(
114 name = "BPHY12_SelectAndWrite_BdKstarKpiMuMu",
115 VertexSearchTool = BPHY12_Finder_BdKstarKpiMuMu,
116 OutputVtxContainerName = "BPHY12_BdKstarKpiMuMu_Candidates",
117 PVContainerName = "PrimaryVertices",
118 RefPVContainerName = "BPHY12_BdKstarKpiMuMu_refitPV",
119 V0Tools = V0Tools,
120 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
121 RefitPV = True,
122 MaxPVrefit = 10000,
123 DoVertexType = 7
124 )
125
126 BPHY12_Select_BdKstarKpiMuMu = CompFactory.DerivationFramework.Select_onia2mumu(
127 name = "BPHY12_Select_BdKstarKpiMuMu",
128 V0Tools = V0Tools,
129 HypothesisName = "Bd",
130 InputVtxContainerName = "BPHY12_BdKstarKpiMuMu_Candidates",
131 TrkMasses = [105.658, 105.658, 493.677, 139.570],
132 VtxMassHypo = 5279.6,
133 MassMax = 10000.,
134 MassMin = 0.,
135 Chi2Max = 1000.)
136
137 BPHY12_Select_BdKstarKpiMuMu_anti = CompFactory.DerivationFramework.Select_onia2mumu(
138 name = "BPHY12_Select_BdKstarKpiMuMu_anti",
139 V0Tools = V0Tools,
140 HypothesisName = "Bdbar",
141 InputVtxContainerName = "BPHY12_BdKstarKpiMuMu_Candidates",
142 TrkMasses = [105.658, 105.658, 139.570, 493.677],
143 VtxMassHypo = 5279.6,
144 MassMax = 10000.,
145 MassMin = 0.,
146 Chi2Max = 1000.)
147
148 BPHY12_ReVertex_Kstar = CompFactory.DerivationFramework.ReVertex(
149 name = "BPHY12_ReVertex_Kstar",
150 InputVtxContainerName = "BPHY12_BdKstarKpiMuMu_Candidates",
151 V0Tools = V0Tools,
152 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
153 TrackIndices = [ 2, 3 ],
154 TrkVertexFitterTool = vkalvrt,
155 OutputVtxContainerName = "BPHY12_Kstar_ReVertexCandidates"
156 )
157
158 BPHY12_Select_KstarKpi = CompFactory.DerivationFramework.Select_onia2mumu(
159 name = "BPHY12_Select_KstarKpi",
160 HypothesisName = "Kstar",
161 InputVtxContainerName = "BPHY12_Kstar_ReVertexCandidates",
162 V0Tools = V0Tools,
163 TrkMasses = [ 493.677, 139.570 ],
164 VtxMassHypo = 891.66,
165 MassMin = 0.,
166 MassMax = 10000.,
167 Chi2Max = 1000.
168 )
169
170 BPHY12_Select_KstarKpi_anti = CompFactory.DerivationFramework.Select_onia2mumu(
171 name = "BPHY12_Select_KstarKpi_anti",
172 HypothesisName = "Kstarbar",
173 InputVtxContainerName = "BPHY12_Kstar_ReVertexCandidates",
174 V0Tools = V0Tools,
175 TrkMasses = [ 139.570, 493.677 ],
176 VtxMassHypo = 891.66,
177 MassMin = 0.,
178 MassMax = 10000.,
179 Chi2Max = 1000.
180 )
181
182
183 BPHY12_SelectBmumuKstEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(
184 name = "BPHY12_SelectBmumuKstEvent",
185 expression = "(count(BPHY12_BdKstarKpiMuMu_Candidates.passed_Bd > 0) + count(BPHY12_BdKstarKpiMuMu_Candidates.passed_Bdbar > 0)) > 0")
186
187 extraTools += [BPHY12_SelectBmumuKstEvent]
188
189 if skimTruth or not isSimulation: #Only Skim Data
190 filterlist = [BPHY12_SelectBmumuKstEvent]
191 for t in filterlist : acc.addPublicTool(t)
192 #====================================================================
193 # Make event selection based on an OR of the input skimming tools (though it seems we only have one here!)
194 #====================================================================
195 BPHY12SkimmingOR = CompFactory.DerivationFramework.FilterCombinationOR(
196 name = "BPHY12SkimmingOR",
197 FilterList = filterlist) #OR of all your different filters
198
199 BPHY12Thin_vtxTrk = CompFactory.DerivationFramework.Thin_vtxTrk(
200 name = "BPHY12Thin_vtxTrk",
201 TrackParticleContainerName = "InDetTrackParticles",
202 StreamName = streamName,
203 VertexContainerNames = ["BPHY12_BdKstarKpiMuMu_Candidates"],
204 PassFlags = ["passed_Bd", "passed_Bdbar"] )
205
206 BPHY12MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(name = "BPHY12MuonTPThinningTool",
207 StreamName = streamName,
208 MuonKey = "Muons",
209 InDetTrackParticlesKey = "InDetTrackParticles")
210
211 BPHY12_thinningTool_PV = CompFactory.DerivationFramework.BPhysPVThinningTool(
212 name = "BPHY12_thinningTool_PV",
213 StreamName = streamName,
214 CandidateCollections = ["BPHY12_BdKstarKpiMuMu_Candidates"],
215 KeepPVTracks = True
216 )
217
218 BPHY12TruthThinTool = CompFactory.DerivationFramework.GenericTruthThinning(name = "BPHY12TruthThinTool",
219 ParticleSelectionString = "TruthParticles.pdgId == 511 || TruthParticles.pdgId == -511 || TruthParticles.pdgId == 531 || TruthParticles.pdgId == -531",
220 PreserveDescendants = True,
221 PreserveAncestors = True)
222
223 BPHY12ThinningTools = [BPHY12Thin_vtxTrk, BPHY12_thinningTool_PV, BPHY12MuonTPThinningTool]
224 if isSimulation:
225 BPHY12ThinningTools.append(BPHY12TruthThinTool)
226
227 augTools = [BPHY12_SelectAndWrite_DiMuon, BPHY12_Select_DiMuons,
228 BPHY12_SelectAndWrite_BdKstarKpiMuMu, BPHY12_Select_BdKstarKpiMuMu, BPHY12_Select_BdKstarKpiMuMu_anti,
229 BPHY12_ReVertex_Kstar, BPHY12_Select_KstarKpi, BPHY12_Select_KstarKpi_anti]
230 skimTools = [BPHY12SkimmingOR] if skimTruth or not isSimulation else []
231
232
233 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(
234 "BPHY12Kernel",
235 AugmentationTools = augTools,
236 SkimmingTools = skimTools,
237 ThinningTools = BPHY12ThinningTools
238 ))
239
240 for t in augTools + skimTools + BPHY12ThinningTools + extraTools: acc.addPublicTool(t)
241 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
242 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
243 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
244 BPHY12SlimmingHelper = SlimmingHelper("BPHY12SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
245 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
246 AllVariables = getDefaultAllVariables()
247 StaticContent = []
248
249 # Needed for trigger objects
250 BPHY12SlimmingHelper.IncludeMuonTriggerContent = True
251 BPHY12SlimmingHelper.IncludeBPhysTriggerContent = True
252
253
254 AllVariables += ["PrimaryVertices"]
255 StaticContent += ["xAOD::VertexContainer#BPHY12_BdKstarKpiMuMu_refitPV"]
256 StaticContent += ["xAOD::VertexAuxContainer#BPHY12_BdKstarKpiMuMu_refitPVAux."]
257
258
259 AllVariables += ["InDetTrackParticles"]
260
261
264 AllVariables += ["CombinedMuonTrackParticles"]
265 AllVariables += ["ExtrapolatedMuonTrackParticles"]
266
267
268 AllVariables += ["Muons"]
269
270
271 StaticContent += ["xAOD::VertexContainer#%s" % BPHY12_SelectAndWrite_DiMuon.OutputVtxContainerName]
272 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY12_SelectAndWrite_DiMuon.OutputVtxContainerName]
273 StaticContent += ["xAOD::VertexContainer#%s" % BPHY12_SelectAndWrite_BdKstarKpiMuMu.OutputVtxContainerName]
274 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY12_SelectAndWrite_BdKstarKpiMuMu.OutputVtxContainerName]
275 StaticContent += ["xAOD::VertexContainer#%s" % BPHY12_ReVertex_Kstar.OutputVtxContainerName]
276 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY12_ReVertex_Kstar.OutputVtxContainerName]
277
278 # Added by ASC
279 # Truth information for MC only
280 if isSimulation:
281 AllVariables += ["TruthEvents","TruthParticles","TruthVertices","MuonTruthParticles"]
282
283 BPHY12SlimmingHelper.AllVariables = AllVariables
284 BPHY12SlimmingHelper.StaticContent = StaticContent
285 BPHY12ItemList = BPHY12SlimmingHelper.GetItemList()
286 acc.merge(OutputStreamCfg(flags, "DAOD_BPHY12", ItemList=BPHY12ItemList, AcceptAlgs=["BPHY12Kernel"]))
287 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY12", AcceptAlgs=["BPHY12Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
288 acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True)
289 return acc
BPHY12Cfg(flags)
Definition BPHY12.py:21