ATLAS Offline Software
LArDigitThinnerFromEMClust.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iostream>
8 
9 #include "Identifier/Identifier.h"
12 #include "LArRawEvent/LArDigit.h"
14 #include "CaloEvent/CaloCell.h"
17 
18 
20  ISvcLocator* pSvcLocator) :
21  AthReentrantAlgorithm(name, pSvcLocator)
22  , m_onlineID(nullptr)
23  , m_inputContainerKey("FREE")
24  , m_outputContainerKey("LArDigitContainer_EMClust")
25  , m_larCablingKey("LArOnOffIdMap")
26 {
27  declareProperty("InputContainerName", m_inputContainerKey);
28  declareProperty("OutputContainerName",m_outputContainerKey);
29  declareProperty("ClusterContainer",m_clusterContainerKey);
30  declareProperty("LArOnOffMap",m_larCablingKey);
31 }
32 
34 
35 
37  ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
42  return StatusCode::SUCCESS;
43 }
44 
46  return StatusCode::SUCCESS;
47 }
48 
49 
50 StatusCode LArDigitThinnerFromEMClust::execute(const EventContext& ctx) const {
51 
52  //Get inputs from read handles:
55 
56  //Write output via write handle
59 
60  //Get cable map via read conditions handle
62  const LArOnOffIdMapping* larCabling=*larCablingHdl;
63 
64  std::bitset<200000> clusteredDigits;
65 
66  //Loop over Clusters:
67  for (const xAOD::CaloCluster* clus : *clusterContainer) {
68 
69  //Loop over cells in cluster:
70  xAOD::CaloCluster::const_cell_iterator cellIter = clus->cell_begin();
71  xAOD::CaloCluster::const_cell_iterator cellIterEnd = clus->cell_end();
72  for( ;cellIter!=cellIterEnd;cellIter++) {
73  const CaloCell* cell = (*cellIter);
74  if (cell) {
75  Identifier id = cell->ID();
76  HWIdentifier hwid = larCabling->createSignalChannelID(id);
77  IdentifierHash idHash = m_onlineID->channel_Hash(hwid);
78  size_t index = (size_t) (idHash);
79  clusteredDigits.set(index);
80  }
81  }//end loop over cells in cluster
82  }//end loop over cluster
83 
84 
85  for (const LArDigit* dig : *inputContainer) {
86  HWIdentifier channelID = dig->channelID();
87  IdentifierHash idHash = m_onlineID->channel_Hash(channelID);
88  size_t index = (size_t) (idHash);
89  if (clusteredDigits.test(index)) outputContainer->push_back(dig);
90  }
91 
92  ATH_MSG_DEBUG("Copied " << outputContainer->size() << " of " << inputContainer->size() << " digits.");
93 
94  return StatusCode::SUCCESS;
95 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
LArDigitThinnerFromEMClust::LArDigitThinnerFromEMClust
LArDigitThinnerFromEMClust(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArDigitThinnerFromEMClust.cxx:19
LArDigitThinnerFromEMClust::m_inputContainerKey
SG::ReadHandleKey< LArDigitContainer > m_inputContainerKey
Definition: LArDigitThinnerFromEMClust.h:53
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
LArDigitThinnerFromEMClust::execute
StatusCode execute(const EventContext &ctx) const override
Definition: LArDigitThinnerFromEMClust.cxx:50
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArDigitThinnerFromEMClust::finalize
StatusCode finalize() override
Definition: LArDigitThinnerFromEMClust.cxx:45
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCell.h
LArDigitThinnerFromEMClust::~LArDigitThinnerFromEMClust
~LArDigitThinnerFromEMClust()
Definition: LArDigitThinnerFromEMClust.cxx:33
HWIdentifier
Definition: HWIdentifier.h:13
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
LArOnOffIdMapping.h
LArDigit.h
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArDigitThinnerFromEMClust::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArDigitThinnerFromEMClust.h:51
LArDigitThinnerFromEMClust::m_outputContainerKey
SG::WriteHandleKey< ConstDataVector< LArDigitContainer > > m_outputContainerKey
Definition: LArDigitThinnerFromEMClust.h:54
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArDigitThinnerFromEMClust::initialize
StatusCode initialize() override
Definition: LArDigitThinnerFromEMClust.cxx:36
LArOnOffIdMapping::createSignalChannelID
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
Definition: LArOnOffIdMapping.h:126
HWIdentifier.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArDigitThinnerFromEMClust.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArDigitThinnerFromEMClust::m_clusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterContainerKey
Definition: LArDigitThinnerFromEMClust.h:55
LArDigitContainer.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
CaloClusterContainer.h
LArDigitThinnerFromEMClust::m_larCablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_larCablingKey
Definition: LArDigitThinnerFromEMClust.h:57
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14