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//==================================================================================================
90{
91
92 ATH_MSG_DEBUG("In ZdRecRun3");
93
94 const EventContext& ctx = Gaudi::Hive::currentContext();
95
96 ATH_MSG_DEBUG ("--> ZDC: ZdcRecRun3 execute starting on "
97 << ctx.evt()
98 << "th event");
99
100 // Get event info
101 //
103 if (!eventInfo.isValid()) return StatusCode::FAILURE;
104
105 if (eventInfo->errorState(xAOD::EventInfo::ForwardDet)==xAOD::EventInfo::Error)
106 {
107 if (eventInfo->isEventFlagBitSet(xAOD::EventInfo::ForwardDet, ZdcEventInfo::DECODINGERROR ))
108 {
109 bool rpdErr = eventInfo->isEventFlagBitSet(xAOD::EventInfo::ForwardDet, ZdcEventInfo::RPDDECODINGERROR );
110 bool zdcErr = eventInfo->isEventFlagBitSet(xAOD::EventInfo::ForwardDet, ZdcEventInfo::ZDCDECODINGERROR );
111 std::string errs = "";
112 if (zdcErr) errs += "* ZDC ";
113 if (rpdErr) errs += "* RPD ";
114 ATH_MSG_WARNING("Decoding error in LUCROD decoding:"+errs);
115 // We no longer abandon the event now - the separate RPD and ZDC analysis tools check the errors and abandon the event separately.
116 // return StatusCode::SUCCESS;
117 }
118 }
119
120 ATH_MSG_DEBUG("Event info type=IS_CALIBRATION:" << eventInfo->eventType(xAOD::EventInfo::IS_CALIBRATION));
121
122 //
123 // Figure out what kind of event this is
124 //
125 unsigned int eventType = ZdcEventInfo::ZdcEventUnknown;
126
128 eventType = m_forcedEventType;
129 }
130 else {
132 //
133 // Problem: we can't determine event type in standalone mode
134 //
135 ATH_MSG_FATAL("Event type must be set in configuration in standalone mode");
136 return StatusCode::FAILURE;
137 }
138 else if (m_DAQMode == ZdcEventInfo::MCDigits || eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
139 eventType = ZdcEventInfo::ZdcSimulation;
140 }
142 if (eventInfo->eventType(xAOD::EventInfo::IS_CALIBRATION)) {
143 //
144 // For now presume LED event. Eventually add check for calreq trigger
145 //
146 eventType = ZdcEventInfo::ZdcEventLED;
147 }
148 else {
150 }
151 }
152 }
153
156
157
158 // Find the sum container for "side 0" which handles event-level information
159 //
160 for (const auto modSum : *(moduleSumContainer.get())) {
161 //
162 // Module sum object with side == 0 contains event-level information
163 //
164 if (modSum->zdcSide() == 0) {
165 //
166 // 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)
167 //
168 static const SG::ConstAccessor<unsigned int> eventTypeAcc("EventType");
169 if (!eventTypeAcc.isAvailable(*modSum))
170 {
172 eventTypeHandle(*modSum) = eventType;
173
175 DAQModeHandle(*modSum) = m_DAQMode;
176 }
177 }
178 }
179
180
181 // Loop over all tools and perform the "reco"
182 //
183 for (ToolHandle<ZDC::IZdcAnalysisTool>& tool : m_zdcTools)
184 {
185 ATH_CHECK( tool->recoZdcModules(*moduleContainer.get(), *moduleSumContainer.get()) );
186 }
187
188 return StatusCode::SUCCESS;
189
190}
191//==================================================================================================
192
193//==================================================================================================
195{
196
197 ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3 finalize complete" );
198
199 return StatusCode::SUCCESS;
200
201}
202//==================================================================================================
203
#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 with parameters:
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
StatusCode execute() override
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 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