Skip to content
Snippets Groups Projects
Commit cfbcce92 authored by Edward Moyse's avatar Edward Moyse Committed by Walter Lampl
Browse files

DumpEventDataToJSON: Add support for NSW.

DumpEventDataToJSON: Add support for NSW.
parent 7d90fc5d
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ def DumpEventDataToJSONAlgCfg(configFlags, doExtrap=False, **kwargs):
if __name__ == "__main__":
# Run this with python -m DumpEventDataToJSON.DumpEventDataToJSONConfig myESD.pool.root
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("input",
......@@ -113,10 +114,15 @@ if __name__ == "__main__":
# Disable doExtrap if you would prefer not to use the extrapolator.
topoAcc = DumpEventDataToJSONAlgCfg(
ConfigFlags, doExtrap=False, OutputLevel=VERBOSE, DumpTestEvent=args.prependCalib, OutputLocation=args.output)
ConfigFlags, doExtrap=False, OutputLevel=VERBOSE, DumpTestEvent=args.prependCalib, OutputLocation=args.output,
CscPrepRawDataKey = "CSC_Clusters" if ConfigFlags.Detector.EnableCSC else "",
MMPrepRawDataKey = "MM_Measurements" if ConfigFlags.Detector.EnableMM else "",
sTgcPrepRawDataKey = "sTgcPrepRawDataKey" if ConfigFlags.Detector.EnablesTGC else "",
)
cfg.merge(topoAcc)
cfg.run(10)
cfg.run(2)
f = open("DumpEventDataToJSONConfig.pkl", "wb")
cfg.store(f)
f.close()
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "GaudiKernel/MsgStream.h"
......@@ -29,13 +29,24 @@ StatusCode DumpEventDataToJsonAlg::initialize()
ATH_CHECK(m_muonKeys.initialize());
ATH_CHECK(m_trackCollectionKeys.initialize());
ATH_CHECK(m_cscPrepRawDataKey.initialize());
ATH_CHECK(m_mdtPrepRawDataKey.initialize());
ATH_CHECK(m_rpcPrepRawDataKey.initialize());
ATH_CHECK(m_tgcPrepRawDataKey.initialize());
ATH_CHECK(m_pixelPrepRawDataKey.initialize());
ATH_CHECK(m_sctPrepRawDataKey.initialize());
ATH_CHECK(m_trtPrepRawDataKey.initialize());
if (!m_cscPrepRawDataKey.empty())
ATH_CHECK(m_cscPrepRawDataKey.initialize());
if (!m_mdtPrepRawDataKey.empty())
ATH_CHECK(m_mdtPrepRawDataKey.initialize());
if (!m_tgcPrepRawDataKey.empty())
ATH_CHECK(m_tgcPrepRawDataKey.initialize());
if (!m_rpcPrepRawDataKey.empty())
ATH_CHECK(m_rpcPrepRawDataKey.initialize());
if (!m_mmPrepRawDataKey.empty())
ATH_CHECK(m_mmPrepRawDataKey.initialize());
if (!m_stgcPrepRawDataKey.empty())
ATH_CHECK(m_stgcPrepRawDataKey.initialize());
if (!m_pixelPrepRawDataKey.empty())
ATH_CHECK(m_pixelPrepRawDataKey.initialize());
if (!m_sctPrepRawDataKey.empty())
ATH_CHECK(m_sctPrepRawDataKey.initialize());
if (!m_trtPrepRawDataKey.empty())
ATH_CHECK(m_trtPrepRawDataKey.initialize());
if (m_extrapolateTrackParticless)
......@@ -99,7 +110,8 @@ void DumpEventDataToJsonAlg::prependTestEvent()
nlohmann::json j;
// FIXME - this
auto writeEtaPhiLabel = [](float eta, float phi) { return std::to_string(eta) + "/" + std::to_string(phi); };
auto writeEtaPhiLabel = [](float eta, float phi)
{ return std::to_string(eta) + "/" + std::to_string(phi); };
j["event number"] = 999;
j["run number"] = 999;
......@@ -155,7 +167,7 @@ void DumpEventDataToJsonAlg::prependTestEvent()
template <class TYPE>
StatusCode DumpEventDataToJsonAlg::getAndFillArrayOfContainers(nlohmann::json &event,
const SG::ReadHandleKeyArray<TYPE> &keys,
const std::string& jsonType)
const std::string &jsonType)
{
for (SG::ReadHandle<TYPE> handle : keys.makeHandles())
{
......@@ -191,8 +203,8 @@ nlohmann::json DumpEventDataToJsonAlg::getData(const xAOD::CaloCluster &clust)
data["phi"] = clust.phi();
data["eta"] = clust.eta();
data["energy"] = clust.e();
//data["etaSize"] = clust.getClusterEtaSize(); // empty
//data["phiSize"] = clust.getClusterPhiSize(); // empty
// data["etaSize"] = clust.getClusterEtaSize(); // empty
// data["phiSize"] = clust.getClusterPhiSize(); // empty
return data;
}
......@@ -204,8 +216,8 @@ nlohmann::json DumpEventDataToJsonAlg::getData(const CaloCell &cell)
data["phi"] = cell.phi();
data["eta"] = cell.eta();
data["energy"] = cell.e();
//data["etaSize"] = clust.getClusterEtaSize(); // empty
//data["phiSize"] = clust.getClusterPhiSize(); // empty
// data["etaSize"] = clust.getClusterEtaSize(); // empty
// data["phiSize"] = clust.getClusterPhiSize(); // empty
return data;
}
......@@ -360,18 +372,21 @@ StatusCode DumpEventDataToJsonAlg::finalize()
template <class TYPE>
StatusCode DumpEventDataToJsonAlg::getAndFillContainer(nlohmann::json &event,
const SG::ReadHandleKey<TYPE> &key,
const std::string& jsonType)
const std::string &jsonType)
{
SG::ReadHandle<TYPE> handle(key);
if (key.empty())
return StatusCode::SUCCESS;
SG::ReadHandle<TYPE> handle(key);
ATH_MSG_VERBOSE("Trying to load " << handle.key());
ATH_CHECK(handle.isValid());
ATH_MSG_VERBOSE("Got back " << handle->size());
ATH_MSG_VERBOSE("Trying to load " << handle.key());
ATH_CHECK(handle.isValid());
ATH_MSG_VERBOSE("Got back " << handle->size());
nlohmann::json tmp = getData(*handle);
event[jsonType][handle.key()]=tmp;
nlohmann::json tmp = getData(*handle);
event[jsonType][handle.key()] = tmp;
return StatusCode::SUCCESS;
return StatusCode::SUCCESS;
}
// Generic PRD
......@@ -380,8 +395,10 @@ nlohmann::json DumpEventDataToJsonAlg::getData(const TYPE &container)
{
nlohmann::json colldata;
for (const auto& coll : container ) {
for (const auto& prd : *coll ) {
for (const auto &coll : container)
{
for (const auto &prd : *coll)
{
nlohmann::json data;
data["pos"] = {prd->globalPosition().x(), prd->globalPosition().y(), prd->globalPosition().z()};
Identifier id = prd->identify();
......@@ -392,4 +409,3 @@ nlohmann::json DumpEventDataToJsonAlg::getData(const TYPE &container)
return colldata;
}
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef DUMPEVENTDATATOJSONALG_H
......@@ -28,8 +28,8 @@
#include <vector>
#include <map>
/** Algorithm to dump some Event data to JSON.
*/
/** Algorithm to dump some Event data to JSON.
*/
class DumpEventDataToJsonAlg : public AthAlgorithm
{
public:
......@@ -48,12 +48,12 @@ protected:
void prependTestEvent();
template <class TYPE>
StatusCode getAndFillArrayOfContainers(nlohmann::json &event, const SG::ReadHandleKeyArray<TYPE> &keys, const std::string& jsonType);
StatusCode getAndFillArrayOfContainers(nlohmann::json &event, const SG::ReadHandleKeyArray<TYPE> &keys, const std::string &jsonType);
template <class TYPE>
StatusCode getAndFillContainer(nlohmann::json &event,
const SG::ReadHandleKey<TYPE> &key,
const std::string& jsonType);
const std::string &jsonType);
template <class TYPE>
nlohmann::json getData(const TYPE &object);
......@@ -78,6 +78,8 @@ protected:
SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_mdtPrepRawDataKey{this, "MdtPrepRawDataKey", "MDT_DriftCircles", "Key for MDT PRD Container"};
SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_rpcPrepRawDataKey{this, "RpcPrepRawDataKey", "RPC_Measurements", "Key for RPC PRD Container"};
SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrepRawDataKey{this, "TgcPrepRawDataKey", "TGC_MeasurementsAllBCs", "Key for TGC PRD Container"};
SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_mmPrepRawDataKey{this, "MMPrepRawDataKey", "MM_Measurements", "Key for MM PRD Container"};
SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_stgcPrepRawDataKey{this, "sTgcPrepRawDataKey", "STGC_Measurements", "Key for sTGC PRD Container"};
SG::ReadHandleKey<InDet::PixelClusterContainer> m_pixelPrepRawDataKey{this, "PixelPrepRawDataKey", "PixelClusters", "Key for Pixel PRD Container"};
SG::ReadHandleKey<InDet::SCT_ClusterContainer> m_sctPrepRawDataKey{this, "SctPrepRawDataKey", "SCT_Clusters", "Key for SCT PRD Container"};
SG::ReadHandleKey<InDet::TRT_DriftCircleContainer> m_trtPrepRawDataKey{this, "TrtPrepRawDataKey", "TRT_DriftCircles", "Key for TRT PRD Container"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment