ATLAS Offline Software
egammaD3PDConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 #
3 # @file D3PDMakerConfig/python/egammaD3PDConfig.py
4 # @author scott snyder <snyder@bnl.gov>
5 # Date: Dec 2023, from old config
6 # @brief Construct an egamma D3PD.
7 #
8 
9 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
10 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
11 
12 
13 # Make a container merging xAOD central and forward electrons.
14 import AthenaPython.PyAthena as PyAthena
15 from AthenaPython.PyAthena import StatusCode
17  def __init__ (self, name = 'MergeElectrons', **kw):
18  super (MergeElectrons, self).__init__ (name = name, **kw)
19  return
20  def execute (self):
21  import ROOT
22  sg=PyAthena.py_svc('StoreGateSvc')
23  e1 = sg['Electrons']
24  e2 = sg['ForwardElectrons']
25  enew = ROOT.DataVector(ROOT.xAOD.Electron_v1) (1) #VIEW_ELEMENTS
26  for e in e1: enew.push_back(e)
27  for e in e2: enew.push_back(e)
28  ROOT.SetOwnership (enew, False)
29  sg.record (enew, 'AllElectrons')
30 
31  # Make sure these aux variables are defined at this point.
32  ROOT.xAOD.ElectronAuxContainer()
33  ROOT.xAOD.CaloClusterAuxContainer()
34 
35  return StatusCode.Success
36 
37 
38 
39 def _args (level, name, kwin, **kw):
40  kw = kw.copy()
41  kw['level'] = level
42  for (k, v) in kwin.items():
43  if k.startswith (name + '_'):
44  kw[k[len(name)+1:]] = v
45  return kw
46 
47 
48 def egammaD3PDCfg (flags, stream = 'egamma', file = 'egamma.root',
49  level = 10,
50  clevel = 6,
51  autoflush = -1,
52  **kw):
53  acc = ComponentAccumulator()
54 
55  acc.addEventAlgo (MergeElectrons())
56 
57  from D3PDMakerCoreComps.MakerAlgConfig import MakerAlgConfig
58  alg = MakerAlgConfig (flags, acc, stream, file,
59  clevel = clevel,
60  autoflush = autoflush)
61 
62  from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject
63  alg += EventInfoD3PDObject (**_args (level, 'EventInfo', kw))
64 
65  from CaloD3PDMaker.LArCollisionTimeD3PDObject import LArCollisionTimeD3PDObject
66  alg += LArCollisionTimeD3PDObject (**_args (level, 'LArCollisionTime', kw))
67 
68  from egammaD3PDMaker.ElectronD3PDObject import ElectronD3PDObject
69  alg += ElectronD3PDObject (**_args (level, 'Electron', kw,
70  EgammaJetSignedIPAndPTRel_target='jet_'
71  ))
72 
73  from egammaD3PDMaker.PhotonD3PDObject import PhotonD3PDObject
74  alg += PhotonD3PDObject (**_args (level, 'Photon', kw))
75 
76  from MuonD3PDMaker.MuonD3PDObject import MuonD3PDObject
77  alg += MuonD3PDObject (**_args (10, 'Muons', kw,
78  sgkey='StacoMuonCollection,Muons', prefix='mu_',
79  include = ["EFCBInfoIndex", "EFMGInfoIndex",
80  "EFMEInfoIndex",
81  "L2CBInfoIndex", "L1InfoIndex",
82  "MuonScatteringAngleSignificance"],
83  exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo",
84  "L2CBInfo", "L1Info"],
85  allowMissing = True ))
86 
87  from JetD3PDMaker.JetD3PDObject import JetD3PDObject
88  alg += JetD3PDObject (**_args (0, 'Jet', kw,
89  include=['JetQual',
90  'DQMoments']))
91 
92  from CaloD3PDMaker.MBTSD3PDObject import MBTSD3PDObject
93  alg += MBTSD3PDObject (**_args (level, 'MBTS', kw))
94 
95  from CaloD3PDMaker.MBTSTimeD3PDObject import MBTSTimeD3PDObject
96  alg += MBTSTimeD3PDObject (**_args (level, 'MBTSTime', kw))
97 
98  # May be missing in single-beam data.
99  from TrackD3PDMaker.xAODVertexD3PDObject import PrimaryxAODVertexD3PDObject
100  alg += PrimaryxAODVertexD3PDObject (**_args (
101  1, 'PrimaryVertex', kw,
102  #allowMissing = True,
103  sgkey = D3PDMakerFlags.VertexSGKey,
104  prefix = 'vxp_',
105  storeVertexTrackIndexAssociation = False,
106  storeVertexTrackAssociation = True,
107  storeDiagonalCovarianceAsErrors = True))
108 
109  from TrackD3PDMaker.xAODTrackD3PDObject import xAODTrackParticleD3PDObject
110  alg += xAODTrackParticleD3PDObject (**_args (
111  3, 'TrackParticleCandidate', kw,
112  trackParametersAtGlobalPerigeeLevelOfDetails = 3,
113  storeDiagonalCovarianceAsErrors = True))
114 
115  if D3PDMakerFlags.DoTruth:
116  from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
117  alg += TruthMuonD3PDObject (**_args (level, 'TruthMuon', kw))
118 
119  from TruthD3PDMaker.TruthEventD3PDObject import TruthEventD3PDObject
120  alg += TruthEventD3PDObject (**_args (1, 'TruthEvent', kw))
121 
122  from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject
123  alg += TruthParticleD3PDObject(**_args (level, 'TruthParticle', kw))
124 
125  acc.addEventAlgo (alg.alg)
126 
127  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
PyAthena::Alg::execute
virtual StatusCode execute() override
Definition: PyAthenaAlg.cxx:93
python.egammaD3PDConfig.MergeElectrons
Definition: egammaD3PDConfig.py:16
python.egammaD3PDConfig.MergeElectrons.__init__
def __init__(self, name='MergeElectrons', **kw)
Definition: egammaD3PDConfig.py:17
python.egammaD3PDConfig.egammaD3PDCfg
def egammaD3PDCfg(flags, stream='egamma', file='egamma.root', level=10, clevel=6, autoflush=-1, **kw)
Definition: egammaD3PDConfig.py:48
python.TruthParticleD3PDObject.TruthParticleD3PDObject
TruthParticleD3PDObject
Definition: TruthParticleD3PDObject.py:21
python.egammaD3PDConfig._args
def _args(level, name, kwin, **kw)
Definition: egammaD3PDConfig.py:39
PyAthena::Alg
Definition: PyAthenaAlg.h:33