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  {
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  }
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 {
149  eventType = ZdcEventInfo::ZdcEventPhysics;
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
167  //
169  eventTypeHandle(*modSum) = eventType;
170 
172  DAQModeHandle(*modSum) = m_DAQMode;
173  }
174  }
175 
176 
177  // Loop over all tools and perform the "reco"
178  //
179  for (ToolHandle<ZDC::IZdcAnalysisTool>& tool : m_zdcTools)
180  {
181  ATH_CHECK( tool->recoZdcModules(*moduleContainer.get(), *moduleSumContainer.get()) );
182  }
183 
184  return StatusCode::SUCCESS;
185 
186 }
187 //==================================================================================================
188 
189 //==================================================================================================
191 {
192 
193  ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3 finalize complete" );
194 
195  return StatusCode::SUCCESS;
196 
197 }
198 //==================================================================================================
199 
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:190
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
ZdcEventInfo::ZDCDECODINGERROR
@ ZDCDECODINGERROR
Definition: ZdcEventInfo.h:19
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:100
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:228
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.
ZdcEventInfo::RPDDECODINGERROR
@ RPDDECODINGERROR
Definition: ZdcEventInfo.h:19