ATLAS Offline Software
BPHY1.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #====================================================================
4 # BPHY1.py
5 #====================================================================
6 
7 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.Enums import MetadataCategory
10 
11 BPHYDerivationName = "BPHY1"
12 streamName = "StreamDAOD_BPHY1"
13 
14 OniaContainerName = "BPHY1OniaCandidates"
15 
16 def BPHY1Kernel(flags):
17  from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
18  acc = ComponentAccumulator()
19  doLRT = flags.Tracking.doLargeD0
20  BPHY1_AugOriginalCounts = CompFactory.DerivationFramework.AugOriginalCounts(
21  name = "BPHY1_AugOriginalCounts",
22  VertexContainer = "PrimaryVertices",
23  TrackContainer = "InDetTrackParticles",
24  TrackLRTContainer = "InDetLargeD0TrackParticles" if doLRT else "" )
25  mainMuonInput = "StdWithLRTMuons" if doLRT else "Muons"
26  mainIDInput = "InDetWithLRTTrackParticles" if doLRT else "InDetTrackParticles"
27  if doLRT:
28  from DerivationFrameworkLLP.LLPToolsConfig import LRTMuonMergerAlg
29  from AthenaConfiguration.Enums import LHCPeriod
30  acc.merge(LRTMuonMergerAlg( flags,
31  PromptMuonLocation = "Muons",
32  LRTMuonLocation = "MuonsLRT",
33  OutputMuonLocation = mainMuonInput,
34  CreateViewCollection = True,
35  UseRun3WP = flags.GeoModel.Run == LHCPeriod.Run3))
36  from DerivationFrameworkInDet.InDetToolsConfig import InDetLRTMergeCfg
37  acc.merge(InDetLRTMergeCfg(flags))
38 
39  toRelink = ["InDetTrackParticles", "InDetLargeD0TrackParticles"] if doLRT else []
40  MuonReLink = [ "Muons", "MuonsLRT" ] if doLRT else []
41 
42  V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, BPHYDerivationName))
43  vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName)) # VKalVrt vertex fitter
44  acc.addPublicTool(vkalvrt)
45  acc.addPublicTool(V0Tools)
46  TrackSelector = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, BPHYDerivationName))
47  acc.addPublicTool(TrackSelector)
48  vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, BPHYDerivationName))
49  acc.addPublicTool(vpest)
50  BPHY1JpsiFinder = CompFactory.Analysis.JpsiFinder(
51  name = "BPHY1JpsiFinder",
52  muAndMu = True,
53  muAndTrack = False,
54  TrackAndTrack = False,
55  assumeDiMuons = True, # If true, will assume dimu hypothesis and use PDG value for mu mass
56  invMassUpper = 100000.0,
57  invMassLower = 0.0,
58  Chi2Cut = 200.,
59  oppChargesOnly = True,
60  atLeastOneComb = True,
61  useCombinedMeasurement = False, # Only takes effect if combOnly=True
62  muonCollectionKey = mainMuonInput,
63  TrackParticleCollection = mainIDInput,
64  useV0Fitter = False, # if False a TrkVertexFitterTool will be used
65  TrkVertexFitterTool = vkalvrt,
66  V0VertexFitterTool = None,
67  TrackSelectorTool = TrackSelector,
68  VertexPointEstimator = vpest,
69  useMCPCuts = False )
70 
71  from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
72  BPHY1_Reco_mumu = CompFactory.DerivationFramework.Reco_Vertex(
73  name = "BPHY1_Reco_mumu",
74  VertexSearchTool = BPHY1JpsiFinder,
75  OutputVtxContainerName = OniaContainerName,
76  PVContainerName = "PrimaryVertices",
77  RefPVContainerName = "BPHY1RefittedPrimaryVertices",
78  RefitPV = True,
79  MaxPVrefit = 100000,
80  V0Tools = V0Tools,
81  RelinkTracks = toRelink,
82  RelinkMuons = MuonReLink,
83  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
84  DoVertexType = 7)
85 
86  BPHY1_Select_Jpsi2mumu =CompFactory.DerivationFramework.Select_onia2mumu(
87  name = "BPHY1_Select_Jpsi2mumu",
88  HypothesisName = "Jpsi",
89  InputVtxContainerName = "BPHY1OniaCandidates",
90  V0Tools = V0Tools,
91  VtxMassHypo = 3096.916,
92  MassMin = 2000.0,
93  MassMax = 3600.0,
94  Chi2Max = 200,
95  DoVertexType = 7)
96  BPHY1_Select_Psi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
97  name = "BPHY1_Select_Psi2mumu",
98  HypothesisName = "Psi",
99  InputVtxContainerName = "BPHY1OniaCandidates",
100  V0Tools = V0Tools,
101  VtxMassHypo = 3686.09,
102  MassMin = 3300.0,
103  MassMax = 4500.0,
104  Chi2Max = 200,
105  DoVertexType = 7)
106  BPHY1_Select_Upsi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
107  name = "BPHY1_Select_Upsi2mumu",
108  HypothesisName = "Upsi",
109  InputVtxContainerName = "BPHY1OniaCandidates",
110  V0Tools = V0Tools,
111  VtxMassHypo = 9460.30,
112  MassMin = 7000.0,
113  MassMax = 12500.0,
114  Chi2Max = 200,
115  DoVertexType = 7)
116  augTools = [BPHY1_AugOriginalCounts, BPHY1_Reco_mumu, BPHY1_Select_Jpsi2mumu, BPHY1_Select_Psi2mumu, BPHY1_Select_Upsi2mumu]
117  for t in [BPHY1JpsiFinder] + augTools : acc.addPublicTool(t)
118 
119 
120  BPHY1Thin_vtxTrk = CompFactory.DerivationFramework.Thin_vtxTrk(
121  name = "BPHY1Thin_vtxTrk",
122  TrackParticleContainerName = "InDetTrackParticles",
123  StreamName = streamName,
124  VertexContainerNames = ["BPHY1OniaCandidates"],
125  PassFlags = ["passed_Jpsi", "passed_Psi", "passed_Upsi"] )
126  BPHY1MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(name = "BPHY1MuonTPThinningTool",
127  MuonKey = "Muons",
128  StreamName = streamName,
129  InDetTrackParticlesKey = "InDetTrackParticles")
130  BPHY1ThinningTools = [BPHY1Thin_vtxTrk, BPHY1MuonTPThinningTool]
131  if flags.Input.isMC :
132  TruthSelection ="TruthParticles.pdgId == 443 || TruthParticles.pdgId == 100443 || TruthParticles.pdgId == 553 || TruthParticles.pdgId == 100553 || TruthParticles.pdgId == 200553"
133  BPHY1TruthThinTool = CompFactory.DerivationFramework.GenericTruthThinning(name = "BPHY1TruthThinTool",
134  StreamName = streamName,
135  ParticleSelectionString = TruthSelection,
136  PreserveDescendants = True,
137  PreserveAncestors = True)
138  BPHY1ThinningTools.append(BPHY1TruthThinTool)
139 
140 
141  SelectExpression = "count(BPHY1OniaCandidates.passed_Jpsi) > 0 || count(BPHY1OniaCandidates.passed_Psi) > 0 || count(BPHY1OniaCandidates.passed_Upsi) > 0"
142  BPHY1_SelectEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(name = "BPHY1_SelectEvent", expression = SelectExpression)
143  acc.addPublicTool(BPHY1_SelectEvent)
144  acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY1Kernel",
145  SkimmingTools = [BPHY1_SelectEvent],
146  ThinningTools = BPHY1ThinningTools,
147  AugmentationTools = augTools))
148  for tool in BPHY1ThinningTools : acc.addPublicTool(tool)
149  return acc
150 
151 def BPHY1Cfg(flags):
152  doLRT = flags.Tracking.doLargeD0
153  acc = BPHY1Kernel(flags)
154  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
155  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
156  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
157  from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
158  AllVariables = getDefaultAllVariables()
159  StaticContent = []
160 
161 
162 
163  AllVariables += ["PrimaryVertices"]
164  StaticContent += ["xAOD::VertexContainer#BPHY1RefittedPrimaryVertices"]
165  StaticContent += ["xAOD::VertexAuxContainer#BPHY1RefittedPrimaryVerticesAux."]
166 
167 
168  AllVariables += ["InDetTrackParticles", "InDetLargeD0TrackParticles"] if doLRT else ["InDetTrackParticles"]
169 
170 
173  AllVariables += ["CombinedMuonTrackParticles"]
174  AllVariables += ["ExtrapolatedMuonTrackParticles"]
175 
176 
177  AllVariables += ["Muons", "MuonsLRT"] if doLRT else ["Muons"]
178 
179 
180  StaticContent += ["xAOD::VertexContainer#%s" % OniaContainerName]
181 
182  StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % OniaContainerName]
183 
184  # Truth information for MC only
185  if flags.Input.isMC :
186  AllVariables += ["TruthEvents","TruthParticles","TruthVertices","MuonTruthParticles"]
187 
188  BPHY1SlimmingHelper = SlimmingHelper("BPHY1SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
189  # Needed for trigger objects
190  BPHY1SlimmingHelper.IncludeMuonTriggerContent = True
191  BPHY1SlimmingHelper.IncludeBPhysTriggerContent = True
192 
193  BPHY1SlimmingHelper.AllVariables = AllVariables
194  BPHY1SlimmingHelper.StaticContent = StaticContent
195  BPHY1ItemList = BPHY1SlimmingHelper.GetItemList()
196 
197  acc.merge(OutputStreamCfg(flags, "DAOD_BPHY1", ItemList=BPHY1ItemList, AcceptAlgs=["BPHY1Kernel"]))
198  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY1", AcceptAlgs=["BPHY1Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
199  acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True, printComponentsOnly=False)
200  return acc
python.HIGG1D1CustomVertexConfig.PrimaryVertexRefittingToolCfg
def PrimaryVertexRefittingToolCfg(flags, **kwargs)
Definition: HIGG1D1CustomVertexConfig.py:7
python.LLPToolsConfig.LRTMuonMergerAlg
def LRTMuonMergerAlg(flags, name="LLP1_MuonLRTMergingAlg", **kwargs)
Definition: LLPToolsConfig.py:172
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
BPHY1.BPHY1Cfg
def BPHY1Cfg(flags)
Definition: BPHY1.py:151
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.InDetToolsConfig.InDetLRTMergeCfg
def InDetLRTMergeCfg(flags, name="InDetLRTMerge", **kwargs)
Definition: InDetToolsConfig.py:14
BPHY1.BPHY1Kernel
def BPHY1Kernel(flags)
Definition: BPHY1.py:16
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