ATLAS Offline Software
DumpEventDataToJsonAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef DUMPEVENTDATATOJSONALG_H
6 #define DUMPEVENTDATATOJSONALG_H
7 
8 // Core
10 #include "GaudiKernel/ToolHandle.h"
12 //EDM
15 #include "xAODJet/JetContainer.h"
16 #include "xAODMuon/MuonContainer.h"
23 //Tools
26 // PRDs
36 // ACTS
40 // Misc
41 #include <nlohmann/json.hpp>
42 #include <string>
43 #include <vector>
44 #include <map>
45 
46 
50 {
51 public:
53  DumpEventDataToJsonAlg(const std::string &name, ISvcLocator *pService);
54 
55  virtual ~DumpEventDataToJsonAlg() = default;
56 
58  virtual StatusCode initialize() override;
59  virtual StatusCode execute() override;
60  virtual StatusCode finalize() override;
61 
62 protected:
64  void prependTestEvent();
65 
66  template <class TYPE>
68 
69  template <class TYPE>
72  const std::string &jsonType);
73  template <class TYPE>
74  nlohmann::json getData(const TYPE &object);
75 
76  nlohmann::json getActsData(const Acts::TrackProxy<ActsTrk::TrackSummaryContainer, ActsTrk::MultiTrajectory, ActsTrk::DataLinkHolder, true> &track,
77  const Acts::GeometryContext& gctx);
78 
79 
80  template <class TYPE>
81  void addLink(const TYPE &link, nlohmann::json &data);
82 
83  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "EventInfoKey", "EventInfo", "Key for the Event Info"};
84 
85  SG::ReadHandleKeyArray<xAOD::TrackParticleContainer> m_trackParticleKeys{this, "TrackParticleContainerKeys", {"InDetTrackParticles", "CombinedMuonTrackParticles"}, "Keys for TrackParticle Containers"};
86 
87  SG::ReadHandleKeyArray<xAOD::JetContainer> m_jetKeys{this, "JetContainerKeys", {"AntiKt4EMTopoJets"}, "Keys for Jet Containers"};
88 
89  SG::ReadHandleKeyArray<xAOD::MuonContainer> m_muonKeys{this, "MuonContainerKeys", {"Muons"}, "Keys for Muon Containers"};
90 
91  SG::ReadHandleKeyArray<xAOD::TauJetContainer> m_tauJetKeys{this, "TauJetContainerKeys", {"TauJets"}, "Keys for Tau Containers"};
92 
93  SG::ReadHandleKeyArray<xAOD::ElectronContainer> m_electronKeys{this, "ElectronContainerKeys", {"Electrons"}, "Keys for Electron Containers"};
94 
95  SG::ReadHandleKeyArray<xAOD::PhotonContainer> m_photonKeys{this, "PhotonContainerKeys", {"Photons"}, "Keys for Photon Containers"};
96 
97  SG::ReadHandleKeyArray<xAOD::CaloClusterContainer> m_caloClustersKeys{this, "CaloClusterContainerKeys", {"CaloCalTopoClusters"}, "Keys for CaloClusters Containers"};
98 
99  SG::ReadHandleKeyArray<CaloCellContainer> m_caloCellKey{this, "CaloCellContainerKey", {"AllCalo"}, "Key for CaloCell Container"};
100 
101  SG::ReadHandleKeyArray<TrackCollection> m_trackCollectionKeys{this, "TrackCollectionKeys", {"CombinedInDetTracks", "CombinedMuonTracks", "MuonSpectrometerTracks"}, "Keys for Track Containers"};
102 
103  // ACTS TrackContainer keys
104  SG::ReadHandleKeyArray<ActsTrk::TrackContainer> m_trackContainerKeys{this, "TrackContainerKeys", {"ConvertedTracks"}, "Location of the converted Acts TrackContainer"};
105 
106  SG::ReadHandleKey<Muon::CscPrepDataContainer> m_cscPrepRawDataKey{this, "CscPrepRawDataKey", "CSC_Clusters", "Key for CSC PRD Container"};
107  SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_mdtPrepRawDataKey{this, "MdtPrepRawDataKey", "MDT_DriftCircles", "Key for MDT PRD Container"};
108  SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_rpcPrepRawDataKey{this, "RpcPrepRawDataKey", "RPC_Measurements", "Key for RPC PRD Container"};
109  SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrepRawDataKey{this, "TgcPrepRawDataKey", "TGC_MeasurementsAllBCs", "Key for TGC PRD Container"};
110  SG::ReadHandleKey<Muon::MMPrepDataContainer> m_mmPrepRawDataKey{this, "MMPrepRawDataKey", "MM_Measurements", "Key for MM PRD Container"};
111  SG::ReadHandleKey<Muon::sTgcPrepDataContainer> m_stgcPrepRawDataKey{this, "sTgcPrepRawDataKey", "STGC_Measurements", "Key for sTGC PRD Container"};
112  SG::ReadHandleKey<InDet::PixelClusterContainer> m_pixelPrepRawDataKey{this, "PixelPrepRawDataKey", "PixelClusters", "Key for Pixel PRD Container"};
113  SG::ReadHandleKey<InDet::SCT_ClusterContainer> m_sctPrepRawDataKey{this, "SctPrepRawDataKey", "SCT_Clusters", "Key for SCT PRD Container"};
114  SG::ReadHandleKey<InDet::TRT_DriftCircleContainer> m_trtPrepRawDataKey{this, "TrtPrepRawDataKey", "TRT_DriftCircles", "Key for TRT PRD Container"};
115 
116  ToolHandle<Trk::IExtrapolationEngine> m_extrapolator{this, "Extrapolator", "Trk::ExtrapolationEngine/AtlasExtrapolation"};
117 
119  this, "ActsAlignmentKey", "ActsAlignment", "cond read key for the alignment"};
120 
121  Gaudi::Property<std::string> m_outputJSON_Name{this, "OutputLocation", "EventData.json", "Default filename for "};
122 
123  Gaudi::Property<bool> m_dumpTestEvent{this, "DumpTestEvent", false, "If true, prepend a test event with some calibration data in it."};
124  Gaudi::Property<bool> m_physlite{this, "PHYSLITE", false, "If true, do not try to access data which is not available in PHYSLITE files."};
125 
127 };
128 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
DumpEventDataToJsonAlg::initialize
virtual StatusCode initialize() override
inherited from Algorithm
Definition: DumpEventDataToJsonAlg.cxx:34
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
DumpEventDataToJsonAlg::m_geometryContextKey
SG::ReadHandleKey< ActsGeometryContext > m_geometryContextKey
Definition: DumpEventDataToJsonAlg.h:118
json
nlohmann::json json
Definition: HistogramDef.cxx:9
ActsGeometryContext.h
DumpEventDataToJsonAlg::m_extrapolator
ToolHandle< Trk::IExtrapolationEngine > m_extrapolator
Definition: DumpEventDataToJsonAlg.h:116
DumpEventDataToJsonAlg::m_stgcPrepRawDataKey
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_stgcPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:111
DumpEventDataToJsonAlg::m_trackCollectionKeys
SG::ReadHandleKeyArray< TrackCollection > m_trackCollectionKeys
Definition: DumpEventDataToJsonAlg.h:101
DumpEventDataToJsonAlg::m_pixelPrepRawDataKey
SG::ReadHandleKey< InDet::PixelClusterContainer > m_pixelPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:112
DumpEventDataToJsonAlg::getAndFillArrayOfContainers
StatusCode getAndFillArrayOfContainers(nlohmann::json &event, const SG::ReadHandleKeyArray< TYPE > &keys, const std::string &jsonType)
Definition: DumpEventDataToJsonAlg.cxx:263
DumpEventDataToJsonAlg::m_rpcPrepRawDataKey
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_rpcPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:108
DumpEventDataToJsonAlg::m_trtPrepRawDataKey
SG::ReadHandleKey< InDet::TRT_DriftCircleContainer > m_trtPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:114
DumpEventDataToJsonAlg
Algorithm to dump some Event data to JSON.
Definition: DumpEventDataToJsonAlg.h:50
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
MMPrepDataContainer.h
RpcPrepDataContainer.h
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
DumpEventDataToJsonAlg::prependTestEvent
void prependTestEvent()
Dumps a dummy event with some objects at specific eta/phi coordinates for calibration.
Definition: DumpEventDataToJsonAlg.cxx:203
DumpEventDataToJsonAlg::finalize
virtual StatusCode finalize() override
Definition: DumpEventDataToJsonAlg.cxx:486
DumpEventDataToJsonAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: DumpEventDataToJsonAlg.h:83
sTgcPrepDataContainer.h
DumpEventDataToJsonAlg::m_trackContainerKeys
SG::ReadHandleKeyArray< ActsTrk::TrackContainer > m_trackContainerKeys
Definition: DumpEventDataToJsonAlg.h:104
DumpEventDataToJsonAlg::m_tgcPrepRawDataKey
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_tgcPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:109
AthAlgorithm.h
MdtPrepDataContainer.h
DumpEventDataToJsonAlg::m_mmPrepRawDataKey
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_mmPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:110
DumpEventDataToJsonAlg::m_tauJetKeys
SG::ReadHandleKeyArray< xAOD::TauJetContainer > m_tauJetKeys
Definition: DumpEventDataToJsonAlg.h:91
DumpEventDataToJsonAlg::m_dumpTestEvent
Gaudi::Property< bool > m_dumpTestEvent
Definition: DumpEventDataToJsonAlg.h:123
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
ElectronContainer.h
DumpEventDataToJsonAlg::m_jetKeys
SG::ReadHandleKeyArray< xAOD::JetContainer > m_jetKeys
Definition: DumpEventDataToJsonAlg.h:87
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TgcPrepDataContainer.h
TrackCollection.h
DumpEventDataToJsonAlg::m_outputJSON_Name
Gaudi::Property< std::string > m_outputJSON_Name
Definition: DumpEventDataToJsonAlg.h:121
DumpEventDataToJsonAlg::m_sctPrepRawDataKey
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_sctPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:113
DumpEventDataToJsonAlg::m_mdtPrepRawDataKey
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_mdtPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:107
TauJetContainer.h
DumpEventDataToJsonAlg::m_eventData
nlohmann::json m_eventData
Definition: DumpEventDataToJsonAlg.h:126
AthAlgorithm
Definition: AthAlgorithm.h:47
TRT_DriftCircleContainer.h
TYPE
#define TYPE(CODE, TYP, IOTYP)
DumpEventDataToJsonAlg::getAndFillContainer
StatusCode getAndFillContainer(nlohmann::json &event, const SG::ReadHandleKey< TYPE > &key, const std::string &jsonType)
Definition: DumpEventDataToJsonAlg.cxx:497
DumpEventDataToJsonAlg::execute
virtual StatusCode execute() override
Definition: DumpEventDataToJsonAlg.cxx:135
CscPrepDataContainer.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DumpEventDataToJsonAlg::addLink
void addLink(const TYPE &link, nlohmann::json &data)
Definition: DumpEventDataToJsonAlg.cxx:480
PixelClusterContainer.h
DumpEventDataToJsonAlg::m_caloClustersKeys
SG::ReadHandleKeyArray< xAOD::CaloClusterContainer > m_caloClustersKeys
Definition: DumpEventDataToJsonAlg.h:97
DumpEventDataToJsonAlg::getData
nlohmann::json getData(const TYPE &object)
Definition: DumpEventDataToJsonAlg.cxx:521
DumpEventDataToJsonAlg::m_cscPrepRawDataKey
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_cscPrepRawDataKey
Definition: DumpEventDataToJsonAlg.h:106
DumpEventDataToJsonAlg::m_physlite
Gaudi::Property< bool > m_physlite
Definition: DumpEventDataToJsonAlg.h:124
DumpEventDataToJsonAlg::DumpEventDataToJsonAlg
DumpEventDataToJsonAlg(const std::string &name, ISvcLocator *pService)
Algorithm constructor.
Definition: DumpEventDataToJsonAlg.cxx:30
CaloCellContainer.h
DumpEventDataToJsonAlg::m_electronKeys
SG::ReadHandleKeyArray< xAOD::ElectronContainer > m_electronKeys
Definition: DumpEventDataToJsonAlg.h:93
EventInfo.h
MuonContainer.h
MultiTrajectory.h
DumpEventDataToJsonAlg::getActsData
nlohmann::json getActsData(const Acts::TrackProxy< ActsTrk::TrackSummaryContainer, ActsTrk::MultiTrajectory, ActsTrk::DataLinkHolder, true > &track, const Acts::GeometryContext &gctx)
Definition: DumpEventDataToJsonAlg.cxx:80
DumpEventDataToJsonAlg::m_photonKeys
SG::ReadHandleKeyArray< xAOD::PhotonContainer > m_photonKeys
Definition: DumpEventDataToJsonAlg.h:95
JetContainer.h
DumpEventDataToJsonAlg::~DumpEventDataToJsonAlg
virtual ~DumpEventDataToJsonAlg()=default
SCT_ClusterContainer.h
DumpEventDataToJsonAlg::m_caloCellKey
SG::ReadHandleKeyArray< CaloCellContainer > m_caloCellKey
Definition: DumpEventDataToJsonAlg.h:99
CaloClusterContainer.h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
IExtrapolationEngine.h
PhotonContainer.h
TrackContainer.h
TrackParticleContainer.h
DumpEventDataToJsonAlg::m_trackParticleKeys
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_trackParticleKeys
Definition: DumpEventDataToJsonAlg.h:85
IActsTrackingGeometryTool.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
DumpEventDataToJsonAlg::m_muonKeys
SG::ReadHandleKeyArray< xAOD::MuonContainer > m_muonKeys
Definition: DumpEventDataToJsonAlg.h:89