ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcRecRun3Decode.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * ZdcRecRun3Decode.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"
21
27
28
29//==================================================================================================
30ZdcRecRun3Decode::ZdcRecRun3Decode(const std::string& name, ISvcLocator* pSvcLocator) :
31
32 AthAlgorithm(name, pSvcLocator)
33{
34}
35
36//==================================================================================================
37
38//==================================================================================================
40//==================================================================================================
41
42//==================================================================================================
44{
45 MsgStream mLog(msgSvc(), name());
46
47 // Reconstruction Tool
48 ATH_CHECK( m_ChannelTool.retrieve() );
49
50
51 // Reconstruction Tool
52
53 ATH_CHECK( m_zdcModuleContainerName.initialize() );
54 ATH_CHECK( m_zdcSumContainerName.initialize() );
56 ATH_CHECK( m_eventInfoKey.initialize() );
57 ATH_CHECK( m_eventInfoDecorKey.initialize() );
58
60 mLog << MSG::DEBUG << "...will OWN its cells." << endmsg;
61 else
62 mLog << MSG::DEBUG << "...will VIEW its cells." << endmsg;
63
64 if(m_DecodeRunMode == 0){
65 mLog << MSG::DEBUG << "--> ZDC: Running in ZDC+RPD mode" << endmsg;
66 m_nFragments.set(6); // default
67 }
68
69 else if(m_DecodeRunMode == 1){
70 mLog << MSG::DEBUG << "--> ZDC: Running in LIS only mode" << endmsg;
71 m_nFragments.set(1);
72 }
73 else if(m_DecodeRunMode == 2){
74 mLog << MSG::DEBUG << "--> ZDC: Running in ZDC+RPD + LIS mode" << endmsg;
75 m_nFragments.set(7);
76 }
77 else {
78 mLog << MSG::ERROR << "--> ZDC: Unknown DecodeRunMode " << m_DecodeRunMode.value() << ", should be 0, 1, or 2. Exiting." << endmsg;
79 return StatusCode::FAILURE;
80 }
81
82
83 mLog << MSG::DEBUG << "--> ZDC: ZdcRecRun3Decode initialization complete" << endmsg;
84
85 return StatusCode::SUCCESS;
86}
87//==================================================================================================
88
89//==================================================================================================
90StatusCode ZdcRecRun3Decode::execute(const EventContext& ctx)
91{
92
93 ATH_MSG_DEBUG("In ZdRecRun3");
94
95
96 ATH_MSG_DEBUG ("--> ZDC: ZdcRecRun3Decode execute starting on "
97 << ctx.evt()
98 << "th event");
99
100 //Look for the container presence
101 if (m_zldContainerName.empty()) {
102 return StatusCode::SUCCESS;
103 }
104
105 ATH_MSG_DEBUG("Trying to get LUCROD DATA!");
107 ATH_MSG_DEBUG("Did I get LUCROD DATA?");
108
109
110 if (zldContainer->size() < m_nFragments)
111 {
112 int zdcLucrod = 0;
113 int rpdLucrod = 0;
114 int lisLucrod = 0;
115 for (auto zld : *zldContainer)
116 {
117 uint32_t lucrod_id = zld->GetLucrodID();
118 if (lucrod_id == ZdcEventInfo::LucrodLowGain || lucrod_id == ZdcEventInfo::LucrodHighGain) // ZDC LUCRODs
119 {
120 zdcLucrod++;
121 }
122 else if (lucrod_id == ZdcEventInfo::LucrodRPD1A
123 || lucrod_id == ZdcEventInfo::LucrodRPD1C
124 || lucrod_id == ZdcEventInfo::LucrodRPD2A
125 || lucrod_id == ZdcEventInfo::LucrodRPD2C)
126 {
127 rpdLucrod++;
128 }
129 else if (lucrod_id == ZdcEventInfo::LucrodLIS) // LIS LUCROD
130 {
131 lisLucrod++;
132 }
133 else
134 {
135 ATH_MSG_WARNING("Unidentified LUCROD ID = " << lucrod_id);
136 }
137 }
139 if (!eventInfo->updateErrorState(xAOD::EventInfo::ForwardDet,xAOD::EventInfo::Error))
140 {
141 ATH_MSG_WARNING( " cannot set EventInfo error state for ForwardDet " );
142 }
143 if (!eventInfo->updateEventFlagBit(xAOD::EventInfo::ForwardDet,ZdcEventInfo::DECODINGERROR))
144 {
145 ATH_MSG_WARNING( " cannot set flag bit for ForwardDet " );
146 }
147 if (rpdLucrod < ZdcEventInfo::nTotalRpdLucrod && m_DecodeRunMode != 1)
148 {
149 if (!eventInfo->updateEventFlagBit(xAOD::EventInfo::ForwardDet,ZdcEventInfo::RPDDECODINGERROR))
150 {
151 ATH_MSG_WARNING( " cannot set RPDDECODINGERROR flag bit for ForwardDet " );
152 }
153 }
154 if (zdcLucrod < ZdcEventInfo::nTotalZdcLucrod && m_DecodeRunMode != 1)
155 {
156 if (!eventInfo->updateEventFlagBit(xAOD::EventInfo::ForwardDet,ZdcEventInfo::ZDCDECODINGERROR))
157 {
158 ATH_MSG_WARNING( " cannot set ZDCDECODINGERROR flag bit for ForwardDet " );
159 }
160 }
161 if (lisLucrod < ZdcEventInfo::nTotalLisLucrod && (m_DecodeRunMode == 1 || m_DecodeRunMode == 2))
162 {
163 if (!eventInfo->updateEventFlagBit(xAOD::EventInfo::ForwardDet,ZdcEventInfo::LISDECODINGERROR))
164 {
165 ATH_MSG_WARNING( " cannot set LISDECODINGERROR flag bit for ForwardDet " );
166 }
167 }
168 }
169
170 //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
171 std::unique_ptr<xAOD::ZdcModuleContainer> moduleContainer( new xAOD::ZdcModuleContainer());
172 std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleAuxContainer( new xAOD::ZdcModuleAuxContainer() );
173 moduleContainer->setStore( moduleAuxContainer.get() );
174
175 //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
176 std::unique_ptr<xAOD::ZdcModuleContainer> moduleSumContainer( new xAOD::ZdcModuleContainer());
177 std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleSumAuxContainer( new xAOD::ZdcModuleAuxContainer() );
178 moduleSumContainer->setStore( moduleSumAuxContainer.get() );
179
180 ATH_MSG_DEBUG("Trying to convert!");
181
182 // rearrange ZDC channels and perform fast reco on all channels (including non-big tubes)
183 int ncha = m_ChannelTool->convertLucrod2ZM(zldContainer.get(), moduleContainer.get(), moduleSumContainer.get() );
184 ATH_MSG_DEBUG("m_ChannelTool->convertLucrod2ZM returned " << ncha << " channels");
185
186 ATH_MSG_DEBUG("Dumping modules");
187 ATH_MSG_DEBUG( ZdcModuleToString(*moduleContainer) );
188 ATH_MSG_DEBUG("Dumping module sums");
189 ATH_MSG_DEBUG( ZdcModuleToString(*moduleSumContainer) );
190
191 // eventually reconstruct RPD, using ML libraries
192 // ATH_CHECK( m_rpdTool...)
193
195 ATH_CHECK( moduleContainerH.record (std::move(moduleContainer),
196 std::move(moduleAuxContainer)) );
197
199 ATH_CHECK( moduleSumContainerH.record (std::move(moduleSumContainer),
200 std::move(moduleSumAuxContainer)) );
201
202 return StatusCode::SUCCESS;
203
204}
205//==================================================================================================
206
207//==================================================================================================
209{
210
211 ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3Decode finalize complete" );
212
213 return StatusCode::SUCCESS;
214
215}
216//==================================================================================================
217
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Define enumerations for event-level ZDC data.
std::string ZdcModuleToString(const xAOD::ZdcModule &zm)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ZdcRecRun3Decode(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
StatusCode initialize() override
StatusCode finalize() override
SG::ReadHandleKey< ZdcLucrodDataContainer > m_zldContainerName
StatusCode execute(const EventContext &ctx) override
Execute method.
SG::WriteHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Gaudi::Property< int > m_DecodeRunMode
Gaudi::Property< int > m_ownPolicy
Gaudi::Property< unsigned int > m_nFragments
ToolHandle< ZdcRecChannelToolLucrod > m_ChannelTool
SG::WriteHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
@ ForwardDet
The forward detectors.
@ Error
The sub-detector issued an error.
@ OWN_ELEMENTS
this data object owns its elements
ZdcModuleContainer_v1 ZdcModuleContainer
ZdcModuleAuxContainer_v2 ZdcModuleAuxContainer