Skip to content
Snippets Groups Projects
Commit 9715ff4d authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

CMakeLists.txt: Remove reference to CLHEP_INCLUDE_DIRS. (DataModelTestDataRead-01-03-41)

	* Tagging DataModelTestDataRead-01-03-41.
	* CMakeLists.txt: Remove reference to CLHEP_INCLUDE_DIRS.

2016-11-22  scott snyder  <snyder@bnl.gov>

	* Tagging DataModelTestDataRead-01-03-40.
	* Turn on hideErrorLocus.

2016-11-15  scott snyder  <snyder@bnl.gov>

	* Tagging DataModelTestDataRead-01-03-39.
	* Make HLTResultReader non-reentrant, since it has to call the
	non-const method NavigationCore::prepare().

2016-10-12  scott snyder  <snyder@bnl.gov>

	* Tagging DataModelTestDataRead-01-03-38.
	* CMakeLists.txt: Link library list fix.

...
(Long ChangeLog diff - truncated)
parent 64491fb6
No related branches found
No related tags found
No related merge requests found
Showing
with 705 additions and 176 deletions
......@@ -49,3 +49,9 @@ atlas_add_dictionary( DataModelTestDataReadDict
EXTRA_FILES src/dict/*.cxx
ELEMENT_LINKS DataVector<DMTest::B> )
atlas_add_sercnv_library ( DataModelTestDataReadSerCnv
FILES DataModelTestDataRead/HVec.h DataModelTestDataRead/HView.h DataModelTestDataRead/HAuxContainer.h
TYPES_WITH_NAMESPACE DMTest::HVec DMTest::HView DMTest::HAuxContainer
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers SGTools xAODCore xAODTrigger GaudiKernel AthLinks TrigSerializeCnvSvcLib DataModelTestDataCommon DataModelTestDataReadLib )
......@@ -51,3 +51,15 @@ apply_pattern lcgdict dict=DataModelTestDataRead selectionfile=selection.xml\
elementLinks="$(elemLinks_DataModelTestDataRead)" \
extralibfiles=../src/dict/*.cxx
private
use TrigSerializeUtils TrigSerializeUtils-* Trigger/TrigDataAccess
apply_tag no_merge_componentslist
apply_pattern sercnv \
typesWithNamespace="DMTest::HVec DMTest::HView DMTest::HAuxContainer" \
files=" -s=${DataModelTestDataRead_root}/DataModelTestDataRead \
HVec.h HView.h HAuxContainer.h "
......@@ -81,52 +81,58 @@ StatusCode AuxDataTestRead::execute()
const BAuxVec* vec = 0;
CHECK( evtStore()->retrieve (vec, m_readPrefix + "bauxvec") );
// Use a temp sstream to prevent output being disrupted by logging
// messages generated by EL dereferences.
std::ostringstream ost;
// Ordering of auxid is not reliable. Sort by name.
std::vector<std::string> names;
for (SG::auxid_t auxid : vec->getAuxIDs())
names.push_back (r.getName(auxid));
std::sort (names.begin(), names.end());
for (const std::string& n : names)
std::cout << n << " ";
std::cout << "\n";
ost << n << " ";
ost << "\n";
for (const BAux* belt : *vec) {
std::cout << " anInt1: " << anInt1(*belt)
ost << " anInt1: " << anInt1(*belt)
<< " aFloat1: " << aFloat1(*belt)
<< " pInt: " << pInt(*belt)
<< " pFloat: " << CxxUtils::strformat ("%.2f", pFloat(*belt))
<< " aB: " << aB(*belt).m_x
<< " dFloat1: " << dFloat1(*belt);
if (dInt1.isAvailable(*belt))
std::cout << " dInt1: " << dInt1(*belt);
ost << " dInt1: " << dInt1(*belt);
if (dInt2.isAvailable(*belt))
std::cout << " dInt2: " << dInt2(*belt);
std::cout << "\n";
ost << " dInt2: " << dInt2(*belt);
ost << "\n";
const std::vector<int>& pvi = pvint(*belt);
std::cout << " pvInt: [";
ost << " pvInt: [";
for (auto ii : pvi)
std::cout << ii << " ";
std::cout << "]\n";
ost << ii << " ";
ost << "]\n";
const std::vector<float>& pvf = pvfloat(*belt);
std::cout << " pvFloat: [";
ost << " pvFloat: [";
for (auto ii : pvf)
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]\n";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]\n";
}
const BAux* b = 0;
CHECK( evtStore()->retrieve (b, m_readPrefix + "b") );
std::cout << "b anInt1: " << anInt1(*b)
ost << "b anInt1: " << anInt1(*b)
<< " aFloat1: " << CxxUtils::strformat ("%.1f", aFloat1(*b))
<< " anEL: " << anEL(*b).dataID() << "[" << anEL(*b).index() << "]"
<< " aB: " << aB(*b).m_x
<< " dFloat1: " << dFloat1(*b);
if (dInt1.isAvailable(*b))
std::cout << " dInt1: " << dInt1(*b);
ost << " dInt1: " << dInt1(*b);
if (dInt2.isAvailable(*b))
std::cout << " dInt2: " << dInt2(*b);
std::cout << "\n";
ost << " dInt2: " << dInt2(*b);
ost << "\n";
std::cout << ost.str();
if (!m_writePrefix.empty()) {
// Passing this as the third arg of record will make the object const.
......
......@@ -26,6 +26,7 @@
#include "GaudiKernel/System.h"
#include <map>
#include <memory>
#include <sstream>
namespace DMTest {
......@@ -57,67 +58,67 @@ StatusCode AuxDataTestTypelessRead::initialize()
namespace {
void dumpAuxItem (SG::auxid_t auxid, const SG::AuxVectorData& c, size_t i)
void dumpAuxItem (std::ostream& ost, SG::auxid_t auxid, const SG::AuxVectorData& c, size_t i)
{
const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
const std::type_info* ti = r.getType(auxid);
std::string head = r.getName(auxid) + ": ";
if (ti == &typeid(int))
std::cout << head << c.getData<int> (auxid, i) << "; ";
ost << head << c.getData<int> (auxid, i) << "; ";
else if (ti == &typeid(float))
std::cout << head << CxxUtils::strformat ("%.3f", c.getData<float> (auxid, i)) << "; ";
ost << head << CxxUtils::strformat ("%.3f", c.getData<float> (auxid, i)) << "; ";
else if (ti == &typeid(ElementLink<DMTest::BAuxVec>)) {
const ElementLink<DMTest::BAuxVec>& el =
c.getData<ElementLink<DMTest::BAuxVec> > (auxid, i);
std::cout << head << el.dataID() << "[" << el.index() << "]; ";
ost << head << el.dataID() << "[" << el.index() << "]; ";
}
else if (ti == &typeid(DMTest::B)) {
std::cout << head << c.getData<B>(auxid, i).m_x << "; ";
ost << head << c.getData<B>(auxid, i).m_x << "; ";
}
#if 0
else if (ti == &typeid(SG::PackedElement<unsigned int>))
std::cout << head << c.getData<SG::PackedElement<unsigned int> > (auxid, i) << "; ";
ost << head << c.getData<SG::PackedElement<unsigned int> > (auxid, i) << "; ";
#endif
else if (ti == &typeid(unsigned int))
std::cout << head << c.getData<unsigned int> (auxid, i) << "; ";
ost << head << c.getData<unsigned int> (auxid, i) << "; ";
#if 0
else if (ti == &typeid(SG::PackedElement<float>))
std::cout << head << c.getData<SG::PackedElement<float> > (auxid, i) << "; ";
ost << head << c.getData<SG::PackedElement<float> > (auxid, i) << "; ";
else if (ti == &typeid(SG::PackedElement<std::vector<unsigned int> >)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<SG::PackedElement<std::vector<unsigned int> > > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(SG::PackedElement<std::vector<int> >)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<SG::PackedElement<std::vector<int> > > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(SG::PackedElement<std::vector<float> >)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<SG::PackedElement<std::vector<float> > > (auxid, i))
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]; ";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]; ";
}
#endif
else if (ti == &typeid(std::vector<int>)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<std::vector<int> > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(std::vector<float>) ||
strcmp (ti->name(), typeid(std::vector<float>).name()) == 0)
{
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<std::vector<float> > (auxid, i))
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]; ";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]; ";
}
else
std::cout << head << "xxx " << ti->name() << "; ";
ost << head << "xxx " << ti->name() << "; ";
}
......@@ -148,10 +149,11 @@ StatusCode AuxDataTestTypelessRead::execute()
<< System::typeinfoName (*r.getType(m.second)) << " ";
std::cout << "\n";
for (size_t i = 0; i < vec->size(); i++) {
std::cout << " ";
std::ostringstream ss;
ss << " ";
for (const auto& m : auxid_map)
dumpAuxItem (m.second, *vec, i);
std::cout << "\n";
dumpAuxItem (ss, m.second, *vec, i);
std::cout << ss.str() << "\n";
}
const BAux* b = 0;
......@@ -167,9 +169,10 @@ StatusCode AuxDataTestTypelessRead::execute()
std::cout << r.getName(m.second) << "/"
<< System::typeinfoName (*r.getType(m.second)) << " ";
std::cout << "\n";
std::ostringstream ss;
for (const auto& m : bauxid_map)
dumpAuxItem (m.second, *cont, 0);
std::cout << "\n";
dumpAuxItem (ss, m.second, *cont, 0);
std::cout << ss.str() << "\n";
if (!m_writePrefix.empty()) {
// Passing this as the third arg of record will make the object const.
......
......@@ -13,8 +13,13 @@
#include "HLTResultReader.h"
#include "DataModelTestDataCommon/CVec.h"
#include "DataModelTestDataCommon/CView.h"
#include "DataModelTestDataCommon/C.h"
#include "DataModelTestDataCommon/CAuxContainer.h"
#include "DataModelTestDataRead/HVec.h"
#include "DataModelTestDataRead/HView.h"
#include "DataModelTestDataRead/H.h"
#include "DataModelTestDataRead/HAuxContainer.h"
#include "TrigNavigation/Navigation.h"
#include "TrigNavigation/Holder.icc"
#include "TrigSteeringEvent/HLTResult.h"
......@@ -22,6 +27,9 @@
HLT_BEGIN_TYPE_REGISTRATION
HLT_REGISTER_TYPE(DMTest::C, DMTest::CVec, DMTest::CVec, DMTest::CAuxContainer)
HLT_REGISTER_TYPE(DMTest::C, DMTest::CView, DMTest::CView, DMTest::CAuxContainer)
HLT_REGISTER_TYPE(DMTest::H, DMTest::HVec, DMTest::HVec, DMTest::HAuxContainer)
HLT_REGISTER_TYPE(DMTest::H, DMTest::HView, DMTest::HView, DMTest::HAuxContainer)
HLT_END_TYPE_REGISTRATION(DataModelTest)
......@@ -51,7 +59,7 @@ namespace DMTest {
*/
HLTResultReader::HLTResultReader (const std::string &name,
ISvcLocator *pSvcLocator)
: AthReentrantAlgorithm (name, pSvcLocator),
: AthAlgorithm (name, pSvcLocator),
m_nav ("TestNav", this)
{
declareProperty ("ResultKey", m_resultKey = "HLTResult_HLT");
......@@ -67,7 +75,11 @@ StatusCode HLTResultReader::initialize()
ATH_CHECK( m_resultKey.initialize() );
ATH_CHECK( m_nav.retrieve() );
HLT::TypeMaps::registerFeatureContainer<DMTest::CVec,DMTest::CVec>();
HLT::TypeMaps::registerFeatureContainer<DMTest::CView,DMTest::CView>();
HLT::TypeMaps::registerType<DMTest::CAuxContainer>();
HLT::TypeMaps::registerFeatureContainer<DMTest::HVec,DMTest::HVec>();
HLT::TypeMaps::registerFeatureContainer<DMTest::HView,DMTest::HView>();
HLT::TypeMaps::registerType<DMTest::HAuxContainer>();
return StatusCode::SUCCESS;
}
......@@ -75,9 +87,9 @@ StatusCode HLTResultReader::initialize()
/**
* @brief Algorithm event processing.
*/
StatusCode HLTResultReader::execute_r (const EventContext& ctx) const
StatusCode HLTResultReader::execute()
{
SG::ReadHandle<HLT::HLTResult> result (m_resultKey, ctx);
SG::ReadHandle<HLT::HLTResult> result (m_resultKey);
m_nav->prepare();
if (!m_nav->deserialize (result->getNavigationResult()))
return StatusCode::FAILURE;
......
......@@ -17,7 +17,7 @@
#define DATAMODELTESTDATAREAD_HLTRESULTREADER_H
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "AthenaBaseComps/AthAlgorithm.h"
#include "StoreGate/ReadHandleKey.h"
#include "GaudiKernel/ToolHandle.h"
......@@ -35,7 +35,7 @@ namespace DMTest {
* @brief Test for serializing an xAOD object from bytestream.
*/
class HLTResultReader
: public AthReentrantAlgorithm
: public AthAlgorithm
{
public:
/**
......@@ -55,7 +55,7 @@ public:
/**
* @brief Algorithm event processing.
*/
virtual StatusCode execute_r (const EventContext& ctx) const override;
virtual StatusCode execute() override;
/**
......
......@@ -14,6 +14,9 @@
#include "../AuxDataTestTypelessRead.h"
#include "../xAODTestRead.h"
#include "../xAODTestReadCVec.h"
#include "../xAODTestReadCView.h"
#include "../xAODTestReadHVec.h"
#include "../xAODTestFilterCVec.h"
#include "../xAODTestDecor.h"
#include "../xAODTestClearDecor.h"
#include "../xAODTestTypelessRead.h"
......@@ -27,6 +30,9 @@ DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, AuxDataTestClearDecor)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, AuxDataTestTypelessRead)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestRead)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestReadCVec)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestReadCView)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestReadHVec)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestFilterCVec)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestDecor)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestClearDecor)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestTypelessRead)
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file DataModelTestDataRead/src/xAODTestFilterCVec.cxx
* @author snyder@bnl.gov
* @date Sep 2016
* @brief Algorithm to test filtering xAOD data.
*/
#include "xAODTestFilterCVec.h"
#include "DataModelTestDataCommon/CVec.h"
#include "DataModelTestDataCommon/C.h"
#include "DataModelTestDataCommon/CAuxContainer.h"
#include "StoreGate/ReadHandle.h"
#include "StoreGate/WriteHandle.h"
#include <memory>
namespace DMTest {
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestFilterCVec::xAODTestFilterCVec (const std::string &name,
ISvcLocator *pSvcLocator)
: AthReentrantAlgorithm (name, pSvcLocator),
m_cvecKey ("cvec_renamed"),
m_writeKey ("cvec")
{
declareProperty ("CVecKey", m_cvecKey);
declareProperty ("WriteKey", m_writeKey);
}
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
StatusCode xAODTestFilterCVec::initialize()
{
ATH_CHECK( m_cvecKey.initialize() );
if (!m_writeKey.key().empty())
ATH_CHECK( m_writeKey.initialize() );
return StatusCode::SUCCESS;
}
/**
* @brief Algorithm event processing.
*/
StatusCode xAODTestFilterCVec::execute_r (const EventContext& ctx) const
{
SG::ReadHandle<DMTest::CVec> cvec (m_cvecKey, ctx);
const static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
auto vecnew = std::make_unique<CVec>();
auto store = std::make_unique<CAuxContainer>();
vecnew->setStore (store.get());
for (size_t i = 0; i < cvec->size(); i+=2) {
vecnew->push_back (new C);
*vecnew->back() = *(*cvec)[i];
}
size_t i = 0;
for (C* c : *vecnew) {
cEL(*c).toIndexedElement (*vecnew, vecnew->size()-1-i);
++i;
}
SG::WriteHandle<DMTest::CVec> writevec (m_writeKey, ctx);
ATH_CHECK( writevec.record(std::move(vecnew), std::move(store)) );
return StatusCode::SUCCESS;
}
/**
* @brief Algorithm finalization; called at the end of the job.
*/
StatusCode xAODTestFilterCVec::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
*/
// $Id$
/**
* @file DataModelTestDataRead/src/xAODTestFilterCVec.h
* @author scott snyder <snyder@bnl.gov>
* @date Sep 2016
* @brief Algorithm to test filtering xAOD data.
*/
#ifndef DATAMODELTESTDATAREAD_XAODTESTFILTERCVEC_H
#define DATAMODELTESTDATAREAD_XAODTESTFILTERCVEC_H
#include "DataModelTestDataCommon/CVec.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
namespace DMTest {
/**
* @brief Algorithm to test filtering xAOD data.
*/
class xAODTestFilterCVec
: public AthReentrantAlgorithm
{
public:
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestFilterCVec (const std::string &name, ISvcLocator *pSvcLocator);
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
virtual StatusCode initialize() override;
/**
* @brief Algorithm event processing.
*/
virtual StatusCode execute_r (const EventContext& ctx) const override;
/**
* @brief Algorithm finalization; called at the end of the job.
*/
virtual StatusCode finalize() override;
private:
SG::ReadHandleKey<DMTest::CVec> m_cvecKey;
SG::WriteHandleKey<DMTest::CVec> m_writeKey;
};
} // namespace DMTest
#endif // not DATAMODELTESTDATAREAD_XAODTESTFILTERCVEC_H
......@@ -13,16 +13,16 @@
#include "xAODTestRead.h"
#include "DataModelTestDataCommon/CVec.h"
#include "DataModelTestDataCommon/CView.h"
//#include "DataModelTestDataCommon/CView.h"
#include "DataModelTestDataCommon/CVecWithData.h"
#include "DataModelTestDataCommon/C.h"
#include "DataModelTestDataCommon/CAuxContainer.h"
#include "DataModelTestDataCommon/CTrigAuxContainer.h"
#include "DataModelTestDataCommon/CInfoAuxContainer.h"
#include "DataModelTestDataRead/HVec.h"
#include "DataModelTestDataRead/H.h"
#include "DataModelTestDataRead/HAuxContainer.h"
#include "DataModelTestDataRead/HView.h"
//#include "DataModelTestDataRead/HVec.h"
//#include "DataModelTestDataRead/H.h"
//#include "DataModelTestDataRead/HAuxContainer.h"
//#include "DataModelTestDataRead/HView.h"
#include "DataModelTestDataRead/GVec.h"
#include "DataModelTestDataRead/G.h"
#include "DataModelTestDataRead/GAuxContainer.h"
......@@ -196,8 +196,7 @@ StatusCode xAODTestRead::execute()
}
CHECK( read_cvec_with_data() );
CHECK( read_cview() );
CHECK( read_htest() );
//CHECK( read_cview() );
return StatusCode::SUCCESS;
}
......@@ -239,6 +238,7 @@ StatusCode xAODTestRead::read_cvec_with_data() const
}
#if 0
/**
* @brief Test reading view container.
*/
......@@ -268,53 +268,7 @@ StatusCode xAODTestRead::read_cview() const
return StatusCode::SUCCESS;
}
/**
* @brief Test schema evolution involving view container.
*/
StatusCode xAODTestRead::read_htest() const
{
const HVec* vec = nullptr;
CHECK( evtStore()->retrieve (vec, m_readPrefix + "hvec") );
std::cout << m_readPrefix << "hvec:";
for (const H* h : *vec)
std::cout << " " << h->aFloat();
std::cout << "\n";
if (!evtStore()->contains<HView> (m_readPrefix + "hview")) {
std::cout << "(No " << m_readPrefix << "hview.)\n";
}
else {
CHECK( evtStore()->retrieve (vec, m_readPrefix + "hview") );
std::cout << m_readPrefix << "hview:";
for (const H* h : *vec)
std::cout << " " << h->aFloat();
std::cout << "\n";
}
if (!m_writePrefix.empty()) {
// Passing this as the third arg of record will make the object const.
bool LOCKED = false;
auto vecnew = CxxUtils::make_unique<HVec>();
auto store = CxxUtils::make_unique<HAuxContainer>();
vecnew->setStore (store.get());
for (size_t i = 0; i < vec->size(); i++) {
vecnew->push_back (new H);
*vecnew->back() = *(*vec)[i];
}
auto viewnew = CxxUtils::make_unique<HView>();
for (size_t i = 0; i < vec->size(); i++)
viewnew->push_back (vecnew->at(vec->size()-1-i));
CHECK (evtStore()->record (std::move(vecnew), m_writePrefix + "hvec", LOCKED));
CHECK (evtStore()->record (std::move(store), m_writePrefix + "hvecAux.", LOCKED));
CHECK (evtStore()->record (std::move(viewnew), m_writePrefix + "hview", LOCKED));
}
return StatusCode::SUCCESS;
}
#endif
/**
......
......@@ -61,10 +61,7 @@ private:
StatusCode read_cvec_with_data() const;
/// Test reading view container.
StatusCode read_cview() const;
/// Test schema evolution involving view container.
StatusCode read_htest() const;
//StatusCode read_cview() const;
/// Parameter: Prefix for names read from SG.
std::string m_readPrefix;
......
......@@ -6,7 +6,7 @@
/**
* @file DataModelTestDataRead/src/xAODTestReadCVec.cxx
* @author snyder@bnl.gov
* @date May 2014
* @date Apr, 2016
* @brief Algorithm to test reading xAOD data (CVec).
*/
......@@ -24,6 +24,7 @@
#include "CxxUtils/make_unique.h"
#include "GaudiKernel/System.h"
#include <memory>
#include <sstream>
namespace DMTest {
......@@ -50,6 +51,10 @@ xAODTestReadCVec::xAODTestReadCVec (const std::string &name,
*/
StatusCode xAODTestReadCVec::initialize()
{
errorcheck::ReportMessage::hideErrorLocus();
C::Accessor<float> dVar1 ("dVar1");
ATH_CHECK( m_cvecKey.initialize() );
if (!m_writeKey.key().empty())
ATH_CHECK( m_writeKey.initialize() );
......@@ -67,6 +72,7 @@ StatusCode xAODTestReadCVec::execute_r (const EventContext& ctx) const
const static C::Accessor<int> anInt2 ("anInt2");
const static C::Accessor<int> anInt10 ("anInt10");
const static C::Accessor<int> dInt1 ("dInt1");
const static C::Accessor<float> dVar1 ("dVar1"); // testing schema evolution
const static C::Accessor<unsigned int> dpInt1 ("dpInt1");
const static C::Accessor<std::vector<float> > dpvFloat ("dpvFloat");
const static C::Accessor<int> dInt100 ("dInt100");
......@@ -81,63 +87,71 @@ StatusCode xAODTestReadCVec::execute_r (const EventContext& ctx) const
for (SG::auxid_t auxid : cvec->getAuxIDs())
names.push_back (r.getName(auxid));
std::sort (names.begin(), names.end());
std::cout << "cvec aux items: ";
std::cout << m_cvecKey.key() << " aux items: ";
for (const std::string& n : names)
std::cout << n << " ";
std::cout << "\n";
std::cout << "Type of aux store: "
<< System::typeinfoName (typeid (*cvec->getConstStore())) << "\n";
{
const SG::IConstAuxStore* auxstore = cvec->getConstStore();
std::cout << "Type of aux store: "
<< System::typeinfoName (typeid (*auxstore)) << "\n";
}
for (const C* c : *cvec) {
std::cout << " anInt1 " << c->anInt()
std::ostringstream ost;
ost << " anInt1 " << c->anInt()
<< " aFloat: " << c->aFloat()
<< " pInt: " << c->pInt()
<< " pFloat: " << CxxUtils::strformat ("%.2f", c->pFloat());
if (anInt2.isAvailable(*c))
std::cout << " anInt2: " << anInt2(*c);
ost << " anInt2: " << anInt2(*c);
if (dInt1.isAvailable(*c))
std::cout << " dInt1: " << dInt1(*c);
ost << " dInt1: " << dInt1(*c);
if (dVar1.isAvailable(*c))
ost << " dVar1: " << dVar1(*c);
if (dpInt1.isAvailable(*c))
std::cout << " dpInt1: " << dpInt1(*c);
ost << " dpInt1: " << dpInt1(*c);
if (dInt100.isAvailable(*c))
std::cout << " dInt100: " << dInt100(*c);
ost << " dInt100: " << dInt100(*c);
if (dInt150.isAvailable(*c))
std::cout << " dInt150: " << dInt150(*c);
ost << " dInt150: " << dInt150(*c);
if (dInt200.isAvailable(*c))
std::cout << " dInt200: " << dInt200(*c);
ost << " dInt200: " << dInt200(*c);
if (dInt250.isAvailable(*c))
std::cout << " dInt250: " << dInt250(*c);
ost << " dInt250: " << dInt250(*c);
if (anInt10.isAvailable(*c))
std::cout << " anInt10: " << anInt10(*c);
ost << " anInt10: " << anInt10(*c);
if (cEL.isAvailable(*c))
std::cout << " cEL: " << cEL(*c).dataID()
ost << " cEL: " << cEL(*c).dataID()
<< "[" << cEL(*c).index() << "]";
std::cout << "\n";
ost << "\n";
{
const std::vector<int>& pvi = c->pvInt();
std::cout << " pvInt: [";
ost << " pvInt: [";
for (auto ii : pvi)
std::cout << ii << " ";
std::cout << "]\n";
ost << ii << " ";
ost << "]\n";
}
{
const std::vector<float>& pvf = c->pvFloat();
std::cout << " pvFloat: [";
ost << " pvFloat: [";
for (auto ii : pvf)
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]\n";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]\n";
}
if (dpvFloat.isAvailable(*c))
{
const std::vector<float>& pvf = dpvFloat(*c);
std::cout << " dpvFloat: [";
ost << " dpvFloat: [";
for (auto ii : pvf)
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]\n";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]\n";
}
std::cout << ost.str();
}
if (!m_writeKey.key().empty()) {
......
......@@ -60,12 +60,6 @@ public:
private:
/// Parameter: Prefix for names read from SG.
std::string m_readPrefix;
/// Parameter: Prefix for names written to SG. Null for no write.
std::string m_writePrefix;
SG::ReadHandleKey<DMTest::CVec> m_cvecKey;
SG::WriteHandleKey<DMTest::CVec> m_writeKey;
};
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file DataModelTestDataRead/src/xAODTestReadCView.cxx
* @author snyder@bnl.gov
* @date Oct 2016
* @brief Algorithm to test reading xAOD data (CView).
*/
#include "xAODTestReadCView.h"
#include "DataModelTestDataCommon/CView.h"
#include "DataModelTestDataCommon/C.h"
#include "StoreGate/ReadHandle.h"
#include "StoreGate/WriteHandle.h"
#include <memory>
#include <sstream>
namespace DMTest {
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestReadCView::xAODTestReadCView (const std::string &name,
ISvcLocator *pSvcLocator)
: AthReentrantAlgorithm (name, pSvcLocator),
m_cviewKey ("cview"),
m_writeKey ("")
{
declareProperty ("CViewKey", m_cviewKey);
declareProperty ("WriteKey", m_writeKey);
}
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
StatusCode xAODTestReadCView::initialize()
{
ATH_CHECK( m_cviewKey.initialize() );
if (!m_writeKey.key().empty())
ATH_CHECK( m_writeKey.initialize() );
return StatusCode::SUCCESS;
}
/**
* @brief Algorithm event processing.
*/
StatusCode xAODTestReadCView::execute_r (const EventContext& ctx) const
{
SG::ReadHandle<DMTest::CView> cview (m_cviewKey, ctx);
static C::Accessor<int> anInt10 ("anInt10");
std::cout << m_cviewKey.key() << ":";
for (const C* c : *cview) {
std::cout << " " << c->anInt();
if (anInt10.isAvailable(*c))
std::cout << "(" << anInt10(*c) << ")";
}
std::cout << "\n";
if (!m_writeKey.key().empty()) {
SG::WriteHandle<DMTest::CView> writeview (m_writeKey, ctx);
ATH_CHECK( writeview.record(std::make_unique<DMTest::CView> (*cview)) );
}
return StatusCode::SUCCESS;
}
/**
* @brief Algorithm finalization; called at the end of the job.
*/
StatusCode xAODTestReadCView::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
*/
// $Id$
/**
* @file src/xAODTestReadCView.h
* @author scott snyder <snyder@bnl.gov>
* @date Oct, 2016
* @brief Algorithm to test reading xAOD data (CView)
*/
#ifndef DATAMODELTESTDATAREAD_XAODTESTREADCVIEW_H
#define DATAMODELTESTDATAREAD_XAODTESTREADCVIEW_H
#include "DataModelTestDataCommon/CView.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
namespace DMTest {
/**
* @brief Algorithm to test reading xAOD data (CView).
*/
class xAODTestReadCView
: public AthReentrantAlgorithm
{
public:
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestReadCView (const std::string &name, ISvcLocator *pSvcLocator);
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
virtual StatusCode initialize() override;
/**
* @brief Algorithm event processing.
*/
virtual StatusCode execute_r (const EventContext& ctx) const override;
/**
* @brief Algorithm finalization; called at the end of the job.
*/
virtual StatusCode finalize() override;
private:
SG::ReadHandleKey<DMTest::CView> m_cviewKey;
SG::WriteHandleKey<DMTest::CView> m_writeKey;
};
} // namespace DMTest
#endif // not DATAMODELTESTDATAREAD_XAODTESTREADCVIEW_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file DataModelTestDataRead/src/xAODTestReadHVec.cxx
* @author snyder@bnl.gov
* @date Oct, 2016
* @brief Algorithm to test reading xAOD data with schema evolution (HVec/HView)
*/
#include "xAODTestReadHVec.h"
#include "DataModelTestDataRead/HVec.h"
#include "DataModelTestDataRead/HView.h"
#include "DataModelTestDataRead/H.h"
#include "DataModelTestDataRead/HAuxContainer.h"
#include "StoreGate/ReadHandle.h"
#include "StoreGate/WriteHandle.h"
#include <memory>
#include <sstream>
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() );
return StatusCode::SUCCESS;
}
/**
* @brief Algorithm event processing.
*/
StatusCode xAODTestReadHVec::execute_r (const EventContext& ctx) const
{
SG::ReadHandle<DMTest::HVec> hvec (m_hvecKey, ctx);
std::cout << m_hvecKey.key() << ":";
for (const H* h : *hvec)
std::cout << " " << h->aFloat();
std::cout << "\n";
if (!m_hviewKey.key().empty()) {
SG::ReadHandle<DMTest::HVec> hview (m_hviewKey, ctx);
std::cout << m_hviewKey.key() << ":";
for (const H* h : *hview)
std::cout << " " << h->aFloat();
std::cout << "\n";
if (!m_vecWriteKey.key().empty()) {
auto vecnew = std::make_unique<HVec>();
auto store = std::make_unique<HAuxContainer>();
vecnew->setStore (store.get());
for (size_t i = 0; i < hview->size(); i++) {
vecnew->push_back (new H);
*vecnew->back() = *(*hview)[i];
}
auto viewnew = std::make_unique<HView>();
for (size_t i = 0; i < vecnew->size(); i++)
viewnew->push_back (vecnew->at(vecnew->size()-1-i));
SG::WriteHandle<DMTest::HVec> writevec (m_vecWriteKey, ctx);
SG::WriteHandle<DMTest::HView> writeview (m_viewWriteKey, ctx);
ATH_CHECK( writevec.record (std::move(vecnew), std::move(store)) );
ATH_CHECK( writeview.record (std::move(viewnew)) );
}
}
return StatusCode::SUCCESS;
}
/**
* @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
*/
// $Id$
/**
* @file src/xAODTestReadHVec.h
* @author scott snyder <snyder@bnl.gov>
* @date Oct, 2016
* @brief Algorithm to test reading xAOD data with schema evolution (HVec/HView)
*/
#ifndef DATAMODELTESTDATAREAD_XAODTESTREADHVEC_H
#define DATAMODELTESTDATAREAD_XAODTESTREADHVEC_H
#include "DataModelTestDataRead/HVec.h"
#include "DataModelTestDataRead/HView.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
namespace DMTest {
/**
* @brief Algorithm to test reading xAOD data with schema evolution (HVec/HView)
*/
class xAODTestReadHVec
: public AthReentrantAlgorithm
{
public:
/**
* @brief Constructor.
* @param name The algorithm name.
* @param svc The service locator.
*/
xAODTestReadHVec (const std::string &name, ISvcLocator *pSvcLocator);
/**
* @brief Algorithm initialization; called at the beginning of the job.
*/
virtual StatusCode initialize() override;
/**
* @brief Algorithm event processing.
*/
virtual StatusCode execute_r (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;
};
} // namespace DMTest
#endif // not DATAMODELTESTDATAREAD_XAODTESTREADHVEC_H
......@@ -32,6 +32,7 @@
#include "CxxUtils/make_unique.h"
#include "GaudiKernel/System.h"
#include <memory>
#include <sstream>
namespace DMTest {
......@@ -63,70 +64,72 @@ StatusCode xAODTestTypelessRead::initialize()
namespace {
void dumpAuxItem (SG::auxid_t auxid, const SG::AuxVectorData& c, size_t i)
void dumpAuxItem (std::ostream& ost,
SG::auxid_t auxid,
const SG::AuxVectorData& c, size_t i)
{
const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
const std::type_info* ti = r.getType(auxid);
std::string head = r.getName(auxid) + ": ";
if (ti == &typeid(int))
std::cout << head << c.getData<int> (auxid, i) << "; ";
ost << head << c.getData<int> (auxid, i) << "; ";
else if (ti == &typeid(unsigned int))
std::cout << head << c.getData<unsigned int> (auxid, i) << "; ";
ost << head << c.getData<unsigned int> (auxid, i) << "; ";
else if (ti == &typeid(float))
std::cout << head << CxxUtils::strformat ("%.3f", c.getData<float> (auxid, i)) << "; ";
ost << head << CxxUtils::strformat ("%.3f", c.getData<float> (auxid, i)) << "; ";
else if (ti == &typeid(ElementLink<DMTest::CVec>)) {
const ElementLink<DMTest::CVec>& el =
c.getData<ElementLink<DMTest::CVec> > (auxid, i);
std::cout << head << el.dataID() << "[" << el.index() << "]; ";
ost << head << el.dataID() << "[" << el.index() << "]; ";
}
#if 0
else if (ti == &typeid(SG::PackedElement<unsigned int>))
std::cout << head << c.getData<SG::PackedElement<unsigned int> > (auxid, i) << "; ";
ost << head << c.getData<SG::PackedElement<unsigned int> > (auxid, i) << "; ";
else if (ti == &typeid(SG::PackedElement<float>))
std::cout << head << c.getData<SG::PackedElement<float> > (auxid, i) << "; ";
ost << head << c.getData<SG::PackedElement<float> > (auxid, i) << "; ";
#endif
else if (ti == &typeid(std::vector<unsigned int>)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<std::vector<unsigned int> > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(std::vector<int>)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<std::vector<int> > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(std::vector<float>) ||
strcmp (ti->name(), typeid(std::vector<float>).name()) == 0)
{
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<std::vector<float> > (auxid, i))
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]; ";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]; ";
}
#if 0
else if (ti == &typeid(SG::PackedElement<std::vector<unsigned int> >)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<SG::PackedElement<std::vector<unsigned int> > > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(SG::PackedElement<std::vector<int> >)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<SG::PackedElement<std::vector<int> > > (auxid, i))
std::cout << ii << " ";
std::cout << "]; ";
ost << ii << " ";
ost << "]; ";
}
else if (ti == &typeid(SG::PackedElement<std::vector<float> >)) {
std::cout << "\n " << head << "[";
ost << "\n " << head << "[";
for (auto ii : c.getData<SG::PackedElement<std::vector<float> > > (auxid, i))
std::cout << CxxUtils::strformat ("%.3f", ii) << " ";
std::cout << "]; ";
ost << CxxUtils::strformat ("%.3f", ii) << " ";
ost << "]; ";
}
#endif
else
std::cout << head << "xxx " << ti->name() << "; ";
ost << head << "xxx " << ti->name() << "; ";
}
......@@ -149,38 +152,41 @@ std::map<std::string, SG::auxid_t> get_map (const SG::AuxElement* elt)
}
void dumpelt (const SG::AuxVectorData* cont,
void dumpelt (std::ostream& ost,
const SG::AuxVectorData* cont,
size_t index,
const std::map<std::string, SG::auxid_t>& auxid_map)
{
for (const auto& m : auxid_map)
dumpAuxItem (m.second, *cont, index);
std::cout << "\n";
dumpAuxItem (ost, m.second, *cont, index);
ost << "\n";
}
template <class OBJ>
void dumpobj (const OBJ* obj,
void dumpobj (std::ostream& ost,
const OBJ* obj,
const std::map<std::string, SG::auxid_t>& auxid_map)
{
for (size_t i = 0; i < obj->size(); i++) {
std::cout << " ";
ost << " ";
if (!obj->hasStore()) {
// Handle view container.
const auto* elt = obj->at(i);
dumpelt (elt->container(), elt->index(), auxid_map);
dumpelt (ost, elt->container(), elt->index(), auxid_map);
}
else
dumpelt (obj, i, auxid_map);
dumpelt (ost, obj, i, auxid_map);
}
}
void dumpobj (const DMTest::C* obj,
void dumpobj (std::ostream& ost,
const DMTest::C* obj,
const std::map<std::string, SG::auxid_t>& auxid_map)
{
const SG::AuxVectorData* cont = obj->container();
dumpelt (cont, 0, auxid_map);
dumpelt (ost, cont, 0, auxid_map);
}
......@@ -235,7 +241,9 @@ xAODTestTypelessRead::testit (const char* key)
<< System::typeinfoName (*r.getType(m.second)) << " ";
std::cout << "\n";
dumpobj (obj, auxid_map);
std::ostringstream ost;
dumpobj (ost, obj, auxid_map);
std::cout << ost.str();
if (!m_writePrefix.empty()) {
// Passing this as the third arg of record will make the object const.
......@@ -263,7 +271,9 @@ xAODTestTypelessRead::testit_view (const char* key)
return StatusCode::SUCCESS;
std::map<std::string, SG::auxid_t> auxid_map = get_map (obj->front());
std::cout << key << "\n";
dumpobj (obj, auxid_map);
std::ostringstream ost;
dumpobj (ost, obj, auxid_map);
std::cout << ost.str();
if (!m_writePrefix.empty()) {
CHECK (evtStore()->record (CxxUtils::make_unique<OBJ>(*obj),
......
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