ATLAS Offline Software
BPHY22.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #====================================================================
4 # BPHY22.py
5 #====================================================================
6 
7 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.Enums import MetadataCategory
10 
11 
12 BPHYDerivationName = "BPHY22"
13 streamName = "StreamDAOD_BPHY22"
14 
15 def BPHY22Cfg(flags):
16  from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
17  from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
18  acc = ComponentAccumulator()
19  isSimulation = flags.Input.isMC
20  V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, BPHYDerivationName))
21  vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName)) # VKalVrt vertex fitter
22  acc.addPublicTool(vkalvrt)
23  acc.addPublicTool(V0Tools)
24  trackselect = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, BPHYDerivationName))
25  acc.addPublicTool(trackselect)
26  vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, BPHYDerivationName))
27  acc.addPublicTool(vpest)
28  PVrefit = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags))
29  acc.addPublicTool(PVrefit)
30  BPHY22_AugOriginalCounts = CompFactory.DerivationFramework.AugOriginalCounts(
31  name = "BPHY22_AugOriginalCounts",
32  VertexContainer = "PrimaryVertices",
33  TrackContainer = "InDetTrackParticles" )
34 
35  BPHY22MuPiFinder = CompFactory.Analysis.JpsiFinder(
36  name = "BPHY22MuPiFinder",
37  muAndMu = False,
38  muAndTrack = True, #need doTagAndProbe flag
39  TrackAndTrack = False,
40  assumeDiMuons = False,
41  muonThresholdPt = 2700,
42  trackThresholdPt = 250.0, # MeV
43  invMassUpper = 8200.0,
44  invMassLower = 200.0,
45  Chi2Cut = 10.,
46  oppChargesOnly = False,
47  allChargeCombinations = True,
48  atLeastOneComb = False, # True by default
49  useCombinedMeasurement = False, # Only takes effect if combOnly=True
50  muonCollectionKey = "Muons",
51  TrackParticleCollection = "InDetTrackParticles",
52  V0VertexFitterTool = None, # V0 vertex fitter
53  useV0Fitter = False, # if False a TrkVertexFitterTool will be used
54  TrkVertexFitterTool = vkalvrt, # VKalVrt vertex fitter
55  TrackSelectorTool = trackselect,
56  VertexPointEstimator = vpest,
57  useMCPCuts = False,
58  doTagAndProbe = True, #won't work with all/same charges combs
59  forceTagAndProbe = True) #force T&P to work with any charges combs
60 
61  BPHY22MuPiSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
62  name = "BPHY22MuPiSelectAndWrite",
63  VertexSearchTool = BPHY22MuPiFinder,
64  OutputVtxContainerName = "BPHY22MuPiCandidates",
65  V0Tools = V0Tools,
66  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
67  PVContainerName = "PrimaryVertices",
68  RefPVContainerName = "SHOULDNOTBEUSED")
69 
70 
71  BPHY22DiTrkFinder = CompFactory.Analysis.JpsiFinder(
72  name = "BPHY22DiTrkFinder",
73  muAndMu = False,
74  muAndTrack = False,
75  TrackAndTrack = True,
76  assumeDiMuons = False, # If true, will assume dimu hypothesis and use PDG value for mu mass
77  trackThresholdPt = 900,
78  invMassUpper = 2100.0,
79  invMassLower = 275,
80  Chi2Cut = 20., #chi2
81  oppChargesOnly = True,
82  atLeastOneComb = False,
83  useCombinedMeasurement = False, # Only takes effect if combOnly=True
84  muonCollectionKey = "Muons",
85  TrackParticleCollection = "InDetTrackParticles",
86  V0VertexFitterTool = None, # V0 vertex fitter
87  useV0Fitter = False, # if False a TrkVertexFitterTool will be used
88  TrkVertexFitterTool = vkalvrt, # VKalVrt vertex fitter
89  TrackSelectorTool = trackselect,
90  VertexPointEstimator = vpest,
91  useMCPCuts = False,
92  track1Mass = 139.571, # Not very important, only used to calculate inv. mass cut, leave it loose here
93  track2Mass = 139.571)
94 
95  BPHY22DiTrkSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
96  name = "BPHY22DiTrkSelectAndWrite",
97  VertexSearchTool = BPHY22DiTrkFinder,
98  OutputVtxContainerName = "BPHY22DiTrkCandidates",
99  PVContainerName = "PrimaryVertices",
100  V0Tools = V0Tools,
101  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
102  RefPVContainerName = "SHOULDNOTBEUSED",
103  CheckCollections = True,
104  CheckVertexContainers = ['BPHY22MuPiCandidates'])
105 
106 
107  BMuDstVertexFit = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName, CascadeCnstPrecision = 1e-6))
108 
109  BPHY22MuDpst = CompFactory.DerivationFramework.MuPlusDpstCascade(
110  name = "BPHY22MuDpst",
111  HypothesisName = "B",
112  TrkVertexFitterTool = BMuDstVertexFit,
113  DxHypothesis = 421, # MC PID for D0
114  ApplyD0MassConstraint = True,
115  MuPiMassLowerCut = 200.,
116  MuPiMassUpperCut = 8200.,
117  V0Tools = V0Tools,
118  PVRefitter = PVrefit,
119  D0MassLowerCut = 1864.83 - 200.,
120  D0MassUpperCut = 1864.83 + 200.,
121  DstMassLowerCut = 2010.26 - 300.,
122  DstMassUpperCut = 2010.26 + 300.,
123  DstMassUpperCutAft = 2010.26 + 25., #mass cut after cascade fit
124  MassLowerCut = 0.,
125  MassUpperCut = 12500.,
126  Chi2Cut = 5, #chi2/ndf
127  RefitPV = True,
128  RefPVContainerName = "BPHY22RefittedPrimaryVertices",
129  MuPiVertices = "BPHY22MuPiCandidates",
130  CascadeVertexCollections = ["BMuDpstCascadeSV2", "BMuDpstCascadeSV1"],
131  D0Vertices = "BPHY22DiTrkCandidates",
132  DoVertexType = 15 )
133 
134  BPHY22Dh3Finder = CompFactory.Analysis.JpsiPlus1Track(
135  name = "BPHY22Dh3Finder",
136  pionHypothesis = True, #false by default
137  kaonHypothesis = False, #true by default
138  trkThresholdPt = 900.0,
139  trkMaxEta = 2.7, # is this value fine?? default would be 102.5
140  BThresholdPt = 2000.0,
141  BMassUpper = 2100.0, # What is this??
142  BMassLower = 500.0,
143  TrkDeltaZ = 20.,
144  TrkTrippletMassUpper = 2200, #2100
145  TrkTrippletMassLower = 500,
146  TrkQuadrupletPt = 2000,
147  JpsiContainerKey = "BPHY22DiTrkCandidates",
148  TrackParticleCollection = "InDetTrackParticles",
149  MuonsUsedInJpsi = "NONE", # ?
150  ExcludeCrossJpsiTracks = False,
151  TrkVertexFitterTool = vkalvrt,
152  TrackSelectorTool = trackselect,
153  UseMassConstraint = False,
154  Chi2Cut = 7) #Cut on chi2/Ndeg_of_freedom 5->7
155 
156  BPHY22Dh3SelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
157  name = "BPHY22Dh3SelectAndWrite",
158  VertexSearchTool = BPHY22Dh3Finder,
159  V0Tools = V0Tools,
160  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
161  OutputVtxContainerName = "BPHY22Dh3Candidates",
162  PVContainerName = "PrimaryVertices",
163  RefPVContainerName = "SHOULDNOTBEUSED",
164  MaxPVrefit = 1000)
165 
166  BMuDxVertexFit = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName+"BMuDxVertexFit", CascadeCnstPrecision = 1e-6))
167 
168  BPHY22MuDs = CompFactory.DerivationFramework.MuPlusDsCascade(
169  name = "BPHY22MuDs",
170  HypothesisName = "B",
171  TrkVertexFitterTool = BMuDxVertexFit,
172  V0Tools = V0Tools,
173  PVRefitter = PVrefit,
174  DxHypothesis = 431,
175  ApplyDxMassConstraint = False,
176  DxMassLowerCut = 1968.28 - 300.,
177  DxMassUpperCut = 1968.28 + 200.,
178  MassLowerCut = 1000,
179  MassUpperCut = 12500,
180  Chi2Cut = 10,
181  RefitPV = True,
182  combOnly = True,
183  TrackSelectorTool = trackselect,
184  useMCPCuts = False,
185  muonThresholdPt = 2700,
186  muonCollectionKey = "Muons",
187  useCombinedMeasurement = False, # Only takes effect if combOnly=True
188  RefPVContainerName = "BPHY22RefittedPrimaryVertices",
189  CascadeVertexCollections = ["BMuDsCascadeSV2", "BMuDsCascadeSV1"],
190  DxVertices = "BPHY22Dh3Candidates")
191 
192  BPHY22MuDp = CompFactory.DerivationFramework.MuPlusDsCascade(
193  name = "BPHY22MuDp",
194  HypothesisName = "B",
195  TrkVertexFitterTool = BMuDxVertexFit,
196  V0Tools = V0Tools,
197  PVRefitter = PVrefit,
198  DxHypothesis = 411,
199  ApplyDxMassConstraint = False,
200  DxMassLowerCut = 1869.59 - 180.,
201  DxMassUpperCut = 1869.59 + 250.,
202  MassLowerCut = 1000,
203  MassUpperCut = 12500,
204  Chi2Cut = 10,
205  RefitPV = True,
206  combOnly = True,
207  TrackSelectorTool = trackselect,
208  useMCPCuts = False,
209  muonThresholdPt = 2700,
210  muonCollectionKey = "Muons",
211  useCombinedMeasurement = False, # Only takes effect if combOnly=True
212  RefPVContainerName = "BPHY22RefittedPrimaryVertices",
213  CascadeVertexCollections = ["BMuDpCascadeSV2", "BMuDpCascadeSV1"],
214  DxVertices = "BPHY22Dh3Candidates")
215 
216  BPHY22MuLambdaC = CompFactory.DerivationFramework.MuPlusDsCascade(
217  name = "BPHY22MuLambdaC",
218  HypothesisName = "B",
219  TrkVertexFitterTool = BMuDxVertexFit,
220  V0Tools = V0Tools,
221  PVRefitter = PVrefit,
222  DxHypothesis = 4122,
223  ApplyDxMassConstraint = False,
224  DxMassLowerCut = 2286.46 - 200,
225  DxMassUpperCut = 2286.46 + 220,
226  MassLowerCut = 1000,
227  MassUpperCut = 12500,
228  Chi2Cut = 10,
229  RefitPV = True,
230  combOnly = True,
231  TrackSelectorTool = trackselect,
232  useMCPCuts = False,
233  muonThresholdPt = 2700,
234  muonCollectionKey = "Muons",
235  useCombinedMeasurement = False, # Only takes effect if combOnly=True
236  RefPVContainerName = "BPHY22RefittedPrimaryVertices",
237  CascadeVertexCollections = ["BMuLambdaCCascadeSV2", "BMuLambdaCCascadeSV1"],
238  DxVertices = "BPHY22Dh3Candidates")
239 
240  CascadeCollections = []
241  CascadeCollections += BPHY22MuDpst.CascadeVertexCollections
242  CascadeCollections += BPHY22MuDp.CascadeVertexCollections
243  CascadeCollections += BPHY22MuDs.CascadeVertexCollections
244  CascadeCollections += BPHY22MuLambdaC.CascadeVertexCollections
245 
246  if not isSimulation: #Only Skim Data
247  BPHY22_SelectBMuDxEvent = CompFactory.DerivationFramework.AnyVertexSkimmingTool("BPHY22_AnyVertexSkimmingTool",
248  VertexContainerNames =CascadeCollections,
249  UseHandles = True )
250  acc.addPublicTool(BPHY22_SelectBMuDxEvent)
251 
252  #====================================================================
253  # Make event selection based on an OR of the input skimming tools
254  #====================================================================
255 
256  BPHY22SkimmingOR = CompFactory.DerivationFramework.FilterCombinationOR(
257  "BPHY22SkimmingOR",
258  FilterList = [BPHY22_SelectBMuDxEvent] )
259  acc.addPublicTool(BPHY22SkimmingOR)
260 
261  augTools = [BPHY22MuPiSelectAndWrite, #BPHY22_Select_MuPi,
262  BPHY22DiTrkSelectAndWrite, #BPHY22_Select_D0, BPHY22_Select_D0b,
263  BPHY22Dh3SelectAndWrite, #BPHY22_Select_Ds, BPHY22_Select_Dp, BPHY22_Select_Dm, BPHY22_Select_LambdaCp, BPHY22_Select_LambdaCm,
264  BPHY22MuDpst,
265  BPHY22MuDs,
266  BPHY22MuDp,
267  BPHY22MuLambdaC,
268  BPHY22_AugOriginalCounts]
269  for t in augTools : acc.addPublicTool(t)
270  acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY22Kernel",
271  AugmentationTools = augTools,
272  #Only skim if not MC
273  SkimmingTools = [BPHY22SkimmingOR] if not isSimulation else [],
274  ThinningTools = []))
275 
276  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
277  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
278  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
279  BPHY22SlimmingHelper = SlimmingHelper("BPHY22SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
280 
281  # Needed for trigger objects
282  BPHY22SlimmingHelper.IncludeMuonTriggerContent = True
283  BPHY22SlimmingHelper.IncludeBPhysTriggerContent = True
284  from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
285  AllVariables = getDefaultAllVariables()
286  StaticContent = []
287 
288  AllVariables += ["PrimaryVertices"]
289  StaticContent += ["xAOD::VertexContainer#BPHY22RefittedPrimaryVertices"]
290  StaticContent += ["xAOD::VertexAuxContainer#BPHY22RefittedPrimaryVerticesAux."]
291 
292 
293  AllVariables += ["InDetTrackParticles"]
294 
295 
298  AllVariables += ["CombinedMuonTrackParticles"]
299  AllVariables += ["ExtrapolatedMuonTrackParticles"]
300 
301 
302  AllVariables += ["Muons"]
303 
304 
305  StaticContent += ["xAOD::VertexContainer#%s" % BPHY22MuPiSelectAndWrite.OutputVtxContainerName]
306 
307  StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY22MuPiSelectAndWrite.OutputVtxContainerName]
308 
309 
310  for cascades in CascadeCollections:
311  StaticContent += ["xAOD::VertexContainer#%s" % cascades]
312  StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % cascades]
313 
314  # Tagging information (in addition to that already requested by usual algorithms)
315  AllVariables += ["MuonSpectrometerTrackParticles" ]
316 
317  # Truth information for MC only
318  if isSimulation:
319  AllVariables += ["TruthEvents","TruthParticles","TruthVertices","MuonTruthParticles"]
320 
321  AllVariables = list(set(AllVariables)) # remove duplicates
322  BPHY22SlimmingHelper.AllVariables = AllVariables
323  BPHY22SlimmingHelper.StaticContent = StaticContent
324  BPHY22ItemList = BPHY22SlimmingHelper.GetItemList()
325  acc.merge(OutputStreamCfg(flags, "DAOD_BPHY22", ItemList=BPHY22ItemList, AcceptAlgs=["BPHY22Kernel"]))
326  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY22", AcceptAlgs=["BPHY22Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
327  acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True, printComponentsOnly=False)
328  return acc
python.HIGG1D1CustomVertexConfig.PrimaryVertexRefittingToolCfg
def PrimaryVertexRefittingToolCfg(flags, **kwargs)
Definition: HIGG1D1CustomVertexConfig.py:7
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
commonBPHYMethodsCfg.BPHY_TrkVKalVrtFitterCfg
def BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName, **kwargs)
Definition: commonBPHYMethodsCfg.py:6
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
BPHY22.BPHY22Cfg
def BPHY22Cfg(flags)
Definition: BPHY22.py:15
commonBPHYMethodsCfg.BPHY_V0ToolCfg
def BPHY_V0ToolCfg(flags, BPHYDerivationName)
Definition: commonBPHYMethodsCfg.py:11
python.InDetConversionFinderToolsConfig.BPHY_VertexPointEstimatorCfg
def BPHY_VertexPointEstimatorCfg(flags, name="BPHY_VertexPointEstimator", **kwargs)
Definition: InDetConversionFinderToolsConfig.py:69
commonBPHYMethodsCfg.getDefaultAllVariables
def getDefaultAllVariables()
Definition: commonBPHYMethodsCfg.py:32
python.InDetTrackSelectorToolConfig.BPHY_InDetDetailedTrackSelectorToolCfg
def BPHY_InDetDetailedTrackSelectorToolCfg(flags, name='BPHY_InDetDetailedTrackSelectorTool', **kwargs)
Definition: InDetTrackSelectorToolConfig.py:215
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:216
SlimmingHelper
Definition: SlimmingHelper.py:1