14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/Bootstrap.h"
27 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
28 CHECK( detStore.isValid() );
35 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"RpcPrepDataContainerCnv_p3 initialized." <<
endmsg;
36 return StatusCode::SUCCESS;
40 if (!cnv_tool)
return nullptr;
63 log << MSG::FATAL <<
"Could not initialize RpcPrepDataContainerCnv_p3 " <<
endmsg;
70 TRANS::const_iterator it_Coll = transCont->
begin();
71 TRANS::const_iterator it_CollEnd = transCont->
end();
72 unsigned int pcollIndex = 0;
73 unsigned int pcollBegin = 0;
74 unsigned int pcollEnd = 0;
78 if (log.level() <= MSG::DEBUG)
79 log << MSG::DEBUG<<
"Preparing " << persCont->
m_collections.size() <<
" Collections" <<
endmsg;
80 for (pcollIndex = 0; it_Coll != it_CollEnd; ++pcollIndex, ++it_Coll) {
82 if (log.level() <= MSG::DEBUG)
83 log << MSG::DEBUG<<
"New collection"<<
endmsg;
87 pcollBegin = pcollEnd;
88 pcollEnd += collection.
size();
95 persCont->
m_prds.resize(pcollEnd);
98 unsigned int lastPRDIdHash = 0;
99 for (
unsigned int i = 0; i < collection.
size(); ++i) {
100 unsigned int pchanIndex=i+pcollBegin;
105 unsigned int clusIdCompact = chan->identify().get_identifier32().get_compact();
108 persCont->
m_prdDeltaId[pchanIndex]=clusIdCompact - collIdCompact;
110 if(log.level() <= MSG::DEBUG){
111 log << MSG::DEBUG<<i<<
":\t clusId: "<<clusIdCompact<<
", \t collectionId="<<collIdCompact<<
"\t delta="<<persCont->
m_prdDeltaId[pchanIndex]<<
endmsg;
113 if (temp!=chan->identify() )
114 log << MSG::WARNING <<
"PRD ids differ! Transient:"<<chan->identify()<<
", From persistent:"<<temp<<
" diff = "<<chan->identify().get_compact()-temp.get_compact()<<
endmsg;
116 log << MSG::DEBUG <<
" PRD ids match."<<
endmsg;
117 if (lastPRDIdHash && lastPRDIdHash != chan->collectionHash() ) log << MSG::WARNING <<
"Collection Identifier hashes differ!"<<
endmsg;
118 lastPRDIdHash = chan->collectionHash();
119 log << MSG::DEBUG<<
"Collection hash = "<<lastPRDIdHash<<
endmsg;
120 if (chan->collectionHash()!= collection.
identifyHash() ) log << MSG::WARNING <<
"Collection's idHash does not match PRD collection hash!"<<
endmsg;
122 log << MSG::WARNING <<
"Getting de from identity didn't work!"<<
endmsg;
124 log << MSG::DEBUG<<
"Getting de from identity did work "<<
endmsg;
125 if (chan->detectorElement() !=
getReadOutElement(temp)) log << MSG::WARNING <<
"Getting de from reconstructed identity didn't work!"<<
endmsg;
126 log << MSG::DEBUG<<
"Finished loop"<<
endmsg;
130 if (log.level() <= MSG::DEBUG)
131 log << MSG::DEBUG<<
" *** Finished Writing RpcPrepDataContainer ***" <<
endmsg;
154 unsigned int pchanIndex(0);
156 if (log.level() <= MSG::DEBUG)
157 log << MSG::DEBUG<<
" Reading " << pCollEnd <<
"Collections" <<
endmsg;
158 for (
unsigned int pcollIndex = 0; pcollIndex < pCollEnd; ++pcollIndex) {
168 unsigned int pchanEnd = pchanIndex+pcoll.
m_size;
169 unsigned int chanIndex = 0;
173 for (; pchanIndex < pchanEnd; ++ pchanIndex, ++chanIndex) {
180 int result =
m_RpcId->get_detectorElement_hash(clusId, deIDHash);
181 if (
result&&log.level() <= MSG::WARNING)
182 log << MSG::WARNING<<
" Muon::RpcPrepDataContainerCnv_p3::persToTrans: problem converting Identifier to DE hash "<<
endmsg;
185 auto chan = std::make_unique<RpcPrepData>
192 chan->setHashAndIndex(collIDHash, chanIndex);
198 if (
sc.isFailure()) {
199 throw std::runtime_error(
"Failed to add collection to Identifiable Container");
201 if (log.level() <= MSG::DEBUG) {
202 log << MSG::DEBUG <<
"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash <<
" / " <<
207 if (log.level() <= MSG::DEBUG)
208 log << MSG::DEBUG<<
" *** Reading RpcPrepDataContainer ***" <<
endmsg;
216 if (log.level() <= MSG::DEBUG)
217 log << MSG::DEBUG<<
" Muon::RpcPrepDataContainerCnv_p3::createTransient" <<
endmsg;
220 log << MSG::FATAL <<
"Could not initialize RpcPrepDataContainerCnv_p3 " <<
endmsg;
226 return(trans.release());
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
void reserve(size_type n)
value_type push_back(value_type pElem)
size_type size() const noexcept
const_iterator end() const
return const_iterator for end of container
virtual size_t numberOfCollections() const override final
return number of collections
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
const_iterator begin() const
return const_iterator for first entry
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Class to hold the persistent representation of MuonPRD_Collection.
unsigned short m_size
Collection size into master collection Note I use a short.
unsigned int m_hashId
Hash Identifier of this collection.
unsigned int m_id
Identifier of this collection.
std::vector< MuonPRD_Collection_p2 > m_collections
std::vector< unsigned short > m_prdDeltaId
The delta identifiers of the PRD i.e.
std::vector< PRD > m_prds
virtual Identifier identify() const override final
virtual void setIdentifier(Identifier id)
virtual IdentifierHash identifyHash() const override final
virtual Muon::RpcPrepDataContainer * createTransient(const Muon::RpcPrepDataContainer_p3 *persObj, MsgStream &log)
virtual void persToTrans(const Muon::RpcPrepDataContainer_p3 *persCont, Muon::RpcPrepDataContainer *transCont, MsgStream &log)
StatusCode initialize(MsgStream &log)
const RpcIdHelper * m_RpcId
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
virtual void transToPers(const Muon::RpcPrepDataContainer *transCont, Muon::RpcPrepDataContainer_p3 *persCont, MsgStream &log)
const MuonGM::RpcReadoutElement * getReadOutElement(const Identifier &id) const
We don't write out (from Trk::PrepRawData) m_indexAndHash (can be recomputed), m_clusId (can be recom...
Class to represent RPC measurements.
void transToPers(const Muon::RpcPrepData *transObj, Muon::RpcPrepData_p3 *persObj, MsgStream &log)
static Muon::RpcPrepData createRpcPrepData(const Muon::RpcPrepData_p3 *persObj, const Identifier &id, const MuonGM::RpcReadoutElement *detEl, MsgStream &log)
MuonPrepDataContainerT< RpcPrepData > RpcPrepDataContainer
MuonPRD_Container_p2< RpcPrepData_p3 > RpcPrepDataContainer_p3
MuonPrepDataCollection< RpcPrepData > RpcPrepDataCollection