ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
ZDC
ZdcRec
src
ZdcRecRun3Decode.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/*
6
* ZdcRecRun3Decode.cxx
7
*
8
* Created on: June 23, 2022 (never forget)
9
* Author: steinberg@bnl.gov
10
*/
11
12
13
#include <memory>
14
15
#include "GaudiKernel/ISvcLocator.h"
16
#include "GaudiKernel/MsgStream.h"
17
#include "GaudiKernel/StatusCode.h"
18
#include "
StoreGate/StoreGateSvc.h
"
19
#include "
StoreGate/WriteHandle.h
"
20
#include "
StoreGate/ReadHandle.h
"
21
22
#include "
ZdcRec/ZdcRecRun3Decode.h
"
23
#include "
ZdcRec/ZdcRecChannelToolLucrod.h
"
24
#include "
xAODForward/ZdcModuleToString.h
"
25
#include "
ZdcByteStream/ZdcToString.h
"
26
#include "
ZdcUtils/ZdcEventInfo.h
"
27
28
29
//==================================================================================================
30
ZdcRecRun3Decode::ZdcRecRun3Decode
(
const
std::string& name, ISvcLocator* pSvcLocator) :
31
32
AthAlgorithm
(name, pSvcLocator),
33
m_ownPolicy
(static_cast<int> (
SG
::OWN_ELEMENTS)),
34
m_DecodeRunMode
(0)
// 0 = ZDC+RPD (default), 1 = LIS only, 2 = ZDC+RPD + LIS
35
{
36
declareProperty
(
"OwnPolicy"
,
m_ownPolicy
) ;
37
declareProperty
(
"DecodeRunMode"
,
m_DecodeRunMode
);
// 0 = ZDC+RPD (default), 1 = LIS only, 2 = ZDC+RPD + LIS
38
}
39
40
//==================================================================================================
41
42
//==================================================================================================
43
ZdcRecRun3Decode::~ZdcRecRun3Decode
() {}
44
//==================================================================================================
45
46
//==================================================================================================
47
StatusCode
ZdcRecRun3Decode::initialize
()
48
{
49
MsgStream mLog(msgSvc(), name());
50
51
// Reconstruction Tool
52
ATH_CHECK
(
m_ChannelTool
.retrieve() );
53
54
55
// Reconstruction Tool
56
57
ATH_CHECK
(
m_zdcModuleContainerName
.initialize() );
58
ATH_CHECK
(
m_zdcSumContainerName
.initialize() );
59
ATH_CHECK
(
m_zldContainerName
.initialize(
SG::AllowEmpty
) );
60
ATH_CHECK
(
m_eventInfoKey
.initialize() );
61
ATH_CHECK
(
m_eventInfoDecorKey
.initialize() );
62
63
if
(
m_ownPolicy
==
SG::OWN_ELEMENTS
)
64
mLog << MSG::DEBUG <<
"...will OWN its cells."
<<
endmsg
;
65
else
66
mLog << MSG::DEBUG <<
"...will VIEW its cells."
<<
endmsg
;
67
68
if
(
m_DecodeRunMode
== 0){
69
mLog << MSG::DEBUG <<
"--> ZDC: Running in ZDC+RPD mode"
<<
endmsg
;
70
m_nFragments
.set(6);
// default
71
}
72
73
else
if
(
m_DecodeRunMode
== 1){
74
mLog << MSG::DEBUG <<
"--> ZDC: Running in LIS only mode"
<<
endmsg
;
75
m_nFragments
.set(1);
76
}
77
else
if
(
m_DecodeRunMode
== 2){
78
mLog << MSG::DEBUG <<
"--> ZDC: Running in ZDC+RPD + LIS mode"
<<
endmsg
;
79
m_nFragments
.set(7);
80
}
81
else
{
82
mLog << MSG::ERROR <<
"--> ZDC: Unknown DecodeRunMode "
<<
m_DecodeRunMode
<<
", should be 0, 1, or 2. Exiting."
<<
endmsg
;
83
return
StatusCode::FAILURE;
84
}
85
86
87
mLog << MSG::DEBUG <<
"--> ZDC: ZdcRecRun3Decode initialization complete"
<<
endmsg
;
88
89
return
StatusCode::SUCCESS;
90
}
91
//==================================================================================================
92
93
//==================================================================================================
94
StatusCode
ZdcRecRun3Decode::execute
(
const
EventContext& ctx)
95
{
96
97
ATH_MSG_DEBUG
(
"In ZdRecRun3"
);
98
99
100
ATH_MSG_DEBUG
(
"--> ZDC: ZdcRecRun3Decode execute starting on "
101
<< ctx.evt()
102
<<
"th event"
);
103
104
//Look for the container presence
105
if
(
m_zldContainerName
.empty()) {
106
return
StatusCode::SUCCESS;
107
}
108
109
ATH_MSG_DEBUG
(
"Trying to get LUCROD DATA!"
);
110
SG::ReadHandle<ZdcLucrodDataContainer>
zldContainer (
m_zldContainerName
, ctx);
111
ATH_MSG_DEBUG
(
"Did I get LUCROD DATA?"
);
112
113
114
if
(zldContainer->size() <
m_nFragments
)
115
{
116
int
zdcLucrod = 0;
117
int
rpdLucrod = 0;
118
int
lisLucrod = 0;
119
for
(
auto
zld : *zldContainer)
120
{
121
uint32_t lucrod_id = zld->GetLucrodID();
122
if
(lucrod_id ==
ZdcEventInfo::LucrodLowGain
|| lucrod_id ==
ZdcEventInfo::LucrodHighGain
)
// ZDC LUCRODs
123
{
124
zdcLucrod++;
125
}
126
else
if
(lucrod_id ==
ZdcEventInfo::LucrodRPD1A
127
|| lucrod_id ==
ZdcEventInfo::LucrodRPD1C
128
|| lucrod_id ==
ZdcEventInfo::LucrodRPD2A
129
|| lucrod_id ==
ZdcEventInfo::LucrodRPD2C
)
130
{
131
rpdLucrod++;
132
}
133
else
if
(lucrod_id ==
ZdcEventInfo::LucrodLIS
)
// LIS LUCROD
134
{
135
lisLucrod++;
136
}
137
else
138
{
139
ATH_MSG_WARNING
(
"Unidentified LUCROD ID = "
<< lucrod_id);
140
}
141
}
142
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
143
if
(!eventInfo->updateErrorState(
xAOD::EventInfo::ForwardDet
,
xAOD::EventInfo::Error
))
144
{
145
ATH_MSG_WARNING
(
" cannot set EventInfo error state for ForwardDet "
);
146
}
147
if
(!eventInfo->updateEventFlagBit(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::DECODINGERROR
))
148
{
149
ATH_MSG_WARNING
(
" cannot set flag bit for ForwardDet "
);
150
}
151
if
(rpdLucrod <
ZdcEventInfo::nTotalRpdLucrod
&&
m_DecodeRunMode
!= 1)
152
{
153
if
(!eventInfo->updateEventFlagBit(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::RPDDECODINGERROR
))
154
{
155
ATH_MSG_WARNING
(
" cannot set RPDDECODINGERROR flag bit for ForwardDet "
);
156
}
157
}
158
if
(zdcLucrod <
ZdcEventInfo::nTotalZdcLucrod
&&
m_DecodeRunMode
!= 1)
159
{
160
if
(!eventInfo->updateEventFlagBit(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::ZDCDECODINGERROR
))
161
{
162
ATH_MSG_WARNING
(
" cannot set ZDCDECODINGERROR flag bit for ForwardDet "
);
163
}
164
}
165
if
(lisLucrod <
ZdcEventInfo::nTotalLisLucrod
&& (
m_DecodeRunMode
== 1 ||
m_DecodeRunMode
== 2))
166
{
167
if
(!eventInfo->updateEventFlagBit(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::LISDECODINGERROR
))
168
{
169
ATH_MSG_WARNING
(
" cannot set LISDECODINGERROR flag bit for ForwardDet "
);
170
}
171
}
172
}
173
174
//Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
175
std::unique_ptr<xAOD::ZdcModuleContainer> moduleContainer(
new
xAOD::ZdcModuleContainer
());
176
std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleAuxContainer(
new
xAOD::ZdcModuleAuxContainer
() );
177
moduleContainer->setStore( moduleAuxContainer.get() );
178
179
//Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
180
std::unique_ptr<xAOD::ZdcModuleContainer> moduleSumContainer(
new
xAOD::ZdcModuleContainer
());
181
std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleSumAuxContainer(
new
xAOD::ZdcModuleAuxContainer
() );
182
moduleSumContainer->setStore( moduleSumAuxContainer.get() );
183
184
ATH_MSG_DEBUG
(
"Trying to convert!"
);
185
186
// rearrange ZDC channels and perform fast reco on all channels (including non-big tubes)
187
int
ncha =
m_ChannelTool
->convertLucrod2ZM(zldContainer.
get
(), moduleContainer.get(), moduleSumContainer.get() );
188
ATH_MSG_DEBUG
(
"m_ChannelTool->convertLucrod2ZM returned "
<< ncha <<
" channels"
);
189
190
ATH_MSG_DEBUG
(
"Dumping modules"
);
191
ATH_MSG_DEBUG
(
ZdcModuleToString
(*moduleContainer) );
192
ATH_MSG_DEBUG
(
"Dumping module sums"
);
193
ATH_MSG_DEBUG
(
ZdcModuleToString
(*moduleSumContainer) );
194
195
// eventually reconstruct RPD, using ML libraries
196
// ATH_CHECK( m_rpdTool...)
197
198
SG::WriteHandle<xAOD::ZdcModuleContainer>
moduleContainerH (
m_zdcModuleContainerName
, ctx);
199
ATH_CHECK
( moduleContainerH.
record
(std::move(moduleContainer),
200
std::move(moduleAuxContainer)) );
201
202
SG::WriteHandle<xAOD::ZdcModuleContainer>
moduleSumContainerH (
m_zdcSumContainerName
, ctx);
203
ATH_CHECK
( moduleSumContainerH.
record
(std::move(moduleSumContainer),
204
std::move(moduleSumAuxContainer)) );
205
206
return
StatusCode::SUCCESS;
207
208
}
209
//==================================================================================================
210
211
//==================================================================================================
212
StatusCode
ZdcRecRun3Decode::finalize
()
213
{
214
215
ATH_MSG_DEBUG
(
"--> ZDC: ZdcRecRun3Decode finalize complete"
);
216
217
return
StatusCode::SUCCESS;
218
219
}
220
//==================================================================================================
221
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:28
StoreGateSvc.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
ZdcEventInfo.h
Define enumerations for event-level ZDC data.
ZdcModuleToString
std::string ZdcModuleToString(const xAOD::ZdcModule &zm)
Definition
ZdcModuleToString.cxx:11
ZdcModuleToString.h
ZdcRecChannelToolLucrod.h
ZdcRecRun3Decode.h
ZdcToString.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
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.
ZdcRecRun3Decode::m_ownPolicy
int m_ownPolicy
Definition
ZdcRecRun3Decode.h:56
ZdcRecRun3Decode::ZdcRecRun3Decode
ZdcRecRun3Decode(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ZdcRecRun3Decode.cxx:30
ZdcRecRun3Decode::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
ZdcRecRun3Decode.h:60
ZdcRecRun3Decode::initialize
StatusCode initialize() override
Definition
ZdcRecRun3Decode.cxx:47
ZdcRecRun3Decode::finalize
StatusCode finalize() override
Definition
ZdcRecRun3Decode.cxx:212
ZdcRecRun3Decode::m_zldContainerName
SG::ReadHandleKey< ZdcLucrodDataContainer > m_zldContainerName
Definition
ZdcRecRun3Decode.h:64
ZdcRecRun3Decode::~ZdcRecRun3Decode
~ZdcRecRun3Decode()
Definition
ZdcRecRun3Decode.cxx:43
ZdcRecRun3Decode::execute
StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
ZdcRecRun3Decode.cxx:94
ZdcRecRun3Decode::m_zdcSumContainerName
SG::WriteHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
Definition
ZdcRecRun3Decode.h:70
ZdcRecRun3Decode::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition
ZdcRecRun3Decode.h:61
ZdcRecRun3Decode::m_nFragments
Gaudi::Property< unsigned int > m_nFragments
Definition
ZdcRecRun3Decode.h:58
ZdcRecRun3Decode::m_ChannelTool
ToolHandle< ZdcRecChannelToolLucrod > m_ChannelTool
Definition
ZdcRecRun3Decode.h:73
ZdcRecRun3Decode::m_DecodeRunMode
int m_DecodeRunMode
Definition
ZdcRecRun3Decode.h:57
ZdcRecRun3Decode::m_zdcModuleContainerName
SG::WriteHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
Definition
ZdcRecRun3Decode.h:67
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition
EventInfo_v1.h:338
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition
EventInfo_v1.h:349
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition
OwnershipPolicy.h:17
ZdcEventInfo::LucrodRPD2C
@ LucrodRPD2C
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LucrodLowGain
@ LucrodLowGain
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LucrodHighGain
@ LucrodHighGain
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LucrodRPD2A
@ LucrodRPD2A
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LucrodLIS
@ LucrodLIS
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LucrodRPD1A
@ LucrodRPD1A
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LucrodRPD1C
@ LucrodRPD1C
Definition
ZdcEventInfo.h:20
ZdcEventInfo::LISDECODINGERROR
@ LISDECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::RPDDECODINGERROR
@ RPDDECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::ZDCDECODINGERROR
@ ZDCDECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::DECODINGERROR
@ DECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::nTotalZdcLucrod
@ nTotalZdcLucrod
Definition
ZdcEventInfo.h:21
ZdcEventInfo::nTotalLisLucrod
@ nTotalLisLucrod
Definition
ZdcEventInfo.h:21
ZdcEventInfo::nTotalRpdLucrod
@ nTotalRpdLucrod
Definition
ZdcEventInfo.h:21
xAOD::ZdcModuleContainer
ZdcModuleContainer_v1 ZdcModuleContainer
Definition
ZdcModuleContainer.h:18
xAOD::ZdcModuleAuxContainer
ZdcModuleAuxContainer_v2 ZdcModuleAuxContainer
Definition
ZdcModuleAuxContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0