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

Merge branch 'DH1' into 'master'

MT migration of LArDigitThinnerFromEMClust Algo

See merge request atlas/athena!9393
parents 80fb00bb 429025e6
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,8 @@ atlas_depends_on_subdirs( PUBLIC
Calorimeter/CaloUtils
Control/AthContainers
DetectorDescription/Identifier
LArCalorimeter/LArRawEvent )
LArCalorimeter/LArRawEvent
LArCalorimeter/LArRecConditions)
# Component(s) in the package:
atlas_add_component( LArClusterRec
......
......@@ -13,18 +13,27 @@
#define LARCLUSTERREC_LArDigitThinnerFromEMClust_H
#include "GaudiKernel/ToolHandle.h"
#include "AthenaBaseComps/AthAlgorithm.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "LArCabling/LArCablingService.h"
#include "LArIdentifier/LArOnlineID.h"
#include <bitset>
#include <vector>
#include <string>
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "AthContainers/ConstDataVector.h"
class HWIdentifier;
class Identifier;
class LArDigitThinnerFromEMClust : public AthAlgorithm
class LArDigitContainer;
class LArOnOffIdMapping;
class LArDigitThinnerFromEMClust : public AthReentrantAlgorithm
{
public:
......@@ -33,25 +42,24 @@ class LArDigitThinnerFromEMClust : public AthAlgorithm
~LArDigitThinnerFromEMClust();
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
StatusCode initialize() override;
StatusCode execute_r(const EventContext& ctx) const override;
StatusCode finalize() override;
private:
StatusCode getCells();
ToolHandle<LArCablingService> m_larCablingSvc;
const LArOnlineID* m_onlineID;
std::string m_inputContainerName, m_outputContainerName;
std::string m_clusterContainerName;
SG::ReadHandleKey<LArDigitContainer> m_inputContainerKey;
SG::WriteHandleKey<ConstDataVector<LArDigitContainer> > m_outputContainerKey;
SG::ReadHandleKey<xAOD::CaloClusterContainer> m_clusterContainerKey;
SG::ReadCondHandleKey<LArOnOffIdMapping> m_larCablingKey;
std::vector<bool> m_listCells;
size_t m_nchannels;
//size_t m_nchannels;
unsigned int m_nevent;
unsigned int m_ncells;
//unsigned int m_nevent;
//unsigned int m_ncells;
};
......
include("LArRecUtils/LArOnOffMappingAlg.py")
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
......
......@@ -13,141 +13,83 @@
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "CaloEvent/CaloCell.h"
#include "AthContainers/ConstDataVector.h"
#include "LArRecConditions/LArOnOffIdMapping.h"
LArDigitThinnerFromEMClust::LArDigitThinnerFromEMClust(const std::string& name,
ISvcLocator* pSvcLocator) :
AthAlgorithm(name, pSvcLocator)
, m_larCablingSvc("LArCablingService")
AthReentrantAlgorithm(name, pSvcLocator)
, m_onlineID(0)
, m_inputContainerName("FREE")
, m_outputContainerName("LArDigitContainer_EMClust")
, m_nchannels(0)
, m_nevent(0)
, m_ncells(0)
, m_inputContainerKey("FREE")
, m_outputContainerKey("LArDigitContainer_EMClust")
, m_larCablingKey("LArOnOffIdMap")
{
declareProperty("InputContainerName", m_inputContainerName);
declareProperty("OutputContainerName",m_outputContainerName);
declareProperty("ClusterContainer",m_clusterContainerName);
declareProperty("InputContainerName", m_inputContainerKey);
declareProperty("OutputContainerName",m_outputContainerKey);
declareProperty("ClusterContainer",m_clusterContainerKey);
declareProperty("LArOnOffMap",m_larCablingKey);
}
LArDigitThinnerFromEMClust::~LArDigitThinnerFromEMClust() { }
StatusCode LArDigitThinnerFromEMClust::initialize() {
ATH_CHECK( m_larCablingSvc.retrieve() );
ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
m_nchannels = m_onlineID->channelHashMax();
m_listCells.resize(m_nchannels);
ATH_MSG_INFO( " Number of LAr online channels " << m_nchannels );
m_nevent=0;
m_ncells=0;
ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
ATH_CHECK( m_inputContainerKey.initialize());
ATH_CHECK( m_outputContainerKey.initialize());
ATH_CHECK( m_clusterContainerKey.initialize());
ATH_CHECK( m_larCablingKey.initialize());
return StatusCode::SUCCESS;
}
StatusCode LArDigitThinnerFromEMClust::finalize()
{
ATH_MSG_INFO( "LArDigitThinnerFromEMClust Finalize" );
ATH_MSG_INFO( " Number of events " << m_nevent );
ATH_MSG_INFO( " Number of digits written " << m_ncells );
StatusCode LArDigitThinnerFromEMClust::finalize() {
return StatusCode::SUCCESS;
}
StatusCode LArDigitThinnerFromEMClust::execute() {
StatusCode sc;
// Create the new digit container
ConstDataVector<LArDigitContainer>* outputContainer = new ConstDataVector<LArDigitContainer>(SG::VIEW_ELEMENTS);
if (!outputContainer){
ATH_MSG_WARNING( "Could not allocate a new LArDigitContainer" );
return StatusCode::SUCCESS;
}
sc = evtStore()->record(outputContainer , m_outputContainerName);
if (sc.isFailure()) {
ATH_MSG_WARNING( "Could not record output LArDigitContainer with key "
<< m_outputContainerName );
return StatusCode::SUCCESS;
}
const LArDigitContainer* inputContainer = 0;
sc = evtStore()->retrieve(inputContainer, m_inputContainerName);
if (sc.isFailure()) {
ATH_MSG_WARNING( "Input LArDigitContainer not found with key"
<< m_inputContainerName );
return StatusCode::SUCCESS;
}
StatusCode LArDigitThinnerFromEMClust::execute_r(const EventContext& ctx) const {
//Get inputs from read handles:
SG::ReadHandle<LArDigitContainer> inputContainer(m_inputContainerKey,ctx);
SG::ReadHandle<xAOD::CaloClusterContainer> clusterContainer(m_clusterContainerKey,ctx);
ATH_CHECK( getCells() );
//Write output via write handle
SG::WriteHandle<ConstDataVector<LArDigitContainer> >outputContainer(m_outputContainerKey,ctx);
ATH_CHECK(outputContainer.record(std::make_unique<ConstDataVector<LArDigitContainer> >(SG::VIEW_ELEMENTS)));
m_nevent++;
//Get cable map via read conditions handle
SG::ReadCondHandle<LArOnOffIdMapping> larCablingHdl(m_larCablingKey,ctx);
const LArOnOffIdMapping* larCabling=*larCablingHdl;
for (LArDigitContainer::const_iterator chan = inputContainer->begin();
chan != inputContainer->end(); ++chan)
{
std::bitset<200000> clusteredDigits;
HWIdentifier channelID = (*chan)->channelID();
IdentifierHash idHash = m_onlineID->channel_Hash(channelID);
size_t index = (size_t) (idHash);
if (!m_listCells[index]) continue;
//Loop over Clusters:
for (const xAOD::CaloCluster* clus : *clusterContainer) {
outputContainer->push_back(*chan);
m_ncells++;
}
ATH_MSG_DEBUG("Copied " << outputContainer->size() << " of " << inputContainer->size() << " digits.");
return StatusCode::SUCCESS;
}
StatusCode LArDigitThinnerFromEMClust::getCells()
{
for (size_t i=0;i<m_nchannels;i++) m_listCells[i]=false;
const xAOD::CaloClusterContainer* clusterCollection=0;
StatusCode sc = evtStore()->retrieve(clusterCollection, m_clusterContainerName);
if ( sc.isFailure() || !clusterCollection) {
ATH_MSG_WARNING( " Cluster collection not found " );
return StatusCode::SUCCESS;
}
xAOD::CaloClusterContainer::const_iterator clusB = clusterCollection->begin();
xAOD::CaloClusterContainer::const_iterator clusE = clusterCollection->end();
for ( ; clusB!= clusE; ++clusB) {
const xAOD::CaloCluster* clus = (*clusB);
// loop over cells
//Loop over cells in cluster:
xAOD::CaloCluster::const_cell_iterator cellIter = clus->cell_begin();
xAOD::CaloCluster::const_cell_iterator cellIterEnd = clus->cell_end();
for( ;cellIter!=cellIterEnd;cellIter++) {
const CaloCell* cell = (*cellIter);
if (cell) {
Identifier id = cell->ID();
HWIdentifier hwid = m_larCablingSvc->createSignalChannelID(id);
IdentifierHash idHash = m_onlineID->channel_Hash(hwid);
size_t index = (size_t) (idHash);
m_listCells[index]=true;
Identifier id = cell->ID();
HWIdentifier hwid = larCabling->createSignalChannelID(id);
IdentifierHash idHash = m_onlineID->channel_Hash(hwid);
size_t index = (size_t) (idHash);
clusteredDigits.set(index);
}
}
}
}//end loop over cells in cluster
}//end loop over cluster
return StatusCode::SUCCESS;
for (const LArDigit* dig : *inputContainer) {
HWIdentifier channelID = dig->channelID();
IdentifierHash idHash = m_onlineID->channel_Hash(channelID);
size_t index = (size_t) (idHash);
if (clusteredDigits.test(index)) outputContainer->push_back(dig);
}
ATH_MSG_DEBUG("Copied " << outputContainer->size() << " of " << inputContainer->size() << " digits.");
return StatusCode::SUCCESS;
}
......@@ -8,6 +8,6 @@ else:
condSequence = AthSequencer("AthCondSeq")
from LArRecUtils.LArRecUtilsConf import LArOnOffMappingAlg
condSequence+=LArOnOffMappingAlg(ReadKey="/LAR/Identifier/OnOffIdMap",OutputLevel=DEBUG)
condSequence+=LArOnOffMappingAlg(ReadKey="/LAR/Identifier/OnOffIdMap")
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