16#include "GaudiKernel/ISvcLocator.h"
17#include "GaudiKernel/Bootstrap.h"
29 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
30 CHECK( detStore.isValid() );
37 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"Converter initialized." <<
endmsg;
38 return StatusCode::SUCCESS;
43 if (!cnv_tool)
return nullptr;
51 if (this->
initialize(log) != StatusCode::SUCCESS) {
52 log << MSG::FATAL <<
"Could not initialize TgcPrepDataContainerCnv_p3 " <<
endmsg;
76 TRANS::const_iterator it_Coll = transCont->
begin();
77 TRANS::const_iterator it_CollEnd = transCont->
end();
78 unsigned int pcollIndex = 0;
79 unsigned int pcollBegin = 0;
80 unsigned int pcollEnd = 0;
84 if (log.level() <= MSG::DEBUG)
85 log << MSG::DEBUG<<
" Preparing " << persCont->
m_collections.size() <<
"Collections" <<
endmsg;
86 for (pcollIndex = 0; it_Coll != it_CollEnd; ++pcollIndex, ++it_Coll) {
88 if (log.level() <= MSG::DEBUG)
89 log << MSG::DEBUG<<
"New collection"<<
endmsg;
93 pcollBegin = pcollEnd;
94 pcollEnd += collection.
size();
101 persCont->
m_prds.resize(pcollEnd);
104 unsigned int lastPRDIdHash = 0;
105 for (
unsigned int i = 0; i < collection.
size(); ++i) {
106 unsigned int pchanIndex=i+pcollBegin;
111 unsigned int clusIdCompact = chan->identify().get_identifier32().get_compact();
114 persCont->
m_prdDeltaId[pchanIndex]=clusIdCompact - collIdCompact;
115 if(log.level() <= MSG::DEBUG){
116 log << MSG::DEBUG<<i<<
":\t clusId: "<<clusIdCompact<<
", \t collectionId="<<collIdCompact<<
"\t delta="<<persCont->
m_prdDeltaId[pchanIndex]<<
endmsg;
118 if (temp!=chan->identify() )
119 log << MSG::WARNING <<
"PRD ids differ! Transient:"<<chan->identify()<<
", From persistent:"<<temp<<
" diff = "<<chan->identify().get_compact()-temp.get_compact()<<
endmsg;
121 log << MSG::DEBUG <<
" PRD ids match."<<
endmsg;
122 if (lastPRDIdHash && lastPRDIdHash != chan->collectionHash() ) log << MSG::WARNING <<
"Collection Identifier hashes differ!"<<
endmsg;
123 lastPRDIdHash = chan->collectionHash();
124 log << MSG::DEBUG<<
"Collection hash = "<<lastPRDIdHash<<
endmsg;
125 if (chan->collectionHash()!= collection.
identifyHash() ) log << MSG::WARNING <<
"Collection's idHash does not match PRD collection hash!"<<
endmsg;
127 log << MSG::WARNING <<
"Getting de from identity didn't work!"<<
endmsg;
129 log << MSG::DEBUG<<
"Getting de from identity did work "<<
endmsg;
130 if (chan->detectorElement() !=
getReadOutElement(temp)) log << MSG::WARNING <<
"Getting de from reconstructed identity didn't work!"<<
endmsg;
131 log << MSG::DEBUG<<
"Finished loop"<<
endmsg;
135 if (log.level() <= MSG::DEBUG)
136 log << MSG::DEBUG<<
" *** Writing TgcPrepDataContainer ***" <<
endmsg;
159 unsigned int pchanIndex(0);
161 if (log.level() <= MSG::DEBUG)
162 log << MSG::DEBUG<<
" Reading " << pCollEnd <<
"Collections" <<
endmsg;
163 for (
unsigned int pcollIndex = 0; pcollIndex < pCollEnd; ++pcollIndex) {
176 unsigned int pchanEnd = pchanIndex+pcoll.
m_size;
177 unsigned int chanIndex = 0;
181 for (; pchanIndex < pchanEnd; ++ pchanIndex, ++chanIndex) {
188 int result =
m_TgcId->get_detectorElement_hash(clusId, deIDHash);
189 if (
result&&log.level() <= MSG::WARNING)
190 log << MSG::WARNING<<
" Muon::TgcPrepDataContainerCnv_p3::persToTrans: problem converting Identifier to DE hash "<<
endmsg;
194 auto chan = std::make_unique<TgcPrepData>
200 chan->setHashAndIndex(collIDHash, chanIndex);
206 if (
sc.isFailure()) {
207 throw std::runtime_error(
"Failed to add collection to Identifiable Container");
209 if (log.level() <= MSG::DEBUG) {
210 log << MSG::DEBUG <<
"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash <<
" / " <<
215 if (log.level() <= MSG::DEBUG)
216 log << MSG::DEBUG<<
" *** Reading TgcPrepDataContainer ***" <<
endmsg;
225 if (this->
initialize(log) != StatusCode::SUCCESS) {
226 log << MSG::FATAL <<
"Could not initialize TgcPrepDataContainerCnv_p3 " <<
endmsg;
232 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.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
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 void persToTrans(const Muon::TgcPrepDataContainer_p3 *persCont, Muon::TgcPrepDataContainer *transCont, MsgStream &log)
const TgcIdHelper * m_TgcId
virtual void transToPers(const Muon::TgcPrepDataContainer *transCont, Muon::TgcPrepDataContainer_p3 *persCont, MsgStream &log)
const MuonGM::TgcReadoutElement * getReadOutElement(const Identifier &id) const
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
virtual Muon::TgcPrepDataContainer * createTransient(const Muon::TgcPrepDataContainer_p3 *persObj, MsgStream &log)
StatusCode initialize(MsgStream &log)
We don't write out (from Trk::PrepRawData) m_indexAndHash (can be recomputed), m_clusId (can be recom...
Class to represent TGC measurements.
void transToPers(const Muon::TgcPrepData *transObj, Muon::TgcPrepData_p3 *persObj, MsgStream &log)
static Muon::TgcPrepData createTgcPrepData(const Muon::TgcPrepData_p3 *persObj, const Identifier &id, const MuonGM::TgcReadoutElement *detEl, MsgStream &log)
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection
MuonPRD_Container_p2< TgcPrepData_p3 > TgcPrepDataContainer_p3
MuonPrepDataContainerT< TgcPrepData > TgcPrepDataContainer