13#include "GaudiKernel/ISvcLocator.h"
14#include "GaudiKernel/Bootstrap.h"
26 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
27 CHECK( detStore.isValid() );
34 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"Converter initialized." <<
endmsg;
35 return StatusCode::SUCCESS;
39 if (!cnv_tool)
return nullptr;
45 if (this->
initialize(log) != StatusCode::SUCCESS) {
46 log << MSG::FATAL <<
"Could not initialize CscPrepDataContainerCnv_p2 " <<
endmsg;
67 TRANS::const_iterator it_Coll = transCont->
begin();
68 TRANS::const_iterator it_CollEnd = transCont->
end();
69 unsigned int pcollIndex = 0;
70 unsigned int pcollBegin = 0;
71 unsigned int pcollEnd = 0;
75 if (log.level() <= MSG::DEBUG)
76 log << MSG::DEBUG<<
" Preparing " << persCont->
m_collections.size() <<
"Collections" <<
endmsg;
77 for (pcollIndex = 0; it_Coll != it_CollEnd; ++pcollIndex, ++it_Coll) {
79 if (log.level() <= MSG::DEBUG)
80 log << MSG::DEBUG<<
"New collection"<<
endmsg;
84 pcollBegin = pcollEnd;
85 pcollEnd += collection.
size();
92 persCont->
m_prds.resize(pcollEnd);
95 unsigned int lastPRDIdHash = 0;
96 for (
unsigned int i = 0; i < collection.
size(); ++i) {
97 unsigned int pchanIndex=i+pcollBegin;
101 unsigned int clusIdCompact = chan->identify().get_identifier32().get_compact();
103 int diff = clusIdCompact - collIdCompact;
104 persCont->
m_prdDeltaId[pchanIndex]=clusIdCompact - collIdCompact;
106 if(log.level() <= MSG::DEBUG){
107 log << MSG::DEBUG<<i<<
":\t clusId: "<<clusIdCompact<<
", \t collectionId="<<collIdCompact<<
"\t delta="<<persCont->
m_prdDeltaId[pchanIndex]<<
"\t diff="<<
diff<<
endmsg;
109 if (temp!=chan->identify() )
110 log << MSG::WARNING <<
"PRD ids differ! Transient:"<<chan->identify()<<
", From persistent:"<<temp<<
" diff = "<<chan->identify().get_compact()-temp.get_compact()<<
endmsg;
112 log << MSG::DEBUG <<
" PRD ids match."<<
endmsg;
113 if (lastPRDIdHash && lastPRDIdHash != chan->collectionHash() ) log << MSG::WARNING <<
"Collection Identifier hashes differ!"<<
endmsg;
114 lastPRDIdHash = chan->collectionHash();
115 log << MSG::DEBUG<<
"Collection hash = "<<lastPRDIdHash<<
endmsg;
116 if (chan->collectionHash()!= collection.
identifyHash() ) log << MSG::WARNING <<
"Collection's idHash does not match PRD collection hash!"<<
endmsg;
118 log << MSG::WARNING <<
"Getting de from identity didn't work!"<<
endmsg;
120 log << MSG::DEBUG<<
"Getting de from identity did work "<<
endmsg;
121 if (chan->detectorElement() !=
getReadOutElement(temp)) log << MSG::WARNING <<
"Getting de from reconstructed identity didn't work!"<<
endmsg;
122 log << MSG::DEBUG<<
"Finished loop"<<
endmsg;
126 if (log.level() <= MSG::DEBUG)
127 log << MSG::DEBUG<<
" *** Writing CscPrepDataContainer ***" <<
endmsg;
150 unsigned int pchanIndex(0);
152 if (log.level() <= MSG::DEBUG)
153 log << MSG::DEBUG<<
" Reading " << pCollEnd <<
"Collections" <<
endmsg;
154 for (
unsigned int pcollIndex = 0; pcollIndex < pCollEnd; ++pcollIndex) {
165 unsigned int pchanEnd = pchanIndex+pcoll.
m_size;
166 unsigned int chanIndex = 0;
170 for (; pchanIndex < pchanEnd; ++ pchanIndex, ++chanIndex) {
174 if ( !
m_CscId->valid(clusId) ) {
176 log << MSG::WARNING <<
"Csc PRD has invalid Identifier of "<<
m_CscId->show_to_string(clusId)
177 <<
" and will be skipped!" <<
endmsg;
183 int result =
m_CscId->get_detectorElement_hash(clusId, deIDHash);
185 if (
result&&log.level() <= MSG::WARNING)
186 log << MSG::WARNING<<
" Muon::CscPrepDataContainerCnv_p2::persToTrans: problem converting Identifier to DE hash "<<
endmsg;
190 if (log.level() <= MSG::WARNING)
191 log << MSG::WARNING<<
"Muon::CscPrepDataContainerCnv_p2::persToTrans: could not get valid det element for PRD with id="<<clusId<<
". Skipping."<<
endmsg;
195 auto chan = std::make_unique<CscPrepData>
202 chan->setHashAndIndex(collIDHash, chanIndex);
208 if (
sc.isFailure()) {
209 throw std::runtime_error(
"Failed to add collection to Identifiable Container");
211 if (log.level() <= MSG::DEBUG) {
212 log << MSG::DEBUG <<
"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash <<
" / " <<
217 if (log.level() <= MSG::DEBUG)
218 log << MSG::DEBUG<<
" *** Reading CscPrepDataContainer ***" <<
endmsg;
224 if (this->
initialize(log) != StatusCode::SUCCESS) {
225 log << MSG::FATAL <<
"Could not initialize CscPrepDataContainerCnv_p2 " <<
endmsg;
231 return(trans.release());
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
void transToPers(const Muon::CscPrepData *transObj, Muon::CscPrepData_p2 *persObj, MsgStream &log)
static Muon::CscPrepData createCscPrepData(const Muon::CscPrepData_p2 *persObj, const Identifier &clusId, const MuonGM::CscReadoutElement *detEl, MsgStream &log)
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.
const MuonGM::CscReadoutElement * getReadOutElement(const Identifier &id) const
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
const CscIdHelper * m_CscId
virtual void persToTrans(const Muon::CscPrepDataContainer_p2 *persCont, Muon::CscPrepDataContainer *transCont, MsgStream &log)
StatusCode initialize(MsgStream &log)
virtual void transToPers(const Muon::CscPrepDataContainer *transCont, Muon::CscPrepDataContainer_p2 *persCont, MsgStream &log)
virtual Muon::CscPrepDataContainer * createTransient(const Muon::CscPrepDataContainer_p2 *persObj, MsgStream &log)
We don't write out (from Trk::PrepRawData) m_indexAndHash (can be recomputed), m_clusId (can be recom...
Class representing clusters from the CSC.
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
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection
MuonPRD_Container_p2< CscPrepData_p2 > CscPrepDataContainer_p2
MuonPrepDataContainerT< CscPrepData > CscPrepDataContainer