ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArROD
src
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
"
6
#include "
LArRawEvent/LArDigitContainer.h
"
7
#include "
LArRawEvent/LArRawChannelContainer.h
"
8
#include "
Identifier/HWIdentifier.h
"
9
#include "
CaloIdentifier/CaloCell_ID.h
"
10
#include "
LArIdentifier/LArOnlineID.h
"
11
#include "
AthContainers/ConstDataVector.h
"
12
13
#include <bitset>
14
#include <limits>
15
#include <cstdlib>
16
17
LArDigitThinner::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
28
LArDigitThinner::~LArDigitThinner
() =
default
;
29
30
31
StatusCode
LArDigitThinner::initialize
() {
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
70
const
std::vector<int>&
71
LArDigitThinner::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
83
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl(
m_cablingKey
,ctx);
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
122
StatusCode
LArDigitThinner::finalize
()
123
{
124
return
StatusCode::SUCCESS;
125
}
126
127
128
StatusCode
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:
133
SG::ReadHandle<LArDigitContainer>
inputContainer(
m_inputKey
,ctx);
134
SG::ReadHandle<LArRawChannelContainer>
larRawChannelContainer(
m_rawChannelKey
,ctx);
135
136
// Create the new digit container
137
SG::WriteHandle<ConstDigitCont_t>
outputContainer(
m_outputKey
,ctx);
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCell_ID.h
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
HWIdentifier.h
LArDigitContainer.h
LArDigitThinner.h
LArOnlineID.h
LArRawChannelContainer.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CaloCell_Base_ID::LAREM
@ LAREM
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition
CaloCell_Base_ID.h:45
HWIdentifier
Definition
HWIdentifier.h:13
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
LArDigitThinner::m_outputKey
SG::WriteHandleKey< ConstDigitCont_t > m_outputKey
Definition
LArDigitThinner.h:74
LArDigitThinner::m_energyCuts
CxxUtils::CachedValue< std::vector< int > > m_energyCuts
Definition
LArDigitThinner.h:76
LArDigitThinner::initCutValues
const std::vector< int > & initCutValues(const EventContext &ctx) const
Definition
LArDigitThinner.cxx:71
LArDigitThinner::initialize
StatusCode initialize() override
Definition
LArDigitThinner.cxx:31
LArDigitThinner::m_onlineID
const LArOnlineID * m_onlineID
Definition
LArDigitThinner.h:64
LArDigitThinner::finalize
StatusCode finalize() override
Definition
LArDigitThinner.cxx:122
LArDigitThinner::m_rawChannelKey
SG::ReadHandleKey< LArRawChannelContainer > m_rawChannelKey
Definition
LArDigitThinner.h:71
LArDigitThinner::m_energyCut_hec
int m_energyCut_hec
Definition
LArDigitThinner.h:60
LArDigitThinner::m_energyCut_fcal
int m_energyCut_fcal
Definition
LArDigitThinner.h:60
LArDigitThinner::m_caloCellId
const CaloCell_ID * m_caloCellId
Definition
LArDigitThinner.h:65
LArDigitThinner::execute
StatusCode execute(const EventContext &ctx) const override
Definition
LArDigitThinner.cxx:128
LArDigitThinner::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition
LArDigitThinner.h:67
LArDigitThinner::m_energyCuts_barrel
std::vector< int > m_energyCuts_barrel
Definition
LArDigitThinner.h:59
LArDigitThinner::m_energyCuts_endcap
std::vector< int > m_energyCuts_endcap
Definition
LArDigitThinner.h:59
LArDigitThinner::~LArDigitThinner
~LArDigitThinner()
LArDigitThinner::m_inputKey
SG::ReadHandleKey< LArDigitContainer > m_inputKey
Definition
LArDigitThinner.h:70
LArDigitThinner::LArDigitThinner
LArDigitThinner(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArDigitThinner.cxx:17
LArDigit
Liquid Argon digit base class.
Definition
LArDigit.h:25
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
LArRawChannel
Liquid Argon ROD output object base class.
Definition
LArRawChannel.h:40
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Identifier
Definition
IdentifierFieldParser.cxx:14
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
Generated on
for ATLAS Offline Software by
1.17.0