diff --git a/Control/AthenaExamples/AthExStoreGateExample/AthExStoreGateExample/MyDataObj.h b/Control/AthenaExamples/AthExStoreGateExample/AthExStoreGateExample/MyDataObj.h index dbe5069a6c1b10f444c3f0f253e3906df1ae8dc6..4cead79abb034d8ea852d69868a6e04b766eeded 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/AthExStoreGateExample/MyDataObj.h +++ b/Control/AthenaExamples/AthExStoreGateExample/AthExStoreGateExample/MyDataObj.h @@ -2,8 +2,10 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef _MYDATAOBJ_ -#define _MYDATAOBJ_ +#ifndef ATHEXSTOREGATEEXAMPLE_MYDATAOBJ_H +#define ATHEXSTOREGATEEXAMPLE_MYDATAOBJ_H + +#include "GaudiKernel/DataObject.h" //sample data class for the Read/Write example //it just wraps an int. Notice that is does not inherit from Gaudi DataObject @@ -25,13 +27,29 @@ public: private: int m_val; }; + + +// This does inherit from DataObject. +class TestDataObject + : public DataObject +{ +public: + TestDataObject(int i=0): m_val(i) {}; + + void val(int i) { m_val = i; } + int val() const { return m_val; } + +private: + int m_val; +}; + + //using the macros below we can assign an identifier (and a version) //to the type MyDataObj //This is required and checked at compile time when you try to record/retrieve #include "SGTools/CLASS_DEF.h" CLASS_DEF(MyDataObj, 8000, 1) CLASS_DEF(BaseClass, 1434, 1) +CLASS_DEF(TestDataObject, 289238765, 1) #endif - - diff --git a/Control/AthenaExamples/AthExStoreGateExample/CMakeLists.txt b/Control/AthenaExamples/AthExStoreGateExample/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2efdef26bac25837327324fbf2818d3b670e0601 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/CMakeLists.txt @@ -0,0 +1,64 @@ +################################################################################ +# Package: AthExStoreGateExample +################################################################################ + +# Declare the package name: +atlas_subdir( AthExStoreGateExample ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaKernel + Control/SGTools + PRIVATE + AtlasTest/TestTools + Control/AthContainers + Control/AthLinks + Control/AthenaBaseComps + Control/CxxUtils + Control/PileUpTools + Control/StoreGate + Event/EventInfo + GaudiKernel ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( SGTutorialLib + Tutorial/LinkObj.cxx + Tutorial/SGRead.cxx + Tutorial/SGWrite.cxx + PUBLIC_HEADERS AthExStoreGateExample + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES AthenaKernel SGTools PileUpToolsLib StoreGateLib SGtests + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthContainers AthLinks AthenaBaseComps CxxUtils EventInfo GaudiKernel ) + +atlas_add_library( SGTutorial + Tutorial/SGTutorial_entries.cxx + Tutorial/SGTutorial_load.cxx + PUBLIC_HEADERS AthExStoreGateExample + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES AthenaKernel SGTools PileUpToolsLib StoreGateLib SGtests SGTutorialLib + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthContainers AthLinks AthenaBaseComps CxxUtils EventInfo GaudiKernel ) + +atlas_add_component( AthExStoreGateExample + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel SGTools TestTools AthContainers AthLinks AthenaBaseComps CxxUtils PileUpToolsLib StoreGateLib SGtests EventInfo GaudiKernel SGTutorialLib SGTutorial ) + +atlas_add_component( AthExDFlow + src_dflow/*.cxx + src_dflow/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel SGTools TestTools AthContainers AthLinks AthenaBaseComps CxxUtils PileUpToolsLib StoreGateLib SGtests EventInfo GaudiKernel SGTutorialLib SGTutorial ) + +atlas_add_dictionary( AthExStoreGateExampleDict + AthExStoreGateExample/AthExStoreGateExampleDict.h + AthExStoreGateExample/selection.xml + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel SGTools TestTools AthContainers AthLinks AthenaBaseComps CxxUtils PileUpToolsLib StoreGateLib SGtests EventInfo GaudiKernel SGTutorialLib SGTutorial ) + +# Install files from the package: +atlas_install_joboptions( share/StoreGateExample_Gen_jobOptions.txt share/StoreGateExample_Gen_jobOptions.py share/StoreGateExample_Del_jobOptions.py share/StoreGateExample_Reentrant_jobOptions.py share/dflow_jobo.py share/StoreGateHiveExample.py ) + diff --git a/Control/AthenaExamples/AthExStoreGateExample/Tutorial/LinkObj.h b/Control/AthenaExamples/AthExStoreGateExample/Tutorial/LinkObj.h index 9b7fc2cabbb027292f56ff76920b3389c5f102ea..41acaaa8edf32c702cdc0c614ec345ce4e3e9db9 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/Tutorial/LinkObj.h +++ b/Control/AthenaExamples/AthExStoreGateExample/Tutorial/LinkObj.h @@ -2,13 +2,13 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef _LinkObj_ -#define _LinkObj_ +#ifndef ATHEXSTOREGATEEXAMPLE_LINKOBJ_H +#define ATHEXSTOREGATEEXAMPLE_LINKOBJ_H #include <vector> -#include "DataModel/DataLink.h" -#include "DataModel/ElementLink.h" +#include "AthLinks/DataLink.h" +#include "AthLinks/ElementLink.h" #include "MyDataObj.h" #include "MyElement.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGRead.cxx b/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGRead.cxx index d84de552b3c70be182806c2e0e402775e21cc5f2..e095cdb1917a842a8c444242ecceb882aa6fd80d 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGRead.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGRead.cxx @@ -10,8 +10,8 @@ #include "GaudiKernel/ISvcLocator.h" -#include "DataModel/DataLink.h" -#include "DataModel/ElementLink.h" +#include "AthLinks/DataLink.h" +#include "AthLinks/ElementLink.h" #include "StoreGate/StoreGateSvc.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGWrite.cxx b/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGWrite.cxx index 816d7e29e368a6ef8f999904a8fcbcc5bb0522f2..3edccaa90ae68b3e68f8fb2682edd90570404189 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGWrite.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/Tutorial/SGWrite.cxx @@ -10,8 +10,8 @@ #include "GaudiKernel/ISvcLocator.h" -#include "DataModel/DataLink.h" -#include "DataModel/ElementLink.h" +#include "AthLinks/DataLink.h" +#include "AthLinks/ElementLink.h" #include "StoreGate/StoreGateSvc.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/cmt/requirements b/Control/AthenaExamples/AthExStoreGateExample/cmt/requirements index 9c6c1ad5471e18a1edc7493a379d468ec71209b1..587bb8035c308f82ea250b3d9b442a3abb374875 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/cmt/requirements +++ b/Control/AthenaExamples/AthExStoreGateExample/cmt/requirements @@ -9,10 +9,10 @@ use AthenaKernel AthenaKernel-* Control use SGTools SGTools-* Control private +use TestTools TestTools-* AtlasTest use AthLinks AthLinks-* Control -#need make_unique +use AthContainers AthContainers-* Control use CxxUtils CxxUtils-* Control -use DataModel DataModel-* Control use AthenaBaseComps AthenaBaseComps-* Control use EventInfo EventInfo-* Event use GaudiInterface GaudiInterface-* External @@ -32,6 +32,7 @@ apply_pattern declare_joboptions files="\ StoreGateExample_Gen_jobOptions.txt \ StoreGateExample_Gen_jobOptions.py \ StoreGateExample_Del_jobOptions.py \ + StoreGateExample_Reentrant_jobOptions.py \ dflow_jobo.py \ StoreGateHiveExample.py \ " @@ -81,3 +82,5 @@ macro_append SGTutorialLib_shlibflags "$(libraryshr_linkopts) $(cmt_installarea_ macro SGTutorialLib_linkopts "-L$(bin) -lSGTutorialLib" macro SGTutorial_shlibflags "$(componentshr_linkopts) -L$(bin) -lSGTutorialLib $(SGTutoriallinkopts) $(use_linkopts)" +apply_pattern optdebug_library name=SGTutorial +apply_pattern optdebug_library name=SGTutorialLib diff --git a/Control/AthenaExamples/AthExStoreGateExample/share/StoreGateExample_Reentrant_jobOptions.py b/Control/AthenaExamples/AthExStoreGateExample/share/StoreGateExample_Reentrant_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..2f679a85cdc32b9b56bb35fea160adf6fb863d72 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/share/StoreGateExample_Reentrant_jobOptions.py @@ -0,0 +1,41 @@ +############################################################### +# +# AthExStoreGateExample Job options file reading Generated events +# +#============================================================== +#import AthenaCommon.AtlasUnixStandardJob +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +from AthenaCommon.AppMgr import theApp +# dummy event loop +theApp.EvtSel = "NONE" +# Number of events to be processed (default is 10) +theApp.EvtMax = 3 + + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +from AthenaCommon.AlgSequence import AlgSequence +topSeq = AlgSequence() + +topSeq += CfgMgr.WriteDataReentrant() +topSeq += CfgMgr.ReadDataReentrant() + +# setup output level +from AthenaCommon.AppMgr import ServiceMgr as svcMgr +if not hasattr (svcMgr, 'StoreGateSvc'): + svcMgr += CfgMgr.StoreGateSvc() +svcMgr.StoreGateSvc.OutputLevel = VERBOSE +#svcMgr.StoreGateSvc.Dump = False #True will dump data store contents + +svcMgr.MessageSvc.useColors = True +#svcMgr.MessageSvc.OutputLevel = Lvl.DEBUG + + +#============================================================== +# +# End of AthExStoreGateExample Job options file +# +############################################################### diff --git a/Control/AthenaExamples/AthExStoreGateExample/share/StoreGateHiveExample_Reentrant_jobOptions.py b/Control/AthenaExamples/AthExStoreGateExample/share/StoreGateHiveExample_Reentrant_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..182a64a856b4799b79049a5adeb66e8d1d00b074 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/share/StoreGateHiveExample_Reentrant_jobOptions.py @@ -0,0 +1,88 @@ +############################################################### +# +# AthExStoreGateExample Job options file reading Generated events +# +#============================================================== +#import AthenaCommon.AtlasUnixStandardJob +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +import AthenaCommon.AtlasUnixGeneratorJob + +theApp.MessageSvcType = "TBBMessageSvc" + +from AthenaServices.AthenaServicesConf import AthenaHiveEventLoopMgr + +svcMgr += AthenaHiveEventLoopMgr() +# svcMgr.AthenaHiveEventLoopMgr.OutputLevel = DEBUG + +theApp.EventLoop = "AthenaHiveEventLoopMgr" + +svcMgr.StatusCodeSvc.AbortOnError = False + +numStores = 1 + +from StoreGate.StoreGateConf import SG__HiveMgrSvc +svcMgr += SG__HiveMgrSvc("EventDataSvc") +svcMgr.EventDataSvc.NSlots = numStores + +from GaudiHive.GaudiHiveConf import ForwardSchedulerSvc +svcMgr += ForwardSchedulerSvc() +svcMgr.ForwardSchedulerSvc.OutputLevel = DEBUG +svcMgr.ForwardSchedulerSvc.MaxEventsInFlight = numStores +svcMgr.ForwardSchedulerSvc.MaxAlgosInFlight = 1 +svcMgr.ForwardSchedulerSvc.ThreadPoolSize = 1 + +svcMgr.ForwardSchedulerSvc.AlgosDependencies = [[],['8000/WriteData'],[],[]] + + +svcMgr += AthenaHiveEventLoopMgr() +svcMgr.AthenaHiveEventLoopMgr.WhiteboardSvc = "EventDataSvc" +svcMgr.AthenaHiveEventLoopMgr.OutputLevel = DEBUG + +from StoreGate.StoreGateConf import SG__HiveMgrSvc +svcMgr += SG__HiveMgrSvc("EventDataSvc") +svcMgr.EventDataSvc.NSlots = numStores +svcMgr.EventDataSvc.OutputLevel = DEBUG + +from StoreGate.StoreGateConf import StoreGateSvc +svcMgr += StoreGateSvc() +svcMgr.StoreGateSvc.OutputLevel = VERBOSE +svcMgr.StoreGateSvc.Dump = True + +from StoreGate.StoreGateConf import SGImplSvc +svcMgr += SGImplSvc("SGImplSvc") +svcMgr.SGImplSvc.OutputLevel = VERBOSE + + +# dummy event loop +#theApp.EvtSel = "NONE" +# Number of events to be processed (default is 10) +theApp.EvtMax = 500 + + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +from AthenaCommon.AlgSequence import AlgSequence +topSeq = AlgSequence() + +topSeq += CfgMgr.WriteDataReentrant() +topSeq += CfgMgr.ReadDataReentrant() + +# setup output level +from AthenaCommon.AppMgr import ServiceMgr as svcMgr +if not hasattr (svcMgr, 'StoreGateSvc'): + svcMgr += CfgMgr.StoreGateSvc() +svcMgr.StoreGateSvc.OutputLevel = VERBOSE +#svcMgr.StoreGateSvc.Dump = False #True will dump data store contents + +svcMgr.MessageSvc.useColors = True +#svcMgr.MessageSvc.OutputLevel = Lvl.DEBUG + + +#============================================================== +# +# End of AthExStoreGateExample Job options file +# +############################################################### diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/MyContObj.h b/Control/AthenaExamples/AthExStoreGateExample/src/MyContObj.h index b986287492669973ae91660cc07c4c800bc4e505..d9538ea827ef19846879eee7c6d87b2516141e4b 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/src/MyContObj.h +++ b/Control/AthenaExamples/AthExStoreGateExample/src/MyContObj.h @@ -2,8 +2,8 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef _MYCONTOBJ_ -#define _MYCONTOBJ_ +#ifndef ATHEXSTOREGATEEXAMPLE_MYCONTOBJ_H +#define ATHEXSTOREGATEEXAMPLE_MYCONTOBJ_H //sample data class for the Read/Write example //Notice that is does not inherit from Gaudi ContainedObject @@ -27,9 +27,3 @@ public: }; #endif - - - - - - diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/ReadData.cxx b/Control/AthenaExamples/AthExStoreGateExample/src/ReadData.cxx index b0accc89f468486d8810a3a412afe8bf3de9c2eb..5718f6e7b6ee5ad1d593aea0a15ca52169b533f4 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/src/ReadData.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src/ReadData.cxx @@ -16,10 +16,10 @@ #include "GaudiKernel/ISvcLocator.h" #include "EventInfo/EventInfo.h" #include "EventInfo/EventID.h" -#include "DataModel/DataVector.h" +#include "AthContainers/DataVector.h" #include "StoreGate/SGIterator.h" -#include "DataModel/ElementLink.h" +#include "AthLinks/ElementLink.h" #include "AthenaKernel/DefaultKey.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/ReadDataReentrant.cxx b/Control/AthenaExamples/AthExStoreGateExample/src/ReadDataReentrant.cxx new file mode 100644 index 0000000000000000000000000000000000000000..89e56c238c25f7ae90907994592504d99d524285 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/src/ReadDataReentrant.cxx @@ -0,0 +1,288 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ReadDataReentrant.h + * @author scott snyder <snyder@bnl.gov> + * @date Jan, 2016 + * @brief + */ + + +#undef NDEBUG +#include "ReadDataReentrant.h" + +#include <list> +#include <map> +#include <vector> +#include "AthExStoreGateExample/MyDataObj.h" +#include "MyContObj.h" +#include "MapStringFloat.h" +#include "StoreGateExample_ClassDEF.h" /*the CLIDs for the containers*/ + +#include "GaudiKernel/ISvcLocator.h" +#include "EventInfo/EventInfo.h" +#include "EventInfo/EventID.h" +#include "AthContainers/DataVector.h" + +#include "StoreGate/SGIterator.h" +#include "StoreGate/UpdateHandle.h" +#include "StoreGate/ReadHandle.h" +#include "AthLinks/ElementLink.h" + +#include "AthenaKernel/DefaultKey.h" + +///////////////////////////////////////////////////////////////////////////// + +ReadDataReentrant::ReadDataReentrant(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name, pSvcLocator) +{ + + declareProperty ("DObjKey3", m_dobjKey3 = std::string("WriteDataReentrant")); + declareProperty ("CObjKey", m_cobjKey = std::string("cobj")); + declareProperty ("VFloatKey", m_vFloatKey = std::string("vFloat")); + //declareProperty ("NonExistingKey", m_nonexistingKey = std::string("FunnyNonexistingKey")); + declareProperty ("PLinkListKey", m_pLinkListKey = std::string("WriteDataReentrant")); + declareProperty ("LinkVectorKey", m_linkVectorKey = std::string("linkvec")); + declareProperty ("TestObjectKey", m_testObjectKey = "testobj"); + +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode ReadDataReentrant::initialize(){ + + + ATH_MSG_INFO ("in initialize()"); + + ATH_CHECK( m_dobjKey3.initialize() ); + ATH_CHECK( m_cobjKey.initialize() ); + ATH_CHECK( m_vFloatKey.initialize() ); + //ATH_CHECK( m_nonexistingKey.initialize() ); + ATH_CHECK( m_pLinkListKey.initialize() ); + ATH_CHECK( m_linkVectorKey.initialize() ); + ATH_CHECK( m_testObjectKey.initialize() ); + + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode ReadDataReentrant::execute_r (const EventContext& ctx) const +{ + + // An algorithm, like this one, retrieving an object from the StoreGate(SG) + // can either ask for: + // i) the most recent (default) object of a given type + // ii) a specific object of a given type + // iii) all objects of a given type + //This example will show how to perform these three tasks + + + ATH_MSG_INFO ("in execute()"); + + ///////////////////////////////////////////////////////////////////// + // Part 1: retrieving individual objects from SG + // + // i)Get the most recent (default) object of type MyDataObj + // we start by creating a *const* pointer: we won't be able + // to modify the MyDataObj we retrieve. + //unless you know what you are doing, *always* use const pointers + //FIXME const MyDataObj* dobj; + + //We pass the pointer to the StoreGate that will set it to point to + //the default MyDataObj. More precisely the handle will now contain + //all infos necessary to access (or create) the default MyDataObj when + //we will use it + //FIXME new (tag StoreGate-02-12-08) keyless record scheme does not allow it! + //FIXME if (StatusCode::SUCCESS != p_SGevent->retrieve(dobj) ) { + //FIXME log << MSG::ERROR + //FIXME << "Could not find default MyDataObj" + //FIXME << endreq; + //FIXME return( StatusCode::FAILURE); + //FIXME } + //FIXME log << MSG::INFO + //FIXME << "default MyDataObj Val: " << dobj->val() + //FIXME << endreq; + + ///////////////////////////////////////////////////////////////////// + // ii) Get a specific MyDataObj by providing its key + // (in this case the name of the algo which recorded it) + + //this time we set a *non-const* pointer. *If* we get back a valid + //pointer we'll be able to modify the content of the underlying transient obj + SG::UpdateHandle<MyDataObj> dobj3 (m_dobjKey3, ctx); + dobj3->val(4); + + SG::ReadHandle<TestDataObject> testobj (m_testObjectKey, ctx); + if (testobj->val() != 10) std::abort(); + +#if 0 + ///////////////////////////////////////////////////////////////////// + // iii) Get all recorded instances of MyDataObj, print out their contents + + // (a SG::ConstIterator is an iterator class that we also use to defer + // and control the access to the persistent object) + SG::ConstIterator<MyDataObj> iMyD; + SG::ConstIterator<MyDataObj> eMyD; + + if (StatusCode::SUCCESS != evtStore()->retrieve(iMyD, eMyD) ) { + ATH_MSG_ERROR ("Could not find MyDataObj list"); + return( StatusCode::FAILURE); + } + + // while(iMyD != eMyD) { + // ATH_MSG_INFO ((*iMyD).val()); + // ++iMyD; + // } + ATH_MSG_WARNING ("FIXME loop of ConstIterator bombs"); +#endif + + + +//////////////////////////////////////////////////////////////////// +// Get the default listof MyContObj, print out its contents + + //the CLID of list<MyContObj> must be defined using the CLASSDEF + //macros. See StoreGateExample_ClassDEF.h for a few examples + //If no CLID is defined StoreGate assumes the object is (convertible to a) + //DataObject. If this is not the case an error message is issued: + //uncomment below to see how your compiler catches an undefined CLID + //ERROR p_SGevent->retrieve(errorH); + + SG::ReadHandle<DataVector<MyContObj> > list (m_cobjKey, ctx); + for (const MyContObj* obj : *list) { + float time = obj->time(); + int ID = obj->id(); + + ATH_MSG_INFO ("Time: " << time << " ID: " << ID); + } + + ///////////////////////////////////////////////////////////////////// + +// Get the std::vector, print out its contents + + SG::ReadHandle<std::vector<float> > pVec (m_vFloatKey, ctx); + for (unsigned int it=0; it<pVec->size(); it++) { + ATH_MSG_INFO ("pVec [" << it << "] = " << (*pVec)[it]); + } + + ///////////////////////////////////////////////////////////////////// + // test if an object is in the store + //FIXME if (p_SGevent->contains<MyDataObj>(SG::DEFAULTKEY)) { + //FIXME log << MSG::INFO + //FIXME <<"event store contains default MyDataObj" + //FIXME <<endreq; + //FIXME } else { + //FIXME log << MSG::ERROR + //FIXME <<"event store claims it does not contain default MyDataObj" + //FIXME <<endreq; + //FIXME return( StatusCode::FAILURE); + //FIXME } + +#if 0 + // test if an object is not in the store + const SG::ReadHandle<MyDataObj> nonexisting (m_nonexistingKey, ctx); + if (nonexisting.isValid()) { + ATH_MSG_ERROR + ("event store claims it contains MyDataObj with FunnyNonExistingKey"); + return( StatusCode::FAILURE); + } else { + ATH_MSG_INFO + ("event store does not contain MyDataObj with FunnyNonExistingKey"); + } +#endif + + + ///////////////////////////////////////////////////////////////////// + // Part 2: retrieving DataLinks + + // Get the list of links, print out its contents + + typedef ElementLink<std::vector<float> > VecElemLink; + auto pList = SG::makeHandle (m_pLinkListKey, ctx); + for (const VecElemLink& l : *pList) { + ATH_MSG_INFO ("ListVecLinks::linked element " << *l); + } + + // Get the vector of links, print out its contents + typedef ElementLink<MapStringFloat> MapElemLink; + SG::ReadHandle<std::vector<MapElemLink> > vectorHandle (m_linkVectorKey, ctx); + for (const MapElemLink& l : *vectorHandle) { + ATH_MSG_INFO + ("VectorMapLinks::linked element: key " << l.index() + << " - value " << (*l) + << " - stored as " << l); + } + + //try to "read back" a link + // istrstream istr("due 0"); + // MapElemLink toBeRead; + // istr >> toBeRead; + // if (!toBeRead.isValid()) { + // log << MSG::ERROR + // << "Could not read back MapElement" + // << endreq; + // return( StatusCode::FAILURE); + // } else { + // log << MSG::INFO << "MapElement read back: key " << toBeRead->first + // << " value " << toBeRead->second <<endreq; + // } + + ///////////////////////////////////////////////////////////////////// + // Part 3: symbolic links and derived types + // Get all objects as its base class + +#if 0 + SG::ConstIterator<BaseClass> it2; + SG::ConstIterator<BaseClass> iEnd2; + + if (StatusCode::SUCCESS != evtStore()->retrieve(it2, iEnd2) ) { + + ATH_MSG_ERROR ("Could not find base class list"); + return( StatusCode::FAILURE); + } + + // not much we can do with an empty base class, + // so print the path of its persistable companion (the DataBucket) + ATH_MSG_INFO (" retrieve as BaseClass, print its address: "); + while(it2 != iEnd2) { + ATH_MSG_INFO (&*it2); + ++it2; + } +#endif + + ///////////////////////////////////////////////////////////////////// + // Part 4: Get the event header, print out event and run number + +#if 0 + int event, run; + + const EventInfo* evt; + if (StatusCode::SUCCESS == evtStore()->retrieve(evt)) + { + event = evt->event_ID()->event_number(); + run = evt->event_ID()->run_number(); + ATH_MSG_INFO (" EventInfo : " + << " event: " << event + << " run: " << run); + } + else + { + ATH_MSG_ERROR (" Unable to retrieve EventInfo from StoreGate "); + return StatusCode::SUCCESS; + } +#endif + + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode ReadDataReentrant::finalize() { + + ATH_MSG_INFO ("in finalize()"); + return StatusCode::SUCCESS; +} diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/ReadDataReentrant.h b/Control/AthenaExamples/AthExStoreGateExample/src/ReadDataReentrant.h new file mode 100644 index 0000000000000000000000000000000000000000..be9f222897e4e4ec5b2f0aa9713bd7054e3d6719 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/src/ReadDataReentrant.h @@ -0,0 +1,49 @@ +// 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 ReadDataReentrant.h + * @author scott snyder <snyder@bnl.gov> + * @date Jan, 2016 + * @brief + */ + + +#ifndef ATHEXSTOREGATEEXAMPLE_READDATAREENTRANT_H +#define ATHEXSTOREGATEEXAMPLE_READDATAREENTRANT_H + +#include <string> +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthExStoreGateExample/MyDataObj.h" +#include "StoreGateExample_ClassDEF.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/UpdateHandleKey.h" + + + +class ReadDataReentrant + : public AthReentrantAlgorithm +{ +public: + ReadDataReentrant (const std::string& name, ISvcLocator* pSvcLocator); + virtual StatusCode initialize() override final; + virtual StatusCode execute_r (const EventContext& ctx) const override final; + virtual StatusCode finalize() override final; + +private: + SG::UpdateHandleKey<MyDataObj> m_dobjKey3; + SG::ReadHandleKey<DataVector<MyContObj> > m_cobjKey; + SG::ReadHandleKey<std::vector<float> > m_vFloatKey; + //SG::ReadHandleKey<MyDataObj> m_nonexistingKey; + SG::ReadHandleKey<std::list<ElementLink<std::vector<float> > > > m_pLinkListKey; + SG::ReadHandleKey<std::vector<ElementLink<MapStringFloat> > > m_linkVectorKey; + SG::ReadHandleKey<TestDataObject> m_testObjectKey; +}; + + + +#endif // not ATHEXSTOREGATEEXAMPLE_READDATAREENTRANT_H diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/ReadPileUpData.cxx b/Control/AthenaExamples/AthExStoreGateExample/src/ReadPileUpData.cxx index 4ab1427ff2671d57fe89e354f515f61da542a1ab..acd60bea60f73c3c6d5b9634cf0952b368fe11f8 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/src/ReadPileUpData.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src/ReadPileUpData.cxx @@ -19,7 +19,7 @@ #include "EventInfo/EventID.h" #include "StoreGate/StoreGateSvc.h" -#include "DataModel/DataLink.h" +#include "AthLinks/DataLink.h" ///////////////////////////////////////////////////////////////////////////// diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/StoreGateExample_ClassDEF.h b/Control/AthenaExamples/AthExStoreGateExample/src/StoreGateExample_ClassDEF.h index b368e14414bef887c2ec8c05ddf7f45d5761a215..9a440a6aba8253762e1e07f6ce838f2cea6da93b 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/src/StoreGateExample_ClassDEF.h +++ b/Control/AthenaExamples/AthExStoreGateExample/src/StoreGateExample_ClassDEF.h @@ -11,8 +11,8 @@ #include <vector> #include "SGTools/StlVectorClids.h" #include "SGTools/CLASS_DEF.h" -#include "DataModel/DataVector.h" -#include "DataModel/ElementLink.h" +#include "AthContainers/DataVector.h" +#include "AthLinks/ElementLink.h" #include "MyContObj.h" #include "MapStringFloat.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/WriteData.cxx b/Control/AthenaExamples/AthExStoreGateExample/src/WriteData.cxx index 14140dab9808a7059834fc65baf6c65ac672fdbf..701265964670eb8cdfc621514d69dbbdb2b602a5 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/src/WriteData.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src/WriteData.cxx @@ -13,10 +13,10 @@ #include "MapStringFloat.h" #include "StoreGateExample_ClassDEF.h" -#include "DataModel/DataVector.h" +#include "AthContainers/DataVector.h" #include "StoreGate/StoreGateSvc.h" -#include "DataModel/DataLink.h" -#include "DataModel/ElementLink.h" +#include "AthLinks/DataLink.h" +#include "AthLinks/ElementLink.h" #include "AthenaKernel/DefaultKey.h" #include "AthenaKernel/errorcheck.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/WriteDataReentrant.cxx b/Control/AthenaExamples/AthExStoreGateExample/src/WriteDataReentrant.cxx new file mode 100644 index 0000000000000000000000000000000000000000..69bf8a5f11314a581fd9bcc13d1a00c559ea4337 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/src/WriteDataReentrant.cxx @@ -0,0 +1,307 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file WriteDataReentrant.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Jan, 2016 + * @brief + */ + + +#undef NDEBUG +#include "WriteDataReentrant.h" + +#include <list> +#include <vector> + +#include "AthExStoreGateExample/MyDataObj.h" +#include "MyContObj.h" +#include "MapStringFloat.h" +#include "StoreGateExample_ClassDEF.h" + +#include "AthContainers/DataVector.h" +#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/WriteHandle.h" +#include "AthLinks/DataLink.h" +#include "AthLinks/ElementLink.h" +#include "TestTools/expect_exception.h" + +#include "AthenaKernel/DefaultKey.h" +#include "AthenaKernel/errorcheck.h" +#include "CxxUtils/make_unique.h" + +///////////////////////////////////////////////////////////////////////////// + + +WriteDataReentrant::WriteDataReentrant(const std::string& name, + ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name, pSvcLocator) +{ + declareProperty ("DObjKey", m_dobjKey = "dobj"); + declareProperty ("DObjKey2", m_dobjKey2 = "dobj2"); + declareProperty ("DObjKey3", m_dobjKey3 = name); + //declareProperty ("DObjKey4", m_dobjKey4 = "dobj4"); + declareProperty ("CObjKey", m_cobjKey = "cobj"); + declareProperty ("VFloatKey", m_vFloatKey = "vFloat"); + declareProperty ("PLinkListKey", m_pLinkListKey = name); + declareProperty ("MKey", m_mKey = "mkey"); + declareProperty ("LinkVectorKey", m_linkVectorKey = "linkvec"); + declareProperty ("TestObjectKey", m_testObjectKey = "testobj"); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode WriteDataReentrant::initialize() +{ + ATH_MSG_INFO ("in initialize()"); + ATH_CHECK( m_dobjKey.initialize() ); + ATH_CHECK( m_dobjKey2.initialize() ); + ATH_CHECK( m_dobjKey3.initialize() ); + //ATH_CHECK( m_dobjKey4.initialize() ); + ATH_CHECK( m_cobjKey.initialize() ); + ATH_CHECK( m_vFloatKey.initialize() ); + ATH_CHECK( m_pLinkListKey.initialize() ); + ATH_CHECK( m_mKey.initialize() ); + ATH_CHECK( m_linkVectorKey.initialize() ); + ATH_CHECK( m_testObjectKey.initialize() ); + + m_testObject = new TestDataObject(10); + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode WriteDataReentrant::execute_r (const EventContext& ctx) const +{ + //this example illustrates how to record objects into the StoreGate(SG) + //with and without providing a key + //It then covers the new DataLink class and its usage as a persistable + //reference among objects in the SG + //Finally it shows how to use symlinks to record an object using its + //concrete type and its base class(es). + + ATH_MSG_INFO ("in execute()"); + + // For algorithms that produce new data objects like this one + // the SG works like a bulletin board: the algorithm posts the + // new object to the SG (optionally providing a "name" for it). + // The SG assigns a unique identifier to the object and puts it on display + // alongside others of the same type. + // At preset intervals all objects are removed from the board to make room + // for new ones and filed. + + // Part 1: Recording objects to SG + SG::WriteHandle<MyDataObj> dobj (m_dobjKey, ctx); + dobj = CxxUtils::make_unique<MyDataObj>(1); + + //now we create a second MyDataObj instance... + //...try to record it as we did for the first. Since dobj2 is also a + //MyDataObj we expect to see an error + ATH_MSG_WARNING ("we expect an error message here"); + EXPECT_EXCEPTION (std::runtime_error, + dobj = CxxUtils::make_unique<MyDataObj>(2)); + ATH_MSG_WARNING ("end of error message"); + + //here we go again... + //... but this time we register the dobj3 using this algo name as key + auto dobj3 = SG::makeHandle (m_dobjKey3, ctx); + dobj3 = CxxUtils::make_unique<MyDataObj>(3); + + SG::WriteHandle<TestDataObject> testobj (m_testObjectKey, ctx); + if (m_testObject->refCount() != 1) std::abort(); + ATH_CHECK( testobj.record (m_testObject) ); + if (m_testObject->refCount() != 2) std::abort(); + +#if 0 + { + SG::WriteHandle<MyDataObj> dobj4 (m_dobjKey4, ctx); + ATH_CHECK( dobj4.recordOrRetrieve (CxxUtils::make_unique<MyDataObj>(4)) ); + MyDataObj* pp = &*dobj4; + ATH_CHECK( dobj4.recordOrRetrieve (CxxUtils::make_unique<MyDataObj>(4)) ); + assert (pp == &*dobj4); + } +#endif + + /////////////////////////////////////////////////////////////////////// + + // Part 2: storing collections in the SG + + SG::WriteHandle<DataVector<MyContObj> > cobj (m_cobjKey, ctx); + ATH_CHECK( cobj.record (CxxUtils::make_unique<DataVector<MyContObj> >()) ); + cobj->reserve(10); + cobj->push_back (CxxUtils::make_unique<MyContObj> (11.3, 132)); + cobj->push_back (CxxUtils::make_unique<MyContObj> (41.7, 291)); + + // as above with a vector of integers + SG::WriteHandle<std::vector<float> > vFloat (m_vFloatKey, ctx); + vFloat = CxxUtils::make_unique<std::vector<float> >(); + vFloat->push_back(1.0); + vFloat->push_back(2.0); + vFloat->push_back(3.0); + + SG::WriteHandle<MapStringFloat> m (m_mKey, ctx); + ATH_CHECK( m.record (CxxUtils::make_unique<MapStringFloat>()) ); + (*m)["uno"]=1.0; + (*m)["due"]=2.0; + + /////////////////////////////////////////////////////////////////////// + // + // Part 3: Data Links + // + // Data links are persistable references. Typically they will replace + // pointers from one object in the event to another, hence they have + // the usual "pointer" syntax (op *, op ->, op !, ...) + // (to be pedantic they have the moniker syntax as they don't define ++, --) + // For example in Atlfast::Cell + // class Cell { + // ... + // private: + // std::vector<const HepMC::Particle*> m_particles; + // }; + // m_particles would become + // std::vector<HepMCLink<Particle>::type > m_particles; + // + // To understand data links it is important to observe that the SG + // is not able to identify every single object in the event. + // In particular individual elements of a container (the MyContObj + // in the vector above or the Particles in McEventCollection) are not + // recorded individually into SG, only their owner (the container) is. + // For this reason data links are supported by two class templates: + // DataLink<DATAOBJ> is a link to a data object i.e. an object + // identified by SG + // ElementLink<CONTAINER> is a link to an element of a container (which + // in turn is a SG data object) + // To make a DataLink persistable we need to provide its SG identifier + // (its type and key). + // To make an ElementLink persistable we need two pieces of information: + // i) the SG identifier (type/key) of the data object owning the element + // ii) the identifier of the contained object within the owner + // For example when we write out a link to the third element of + // our vector<float> we want to write the SG id of the vector + // and the index (2) of the element in the vector + // + // Since the indexing mechanism of a container depends on the container + // type we need to specialize ElementLink for different containers + // Elements of STL sequences (lists, vectors, deques but also DataVector + // and DataList) are dealt with automatically. + // For other STL or STL-like containers, the data object designer (or the + // client must "help" ElementLink identifying the type of container + // Three macros in the header StoreGate/DeclareIndexingPolicy.h + // are provided to this end: + // for sequences use CONTAINER_IS_SEQUENCE( MySequence ) + // for sets use CONTAINER_IS_SET( MySet ) + // for maps and related containers use CONTAINER_IS_MAP( MyMap ) + // + // It is also possible to define custom specializations of ElementLink + // for custom containers (e.g. GenParticleLink for McEventCollection). + // + //Enough! Let's now create our first DataLink. It refers to the first + // MyDataObj we recorded. DataLink constructors use references + // as input arguments + // + // DataLink referring to a storable object + // + DataLink<MyDataObj> dobjLink(*dobj); + //since dobj is identifiable in the SG a reference to it is all we need + + SG::WriteHandle<MyDataObj> dobj2 (m_dobjKey2, ctx); + dobj2 = CxxUtils::make_unique<MyDataObj> (2); + + //Otherwise one could first create an empty link + DataLink<MyDataObj> dobjLink2; + //and later on set it to refer to its target + dobjLink2.toStorableObject(*dobj2); + + + // Added Aug 30, 2001 HMA + // DataLink made from a key. This should work for either an object + // already registered in the store, or an object that has a + // persistency for it. we use dobj3, which is an object registered with + // a key. + + DataLink<MyDataObj> dobjLink3(name()); + // now access it. DataLink will do a retrieve to get it from the store. + dobjLink3->val(); + + // + // ElementLinks referring to contained objects + // + typedef ElementLink<std::vector<float> > VecElemLink; + + + VecElemLink thirdElementLink(*vFloat, 2); //THIS CRASHES SUN CC + + //sometimes we would not know the index of the element we want to refer to + + //reference to an element of the vector + float& anElement = vFloat->operator[](0); + + //starting from an empty link + VecElemLink aLink; + //we can refer it to its target without knowing its index + aLink.toContainedElement(*vFloat, anElement); + //it is better though to remember that toContainedElement for an + //ElementLink performs a linear search of "anElement" into "vFloat". + // If vFloat has a million elements think twice before using + // toContainedElement! + + SG::WriteHandle<std::list<VecElemLink> > pLinkList (m_pLinkListKey, ctx); + pLinkList = CxxUtils::make_unique<std::list<VecElemLink> >(); + pLinkList->push_back(aLink); + pLinkList->push_back(thirdElementLink); + + // + // Part 3b: create a vector of links to the elements of the map above + // + typedef ElementLink<MapStringFloat> MapElemLink; + SG::WriteHandle<std::vector<MapElemLink> > linkVector (m_linkVectorKey, ctx); + linkVector = CxxUtils::make_unique<std::vector<MapElemLink> >(); + linkVector->push_back(MapElemLink(*m, "uno")); + MapElemLink mLink; + mLink.toContainedElement(*m, (*m)["due"]); + linkVector->push_back(mLink); + + // Part 4 + // make a link to dobj as its base class after it has been registered + // this allows later to retrieve different concrete types as a common ABC + + const BaseClass * pDO = 0; + if ( (evtStore()->symLink(dobj.cptr(), pDO)).isFailure() ) { + ATH_MSG_ERROR (" could not make link to BaseClass"); + return( onError() ); + } + + // make a link as its base class, with the same name + if ( ( evtStore()->symLink(dobj3.cptr(), pDO)).isFailure() ) { + ATH_MSG_ERROR (" could not make link to BaseClass"); + return( onError() ); + } + + // Part 5 + // finally dump the structure of the StoreGate before returning + ATH_MSG_INFO (" registered all data objects"); + ATH_MSG_INFO (" StoreGate structure before returning from execute \n" + << evtStore()->dump()); + + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode WriteDataReentrant::finalize() +{ + ATH_MSG_INFO ("in finalize()"); + return StatusCode::SUCCESS; +} + + +StatusCode WriteDataReentrant::onError() const +{ + ATH_MSG_ERROR ("Dumping StoreGate after error occurred\n" + << evtStore()->dump()); + return StatusCode::FAILURE; +} + diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/WriteDataReentrant.h b/Control/AthenaExamples/AthExStoreGateExample/src/WriteDataReentrant.h new file mode 100644 index 0000000000000000000000000000000000000000..e38c833313802fd2a3ec37efb3bb4aa9741e88a7 --- /dev/null +++ b/Control/AthenaExamples/AthExStoreGateExample/src/WriteDataReentrant.h @@ -0,0 +1,53 @@ +// 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 WriteDataReentrant.h + * @author scott snyder <snyder@bnl.gov> + * @date Jan, 2016 + * @brief + */ + + +#ifndef ATHEXSTOREGATEEXAMPLE_WRITEDATAREENTRANT_H +#define ATHEXSTOREGATEEXAMPLE_WRITEDATAREENTRANT_H + + +#include <string> +#include "AthExStoreGateExample/MyDataObj.h" +#include "StoreGateExample_ClassDEF.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/WriteHandleKey.h" + + +class WriteDataReentrant + : public AthReentrantAlgorithm +{ +public: + WriteDataReentrant (const std::string& name, ISvcLocator* pSvcLocator); + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + virtual StatusCode execute_r (const EventContext& ctx) const override final; + +private: + SG::WriteHandleKey<MyDataObj> m_dobjKey; + SG::WriteHandleKey<MyDataObj> m_dobjKey2; + SG::WriteHandleKey<MyDataObj> m_dobjKey3; + //SG::WriteHandleKey<MyDataObj> m_dobjKey4; + SG::WriteHandleKey<DataVector<MyContObj> > m_cobjKey; + SG::WriteHandleKey<std::vector<float> > m_vFloatKey; + SG::WriteHandleKey<MapStringFloat> m_mKey; + SG::WriteHandleKey<std::list<ElementLink<std::vector<float> > > > m_pLinkListKey; + SG::WriteHandleKey<std::vector<ElementLink<MapStringFloat> > > m_linkVectorKey; + SG::WriteHandleKey<TestDataObject> m_testObjectKey; + + SG::DataObjectSharedPtr<TestDataObject> m_testObject; + StatusCode onError() const; +}; + + +#endif // not ATHEXSTOREGATEEXAMPLE_WRITEDATAREENTRANT_H diff --git a/Control/AthenaExamples/AthExStoreGateExample/src/components/StoreGateExample_entries.cxx b/Control/AthenaExamples/AthExStoreGateExample/src/components/StoreGateExample_entries.cxx index e1fad652e833b179b8160243168692d4eaa65bec..88ae0c6cc4f28d708030a46a7a8dbc3f0f27bd60 100755 --- a/Control/AthenaExamples/AthExStoreGateExample/src/components/StoreGateExample_entries.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src/components/StoreGateExample_entries.cxx @@ -13,14 +13,13 @@ #include "../ReadData.h" #include "../ReadPileUpData.h" #include "../WriteData.h" +#include "../WriteDataReentrant.h" +#include "../ReadDataReentrant.h" #include "GaudiKernel/DeclareFactoryEntries.h" DECLARE_ALGORITHM_FACTORY( ReadData ) DECLARE_ALGORITHM_FACTORY( ReadPileUpData ) DECLARE_ALGORITHM_FACTORY( WriteData ) +DECLARE_ALGORITHM_FACTORY( WriteDataReentrant ) +DECLARE_ALGORITHM_FACTORY( ReadDataReentrant ) -DECLARE_FACTORY_ENTRIES(AthExStoreGateExample) { - DECLARE_ALGORITHM( ReadData ) - DECLARE_ALGORITHM( ReadPileUpData ) - DECLARE_ALGORITHM( WriteData ) -} diff --git a/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx b/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx index 4afa2876a2fc221ad7ce9d84a79e2e25163729a3..855cc240a0c9c80fa42b97fa9cddf449abc3d882 100644 --- a/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx @@ -8,6 +8,7 @@ // Implementation file for class DFlowAlg1 // Author: S.Binet<binet@cern.ch> /////////////////////////////////////////////////////////////////// +#undef NDEBUG // AthExStoreGateExample includes #include "DFlowAlg1.h" @@ -104,7 +105,7 @@ StatusCode DFlowAlg1::execute() ATH_MSG_INFO("val: " << *m_w_int); ATH_MSG_INFO("modify myint by value..."); - m_w_int = m_r_evtInfo->event_ID()->event_number() + 20; + *m_w_int = m_r_evtInfo->event_ID()->event_number() + 20; ATH_MSG_INFO("ptr: " << m_w_int.cptr()); ATH_MSG_INFO("val: " << *m_w_int); diff --git a/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx b/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx index 6e0e7b1069e87f6e13a7162bacd94f4f101c9fdc..e546f9e5337cb000240b7b3fed3f44d12445f92a 100644 --- a/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx @@ -8,6 +8,7 @@ // Implementation file for class DFlowAlg2 // Author: S.Binet<binet@cern.ch> /////////////////////////////////////////////////////////////////// +#undef NDEBUG // AthExStoreGateExample includes #include "DFlowAlg2.h" diff --git a/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg3.cxx b/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg3.cxx index 997bc70ddd7b61546ae96fd3477637506a17cc7a..995329eec32bed09b4e470cb310a76fac99aeccd 100644 --- a/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg3.cxx +++ b/Control/AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg3.cxx @@ -8,6 +8,7 @@ // Implementation file for class DFlowAlg3 // Author: S.Binet<binet@cern.ch> /////////////////////////////////////////////////////////////////// +#undef NDEBUG // AthExStoreGateExample includes #include "DFlowAlg3.h" @@ -117,7 +118,7 @@ StatusCode DFlowAlg3::execute() // test that modification thru one handle is seen thru the other one std::vector<int> save = *m_rw_ints; - m_rw_ints = std::vector<int>(); + *m_rw_ints = std::vector<int>(); ATH_MSG_INFO("temporary r-handle[ints] - size: " << ints->size()); if (m_r_int.isValid()) { ATH_MSG_INFO("data mbr r-handle[ints] - size: " << m_r_ints->size()); @@ -125,7 +126,7 @@ StatusCode DFlowAlg3::execute() ATH_MSG_INFO("data mbr rw-handle[ints] - size: " << m_rw_ints->size()); ATH_MSG_INFO("--restore--"); - m_rw_ints = save; + *m_rw_ints = save; ATH_MSG_INFO("temporary r-handle[ints] - size: " << ints->size()); if (m_r_int.isValid()) { ATH_MSG_INFO("data mbr r-handle[ints] - size: " << m_r_ints->size()); @@ -169,7 +170,7 @@ StatusCode DFlowAlg3::execute() if (rw_int.isValid()) { ATH_MSG_INFO("temporary r/w-int: " << *rw_int); } - m_r_int.setConst(); + ATH_CHECK( m_r_int.setConst() ); if (!m_r_int.isConst()) { ATH_MSG_ERROR("ReadHandle<int>@[" << m_r_int.name() << "] should be CONST !"); return StatusCode::FAILURE; @@ -194,7 +195,7 @@ StatusCode DFlowAlg3::execute() return StatusCode::FAILURE; } try { - o = 42; + *o = 42; if (o.isValid()) { ATH_MSG_ERROR("should NOT be valid ! [line " << __LINE__ << "]" ); return StatusCode::FAILURE; @@ -220,7 +221,7 @@ StatusCode DFlowAlg3::execute() return StatusCode::FAILURE; } try { - o = 42; + *o = 42; if (o.isValid()) { ATH_MSG_ERROR("should NOT be valid ! [line " << __LINE__ << "]" ); return StatusCode::FAILURE;