From 2a9838b89f5048d388dcfdd1cd3ff3492af09294 Mon Sep 17 00:00:00 2001 From: abarton <Adam.Edward.Barton@cern.ch> Date: Wed, 23 Jun 2021 12:24:41 +0100 Subject: [PATCH 1/2] debug initialization fix --- .../MuonCablingData/MdtMapBase.h | 8 ++- .../MuonCablingData/src/MdtAmtMap.cxx | 18 +++---- .../MuonCablingData/src/MdtMezzanineType.cxx | 8 +-- .../src/MuonMDT_CablingMap.cxx | 50 +++++++++---------- .../src/MuonMDT_CablingAlg.cxx | 8 +-- 5 files changed, 43 insertions(+), 49 deletions(-) diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMapBase.h b/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMapBase.h index f45aa8bc0c0e..04e3c3e7e7b4 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMapBase.h +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMapBase.h @@ -29,7 +29,7 @@ template<class T> class MdtMapBase /** constructor */ - MdtMapBase(uint8_t moduleId, const std::string itemName); + MdtMapBase(uint8_t moduleId, std::string itemName); /** destructor */ ~MdtMapBase() = default; @@ -47,8 +47,6 @@ template<class T> class MdtMapBase /** Module ID */ uint8_t m_moduleId; - /** Output level and message service */ - bool m_debug; /** set function */ bool addItem(uint8_t itemId, T* item, MsgStream &log); @@ -89,7 +87,7 @@ template<class T> void MdtMapBase<T>::clear() { template<class T> bool MdtMapBase<T>::addItem(uint8_t itemId, T* item, MsgStream &log) { bool itemAdded = false; - + bool debug = (log.level() <= MSG::VERBOSE); // check if the id are matching if (itemId != item->moduleId() ) { log << MSG::ERROR << m_itemName << " Id different from the module one: " @@ -104,7 +102,7 @@ template<class T> bool MdtMapBase<T>::addItem(uint8_t itemId, T* item, MsgStream << (int) m_moduleId << endmsg; } else { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Adding " << m_itemName << " with id: 0x" << MSG::hex << (int) itemId << MSG::dec << " to module 0x" << MSG::hex << (int) m_moduleId << MSG::dec << endmsg; diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtAmtMap.cxx b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtAmtMap.cxx index 6ab35d0dfbde..9ebbfe8be836 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtAmtMap.cxx +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtAmtMap.cxx @@ -14,7 +14,7 @@ MdtAmtMap::MdtAmtMap(uint8_t tdcId) : m_phi(0), m_multiLayer(0), m_mezType(0), - m_mdtIdHelper(0),m_debug(false) + m_mdtIdHelper(0) { } @@ -35,9 +35,9 @@ MdtAmtMap::MdtAmtMap(const MdtMezzanineType* mezType, uint8_t tdcId, uint8_t cha //std::cout<<" Here we are "<<std::endl; - m_debug = (ext_log.level() <= MSG::VERBOSE); + bool debug = (ext_log.level() <= MSG::VERBOSE); - if (m_debug) { + if (debug) { ext_log << MSG::VERBOSE << "Adding Tdc number: " << (int) tdcId << endmsg; } @@ -51,14 +51,14 @@ MdtAmtMap::MdtAmtMap(const MdtMezzanineType* mezType, uint8_t tdcId, uint8_t cha // call the function that initializes the actual map if ( initMap(mezType, channel, layer, tube, ext_log) ) { - if (m_debug) { + if (debug) { ext_log << MSG::VERBOSE << "Map initialized successfully for tdc number: " << MSG::hex << (int) tdcId << MSG::dec << endmsg; } } else { - if (m_debug) { + if (debug) { ext_log << MSG::VERBOSE << "Could not initialize completely the TDC map" << endmsg; } } @@ -71,8 +71,8 @@ bool MdtAmtMap::initMap(const MdtMezzanineType* mezType, uint8_t chanZero, int l { bool successful = true; - - if (m_debug) { + bool debug = (log.level() <= MSG::VERBOSE); + if (debug) { log << MSG::VERBOSE << "Initializing the map, the mezzanine type is " << (int) m_mezType << " with " << (int) mezType->nOfTubesInLayer() << " tubes per layer and " << (int) mezType->nOfLayers() << " layers" << endmsg; @@ -195,8 +195,8 @@ bool MdtAmtMap::setChannel(uint8_t channel, uint8_t layer, uint8_t tube, MsgStre m_multiLayer,layer,tube); if ( tube > m_mdtIdHelper->tubeMax(id) || tube < m_mdtIdHelper->tubeMin(id) ) { - - if (m_debug) { + bool debug = (log.level() <= MSG::VERBOSE); + if (debug) { log << MSG::VERBOSE << "The tube is invalid (as expected) ! not adding it..." << endmsg; } diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx index 9c0729f39420..d160335097c3 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx @@ -8,16 +8,12 @@ MdtMezzanineType::MdtMezzanineType(uint8_t typeId, uint8_t nOfLayers, MsgStream m_type(typeId), m_nOfLayers(nOfLayers) { - m_debug = (log.level() <= MSG::VERBOSE); - } MdtMezzanineType::MdtMezzanineType(uint8_t typeId, MsgStream &log) : m_type(typeId), m_nOfLayers(0) { - m_debug = (log.level() <= MSG::VERBOSE); - } /** Destructor */ @@ -40,9 +36,9 @@ bool MdtMezzanineType::addLayer(uint8_t layerNumber, MdtLayer layer, MsgStream & } m_layers[layerNumber]=std::move(layer); - + bool debug = (log.level() <= MSG::VERBOSE); // dump the layer content for debugging - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Adding layer " << (int) layerNumber << " "; for (unsigned int i=0 ; i<m_layers[layerNumber].size() ; ++i) { log << MSG::VERBOSE << (int) m_layers[layerNumber][i]; diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx index 41bf48408030..b1ff504fce30 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx @@ -59,8 +59,8 @@ bool MuonMDT_CablingMap::addMezzanineLine(const int type, const int layer, const int sequence, MsgStream &log) { bool added = true; - - if (m_debug) { + bool debug = (log.level() <= MSG::VERBOSE); + if (debug) { log << MSG::VERBOSE << "Now in MuonMDT_CablingMap::addMezzanineLine" << endmsg; } @@ -83,7 +83,7 @@ bool MuonMDT_CablingMap::addMezzanineLine(const int type, const int layer, } // if it does not exist, create the new type else { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Creating a new mezzanine type: " << type << endmsg; } mezType = new MdtMezzanineType(type, log); @@ -106,7 +106,7 @@ bool MuonMDT_CablingMap::addMezzanineLine(const int type, const int layer, << endmsg; return false; } - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Adding tube number: " << tube << " to the layer " << layer << " of mezzanine type " << type << endmsg; } @@ -136,7 +136,7 @@ bool MuonMDT_CablingMap::addMezzanineLine(const int type, const int layer, } - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Found " << ntubes << " tubes in layer " << layer << endmsg; log << MSG::VERBOSE << "This is a " << nOfLayers << " layers mezzanine - OK, OK..." << endmsg; @@ -188,11 +188,11 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in uint8_t csmId = (uint8_t) csm; uint8_t tdcId = (uint8_t) tdc; uint8_t channel = (uint8_t) chan; - + bool debug = (log.level() <= MSG::VERBOSE); /** check if the subdetector exists, otherwise create it */ MdtSubdetectorMap* subdetectorMap = this->getSubdetectorMap(subdetectorId); if (!subdetectorMap) { - if (m_debug){ + if (debug){ log << MSG::VERBOSE << "Subdetector: 0x" << MSG::hex << (int) subdetectorId << MSG::dec << " not found: create it" << endmsg; } @@ -202,7 +202,7 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in this->setSubdetectorMap(subdetectorId, subdetectorMap, log); } else { - if (m_debug){ + if (debug){ log << MSG::VERBOSE << "Found the subdetector: 0x" << MSG::hex << (int) subdetectorId << MSG::dec << endmsg; } @@ -211,7 +211,7 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in /** look for the correct ROD in the subdetector */ MdtRODMap* rodMap = subdetectorMap->getRODMap(rodId); if (!rodMap) { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "ROD with id: 0x" << MSG::hex << (int) rodId << MSG::dec << " not found, create it" << endmsg; } @@ -219,7 +219,7 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in subdetectorMap->setRODMap(rodId,rodMap, log); } else { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Found the RODid: 0x" << MSG::hex << (int) rodId << MSG::dec << endmsg; } @@ -228,7 +228,7 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in /** look for the correct CSM in the ROD */ MdtCsmMap* csmMap = rodMap->getCsmMap(csmId); if (!csmMap) { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "CSM with id: 0x" << MSG::hex << (int) csmId << MSG::dec << " not found, create it" << endmsg; } @@ -246,7 +246,7 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in } else { - if (m_debug){ + if (debug){ log << MSG::VERBOSE << "Found the CSMid: 0x" << MSG::hex << (int) csmId << MSG::dec << endmsg; } @@ -255,7 +255,7 @@ bool MuonMDT_CablingMap::addMezzanine( uint8_t mezType, int station, int eta, in // if it's a new CSM (here), update the chamber to ROD map at the same time bool added = addChamberToRODMap(station,eta,phi,subdetectorId,rodId, log); if (!added) { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Station already in the map !" << endmsg; } } @@ -302,7 +302,7 @@ bool MuonMDT_CablingMap::addChamberToRODMap(int station, int eta, int phi, { int sub = (int) subdetectorId; int rod = (int) rodId; - + bool debug = (log.level() <= MSG::VERBOSE); IdentifierHash chamberId; bool hashFound = getStationCode(station, eta, phi,chamberId, log); if (!hashFound) { @@ -312,7 +312,7 @@ bool MuonMDT_CablingMap::addChamberToRODMap(int station, int eta, int phi, } uint32_t hardId = (sub<<16) | rod; - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Adding the chamber with Id: " << chamberId << " and subdetector+rod ID: 0x" << MSG::hex << hardId << MSG::dec << endmsg; } @@ -345,7 +345,7 @@ bool MuonMDT_CablingMap::addChamberToRODMap(int station, int eta, int phi, } } if (!rodInitialized) { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Adding the ROD 0x" << MSG::hex << hardId << MSG::dec << " to the list" << endmsg; } @@ -422,14 +422,14 @@ uint32_t MuonMDT_CablingMap::getROBId(const IdentifierHash stationCode, MsgStrea std::vector<uint32_t> MuonMDT_CablingMap::getROBId(const std::vector<IdentifierHash>& mdtHashVector, MsgStream &log) const { std::vector<uint32_t> robVector; - + bool debug = (log.level() <= MSG::VERBOSE); for ( unsigned int i = 0 ; i<mdtHashVector.size() ; ++i ) { int robId = getROBId(mdtHashVector[i], log); if (robId==0) { log << MSG::ERROR << "ROB id not found for Hash Id: " << mdtHashVector[i] << endmsg; } else { - if(m_debug){ + if(debug){ log << MSG::VERBOSE << "Found ROB id 0x" << MSG::hex << robId << MSG::dec << " for hashId " << mdtHashVector[i] << endmsg; } } @@ -581,8 +581,8 @@ bool MuonMDT_CablingMap::getOfflineId(uint8_t subdetectorId, // << " subdetector: 0x" << MSG::hex << (int) subdetectorId << MSG::dec << endmsg; return false; } - - if (m_debug) { + bool debug = (log.level() <= MSG::VERBOSE); + if (debug) { log << MSG::VERBOSE << "Channel: 0x" << MSG::hex << (int) channelId << MSG::dec << " Tdc: 0x" << MSG::hex << (int) tdcId << MSG::dec << " CSM: 0x" << MSG::hex << (int) csmId @@ -607,14 +607,14 @@ bool MuonMDT_CablingMap::getOnlineId(int stationName, int stationEta, int statio uint8_t& channelId, MsgStream &log) const { - + bool debug = (log.level() <= MSG::VERBOSE); // get the station ROD from the ROD map int module = getROBId(stationName, stationEta, stationPhi, log); rodId = (module & 0xff); subdetectorId = (module>>16) & 0xff; - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Station: " << stationName << " eta: " << stationEta << " phi: " << stationPhi << " mapped to subdet: 0x" << MSG::hex << subdetectorId << MSG::dec << " rodId: 0x" << MSG::hex << rodId << MSG::dec << endmsg; @@ -649,7 +649,7 @@ bool MuonMDT_CablingMap::getOnlineId(int stationName, int stationEta, int statio const std::map<uint8_t, std::unique_ptr<MdtAmtMap>, std::less<uint8_t> >* listOfAmt; std::map<uint8_t, std::unique_ptr<MdtAmtMap>, std::less<uint8_t> >::const_iterator it_amt; - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "number of csm to loop: " << listOfCsm->size() << endmsg; } @@ -658,7 +658,7 @@ bool MuonMDT_CablingMap::getOnlineId(int stationName, int stationEta, int statio csmId = ((*it_csm).second)->moduleId(); - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Csm number: " << MSG::hex << (int) csmId << MSG::dec << endmsg; } @@ -690,7 +690,7 @@ bool MuonMDT_CablingMap::getOnlineId(int stationName, int stationEta, int statio found = amtMap->offlineId(23,test_station,test_eta,test_phi, test_multi,test_layer,test_tube, log); if (!found) { - if (m_debug) { + if (debug) { log << MSG::VERBOSE << "Error converting offline->online" << endmsg; } return false; diff --git a/MuonSpectrometer/MuonCablings/MuonMDT_Cabling/src/MuonMDT_CablingAlg.cxx b/MuonSpectrometer/MuonCablings/MuonMDT_Cabling/src/MuonMDT_CablingAlg.cxx index 348110f7f535..088d736986f9 100644 --- a/MuonSpectrometer/MuonCablings/MuonMDT_Cabling/src/MuonMDT_CablingAlg.cxx +++ b/MuonSpectrometer/MuonCablings/MuonMDT_Cabling/src/MuonMDT_CablingAlg.cxx @@ -44,10 +44,10 @@ StatusCode MuonMDT_CablingAlg::initialize(){ StatusCode MuonMDT_CablingAlg::execute(){ ATH_MSG_DEBUG( "execute " << name() ); - + const auto ctx = Gaudi::Hive::currentContext(); // Write Cond Handle - SG::WriteCondHandle<MuonMDT_CablingMap> writeHandle{m_writeKey}; + SG::WriteCondHandle<MuonMDT_CablingMap> writeHandle{m_writeKey, ctx}; if (writeHandle.isValid()) { ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." << ". In theory this should not be called, but may happen" @@ -58,7 +58,7 @@ StatusCode MuonMDT_CablingAlg::execute(){ // Read Cond Handle - SG::ReadCondHandle<CondAttrListCollection> readHandleMez{ m_readKeyMez }; + SG::ReadCondHandle<CondAttrListCollection> readHandleMez{ m_readKeyMez, ctx }; const CondAttrListCollection* readCdoMez{*readHandleMez}; if(readCdoMez==nullptr){ ATH_MSG_ERROR("Null pointer to the read conditions object"); @@ -72,7 +72,7 @@ StatusCode MuonMDT_CablingAlg::execute(){ ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleMez.fullKey() << " readCdoMez->size()= " << readCdoMez->size()); ATH_MSG_INFO("Range of input is " << rangeMez); - SG::ReadCondHandle<CondAttrListCollection> readHandleMap{ m_readKeyMap }; + SG::ReadCondHandle<CondAttrListCollection> readHandleMap{ m_readKeyMap, ctx }; const CondAttrListCollection* readCdoMap{*readHandleMap}; if(readCdoMap==nullptr){ ATH_MSG_ERROR("Null pointer to the read conditions object"); -- GitLab From dcad776f96db332c18f59066d43fff4e547d90f8 Mon Sep 17 00:00:00 2001 From: abarton <Adam.Edward.Barton@cern.ch> Date: Thu, 24 Jun 2021 08:46:38 +0100 Subject: [PATCH 2/2] Fix warning --- .../MuonCablingData/MuonCablingData/MdtMezzanineType.h | 6 ++---- .../MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx | 4 ++-- .../MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMezzanineType.h b/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMezzanineType.h index 0925d5fd1eb8..baeeefddff68 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMezzanineType.h +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/MuonCablingData/MdtMezzanineType.h @@ -28,10 +28,10 @@ class MdtMezzanineType { public: /** constructors with arguments */ - MdtMezzanineType(uint8_t typeId, uint8_t nOfLayers, MsgStream &log); + MdtMezzanineType(uint8_t typeId, uint8_t nOfLayers); /** constructor only with typeId */ - MdtMezzanineType(uint8_t typeId, MsgStream &log); + MdtMezzanineType(uint8_t typeId); ~MdtMezzanineType(); @@ -67,8 +67,6 @@ class MdtMezzanineType { /** Array with the layers (maximum 4) */ std::array<MdtLayer, 5> m_layers; - /** Output level and message service */ - bool m_debug; }; #endif // MUONMDT_CABLING_MDTMEZZANINETYPE_H diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx index d160335097c3..e396f3814d55 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MdtMezzanineType.cxx @@ -4,13 +4,13 @@ #include "MuonCablingData/MdtMezzanineType.h" -MdtMezzanineType::MdtMezzanineType(uint8_t typeId, uint8_t nOfLayers, MsgStream &log) : +MdtMezzanineType::MdtMezzanineType(uint8_t typeId, uint8_t nOfLayers) : m_type(typeId), m_nOfLayers(nOfLayers) { } -MdtMezzanineType::MdtMezzanineType(uint8_t typeId, MsgStream &log) : +MdtMezzanineType::MdtMezzanineType(uint8_t typeId) : m_type(typeId), m_nOfLayers(0) { diff --git a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx index b1ff504fce30..004b4125f38d 100644 --- a/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx +++ b/MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonMDT_CablingMap.cxx @@ -86,7 +86,7 @@ bool MuonMDT_CablingMap::addMezzanineLine(const int type, const int layer, if (debug) { log << MSG::VERBOSE << "Creating a new mezzanine type: " << type << endmsg; } - mezType = new MdtMezzanineType(type, log); + mezType = new MdtMezzanineType(type); // insert the new mezzanine in the map m_listOfMezzanineTypes.insert(MezzanineTypes::value_type(type,mezType)); isNewMezzanine=true; -- GitLab