diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/share/RpcPadContainerCnv_p2_test.ref b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/share/RpcPadContainerCnv_p2_test.ref index a246a707f206dfe9493c7d1435a8d8e55fa901bb..d56b817d62cf49ed5d326a92dffc2e7831420d20 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/share/RpcPadContainerCnv_p2_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/share/RpcPadContainerCnv_p2_test.ref @@ -14,4 +14,3 @@ RpcIdHelper INFO The element hash max is 600 RpcIdHelper INFO The detector element hash max is 1122 RpcIdHelper INFO Initializing RPC hash indices for finding neighbors ... test1 -test INFO RPCcablingSvc obtained - hashmax = 3 diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx index a47da9759f8b599b784b3443aac122d8b31e96a1..f8ae45611c34907d2121b17d40ae210a1bfd4e34 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx +++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx @@ -1,42 +1,39 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ +#include "RpcPadContainerCnv_p1.h" + #include "MuonRDO/RpcPad.h" #include "MuonRDO/RpcPadContainer.h" #include "MuonEventAthenaPool/RpcPad_p1.h" #include "MuonEventAthenaPool/RpcPadContainer_p1.h" -#include "MuonIdHelpers/RpcIdHelper.h" #include "RpcPadCnv_p1.h" -#include "RpcPadContainerCnv_p1.h" - -// Gaudi #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/StatusCode.h" #include "GaudiKernel/Service.h" #include "GaudiKernel/MsgStream.h" - -// Athena #include "StoreGate/StoreGateSvc.h" - #include "AthAllocators/DataPool.h" -#include "RPCcablingInterface/IRPCcablingServerSvc.h" -#include "RPCcablingInterface/RpcPadIdHash.h" -#include "RPCcablingInterface/IRPCcablingSvc.h" +#include "RPCcablingInterface/IRPCcablingServerSvc.h" // to be removed +#include "RPCcablingInterface/RpcPadIdHash.h" // to be removed +#include "RPCcablingInterface/IRPCcablingSvc.h" // to be removed +RpcPadContainerCnv_p1::RpcPadContainerCnv_p1() : + m_rpcCabling(nullptr), // to be removed + m_isInitialized(false), + m_rpcCondData(nullptr) { +} -StatusCode RpcPadContainerCnv_p1::initialize(MsgStream &log, - IRPCcablingSvc* cabling /*= nullptr*/) { - // Do not initialize again: - m_isInitialized=true; +StatusCode RpcPadContainerCnv_p1::initialize(MsgStream &log, IRPCcablingSvc* cabling) { - // Get Storegate, ID helpers, and so on + // Get Storegate, ID helpers, and so on ISvcLocator* svcLocator = Gaudi::svcLocator(); - + // to be removed if (cabling) m_rpcCabling = cabling; else { @@ -52,7 +49,7 @@ StatusCode RpcPadContainerCnv_p1::initialize(MsgStream &log, sc = RpcCabGet->giveCabling(m_rpcCabling); if (sc.isFailure()) { log << MSG::FATAL << "Could not get RPCcablingSvc from the Server !" << endmsg; - m_rpcCabling = 0; + m_rpcCabling = nullptr; return StatusCode::FAILURE; } else { @@ -61,6 +58,8 @@ StatusCode RpcPadContainerCnv_p1::initialize(MsgStream &log, } log << MSG::DEBUG << "Converter initialized." << endmsg; + + m_isInitialized=true; return StatusCode::SUCCESS; } @@ -79,7 +78,6 @@ void RpcPadContainerCnv_p1::transToPers(const RpcPadContainer* transCont, RpcPa for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) { // Add in new collection - //log << MSG::DEBUG << " New collection" << endmsg; RpcPad_p1* pcoll = &( (*persCont)[collIndex] ); cnv.transToPers( &(**it_Coll), pcoll , log); } @@ -95,37 +93,21 @@ void RpcPadContainerCnv_p1::persToTrans(const RpcPadContainer_p1* persCont, Rpc log << MSG::DEBUG << " Reading " << persCont->size() << "Collections" << endmsg; for (unsigned int icoll = 0; icoll < persCont->size(); ++icoll) { - // Identifier collID(Identifier(pcoll.m_id)); - // IdentifierHash collIDHash(IdentifierHash(persCont[icoll].m_hashId)); RpcPad* coll = new RpcPad; cnv.persToTrans( &( (*persCont)[icoll]), coll, log); - // register the rdo collection in IDC with hash - faster addCollection -// log<<MSG::INFO<<"coll has size "<<coll->size()<<endmsg; -// log << MSG::INFO<<" coll has hash: "<<static_cast<unsigned int>(coll->identifyHash())<<endmsg; -// log << MSG::INFO<<" coll has id: "<<static_cast<unsigned int>(coll->identify())<<endmsg; - -// hack to fix bug#56429 - always use identifier to get hash - - // sanity check -// if (coll->identifyHash() > static_cast<unsigned int>(m_rpcCabling->padHashFunction()->max() ) ) { -// m_errorCount++; - -// if (m_errorCount<m_maxNumberOfErrors) -// log<<MSG::WARNING<< "The persistent RDO had an IdentifierHash of "<<coll->identifyHash() -// <<" which is larger than the hash max of "<<m_rpcCabling->padHashFunction()->max() -// <<". Will attempt to correct from Identifier. This is message "<<m_errorCount<<" of " -// <<m_maxNumberOfErrors<<" maximum."<<endmsg; -// if (m_errorCount==m_maxNumberOfErrors) log<<MSG::WARNING<<"Exceeding max errors. Further WARNINGs will be suppressed!"<<endmsg; + + int temp=-1; + if (m_rpcCondData) temp = m_rpcCondData->operator()(coll->identify()); + else { const RpcPadIdHash* pdHashFn = m_rpcCabling->padHashFunction(); - int temp = (*pdHashFn)(coll->identify()); - if (temp==-1) { - coll->m_idHash = IdentifierHash(); - log<<MSG::WARNING<<"get_hash failed - nothing else we can try!"<<endmsg; - } else{ - coll->m_idHash = temp; -// if (m_errorCount<m_maxNumberOfErrors) log<<MSG::WARNING<<"New hash is: "<<coll->identifyHash()<<endmsg; - } -// } + temp = (*pdHashFn)(coll->identify()); + } + if (temp==-1) { + coll->m_idHash = IdentifierHash(); + log<<MSG::WARNING<<"get_hash failed - nothing else we can try!"<<endmsg; + } else{ + coll->m_idHash = temp; + } // another check - see if already added auto ptr = transCont->indexFindPtr(coll->identifyHash()); @@ -136,15 +118,16 @@ void RpcPadContainerCnv_p1::persToTrans(const RpcPadContainer_p1* persCont, Rpc } else { StatusCode sc = transCont->addCollection(coll, coll->identifyHash()); if (sc.isFailure()) { - log << MSG::WARNING<<"Could not add collection with hash="<<coll->identifyHash() + if (m_rpcCondData) { + log << MSG::WARNING<<"Could not add collection with hash="<<coll->identifyHash() + <<" to IDC which has hash max of "<<transCont->size()<<" (PadHashFunction gives "<<m_rpcCondData->max()<<")"<<endmsg; + } else { + log << MSG::WARNING<<"Could not add collection with hash="<<coll->identifyHash() <<" to IDC which has hash max of "<<transCont->size()<<" (PadHashFunction gives "<<m_rpcCabling->padHashFunction()->max()<<")"<<endmsg; + } throw std::runtime_error("Failed to add collection to ID Container. Hash = "+std::to_string(coll->identifyHash())); } } - // if (log.level() <= MSG::DEBUG) { - // log << MSG::DEBUG << "AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash << " / " << - // persCont[icoll].m_id << ", added to Identifiable container." << endmsg; - // } } log << MSG::DEBUG << " *** Reading RpcPadContainer" << endmsg; @@ -161,9 +144,10 @@ RpcPadContainer* RpcPadContainerCnv_p1::createTransient(const RpcPadContainer_p1 return 0; } } - // log<<MSG::INFO<<"creating new pad container with hashmax= "<<m_RpcId->module_hash_max()<<endmsg; - - std::unique_ptr<RpcPadContainer> trans(new RpcPadContainer(m_rpcCabling->padHashFunction()->max() )); + int hashMax=-1; + if (m_rpcCondData) hashMax = m_rpcCondData->max(); + else hashMax = m_rpcCabling->padHashFunction()->max(); + std::unique_ptr<RpcPadContainer> trans(new RpcPadContainer(hashMax)); persToTrans(persObj, trans.get(), log); return(trans.release()); } diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.h b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.h index 219833cdf04823b3c291abfd83c440c2ffc70f99..626d7b7df23177c326c582cdbbf82f70c6da797d 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.h +++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef RPCPADCONTAINERCNV_P1 @@ -15,8 +15,9 @@ #include "MuonRDO/RpcPadContainer.h" #include "MuonEventAthenaPool/RpcPadContainer_p1.h" +#include "RPC_CondCabling/RpcCablingCondData.h" -class IRPCcablingSvc; +class IRPCcablingSvc; // to be removed class MsgStream; class RpcPadContainerCnv_p1 : public T_AthenaPoolTPCnvBase< RpcPadContainer, RpcPadContainer_p1 > @@ -25,17 +26,17 @@ class RpcPadContainerCnv_p1 : public T_AthenaPoolTPCnvBase< RpcPadContainer, Rpc public: typedef RpcPadContainer_p1 PERS; typedef RpcPadContainer TRANS; - RpcPadContainerCnv_p1(): m_rpcCabling(0), m_isInitialized(false)/*, m_errorCount(0), m_maxNumberOfErrors(10)*/ {} + RpcPadContainerCnv_p1(); virtual void persToTrans(const PERS* persCont, TRANS* transCont, MsgStream &log) override; virtual void transToPers(const TRANS* transCont, PERS* persCont, MsgStream &log) override; virtual RpcPadContainer* createTransient(const RpcPadContainer_p1* persObj, MsgStream& log) override; StatusCode initialize(MsgStream &log, IRPCcablingSvc* cabling = nullptr); + void setRpcCablingCondData(const RpcCablingCondData* rpc){m_rpcCondData=rpc;} private: - const IRPCcablingSvc *m_rpcCabling; + const IRPCcablingSvc *m_rpcCabling; // to be removed bool m_isInitialized; - //unsigned int m_errorCount; - //unsigned int m_maxNumberOfErrors; + const RpcCablingCondData* m_rpcCondData; }; #endif diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx index 53e3029b72f686b2aaeced86fa8178db087f4894..30594ccb0a1c68c4c93b285b269c3cdcaad6697c 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx +++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx @@ -1,34 +1,34 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ +#include "RpcPadContainerCnv_p2.h" + #include "MuonRDO/RpcPad.h" #include "MuonRDO/RpcPadContainer.h" #include "MuonEventAthenaPool/RpcPad_p1.h" #include "MuonEventAthenaPool/RpcPadContainer_p2.h" -#include "MuonIdHelpers/RpcIdHelper.h" #include "RpcPadCnv_p1.h" -#include "RpcPadContainerCnv_p2.h" - -// Gaudi #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/StatusCode.h" #include "GaudiKernel/Service.h" #include "GaudiKernel/MsgStream.h" - -// Athena #include "StoreGate/StoreGateSvc.h" - #include "AthAllocators/DataPool.h" -#include "RPCcablingInterface/IRPCcablingServerSvc.h" -#include "RPCcablingInterface/RpcPadIdHash.h" -#include "RPCcablingInterface/IRPCcablingSvc.h" +#include "RPCcablingInterface/IRPCcablingServerSvc.h" // to be removed +#include "RPCcablingInterface/RpcPadIdHash.h" // to be removed +#include "RPCcablingInterface/IRPCcablingSvc.h" // to be removed + +RpcPadContainerCnv_p2::RpcPadContainerCnv_p2() : + m_rpcCabling(nullptr), + m_isInitialized(false), + m_rpcCondData(nullptr) { +} -StatusCode RpcPadContainerCnv_p2::initialize(MsgStream &log, - IRPCcablingSvc* cabling /*= nullptr*/) { +StatusCode RpcPadContainerCnv_p2::initialize(MsgStream &log, IRPCcablingSvc* cabling) { // Do not initialize again: m_isInitialized=true; @@ -51,22 +51,11 @@ StatusCode RpcPadContainerCnv_p2::initialize(MsgStream &log, sc = RpcCabGet->giveCabling(m_rpcCabling); if (sc.isFailure()) { log << MSG::FATAL << "Could not get RPCcablingSvc from the Server !" << endmsg; - m_rpcCabling = 0; + m_rpcCabling = nullptr; return StatusCode::FAILURE; } } - { - if (!m_rpcCabling->padHashFunction()) - { - m_padhashmax = 1000; - log<<MSG::INFO << "... hoewever it doesn't look like been already init; container size set by hand to "<< m_padhashmax << endmsg; - } - else m_padhashmax = m_rpcCabling->padHashFunction()->max(); - if (log.level() <= MSG::INFO) log <<MSG::INFO << " RPCcablingSvc obtained - hashmax = "<<m_padhashmax << endmsg; - // if (log.level() <= MSG::VERBOSE) log <<MSG::VERBOSE << " RPCcablingSvc obtained " << endmsg; - } - if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized." << endmsg; return StatusCode::SUCCESS; } @@ -85,8 +74,6 @@ void RpcPadContainerCnv_p2::transToPers(const RpcPadContainer* transCont, RpcPa persCont->m_pads.resize(numColl); log << MSG::DEBUG << " Preparing " << persCont->m_pads.size() << "Collections" << endmsg; for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) { - // Add in new collection - //log << MSG::DEBUG << " New collection" << endmsg; RpcPad_p1* pcoll = &( persCont->m_pads[collIndex] ); cnv.transToPers( &(**it_Coll), pcoll , log); } @@ -111,8 +98,13 @@ void RpcPadContainerCnv_p2::persToTrans(const RpcPadContainer_p2* persCont, Rpc } else { StatusCode sc = transCont->addCollection(coll, coll->identifyHash()); if (sc.isFailure()) { - log << MSG::WARNING<<"Could not add collection with hash="<<coll->identifyHash() + if (m_rpcCondData) { + log << MSG::WARNING<<"Could not add collection with hash="<<coll->identifyHash() + <<" to IDC which has hash max of "<<transCont->size()<<" (PadHashFunction gives "<<m_rpcCondData->max()<<")"<<endmsg; + } else { + log << MSG::WARNING<<"Could not add collection with hash="<<coll->identifyHash() <<" to IDC which has hash max of "<<transCont->size()<<" (PadHashFunction gives "<<m_rpcCabling->padHashFunction()->max()<<")"<<endmsg; + } throw std::runtime_error("Failed to add collection to ID Container. Hash = "+std::to_string(coll->identifyHash())); } } @@ -130,13 +122,12 @@ RpcPadContainer* RpcPadContainerCnv_p2::createTransient(const RpcPadContainer_p2 if (this->initialize(log) != StatusCode::SUCCESS) { log << MSG::FATAL << "Could not initialize RpcPadContainerCnv_p2 " << endmsg; return 0; - } + } } - // log<<MSG::INFO<<"creating new pad container with hashmax= "<<m_rpcCabling->padHashFunction()->max()<<endmsg; - - // std::unique_ptr<RpcPadContainer> trans(new RpcPadContainer(m_rpcCabling->padHashFunction()->max() )); - // std::unique_ptr<RpcPadContainer> trans(new RpcPadContainer(404 )) ; // hardcoded number from above. FIXME! - std::unique_ptr<RpcPadContainer> trans(new RpcPadContainer(m_padhashmax)) ; // hardcoded number from above. FIXME! + int hashMax=-1; + if (m_rpcCondData) hashMax = m_rpcCondData->max(); + else hashMax = m_rpcCabling->padHashFunction()->max(); + std::unique_ptr<RpcPadContainer> trans(new RpcPadContainer(hashMax)); persToTrans(persObj, trans.get(), log); return(trans.release()); diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.h b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.h index 72f605be839ea7f66279b226f4e59c9b81955370..86019240cc9c09ca7370e5b4664b996b41e11e33 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.h +++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONEVENTATHENAPOOL_RPCPADCONTAINERCNV_P2 @@ -15,8 +15,9 @@ #include "MuonRDO/RpcPadContainer.h" #include "MuonEventAthenaPool/RpcPadContainer_p2.h" +#include "RPC_CondCabling/RpcCablingCondData.h" -class IRPCcablingSvc; +class IRPCcablingSvc; // to be removed class MsgStream; class RpcPadContainerCnv_p2 : public T_AthenaPoolTPCnvBase< RpcPadContainer, RpcPadContainer_p2 > @@ -25,18 +26,17 @@ class RpcPadContainerCnv_p2 : public T_AthenaPoolTPCnvBase< RpcPadContainer, Rpc public: typedef RpcPadContainer_p2 PERS; typedef RpcPadContainer TRANS; - RpcPadContainerCnv_p2(): m_rpcCabling(0), m_isInitialized(false), m_padhashmax(0)/*, m_errorCount(0), m_maxNumberOfErrors(10)*/ {} + RpcPadContainerCnv_p2(); virtual void persToTrans(const PERS* persCont, TRANS* transCont, MsgStream &log); virtual void transToPers(const TRANS* transCont, PERS* persCont, MsgStream &log); virtual RpcPadContainer* createTransient(const RpcPadContainer_p2* persObj, MsgStream& log); StatusCode initialize(MsgStream &log, IRPCcablingSvc* cabling = nullptr); + void setRpcCablingCondData(const RpcCablingCondData* rpc){m_rpcCondData=rpc;} private: - const IRPCcablingSvc *m_rpcCabling; + const IRPCcablingSvc *m_rpcCabling; // to be removed bool m_isInitialized; - unsigned int m_padhashmax; - //unsigned int m_errorCount; - //unsigned int m_maxNumberOfErrors; + const RpcCablingCondData* m_rpcCondData; }; #endif