ATLAS Offline Software
BPHY18.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 #====================================================================
3 # BPHY18.py
4 #====================================================================
5 
6 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7 from AthenaConfiguration.ComponentFactory import CompFactory
8 from AthenaConfiguration.Enums import MetadataCategory
9 
10 
11 BPHYDerivationName = "BPHY18"
12 streamName = "StreamDAOD_BPHY18"
13 
14 def BPHY18Cfg(flags):
15  from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
16  from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
17  from DerivationFrameworkEGamma.EGammaCommonConfig import EGammaCommonCfg
18  acc = ComponentAccumulator()
19  acc.merge(EGammaCommonCfg(flags))
20  isSimulation = flags.Input.isMC
21  V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, BPHYDerivationName))
22  vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, BPHYDerivationName)) # VKalVrt vertex fitter
23  acc.addPublicTool(vkalvrt)
24  acc.addPublicTool(V0Tools)
25  trackselect = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, BPHYDerivationName))
26  acc.addPublicTool(trackselect)
27  vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, BPHYDerivationName))
28  acc.addPublicTool(vpest)
29 
30  #BPHY18TriggerSkim = CompFactory.DerivationFramework.TriggerSkimmingTool(name = "BPHY18TriggerSkim",
31 # TriggerListOR = triggerList,
32 # TriggerListORHLTOnly = triggerList_unseeded )
33 
34  ElectronLHSelectorLHvloose_nod0 = CompFactory.AsgElectronLikelihoodTool("ElectronLHSelectorLHvloosenod0",
35  primaryVertexContainer = "PrimaryVertices",
36  ConfigFile="ElectronPhotonSelectorTools/offline/mc20_20230321/ElectronLikelihoodVeryLooseOfflineConfig2017_Smooth_NoD0_NoPix.conf")
37 
38  # decorate electrons with the output of LH
39 
40  ElectronPassLHvloosenod0 = CompFactory.DerivationFramework.EGElectronLikelihoodToolWrapper(name = "ElectronPassLHvloosenod0",
41  EGammaElectronLikelihoodTool = ElectronLHSelectorLHvloose_nod0,
42  EGammaFudgeMCTool = "",
43  CutType = "",
44  StoreGateEntryName = "DFCommonElectronsLHVeryLoosenod0",
45  ContainerName = "Electrons",
46  StoreTResult=False)
47 
48  BPHY18DiElectronFinder = CompFactory.Analysis.JpsiFinder_ee(
49  name = "BPHY18DiElectronFinder",
50  elAndEl = True,
51  elAndTrack = False,
52  TrackAndTrack = False,
53  assumeDiElectrons = True,
54  elThresholdPt = 4000.0,
55  invMassUpper = 7000.0,
56  invMassLower = 1.0,
57  Chi2Cut = 30.,
58  oppChargesOnly = False,
59  allChargeCombinations = True,
60  useElectronTrackMeasurement = True,
61  electronCollectionKey = "Electrons",
62  TrackParticleCollection = "GSFTrackParticles",
63  useEgammaCuts = True,
64  V0VertexFitterTool = None,
65  useV0Fitter = False,
66  TrkVertexFitterTool = vkalvrt,
67  TrackSelectorTool = trackselect,
68  VertexPointEstimator = vpest,
69  ElectronSelection = "d0_or_nod0"
70  )
71  extraTools = [BPHY18DiElectronFinder]
72  BPHY18DiElectronSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
73  name = "BPHY18DiElectronSelectAndWrite",
74  VertexSearchTool = BPHY18DiElectronFinder,
75  OutputVtxContainerName = "BPHY18DiElectronCandidates",
76  PVContainerName = "PrimaryVertices",
77  V0Tools = V0Tools,
78  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
79  RefPVContainerName = "SHOULDNOTBEUSED",
80  DoVertexType = 7
81  )
82 
83  BPHY18_Select_DiElectrons = CompFactory.DerivationFramework.Select_onia2mumu(
84  name = "BPHY18_Select_DiElectrons",
85  HypothesisName = "Jpsi",
86  InputVtxContainerName = "BPHY18DiElectronCandidates",
87  V0Tools = V0Tools,
88  VtxMassHypo = 3096.916,
89  MassMin = 1.0,
90  MassMax = 7000.0,
91  Chi2Max = 30,
92  DoVertexType = 7
93  )
94 
95  BPHY18BeeKst = CompFactory.Analysis.JpsiPlus2Tracks(
96  name = "BPHY18BeeKstFinder",
97  kaonkaonHypothesis = False,
98  pionpionHypothesis = False,
99  kaonpionHypothesis = True,
100  oppChargesOnly = False,
101  SameChargesOnly = False,
102  trkThresholdPt = 500.0,
103  trkMaxEta = 3.0,
104  BThresholdPt = 1000.,
105  BMassLower = 3000.0,
106  BMassUpper = 6500.0,
107  JpsiContainerKey = "BPHY18DiElectronCandidates",
108  TrackParticleCollection = "InDetTrackParticles",
109  ExcludeCrossJpsiTracks = False,
110  TrkVertexFitterTool = vkalvrt,
111  TrackSelectorTool = trackselect,
112  UseMassConstraint = False,
113  DiTrackMassUpper = 1110.,
114  DiTrackMassLower = 690.,
115  Chi2Cut = 15.0,
116  DiTrackPt = 500.,
117  TrkQuadrupletMassLower = 1000.0,
118  TrkQuadrupletMassUpper = 10000.0,
119  FinalDiTrackPt = 500.,
120  UseGSFTrackIndices = [0,1]
121  )
122  BPHY18BeeKstSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(
123  name = "BPHY18BeeKstSelectAndWrite",
124  VertexSearchTool = BPHY18BeeKst,
125  OutputVtxContainerName = "BeeKstCandidates",
126  PVContainerName = "PrimaryVertices",
127  RefPVContainerName = "BPHY18RefittedPrimaryVertices",
128  RefitPV = True,
129  V0Tools = V0Tools,
130  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
131  MaxPVrefit = 10000,
132  DoVertexType = 7
133  )
134 
135  BPHY18_Select_BeeKst = CompFactory.DerivationFramework.Select_onia2mumu(
136  name = "BPHY18_Select_BeeKst",
137  HypothesisName = "Bd",
138  InputVtxContainerName = "BeeKstCandidates",
139  V0Tools = V0Tools,
140  TrkMasses = [0.511, 0.511, 493.677, 139.570],
141  VtxMassHypo = 5279.6,
142  MassMin = 1.0,
143  MassMax = 10000.0,
144  Chi2Max = 30.0
145  )
146 
147  BPHY18_Select_BeeKstbar = CompFactory.DerivationFramework.Select_onia2mumu(
148  name = "BPHY18_Select_Bd2JpsiKstbar",
149  HypothesisName = "Bdbar",
150  InputVtxContainerName = "BeeKstCandidates",
151  V0Tools = V0Tools,
152  TrkMasses = [0.511, 0.511, 139.570, 493.677],
153  VtxMassHypo = 5279.6,
154  MassMin = 1.0,
155  MassMax = 10000.0,
156  Chi2Max = 30.0
157  )
158 
159 
160  BPHY18_diMeson_revertex = CompFactory.DerivationFramework.ReVertex(
161  name = "BPHY18_diMeson_revertex",
162  InputVtxContainerName = "BeeKstCandidates",
163  V0Tools = V0Tools,
164  PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
165  TrackIndices = [ 2, 3 ],
166  TrkVertexFitterTool = vkalvrt,
167  OutputVtxContainerName = "BPHY18DiMeson"
168  )
169 
170  BPHY18_Select_Kpi = CompFactory.DerivationFramework.Select_onia2mumu(
171  name = "BPHY18_Select_Kpi",
172  HypothesisName = "Kpi",
173  InputVtxContainerName = "BPHY18DiMeson",
174  V0Tools = V0Tools,
175  TrkMasses = [ 493.677, 139.570 ],
176  VtxMassHypo = 891.66,
177  MassMin = 1.0,
178  MassMax = 100000.0,
179  Chi2Max = 100.0
180  )
181 
182  BPHY18_Select_piK = CompFactory.DerivationFramework.Select_onia2mumu(
183  name = "BPHY18_Select_piK",
184  HypothesisName = "piK",
185  InputVtxContainerName = "BPHY18DiMeson",
186  V0Tools = V0Tools,
187  TrkMasses = [ 139.570, 493.677 ],
188  VtxMassHypo = 891.66,
189  MassMin = 1.0,
190  MassMax = 100000.0,
191  Chi2Max = 100.0
192  )
193 
194  BPHY18_SelectBeeKstEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(
195  name = "BPHY18_SelectBeeKstEvent",
196  expression = "(count(BeeKstCandidates.passed_Bd > 0) + count(BeeKstCandidates.passed_Bdbar > 0)) > 0")
197 
198  BPHY18SkimmingAND = CompFactory.DerivationFramework.FilterCombinationAND(
199  "BPHY18SkimmingAND",
200  #FilterList = [BPHY18_SelectBeeKstEvent, BPHY18TriggerSkim]) # TODO: Need to update the trigger names
201  FilterList = [BPHY18_SelectBeeKstEvent])
202  extraTools += [BPHY18_SelectBeeKstEvent, BPHY18SkimmingAND]
203  BPHY18_thinningTool_Tracks = CompFactory.DerivationFramework.Thin_vtxTrk(
204  name = "BPHY18_thinningTool_Tracks",
205  TrackParticleContainerName = "InDetTrackParticles",
206  StreamName = streamName,
207  VertexContainerNames = ["BeeKstCandidates"],
208  PassFlags = ["passed_Bd", "passed_Bdbar"] )
209 
210  BPHY18_thinningTool_GSFTracks = CompFactory.DerivationFramework.Thin_vtxTrk(
211  name = "BPHY18_thinningTool_GSFTracks",
212  TrackParticleContainerName = "GSFTrackParticles",
213  StreamName = streamName,
214  VertexContainerNames = ["BeeKstCandidates"],
215  PassFlags = ["passed_Bd", "passed_Bdbar"] )
216 
217  BPHY18_thinningTool_PV = CompFactory.DerivationFramework.BPhysPVThinningTool(
218  name = "BPHY18_thinningTool_PV",
219  StreamName = streamName,
220  CandidateCollections = ["BeeKstCandidates"],
221  KeepPVTracks = True
222  )
223 
224  BPHY18MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(
225  name = "BPHY18MuonTPThinningTool",
226  StreamName = streamName,
227  MuonKey = "Muons",
228  InDetTrackParticlesKey = "InDetTrackParticles")
229 
230  BPHY18EgammaTPThinningTool = CompFactory.DerivationFramework.EgammaTrackParticleThinning(
231  name = "BPHY18EgammaTPThinningTool",
232  StreamName = streamName,
233  SGKey = "Electrons",
234  InDetTrackParticlesKey = "InDetTrackParticles")
235 
236  BPHY18TruthThinTool = CompFactory.DerivationFramework.GenericTruthThinning(name = "BPHY18TruthThinTool",
237  ParticleSelectionString = "abs(TruthParticles.pdgId) == 11 || abs(TruthParticles.pdgId) == 13 || abs(TruthParticles.pdgId) == 10311 || abs(TruthParticles.pdgId) == 521 || abs(TruthParticles.pdgId) == 523 || abs(TruthParticles.pdgId) == 511 || abs(TruthParticles.pdgId) == 513",
238  PreserveDescendants = True,
239  StreamName = streamName,
240  PreserveAncestors = True)
241 
242  BPHY18TruthThinNoChainTool = CompFactory.DerivationFramework.GenericTruthThinning(name = "BPHY18TruthThinNoChainTool",
243  ParticleSelectionString = "abs(TruthParticles.pdgId) == 5 || abs(TruthParticles.pdgId) == 12 || abs(TruthParticles.pdgId) == 14",
244  PreserveDescendants = False,
245  StreamName = streamName,
246  PreserveAncestors = False)
247 
248  thinningCollection = [ BPHY18_thinningTool_Tracks, BPHY18_thinningTool_GSFTracks,
249  BPHY18_thinningTool_PV, #BPHY18_thinningTool_PV_GSF,
250  BPHY18EgammaTPThinningTool, BPHY18MuonTPThinningTool
251  ]
252 
253 
254  augTools = [ElectronPassLHvloosenod0,
255  BPHY18DiElectronSelectAndWrite, BPHY18_Select_DiElectrons,
256  BPHY18BeeKstSelectAndWrite, BPHY18_Select_BeeKst, BPHY18_Select_BeeKstbar,
257  BPHY18_diMeson_revertex, BPHY18_Select_Kpi, BPHY18_Select_piK]
258  skimTools = [BPHY18SkimmingAND]
259 
260  if isSimulation:
261  thinningCollection += [BPHY18TruthThinTool,BPHY18TruthThinNoChainTool]
262 
263  for t in augTools + skimTools + thinningCollection + extraTools: acc.addPublicTool(t)
264  acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("BPHY18Kernel",
265  AugmentationTools = augTools,
266  #Only skim if not MC
267  SkimmingTools = skimTools,
268  ThinningTools = thinningCollection))
269 
270  from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
271  acc.merge(DerivationTrackIsoCfg(flags, object_types=("Electrons", "Muons")))
272 
273 
274  #====================================================================
275  # Slimming
276  #====================================================================
277 
278  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
279  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
280  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
281  BPHY18SlimmingHelper = SlimmingHelper("BPHY18SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
282  from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
283  AllVariables = getDefaultAllVariables()
284  StaticContent = []
285  ExtraVariables = []
286  BPHY18SlimmingHelper.SmartCollections = ["Electrons", "Muons", "InDetTrackParticles" ]
287 
288  # Needed for trigger objects
289  BPHY18SlimmingHelper.IncludeMuonTriggerContent = False
290  BPHY18SlimmingHelper.IncludeBPhysTriggerContent = False
291  BPHY18SlimmingHelper.IncludeEGammaTriggerContent = True
292 
293  AllVariables += ["PrimaryVertices"]
294  StaticContent += ["xAOD::VertexContainer#BPHY18RefittedPrimaryVertices"]
295  StaticContent += ["xAOD::VertexAuxContainer#BPHY18RefittedPrimaryVerticesAux."]
296 
297  ExtraVariables += ["Muons.etaLayer1Hits.etaLayer2Hits.etaLayer3Hits.etaLayer4Hits.phiLayer1Hits.phiLayer2Hits.phiLayer3Hits.phiLayer4Hits",
298  "Muons.numberOfTriggerEtaLayers.numberOfPhiLayers",
299  "InDetTrackParticles.numberOfTRTHits.numberOfTRTHighThresholdHits.vx.vy.vz.pixeldEdx",
300  "PrimaryVertices.chiSquared.covariance",
301  "Electrons.deltaEta1.DFCommonElectronsLHVeryLoosenod0.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt1000.ptvarcone20_Nonprompt_All_MaxWeightTTVA_pt1000.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt500.ptvarcone40_Nonprompt_All_MaxWeightTTVALooseCone_pt1000.ptvarcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000",
302  "egammaClusters.calE.calEta.calPhi.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME",
303  "HLT_xAOD__ElectronContainer_egamma_ElectronsAuxDyn.charge"]
304 
305 
306  StaticContent += ["xAOD::VertexContainer#%s" % BPHY18DiElectronSelectAndWrite.OutputVtxContainerName]
307  StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY18DiElectronSelectAndWrite.OutputVtxContainerName]
308 
309  StaticContent += ["xAOD::VertexContainer#%s" % BPHY18BeeKstSelectAndWrite.OutputVtxContainerName]
310  StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY18BeeKstSelectAndWrite.OutputVtxContainerName]
311 
312  StaticContent += ["xAOD::VertexContainer#%s" % BPHY18_diMeson_revertex.OutputVtxContainerName]
313  StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY18_diMeson_revertex.OutputVtxContainerName]
314 
315  AllVariables += [ "GSFTrackParticles"]
316 
317 
318  # Truth information for MC only
319  if isSimulation:
320  AllVariables += ["TruthEvents","TruthParticles","TruthVertices", "ElectronTruthParticles"]
321 
322  AllVariables = list(set(AllVariables)) # remove duplicates
323 
324  BPHY18SlimmingHelper.AllVariables = AllVariables
325  BPHY18SlimmingHelper.ExtraVariables = ExtraVariables
326 
327  BPHY18SlimmingHelper.StaticContent = StaticContent
328 
329  from DerivationFrameworkEGamma.ElectronsCPDetailedContent import ElectronsCPDetailedContent, GSFTracksCPDetailedContent
330  BPHY18SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
331  BPHY18SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
332 
333  BPHY18ItemList = BPHY18SlimmingHelper.GetItemList()
334  acc.merge(OutputStreamCfg(flags, "DAOD_BPHY18", ItemList=BPHY18ItemList, AcceptAlgs=["BPHY18Kernel"]))
335  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_BPHY18", AcceptAlgs=["BPHY18Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
336  acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True, printComponentsOnly=False)
337  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
python.EGammaCommonConfig.EGammaCommonCfg
def EGammaCommonCfg(ConfigFlags)
Definition: EGammaCommonConfig.py:15
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
commonBPHYMethodsCfg.BPHY_V0ToolCfg
def BPHY_V0ToolCfg(flags, BPHYDerivationName)
Definition: commonBPHYMethodsCfg.py:11
BPHY18.BPHY18Cfg
def BPHY18Cfg(flags)
Definition: BPHY18.py:14
python.InDetConversionFinderToolsConfig.BPHY_VertexPointEstimatorCfg
def BPHY_VertexPointEstimatorCfg(flags, name="BPHY_VertexPointEstimator", **kwargs)
Definition: InDetConversionFinderToolsConfig.py:69
commonBPHYMethodsCfg.getDefaultAllVariables
def getDefaultAllVariables()
Definition: commonBPHYMethodsCfg.py:32
DerivationTrackIsoConfig.DerivationTrackIsoCfg
def DerivationTrackIsoCfg(flags, **jwarg)
Definition: DerivationTrackIsoConfig.py:11
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