diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h index 3ee4f9cd7b364d8e1da38d93f7ab2bd3bd7c2864..6841c9a6c2e94b5cd8da76dcec5e2dbfd4b87142 100644 --- a/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h @@ -1,14 +1,15 @@ //Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef LARGAINTHRESHOLDS2NTUPLE #define LARGAINTHRESHOLDS2NTUPLE #include "LArCalibTools/LArCond2NtupleBase.h" -#include "LArElecCalib/ILArFEBConfigReader.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArRecConditions/LArFebConfig.h" class LArGainThresholds2Ntuple : public LArCond2NtupleBase { @@ -21,7 +22,8 @@ class LArGainThresholds2Ntuple : public LArCond2NtupleBase StatusCode finalize(){return StatusCode::SUCCESS;} StatusCode stop(); private: - ToolHandle<ILArFEBConfigReader> m_febConfigReader; + + SG::ReadCondHandleKey<LArFebConfig> m_configKey{this, "inputKey","LArFebConfig", "Input key for FEB config object"}; }; diff --git a/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py b/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py index fadd2ca78c7d74d6de9c032b8a93e9e8b12e0c66..44edf30ec9fb013aaef234f47993e537eadb6d03 100644 --- a/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py +++ b/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py @@ -12,7 +12,7 @@ globalflags.DataSource.set_Value_and_Lock('data') globalflags.InputFormat.set_Value_and_Lock('bytestream') from AthenaCommon.JobProperties import jobproperties -jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" +jobproperties.Global.DetDescrVersion = "ATLAS-R2-2016-01-00-01" from AthenaCommon.DetFlags import DetFlags DetFlags.Calo_setOff() @@ -28,61 +28,29 @@ from AtlasGeoModel import GeoModelInit #Get identifier mapping (needed by LArConditionsContainer) -svcMgr.IOVDbSvc.GlobalTag="LARCALIB-000-02" +svcMgr.IOVDbSvc.GlobalTag="LARCALIB-RUN2-02" include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) theApp.EvtMax = 1 svcMgr.EventSelector.RunNumber = 500000 svcMgr.EventSelector.InitialTimeStamp=int(time()) -dbname="<db>COOLOFL_LAR/COMP200</db>" - -conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>"+dbname) -conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>"+dbname) -#conddb.addFolder("","/LAR/ElecCalibOfl/PhysCaliTdiff<key>input</key>"+dbname) - -## LArFebConfigFolders=[ -## "/LAR/Configuration/FEBConfig/Physics/EMBA1", -## "/LAR/Configuration/FEBConfig/Physics/EMBA2", -## "/LAR/Configuration/FEBConfig/Physics/EMBA3", -## "/LAR/Configuration/FEBConfig/Physics/EMBA4", -## "/LAR/Configuration/FEBConfig/Physics/EMBC1", -## "/LAR/Configuration/FEBConfig/Physics/EMBC2", -## "/LAR/Configuration/FEBConfig/Physics/EMBC3", -## "/LAR/Configuration/FEBConfig/Physics/EMBC4", -## "/LAR/Configuration/FEBConfig/Physics/EMECA1", -## "/LAR/Configuration/FEBConfig/Physics/EMECA2", -## "/LAR/Configuration/FEBConfig/Physics/EMECA3", -## "/LAR/Configuration/FEBConfig/Physics/EMECC1", -## "/LAR/Configuration/FEBConfig/Physics/EMECC2", -## "/LAR/Configuration/FEBConfig/Physics/EMECC3", -## "/LAR/Configuration/FEBConfig/Physics/FCALA", -## "/LAR/Configuration/FEBConfig/Physics/FCALC", -## "/LAR/Configuration/FEBConfig/Physics/HECA", -## "/LAR/Configuration/FEBConfig/Physics/HECC", -## ] - - -## for f in LArFebConfigFolders: -## conddb.addFolder("LAR_ONL",f) - - -## from LArRecUtils.LArRecUtils import LArFEBConfigReader -## theLArFebConfigReader=LArFEBConfigReader() -## theLArFebConfigReader.OutputLevel=DEBUG -## theLArFebConfigReader.ListOfFolders=LArFebConfigFolders - - - -from LArRecUtils.LArFEBConfigReaderDefault import LArFEBConfigReaderDefault -theLArFebConfigReader=LArFEBConfigReaderDefault() -theLArFebConfigReader.OutputLevel=DEBUG -ToolSvc+=theLArFebConfigReader +dbname="<db>COOLOFL_LAR/CONDBR2</db>" + +#conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>"+dbname) +#conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>"+dbname) +from LArBadChannelTool.LArBadChannelAccess import LArBadChannelAccess +LArBadChannelAccess() +#from LArBadChannelTool.LArBadFebAccess import LArBadFebAccess +#LArBadFebAccess() + +from LArRecUtils.LArFebConfigCondAlgDefault import LArFebConfigCondAlgDefault +LArFebConfigCondAlgDefault() from LArCalibTools.LArCalibToolsConf import LArGainThresholds2Ntuple theLArGainThresholds2Ntuple=LArGainThresholds2Ntuple() theLArGainThresholds2Ntuple.OutputLevel=DEBUG theLArGainThresholds2Ntuple.AddFEBTempInfo=False -theLArGainThresholds2Ntuple.FebConfigReader=theLArFebConfigReader +theLArGainThresholds2Ntuple.isSC=False topSequence+=theLArGainThresholds2Ntuple @@ -96,11 +64,10 @@ svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='thresholds.root' OPT='NEW'" ] #svcMgr.MessageSvc.OutputLevel = DEBUG svcMgr.IOVDbSvc.DBInstance="" -svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", - "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml", - ] +#svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", +# "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml", +# ] svcMgr.MessageSvc.debugLimit = 5000000 - svcMgr.IOVDbSvc.OutputLevel=DEBUG diff --git a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx index 03eb8f633ea306eee7c4a0af9e8e77ba42dcaf99..5d2a066715678a98ce7bcec806058699a7d7484d 100644 --- a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx @@ -281,7 +281,7 @@ bool LArCond2NtupleBase::fillFromIdentifier(const HWIdentifier& hwid) { return false; } const LArOnOffIdMapping* cabling=nullptr; - if(m_isSC) { + if(!m_isSC) { SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey}; cabling = *cablingHdl; } else { diff --git a/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx index 168e8399b079b0c43143d21a986bed1250198902..e526bd605f6f6829a38b58ee3b2545bb2080a168 100644 --- a/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx @@ -1,14 +1,13 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "LArCalibTools/LArGainThresholds2Ntuple.h" #include "LArIdentifier/LArOnlineID.h" LArGainThresholds2Ntuple::LArGainThresholds2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): - LArCond2NtupleBase(name, pSvcLocator), m_febConfigReader("LArFEBConfigReader") { + LArCond2NtupleBase(name, pSvcLocator) { - declareProperty("FebConfigReader",m_febConfigReader); m_ntTitle="Gain Thresholds"; m_ntpath="/NTUPLES/FILE1/GAINTH"; } @@ -16,10 +15,7 @@ LArGainThresholds2Ntuple::LArGainThresholds2Ntuple(const std::string& name, ISvc StatusCode LArGainThresholds2Ntuple::initialize() { - if (m_febConfigReader.retrieve().isFailure()) { - msg(MSG::ERROR) << "Failed to retrieve tool " << m_febConfigReader << endmsg; - return StatusCode::FAILURE; - } + ATH_CHECK(m_configKey.initialize()); return LArCond2NtupleBase::initialize(); } @@ -28,40 +24,35 @@ LArGainThresholds2Ntuple::~LArGainThresholds2Ntuple() {} StatusCode LArGainThresholds2Ntuple::stop() { - StatusCode sc; - NTuple::Item<long> lower; - NTuple::Item<long> upper; + + ATH_MSG_DEBUG(" trying stop"); + + NTuple::Item<long> lower; + NTuple::Item<long> upper; - sc=m_nt->addItem("lower",lower,-1000,5000); - if (sc!=StatusCode::SUCCESS) { - msg(MSG::ERROR) << "addItem 'lower' failed" << endmsg; - return StatusCode::FAILURE; - } - - sc=m_nt->addItem("upper",upper,-1000.,5000.); - if (sc!=StatusCode::SUCCESS) { - msg(MSG::ERROR) << "addItem 'upper' failed" << endmsg; + SG::ReadCondHandle<LArFebConfig> configHdl{m_configKey}; + const LArFebConfig* febConfig = *configHdl; + if (febConfig==nullptr) { + ATH_MSG_ERROR( "Unable to retrieve LArFebConfig with key " << m_configKey.key()); return StatusCode::FAILURE; } + + ATH_CHECK(m_nt->addItem("lower",lower,-1000,5000)); + ATH_CHECK(m_nt->addItem("upper",upper,-1000.,5000.)); std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); for(; itOnId!=itOnIdEnd;++itOnId){ const HWIdentifier hwid = *itOnId; - lower=m_febConfigReader->lowerGainThreshold(hwid); - upper=m_febConfigReader->upperGainThreshold(hwid); - + lower=febConfig->lowerGainThreshold(hwid); + upper=febConfig->upperGainThreshold(hwid); + fillFromIdentifier(hwid); - sc=ntupleSvc()->writeRecord(m_nt); - if (sc!=StatusCode::SUCCESS) { - (*m_log) << MSG::ERROR << "writeRecord failed" << endmsg; - return StatusCode::FAILURE; - } + ATH_CHECK(ntupleSvc()->writeRecord(m_nt)); } - msg(MSG::INFO) << "LArGainThresholds2Ntuple has finished." << endmsg; + ATH_MSG_INFO("LArGainThresholds2Ntuple has finished."); return StatusCode::SUCCESS; -}// end finalize-method. - +} diff --git a/LArCalorimeter/LArRecConditions/CMakeLists.txt b/LArCalorimeter/LArRecConditions/CMakeLists.txt index a2a15271ea40337f57dacea1fdf75285868b895c..e389bfa48984dd33420f6eff05c2a22d9df0166a 100644 --- a/LArCalorimeter/LArRecConditions/CMakeLists.txt +++ b/LArCalorimeter/LArRecConditions/CMakeLists.txt @@ -10,6 +10,7 @@ atlas_depends_on_subdirs( PUBLIC Calorimeter/CaloIdentifier LArCalorimeter/LArIdentifier Control/AthenaKernel + Control/AthenaBaseComps DetectorDescription/Identifier GaudiKernel PRIVATE @@ -24,7 +25,7 @@ atlas_add_library( LArRecConditions src/*.cxx PUBLIC_HEADERS LArRecConditions PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES CaloIdentifier LArIdentifier AthenaKernel Identifier GaudiKernel + LINK_LIBRARIES CaloIdentifier LArIdentifier AthenaKernel Identifier GaudiKernel AthenaBaseComps PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) atlas_add_dictionary( LArRecConditionsDict diff --git a/LArCalorimeter/LArRecConditions/LArRecConditions/LArFebConfig.h b/LArCalorimeter/LArRecConditions/LArRecConditions/LArFebConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..f63cbe0e72c40423a425816536c4a348da03a526 --- /dev/null +++ b/LArCalorimeter/LArRecConditions/LArRecConditions/LArFebConfig.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARRECCONDITIONS_LARFEBCONFIG_H +#define LARRECCONDITIONS_LARFEBCONFIG_H + +#include "AthenaBaseComps/AthMessaging.h" +#include "Identifier/HWIdentifier.h" +#include "CoralBase/AttributeList.h" +#include "LArElecCalib/LArCalibErrorCode.h" +#include <vector> +#include <mutex> + +class LArOnlineID; + +class LArFebConfig: public AthMessaging { + + friend class LArFEBConfigCondAlg; //The conditions alg filling this object + + public: + LArFebConfig()=delete; + LArFebConfig(const LArOnlineID* onlineId); // we do not own this pointer + + //Accessor methods from ILArFEBConfigReader + short lowerGainThreshold(const HWIdentifier& id) const; + short upperGainThreshold(const HWIdentifier& id) const; + + private: + const LArOnlineID* m_onlineID; + + std::map<HWIdentifier,const coral::AttributeList*> m_attrPerFeb; + mutable std::map<HWIdentifier,const coral::AttributeList*>::const_iterator m_lastIt; + mutable std::mutex m_itMtx; + + short getThreshold(const char* MedLow, const HWIdentifier& chid) const; + + enum {ERRORCODE = LArElecCalib::ERRORCODE}; + +}; + +inline short LArFebConfig::lowerGainThreshold(const HWIdentifier& chid) const { + return getThreshold("lower",chid); +} + + +inline short LArFebConfig::upperGainThreshold(const HWIdentifier& chid) const { + return getThreshold("upper",chid); +} + + +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF( LArFebConfig, 155518838 , 1) +#include "AthenaKernel/CondCont.h" +CLASS_DEF( CondCont<LArFebConfig>, 148539538 , 1) + +#endif diff --git a/LArCalorimeter/LArRecConditions/src/LArFebConfig.cxx b/LArCalorimeter/LArRecConditions/src/LArFebConfig.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3c597c620c70af294b7787d7ba1dc1ada722296e --- /dev/null +++ b/LArCalorimeter/LArRecConditions/src/LArFebConfig.cxx @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRecConditions/LArFebConfig.h" +#include "LArIdentifier/LArOnlineID.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IMessageSvc.h" +#include "CoralBase/Attribute.h" + +LArFebConfig::LArFebConfig(const LArOnlineID* onlineId) : + AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),"LArFebConfig"), + m_onlineID(onlineId) + +{ } + +short LArFebConfig::getThreshold(const char* MedLow, const HWIdentifier& chid) const { + + if (m_attrPerFeb.size()==0) { + ATH_MSG_WARNING("FEB treshold cache is empty. Callback not fired?"); + return ERRORCODE; + } + + std::lock_guard<std::mutex> lock(m_itMtx); //Makes sure the following isn't executed concurently + + const HWIdentifier fid=m_onlineID->feb_Id(chid); + const int channel=m_onlineID->channel(chid); + if (m_lastIt==m_attrPerFeb.end() || m_lastIt->first!=fid) + m_lastIt=m_attrPerFeb.find(fid); + + if (m_lastIt==m_attrPerFeb.end()) { + ATH_MSG_DEBUG("Such FEB was not found !"); + return ERRORCODE; + }else { + std::string channame(MedLow,5); + channame += std::to_string(channel+1); + return (short)(*(m_lastIt->second))[channame].data<int32_t>(); //Will throw and exception if channel does not exist + } +} diff --git a/LArCalorimeter/LArRecUtils/python/LArADC2MeVCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArADC2MeVCondAlgDefault.py index 551b7b98c79a37c9069c661e027ccacdf258e1a3..c88ecae5bcdefc01d11b5d2d83facb81758110e4 100644 --- a/LArCalorimeter/LArRecUtils/python/LArADC2MeVCondAlgDefault.py +++ b/LArCalorimeter/LArRecUtils/python/LArADC2MeVCondAlgDefault.py @@ -40,8 +40,8 @@ def LArADC2MeVCondAlgDefault(): theADC2MeVCondAlg.UseFEBGainTresholds=False else: # not MC: - from LArRecUtils.LArFEBConfigReaderDefault import LArFEBConfigReaderDefault - theADC2MeVCondAlg.FebConfigReader=LArFEBConfigReaderDefault() + from LArRecUtils.LArFebConfigCondAlgDefault import LArFebConfigCondAlgDefault + LArFebConfigCondAlgDefault() condSeq+=theADC2MeVCondAlg diff --git a/LArCalorimeter/LArRecUtils/python/LArADC2MeVToolDefault.py b/LArCalorimeter/LArRecUtils/python/LArADC2MeVToolDefault.py index 763d697aaab6267c63d430b8848cdd4127bd5dfe..d258300fd27a78be737781bde23b6d6fa4a74afd 100644 --- a/LArCalorimeter/LArRecUtils/python/LArADC2MeVToolDefault.py +++ b/LArCalorimeter/LArRecUtils/python/LArADC2MeVToolDefault.py @@ -32,11 +32,8 @@ def LArADC2MeVToolDefault (name="LArADC2MeVToolDefault", **kw): tool.UseHVScaleCorr = True if larCondFlags.useLArFEBGainThresholds(): - from LArRecUtils.LArFEBConfigReaderDefault import LArFEBConfigReaderDefault - theLArFebConfigReader=LArFEBConfigReaderDefault() - #theLArFebConfigReader.OutputLevel=DEBUG - ServiceMgr.ToolSvc+=theLArFebConfigReader - tool.FebConfigReader=theLArFebConfigReader + from LArRecUtils.LArFebConfigCondAlgDefault import LArFebConfigCondAlgDefault + LArFebConfigCondAlgDefault() tool.UseFEBGainTresholds=True diff --git a/LArCalorimeter/LArRecUtils/python/LArFEBConfigReaderDefault.py b/LArCalorimeter/LArRecUtils/python/LArFebConfigCondAlgConfig.py similarity index 60% rename from LArCalorimeter/LArRecUtils/python/LArFEBConfigReaderDefault.py rename to LArCalorimeter/LArRecUtils/python/LArFebConfigCondAlgConfig.py index 2368fea78fdb4de02208997164fb7cdd38deb745..5a852542359a327a7a10cffe78673538a5b695e6 100644 --- a/LArCalorimeter/LArRecUtils/python/LArFEBConfigReaderDefault.py +++ b/LArCalorimeter/LArRecUtils/python/LArFebConfigCondAlgConfig.py @@ -1,21 +1,13 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from IOVDbSvc.CondDB import conddb -from AthenaCommon.Logging import logging -from AthenaCommon.AppMgr import ServiceMgr +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from IOVDbSvc.IOVDbSvcConfig import addFolders +from LArRecUtils.LArRecUtilsConf import LArFEBConfigCondAlg -def LArFEBConfigReaderDefault (name="LArFEBConfigReaderDefault", **kw): - mlog = logging.getLogger( 'LArFEBConfigReaderDefault::__init__ ' ) - if hasattr(ServiceMgr.ToolSvc,name): - mlog.info("LArFEBConfigReader with name" + name + "already known to ToolSvc") - return getattr(ServiceMgr.ToolSvc,name) +def LArFEBConfigCondAlgCfg (configFlags): - - # call base class constructor - from AthenaCommon import CfgMgr - kw['name'] = name - tool = CfgMgr.LArFEBConfigReader (**kw) + result=ComponentAccumulator() LArFebConfigFolders=[ "/LAR/Configuration/FEBConfig/Physics/EMBA1", @@ -41,7 +33,8 @@ def LArFEBConfigReaderDefault (name="LArFEBConfigReaderDefault", **kw): for f in LArFebConfigFolders: conddb.addFolder("LAR_ONL",f) + result.merge(addFolders(configFlags,f,"LAR_ONL",className="CondAttrListCollection")) + + result.addCondAlgo(LArFEBConfigCondAlg(ListOfFolders=LArFebConfigFolders,keyOutput="LArFebConfig")) - tool.ListOfFolders=LArFebConfigFolders return tool - diff --git a/LArCalorimeter/LArRecUtils/python/LArFebConfigCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArFebConfigCondAlgDefault.py new file mode 100644 index 0000000000000000000000000000000000000000..98939d84ad21c0ac59e795b4a355e1490314e94f --- /dev/null +++ b/LArCalorimeter/LArRecUtils/python/LArFebConfigCondAlgDefault.py @@ -0,0 +1,46 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.Include import Include, IncludeError, include +from IOVDbSvc.CondDB import conddb +from AthenaCommon.AlgSequence import AthSequencer +from LArRecUtils.LArRecUtilsConf import LArFEBConfigCondAlg + + +def LArFebConfigCondAlgDefault (): + + condSeq = AthSequencer("AthCondSeq") + if hasattr (condSeq,"LArFEBConfigCondAlg"): + return getattr(condSeq,"LArFEBConfigCondAlg") + + theLArFEBConfigCondAlg = LArFEBConfigCondAlg() + + LArFebConfigFolders=[ + "/LAR/Configuration/FEBConfig/Physics/EMBA1", + "/LAR/Configuration/FEBConfig/Physics/EMBA2", + "/LAR/Configuration/FEBConfig/Physics/EMBA3", + "/LAR/Configuration/FEBConfig/Physics/EMBA4", + "/LAR/Configuration/FEBConfig/Physics/EMBC1", + "/LAR/Configuration/FEBConfig/Physics/EMBC2", + "/LAR/Configuration/FEBConfig/Physics/EMBC3", + "/LAR/Configuration/FEBConfig/Physics/EMBC4", + "/LAR/Configuration/FEBConfig/Physics/EMECA1", + "/LAR/Configuration/FEBConfig/Physics/EMECA2", + "/LAR/Configuration/FEBConfig/Physics/EMECA3", + "/LAR/Configuration/FEBConfig/Physics/EMECC1", + "/LAR/Configuration/FEBConfig/Physics/EMECC2", + "/LAR/Configuration/FEBConfig/Physics/EMECC3", + "/LAR/Configuration/FEBConfig/Physics/FCALA", + "/LAR/Configuration/FEBConfig/Physics/FCALC", + "/LAR/Configuration/FEBConfig/Physics/HECA", + "/LAR/Configuration/FEBConfig/Physics/HECC", + ] + + + for f in LArFebConfigFolders: + conddb.addFolder("LAR_ONL",f,className="CondAttrListCollection") + + theLArFEBConfigCondAlg.ListOfFolders=LArFebConfigFolders + theLArFEBConfigCondAlg.keyOutput="LArFebConfig" + + condSeq+=theLArFEBConfigCondAlg + return theLArFEBConfigCondAlg diff --git a/LArCalorimeter/LArRecUtils/python/LArRecUtilsConfigDb.py b/LArCalorimeter/LArRecUtils/python/LArRecUtilsConfigDb.py index 2c13020f134532b5dcce6b5eb769ac5e363b8c02..ecf2c8f6ae15e917bd6f5e1acee2cea5922fcf83 100644 --- a/LArCalorimeter/LArRecUtils/python/LArRecUtilsConfigDb.py +++ b/LArCalorimeter/LArRecUtils/python/LArRecUtilsConfigDb.py @@ -6,6 +6,5 @@ addTool("LArRecUtils.LArOFCToolDefault.LArOFCToolDefault" , "LArOFCToolDefault") addTool("LArRecUtils.LArAutoCorrNoiseToolDefault.LArAutoCorrNoiseToolDefault" , "LArAutoCorrNoiseToolDefault") addTool("LArRecUtils.LArAutoCorrTotalToolDefault.LArAutoCorrTotalToolDefault","LArAutoCorrTotalToolDefault") addTool("LArRecUtils.LArHVCorrToolDefault.LArHVCorrToolDefault","LArHVCorrToolDefault") -addTool("LArRecUtils.LArFEBConfigReaderDefault.LArFEBConfigReaderDefault","LArFEBConfigReaderDefault") addTool("LArRecUtils.LArOFPeakRecoToolDefault.LArOFPeakRecoToolDefault","LArOFPeakRecoToolDefault") addTool("LArRecUtils.LArParabolaPeakRecoToolDefault.LArParabolaPeakRecoToolDefault","LArParabolaPeakRecoToolDefault") diff --git a/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.cxx index 69e4234ac3e6c4a94d8f1c180bd4d34066688944..f7241477e33f1f993f82bbcaada976ff7c51e765 100644 --- a/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -16,8 +16,6 @@ #include "LArIdentifier/LArOnline_SuperCellID.h" #include "CaloIdentifier/CaloGain.h" -#include "LArElecCalib/ILArFEBConfigReader.h" - #include <memory> #include "GaudiKernel/EventIDRange.h" @@ -32,12 +30,10 @@ LArADC2MeVCondAlg::LArADC2MeVCondAlg(const std::string& name, ISvcLocator* pSvcL m_lArHVScaleCorrKey("LArHVScaleCorr"), m_ADC2MeVKey("LArADC2MeV","LArADC2MeV"), m_condSvc("CondSvc",name), - m_febCfgReader("LArFEBConfigReader",this), + m_configKey("LArFebConfig"), m_isSuperCell(false) { - //declareProperty("LArOnlineIDKey",m_larOnlineIDKey,"SG key of LArOnlineID helper obj for regular cells"); - //declareProperty("LArSCOnlineIDKey",m_larSCOnlineIDKey,"SG key of LArOnlineID helper obj for SuperCells"); declareProperty("LArOnOffIdMappingKey",m_cablingKey,"SG key of LArOnOffIdMapping object"); declareProperty("LAruA2MeVKey",m_lAruA2MeVKey,"SG key of uA2MeV object"); declareProperty("LArDAC2uAKey",m_lArDAC2uAKey,"SG key of DAC2uA object"); @@ -46,8 +42,8 @@ LArADC2MeVCondAlg::LArADC2MeVCondAlg(const std::string& name, ISvcLocator* pSvcL declareProperty("LArHVScaleCorrKey",m_lArHVScaleCorrKey,"SG key of HVScaleCorr object (or empty string if no HVScaleCorr)"); declareProperty("LArADC2MeVKey",m_ADC2MeVKey,"SG key of the resulting LArADC2MeV object"); declareProperty("isSuperCell",m_isSuperCell,"switch to true to use the SuperCell Identfier helper"); - declareProperty("FebConfigReader",m_febCfgReader); declareProperty("UseFEBGainTresholds",m_useFEBGainThresholds=true); + declareProperty("inputKey",m_configKey,"SG key for FEB config object"); } LArADC2MeVCondAlg::~LArADC2MeVCondAlg() {} @@ -92,11 +88,8 @@ StatusCode LArADC2MeVCondAlg::initialize() { return StatusCode::FAILURE; } - if (m_useFEBGainThresholds) { - ATH_CHECK(m_febCfgReader.retrieve()); - } else { - m_febCfgReader.disable(); - } + if (m_useFEBGainThresholds) ATH_CHECK(m_configKey.initialize()); + return StatusCode::SUCCESS; } @@ -166,6 +159,17 @@ StatusCode LArADC2MeVCondAlg::execute() { return StatusCode::FAILURE; } + // retrieve LArFebConfig if needed + const LArFebConfig *febConfig=nullptr; + if(m_useFEBGainThresholds) { + SG::ReadCondHandle<LArFebConfig> configHdl{m_configKey}; + febConfig = *configHdl; + if (febConfig==nullptr) { + ATH_MSG_ERROR( "Unable to retrieve LArFebConfig with key " << m_configKey.key()); + return StatusCode::FAILURE; + } + } + rangeOut=EventIDRange::intersect(rangeOut,rangeIn); //The following two are optional (not used for MC and/or SuperCells) @@ -280,7 +284,7 @@ StatusCode LArADC2MeVCondAlg::execute() { } //Determine if the intercept is to be used: - if (igain==0 || (igain==1 && m_useFEBGainThresholds && m_febCfgReader->lowerGainThreshold(chid)<5)) { + if (igain==0 || (igain==1 && febConfig && febConfig->lowerGainThreshold(chid)<5)) { //Don't use ramp intercept in high gain and in medium gain if the no high gain is used //(eg lowerGainThreshold is ~zero) ADC2MeV.push_back(0.); diff --git a/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.h b/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.h index 2ad45971f321c7fa33c7dfa6890a02a9a56cee55..992d255c6c1a47baadd0a1a6008c915e66879839 100644 --- a/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.h +++ b/LArCalorimeter/LArRecUtils/src/LArADC2MeVCondAlg.h @@ -1,7 +1,7 @@ //Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -13,7 +13,7 @@ #include "StoreGate/ReadCondHandleKey.h" #include "StoreGate/WriteCondHandleKey.h" #include "GaudiKernel/ICondSvc.h" -#include "GaudiKernel/ToolHandle.h" +#include "LArRecConditions/LArFebConfig.h" class LArADC2MeV; class ILAruA2MeV; @@ -23,8 +23,6 @@ class ILArMphysOverMcal; class ILArHVScaleCorr; class LArOnOffIdMapping; -class ILArFEBConfigReader; - class LArADC2MeVCondAlg: public AthAlgorithm { public: @@ -50,10 +48,7 @@ class LArADC2MeVCondAlg: public AthAlgorithm { ServiceHandle<ICondSvc> m_condSvc; - //FIXME: - //The FEB configurations (gain thresholds) are also conditions - //Its stored in 18 COOL folders, so waiting for ReadCondHandleArray for migrating to a cond-algo - ToolHandle<ILArFEBConfigReader> m_febCfgReader; + SG::ReadCondHandleKey<LArFebConfig> m_configKey; bool m_useFEBGainThresholds; size_t m_nGains; diff --git a/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx b/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx index 26c58abe2ebc6092cfaa539edd1362980da06c76..d0cb9f9ed5f23f73f5b64b5a4a1c4fc1058dc210 100644 --- a/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.cxx @@ -33,8 +33,7 @@ LArADC2MeVTool::LArADC2MeVTool(const std::string& type, m_useHVScaleCorr(false), m_useFEBGainThresholds(false), m_cacheValid(false), - m_febConfigReader("LArFEBConfigReader") - , m_isSC(false) + m_isSC(false) { declareInterface<ILArADC2MeVTool>(this); @@ -47,7 +46,6 @@ LArADC2MeVTool::LArADC2MeVTool(const std::string& type, declareProperty("UseMphysOverMcal",m_useMphysOverMcal); declareProperty("UseHVScaleCorr",m_useHVScaleCorr); declareProperty("LoadAtBegin",m_loadAtBegin=true); - declareProperty("FebConfigReader",m_febConfigReader); declareProperty("UseFEBGainTresholds",m_useFEBGainThresholds); declareProperty("IsSC",m_isSC); m_ADC2MeV=NULL; @@ -158,7 +156,7 @@ StatusCode LArADC2MeVTool::initialize() { } } - ATH_CHECK( m_febConfigReader.retrieve( DisableTool{ !m_useFEBGainThresholds } )); + if(m_useFEBGainThresholds) ATH_CHECK(m_configKey.initialize()); if (m_loadAtBegin) { ATH_MSG_DEBUG( "Setting callback function to load calibration at begin of run"); @@ -288,6 +286,16 @@ StatusCode LArADC2MeVTool::getADC2MeV() const { unsigned int ngains(3); if ( m_isSC ) ngains=1; + // retrieve LArFebConfig if needed + const LArFebConfig *febConfig=nullptr; + if(m_useFEBGainThresholds) { + SG::ReadCondHandle<LArFebConfig> configHdl{m_configKey}; + febConfig = *configHdl; + if (febConfig==nullptr) { + ATH_MSG_ERROR( "Unable to retrieve LArFebConfig with key " << m_configKey.key()); + return StatusCode::FAILURE; + } + } for(;it!=it_e;++it) { count ++; const HWIdentifier id = *it; @@ -361,7 +369,7 @@ StatusCode LArADC2MeVTool::getADC2MeV() const { const std::size_t iMax = ADC2DAC.size(); vADC2MeV.reserve(iMax); for(unsigned int i=0;i<iMax;i++) { - if (m_useFEBGainThresholds && igain==1 && i==0 && m_febConfigReader->lowerGainThreshold(id)<5) { + if (febConfig && igain==1 && i==0 && febConfig->lowerGainThreshold(id)<5) { //Don't use ramp offset in MED gain offset if HIGH gain is not used ++count8; vADC2MeV.push_back(0.); diff --git a/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.h b/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.h index 43f2431852bb9bc78ff1dbaf12fbc0c9db278b33..459bf4174229f87478adfc576267c31b69d8b60c 100644 --- a/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.h +++ b/LArCalorimeter/LArRecUtils/src/LArADC2MeVTool.h @@ -28,7 +28,9 @@ #include "LArElecCalib/ILAruA2MeV.h" #include "LArElecCalib/ILArMphysOverMcal.h" #include "LArElecCalib/ILArHVScaleCorr.h" -#include "LArElecCalib/ILArFEBConfigReader.h" + +#include "StoreGate/ReadCondHandleKey.h" +#include "LArRecConditions/LArFebConfig.h" #include "StoreGate/DataHandle.h" #include "LArCabling/LArCablingBase.h" @@ -104,7 +106,8 @@ class LArADC2MeVTool: public AthAlgTool, mutable LArConditionsContainer< std::vector<float> >* m_ADC2MeV; mutable std::vector< std::vector < float > > m_ADC2MeV_vec; - ToolHandle<ILArFEBConfigReader> m_febConfigReader; + SG::ReadCondHandleKey<LArFebConfig> m_configKey{this, "inputKey","LArFebConfig", "Input key for FEB config object"}; + bool m_isSC; }; diff --git a/LArCalorimeter/LArRecUtils/src/LArFEBConfigCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArFEBConfigCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3f533c68a93f8e525007149fdb539d05bfd4a1ca --- /dev/null +++ b/LArCalorimeter/LArRecUtils/src/LArFEBConfigCondAlg.cxx @@ -0,0 +1,112 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArFEBConfigCondAlg.h" +#include "LArIdentifier/LArOnlineID.h" + + +LArFEBConfigCondAlg::LArFEBConfigCondAlg(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name,pSvcLocator),m_onlineID(nullptr) { + + declareProperty("ListOfFolders",m_listOfFolders); + +} + + +LArFEBConfigCondAlg::~LArFEBConfigCondAlg() {} + +StatusCode LArFEBConfigCondAlg::initialize() { + + ATH_MSG_DEBUG(" trying initialize"); + + ATH_CHECK(detStore()->retrieve(m_onlineID,"LArOnlineID")); + + if (m_listOfFolders.size()==0) { + ATH_MSG_WARNING( "List of folders is emtpy, do nothing"); + return StatusCode::SUCCESS; + } + + for (size_t i=0;i<m_listOfFolders.size();++i) { + ATH_CHECK(m_listOfFolders[i].initialize()); + }//end loop over folders + + ATH_CHECK(m_configKey.initialize()); + + ATH_MSG_DEBUG("Successfully initialized LArFEBConfigCondAlg"); + return StatusCode::SUCCESS; +} + + + +StatusCode LArFEBConfigCondAlg::execute(const EventContext& ctx) const { + ATH_MSG_DEBUG("executing"); + + SG::WriteCondHandle<LArFebConfig> writeHandle{m_configKey}; + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("Found valid write LArFebConfig handle"); + return StatusCode::SUCCESS; + } + + // Define validity of the output cond object + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + EventIDRange rangeW{start, stop}; + + std::vector<const CondAttrListCollection*> attrvec; + + for (auto fldkey: m_listOfFolders) { + SG::ReadCondHandle<CondAttrListCollection> cHdl(fldkey, ctx); + const CondAttrListCollection* cattr = *cHdl; + if(cattr) { + ATH_MSG_DEBUG("Folder: "<<cHdl.key()<<" has size: "<<std::distance(cattr->begin(),cattr->end())); + attrvec.push_back(cattr); + EventIDRange rangeW_tmp; + if(!cHdl.range(rangeW_tmp)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << cHdl.key()); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG("and validity range: "<<rangeW_tmp); + rangeW.intersect(rangeW,rangeW_tmp); + } else { + ATH_MSG_WARNING("Why do not have FEB config folder " << fldkey.fullKey()); + } + } + + // Fill LArFebConfig + std::unique_ptr<LArFebConfig> febConfig=std::make_unique<LArFebConfig>(m_onlineID); + LArFebConfig* p_febConfig = febConfig.get(); + + unsigned nFebs=0; + for(auto dh: attrvec){ + CondAttrListCollection::const_iterator chanit=dh->begin(); + CondAttrListCollection::const_iterator chanit_e=dh->end(); + for (;chanit!=chanit_e;++chanit) { + if (chanit->first==0) { + ATH_MSG_DEBUG("Invalid channel number 0, ignoring..."); + continue; + } + const HWIdentifier fid(chanit->first); //COOL channel number == FEB identifier + //const coral::AttributeList& attr = chanit->second; + ATH_MSG_DEBUG("Working on FEB 0x" << std::hex << fid.get_compact() << std::dec << " " << m_onlineID->channel_name(fid)); + p_febConfig->m_attrPerFeb[fid]=std::move(&(chanit->second)); + ++nFebs; + }//End loop over COOL channels + p_febConfig->m_lastIt = p_febConfig->m_attrPerFeb.end(); + } + ATH_MSG_INFO("Read gain thresholds for " << nFebs << " Febs from " << m_listOfFolders.size() << " database folders."); + + // Record output + const EventIDRange crangeW(rangeW); + if(writeHandle.record(crangeW,febConfig.release()).isFailure()) { + ATH_MSG_ERROR("Could not record LArFebConfig object with " << writeHandle.key() + << " with EventRange " << crangeW << " into Conditions Store"); + return StatusCode::FAILURE; + } + + ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << crangeW << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + + diff --git a/LArCalorimeter/LArRecUtils/src/LArFEBConfigCondAlg.h b/LArCalorimeter/LArRecUtils/src/LArFEBConfigCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..76a6c0d7c933a71d22b5399d9842eb70ab494a37 --- /dev/null +++ b/LArCalorimeter/LArRecUtils/src/LArFEBConfigCondAlg.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARRECUTILS_LARFEBCONFIGCONDALG +#define LARRECUTILS_LARFEBCONFIGCONDALG + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaKernel/IOVSvcDefs.h" +#include "LArRecConditions/LArFebConfig.h" +#include "StoreGate/CondHandleKeyArray.h" +#include "StoreGate/WriteCondHandleKey.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" + +#include <map> + +class LArOnlineID; + +class LArFEBConfigCondAlg: public AthReentrantAlgorithm { + + public: + LArFEBConfigCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~LArFEBConfigCondAlg(); + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + + private: + + const LArOnlineID* m_onlineID; + SG::ReadCondHandleKeyArray<CondAttrListCollection> m_listOfFolders; + SG::WriteCondHandleKey<LArFebConfig> m_configKey{this, "keyOutput", "LArFebConfig", "Output key for LArFebConfig"}; +}; + +#endif diff --git a/LArCalorimeter/LArRecUtils/src/LArFEBConfigReader.cxx b/LArCalorimeter/LArRecUtils/src/LArFEBConfigReader.cxx deleted file mode 100644 index 1baed3e5bf3cdd6220acdff5e82f563db5c6cf69..0000000000000000000000000000000000000000 --- a/LArCalorimeter/LArRecUtils/src/LArFEBConfigReader.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArFEBConfigReader.h" -#include "LArIdentifier/LArOnlineID.h" - -LArFEBConfigReader::LArFEBConfigReader(const std::string& type, const std::string& name, const IInterface* parent) : - AthAlgTool(type,name,parent),m_onlineID(NULL) { - - declareInterface<ILArFEBConfigReader>(this); - declareProperty("ListOfFolders",m_listOfFolders); - m_lastIt=m_attrPerFeb.end(); -} - - -LArFEBConfigReader::~LArFEBConfigReader() {} - -StatusCode LArFEBConfigReader::initialize() { - - if (detStore()->retrieve(m_onlineID,"LArOnlineID").isFailure()) { - msg(MSG::ERROR) << "Failed to retrieve LArOnlineID" << endmsg; - return StatusCode::FAILURE; - } - - if (m_listOfFolders.size()==0) { - msg(MSG::WARNING) << "List of folders is emtpy, do nothing" << endmsg; - return StatusCode::SUCCESS; - } - - const size_t nFolders=m_listOfFolders.size(); - m_handles.resize(nFolders); - - for (size_t i=0;i<nFolders;++i) { - const std::string& fn=m_listOfFolders[i]; - const DataHandle<CondAttrListCollection>& chdl=m_handles[i]; - ATH_MSG_DEBUG("Registering callback for folder " << fn); - StatusCode sc=detStore()->regFcn(&ILArFEBConfigReader::loadData,dynamic_cast<ILArFEBConfigReader*>(this), - chdl,fn); - - if (sc.isFailure()) { - msg(MSG::ERROR) << "Failed to register callback for DB folder " << fn << endmsg; - return StatusCode::FAILURE; - } - }//end loop over folders - - msg(MSG::DEBUG) << "Successfully initialized LArFEBConfigReader" << endmsg; - return StatusCode::SUCCESS; -} - - - -StatusCode LArFEBConfigReader::finalize() { - return StatusCode::SUCCESS; -} - - -StatusCode LArFEBConfigReader::loadData(IOVSVC_CALLBACK_ARGS) { - msg(MSG::INFO) << "In IOV callback method..." << endmsg; - m_attrPerFeb.clear(); - unsigned nFebs=0; - const size_t nFolders=m_listOfFolders.size(); - for (size_t i=0;i<nFolders;++i) { - ATH_MSG_DEBUG("Working on folder " << m_listOfFolders[i]); - const DataHandle<CondAttrListCollection> dh; - if (detStore()->retrieve(dh,m_listOfFolders[i]).isFailure()) { - msg(MSG::ERROR) << "Failed to retrieve DataHandle for folder " << m_listOfFolders[i] << endmsg; - return StatusCode::FAILURE; - } - CondAttrListCollection::const_iterator chanit=dh->begin(); - CondAttrListCollection::const_iterator chanit_e=dh->end(); - for (;chanit!=chanit_e;++chanit) { - if (chanit->first==0) { - ATH_MSG_DEBUG("Invalid channel number 0, ignoring..."); - continue; - } - const HWIdentifier fid(chanit->first); //COOL channel number == FEB identifier - //const coral::AttributeList& attr = chanit->second; - ATH_MSG_DEBUG("Working on FEB 0x" << std::hex << fid.get_compact() << std::dec << " " << m_onlineID->channel_name(fid)); - ++nFebs; - m_attrPerFeb[fid]=&(chanit->second); - }//End loop over COOL channels - }//End loop over folders - m_lastIt=m_attrPerFeb.end(); - msg(MSG::INFO) << "Read gain thresholds for " << nFebs << " Febs from " << m_listOfFolders.size() << " database folders." << endmsg; - return StatusCode::SUCCESS; -} - - -short LArFEBConfigReader::getThreshold(const char* MedLow, const HWIdentifier& chid) const { - - if (m_attrPerFeb.size()==0) { - msg(MSG::WARNING) << "FEB treshold cache is empty. Callback not fired?" << endmsg; - return ERRORCODE; - } - - const HWIdentifier fid=m_onlineID->feb_Id(chid); - const int channel=m_onlineID->channel(chid); - if (m_lastIt==m_attrPerFeb.end() || m_lastIt->first!=fid) - m_lastIt=m_attrPerFeb.find(fid); - - if (m_lastIt==m_attrPerFeb.end()) - return ERRORCODE; - else { - char channame[16]; - snprintf(channame,15,"%s%i",MedLow,channel+1); - channame[15]='\n';// Just to be sure... - return (short)(*(m_lastIt->second))[channame].data<int32_t>(); //Will throw and exception if channel does not exist - } -} diff --git a/LArCalorimeter/LArRecUtils/src/LArFEBConfigReader.h b/LArCalorimeter/LArRecUtils/src/LArFEBConfigReader.h deleted file mode 100644 index 6ba3a618e3f01b7f139089970b41555e4475c0ff..0000000000000000000000000000000000000000 --- a/LArCalorimeter/LArRecUtils/src/LArFEBConfigReader.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//Dear emacs, this is -*-c++-*- -#ifndef LARRECUTILS_LARFEBCONFIGREADERTOOL -#define LARRECUTILS_LARFEBCONFIGREADERTOOL - -#include "AthenaBaseComps/AthAlgTool.h" -#include "LArElecCalib/ILArFEBConfigReader.h" -#include "AthenaKernel/IOVSvcDefs.h" -#include "CoralBase/AttributeList.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" - -#include "LArRawConditions/LArConditionsContainer.h" - -#include <map> - -class LArOnlineID; - -class LArFEBConfigReader: public AthAlgTool, - virtual public ILArFEBConfigReader { - - public: - LArFEBConfigReader(const std::string& type, const std::string& name, const IInterface* parent); - virtual ~LArFEBConfigReader(); - - StatusCode initialize(); - StatusCode finalize(); - - //Accessor methods from ILArFEBConfigReader - virtual short lowerGainThreshold(const HWIdentifier& id) const; - virtual short upperGainThreshold(const HWIdentifier& id) const; - - //IOV Callback function - virtual StatusCode loadData(IOVSVC_CALLBACK_ARGS); - - static const InterfaceID& interfaceID() { return ILArFEBConfigReader::interfaceID();} - - private: - - const LArOnlineID* m_onlineID; - std::vector<std::string> m_listOfFolders; - - std::map<HWIdentifier,const coral::AttributeList*> m_attrPerFeb; - mutable std::map<HWIdentifier,const coral::AttributeList*>::const_iterator m_lastIt; - - std::vector<DataHandle<CondAttrListCollection> > m_handles; - - short getThreshold(const char* MedLow, const HWIdentifier& chid) const; -}; - - -inline short LArFEBConfigReader::lowerGainThreshold(const HWIdentifier& chid) const { - return getThreshold("lower",chid); -} - - -inline short LArFEBConfigReader::upperGainThreshold(const HWIdentifier& chid) const { - return getThreshold("upper",chid); -} - -#endif diff --git a/LArCalorimeter/LArRecUtils/src/components/LArRecUtils_entries.cxx b/LArCalorimeter/LArRecUtils/src/components/LArRecUtils_entries.cxx index b90e8dca174432c6355dc03e1bba50b985cc1883..36d0d4769eeaf1e64350091aee8f77bd269d4e75 100644 --- a/LArCalorimeter/LArRecUtils/src/components/LArRecUtils_entries.cxx +++ b/LArCalorimeter/LArRecUtils/src/components/LArRecUtils_entries.cxx @@ -11,7 +11,6 @@ #include "LArRecUtils/LArShapePeakRecoTool.h" #include "../LArTowerBuilderTool.h" #include "../LArFCalTowerBuilderTool.h" -#include "../LArFEBConfigReader.h" #include "../LArFlatConditionSvc.h" #include "../LArFCalTowerBuilderToolTestAlg.h" #include "../LArFlatConditionsAlg.h" @@ -29,6 +28,7 @@ #include "../LArHVCondAlg.h" #include "../LArHVScaleCorrCondAlg.h" #include "../LArAutoCorrNoiseCondAlg.h" +#include "../LArFEBConfigCondAlg.h" DECLARE_COMPONENT( LArADC2MeVTool ) @@ -44,7 +44,6 @@ DECLARE_COMPONENT( LArParabolaPeakRecoTool ) DECLARE_COMPONENT( LArShapePeakRecoTool ) DECLARE_COMPONENT( LArTowerBuilderTool ) DECLARE_COMPONENT( LArFCalTowerBuilderTool ) -DECLARE_COMPONENT( LArFEBConfigReader ) DECLARE_COMPONENT( LArFlatConditionSvc ) DECLARE_COMPONENT( LArFCalTowerBuilderToolTestAlg ) DECLARE_COMPONENT( LArCondAlgAutoCorrSC ) @@ -90,3 +89,4 @@ DECLARE_COMPONENT( LArOFCCondAlg ) DECLARE_COMPONENT( LArHVCondAlg ) DECLARE_COMPONENT( LArHVScaleCorrCondAlg ) DECLARE_COMPONENT( LArAutoCorrNoiseCondAlg ) +DECLARE_COMPONENT( LArFEBConfigCondAlg )