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