ATLAS Offline Software
Loading...
Searching...
No Matches
LArDigitThinner.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "LArDigitThinner.h"
12
13#include <bitset>
14#include <limits>
15#include <cstdlib>
16
17LArDigitThinner::LArDigitThinner(const std::string& name,
18 ISvcLocator* pSvcLocator) :
19 AthReentrantAlgorithm(name, pSvcLocator)
20 , m_onlineID(nullptr)
21 , m_caloCellId(nullptr) {
22 declareProperty("EnergyCuts_Barrel", m_energyCuts_barrel);
23 declareProperty("EnergyCuts_Endcap", m_energyCuts_endcap);
24 declareProperty("EnergyCut_HEC", m_energyCut_hec = 5000);
25 declareProperty("EnergyCut_FCAL", m_energyCut_fcal = 20000);
26}
27
29
30
32
33 ATH_CHECK(m_cablingKey.initialize());
34 ATH_CHECK(m_inputKey.initialize());
35 ATH_CHECK(m_rawChannelKey.initialize());
36 ATH_CHECK(m_outputKey.initialize());
37
38 ATH_CHECK(detStore()->retrieve(m_onlineID, "LArOnlineID"));
39 ATH_CHECK(detStore()->retrieve(m_caloCellId,"CaloCell_ID"));
40
41
42 //Fix up jobOptions if needed:
43 int defaultCuts_barrel[] = { 1000, 1000, 1000, 1000 };
44 int defaultCuts_endcap[] = { 2000, 2000, 2000, 2000 };
45
46 if (m_energyCuts_barrel.size() != 4) {
47 msg(MSG::WARNING) << "Only " << m_energyCuts_barrel.size()
48 << " energy cut values provided for the endcap : reverting to default" << endmsg;
49 for (size_t i=0;i<4;++i) m_energyCuts_barrel.push_back(defaultCuts_barrel[i]);
50 }
51
52 if (m_energyCuts_endcap.size() != 4) {
53 msg(MSG::WARNING) << "Only " << m_energyCuts_endcap.size()
54 << " energy cut values provided for the endcap : reverting to default" << endmsg;
55 for (size_t i=0;i<4;++i) m_energyCuts_endcap.push_back(defaultCuts_endcap[i]);
56 }
57
58 msg(MSG::INFO) << "Energy cuts (Barrel) : ";
59 for (unsigned int i = 0; i < 4; i++) msg() << m_energyCuts_barrel[i] << " ";
60 msg(MSG::INFO) << "GeV" << endmsg;
61
62 msg() << MSG::INFO << "Energy cuts (Endcap) : ";
63 for (unsigned int i = 0; i < 4; i++) msg() << m_energyCuts_endcap[i] << " ";
64 msg() << MSG::INFO << "GeV" << endmsg;
65
66 return StatusCode::SUCCESS;
67}
68
69
70const std::vector<int>&
71LArDigitThinner::initCutValues(const EventContext& ctx) const
72{
73 if (!m_energyCuts.isValid()) {
74 //Note that the cut values per online-ID depends on the LAr-cabling. Even the cabling is
75 //formally a time-dependent condition, it changes very rarely. Therefore putting it
76 //into a ConditionsContainer filled by a dedicated conditions algorithm seems an
77 //unecessary overkill.
78
79 std::vector<int> energyCuts;
80 energyCuts.assign(m_onlineID->channelHashMax(),std::numeric_limits<int>::max());
81
82
84 const LArOnOffIdMapping* cabling=*cablingHdl;
85
86
87 for (const Identifier id : m_caloCellId->cell_range(CaloCell_ID::LAREM)) {
88 HWIdentifier chid=cabling->createSignalChannelID(id);
89 IdentifierHash onlHash=m_onlineID->channel_Hash(chid);
90 int sampling = m_caloCellId->sampling(id);
91 if (sampling < 0) continue;
92 if (m_caloCellId->is_em_barrel(id)) {
93 energyCuts[onlHash]=m_energyCuts_barrel[sampling];
94 }
95 else { //endcap
96 energyCuts[onlHash]=m_energyCuts_endcap[sampling];
97 continue;
98 }
99 }//end loop over EM cells;
100
101 for (const Identifier id : m_caloCellId->cell_range(CaloCell_ID::LARHEC)) {
102 HWIdentifier chid=cabling->createSignalChannelID(id);
103 IdentifierHash onlHash=m_onlineID->channel_Hash(chid);
104 energyCuts[onlHash]= m_energyCut_hec;
105 }//End loop over HEC cells
106
107 for (const Identifier id : m_caloCellId->cell_range(CaloCell_ID::LARFCAL)) {
108 HWIdentifier chid=cabling->createSignalChannelID(id);
109 IdentifierHash onlHash=m_onlineID->channel_Hash(chid);
110 energyCuts[onlHash]= m_energyCut_fcal;
111 }//end loop over FCAL cells
112
113 m_energyCuts.set (std::move (energyCuts));
114
115 ATH_MSG_INFO("Done filling cache of cut values");
116 }
117
118 return *m_energyCuts.ptr();
119}
120
121
123{
124 return StatusCode::SUCCESS;
125}
126
127
128StatusCode LArDigitThinner::execute(const EventContext& ctx) const {
129
130 const std::vector<int>& energyCuts = initCutValues(ctx); //Should return right away if the cut values are already initialized
131
132 //Get event inputs from read handles:
135
136 // Create the new digit container
138
139 ATH_CHECK(outputContainer.record(std::make_unique<ConstDigitCont_t>(SG::VIEW_ELEMENTS)));
140
141
142 auto keepSet = std::make_unique<std::bitset<200000> >();
143
144 for(const LArRawChannel& chan : *larRawChannelContainer) {
145 const IdentifierHash onlHash=m_onlineID->channel_Hash(chan.hardwareID());
146 if (abs(chan.energy())>=energyCuts[onlHash]) {
147 keepSet->set(onlHash);
148 }
149 }//end loop over raw channels
150
151
152 //start loop over digits
153 for (const LArDigit* dig : *inputContainer) {
154 const IdentifierHash onlHash=m_onlineID->channel_Hash(dig->hardwareID());
155 if (keepSet->test(onlHash)) {
156 outputContainer->push_back(dig);
157 }
158 }//end loop over input container
159
160 ATH_MSG_DEBUG("Copied " << outputContainer->size() << " of "
161 << inputContainer->size() << " digits.");
162
163 return StatusCode::SUCCESS;
164}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
This is a "hash" representation of an Identifier.
SG::WriteHandleKey< ConstDigitCont_t > m_outputKey
CxxUtils::CachedValue< std::vector< int > > m_energyCuts
const std::vector< int > & initCutValues(const EventContext &ctx) const
StatusCode initialize() override
const LArOnlineID * m_onlineID
StatusCode finalize() override
SG::ReadHandleKey< LArRawChannelContainer > m_rawChannelKey
const CaloCell_ID * m_caloCellId
StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
std::vector< int > m_energyCuts_barrel
std::vector< int > m_energyCuts_endcap
SG::ReadHandleKey< LArDigitContainer > m_inputKey
LArDigitThinner(const std::string &name, ISvcLocator *pSvcLocator)
Liquid Argon digit base class.
Definition LArDigit.h:25
Liquid Argon ROD output object base class.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts