Commit 6fb80d82 authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

MissingCellListTool migrate to retrieving the CaloDDM from the Cond Store....

MissingCellListTool migrate to retrieving the CaloDDM from the Cond Store. Additionally, migrate all imput/output to handles
parent f9925433
......@@ -31,23 +31,24 @@
//#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
//include "CaloEvent/CaloCell.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
//
#include "CaloIdentifier/CaloCell_ID.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "TileConditions/TileCablingSvc.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "LArRecConditions/LArBadChannelCont.h"
//
#include "JetUtils/TiledEtaPhiMap.h"
//
#include "xAODCore/CLASS_DEF.h"
#include "AsgTools/AsgTool.h"
#include "JetInterface/IJetExecuteTool.h"
// Forward declaration
class CaloCell;
class CaloDetDescrManager;
class ITileBadChanTool ;
namespace jet {
......@@ -156,7 +157,6 @@ class MissingCellListTool
private:
const CaloDetDescrManager * m_caloDDM;
typedef std::vector<unsigned int> cellidvec_t;
cellidvec_t m_userRemovedCells;
......@@ -172,10 +172,29 @@ class MissingCellListTool
ServiceHandle<TileCablingSvc> m_tileCabling;
ToolHandle<ITileBadChanTool> m_tileTool;
SG::ReadCondHandleKey<LArBadChannelCont> m_BCKey{this, "BadChanKey", "LArBadChannel", "SG bad channels key"};
SG::ReadCondHandleKey<LArBadChannelCont> m_BCKey{ this,
"BadChanKey",
"LArBadChannel",
"SG bad channels key" };
SG::ReadCondHandleKey<CaloDetDescrManager> m_caloDetDescrMgrKey{
this,
"CaloDetDescrManager",
"CaloDetDescrManager",
"SG Key for CaloDetDescrManager in the Condition Store"
};
std::string m_missingCellMapName;
};
SG::ReadHandleKey<CaloCellContainer> m_cells_name{ this,
"cells_name",
"AllCalo",
"" };
SG::WriteHandleKey<jet::CaloCellFastMap> m_badCellMap_key{
this,
"MissingCellMapName",
"MissingCaloCellsMap",
"SG key for missing cell map"
};
};
// I/O operators
//////////////////////
......
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
// MissingCellListTool.cxx
......@@ -11,17 +11,14 @@
// JetMomentTools includes
#include "JetRecCalo/MissingCellListTool.h"
// STL includes
// FrameWork includes
//#include "GaudiKernel/IToolSvc.h"
#include "AthenaKernel/errorcheck.h"
// StoreGate
#include "CaloEvent/CaloCellContainer.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "StoreGate/ReadCondHandle.h"
#include "StoreGate/WriteHandle.h"
#include "StoreGate/WriteHandle.h"
//
#include "TileConditions/ITileBadChanTool.h"
#include "TileConditions/TileBadChanTool.h"
......@@ -36,25 +33,20 @@
MissingCellListTool::MissingCellListTool(const std::string& name) :
asg::AsgTool ( name ),
m_tileCabling("TileCablingSvc",name),
m_tileTool("TileBadChanTool")
m_tileTool("TileBadChanTool",this)
{
//declareInterface<IMissingCellListTool>( this );
declareProperty("AddCellList", m_userAddedCells);
declareProperty("RemoveCellList", m_userRemovedCells );
declareProperty("AddBadCells", m_addBadCells=true );
declareProperty("DeltaRmax", m_rmax=1.0);
// ported from JetBadChanCorrTool
declareProperty("AddCellFromTool", m_addCellFromTool = false);
declareProperty("LArMaskBit", m_larMaskBit = ( 1<< 0 | 1<< 2 | 1<<16 | 1<<8 | 1<<11 | 1<<14 | 1<<19 )); //608517, deadReadout | deadPhys | missingFEB | highNoiseHG | highNoiseMG | highNoiseLG | sporadicBurstNoise
//608517, deadReadout | deadPhys | missingFEB | highNoiseHG | highNoiseMG | highNoiseLG | spor adicBurstNoise
declareProperty("LArMaskBit", m_larMaskBit = ( 1<< 0 | 1<< 2 | 1<<16 | 1<<8 | 1<<11 | 1<<14 | 1<<19 ));
declareProperty("TileMaskBit", m_tileMaskBit = ( 1<< 0 )); //1, dead
declareProperty("MissingCellMapName",m_missingCellMapName = "MissingCaloCellsMap");
}
// Destructor
......@@ -67,25 +59,17 @@ MissingCellListTool::~MissingCellListTool()
StatusCode MissingCellListTool::initialize()
{
ATH_MSG_INFO ("Initializing " << name() << "...");
ATH_MSG_DEBUG ("Initializing " << name() << "...");
CHECK( m_tileCabling.retrieve() );
CHECK(detStore()->retrieve(m_caloDDM) );
//m_badandmissingCellsGeomMap.init(m_rmax);
// Register listener for BeginEvent
//incidentSvc->addListener(this, "BeginEvent");
if ( m_addCellFromTool) {
CHECK( m_tileTool.retrieve() );
ATH_CHECK( m_BCKey.initialize() );
//
ATH_CHECK(m_badCellMap_key.initialize());
ATH_CHECK(m_caloDetDescrMgrKey.initialize());
ATH_CHECK(m_cells_name.initialize(m_addBadCells));
ATH_CHECK(m_BCKey.initialize(m_addCellFromTool));
if (m_addCellFromTool) {
ATH_CHECK( m_tileTool.retrieve() );
} else {
m_tileTool.disable();
}
return StatusCode::SUCCESS;
}
......@@ -96,42 +80,18 @@ StatusCode MissingCellListTool::finalize()
return StatusCode::SUCCESS;
}
// IMissingCellListTool::const_iterator MissingCellListTool::begin() {
// if(prepareCellList().isFailure()) return m_missingCells.end();
// return m_missingCells.begin();
// }
// IMissingCellListTool::const_iterator MissingCellListTool::end() {
// if(prepareCellList().isFailure()) return m_missingCells.end();
// return m_missingCells.end();
// }
// size_t MissingCellListTool::size() {
// if(prepareCellList().isFailure()) return 0;
// return m_missingCells.size();
// }
int MissingCellListTool::execute() const {
//if(! m_needSetup) return StatusCode::SUCCESS;
// clear cell containers.
//cellset_t missingCells;
jet::CaloCellFastMap * badandmissingCellsGeomMap = new jet::CaloCellFastMap();
auto badandmissingCellsGeomMap = std::make_unique<jet::CaloCellFastMap>();
jet::cellset_t & badandmissingCells = badandmissingCellsGeomMap->cells();
badandmissingCellsGeomMap->init(m_rmax);
// get permanently missing cells.
const std::vector<Identifier> & tiledisconnected = m_tileCabling->disconnectedCells();
badandmissingCells.insert(tiledisconnected.begin(), tiledisconnected.end());
// ATH_MSG( DEBUG ) << " tile disconnected "<< tiledisconnected.size() << " "<< missingCells.size() << endmsg;
// // fill bad and missing cell list. ------------
// badandmissingCells.insert( missingCells.begin(), missingCells.end());
// from user given cells
for(cellidvec_t::const_iterator it=m_userAddedCells.begin(); it != m_userAddedCells.end(); ++it){
badandmissingCells.insert( Identifier(*it) ) ;
......@@ -142,16 +102,17 @@ int MissingCellListTool::execute() const {
}
// ---------------------------
SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle {m_caloDetDescrMgrKey};
const CaloDetDescrManager* caloDDM = *caloDetDescrMgrHandle;
if(m_addBadCells) {
// (In run1 this part possibly added several times the same cell in the geometric map)
const CaloCellContainer * cells;
StatusCode sc = evtStore()->retrieve(cells, "AllCalo");
if ( sc.isFailure() ) {
SG::ReadHandle<CaloCellContainer> cc (m_cells_name);
if ( !cc.isValid() ) {
ATH_MSG_ERROR("Unable to retrieve CaloCellContainer AllCalo from event store.");
return 1;
}
const CaloCellContainer * cells = cc.ptr();
CaloCellContainer::const_iterator it= cells->begin();
CaloCellContainer::const_iterator itE= cells->end();
for(; it!=itE; ++it){
......@@ -164,7 +125,7 @@ int MissingCellListTool::execute() const {
if(m_addCellFromTool){
const CaloCell_ID* calo_id = m_caloDDM->getCaloCell_ID();
const CaloCell_ID* calo_id = caloDDM->getCaloCell_ID();
const TileBadChanTool* tileTool = dynamic_cast<const TileBadChanTool*>(m_tileTool.operator->());
SG::ReadCondHandle<LArBadChannelCont> readHandle{m_BCKey};
const LArBadChannelCont *bcCont {*readHandle};
......@@ -196,37 +157,23 @@ int MissingCellListTool::execute() const {
jet::cellset_t::iterator lit = badandmissingCells.begin();
jet::cellset_t::iterator litE = badandmissingCells.end();
for( ; lit != litE; ++lit){
const CaloDetDescrElement * dde = m_caloDDM->get_element(*lit);
const CaloDetDescrElement * dde = caloDDM->get_element(*lit);
jet::CellPosition p(dde->eta(), dde->phi(), *lit, dde->getSampling());
badandmissingCellsGeomMap->insert( p );
}
// ---------------------------
ATH_MSG( DEBUG ) << " total bad and missing "<< badandmissingCells.size() << " "<< badandmissingCellsGeomMap->size() << endmsg;
ATH_MSG( DEBUG ) << " total bad and missing "<< badandmissingCells.size() << " "<< badandmissingCellsGeomMap->size() << endmsg;
StatusCode sc = evtStore()->record(badandmissingCellsGeomMap, m_missingCellMapName) ;
if ( sc.isFailure() ) {
ATH_MSG_ERROR("Unable to record badandmissingCellsGeomMap in event store: " << m_missingCellMapName);
return 1;
SG::WriteHandle<jet::CaloCellFastMap> badCellMap(m_badCellMap_key);
StatusCode sc = badCellMap.record(std::move(badandmissingCellsGeomMap));
if (sc.isFailure()) {
ATH_MSG_ERROR("Unable to record badandmissingCellsGeomMap in event store: "
<< m_badCellMap_key);
return 1;
}
// m_needSetup = false;
return 0;
}
// ////////////////////////////////////////////////////////////////////////////////
// // Handle incidents
// ////////////////////////////////////////////////////////////////////////////////
// void MissingCellListTool::handle(const Incident& inc)
// {
// ATH_MSG_DEBUG ("handle " << name() << "..."<< inc.type());
// if (inc.type()=="BeginEvent") {
// ATH_MSG(DEBUG) << " got begining event" << endmsg;
// m_needSetup = true;
// //if(prepareCellList().isFailure()) ATH_MSG(ERROR)<< " Could not build missing cell list !!"<<endmsg;
// }
// }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment