ATLAS Offline Software
Loading...
Searching...
No Matches
HLTCaloGlobalCellMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
11#include <memory>
12#include <cmath>
13#include <map>
14#include <algorithm> //for std::sort
15HLTCaloGlobalCellMaker::HLTCaloGlobalCellMaker(std::string const& name, ISvcLocator* pSvcLocator)
16 : AthReentrantAlgorithm(name, pSvcLocator) {
17}
18
20
21 ATH_CHECK( detStore()->retrieve(m_onlineId,"LArOnlineID") );
22 ATH_CHECK( detStore()->retrieve(m_caloCell_ID) );
23 ATH_CHECK( m_onOffIdMappingKey.initialize() );
24 ATH_CHECK(m_noiseCDOKey.initialize());
27
28 return StatusCode::SUCCESS;
29}
30
31StatusCode HLTCaloGlobalCellMaker::execute(EventContext const& context) const {
32 ATH_MSG_DEBUG("HLTCaloGlobalCellMaker::execute()");
33
35
37
39 const CaloNoise* noiseCDO=*noiseHdl;
41
42 auto outputCells = std::make_unique<CaloConstCellContainer>();
43 uint32_t n_febs = m_onlineId->febHashMax();
44 std::map<HWIdentifier,std::vector<uint16_t> > cells_idx_per_feb;
45 std::map<HWIdentifier,uint16_t > maxcell_idx_per_feb;
46 constexpr uint16_t maxidx = 129;
47 for(uint32_t i=0;i<n_febs;i++){
48 HWIdentifier feb_id = m_onlineId->feb_Id(IdentifierHash(i));
49 maxcell_idx_per_feb[feb_id]=maxidx;
50 }
51
52 // Get all channels which are above a given sigma cut (usually 2) and
53 // organize them in vectors.
54 for (auto const* cell : *inputCellHandle) {
55 if (!cell->caloDDE()->is_tile() ){
56 Identifier cellID = cell->ID();
57 float noiseSigma = noiseCDO->getNoise(cellID,cell->gain());
58 IdentifierHash offhashid = m_caloCell_ID->calo_cell_hash(cellID);
59 HWIdentifier hwid = (*onoff)->createSignalChannelIDFromHash(offhashid);
60 HWIdentifier hwid_feb = m_onlineId->feb_Id(hwid);
61 uint16_t channel = m_onlineId->channel(hwid);
62 if ( cell->energy() > m_NumberOfSigma*noiseSigma ) {
63 cells_idx_per_feb[hwid_feb].push_back(channel);
64 }
65 }
66 }
67
68 // impose the channel order. One might want to have other organizations.
69 // Here, I assume channel order. Only worth to manipulate if above
70 // a given number
71 for(uint32_t i=0;i<n_febs;i++){
72 HWIdentifier hwid_feb = m_onlineId->feb_Id(IdentifierHash(i));
73 std::vector<uint16_t>& indexes = cells_idx_per_feb[hwid_feb];
74 if ( indexes.size() < m_MaxNCellsPerFEB ) continue;
75 std::sort(indexes.begin(),indexes.end());
76 // This is the maximal channel number that will be accepted in
77 // a given FEB
78 maxcell_idx_per_feb[hwid_feb]=indexes[m_MaxNCellsPerFEB-1];
79 }
80
81 for (auto const* cell : *inputCellHandle) {
82 if (cell->caloDDE()->is_tile() ){
83 std::unique_ptr<CaloCell> copy = cell->clone();
84 outputCells->push_back(std::move(copy));
85 } else {
86 Identifier cellID = cell->ID();
87 float noiseSigma = noiseCDO->getNoise(cellID,cell->gain());
88 IdentifierHash offhashid = m_caloCell_ID->calo_cell_hash(cellID);
89 HWIdentifier hwid = (*onoff)->createSignalChannelIDFromHash(offhashid);
90 HWIdentifier hwid_feb = m_onlineId->feb_Id(hwid);
91 uint16_t channel = m_onlineId->channel(hwid);
92 // remember, by default, no channel number is above 128
93 if ( (cell->energy() > m_NumberOfSigma*noiseSigma) && (channel <= maxcell_idx_per_feb[hwid_feb]) ) {
94 std::unique_ptr<CaloCell> copy = cell->clone();
95 outputCells->push_back(std::move(copy));
96 }
97 }
98 }
99
101 if (inputCellHandle->hasCalo(id))
102 outputCells->setHasCalo(id);
103
104 outputCells->updateCaloIterators();
105
106 ATH_CHECK(outputCellHandle.record(std::move(outputCells)));
107
108 return StatusCode::SUCCESS;
109}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:35
Gaudi::Property< uint32_t > m_MaxNCellsPerFEB
virtual StatusCode execute(EventContext const &context) const override
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
virtual StatusCode initialize() override
SG::WriteHandleKey< CaloConstCellContainer > m_outputCellContainerKey
SG::ReadHandleKey< CaloConstCellContainer > m_inputCellContainerKey
Gaudi::Property< float > m_NumberOfSigma
const CaloCell_ID * m_caloCell_ID
HLTCaloGlobalCellMaker(std::string const &name, ISvcLocator *pSvcLocator)
const LArOnlineID * m_onlineId
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
This is a "hash" representation of an Identifier.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.