Skip to content
Snippets Groups Projects
Commit d47b797a authored by scott snyder's avatar scott snyder
Browse files

DataModelTestDataRead: Update to support tests reading and writing to RNTuple.

Make ViewVector tests optional.
parent 495a7a01
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file DataModelTestDataRead/src/xAODTestReadHVec.cxx
* @author snyder@bnl.gov
......@@ -25,38 +23,15 @@
namespace DMTest {
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestReadHVec::xAODTestReadHVec (const std::string &name,
ISvcLocator *pSvcLocator)
: AthReentrantAlgorithm (name, pSvcLocator),
m_hvecKey ("hvec"),
m_hviewKey ("hview"),
m_vecWriteKey (""),
m_viewWriteKey ("")
{
declareProperty ("HVecKey", m_hvecKey);
declareProperty ("HViewKey", m_hviewKey);
declareProperty ("VecWriteKey", m_vecWriteKey);
declareProperty ("ViewWriteKey", m_viewWriteKey);
}
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
StatusCode xAODTestReadHVec::initialize()
{
ATH_CHECK( m_hvecKey.initialize() );
if (!m_hviewKey.key().empty())
ATH_CHECK( m_hviewKey.initialize() );
if (!m_vecWriteKey.key().empty())
ATH_CHECK( m_vecWriteKey.initialize() );
if (!m_viewWriteKey.key().empty())
ATH_CHECK( m_viewWriteKey.initialize() );
ATH_CHECK( m_hviewKey.initialize(SG::AllowEmpty) );
ATH_CHECK( m_vecWriteKey.initialize(SG::AllowEmpty) );
ATH_CHECK( m_viewWriteKey.initialize(SG::AllowEmpty) );
return StatusCode::SUCCESS;
}
......@@ -73,7 +48,8 @@ StatusCode xAODTestReadHVec::execute (const EventContext& ctx) const
ost1 << " " << h->aFloat();
ATH_MSG_INFO (ost1.str());
if (const DMTest::HVec* hview = SG::get (m_hviewKey, ctx)) {
if (!m_hviewKey.empty()) {
const DMTest::HVec* hview = SG::get (m_hviewKey, ctx);
std::ostringstream ost2;
ost2 << m_hviewKey.key() << ":";
for (const H* h : *hview)
......@@ -105,14 +81,5 @@ StatusCode xAODTestReadHVec::execute (const EventContext& ctx) const
}
/**
* @brief Algorithm finalization; called at the end of the job.
*/
StatusCode xAODTestReadHVec::finalize()
{
return StatusCode::SUCCESS;
}
} // namespace DMTest
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file src/xAODTestReadHVec.h
* @author scott snyder <snyder@bnl.gov>
......@@ -34,12 +31,7 @@ class xAODTestReadHVec
: public AthReentrantAlgorithm
{
public:
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestReadHVec (const std::string &name, ISvcLocator *pSvcLocator);
using AthReentrantAlgorithm::AthReentrantAlgorithm;
/**
......@@ -54,17 +46,15 @@ public:
virtual StatusCode execute (const EventContext& ctx) const override;
/**
* @brief Algorithm finalization; called at the end of the job.
*/
virtual StatusCode finalize() override;
private:
SG::ReadHandleKey<DMTest::HVec> m_hvecKey;
SG::ReadHandleKey<DMTest::HVec> m_hviewKey;
SG::WriteHandleKey<DMTest::HVec> m_vecWriteKey;
SG::WriteHandleKey<DMTest::HView> m_viewWriteKey;
SG::ReadHandleKey<DMTest::HVec> m_hvecKey
{ this, "HVecKey", "hvec" };
SG::ReadHandleKey<DMTest::HVec> m_hviewKey
{ this, "HViewKey", "hview" };
SG::WriteHandleKey<DMTest::HVec> m_vecWriteKey
{ this, "VecWriteKey", "" };
SG::WriteHandleKey<DMTest::HView> m_viewWriteKey
{ this, "ViewWriteKey", "" };
};
......
......@@ -47,29 +47,6 @@
namespace DMTest {
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestTypelessRead::xAODTestTypelessRead (const std::string &name,
ISvcLocator *pSvcLocator)
: AthAlgorithm (name, pSvcLocator),
m_count(0)
{
declareProperty ("WritePrefix", m_writePrefix);
}
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
StatusCode xAODTestTypelessRead::initialize()
{
return StatusCode::SUCCESS;
}
namespace {
......@@ -341,7 +318,7 @@ void copy (DMTest::PLinks& to, const DMTest::PLinks& from)
template <class OBJ, class AUX>
StatusCode
xAODTestTypelessRead::testit (const char* key)
xAODTestTypelessRead::testit (const std::string& key)
{
const OBJ* obj = nullptr;
CHECK( evtStore()->retrieve (obj, key) );
......@@ -380,7 +357,7 @@ xAODTestTypelessRead::testit (const char* key)
template <class OBJ>
StatusCode
xAODTestTypelessRead::testit_view (const char* key)
xAODTestTypelessRead::testit_view (const std::string& key)
{
const OBJ* obj = nullptr;
CHECK( evtStore()->retrieve (obj, key) );
......@@ -413,10 +390,16 @@ StatusCode xAODTestTypelessRead::execute()
CHECK(( testit<C, CInfoAuxContainer> ("cinfo") ));
CHECK(( testit<CVec, CTrigAuxContainer> ("ctrig") ));
CHECK(( testit<CVecWithData, CAuxContainer> ("cvecWD") ));
CHECK(( testit_view<CView> ("cview") ));
CHECK(( testit<PVec, PAuxContainer> ("pvec") ));
if (!m_cviewKey.empty()) {
CHECK(( testit_view<CView> (m_cviewKey) ));
}
if (!m_pvecKey.empty()) {
CHECK(( testit<PVec, PAuxContainer> (m_pvecKey) ));
}
CHECK(( testit<HVec, HAuxContainer> ("hvec") ));
CHECK(( testit_view<HView> ("hview") ));
if (!m_hviewKey.empty()) {
CHECK(( testit_view<HView> (m_hviewKey) ));
}
CHECK(( testit<JVecContainer, JVecAuxContainer> ("jvecContainer") ));
CHECK(( testit<JVec, JVecAuxInfo> ("jvecInfo") ));
CHECK(( testit<PLinksContainer, PLinksAuxContainer> ("plinksContainer") ));
......@@ -426,14 +409,5 @@ StatusCode xAODTestTypelessRead::execute()
}
/**
* @brief Algorithm finalization; called at the end of the job.
*/
StatusCode xAODTestTypelessRead::finalize()
{
return StatusCode::SUCCESS;
}
} // namespace DMTest
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file src/xAODTestTypelessRead.h
* @author scott snyder <snyder@bnl.gov>
......@@ -30,18 +27,7 @@ class xAODTestTypelessRead
: public AthAlgorithm
{
public:
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestTypelessRead (const std::string &name, ISvcLocator *pSvcLocator);
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
virtual StatusCode initialize();
using AthAlgorithm::AthAlgorithm;
/**
......@@ -50,24 +36,26 @@ public:
virtual StatusCode execute();
/**
* @brief Algorithm finalization; called at the end of the job.
*/
virtual StatusCode finalize();
private:
template <class OBJ, class AUX>
StatusCode testit (const char* key);
StatusCode testit (const std::string& key);
template <class OBJ>
StatusCode testit_view (const char* key);
/// Parameter: Prefix for names written to SG. Null for no write.
std::string m_writePrefix;
StatusCode testit_view (const std::string& key);
/// Event counter.
int m_count;
int m_count = 0;
/// Prefix for names written to SG. Null for no write.
StringProperty m_writePrefix
{ this, "WritePrefix", "cview", "" };
StringProperty m_cviewKey
{ this, "CViewKey", "cview", "" };
StringProperty m_pvecKey
{ this, "PVecKey", "pvec", "" };
StringProperty m_hviewKey
{ this, "HViewKey", "hview", "" };
};
......
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