2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
6 #include "GaudiKernel/StatusCode.h"
7 #include "GaudiKernel/MsgStream.h"
10 #include "StoreGate/StoreGateSvc.h"
15 MuonRdoContainerCnv<T>::MuonRdoContainerCnv(ISvcLocator* svcloc)
16 : T_AthenaPoolCustCnv<T, DataVector<typename T::IDENTIFIABLE> >::T_AthenaPoolCustCnv(svcloc),
17 m_colV(SG::VIEW_ELEMENTS), // Must create DataVector that does NOT own elements
23 MuonRdoContainerCnv<T>::~MuonRdoContainerCnv()
28 StatusCode MuonRdoContainerCnv<T>::initialize()
30 // Call base clase initialize
31 if (!AthenaPoolConverter::initialize().isSuccess()) {
32 return StatusCode::FAILURE;
35 // Get the messaging service, print where you are
36 MsgStream log(this->msgSvc(), "MuonRdoContainerCnv");
37 log << MSG::INFO << "MuonRdoContainerCnv::initialize()" << endmsg;
39 // get StoreGate service
40 StatusCode sc=this->service("StoreGateSvc",m_storeGate);
43 log << MSG::FATAL << "StoreGate service not found !" << endmsg;
44 return StatusCode::FAILURE;
47 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized" << endmsg;
49 return StatusCode::SUCCESS;
54 StatusCode MuonRdoContainerCnv<T>::transToPers(T* rdoC, DataVector<typename T::IDENTIFIABLE>*& persObj)
56 MsgStream log(this->msgSvc(), "MuonRdoContainerCnv" );
58 // Copy RDOs to vector
61 // loop over collections
63 typename T::const_iterator it_Coll = rdoC->begin() ;
64 typename T::const_iterator it_CollE = rdoC->end() ;
65 for (; it_Coll != it_CollE; ++it_Coll)
68 COLLECTION_t *col = const_cast<COLLECTION_t *> (&(**it_Coll));
69 m_colV.push_back(col);
72 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Write RDO vector, size " << iColl << endmsg;
76 return StatusCode::SUCCESS;
81 StatusCode MuonRdoContainerCnv<T>::persToTrans(T*& rdoC, DataVector<typename T::IDENTIFIABLE>* colV)
83 MsgStream log(this->msgSvc(), "MuonRdoContainerCnv" );
85 // create the IdentifiableContainer to contain the collections
88 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read RDO vector, size " << colV->size()
91 // empty vector - just return
92 if (colV->size() == 0)
95 return StatusCode::SUCCESS;
98 // loop over collections
99 typename COLL_vector::const_iterator it_Coll = colV->begin();
100 typename COLL_vector::const_iterator it_CollE = colV->end();
101 for (; it_Coll != it_CollE; ++it_Coll)
103 const COLLECTION_t *col = *it_Coll;
105 // register the rdo collection in IDC
106 typename COLLECTION_t::ID id_coll = col->identify();
107 const typename T::KEY key_rdo= rdoC->key(id_coll);
108 StatusCode sc=rdoC->addCollection(col,id_coll);
111 log << MSG::FATAL << "RDOs could not be recorded in IDC"
114 return StatusCode::FAILURE;
118 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "RDOs " << key_rdo << " recorded in IDC"
124 return StatusCode::SUCCESS;