Skip to content
Snippets Groups Projects
Commit f0ef3e7c authored by Walter Lampl's avatar Walter Lampl Committed by Vakhtang Tsulaia
Browse files

LArCellRec: Migrate to CondReadHandles

Former-commit-id: 1b83f6aa
parent baaa6fcb
No related branches found
No related tags found
No related merge requests found
......@@ -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]
#
......
......@@ -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
......
/*
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) {
......
/*
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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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
*/
......
/*
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();
......
/*
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;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment