diff --git a/InnerDetector/InDetConditions/SCT_ConditionsData/src/SCT_TdaqEnabledCondData.cxx b/InnerDetector/InDetConditions/SCT_ConditionsData/src/SCT_TdaqEnabledCondData.cxx index 2ea407dc026700ab10ed2ab0a3bce36b6e117ac6..3f5ba630fb9495beacedc63af585fd0aa41207b8 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsData/src/SCT_TdaqEnabledCondData.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsData/src/SCT_TdaqEnabledCondData.cxx @@ -14,10 +14,10 @@ //---------------------------------------------------------------------- // Constructor SCT_TdaqEnabledCondData::SCT_TdaqEnabledCondData(): - m_goodRods(), - m_goodIds(), - m_noneBad(false), - m_filled(false) + m_goodRods{}, + m_goodIds{}, + m_noneBad{false}, + m_filled{false} {} //---------------------------------------------------------------------- @@ -90,4 +90,3 @@ void SCT_TdaqEnabledCondData::clear() { m_noneBad = false; m_filled = false; } - diff --git a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.cxx b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.cxx index 3a01e38a26b52a409efb91046e4436c1a5d0f649..30390fe1096e6b78d7fe0f82f99f8eeba54c4738 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.cxx @@ -16,9 +16,6 @@ #include "SCT_SlhcIdConverter.h" -#include "AthenaPoolUtilities/AthenaAttributeList.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" - #include "Identifier/IdentifierHash.h" #include "InDetIdentifier/SCT_ID.h" @@ -41,13 +38,14 @@ string SCT_MonitorConditionsSvc::s_defectFolderName{string("/SCT/Derived/Monitor SCT_MonitorConditionsSvc::SCT_MonitorConditionsSvc(const std::string& name,ISvcLocator* pSvcLocator) : AthService(name, pSvcLocator), - m_attrListCollection{nullptr}, m_detStore{"DetectorStore", name}, m_nhits_noisychip{64}, m_nhits_noisywafer{384}, m_nhits_noisymodule{768}, m_pHelper{nullptr}, - m_currentDefectList{""} + m_currentDefectList{""}, + m_condData{nullptr}, + m_condKey{std::string{"SCT_MonitorConditionsCondData"}} { declareProperty("Nnoisychip", m_nhits_noisychip); declareProperty("Nnoisywafer", m_nhits_noisywafer); @@ -68,10 +66,8 @@ SCT_MonitorConditionsSvc::initialize() { return StatusCode::FAILURE; } - if(m_detStore->regFcn(&SCT_MonitorConditionsSvc::getAttrListCollection, this, m_DefectData, s_defectFolderName).isFailure()) { - ATH_MSG_ERROR("Failed to register callback"); - return StatusCode::FAILURE; - } + // Read Cond Handle Key + ATH_CHECK(m_condKey.initialize()); return StatusCode::SUCCESS; } @@ -217,17 +213,12 @@ SCT_MonitorConditionsSvc::badStripsAsString(const Identifier & moduleId) { std::string SCT_MonitorConditionsSvc::getList(const Identifier& imodule) const { - static const string errorstring{""}; - //to be completely robust, could use iter->index("DefectList") below (before the loop) - if(not m_attrListCollection) { - ATH_MSG_ERROR("In getList - no attrListCollection"); - return errorstring; - } m_currentDefectList = ""; int channelNumber{static_cast<int>(imodule.get_identifier32().get_compact())}; - std::map<const int, const std::string>::iterator it{m_defectListMap.find(channelNumber)}; - if(it!=m_defectListMap.end()) { - m_currentDefectList = it->second; + if(getCondData()) { + m_condData->find(channelNumber, m_currentDefectList); + } else { + ATH_MSG_ERROR("In getList - no data"); } return m_currentDefectList; @@ -235,35 +226,6 @@ SCT_MonitorConditionsSvc::getList(const Identifier& imodule) const { /////////////////////////////////////////////////////////////////////////////////// -StatusCode -SCT_MonitorConditionsSvc::getAttrListCollection(int& /*i*/ , std::list<std::string>& /*l*/) { - // trying to find the pointer in the hashmap - // if it exists, return it, otherwise put it in. - - m_attrListCollectionMap.erase(s_defectFolderName); - m_defectListMap.clear(); - - StatusCode sc{m_detStore->retrieve(m_attrListCollection, s_defectFolderName)}; - if(sc.isFailure()) { - ATH_MSG_ERROR("Could not retrieve " << s_defectFolderName); - // Using COOL, is failure - return StatusCode::FAILURE; - } - m_attrListCollectionMap.insert(make_pair(s_defectFolderName, m_attrListCollection)); - static const unsigned int defectListIndex{7}; - CondAttrListCollection::const_iterator iter{m_attrListCollection->begin()}; - CondAttrListCollection::const_iterator last{m_attrListCollection->end()}; - for(; iter != last; ++iter) { - const AthenaAttributeList& list{iter->second}; - if(list.size()) { - m_defectListMap.insert(make_pair(iter->first,list[defectListIndex].data<std::string>())); - } - } - return StatusCode::SUCCESS; -} - -/////////////////////////////////////////////////////////////////////////////////// - bool SCT_MonitorConditionsSvc::stripIsNoisy(const int strip, const std::string & defectList) const { return inList(strip, defectList); @@ -443,3 +405,18 @@ SCT_MonitorConditionsSvc::computeIstrip4moncond(const Identifier& elementId) con unsigned int iistrip{static_cast<unsigned int>(m_pHelper->strip(elementId))}; return stripsPerSide*iiside + iistrip; } + +/////////////////////////////////////////////////////////////////////////////////// + +bool +SCT_MonitorConditionsSvc::getCondData() const { + if(!m_condData) { + SG::ReadCondHandle<SCT_MonitorConditionsCondData> condData{m_condKey}; + if((not condData.isValid()) or !(*condData)) { + ATH_MSG_ERROR("Failed to get " << m_condKey.key()); + return false; + } + m_condData = *condData; + } + return true; +} diff --git a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.h b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.h index 67b17590e87c0684cbe0717a5b4d867d992df72b..20db833ed56b4a1b93452cef4e9e7e17e51dc54a 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.h +++ b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_MonitorConditionsSvc.h @@ -16,8 +16,6 @@ #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/StatusCode.h" -//COOL includes - // Athena includes #include "Identifier/Identifier.h" #include "StoreGate/StoreGateSvc.h" @@ -27,11 +25,16 @@ #include "SCT_ConditionsServices/ISCT_ConditionsSvc.h" #include "SCT_ConditionsServices/ISCT_MonitorConditionsSvc.h" +#include "SCT_ConditionsData/SCT_MonitorConditionsCondData.h" + +// Read Handle Key +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/ReadCondHandleKey.h" + //forward declarations class ISvcLocator; class IdentifierHash; class SCT_ID; -class CondAttrListCollection; /** ** Class for keeping track of errors caught by the monitoring @@ -88,8 +91,6 @@ private: // ------------------------------------------------------------------------------------ std::string getList(const Identifier & imodule) const; - virtual StatusCode getAttrListCollection(int& i, std::list<std::string>& l); - bool stripIsNoisy(const int strip, const std::string& defectList) const; bool chipIsNoisy(int strip, const std::string& defectList) const; @@ -123,18 +124,17 @@ private: static std::string s_defectFolderName; mutable std::map<const int, const std::string> m_defectListMap; - mutable std::map<const std::string, const CondAttrListCollection*> m_attrListCollectionMap; - const DataHandle<CondAttrListCollection> m_DefectData; - const CondAttrListCollection* m_attrListCollection; ServiceHandle<StoreGateSvc> m_detStore; IntegerProperty m_nhits_noisychip; IntegerProperty m_nhits_noisywafer; IntegerProperty m_nhits_noisymodule; - StringProperty m_streamName; bool m_filled; const SCT_ID* m_pHelper; mutable std::string m_currentDefectList; + const mutable SCT_MonitorConditionsCondData *m_condData; + SG::ReadCondHandleKey<SCT_MonitorConditionsCondData> m_condKey; + bool getCondData() const; }; #endif // SCT_MonitorConditinosSvc.h diff --git a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledCondAlg.cxx b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledCondAlg.cxx index dff3acf750e129be43020cd17b1b8d169519c4f3..c46cfa01d1cb4039733957a2509d9d984272eda1 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledCondAlg.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledCondAlg.cxx @@ -12,14 +12,14 @@ SCT_TdaqEnabledCondAlg::SCT_TdaqEnabledCondAlg(const std::string& name, ISvcLocator* pSvcLocator) : ::AthAlgorithm(name, pSvcLocator) - , m_readKey("/TDAQ/Resources/ATLAS/SCT/Robins") - , m_writeKey("SCT_TdaqEnabledCondData", "SCT_TdaqEnabledCondData") - , m_condSvc("CondSvc", name) - , m_cablingSvc("SCT_CablingSvc", name) + , m_readKey{"/TDAQ/Resources/ATLAS/SCT/Robins"} + , m_writeKey{"SCT_TdaqEnabledCondData", "SCT_TdaqEnabledCondData"} + , m_condSvc{"CondSvc", name} + , m_cablingSvc{"SCT_CablingSvc", name} { - declareProperty("ReadKey", m_readKey); - declareProperty("WriteKey", m_writeKey); - declareProperty("EventInfoKey", m_eventInfoKey=std::string("ByteStreamEventInfo")); + declareProperty("ReadKey", m_readKey, "Key of input (raw) conditions folder"); + declareProperty("WriteKey", m_writeKey, "Key of output (derived) conditions folder"); + declareProperty("EventInfoKey", m_eventInfoKey=std::string{"ByteStreamEventInfo"}, "Key of non-xAOD EventInfo"); } SCT_TdaqEnabledCondAlg::~SCT_TdaqEnabledCondAlg() @@ -71,7 +71,7 @@ StatusCode SCT_TdaqEnabledCondAlg::execute() } // Construct the output Cond Object and fill it in - SCT_TdaqEnabledCondData* writeCdo = new SCT_TdaqEnabledCondData(); + SCT_TdaqEnabledCondData* writeCdo{new SCT_TdaqEnabledCondData()}; // clear structures before filling writeCdo->clear(); @@ -80,9 +80,9 @@ StatusCode SCT_TdaqEnabledCondAlg::execute() // check whether we expect valid data at this time if(unfilledRun()) { - EventIDBase unfilledStart(0, 0, 0, 0); // run 0, event 0, timestamp 0, timestamp_ns 0 - EventIDBase unfilledStop(s_earliestRunForFolder, 0, s_earliestTimeStampForFolder, 0); // run 119253, event 0, timestamp 1245064619, timestamp_ns 0 - EventIDRange unfilledRange(unfilledStart, unfilledStop); + EventIDBase unfilledStart{0, 0, 0, 0}; // run 0, event 0, timestamp 0, timestamp_ns 0 + EventIDBase unfilledStop{s_earliestRunForFolder, 0, s_earliestTimeStampForFolder, 0}; // run 119253, event 0, timestamp 1245064619, timestamp_ns 0 + EventIDRange unfilledRange{unfilledStart, unfilledStop}; rangeW = unfilledRange; writeCdo->setNoneBad(true); writeCdo->setFilled(true); @@ -97,16 +97,16 @@ StatusCode SCT_TdaqEnabledCondAlg::execute() ATH_MSG_INFO("Size of CondAttrListCollection readCdo->size()= " << readCdo->size()); - CondAttrListCollection::const_iterator attrList(readCdo->begin()); - CondAttrListCollection::const_iterator end(readCdo->end()); + CondAttrListCollection::const_iterator attrList{readCdo->begin()}; + CondAttrListCollection::const_iterator end{readCdo->end()}; // CondAttrListCollection doesnt support C++11 type loops, no generic 'begin' for(; attrList!=end; ++attrList) { // A CondAttrListCollection is a map of ChanNum and AttributeList - CondAttrListCollection::ChanNum channelNumber = attrList->first; - CondAttrListCollection::AttributeList payload = attrList->second; - std::string enabled = payload["class"].data<std::string>(); - std::string chanName = readCdo->chanName(channelNumber); - unsigned int rodNumber = parseChannelName(chanName); + CondAttrListCollection::ChanNum channelNumber{attrList->first}; + CondAttrListCollection::AttributeList payload{attrList->second}; + std::string enabled{payload["class"].data<std::string>()}; + std::string chanName{readCdo->chanName(channelNumber)}; + unsigned int rodNumber{parseChannelName(chanName)}; // range check on the rod channel number has been removed, since it refers both to existing channel names // which can be rods in slots 1-128 but also historical names which have since been removed if(SCT_OnlineId::rodIdInRange(rodNumber)) { @@ -124,8 +124,8 @@ StatusCode SCT_TdaqEnabledCondAlg::execute() return StatusCode::FAILURE; } - unsigned int nBad = s_NRODS-writeCdo->getGoodRods().size(); - std::string howMany = inWords(nBad); + long unsigned int nBad{s_NRODS-writeCdo->getGoodRods().size()}; + std::string howMany{inWords(nBad)}; ATH_MSG_DEBUG(howMany << " declared bad in the database."); // provide short-cut for no rods bad (hopefully the most common case) @@ -135,7 +135,7 @@ StatusCode SCT_TdaqEnabledCondAlg::execute() } else { // now find the modules which belong to those rods... // const int modulesPerRod(48); - std::vector<IdentifierHash> tmpIdVec(0); + std::vector<IdentifierHash> tmpIdVec{0}; tmpIdVec.reserve(s_modulesPerRod); for(const auto & thisRod : writeCdo->getGoodRods()) { tmpIdVec.clear(); @@ -169,10 +169,10 @@ StatusCode SCT_TdaqEnabledCondAlg::finalize() } bool SCT_TdaqEnabledCondAlg::unfilledRun() const { - SG::ReadHandle<EventInfo> event(m_eventInfoKey); + SG::ReadHandle<EventInfo> event{m_eventInfoKey}; if (event.isValid()) { - const unsigned int runNumber=event->event_ID()->run_number(); - const bool noDataExpected=(runNumber < s_earliestRunForFolder); + const unsigned int runNumber{event->event_ID()->run_number()}; + const bool noDataExpected{runNumber < s_earliestRunForFolder}; if (noDataExpected) ATH_MSG_INFO("This run occurred before the /TDAQ/EnabledResources/ATLAS/SCT/Robins folder was filled in COOL; assuming the SCT is all ok."); return noDataExpected; } @@ -183,11 +183,11 @@ bool SCT_TdaqEnabledCondAlg::unfilledRun() const { //parse a rod channel name to a rod number, names are of the format 'ROL-SCT-BA-00-210000' //October 2014: names can now also be of format 'ROL-SCT-B-00-210100' unsigned int SCT_TdaqEnabledCondAlg::parseChannelName(const std::string &chanNameString) const { - unsigned int result(0); - const unsigned int length=chanNameString.size(); + unsigned int result{0}; + const long unsigned int length{chanNameString.size()}; if (length < 19) return result; //very rough check on sanity of string, should use regex //get the last six numbers, these are in hex - std::istringstream iss(chanNameString.substr(length-6, 6)); + std::istringstream iss{chanNameString.substr(length-6, 6)}; iss.exceptions(std::ios_base::badbit|std::ios_base::failbit); try{ iss>>std::hex>>result; @@ -212,7 +212,7 @@ std::string SCT_TdaqEnabledCondAlg::inWords(const unsigned int aNumber) const { } } -const unsigned int SCT_TdaqEnabledCondAlg::s_NRODS(128); -const unsigned int SCT_TdaqEnabledCondAlg::s_modulesPerRod(48); -const unsigned int SCT_TdaqEnabledCondAlg::s_earliestRunForFolder(119253); -const unsigned int SCT_TdaqEnabledCondAlg::s_earliestTimeStampForFolder(1245064619); // 20090615T111659 UTC for run 119253 +const unsigned int SCT_TdaqEnabledCondAlg::s_NRODS{128}; +const unsigned int SCT_TdaqEnabledCondAlg::s_modulesPerRod{48}; +const unsigned int SCT_TdaqEnabledCondAlg::s_earliestRunForFolder{119253}; +const unsigned int SCT_TdaqEnabledCondAlg::s_earliestTimeStampForFolder{1245064619}; // 20090615T111659 UTC for run 119253 diff --git a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.cxx b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.cxx index 2043ec435b781fa14079a740dc94a92503bf292b..9ab11c470872188df10da38f1603be9a174eaf0f 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.cxx @@ -11,13 +11,9 @@ #include "SCT_TdaqEnabledSvc.h" //STL includes -#include <vector> -#include <list> -#include <algorithm> -#include <sstream> #include <iterator> -#include "boost/array.hpp" #include <iostream> + //Use Event info to determine whether folder is expetd to have valid data #include "EventInfo/EventID.h" #include "EventInfo/EventInfo.h" @@ -37,19 +33,19 @@ // Constructor SCT_TdaqEnabledSvc::SCT_TdaqEnabledSvc( const std::string& name, ISvcLocator* pSvcLocator ) : AthService(name, pSvcLocator), -m_data{nullptr}, +m_condData{nullptr}, m_pHelper{nullptr}, -m_useDatabase(true), m_detStore("DetectorStore",name), -m_condKey(std::string("SCT_TdaqEnabledCondData")) +m_useDatabase{true}, +m_detStore{"DetectorStore", name}, +m_condKey{std::string{"SCT_TdaqEnabledCondData"}} { - //declareProperty("BadRodIdentifiers",m_badElements); - declareProperty("EventInfoKey", m_eventInfoKey=std::string("ByteStreamEventInfo")); + declareProperty("EventInfoKey", m_eventInfoKey=std::string{"ByteStreamEventInfo"}); } //Initialize StatusCode SCT_TdaqEnabledSvc::initialize(){ - const std::string databaseUseString(m_useDatabase?"":"not "); + const std::string databaseUseString{m_useDatabase?"":"not "}; ATH_MSG_INFO(" Database will "<<databaseUseString<<"be used."); ATH_CHECK(m_detStore->retrieve(m_pHelper,"SCT_ID")); @@ -64,8 +60,7 @@ SCT_TdaqEnabledSvc::initialize(){ //Finalize StatusCode SCT_TdaqEnabledSvc::finalize(){ - StatusCode sc(StatusCode::SUCCESS); - return sc; + return StatusCode::SUCCESS; } // From s.binet @@ -75,9 +70,8 @@ SCT_TdaqEnabledSvc::finalize(){ // Return: StatusCode indicating SUCCESS or FAILURE. // N.B. Don't forget to release the interface after use!!! StatusCode -SCT_TdaqEnabledSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) -{ - if ( ISCT_ConditionsSvc::interfaceID().versionMatch(riid) ) { +SCT_TdaqEnabledSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) { + if(ISCT_ConditionsSvc::interfaceID().versionMatch(riid)) { *ppvInterface = dynamic_cast<ISCT_ConditionsSvc*>(this); } else { // Interface is not directly available : try out a base class @@ -88,44 +82,44 @@ SCT_TdaqEnabledSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) } bool -SCT_TdaqEnabledSvc::canReportAbout(InDetConditions::Hierarchy h){ +SCT_TdaqEnabledSvc::canReportAbout(InDetConditions::Hierarchy h) { return (h==InDetConditions::DEFAULT or h==InDetConditions::SCT_SIDE or h==InDetConditions::SCT_MODULE); } bool -SCT_TdaqEnabledSvc::isGood(const Identifier & elementId, InDetConditions::Hierarchy h){ - if (not canReportAbout(h)) return true; +SCT_TdaqEnabledSvc::isGood(const Identifier & elementId, InDetConditions::Hierarchy h) { + if(not canReportAbout(h)) return true; //turn to hash, given the identifier - const IdentifierHash hashId=m_pHelper->wafer_hash(elementId); + const IdentifierHash hashId{m_pHelper->wafer_hash(elementId)}; return isGood(hashId); } bool -SCT_TdaqEnabledSvc::isGood(const IdentifierHash & hashId){ +SCT_TdaqEnabledSvc::isGood(const IdentifierHash & hashId) { if(not getCondData()) return false; - return m_data->isGood(hashId); + return m_condData->isGood(hashId); } bool -SCT_TdaqEnabledSvc::canFillDuringInitialize(){ +SCT_TdaqEnabledSvc::canFillDuringInitialize() { return (not m_useDatabase);// can only fill during intialize if we don't use the database } bool -SCT_TdaqEnabledSvc::filled() const{ +SCT_TdaqEnabledSvc::filled() const { if(not getCondData()) return false; - return m_data->isFilled(); + return m_condData->isFilled(); } bool SCT_TdaqEnabledSvc::getCondData() const { - if(!m_data) { - SG::ReadCondHandle<SCT_TdaqEnabledCondData> data(m_condKey); - if((not data.isValid()) or !(*data)) { + if(!m_condData) { + SG::ReadCondHandle<SCT_TdaqEnabledCondData> condData{m_condKey}; + if((not condData.isValid()) or !(*condData)) { ATH_MSG_ERROR("Failed to get " << m_condKey.key()); return false; } - m_data = *data; + m_condData = *condData; } return true; } diff --git a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.h b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.h index ac6caded4bbfc7bff9ac198179fbe42909a1bb33..d0024938a9d5769eb6287515e42f53dec8e67d1f 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.h +++ b/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_TdaqEnabledSvc.h @@ -77,8 +77,7 @@ public: virtual bool canFillDuringInitialize(); private: - // static const unsigned int NRODS; //!< This was 90 in run 1; changed to 128 on Oct 22, 2014 - const mutable SCT_TdaqEnabledCondData *m_data; + const mutable SCT_TdaqEnabledCondData *m_condData; const SCT_ID * m_pHelper; bool m_useDatabase;