ATLAS Offline Software
DumpEventDataToJSONConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaCommon.Constants import VERBOSE
6 
7 
8 def DumpEventDataToJSONAlgCfg(flags, doExtrap=False, doACTSEDM = True, **kwargs):
9  result = ComponentAccumulator()
10  extrapolationEngine = ""
11  if doExtrap:
12  from AtlasGeoModel.GeoModelConfig import GeoModelCfg
13  gmsAcc = GeoModelCfg(flags)
14  result.merge(gmsAcc)
15 
16  from TrkConfig.AtlasExtrapolationEngineConfig import AtlasExtrapolationEngineCfg
17  extrapAcc = AtlasExtrapolationEngineCfg(flags)
18  extrapolationEngine = extrapAcc.getPrimary()
19  result.merge(extrapAcc)
20 
21  kwargs.setdefault('Extrapolator', extrapolationEngine)
22  else:
23  kwargs.setdefault('Extrapolator', '')
24 
25 
26  if doACTSEDM:
27  # Need to be able to retrieve the ActsAlignment in order to understand the geometry
28  from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
29  result.merge(ActsGeometryContextAlgCfg(flags))
30  else:
31  kwargs.setdefault('ActsAlignmentKey', '')
32  kwargs.setdefault('TrackContainerKeys', [])
33 
34 
35  # Special container names in DAOD_PHYSLITE for calibrated objects
36  if 'StreamDAOD_PHYSLITE' in flags.Input.Collections:
37  # AnalysisJets and AnalysisLargeRJets are the standard jet containers
38  kwargs.setdefault('JetContainerKeys', ['AnalysisJets','AnalysisLargeRJets'])
39  # AnalysisMuons are the standard calibrated muon container
40  kwargs.setdefault('MuonContainerKeys', ['AnalysisMuons'])
41  # AnalysisTauJets are the calibrated tau jet container
42  kwargs.setdefault('TauJetContainerKeys', ['AnalysisTauJets'])
43  # AnalysisElectrons are the standard calibrated electron container
44  kwargs.setdefault('ElectronContainerKeys', ['AnalysisElectrons'])
45  # AnalysisPhotons are the standard calibrated photon container
46  kwargs.setdefault('PhotonContainerKeys', ['AnalysisPhotons'])
47 
48  # Reduced information in PHYS and PHYSLITE compared to AOD/ESD
49  if 'StreamDAOD_PHYS' in flags.Input.Collections or 'StreamDAOD_PHYSLITE' in flags.Input.Collections:
50  # Not all data is available in PHYS/LITE files
51  kwargs.setdefault('PHYSLITE', True)
52  # Only egamma clusters in DAOD_PHYS/LITE
53  kwargs.setdefault('CaloClusterContainerKeys', ['egammaClusters'])
54  kwargs.setdefault('CaloCellContainerKey', [])
55  # No prep raw data in DAOD_PHYS/LITE
56  kwargs.setdefault('MdtPrepRawDataKey', '')
57  kwargs.setdefault('RpcPrepRawDataKey', '')
58  kwargs.setdefault('TgcPrepRawDataKey', '')
59  kwargs.setdefault('PixelPrepRawDataKey', '')
60  kwargs.setdefault('SctPrepRawDataKey', '')
61  kwargs.setdefault('TrtPrepRawDataKey', '')
62  # These are set based on detector flags and can simply be disabled (no point)
63  kwargs.update( {'MMPrepRawDataKey':'', 'CscPrepRawDataKey':'', 'sTgcPrepRawDataKey':''} )
64  # No real track collections in DAOD_PHYS/LITE
65  kwargs.setdefault('TrackCollectionKeys', [])
66  kwargs.setdefault('TrackContainerKeys', [])
67  kwargs.setdefault('TrackParticleContainerKeys', ['InDetTrackParticles', 'CombinedMuonTrackParticles']) #, 'GSFTrackParticles'])
68 
69 
70  dumpAlg = CompFactory.DumpEventDataToJsonAlg( **kwargs)
71  result.addEventAlgo(dumpAlg)
72  return result
73 
74 
75 if __name__ == "__main__":
76  # Run this with python -m DumpEventDataToJSON.DumpEventDataToJSONConfig --filesInput myESD.pool.root
77  # For help, python -m DumpEventDataToJSON.DumpEventDataToJSONConfig --help
78  from AthenaConfiguration.AllConfigFlags import initConfigFlags
79  flags = initConfigFlags()
80  parser = flags.getArgumentParser()
81  parser.add_argument("-o", "--output", dest="output", default='Event.json',
82  help="write JSON to FILE", metavar="FILE")
83  parser.add_argument("--prependCalib", help="Prepend a calibration event with some labelled objects at specific eta/phi.",
84  action="store_true")
85  args = parser.parse_args()
86 
87  print('Running DumpEventDataToJSON on {} and outputting to {}. Prepend calib event is {}'.format(
88  args.filesInput, args.output, args.prependCalib))
89 
90  from AthenaCommon.Logging import log
91  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
92  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
93 
94  # Uncomment for debugging
95  # from AthenaCommon.Constants import DEBUG
96  # log.setLevel(DEBUG)
97 
98  args = flags.fillFromArgs(parser = parser)
99 
100  # This should run serially for the moment.
101  flags.Concurrency.NumThreads = 1
102  flags.Concurrency.NumConcurrentEvents = 1
103 
104  flags.dump()
105  log.debug('Lock config flags now.')
106  flags.lock()
107 
108  cfg = MainServicesCfg(flags)
109  cfg.merge(PoolReadCfg(flags))
110 
111  if flags.Detector.GeometryBpipe:
112  from BeamPipeGeoModel.BeamPipeGMConfig import BeamPipeGeometryCfg
113  cfg.merge(BeamPipeGeometryCfg(flags))
114 
115  if flags.Detector.GeometryPixel:
116  from PixelGeoModel.PixelGeoModelConfig import PixelReadoutGeometryCfg
117  cfg.merge(PixelReadoutGeometryCfg(flags))
118 
119  if flags.Detector.GeometrySCT:
120  from SCT_GeoModel.SCT_GeoModelConfig import SCT_ReadoutGeometryCfg
121  cfg.merge(SCT_ReadoutGeometryCfg(flags))
122 
123  if flags.Detector.GeometryTRT:
124  from TRT_GeoModel.TRT_GeoModelConfig import TRT_ReadoutGeometryCfg
125  cfg.merge(TRT_ReadoutGeometryCfg(flags))
126 
127  if flags.Detector.GeometryITkPixel:
128  from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg
129  cfg.merge(ITkPixelReadoutGeometryCfg(flags))
130 
131  if flags.Detector.GeometryITkStrip:
132  from StripGeoModelXml.ITkStripGeoModelConfig import ITkStripReadoutGeometryCfg
133  cfg.merge(ITkStripReadoutGeometryCfg(flags))
134 
135  if flags.Detector.GeometryLAr:
136  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
137  cfg.merge(LArGMCfg(flags))
138 
139  if flags.Detector.GeometryTile:
140  from TileGeoModel.TileGMConfig import TileGMCfg
141  cfg.merge(TileGMCfg(flags))
142 
143  if flags.Detector.GeometryMuon:
144  from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
145  cfg.merge(MuonGeoModelCfg(flags))
146 
147  from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg
148  cfg.merge(TrackCollectionReadCfg(flags, 'Tracks'))
149 
150  muon_edm_helper_svc = CompFactory.Muon.MuonEDMHelperSvc("MuonEDMHelperSvc")
151  cfg.addService(muon_edm_helper_svc)
152 
153  # Disable doExtrap if you would prefer not to use the extrapolator.
155  flags, doExtrap=True, doACTSEDM=False, OutputLevel=VERBOSE, DumpTestEvent=args.prependCalib, OutputLocation=args.output,
156  CscPrepRawDataKey = "CSC_Clusters" if flags.Detector.EnableCSC else "",
157  MMPrepRawDataKey = "MM_Measurements" if flags.Detector.EnableMM else "",
158  sTgcPrepRawDataKey = "STGC_Measurements" if flags.Detector.EnablesTGC else "",
159  )
160 
161  cfg.merge(topoAcc)
162 
163  cfg.run()
python.AtlasExtrapolationEngineConfig.AtlasExtrapolationEngineCfg
def AtlasExtrapolationEngineCfg(flags, name='Extrapolation', nameprefix='Atlas')
Definition: AtlasExtrapolationEngineConfig.py:14
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
BeamPipeGMConfig.BeamPipeGeometryCfg
def BeamPipeGeometryCfg(flags)
Definition: BeamPipeGMConfig.py:5
TRT_GeoModelConfig.TRT_ReadoutGeometryCfg
def TRT_ReadoutGeometryCfg(flags)
Definition: TRT_GeoModelConfig.py:55
SCT_GeoModelConfig.SCT_ReadoutGeometryCfg
def SCT_ReadoutGeometryCfg(flags)
Definition: SCT_GeoModelConfig.py:42
AlignmentAlgsConfig.ActsGeometryContextAlgCfg
def ActsGeometryContextAlgCfg(flags, name="GeometryContextAlg", **kwargs)
Setup the Geometry context algorithm.
Definition: AlignmentAlgsConfig.py:125
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
Constants
some useful constants -------------------------------------------------—
DumpEventDataToJSONConfig.DumpEventDataToJSONAlgCfg
def DumpEventDataToJSONAlgCfg(flags, doExtrap=False, doACTSEDM=True, **kwargs)
Definition: DumpEventDataToJSONConfig.py:8
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
PixelGeoModelConfig.PixelReadoutGeometryCfg
def PixelReadoutGeometryCfg(flags)
Definition: PixelGeoModelConfig.py:42
ITkPixelGeoModelConfig.ITkPixelReadoutGeometryCfg
def ITkPixelReadoutGeometryCfg(flags, setGeometryAlignable=False, setAlignmentFolderName="/Indet/Align")
Definition: ITkPixelGeoModelConfig.py:39
python.MuonGeometryConfig.MuonGeoModelCfg
def MuonGeoModelCfg(flags)
Definition: MuonGeometryConfig.py:28
ITkStripGeoModelConfig.ITkStripReadoutGeometryCfg
def ITkStripReadoutGeometryCfg(flags, setGeometryAlignable=False, setAlignmentFolderName="/Indet/Align")
Definition: ITkStripGeoModelConfig.py:39
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.TrackCollectionReadConfig.TrackCollectionReadCfg
def TrackCollectionReadCfg(flags, key)
Definition: TrackCollectionReadConfig.py:28
python.GeoModelConfig.GeoModelCfg
def GeoModelCfg(flags)
Definition: GeoModelConfig.py:16
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7