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