ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
ZDC
ZdcRec
src
ZdcRecRun3.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
* ZdcRecRun3.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/WriteDecorHandle.h
"
21
#include "
StoreGate/ReadHandle.h
"
22
#include "
StoreGate/ReadDecorHandle.h
"
23
24
#include "
ZdcRec/ZdcRecRun3.h
"
25
#include "
xAODForward/ZdcModuleAuxContainer.h
"
26
#include "
xAODForward/ZdcModuleToString.h
"
27
#include "
ZdcByteStream/ZdcToString.h
"
28
#include "
ZdcUtils/ZdcEventInfo.h
"
29
30
//==================================================================================================
31
ZdcRecRun3::ZdcRecRun3
(
const
std::string& name, ISvcLocator* pSvcLocator) :
32
AthAlgorithm
(name, pSvcLocator)
33
{}
34
35
//==================================================================================================
36
37
//==================================================================================================
38
ZdcRecRun3::~ZdcRecRun3
() {}
39
//==================================================================================================
40
41
//==================================================================================================
42
StatusCode
ZdcRecRun3::initialize
()
43
{
44
MsgStream mLog(msgSvc(), name());
45
46
// Reconstruction Tool chain
47
48
ATH_CHECK
(
m_zdcTools
.retrieve() );
49
50
ATH_CHECK
(
m_zdcModuleContainerName
.initialize() );
51
ATH_CHECK
(
m_zdcSumContainerName
.initialize() );
52
53
if
(
m_ownPolicy
==
SG::OWN_ELEMENTS
)
54
mLog << MSG::DEBUG <<
"...will OWN its cells."
<<
endmsg
;
55
else
56
mLog << MSG::DEBUG <<
"...will VIEW its cells."
<<
endmsg
;
57
58
59
mLog << MSG::DEBUG <<
"--> ZDC: ZdcRecRun3 initialization complete"
<<
endmsg
;
60
61
if
(
m_DAQMode
>=
ZdcEventInfo::numDAQModes
) {
62
ATH_MSG_ERROR
(
"Invalid DAQ mode, mode = "
<<
m_DAQMode
);
63
return
StatusCode::FAILURE;
64
}
65
66
ATH_MSG_DEBUG
(
"Configuration:"
);
67
ATH_MSG_DEBUG
(
"ForcedEventType = "
<<
m_forcedEventType
);
68
ATH_MSG_DEBUG
(
"DAQMode = "
<<
m_DAQMode
);
69
70
// initialize eventInfo access
71
//
72
ATH_CHECK
(
m_eventInfoKey
.initialize());
73
ATH_CHECK
(
m_eventInfoDecorKey
.initialize() );
74
75
// Initialize writedecor keys
76
//
77
std::string sumContainerName =
"ZdcSums"
;
78
m_ZdcEventType
= sumContainerName +
".EventType"
;
79
ATH_CHECK
(
m_ZdcEventType
.initialize());
80
81
m_ZdcDAQMode
= sumContainerName +
".DAQMode"
;
82
ATH_CHECK
(
m_ZdcDAQMode
.initialize());
83
84
return
StatusCode::SUCCESS;
85
}
86
//==================================================================================================
87
88
//==================================================================================================
89
StatusCode
ZdcRecRun3::execute
(
const
EventContext& ctx)
90
{
91
92
ATH_MSG_DEBUG
(
"In ZdRecRun3"
);
93
94
95
ATH_MSG_DEBUG
(
"--> ZDC: ZdcRecRun3 execute starting on "
96
<< ctx.evt()
97
<<
"th event"
);
98
99
// Get event info
100
//
101
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
102
if
(!eventInfo.
isValid
()) {
103
ATH_MSG_WARNING
(
"EventInfo not valid"
);
104
return
StatusCode::FAILURE;
105
}
106
107
if
(eventInfo->errorState(
xAOD::EventInfo::ForwardDet
)==
xAOD::EventInfo::Error
)
108
{
109
if
(eventInfo->isEventFlagBitSet(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::DECODINGERROR
))
110
{
111
bool
rpdErr = eventInfo->isEventFlagBitSet(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::RPDDECODINGERROR
);
112
bool
zdcErr = eventInfo->isEventFlagBitSet(
xAOD::EventInfo::ForwardDet
,
ZdcEventInfo::ZDCDECODINGERROR
);
113
std::string errs =
""
;
114
if
(zdcErr) errs +=
"* ZDC "
;
115
if
(rpdErr) errs +=
"* RPD "
;
116
ATH_MSG_WARNING
(
"Decoding error in LUCROD decoding:"
+errs);
117
// We no longer abandon the event now - the separate RPD and ZDC analysis tools check the errors and abandon the event separately.
118
// return StatusCode::SUCCESS;
119
}
120
}
121
122
ATH_MSG_DEBUG
(
"Event info type=IS_CALIBRATION:"
<< eventInfo->eventType(
xAOD::EventInfo::IS_CALIBRATION
));
123
124
//
125
// Figure out what kind of event this is
126
//
127
unsigned
int
eventType =
ZdcEventInfo::ZdcEventUnknown
;
128
129
if
(
m_forcedEventType
!=
ZdcEventInfo::ZdcEventUnknown
) {
130
eventType =
m_forcedEventType
;
131
}
132
else
{
133
if
(
m_DAQMode
==
ZdcEventInfo::Standalone
) {
134
//
135
// Problem: we can't determine event type in standalone mode
136
//
137
ATH_MSG_FATAL
(
"Event type must be set in configuration in standalone mode"
);
138
return
StatusCode::FAILURE;
139
}
140
else
if
(
m_DAQMode
==
ZdcEventInfo::MCDigits
|| eventInfo->eventType(
xAOD::EventInfo::IS_SIMULATION
)) {
141
eventType =
ZdcEventInfo::ZdcSimulation
;
142
}
143
else
if
((
m_DAQMode
==
ZdcEventInfo::PhysicsPEB
) || (
m_DAQMode
==
ZdcEventInfo::CombinedPhysics
)) {
144
if
(eventInfo->eventType(
xAOD::EventInfo::IS_CALIBRATION
)) {
145
//
146
// For now presume LED event. Eventually add check for calreq trigger
147
//
148
eventType =
ZdcEventInfo::ZdcEventLED
;
149
}
150
else
{
151
eventType =
ZdcEventInfo::ZdcEventPhysics
;
152
}
153
}
154
}
155
156
SG::ReadHandle<xAOD::ZdcModuleContainer>
moduleContainer (
m_zdcModuleContainerName
, ctx);
157
SG::ReadHandle<xAOD::ZdcModuleContainer>
moduleSumContainer (
m_zdcSumContainerName
, ctx);
158
159
160
// Find the sum container for "side 0" which handles event-level information
161
//
162
for
(
const
auto
modSum : *(moduleSumContainer.
get
())) {
163
//
164
// Module sum object with side == 0 contains event-level information
165
//
166
if
(modSum->zdcSide() == 0) {
167
//
168
// Add the event type and daq mode as aux decors, but not if this information is already written (e.g. if we are using an existing xAOD)
169
//
170
static
const
SG::ConstAccessor<unsigned int>
eventTypeAcc(
"EventType"
);
171
if
(!eventTypeAcc.
isAvailable
(*modSum))
172
{
173
SG::WriteDecorHandle<xAOD::ZdcModuleContainer,unsigned int>
eventTypeHandle(
m_ZdcEventType
, ctx);
174
eventTypeHandle(*modSum) = eventType;
175
176
SG::WriteDecorHandle<xAOD::ZdcModuleContainer,unsigned int>
DAQModeHandle(
m_ZdcDAQMode
, ctx);
177
DAQModeHandle(*modSum) =
m_DAQMode
;
178
}
179
}
180
}
181
182
183
// Loop over all tools and perform the "reco"
184
//
185
for
(ToolHandle<ZDC::IZdcAnalysisTool>& tool :
m_zdcTools
)
186
{
187
ATH_CHECK
( tool->recoZdcModules(*moduleContainer.
get
(), *moduleSumContainer.
get
()) );
188
}
189
190
return
StatusCode::SUCCESS;
191
192
}
193
//==================================================================================================
194
195
//==================================================================================================
196
StatusCode
ZdcRecRun3::finalize
()
197
{
198
199
ATH_MSG_DEBUG
(
"--> ZDC: ZdcRecRun3 finalize complete"
);
200
201
return
StatusCode::SUCCESS;
202
203
}
204
//==================================================================================================
205
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_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
StoreGateSvc.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
WriteHandle.h
Handle class for recording to StoreGate.
ZdcEventInfo.h
Define enumerations for event-level ZDC data.
ZdcModuleAuxContainer.h
ZdcModuleToString.h
ZdcRecRun3.h
ZdcToString.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
ZdcRecRun3::ZdcRecRun3
ZdcRecRun3(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ZdcRecRun3.cxx:31
ZdcRecRun3::m_DAQMode
Gaudi::Property< unsigned int > m_DAQMode
Definition
ZdcRecRun3.h:62
ZdcRecRun3::m_zdcSumContainerName
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
Definition
ZdcRecRun3.h:73
ZdcRecRun3::m_zdcTools
ToolHandleArray< ZDC::IZdcAnalysisTool > m_zdcTools
Definition
ZdcRecRun3.h:86
ZdcRecRun3::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
ZdcRecRun3.h:75
ZdcRecRun3::m_ownPolicy
Gaudi::Property< int > m_ownPolicy
Definition
ZdcRecRun3.h:67
ZdcRecRun3::m_ZdcDAQMode
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_ZdcDAQMode
Definition
ZdcRecRun3.h:80
ZdcRecRun3::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition
ZdcRecRun3.h:76
ZdcRecRun3::~ZdcRecRun3
~ZdcRecRun3()
Definition
ZdcRecRun3.cxx:38
ZdcRecRun3::m_ZdcEventType
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_ZdcEventType
Definition
ZdcRecRun3.h:78
ZdcRecRun3::execute
StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
ZdcRecRun3.cxx:89
ZdcRecRun3::initialize
StatusCode initialize() override
Definition
ZdcRecRun3.cxx:42
ZdcRecRun3::finalize
StatusCode finalize() override
Definition
ZdcRecRun3.cxx:196
ZdcRecRun3::m_forcedEventType
Gaudi::Property< unsigned int > m_forcedEventType
Definition
ZdcRecRun3.h:64
ZdcRecRun3::m_zdcModuleContainerName
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
Definition
ZdcRecRun3.h:70
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
xAOD::EventInfo_v1::IS_CALIBRATION
@ IS_CALIBRATION
true: calibration, false: physics
Definition
EventInfo_v1.h:155
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition
EventInfo_v1.h:151
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition
OwnershipPolicy.h:17
ZdcEventInfo::ZdcEventLED
@ ZdcEventLED
Definition
ZdcEventInfo.h:16
ZdcEventInfo::ZdcEventUnknown
@ ZdcEventUnknown
Definition
ZdcEventInfo.h:16
ZdcEventInfo::ZdcSimulation
@ ZdcSimulation
Definition
ZdcEventInfo.h:16
ZdcEventInfo::ZdcEventPhysics
@ ZdcEventPhysics
Definition
ZdcEventInfo.h:16
ZdcEventInfo::RPDDECODINGERROR
@ RPDDECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::ZDCDECODINGERROR
@ ZDCDECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::DECODINGERROR
@ DECODINGERROR
Definition
ZdcEventInfo.h:19
ZdcEventInfo::CombinedPhysics
@ CombinedPhysics
Definition
ZdcEventInfo.h:17
ZdcEventInfo::numDAQModes
@ numDAQModes
Definition
ZdcEventInfo.h:17
ZdcEventInfo::PhysicsPEB
@ PhysicsPEB
Definition
ZdcEventInfo.h:17
ZdcEventInfo::Standalone
@ Standalone
Definition
ZdcEventInfo.h:17
ZdcEventInfo::MCDigits
@ MCDigits
Definition
ZdcEventInfo.h:17
Generated on
for ATLAS Offline Software by
1.17.0