Skip to content
Snippets Groups Projects
Commit b9699b2a authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'masking.LArCellRec-20190118' into 'master'

LArCellRec: Thread-safety fixes for LArCellMakingTool.

See merge request atlas/athena!20429
parents d109cbc9 9e421ed4
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/********************************************************************
......@@ -25,6 +25,8 @@ LArCellMaskingTool::LArCellMaskingTool(
m_onlineID(nullptr),
m_offlineID(nullptr)
{
m_mapInitialized = false;
declareInterface<ICaloCellMakerTool>(this);
//List of strings to determine detector parts to be masked.
//Syntax: barrel_endcap pos_neg Feedthrough slot channel (integers separated by white space)
......@@ -64,7 +66,8 @@ StatusCode LArCellMaskingTool::initialize()
}
StatusCode LArCellMaskingTool::fillIncludedCellsMap(const LArOnOffIdMapping* cabling) {
StatusCode LArCellMaskingTool::fillIncludedCellsMap(const LArOnOffIdMapping* cabling) const
{
std::vector<std::string>::const_iterator it=m_rejLArChannels.begin();
std::vector<std::string>::const_iterator it_e= m_rejLArChannels.end();
......@@ -155,13 +158,17 @@ StatusCode LArCellMaskingTool::fillIncludedCellsMap(const LArOnOffIdMapping* cab
StatusCode LArCellMaskingTool::process(CaloCellContainer * theCont )
{
const EventContext& ctx = Gaudi::Hive::currentContext();
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;
// FIXME: Can we do this in start()?
std::lock_guard<std::mutex> lock (m_mutex);
if (!m_mapInitialized) {
SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl (m_cablingKey, ctx);
const LArOnOffIdMapping* cabling=*cablingHdl;
ATH_CHECK(fillIncludedCellsMap(cabling));
m_mapInitialized=true;
}
}
//Build bitmap to keep track which cells have been added to reducedCellContainer;
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef LARCELLREC_LARCELLMASKINGTOOL_H
......@@ -13,7 +13,9 @@
#include "CaloInterface/ICaloCellMakerTool.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "LArCabling/LArOnOffIdMapping.h"
#include "CxxUtils/checker_macros.h"
#include <bitset>
#include <mutex>
class LArCellMaskingTool: public AthAlgTool,
......@@ -36,18 +38,19 @@ public:
virtual StatusCode finalize();
private:
StatusCode fillIncludedCellsMap(const LArOnOffIdMapping* cabling);
StatusCode fillIncludedCellsMap(const LArOnOffIdMapping* cabling) const;
const LArOnlineID* m_onlineID;
const CaloCell_ID* m_offlineID;
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....
mutable std::bitset<200000> m_includedCellsMap ATLAS_THREAD_SAFE; //Slightly too big but who cares....
bool m_mapInitialized=false;
mutable std::atomic<bool> m_mapInitialized;
IdentifierHash m_offlinehashMax;
IdentifierHash m_onlinehashMax;
mutable std::mutex m_mutex;
};
#endif
......
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