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