diff --git a/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt b/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt index a605ff609c3baa0349756c1fd9cf6d751690e1fb..b43ef7397e45384b64df6f493198a291de8e696f 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt +++ b/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt @@ -51,3 +51,10 @@ atlas_add_dictionary( DataModelTestDataWriteDict EXTRA_FILES src/dict/*.cxx ELEMENT_LINKS DataVector<DMTest::B> ) + + +atlas_add_sercnv_library ( DataModelTestDataWriteSerCnv + FILES DataModelTestDataWrite/HVec.h DataModelTestDataWrite/HView.h DataModelTestDataWrite/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 DataModelTestDataWriteLib ) diff --git a/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements b/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements index ba97ab217ca5c2ed951008e9ba1b05eb1938b49c..b1cab4144d9aca617908302e29bc19e26af4fe8e 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements +++ b/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements @@ -48,3 +48,16 @@ apply_pattern lcgdict dict=DataModelTestDataWrite selectionfile=selection.xml\ headerfiles="../DataModelTestDataWrite/DataModelTestDataWriteDict.h" \ elementLinks="$(elemLinks_DataModelTestDataWrite)" \ 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=${DataModelTestDataWrite_root}/DataModelTestDataWrite \ + HVec.h HView.h HAuxContainer.h " + diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx index a498a7c0919620edea1bb6635bc315dfe1d54c47..1f82e41a7d6ae2b0cbc1edd0577a8792bad0f70e 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx +++ b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx @@ -7,14 +7,19 @@ * @file DataModelTestDataWrite/src/HLTResultWriter.cxx * @author snyder@bnl.gov * @date Mar, 2016 - * @brief Test for serializing an xAOD object into bytestream. + * @brief Test for serialiclang warnings: unused members.zing an xAOD object into bytestream. */ #include "HLTResultWriter.h" #include "DataModelTestDataCommon/CVec.h" +#include "DataModelTestDataCommon/CView.h" #include "DataModelTestDataCommon/C.h" #include "DataModelTestDataCommon/CAuxContainer.h" +#include "DataModelTestDataWrite/HVec.h" +#include "DataModelTestDataWrite/HView.h" +#include "DataModelTestDataWrite/H.h" +#include "DataModelTestDataWrite/HAuxContainer.h" #include "TrigNavigation/Navigation.h" #include "TrigNavigation/Holder.icc" #include "TrigSteeringEvent/HLTResult.h" @@ -23,6 +28,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) @@ -52,7 +60,7 @@ namespace DMTest { */ HLTResultWriter::HLTResultWriter (const std::string &name, ISvcLocator *pSvcLocator) - : AthReentrantAlgorithm (name, pSvcLocator), + : AthAlgorithm (name, pSvcLocator), m_nav ("TestNav", this) { declareProperty ("ResultKey", m_resultKey = "HLTResult_HLT"); @@ -68,7 +76,11 @@ StatusCode HLTResultWriter::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; } @@ -76,9 +88,9 @@ StatusCode HLTResultWriter::initialize() /** * @brief Algorithm event processing. */ -StatusCode HLTResultWriter::execute_r (const EventContext& ctx) const +StatusCode HLTResultWriter::execute() { - SG::WriteHandle<HLT::HLTResult> result (m_resultKey, ctx); + SG::WriteHandle<HLT::HLTResult> result (m_resultKey); ATH_CHECK( result.record (CxxUtils::make_unique<HLT::HLTResult>()) ); m_nav->prepare(); diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h index 1737e76d4c71097e0c13ec9cb9c1611a7d323a1e..b8e07419653abb85e7464408548462b1b577d883 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h +++ b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h @@ -17,7 +17,7 @@ #define DATAMODELTESTDATAWRITE_HLTRESULTWRITER_H -#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaBaseComps/AthAlgorithm.h" #include "StoreGate/WriteHandleKey.h" #include "GaudiKernel/ToolHandle.h" @@ -35,7 +35,7 @@ namespace DMTest { * @brief Test for serializing an xAOD object into bytestream. */ class HLTResultWriter - : 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; /** diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx index b3fa5e78c0e5563849ee2cd5bcab9ed73afcae6f..c85dd40d3ee72e7c8121848988b6e61d432e5592 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx +++ b/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx @@ -11,11 +11,19 @@ #include "../AuxDataTestWrite.h" #include "../xAODTestWrite.h" #include "../xAODTestWriteCVec.h" +#include "../xAODTestWriteHVec.h" +#include "../xAODTestWriteCView.h" +#include "../xAODTestWriteCInfo.h" +#include "../xAODTestWriteCVecConst.h" #include "../HLTResultWriter.h" DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, DMTestWrite) DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, AuxDataTestWrite) DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWrite) DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWriteCVec) +DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWriteHVec) +DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWriteCView) +DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWriteCInfo) +DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWriteCVecConst) DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, HLTResultWriter) diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx index 77569dcfcfbaef23cc1571d2c27aeb053aa029db..eeb097540e82ed885bb4a5d2d35d0372a373bbe6 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx @@ -14,24 +14,20 @@ #include "xAODTestWrite.h" #include "xAODTestWriteHelper.h" #include "DataModelTestDataCommon/CVec.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 "DataModelTestDataWrite/GVec.h" #include "DataModelTestDataWrite/G.h" #include "DataModelTestDataWrite/GAuxContainer.h" -#include "DataModelTestDataWrite/H.h" -#include "DataModelTestDataWrite/HVec.h" -#include "DataModelTestDataWrite/HView.h" -#include "DataModelTestDataWrite/HAuxContainer.h" +//#include "DataModelTestDataWrite/H.h" +//#include "DataModelTestDataWrite/HVec.h" +//#include "DataModelTestDataWrite/HView.h" +//#include "DataModelTestDataWrite/HAuxContainer.h" #include "AthContainersInterfaces/AuxDataOption.h" -#include "AthContainers/ConstDataVector.h" #include "AthLinks/ElementLink.h" #include "AthenaKernel/errorcheck.h" -#include "CxxUtils/make_unique.h" #define CHECK_OPTION(ret) \ @@ -55,8 +51,8 @@ xAODTestWrite::xAODTestWrite (const std::string &name, ISvcLocator *pSvcLocator) : AthAlgorithm (name, pSvcLocator), m_count(0), - m_cvecKey ("cvec"), - m_hvecKey ("hvec") + m_cvecKey ("cvec") + //m_hvecKey ("hvec") { } @@ -67,7 +63,7 @@ xAODTestWrite::xAODTestWrite (const std::string &name, StatusCode xAODTestWrite::initialize() { ATH_CHECK( m_cvecKey.initialize() ); - ATH_CHECK( m_hvecKey.initialize() ); + //ATH_CHECK( m_hvecKey.initialize() ); return StatusCode::SUCCESS; } @@ -85,10 +81,6 @@ StatusCode xAODTestWrite::execute() DMTest::CTrigAuxContainer* trig_store = new DMTest::CTrigAuxContainer; trig_coll->setStore (trig_store); - DMTest::C* cinfo = new DMTest::C; - DMTest::CInfoAuxContainer* info_store = new DMTest::CInfoAuxContainer; - cinfo->setStore (info_store); - static C::Accessor<int> anInt2 ("anInt2"); static C::Decorator<int> dInt1 ("dInt1"); static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL"); @@ -108,23 +100,11 @@ StatusCode xAODTestWrite::execute() dInt1(c) = m_count*480 + i+1; } - cinfo->setAnInt (m_count * 1000); - cinfo->setAFloat ((float)m_count * 0.1); - anInt2(*cinfo) = m_count * 2000; - dInt1(*cinfo) = m_count * 3000; - CHECK( evtStore()->record (trig_coll, "ctrig") ); CHECK( evtStore()->record (trig_store, "ctrigAux.") ); CHECK( evtStore()->setConst (trig_coll) ); CHECK( evtStore()->setConst (trig_store) ); - cEL(*cinfo).toIndexedElement (*cvec, m_count % cvec->size()); - - CHECK( evtStore()->record (cinfo, "cinfo") ); - CHECK( evtStore()->record (info_store, "cinfoAux.") ); - CHECK( evtStore()->setConst (cinfo) ); - CHECK( evtStore()->setConst (info_store) ); - DMTest::GVec* gvec = new DMTest::GVec; DMTest::GAuxContainer* gstore = new DMTest::GAuxContainer; gvec->setStore (gstore); @@ -141,8 +121,7 @@ StatusCode xAODTestWrite::execute() CHECK( evtStore()->setConst (gstore) ); CHECK( write_cvec_with_data() ); - CHECK( write_cview (*cvec) ); - CHECK( write_htest() ); + //CHECK( write_htest() ); return StatusCode::SUCCESS; } @@ -173,30 +152,16 @@ StatusCode xAODTestWrite::write_cvec_with_data() } -/** - * @brief Test writing view container. - */ -StatusCode xAODTestWrite::write_cview (const DMTest::CVec& coll) -{ - auto cview = CxxUtils::make_unique<ConstDataVector<DMTest::CView> >(SG::VIEW_ELEMENTS); - for (int i = coll.size()-1; i >= 0; --i) - cview->push_back (coll[i]); - - CHECK( DMTest::recordView1 (&*evtStore(), std::move(cview), "cview") ); - - return StatusCode::SUCCESS; -} - - +#if 0 /** * @brief Test schema evolution involving view container. */ StatusCode xAODTestWrite::write_htest() { - auto hvec = CxxUtils::make_unique<DMTest::HVec>(); - auto store = CxxUtils::make_unique<DMTest::HAuxContainer>(); + auto hvec = std::make_unique<DMTest::HVec>(); + auto store = std::make_unique<DMTest::HAuxContainer>(); hvec->setStore (store.get()); - auto hview = CxxUtils::make_unique<DMTest::HView>(); + auto hview = std::make_unique<DMTest::HView>(); for (int i = 0; i < 20; i++) { hvec->push_back (new DMTest::H); @@ -213,6 +178,7 @@ StatusCode xAODTestWrite::write_htest() return StatusCode::SUCCESS; } +#endif /** diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h index 944728ab08b8fbc56f97f1726f967dd8bf5a350d..59d9ea0cfe0213afec117ab512c4f8b5120c9db5 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h @@ -17,7 +17,7 @@ #define DATAMODELTESTDATAWRITE_XAODTESTWRITE_H -#include "DataModelTestDataWrite/HVec.h" +//#include "DataModelTestDataWrite/HVec.h" #include "DataModelTestDataCommon/CVec.h" #include "AthenaBaseComps/AthAlgorithm.h" #include "StoreGate/ReadHandleKey.h" @@ -64,17 +64,14 @@ private: /// Test writing container with additional data. StatusCode write_cvec_with_data(); - /// Test writing view container. - StatusCode write_cview (const DMTest::CVec& coll); - /// Test schema evolution involving view container. - StatusCode write_htest(); + //StatusCode write_htest(); /// Event counter. int m_count; SG::ReadHandleKey<DMTest::CVec> m_cvecKey; - SG::WriteHandleKey<DMTest::HVec> m_hvecKey; + //SG::WriteHandleKey<DMTest::HVec> m_hvecKey; }; diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCInfo.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCInfo.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4d4f4283dc831c2ee057dbd950f87f6b93d34dfa --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCInfo.cxx @@ -0,0 +1,98 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file DataModelTestDataWrite/src/xAODTestWriteCInfo.cxx + * @author snyder@bnl.gov + * @date Apr 2016 + * @brief Algorithm to test writing xAOD classes with auxiliary data (cinfo). + */ + + +#include "xAODTestWriteCInfo.h" +#include "EventInfo/EventID.h" +#include "DataModelTestDataCommon/C.h" +#include "DataModelTestDataCommon/CInfoAuxContainer.h" +#include "AthLinks/ElementLink.h" + + +namespace DMTest { + + +/** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ +xAODTestWriteCInfo::xAODTestWriteCInfo (const std::string &name, + ISvcLocator *pSvcLocator) + : AthReentrantAlgorithm (name, pSvcLocator), + m_eventInfoKey ("McEventInfo"), + m_cvecKey ("cvec"), + m_cinfoKey ("cinfo") +{ + declareProperty ("EventInfoKey", m_eventInfoKey); + declareProperty ("CVecKey", m_cvecKey); + declareProperty ("CInfoKey", m_cinfoKey); +} + + +/** + * @brief Algorithm initialization; called at the beginning of the job. + */ +StatusCode xAODTestWriteCInfo::initialize() +{ + ATH_CHECK( m_eventInfoKey.initialize() ); + ATH_CHECK( m_cvecKey.initialize() ); + ATH_CHECK( m_cinfoKey.initialize() ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm event processing. + */ +StatusCode xAODTestWriteCInfo::execute_r (const EventContext& ctx) const +{ + //SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey, ctx); + //unsigned int count = eventInfo->eventNumber() + 1; + SG::ReadHandle<EventInfo> eventInfo (m_eventInfoKey, ctx); + unsigned int count = eventInfo->event_ID()->event_number() + 1; + + SG::ReadHandle<DMTest::CVec> cvec (m_cvecKey, ctx); + + auto cinfo = std::make_unique<DMTest::C>(); + auto info_store = std::make_unique<DMTest::CInfoAuxContainer>(); + cinfo->setStore (info_store.get()); + + static C::Accessor<int> anInt2 ("anInt2"); + static C::Decorator<int> dInt1 ("dInt1"); + static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL"); + + cinfo->setAnInt (count * 1000); + cinfo->setAFloat ((float)count * 0.1); + anInt2(*cinfo) = count * 2000; + dInt1(*cinfo) = count * 3000; + + cEL(*cinfo).toIndexedElement (*cvec, count % cvec->size()); + + SG::WriteHandle<DMTest::C> cinfoH (m_cinfoKey, ctx); + CHECK( cinfoH.record (std::move(cinfo), std::move(info_store)) ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm finalization; called at the end of the job. + */ +StatusCode xAODTestWriteCInfo::finalize() +{ + return StatusCode::SUCCESS; +} + + +} // namespace DMTest + diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCInfo.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..6b0b9db6814adefd9714dc62735a47b7cee72579 --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCInfo.h @@ -0,0 +1,76 @@ +// 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 DataModelTestDataWrite/src/xAODTestWriteCInfo.h + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2016 + * @brief Algorithm to test writing xAOD classes with auxiliary data (cinfo). + */ + + +#ifndef DATAMODELTESTDATAWRITE_XAODTESTWRITECINFO_H +#define DATAMODELTESTDATAWRITE_XAODTESTWRITECINFO_H + + +//#include "xAODEventInfo/EventInfo.h" +#include "EventInfo/EventInfo.h" +#include "DataModelTestDataCommon/C.h" +#include "DataModelTestDataCommon/CVec.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/WriteHandleKey.h" +#include "StoreGate/ReadHandleKey.h" + + +namespace DMTest { + + +/** + * @brief Algorithm for creating test aux data. + */ +class xAODTestWriteCInfo + : public AthReentrantAlgorithm +{ +public: + /** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ + xAODTestWriteCInfo (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<xAOD::EventInfo> m_eventInfoKey; + SG::ReadHandleKey<EventInfo> m_eventInfoKey; + SG::ReadHandleKey<DMTest::CVec> m_cvecKey; + SG::WriteHandleKey<DMTest::C> m_cinfoKey; +}; + + +} // namespace DMTest + + +#endif // not DATAMODELTESTDATAWRITE_XAODTESTWRITECINFO_H diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx index b7d769c82dfd76ccd5d846f4339c11199b5b612a..b05585c5a7f2d0a4855aa792a40f2ca7b58444cb 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx @@ -77,6 +77,8 @@ StatusCode xAODTestWriteCVec::execute_r (const EventContext& ctx) const const static C::Accessor<int> anInt2 ("anInt2"); const static C::Decorator<int> dInt1 ("dInt1"); + const static C::Decorator<int> dVar1 ("dVar1"); + const static C::Decorator<int> dVar2 ("dVar2"); const static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL"); const static C::Decorator<unsigned int> dpInt1 ("dpInt1"); @@ -102,6 +104,8 @@ StatusCode xAODTestWriteCVec::execute_r (const EventContext& ctx) const anInt2(c) = count*300 + i+1; dInt1(c) = count*400 + i+1; + dVar1(c) = count*450 + i+1; + dVar2(c) = count*750 + i+1; dpInt1(c) = count*50 + i+1; cEL(c).toIndexedElement (*coll, 9-i); diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVecConst.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVecConst.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3f54d8c62cfe14972b9e3e2084ee3620d804a55c --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVecConst.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file DataModelTestDataWrite/src/xAODTestWriteCVecConst.cxx + * @author snyder@bnl.gov + * @date Jun, 2016 + * @brief Test recording a const aux obj via WriteHandle + */ + + +#include "xAODTestWriteCVecConst.h" +#include "DataModelTestDataCommon/CVec.h" +#include "DataModelTestDataCommon/C.h" +#include "DataModelTestDataCommon/CAuxContainer.h" +#include "AthContainersInterfaces/AuxDataOption.h" +#include "AthenaKernel/errorcheck.h" +#include "CxxUtils/make_unique.h" + + +namespace DMTest { + + +/** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ +xAODTestWriteCVecConst::xAODTestWriteCVecConst (const std::string &name, + ISvcLocator *pSvcLocator) + : AthReentrantAlgorithm (name, pSvcLocator), + m_cvecKey ("cvecConst") +{ + declareProperty ("CVecKey", m_cvecKey); +} + + +/** + * @brief Algorithm initialization; called at the beginning of the job. + */ +StatusCode xAODTestWriteCVecConst::initialize() +{ + ATH_CHECK( m_cvecKey.initialize() ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm event processing. + */ +StatusCode xAODTestWriteCVecConst::execute_r (const EventContext& ctx) const +{ + auto coll = CxxUtils::make_unique<DMTest::CVec>(); + auto store = CxxUtils::make_unique<DMTest::CAuxContainer>(); + coll->setStore (store.get()); + + SG::WriteHandle<DMTest::CVec> cvec (m_cvecKey, ctx); + CHECK( cvec.record (std::move(coll), std::move(store)) ); + + size_t count = ctx.evt(); + for (int i=0; i < 10; i++) { + cvec->push_back (new DMTest::C); + C& c = *cvec->back(); + c.setAnInt (count * 100 + i+1); + c.setAFloat (count * 200 + (float)i*0.1); + } + + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm finalization; called at the end of the job. + */ +StatusCode xAODTestWriteCVecConst::finalize() +{ + return StatusCode::SUCCESS; +} + + +} // namespace DMTest + diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVecConst.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVecConst.h new file mode 100644 index 0000000000000000000000000000000000000000..5802915bdc886a3df0c6682a21be9e3c1e169566 --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVecConst.h @@ -0,0 +1,69 @@ +// 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 DataModelTestDataWrite/src/xAODTestWriteCVecConst.h + * @author scott snyder <snyder@bnl.gov> + * @date Jun, 2016 + * @brief Test recording a const aux obj via WriteHandle + */ + + +#ifndef DATAMODELTESTDATAWRITE_XAODTESTWRITECVECCONST_H +#define DATAMODELTESTDATAWRITE_XAODTESTWRITECVECCONST_H + + +#include "DataModelTestDataCommon/CVec.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/WriteHandleKey.h" + + +namespace DMTest { + + +/** + * @brief Test recording a const aux obj via WriteHandle + */ +class xAODTestWriteCVecConst + : public AthReentrantAlgorithm +{ +public: + /** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ + xAODTestWriteCVecConst (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::WriteHandleKey<DMTest::CVec> m_cvecKey; +}; + + +} // namespace DMTest + + +#endif // not DATAMODELTESTDATAWRITE_XAODTESTWRITECVECCONST_H diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCView.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCView.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b9a3417d759cab6df01285e82c0aaa7370d23d95 --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCView.cxx @@ -0,0 +1,79 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file DataModelTestDataWrite/src/xAODTestWriteCView.cxx + * @author snyder@bnl.gov + * @date Apr 2016 + * @brief Algorithm to test writing an xAOD view vector (cview) + */ + + +#include "xAODTestWriteCView.h" +#include "xAODTestWriteHelper.h" +#include "DataModelTestDataCommon/CVec.h" +#include "DataModelTestDataCommon/CView.h" +#include "AthContainers/ConstDataVector.h" +#include "AthenaKernel/errorcheck.h" + + +namespace DMTest { + + +/** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ +xAODTestWriteCView::xAODTestWriteCView (const std::string &name, + ISvcLocator *pSvcLocator) + : AthReentrantAlgorithm (name, pSvcLocator), + m_cvecKey ("cvec"), + m_cviewKey ("cview") +{ + declareProperty ("CVecKey", m_cvecKey); + declareProperty ("CViewKey", m_cviewKey); +} + + +/** + * @brief Algorithm initialization; called at the beginning of the job. + */ +StatusCode xAODTestWriteCView::initialize() +{ + ATH_CHECK( m_cvecKey.initialize() ); + ATH_CHECK( m_cviewKey.initialize() ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm event processing. + */ +StatusCode xAODTestWriteCView::execute_r (const EventContext& ctx) const +{ + SG::ReadHandle<DMTest::CVec> cvec (m_cvecKey, ctx); + auto cview = std::make_unique<ConstDataVector<DMTest::CView> >(SG::VIEW_ELEMENTS); + for (int i = cvec->size()-1; i >= 0; --i) + cview->push_back ((*cvec)[i]); + + SG::WriteHandle<ConstDataVector<DMTest::CView> > cviewH (m_cviewKey, ctx); + CHECK( DMTest::recordView1 (cviewH, std::move(cview)) ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm finalization; called at the end of the job. + */ +StatusCode xAODTestWriteCView::finalize() +{ + return StatusCode::SUCCESS; +} + + +} // namespace DMTest + diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCView.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCView.h new file mode 100644 index 0000000000000000000000000000000000000000..89cf85142768914a2ef9b645609aa8a2fd4e7a37 --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCView.h @@ -0,0 +1,73 @@ +// 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 DataModelTestDataWrite/src/xAODTestWriteCView.h + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2016 + * @brief Algorithm to test writing an xAOD view vector (cview) + */ + + +#ifndef DATAMODELTESTDATAWRITE_XAODTESTWRITECVIEW_H +#define DATAMODELTESTDATAWRITE_XAODTESTWRITECVIEW_H + + +#include "DataModelTestDataCommon/CVec.h" +#include "DataModelTestDataCommon/CView.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthContainers/ConstDataVector.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" + + +namespace DMTest { + + +/** + * @brief Algorithm to test writing an xAOD view vector (cview) + */ +class xAODTestWriteCView + : public AthReentrantAlgorithm +{ +public: + /** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ + xAODTestWriteCView (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<ConstDataVector<DMTest::CView> > m_cviewKey; +}; + + +} // namespace DMTest + + +#endif // not DATAMODELTESTDATAWRITE_XAODTESTWRITECVIEW_H diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHVec.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHVec.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d091fc269321e02683e20048078887b5e2420d5f --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHVec.cxx @@ -0,0 +1,98 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file DataModelTestDataWrite/src/xAODTestWriteHVec.cxx + * @author snyder@bnl.gov + * @date Oct, 2016 + * @brief Algorithm to test writing xAOD classes for schema evolution (hvec/hview). + */ + + +#include "xAODTestWriteHVec.h" +#include "xAODTestWriteHelper.h" +#include "EventInfo/EventID.h" +#include "DataModelTestDataWrite/HVec.h" +#include "DataModelTestDataWrite/HView.h" +#include "DataModelTestDataWrite/H.h" +#include "DataModelTestDataWrite/HAuxContainer.h" + + +namespace DMTest { + + +/** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ +xAODTestWriteHVec::xAODTestWriteHVec (const std::string &name, + ISvcLocator *pSvcLocator) + : AthReentrantAlgorithm (name, pSvcLocator), + m_eventInfoKey ("McEventInfo"), + m_hvecKey ("hvec"), + m_hviewKey ("hview") +{ + declareProperty ("EventInfoKey", m_eventInfoKey); + declareProperty ("HVecKey", m_hvecKey); + declareProperty ("HViewKey", m_hviewKey); +} + + +/** + * @brief Algorithm initialization; called at the beginning of the job. + */ +StatusCode xAODTestWriteHVec::initialize() +{ + ATH_CHECK( m_eventInfoKey.initialize() ); + ATH_CHECK( m_hvecKey.initialize() ); + ATH_CHECK( m_hviewKey.initialize() ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm event processing. + */ +StatusCode xAODTestWriteHVec::execute_r (const EventContext& ctx) const +{ + SG::ReadHandle<EventInfo> eventInfo (m_eventInfoKey, ctx); + unsigned int count = eventInfo->event_ID()->event_number() + 1; + + auto hvec = std::make_unique<DMTest::HVec>(); + auto store = std::make_unique<DMTest::HAuxContainer>(); + hvec->setStore (store.get()); + auto hview = std::make_unique<DMTest::HView>(); + + for (int i = 0; i < 20; i++) { + hvec->push_back (new DMTest::H); + hvec->back()->setAnInt (i+1 + count * 400); + } + + for (int i = 0; i < 20; i++) { + hview->push_back (hvec->at (19-i)); + } + + ATH_CHECK( SG::makeHandle(m_hvecKey).record (std::move(hvec), + std::move(store)) ); + + SG::WriteHandle<DMTest::HView> hviewH (m_hviewKey, ctx); + ATH_CHECK( DMTest::recordView2 (hviewH, std::move(hview)) ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Algorithm finalization; called at the end of the job. + */ +StatusCode xAODTestWriteHVec::finalize() +{ + return StatusCode::SUCCESS; +} + + +} // namespace DMTest + diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHVec.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHVec.h new file mode 100644 index 0000000000000000000000000000000000000000..a932ea9f9ec657531496b9282c59c350d3fb644e --- /dev/null +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHVec.h @@ -0,0 +1,76 @@ +// 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 DataModelTestDataWrite/src/xAODTestWriteHVec.h + * @author scott snyder <snyder@bnl.gov> + * @date Oct, 2016 + * @brief Algorithm to test writing xAOD classes for schema evolution (hvec/hview). + */ + + +#ifndef DATAMODELTESTDATAWRITE_XAODTESTWRITEHVEC_H +#define DATAMODELTESTDATAWRITE_XAODTESTWRITEHVEC_H + + +//#include "xAODEventInfo/EventInfo.h" +#include "EventInfo/EventInfo.h" +#include "DataModelTestDataWrite/HVec.h" +#include "DataModelTestDataWrite/HView.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/WriteHandleKey.h" +#include "StoreGate/ReadHandleKey.h" + + +namespace DMTest { + + +/** + * @brief Algorithm to test writing xAOD classes for schema evolution (hvec/hview). + */ +class xAODTestWriteHVec + : public AthReentrantAlgorithm +{ +public: + /** + * @brief Constructor. + * @param name The algorithm name. + * @param svc The service locator. + */ + xAODTestWriteHVec (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<xAOD::EventInfo> m_eventInfoKey; + SG::ReadHandleKey<EventInfo> m_eventInfoKey; + SG::WriteHandleKey<DMTest::HVec> m_hvecKey; + SG::WriteHandleKey<DMTest::HView> m_hviewKey; +}; + + +} // namespace DMTest + + +#endif // not DATAMODELTESTDATAWRITE_XAODTESTWRITEHVEC_H diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx index f5841d11bb6749bbd2d6f6b3ee61e318673a046d..e4a35f297c01753de4ca7a77730ba63ada20cd45 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx @@ -18,19 +18,17 @@ namespace DMTest { -StatusCode recordView1 (StoreGateSvc* svc, - std::unique_ptr<ConstDataVector<ViewVector<DMTest::CVec> > > view, - const std::string& key) +StatusCode recordView1 (SG::WriteHandle<ConstDataVector<ViewVector<DMTest::CVec> > >& h, + std::unique_ptr<ConstDataVector<ViewVector<DMTest::CVec> > > view) { - return svc->record (std::move(view), key, false); + return h.record (std::move (view)); } -StatusCode recordView2 (StoreGateSvc* svc, - std::unique_ptr<DMTest::HVec> view, - const std::string& key) +StatusCode recordView2 (SG::WriteHandle<ViewVector<DMTest::HVec> >& h, + std::unique_ptr<ViewVector<DMTest::HVec> > view) { - return svc->record (std::move(view), key, false); + return h.record (std::move (view)); } diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h index 90756ff55fab09f0c5fd7f8d3b4dd105747730e3..9b154a831beb85ba3d6a81c916392a17f46717e6 100644 --- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h +++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h @@ -20,6 +20,7 @@ #include "DataModelTestDataCommon/CVec.h" #include "DataModelTestDataWrite/HVec.h" +#include "StoreGate/WriteHandle.h" #include "StoreGate/StoreGateSvc.h" #include "AthContainers/ViewVector.h" #include "AthContainers/ConstDataVector.h" @@ -28,14 +29,12 @@ namespace DMTest { -StatusCode recordView1 (StoreGateSvc* svc, - std::unique_ptr<ConstDataVector<ViewVector<DMTest::CVec> > > view, - const std::string& key); +StatusCode recordView1 (SG::WriteHandle<ConstDataVector<ViewVector<DMTest::CVec> > >& h, + std::unique_ptr<ConstDataVector<ViewVector<DMTest::CVec> > > view); -StatusCode recordView2 (StoreGateSvc* svc, - std::unique_ptr<DMTest::HVec> view, - const std::string& key); +StatusCode recordView2 (SG::WriteHandle<ViewVector<DMTest::HVec> >& h, + std::unique_ptr<ViewVector<DMTest::HVec> > view); } // namespace DMTest