Skip to content
Snippets Groups Projects
Commit b993fdfe authored by Scott Snyder's avatar Scott Snyder Committed by scott snyder
Browse files

Add some testing of read/write handle arrays to AthExStoreGateExample.

Add versions of makeHandles methods of arrays that take an EventContext.


Former-commit-id: b240cd6269e4d0d60e480bcb6ba4864ac6e0db6d
parent f715bbe0
No related branches found
No related tags found
8 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!28528Revert 63f845ae,!27054Atr20369 210,!26342Monopole: Handle fractionally charged particles
This diff is collapsed.
...@@ -20,8 +20,8 @@ theApp.EvtMax = 3 ...@@ -20,8 +20,8 @@ theApp.EvtMax = 3
from AthenaCommon.AlgSequence import AlgSequence from AthenaCommon.AlgSequence import AlgSequence
topSeq = AlgSequence() topSeq = AlgSequence()
topSeq += CfgMgr.WriteDataReentrant() topSeq += CfgMgr.WriteDataReentrant(DObjKeyArray = ['x1', 'x2', 'x3'])
topSeq += CfgMgr.ReadDataReentrant() topSeq += CfgMgr.ReadDataReentrant(DObjKeyArray = ['x1', 'x2', 'x3'])
# setup output level # setup output level
from AthenaCommon.AppMgr import ServiceMgr as svcMgr from AthenaCommon.AppMgr import ServiceMgr as svcMgr
......
...@@ -48,7 +48,7 @@ ReadDataReentrant::ReadDataReentrant(const std::string& name, ISvcLocator* pSvcL ...@@ -48,7 +48,7 @@ ReadDataReentrant::ReadDataReentrant(const std::string& name, ISvcLocator* pSvcL
declareProperty ("PLinkListKey", m_pLinkListKey = std::string("WriteDataReentrant")); declareProperty ("PLinkListKey", m_pLinkListKey = std::string("WriteDataReentrant"));
declareProperty ("LinkVectorKey", m_linkVectorKey = std::string("linkvec")); declareProperty ("LinkVectorKey", m_linkVectorKey = std::string("linkvec"));
declareProperty ("TestObjectKey", m_testObjectKey = "testobj"); declareProperty ("TestObjectKey", m_testObjectKey = "testobj");
declareProperty ("DObjKeyArray", m_dobjKeyArray = {"dobj_a1", "dobj_a2"});
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
...@@ -66,6 +66,7 @@ StatusCode ReadDataReentrant::initialize() ...@@ -66,6 +66,7 @@ StatusCode ReadDataReentrant::initialize()
ATH_CHECK( m_pLinkListKey.initialize() ); ATH_CHECK( m_pLinkListKey.initialize() );
ATH_CHECK( m_linkVectorKey.initialize() ); ATH_CHECK( m_linkVectorKey.initialize() );
ATH_CHECK( m_testObjectKey.initialize() ); ATH_CHECK( m_testObjectKey.initialize() );
ATH_CHECK( m_dobjKeyArray.initialize() );
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -120,6 +121,13 @@ StatusCode ReadDataReentrant::execute_r (const EventContext& ctx) const ...@@ -120,6 +121,13 @@ StatusCode ReadDataReentrant::execute_r (const EventContext& ctx) const
SG::ReadHandle<TestDataObject> testobj (m_testObjectKey, ctx); SG::ReadHandle<TestDataObject> testobj (m_testObjectKey, ctx);
if (testobj->val() != 10) std::abort(); if (testobj->val() != 10) std::abort();
// Reading the array of handles.
std::vector<SG::ReadHandle<MyDataObj> > vh = m_dobjKeyArray.makeHandles (ctx);
for (size_t i = 0; i < vh.size(); i++) {
assert (vh[i]->val() == static_cast<int> (100+i));
++i;
}
#if 0 #if 0
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
......
...@@ -42,6 +42,7 @@ private: ...@@ -42,6 +42,7 @@ private:
SG::ReadHandleKey<std::list<ElementLink<std::vector<float> > > > m_pLinkListKey; SG::ReadHandleKey<std::list<ElementLink<std::vector<float> > > > m_pLinkListKey;
SG::ReadHandleKey<std::vector<ElementLink<MapStringFloat> > > m_linkVectorKey; SG::ReadHandleKey<std::vector<ElementLink<MapStringFloat> > > m_linkVectorKey;
SG::ReadHandleKey<TestDataObject> m_testObjectKey; SG::ReadHandleKey<TestDataObject> m_testObjectKey;
SG::ReadHandleKeyArray<MyDataObj> m_dobjKeyArray;
}; };
......
...@@ -49,6 +49,7 @@ WriteDataReentrant::WriteDataReentrant(const std::string& name, ...@@ -49,6 +49,7 @@ WriteDataReentrant::WriteDataReentrant(const std::string& name,
declareProperty ("MKey", m_mKey = "mkey"); declareProperty ("MKey", m_mKey = "mkey");
declareProperty ("LinkVectorKey", m_linkVectorKey = "linkvec"); declareProperty ("LinkVectorKey", m_linkVectorKey = "linkvec");
declareProperty ("TestObjectKey", m_testObjectKey = "testobj"); declareProperty ("TestObjectKey", m_testObjectKey = "testobj");
declareProperty ("DObjKeyArray", m_dobjKeyArray = {"dobj_a1", "dobj_a2"});
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
...@@ -68,6 +69,7 @@ StatusCode WriteDataReentrant::initialize() ...@@ -68,6 +69,7 @@ StatusCode WriteDataReentrant::initialize()
ATH_CHECK( m_mKey.initialize() ); ATH_CHECK( m_mKey.initialize() );
ATH_CHECK( m_linkVectorKey.initialize() ); ATH_CHECK( m_linkVectorKey.initialize() );
ATH_CHECK( m_testObjectKey.initialize() ); ATH_CHECK( m_testObjectKey.initialize() );
ATH_CHECK( m_dobjKeyArray.initialize() );
m_testObject = m_testObject =
SG::DataObjectSharedPtr<TestDataObject> (new TestDataObject(10)); SG::DataObjectSharedPtr<TestDataObject> (new TestDataObject(10));
...@@ -126,6 +128,14 @@ StatusCode WriteDataReentrant::execute_r (const EventContext& ctx) const ...@@ -126,6 +128,14 @@ StatusCode WriteDataReentrant::execute_r (const EventContext& ctx) const
assert (pp == &*dobj4); assert (pp == &*dobj4);
} }
#endif #endif
// Writing an array of objects.
size_t i = 0;
for (const SG::WriteHandleKey<MyDataObj>& k : m_dobjKeyArray) {
SG::WriteHandle<MyDataObj> h (k, ctx);
ATH_CHECK( h.record (std::make_unique<MyDataObj> (i+100)) );
++i;
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "StoreGateExample_ClassDEF.h" #include "StoreGateExample_ClassDEF.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "StoreGate/WriteHandleKey.h" #include "StoreGate/WriteHandleKey.h"
#include "StoreGate/WriteHandleKeyArray.h"
class WriteDataReentrant class WriteDataReentrant
...@@ -45,6 +46,8 @@ private: ...@@ -45,6 +46,8 @@ private:
SG::WriteHandleKey<std::vector<ElementLink<MapStringFloat> > > m_linkVectorKey; SG::WriteHandleKey<std::vector<ElementLink<MapStringFloat> > > m_linkVectorKey;
SG::WriteHandleKey<TestDataObject> m_testObjectKey; SG::WriteHandleKey<TestDataObject> m_testObjectKey;
SG::WriteHandleKeyArray<MyDataObj> m_dobjKeyArray;
SG::DataObjectSharedPtr<TestDataObject> m_testObject; SG::DataObjectSharedPtr<TestDataObject> m_testObject;
StatusCode onError() const; StatusCode onError() const;
}; };
......
...@@ -83,6 +83,20 @@ namespace SG { ...@@ -83,6 +83,20 @@ namespace SG {
return ( std::move( hndl ) ); return ( std::move( hndl ) );
} }
/**
* @brief create a vector of ReadHandles from the ReadHandleKeys
* in the array, with explicit EventContext.
*/
std::vector< ReadHandle<T> > makeHandles (const EventContext& ctx) const
{
std::vector< ReadHandle<T> > hndl;
typename std::vector<ReadHandleKey<T>>::const_iterator itr;
for (itr = this->begin(); itr != this->end(); ++itr) {
hndl.push_back ( ReadHandle<T>( *itr, ctx ) );
}
return ( std::move( hndl ) );
}
}; };
......
...@@ -83,6 +83,20 @@ namespace SG { ...@@ -83,6 +83,20 @@ namespace SG {
return ( std::move( hndl ) ); return ( std::move( hndl ) );
} }
/**
* @brief create a vector of WriteHandles from the WriteHandleKeys
* in the array, with explicit EventContext.
*/
std::vector< WriteHandle<T> > makeHandles (const EventContext& ctx) const
{
std::vector< WriteHandle<T> > hndl;
typename std::vector<WriteHandleKey<T>>::const_iterator itr;
for (itr = this->begin(); itr != this->end(); ++itr) {
hndl.push_back ( WriteHandle<T>( *itr, ctx) );
}
return ( std::move( hndl ) );
}
}; };
......
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