15#include "GaudiKernel/Bootstrap.h"
16#include "GaudiKernel/ISvcLocator.h"
27 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
28 CHECK( detStore.isValid() );
35 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"Converter initialized." <<
endmsg;
36 return StatusCode::SUCCESS;
40 if (!cnv_tool)
return nullptr;
46 if (this->
initialize(log) != StatusCode::SUCCESS) {
47 log << MSG::FATAL <<
"Could not initialize MMPrepDataContainerCnv_p1 " <<
endmsg;
67 unsigned int pcollEnd = 0;
70 if (log.level() <= MSG::DEBUG) { log << MSG::DEBUG <<
" Preparing " << persCont->
m_collections.size() <<
"collections" <<
endmsg; }
72 for (
unsigned int pcollIndex = 0; it_Coll != it_CollEnd; ++pcollIndex, ++it_Coll) {
74 if (log.level() <= MSG::DEBUG) {
75 log << MSG::DEBUG <<
"Coll hash for " << pcollIndex <<
": " << collection.
identifyHash() <<
endmsg;
80 pcollEnd += collection.
size();
86 persCont->
m_prds.reserve(pcollEnd);
89 for (
unsigned int i = 0; i < collection.
size(); ++i) {
97 int multilayer = (
m_MMId->multilayer(chan_id) - 1);
98 int gasGap = (
m_MMId->gasGap(chan_id) - 1);
102 unsigned short diff = (channel << 3 | gasGap << 1 | multilayer);
103 if (log.level() <= MSG::DEBUG) {
104 log << MSG::DEBUG <<
"Translated id=" << chan_id.
get_compact() <<
" (multilayer=" << multilayer <<
", gasGap=" << gasGap
105 <<
", channel=" << channel <<
") into diff=" <<
diff <<
endmsg;
111 if (log.level() <= MSG::WARNING && chan->detectorElement()->identify() != ele_from_mgr->
identify()) {
112 log << MSG::WARNING <<
"DE from det manager (" <<
m_MMId->print_to_string(ele_from_mgr->
identify())
113 <<
") does not match that from PRD (" <<
m_MMId->print_to_string(chan->detectorElement()->identify()) <<
") for PRD "
116 persCont->
m_prds.emplace_back(std::move(pchan));
119 log << MSG::DEBUG <<
" *** Writing MMPrepDataContainer ***" <<
endmsg;
141 unsigned int pchanIndex(0);
143 if (log.level() <= MSG::DEBUG) { log << MSG::DEBUG <<
" Reading " << pCollEnd <<
"Collections" <<
endmsg; }
144 for (
unsigned int pcollIndex = 0; pcollIndex < pCollEnd; ++pcollIndex) {
147 if (log.level() <= MSG::DEBUG) { log << MSG::DEBUG <<
"Coll hash for " << pcollIndex <<
": " << collIDHash <<
endmsg; }
152 unsigned int pchanEnd = pchanIndex + pcoll.
m_size;
153 unsigned int chanIndex = 0;
157 for (; pchanIndex < pchanEnd; ++pchanIndex, ++chanIndex) {
163 int channel = (
diff >> 3);
164 int gasGap = (3 & (
diff >> 1));
165 int multilayer = (1 &
diff);
167 if (log.level() <= MSG::DEBUG) {
168 log << MSG::DEBUG <<
"Diff of " <<
diff <<
" translated into multilayer=" << multilayer <<
", gasGap=" << gasGap
174 if (log.level() <= MSG::WARNING) {
175 log << MSG::WARNING <<
"Muon::MMPrepDataContainerCnv_p1::persToTrans: could not get valid det element for PRD with id="
176 <<
m_MMId->show_to_string(clusId) <<
". Skipping." <<
endmsg;
181 auto chan = std::make_unique<MMPrepData>(chanCnv.
createMMPrepData(pchan, clusId, detEl, log));
183 if (!
m_MMId->valid(chan->identify())) {
184 log << MSG::WARNING <<
"MM PRD has invalid Identifier of " << chan->identify().get_compact()
185 <<
" - are you sure you have the correct geometry loaded, and NSW enabled?" <<
endmsg;
189 if (log.level() <= MSG::DEBUG) { log << MSG::DEBUG <<
"chan identify(): " << chan->identify().get_compact() <<
endmsg; }
191 chan->setHashAndIndex(collIDHash, chanIndex);
197 if (
sc.isFailure()) {
throw std::runtime_error(
"Failed to add collection to Identifiable Container"); }
198 if (log.level() <= MSG::DEBUG) {
199 log << MSG::DEBUG <<
"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int)collIDHash <<
" / "
203 if (log.level() <= MSG::DEBUG) { log << MSG::DEBUG <<
" *** Reading MMPrepDataContainer ***" <<
endmsg; }
208 if (this->
initialize(log) != StatusCode::SUCCESS) {
209 log << MSG::FATAL <<
"Could not initialize MMPrepDataContainerCnv_p1 " <<
endmsg;
213 std::unique_ptr<Muon::MMPrepDataContainer> trans = std::make_unique<Muon::MMPrepDataContainer>(
m_MMId->module_hash_max());
215 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 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.
static Muon::MMPrepData createMMPrepData(const Muon::MMPrepData_p1 *persObj, Identifier clusId, const MuonGM::MMReadoutElement *detEl, MsgStream &log)
function used to create an MMPrepDataObject when converting Pers to trans
void transToPers(const Muon::MMPrepData *transObj, Muon::MMPrepData_p1 *persObj, MsgStream &log)
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
StatusCode initialize(MsgStream &log)
const MmIdHelper * m_MMId
virtual void transToPers(const Muon::MMPrepDataContainer *transCont, Muon::MMPrepDataContainer_p1 *persCont, MsgStream &log)
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
virtual Muon::MMPrepDataContainer * createTransient(const Muon::MMPrepDataContainer_p1 *persObj, MsgStream &log)
const MuonGM::MMReadoutElement * getReadOutElement(const Identifier &id) const
virtual void persToTrans(const Muon::MMPrepDataContainer_p1 *persCont, Muon::MMPrepDataContainer *transCont, MsgStream &log)
We don't write out (from Trk::PrepRawData) m_indexAndHash (can be recomputed), m_clusId (can be recom...
Class to represent MM measurements.
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< MMPrepData > MMPrepDataCollection
MuonPRD_Container_p2< MMPrepData_p1 > MMPrepDataContainer_p1
MuonPrepDataContainerT< MMPrepData > MMPrepDataContainer