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