ATLAS Offline Software
Loading...
Searching...
No Matches
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"
23
24#include "ZdcRec/ZdcRecRun3.h"
29
30//==================================================================================================
31ZdcRecRun3::ZdcRecRun3(const std::string& name, ISvcLocator* pSvcLocator) :
32 AthAlgorithm(name, pSvcLocator)
33{}
34
35//==================================================================================================
36
37//==================================================================================================
39//==================================================================================================
40
41//==================================================================================================
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
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
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//==================================================================================================
89StatusCode 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 //
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
130 eventType = m_forcedEventType;
131 }
132 else {
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 }
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 {
152 }
153 }
154 }
155
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 {
174 eventTypeHandle(*modSum) = eventType;
175
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//==================================================================================================
197{
198
199 ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3 finalize complete" );
200
201 return StatusCode::SUCCESS;
202
203}
204//==================================================================================================
205
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
Define enumerations for event-level ZDC data.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
Handle class for adding a decoration to an object.
ZdcRecRun3(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< unsigned int > m_DAQMode
Definition ZdcRecRun3.h:62
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
Definition ZdcRecRun3.h:73
ToolHandleArray< ZDC::IZdcAnalysisTool > m_zdcTools
Definition ZdcRecRun3.h:86
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition ZdcRecRun3.h:75
Gaudi::Property< int > m_ownPolicy
Definition ZdcRecRun3.h:67
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_ZdcDAQMode
Definition ZdcRecRun3.h:80
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition ZdcRecRun3.h:76
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_ZdcEventType
Definition ZdcRecRun3.h:78
StatusCode execute(const EventContext &ctx) override
Execute method.
StatusCode initialize() override
StatusCode finalize() override
Gaudi::Property< unsigned int > m_forcedEventType
Definition ZdcRecRun3.h:64
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
Definition ZdcRecRun3.h:70
@ ForwardDet
The forward detectors.
@ Error
The sub-detector issued an error.
@ IS_CALIBRATION
true: calibration, false: physics
@ IS_SIMULATION
true: simulation, false: data
@ OWN_ELEMENTS
this data object owns its elements