diff --git a/Calorimeter/CaloRec/python/CaloCellGetter.py b/Calorimeter/CaloRec/python/CaloCellGetter.py index 68c1f66bb87f8b016e85f022ef20726b2c9da8f7..09239d9cf71203d109e4e04999e858f24d3c4962 100644 --- a/Calorimeter/CaloRec/python/CaloCellGetter.py +++ b/Calorimeter/CaloRec/python/CaloCellGetter.py @@ -404,9 +404,6 @@ class CaloCellGetter (Configured) : mlog.error("could not access bad channel tool Quit") print traceback.format_exc() return False - ToolSvc += theLArBadChannelTool - - theLArBadFebMaskingTool.badChannelTool = theLArBadChannelTool theCaloCellMaker.CaloCellMakerToolNames += [theLArBadFebMaskingTool] # diff --git a/LArCalorimeter/LArCellRec/CMakeLists.txt b/LArCalorimeter/LArCellRec/CMakeLists.txt index 399532e7cb1d5b3b4a69d3513effa78fd7166b5a..f36d59d4e2ddf4c9d59774dcade89617b935b0e0 100644 --- a/LArCalorimeter/LArCellRec/CMakeLists.txt +++ b/LArCalorimeter/LArCellRec/CMakeLists.txt @@ -55,10 +55,10 @@ atlas_install_python_modules( python/*.py ) atlas_install_joboptions( share/*.py ) -atlas_add_test( LArBadFebMaskingTool_test - SCRIPT test/LArBadFebMaskingTool_test.sh - PROPERTIES TIMEOUT 600 - EXTRA_PATTERNS "LArDetectorToolNV|is still valid|no data retrieved|Database being retired|Reading file|Unable to locate catalog|Resolved path|DigitizationFlags|^Domain|created CondCont|no dictionary for class|^ +[+]|Reading LArPedestalMC|IOV callback|^DetectorStore|Cache alignment" ) +#atlas_add_test( LArBadFebMaskingTool_test +# SCRIPT test/LArBadFebMaskingTool_test.sh +# PROPERTIES TIMEOUT 600 +# EXTRA_PATTERNS "LArDetectorToolNV|is still valid|no data retrieved|Database being retired|Reading file|Unable to locate catalog|Resolved path|DigitizationFlags|^Domain|created CondCont|no dictionary for class|^ +[+]|Reading LArPedestalMC|IOV callback|^DetectorStore|Cache alignment" ) #atlas_add_test( LArCellDeadOTXCorr_test diff --git a/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx b/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx index 2563520ad9c68e1bad952619b3465316bd824de2..58edf650cd1e848b381b555328615d8c843672bd 100644 --- a/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx +++ b/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /******************************************************************** @@ -23,9 +23,7 @@ PURPOSE: #include "CaloIdentifier/CaloCell_ID.h" #include "LArRawEvent/LArFebErrorSummary.h" #include "LArIdentifier/LArOnlineID.h" -#include "LArRecConditions/ILArBadChanTool.h" #include "LArRecConditions/LArBadFeb.h" -#include "LArCabling/LArCablingService.h" #include "LArRecEvent/LArEventBitInfo.h" #include "xAODEventInfo/EventInfo.h" #include "GaudiKernel/ThreadLocalContext.h" @@ -41,8 +39,6 @@ LArBadFebMaskingTool::LArBadFebMaskingTool( const std::string& name, const IInterface* parent) :base_class(type, name, parent), - m_badChannelTool(""), - m_cablingService("LArCablingService"), m_maskParity(true),m_maskSampleHeader(true),m_maskEVTID(true),m_maskScacStatus(true), m_maskScaOutOfRange(true),m_maskGainMismatch(true),m_maskTypeMismatch(true),m_maskNumOfSamples(true), m_maskEmptyDataBlock(true),m_maskDspBlockSize(true),m_maskCheckSum(true),m_maskMissingHeader(true), @@ -54,7 +50,6 @@ LArBadFebMaskingTool::LArBadFebMaskingTool( m_evt(0), m_mask(0) { - declareProperty("badChannelTool",m_badChannelTool); declareProperty("maskParity",m_maskParity); declareProperty("maskSampleHeader",m_maskSampleHeader); declareProperty("maskEVTID",m_maskEVTID); @@ -109,14 +104,10 @@ StatusCode LArBadFebMaskingTool::initialize() ATH_CHECK( detStore()->retrieve( caloIdMgr ) ); m_calo_id = caloIdMgr->getCaloCell_ID(); - // translate offline ID into online ID - ATH_CHECK( m_cablingService.retrieve() ); + ATH_CHECK( m_badFebKey.initialize()); + ATH_CHECK( m_cablingKey.initialize()); ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") ); - if (!m_badChannelTool.empty()) { - ATH_CHECK( m_badChannelTool.retrieve() ); - } - return StatusCode::SUCCESS; } @@ -166,6 +157,14 @@ StatusCode LArBadFebMaskingTool::process(CaloCellContainer * theCont ) flagBadEvent = true; } + + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey,ctx}; + const LArOnOffIdMapping* cabling=*cablingHdl; + + SG::ReadCondHandle<LArBadFebCont> badFebHdl{m_badFebKey,ctx}; + const LArBadFebCont* badFebs=*badFebHdl; + + // loop over all Febs std::vector<HWIdentifier>::const_iterator feb = m_onlineID->feb_begin(); @@ -190,12 +189,12 @@ StatusCode LArBadFebMaskingTool::process(CaloCellContainer * theCont ) ATH_MSG_DEBUG (" ierror,toMask " << ierror << " " << toMask1 << " "); } - if (!m_badChannelTool.empty()) { - LArBadFeb febstatus = m_badChannelTool->febStatus(febId); - inError = febstatus.inError(); - isDead = ( febstatus.deadReadout() | febstatus.deadAll() ); - ATH_MSG_DEBUG (" inError, isDead " << inError << " " << isDead); - } + + LArBadFeb febstatus = badFebs->status(febId); + inError = febstatus.inError(); + isDead = ( febstatus.deadReadout() | febstatus.deadAll() ); + ATH_MSG_DEBUG (" inError, isDead " << inError << " " << isDead); + if (toMask1 && !inError && !isDead) nbOfFebsInError = nbOfFebsInError + 1; @@ -203,8 +202,8 @@ StatusCode LArBadFebMaskingTool::process(CaloCellContainer * theCont ) m_mask++; for (int ch=0; ch<128; ++ch) { HWIdentifier hwid = m_onlineID->channel_Id(febId, ch); - if (m_cablingService->isOnlineConnected(hwid)) { - Identifier id = m_cablingService->cnvToIdentifier( hwid); + if (cabling->isOnlineConnected(hwid)) { + Identifier id = cabling->cnvToIdentifier( hwid); IdentifierHash theCellHashID = m_calo_id->calo_cell_hash(id); int index = theCont->findIndex(theCellHashID); if (index<0) { diff --git a/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.h b/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.h index 94339be06ff1601e29f02dd4c9e0cf5ee37293bc..d797bf40802f8fdffff521e873866af0ef18fd5b 100755 --- a/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.h +++ b/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef LARCELLREC_LArBadFebMaskingTool_H @@ -19,17 +19,15 @@ #include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" #include "CaloInterface/ICaloCellMakerTool.h" -#include "AthenaKernel/IOVSvcDefs.h" #include "StoreGate/ReadHandleKey.h" -#include "LArRecConditions/ILArBadChanTool.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArRecConditions/LArBadChannelCont.h" +#include "LArCabling/LArOnOffIdMapping.h" #include "xAODEventInfo/EventInfo.h" #include <atomic> -class LArCablingService; -class StoreGateSvc; class CaloCell_ID; class LArOnlineID; class LArFebErrorSummary; @@ -58,12 +56,13 @@ public: private: - /** handle to bad channel tool (to get problematic Feb into) + /** handle to get bad febs */ - ToolHandle<ILArBadChanTool> m_badChannelTool; - /** handle to LAr cabling service + SG::ReadCondHandleKey<LArBadFebCont> m_badFebKey{this,"BadFebKey","LArBadFeb","Key of Bad-Feb object"}; + /** handle to LAr cabling */ - ToolHandle<LArCablingService> m_cablingService; + SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + /** flags to select which errors to mask */ bool m_maskParity; diff --git a/LArCalorimeter/LArCellRec/src/LArCellDeadOTXCorr.h b/LArCalorimeter/LArCellRec/src/LArCellDeadOTXCorr.h index 7bf087626fd5add91e85070a065483c45605e2fb..ce74fb5c8aeeb521b0fa8e1914b3f27ab45885cc 100644 --- a/LArCalorimeter/LArCellRec/src/LArCellDeadOTXCorr.h +++ b/LArCalorimeter/LArCellRec/src/LArCellDeadOTXCorr.h @@ -31,12 +31,9 @@ // Headerfile #include "AthenaBaseComps/AthAlgTool.h" -//#include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/Property.h" -//#include "StoreGate/StoreGateSvc.h" #include "StoreGate/ReadHandleKey.h" #include "CaloInterface/ICaloCellMakerTool.h" -//#include "AthenaKernel/IOVSvcDefs.h" #include "Identifier/Identifier.h" #include "CaloConditions/Array.h" #include "CaloRec/ToolWithConstantsMixin.h" @@ -53,12 +50,10 @@ #include <map> #include <atomic> -class LArCablingService; class StoreGateSvc; class CaloCell_ID; class LArOnlineID; class CaloLVL1_ID; -class ILArBadChanTool; class CaloTriggerTowerService; // class L1CaloTTIdTools; class CaloIdManager; @@ -99,13 +94,6 @@ class LArCellDeadOTXCorr private: - - - // get a handle to the tool helper - - //ToolHandle<ILArBadChanTool> m_badChannelTool; - //ToolHandle<LArCablingService> m_cablingService; - SG::ReadCondHandleKey<LArBadFebCont> m_badFebKey{this,"BadFebKey","LArBadFeb","Key of Bad-Feb object"}; SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this, "CablingKey", "LArOnOffIdMap","Cabling key"}; //std::string m_TTLocation; diff --git a/LArCalorimeter/LArCellRec/src/LArCellGainPathology.cxx b/LArCalorimeter/LArCellRec/src/LArCellGainPathology.cxx index 9eb09605cf524d9761180947afac81d2dce4a327..b05cf4dd6f7daf2f27008ab76f2c0cc1b3cccd84 100644 --- a/LArCalorimeter/LArCellRec/src/LArCellGainPathology.cxx +++ b/LArCalorimeter/LArCellRec/src/LArCellGainPathology.cxx @@ -24,7 +24,6 @@ PURPOSE: #include "CaloIdentifier/CaloCell_ID.h" #include "LArRawEvent/LArFebErrorSummary.h" #include "LArIdentifier/LArOnlineID.h" -#include "LArCabling/LArCablingService.h" ///////////////////////////////////////////////////////////////////// @@ -36,7 +35,6 @@ LArCellGainPathology::LArCellGainPathology( const std::string& name, const IInterface* parent) : AthAlgTool(type, name, parent), - m_cablingService("LArCablingService"), m_calo_id(nullptr), m_onlineID(nullptr) { @@ -57,7 +55,7 @@ StatusCode LArCellGainPathology::initialize() m_calo_id = caloIdMgr->getCaloCell_ID(); // translate offline ID into online ID - ATH_CHECK( m_cablingService.retrieve() ); + ATH_CHECK( m_cablingKey.initialize()); ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") ); return StatusCode::SUCCESS; @@ -72,6 +70,9 @@ StatusCode LArCellGainPathology::process(CaloCellContainer * theCont ) { ATH_MSG_DEBUG (" in LArCellGainPathology::process "); + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey}; + const LArOnOffIdMapping* cabling=*cablingHdl; + // loop over all Febs std::vector<HWIdentifier>::const_iterator feb = m_onlineID->feb_begin(); @@ -79,32 +80,29 @@ StatusCode LArCellGainPathology::process(CaloCellContainer * theCont ) for ( ; feb != feb_end; feb++) { - - // for debug - HWIdentifier febId = (*feb); - unsigned int ifeb = febId.get_identifier32().get_compact(); - ATH_MSG_DEBUG (" process Feb: " << ifeb << " "); + ATH_MSG_DEBUG (" process Feb: " << + feb->get_identifier32().get_compact()); // get information for channel 0-63 64-127 for (int i=0;i<2;i++) { int cha1 = i*64; int cha2 = i*64+63; - HWIdentifier hwid1 = m_onlineID->channel_Id(febId,cha1); - HWIdentifier hwid2 = m_onlineID->channel_Id(febId,cha2); - this->ApplyPathology(theCont,hwid1,hwid2); + HWIdentifier hwid1 = m_onlineID->channel_Id(*feb,cha1); + HWIdentifier hwid2 = m_onlineID->channel_Id(*feb,cha2); + this->ApplyPathology(theCont,hwid1,hwid2,cabling); } } return StatusCode::SUCCESS; } -void LArCellGainPathology::ApplyPathology(CaloCellContainer* theCont, HWIdentifier id1, HWIdentifier id2) +void LArCellGainPathology::ApplyPathology(CaloCellContainer* theCont, HWIdentifier id1, HWIdentifier id2,const LArOnOffIdMapping* cabling) { - CaloCell* cell1 = this->GetCell(theCont, id1); - CaloCell* cell2 = this->GetCell(theCont, id2); + CaloCell* cell1 = this->GetCell(theCont, id1,cabling); + CaloCell* cell2 = this->GetCell(theCont, id2,cabling); if (!cell1 || !cell2) return; @@ -135,11 +133,11 @@ void LArCellGainPathology::ApplyPathology(CaloCellContainer* theCont, HWIdentifi } -CaloCell* LArCellGainPathology::GetCell(CaloCellContainer* theCont, HWIdentifier id) +CaloCell* LArCellGainPathology::GetCell(CaloCellContainer* theCont, HWIdentifier id,const LArOnOffIdMapping* cabling) { CaloCell* aCell =0; - if (m_cablingService->isOnlineConnected(id)) { - Identifier id_off = m_cablingService->cnvToIdentifier(id); + if (cabling->isOnlineConnected(id)) { + Identifier id_off = cabling->cnvToIdentifier(id); IdentifierHash theCellHashID = m_calo_id->calo_cell_hash(id_off); int index = theCont->findIndex(theCellHashID); if (index>=0) { diff --git a/LArCalorimeter/LArCellRec/src/LArCellGainPathology.h b/LArCalorimeter/LArCellRec/src/LArCellGainPathology.h index d5df7db06032a10e73f7b29e10fb8fce9e2d9e47..e296b8b5059cebf27556819895be7934d57a2533 100644 --- a/LArCalorimeter/LArCellRec/src/LArCellGainPathology.h +++ b/LArCalorimeter/LArCellRec/src/LArCellGainPathology.h @@ -16,15 +16,13 @@ #include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" #include "CaloInterface/ICaloCellMakerTool.h" -#include "AthenaKernel/IOVSvcDefs.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArCabling/LArOnOffIdMapping.h" + -class LArCablingService; -class StoreGateSvc; class CaloCell_ID; class LArOnlineID; -class ILArBadChanTool; class HWIdentifier; class CaloCell; @@ -52,15 +50,17 @@ public: private: /** method to apply pathology between a couple of cells */ - void ApplyPathology(CaloCellContainer* theCont, HWIdentifier id1, HWIdentifier id2); + void ApplyPathology(CaloCellContainer* theCont, HWIdentifier id1, HWIdentifier id, + const LArOnOffIdMapping* cabling); /** method to find cell from hardware id */ - CaloCell* GetCell(CaloCellContainer* theCont, HWIdentifier id); + CaloCell* GetCell(CaloCellContainer* theCont, HWIdentifier id, + const LArOnOffIdMapping* cabling); /** handle to LAr cabling service */ - ToolHandle<LArCablingService> m_cablingService; + SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; /** pointers to storegateSvc and identifier helpers */ diff --git a/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.cxx b/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.cxx index 5f8697e1b53c5a7637d07305000e339b97208caf..e5212b082ea888f675bdce41a45a529d729ec33e 100644 --- a/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.cxx +++ b/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /******************************************************************** @@ -10,9 +10,7 @@ PACKAGE: offline/Calorimeter/CaloRec ********************************************************************/ #include "LArCellMaskingTool.h" -#include "StoreGate/StoreGateSvc.h" #include "CaloEvent/CaloCellContainer.h" -#include "LArCabling/LArCablingService.h" ///////////////////////////////////////////////////////////////////// @@ -25,8 +23,7 @@ LArCellMaskingTool::LArCellMaskingTool( const IInterface* parent) : AthAlgTool(type, name, parent), m_onlineID(nullptr), - m_offlineID(nullptr), - m_larCablingSvc(nullptr) + m_offlineID(nullptr) { declareInterface<ICaloCellMakerTool>(this); //List of strings to determine detector parts to be masked. @@ -48,11 +45,8 @@ StatusCode LArCellMaskingTool::initialize() { ATH_CHECK( detStore()->retrieve(m_offlineID) ); ATH_CHECK( detStore()->retrieve(m_onlineID) ); - - IToolSvc* p_toolSvc = 0; - ATH_CHECK( service("ToolSvc", p_toolSvc) ); - ATH_CHECK( p_toolSvc->retrieveTool("LArCablingService",m_larCablingSvc) ); - + ATH_CHECK( m_cablingKey.initialize()); + // Get hash ranges m_offlinehashMax=m_offlineID->calo_cell_hash_max(); ATH_MSG_DEBUG ("CaloCell Hash Max: " << m_offlinehashMax); @@ -63,16 +57,14 @@ StatusCode LArCellMaskingTool::initialize() //Fill the bit map m_includedCellsMap.set(); // By default include all cells - StatusCode sc=fillIncludedCellsMap(); - ATH_MSG_INFO (" Will exclude " << m_includedCellsMap.size() - m_includedCellsMap.count() << " cells from CaloCellContainer"); - return sc; + return StatusCode::SUCCESS; } -StatusCode LArCellMaskingTool::fillIncludedCellsMap() { +StatusCode LArCellMaskingTool::fillIncludedCellsMap(const LArOnOffIdMapping* cabling) { std::vector<std::string>::const_iterator it=m_rejLArChannels.begin(); std::vector<std::string>::const_iterator it_e= m_rejLArChannels.end(); @@ -130,8 +122,8 @@ StatusCode LArCellMaskingTool::fillIncludedCellsMap() { nChannels++; try { chanId=m_onlineID->channel_Id(bec,pn,FT,slot,channel); - if (m_larCablingSvc->isOnlineConnected(chanId)) { - const Identifier cellId=m_larCablingSvc->cnvToIdentifier(chanId); + if (cabling->isOnlineConnected(chanId)) { + const Identifier cellId=cabling->cnvToIdentifier(chanId); const IdentifierHash cellhash=m_offlineID->calo_cell_hash(cellId); m_includedCellsMap.reset(cellhash); //std::cout << "Block channel: bec="<< bec << " pn=" << pn @@ -163,6 +155,15 @@ StatusCode LArCellMaskingTool::fillIncludedCellsMap() { StatusCode LArCellMaskingTool::process(CaloCellContainer * theCont ) { + if (! m_mapInitialized) { + //To make this (practically never used) method re-entrant, + //protect the following with a mutex + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey}; + const LArOnOffIdMapping* cabling=*cablingHdl; + ATH_CHECK(fillIncludedCellsMap(cabling)); + m_mapInitialized=true; + } + //Build bitmap to keep track which cells have been added to reducedCellContainer; unsigned cnt=0; CaloCellContainer::iterator it=theCont->begin(); diff --git a/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.h b/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.h index 3954526073be03f8db8ada1feb03c9b50f2c60b8..baa90be624d6e309c3d052d1453160eac2000210 100644 --- a/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.h +++ b/LArCalorimeter/LArCellRec/src/LArCellMaskingTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef LARCELLREC_LARCELLMASKINGTOOL_H @@ -11,11 +11,10 @@ #include "LArIdentifier/LArOnlineID.h" #include "CaloIdentifier/CaloCell_ID.h" #include "CaloInterface/ICaloCellMakerTool.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArCabling/LArOnOffIdMapping.h" #include <bitset> -#include "LArCabling/LArCablingService.h" -class StoreGateSvc; -class MsgStream; class LArCellMaskingTool: public AthAlgTool, virtual public ICaloCellMakerTool @@ -37,15 +36,16 @@ public: virtual StatusCode finalize(); private: - StatusCode fillIncludedCellsMap(); + StatusCode fillIncludedCellsMap(const LArOnOffIdMapping* cabling); const LArOnlineID* m_onlineID; const CaloCell_ID* m_offlineID; - LArCablingService* m_larCablingSvc; + SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + std::vector<std::string> m_rejLArChannels; std::bitset<200000> m_includedCellsMap; //Slightly too big but who cares.... - + bool m_mapInitialized=false; IdentifierHash m_offlinehashMax; IdentifierHash m_onlinehashMax; };