ATLAS Offline Software
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"
21 #include "StoreGate/ReadHandle.h"
23 
24 #include "ZdcRec/ZdcRecRun3.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 //==================================================================================================
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  //
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 
106  {
108  {
109  ATH_MSG_WARNING("Error in LUCROD decoding");
110  return StatusCode::SUCCESS;
111  }
112  }
113 
114  ATH_MSG_DEBUG("Event info type=IS_CALIBRATION:" << eventInfo->eventType(xAOD::EventInfo::IS_CALIBRATION));
115 
116  //
117  // Figure out what kind of event this is
118  //
119  unsigned int eventType = ZdcEventInfo::ZdcEventUnknown;
120 
122  eventType = m_forcedEventType;
123  }
124  else {
126  //
127  // Problem: we can't determine event type in standalone mode
128  //
129  ATH_MSG_FATAL("Event type must be set in configuration in standalone mode");
130  return StatusCode::FAILURE;
131  }
133  eventType = ZdcEventInfo::ZdcSimulation;
134  }
136  if (eventInfo->eventType(xAOD::EventInfo::IS_CALIBRATION)) {
137  //
138  // For now presume LED event. Eventually add check for calreq trigger
139  //
140  eventType = ZdcEventInfo::ZdcEventLED;
141  }
142  else {
143  eventType = ZdcEventInfo::ZdcEventPhysics;
144  }
145  }
146  }
147 
150 
151 
152  // Find the sum container for "side 0" which handles event-level information
153  //
154  for (const auto modSum : *(moduleSumContainer.get())) {
155  //
156  // Module sum object with side == 0 contains event-level information
157  //
158  if (modSum->zdcSide() == 0) {
159  //
160  // Add the event type and daq mode as aux decors
161  //
163  eventTypeHandle(*modSum) = eventType;
164 
166  DAQModeHandle(*modSum) = m_DAQMode;
167  }
168  }
169 
170 
171  // Loop over all tools and perform the "reco"
172  //
173  for (ToolHandle<ZDC::IZdcAnalysisTool>& tool : m_zdcTools)
174  {
175  ATH_CHECK( tool->recoZdcModules(*moduleContainer.get(), *moduleSumContainer.get()) );
176  }
177 
178  return StatusCode::SUCCESS;
179 
180 }
181 //==================================================================================================
182 
183 //==================================================================================================
185 {
186 
187  ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3 finalize complete" );
188 
189  return StatusCode::SUCCESS;
190 
191 }
192 //==================================================================================================
193 
ZdcRecRun3::execute
StatusCode execute() override
Definition: ZdcRecRun3.cxx:89
ZdcEventInfo::ZdcEventPhysics
@ ZdcEventPhysics
Definition: ZdcEventInfo.h:16
ZdcRecRun3::m_zdcModuleContainerName
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
Definition: ZdcRecRun3.h:70
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ZdcRecRun3.h
ZdcRecRun3::ZdcRecRun3
ZdcRecRun3(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZdcRecRun3.cxx:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ZdcRecRun3::m_DAQMode
Gaudi::Property< unsigned int > m_DAQMode
Definition: ZdcRecRun3.h:62
xAOD::EventInfo_v1::IS_CALIBRATION
@ IS_CALIBRATION
true: calibration, false: physics
Definition: EventInfo_v1.h:155
ZdcEventInfo::ZdcEventUnknown
@ ZdcEventUnknown
Definition: ZdcEventInfo.h:16
ZdcEventInfo::DECODINGERROR
@ DECODINGERROR
Definition: ZdcEventInfo.h:19
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
ZdcRecRun3::m_ZdcEventType
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_ZdcEventType
Definition: ZdcRecRun3.h:78
ZdcEventInfo::CombinedPhysics
@ CombinedPhysics
Definition: ZdcEventInfo.h:17
ZdcEventInfo::numDAQModes
@ numDAQModes
Definition: ZdcEventInfo.h:17
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
ZdcRecRun3::finalize
StatusCode finalize() override
Definition: ZdcRecRun3.cxx:184
ZdcModuleAuxContainer.h
ZdcEventInfo::PhysicsPEB
@ PhysicsPEB
Definition: ZdcEventInfo.h:17
ZdcRecRun3::m_ownPolicy
Gaudi::Property< int > m_ownPolicy
Definition: ZdcRecRun3.h:67
WriteHandle.h
Handle class for recording to StoreGate.
ZdcRecRun3::~ZdcRecRun3
~ZdcRecRun3()
Definition: ZdcRecRun3.cxx:38
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ZdcRecRun3::m_ZdcDAQMode
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_ZdcDAQMode
Definition: ZdcRecRun3.h:80
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
ZdcRecRun3::initialize
StatusCode initialize() override
Definition: ZdcRecRun3.cxx:42
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ZdcRecRun3::m_zdcTools
ToolHandleArray< ZDC::IZdcAnalysisTool > m_zdcTools
Definition: ZdcRecRun3.h:86
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
ZdcEventInfo::ZdcSimulation
@ ZdcSimulation
Definition: ZdcEventInfo.h:16
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition: EventInfo_v1.h:338
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ZdcToString.h
ZdcEventInfo::MCDigits
@ MCDigits
Definition: ZdcEventInfo.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
ZdcRecRun3::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: ZdcRecRun3.h:76
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ZdcModuleToString.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ZdcRecRun3::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ZdcRecRun3.h:75
DEBUG
#define DEBUG
Definition: page_access.h:11
ZdcEventInfo::Standalone
@ Standalone
Definition: ZdcEventInfo.h:17
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
xAOD::EventInfo_v1::isEventFlagBitSet
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Definition: EventInfo_v1.cxx:703
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ZdcRecRun3::m_zdcSumContainerName
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
Definition: ZdcRecRun3.h:73
ReadHandle.h
Handle class for reading from StoreGate.
StoreGateSvc.h
ZdcEventInfo.h
Define enumerations for event-level ZDC data.
ZdcRecRun3::m_forcedEventType
Gaudi::Property< unsigned int > m_forcedEventType
Definition: ZdcRecRun3.h:64
ZdcEventInfo::ZdcEventLED
@ ZdcEventLED
Definition: ZdcEventInfo.h:16
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.