Skip to content
Snippets Groups Projects
Commit 4dc2c331 authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'LArDH1' into 'master'

LArCellMerger MT migration

See merge request atlas/athena!9798
parents 0b53dcbb 4353d665
No related merge requests found
//Dear emacs, this is -*-c++-*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
......@@ -20,12 +21,13 @@
#include "GaudiKernel/ToolHandle.h"
#include "CaloInterface/ICaloCellMakerTool.h"
#include "AthenaKernel/IOVSvcDefs.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/ReadCondHandleKey.h"
class LArCablingService;
class StoreGateSvc;
class LArOnOffIdMapping;
class CaloCell_ID;
class LArRawChannelContainer;
class LArCellMerger: public AthAlgTool,
virtual public ICaloCellMakerTool
......@@ -41,40 +43,30 @@ public:
/** initialize the tool
*/
virtual StatusCode initialize() ;
virtual StatusCode initialize() override;
/** finalize the tool
/** finalize the tool
*/
virtual StatusCode finalize() ;
virtual StatusCode finalize() override;
/** update theCellContainer
*/
virtual StatusCode process( CaloCellContainer * theCellContainer) ;
virtual StatusCode process( CaloCellContainer * theCellContainer) override; //could be const if the abstract base-class were const
private:
/** handle to LAr cabling service
*/
ToolHandle<LArCablingService> m_cablingService;
/** flags to select which errors to mask
/** handle to LAr cabling
*/
SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey;
/** key for raw channel container to merge to cells
*/
std::string m_rawChannelContainerName;
*/
SG::ReadHandleKey<LArRawChannelContainer> m_rawChannelContainerName;
const CaloCell_ID* m_calo_id;
/** Number of events processed
*/
int m_evt;
/** Number of cells read from new container
*/
int m_ncell;
};
#endif
......
......@@ -20,10 +20,8 @@ PURPOSE:
#include "CaloEvent/CaloCellContainer.h"
#include "Identifier/Identifier.h"
#include "Identifier/IdentifierHash.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_ID.h"
#include "LArCabling/LArCablingService.h"
#include "LArCabling/LArOnOffIdMapping.h"
/////////////////////////////////////////////////////////////////////
// CONSTRUCTOR:
......@@ -34,11 +32,9 @@ LArCellMerger::LArCellMerger(
const std::string& name,
const IInterface* parent)
:AthAlgTool(type, name, parent),
m_cablingService("LArCablingService"),
m_cablingKey("LArOnOffIdMap"),
m_rawChannelContainerName("LArRawChannels_digits"),
m_calo_id(nullptr),
m_evt(0),
m_ncell(0)
m_calo_id(nullptr)
{
declareInterface<ICaloCellMakerTool>(this);
......@@ -51,41 +47,36 @@ LArCellMerger::LArCellMerger(
// The initialize method will create all the required algorithm objects
/////////////////////////////////////////////////////////////////////
StatusCode LArCellMerger::initialize()
{
m_evt=0;
m_ncell=0;
StatusCode LArCellMerger::initialize() {
ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
ATH_CHECK( m_cablingKey.initialize() );
ATH_CHECK(m_rawChannelContainerName.initialize());
const CaloIdManager* caloIdMgr;
ATH_CHECK( detStore()->retrieve( caloIdMgr ) );
m_calo_id = caloIdMgr->getCaloCell_ID();
ATH_CHECK( m_cablingService.retrieve() );
return StatusCode::SUCCESS;
}
StatusCode LArCellMerger::finalize()
{
ATH_MSG_INFO( " ---- Summary from LArCellMerger " );
ATH_MSG_INFO( " Number of events processed " << m_evt );
ATH_MSG_INFO( " Number of cells from merged raw channel container " << m_ncell );
float ratio=0.;
if (m_evt>0) ratio=((float)(m_ncell))/((float)(m_evt));
ATH_MSG_INFO( " Average number of cells per event " << ratio );
StatusCode LArCellMerger::finalize(){
return StatusCode::SUCCESS;
}
StatusCode LArCellMerger::process(CaloCellContainer * theCont )
{
StatusCode LArCellMerger::process(CaloCellContainer * theCont ) {
m_evt++;
unsigned int nwarnings=0;
ATH_MSG_DEBUG("in LArCellMerger::process");
const LArRawChannelContainer* rawColl;
ATH_CHECK( evtStore()->retrieve(rawColl,m_rawChannelContainerName) );
SG::ReadHandle<LArRawChannelContainer> rawColl(m_rawChannelContainerName);
if (!rawColl.isValid()) {
ATH_MSG_ERROR("Failed to retrieve LArRawChannelContainer with key " <<
rawColl.name());
return StatusCode::FAILURE;
}
SG::ReadCondHandle<LArOnOffIdMapping> larCablingHdl(m_cablingKey);
const LArOnOffIdMapping* cabling=*larCablingHdl;
unsigned nReplaced=0;
// loop over raw channel container
// as this new container is supposed to contain only few cells, we do a simple loop and the basics onlineId to offlineId conversion
......@@ -98,33 +89,32 @@ StatusCode LArCellMerger::process(CaloCellContainer * theCont )
const LArRawChannel& theRawChannel = (*itrRawChannel);
const HWIdentifier hwid=theRawChannel.channelID();
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) {
if (nwarnings<100) {
ATH_MSG_WARNING( " cell " << hwid.get_compact() << " " << id.get_compact() << " is not in the container " );
nwarnings++;
if (nwarnings==100) ATH_MSG_WARNING( " will not print anymore warnings for this event... " );
}
continue;
ATH_MSG_WARNING( " cell " << hwid.get_compact() << " " << id.get_compact() << " is not in the container " );
continue;
}
CaloCell* aCell = theCont->at(index);
if (aCell) {
ATH_MSG_DEBUG(" replace energies in cell hwid= " << hwid.get_compact() << " offlineid = " << id.get_compact()
<< " " << aCell->ID().get_compact() << " old energy " << aCell->e() << " new energy " << theRawChannel.energy());
ATH_MSG_DEBUG(" replace energies in cell hwid= " << hwid.get_identifier32().get_compact()
<< " offlineid = " << id.get_identifier32().get_compact()
<< " old energy " << aCell->e() << " new energy " << theRawChannel.energy());
nReplaced++;
aCell->setEnergy((float)(theRawChannel.energy()));
aCell->setTime((float)(theRawChannel.time())*0.001); // convert from ps int in raw channel to ns float in calocell
aCell->setQuality(theRawChannel.quality());
aCell->setProvenance(theRawChannel.provenance());
m_ncell++;
}
} // isConnected
} // loop over raw channel container
if (nReplaced*5>theCont->size()) {
ATH_MSG_WARNING("Replaced more than 20% of channels reco'ed online by channels reco'ed offline");
}
return StatusCode::SUCCESS;
}
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