ATLAS Offline Software
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"
18 #include "StoreGate/StoreGateSvc.h"
19 #include "StoreGate/WriteHandle.h"
20 #include "StoreGate/ReadHandle.h"
21 
26 #include "ZdcUtils/ZdcEventInfo.h"
27 
28 
29 //==================================================================================================
30 ZdcRecRun3Decode::ZdcRecRun3Decode(const std::string& name, ISvcLocator* pSvcLocator) :
31 
32  AthAlgorithm(name, pSvcLocator),
33  m_ownPolicy(static_cast<int> (SG::OWN_ELEMENTS))
34 {
35  declareProperty("OwnPolicy",m_ownPolicy) ;
36 }
37 
38 //==================================================================================================
39 
40 //==================================================================================================
42 //==================================================================================================
43 
44 //==================================================================================================
46 {
47  MsgStream mLog(msgSvc(), name());
48 
49  // Reconstruction Tool
50  ATH_CHECK( m_ChannelTool.retrieve() );
51 
52  // Reconstruction Tool
53 
54  ATH_CHECK( m_zdcModuleContainerName.initialize() );
55  ATH_CHECK( m_zdcSumContainerName.initialize() );
59 
61  mLog << MSG::DEBUG << "...will OWN its cells." << endmsg;
62  else
63  mLog << MSG::DEBUG << "...will VIEW its cells." << endmsg;
64 
65 
66  mLog << MSG::DEBUG << "--> ZDC: ZdcRecRun3Decode initialization complete" << endmsg;
67 
68  return StatusCode::SUCCESS;
69 }
70 //==================================================================================================
71 
72 //==================================================================================================
74 {
75 
76  ATH_MSG_DEBUG("In ZdRecRun3");
77 
78  const EventContext& ctx = Gaudi::Hive::currentContext();
79 
80  ATH_MSG_DEBUG ("--> ZDC: ZdcRecRun3Decode execute starting on "
81  << ctx.evt()
82  << "th event");
83 
84  //Look for the container presence
85  if (m_zldContainerName.empty()) {
86  return StatusCode::SUCCESS;
87  }
88 
89  ATH_MSG_DEBUG("Trying to get LUCROD DATA!");
91  ATH_MSG_DEBUG("Did I get LUCROD DATA?");
92 
93  if (zldContainer->size() < m_nFragments)
94  {
95  int zdcLucrod = 0;
96  int rpdLucrod = 0;
97  for (auto zld : *zldContainer)
98  {
99  uint32_t lucrod_id = zld->GetLucrodID();
100  if (lucrod_id == ZdcEventInfo::LucrodLowGain || lucrod_id == ZdcEventInfo::LucrodHighGain) // ZDC LUCRODs
101  {
102  zdcLucrod++;
103  }
104  else if (lucrod_id == ZdcEventInfo::LucrodRPD1A
105  || lucrod_id == ZdcEventInfo::LucrodRPD1C
106  || lucrod_id == ZdcEventInfo::LucrodRPD2A
107  || lucrod_id == ZdcEventInfo::LucrodRPD2C)
108  {
109  rpdLucrod++;
110  }
111  else
112  {
113  ATH_MSG_WARNING("Unidentified LUCROD ID = " << lucrod_id);
114  }
115  }
118  {
119  ATH_MSG_WARNING( " cannot set EventInfo error state for ForwardDet " );
120  }
122  {
123  ATH_MSG_WARNING( " cannot set flag bit for ForwardDet " );
124  }
125  if (rpdLucrod < ZdcEventInfo::nTotalRpdLucrod)
126  {
128  {
129  ATH_MSG_WARNING( " cannot set RPDDECODINGERROR flag bit for ForwardDet " );
130  }
131  }
132  if (zdcLucrod < ZdcEventInfo::nTotalZdcLucrod)
133  {
135  {
136  ATH_MSG_WARNING( " cannot set ZDCDECODINGERROR flag bit for ForwardDet " );
137  }
138  }
139  }
140 
141  //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
142  std::unique_ptr<xAOD::ZdcModuleContainer> moduleContainer( new xAOD::ZdcModuleContainer());
143  std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleAuxContainer( new xAOD::ZdcModuleAuxContainer() );
144  moduleContainer->setStore( moduleAuxContainer.get() );
145 
146  //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
147  std::unique_ptr<xAOD::ZdcModuleContainer> moduleSumContainer( new xAOD::ZdcModuleContainer());
148  std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleSumAuxContainer( new xAOD::ZdcModuleAuxContainer() );
149  moduleSumContainer->setStore( moduleSumAuxContainer.get() );
150 
151  ATH_MSG_DEBUG("Trying to convert!");
152 
153  // rearrange ZDC channels and perform fast reco on all channels (including non-big tubes)
154  int ncha = m_ChannelTool->convertLucrod2ZM(zldContainer.get(), moduleContainer.get(), moduleSumContainer.get() );
155  ATH_MSG_DEBUG("m_ChannelTool->convertLucrod2ZM returned " << ncha << " channels");
156 
157  ATH_MSG_DEBUG("Dumping modules");
158  ATH_MSG_DEBUG( ZdcModuleToString(*moduleContainer) );
159  ATH_MSG_DEBUG("Dumping module sums");
160  ATH_MSG_DEBUG( ZdcModuleToString(*moduleSumContainer) );
161 
162  // eventually reconstruct RPD, using ML libraries
163  // ATH_CHECK( m_rpdTool...)
164 
166  ATH_CHECK( moduleContainerH.record (std::move(moduleContainer),
167  std::move(moduleAuxContainer)) );
168 
170  ATH_CHECK( moduleSumContainerH.record (std::move(moduleSumContainer),
171  std::move(moduleSumAuxContainer)) );
172 
173  return StatusCode::SUCCESS;
174 
175 }
176 //==================================================================================================
177 
178 //==================================================================================================
180 {
181 
182  ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3Decode finalize complete" );
183 
184  return StatusCode::SUCCESS;
185 
186 }
187 //==================================================================================================
188 
ZdcRecRun3Decode.h
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::ZdcModuleAuxContainer_v2
Auxiliary store for xAOD::ZdcModuleContainer_v2.
Definition: ZdcModuleAuxContainer_v2.h:31
ZdcEventInfo::LucrodRPD2A
@ LucrodRPD2A
Definition: ZdcEventInfo.h:20
ZdcRecRun3Decode::~ZdcRecRun3Decode
~ZdcRecRun3Decode()
Definition: ZdcRecRun3Decode.cxx:41
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::EventInfo_v1::updateEventFlagBit
bool updateEventFlagBit(const EventFlagSubDet subDet, const size_t bit) const
Change detector flags with update semantics.
Definition: EventInfo_v1.cxx:746
ZdcEventInfo::LucrodHighGain
@ LucrodHighGain
Definition: ZdcEventInfo.h:20
ZdcEventInfo::DECODINGERROR
@ DECODINGERROR
Definition: ZdcEventInfo.h:19
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
ZdcEventInfo::LucrodLowGain
@ LucrodLowGain
Definition: ZdcEventInfo.h:20
ZdcRecRun3Decode::initialize
StatusCode initialize() override
Definition: ZdcRecRun3Decode.cxx:45
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
ZdcRecRun3Decode::m_nFragments
Gaudi::Property< unsigned int > m_nFragments
Definition: ZdcRecRun3Decode.h:57
WriteHandle.h
Handle class for recording to StoreGate.
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
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
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
ZdcRecRun3Decode::m_zldContainerName
SG::ReadHandleKey< ZdcLucrodDataContainer > m_zldContainerName
Definition: ZdcRecRun3Decode.h:63
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition: EventInfo_v1.h:338
AthAlgorithm
Definition: AthAlgorithm.h:47
ZdcToString.h
ZdcEventInfo::LucrodRPD1A
@ LucrodRPD1A
Definition: ZdcEventInfo.h:20
ZdcRecRun3Decode::m_ownPolicy
int m_ownPolicy
Definition: ZdcRecRun3Decode.h:56
ZdcRecRun3Decode::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: ZdcRecRun3Decode.h:60
ZdcRecRun3Decode::finalize
StatusCode finalize() override
Definition: ZdcRecRun3Decode.cxx:179
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
ZdcRecRun3Decode::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ZdcRecRun3Decode.h:59
ZdcEventInfo::LucrodRPD1C
@ LucrodRPD1C
Definition: ZdcEventInfo.h:20
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.
ZdcRecRun3Decode::m_ChannelTool
ToolHandle< ZdcRecChannelToolLucrod > m_ChannelTool
Definition: ZdcRecRun3Decode.h:72
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ZdcModuleToString.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ZdcEventInfo::nTotalRpdLucrod
@ nTotalRpdLucrod
Definition: ZdcEventInfo.h:21
DEBUG
#define DEBUG
Definition: page_access.h:11
xAOD::EventInfo_v1::updateErrorState
bool updateErrorState(const EventFlagSubDet subDet, const EventFlagErrorState state) const
Update the error state for one particular sub-detector.
Definition: EventInfo_v1.cxx:856
ZdcRecRun3Decode::m_zdcModuleContainerName
SG::WriteHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
Definition: ZdcRecRun3Decode.h:66
ReadHandle.h
Handle class for reading from StoreGate.
ZdcEventInfo::LucrodRPD2C
@ LucrodRPD2C
Definition: ZdcEventInfo.h:20
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
StoreGateSvc.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ZdcEventInfo::nTotalZdcLucrod
@ nTotalZdcLucrod
Definition: ZdcEventInfo.h:21
ZdcEventInfo.h
Define enumerations for event-level ZDC data.
ZdcRecRun3Decode::m_zdcSumContainerName
SG::WriteHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
Definition: ZdcRecRun3Decode.h:69
ZdcRecRun3Decode::ZdcRecRun3Decode
ZdcRecRun3Decode(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZdcRecRun3Decode.cxx:30
ZdcModuleToString
std::string ZdcModuleToString(const xAOD::ZdcModule &zm)
Definition: ZdcModuleToString.cxx:9
ZdcRecChannelToolLucrod.h
ZdcEventInfo::RPDDECODINGERROR
@ RPDDECODINGERROR
Definition: ZdcEventInfo.h:19
ZdcRecRun3Decode::execute
StatusCode execute() override
Definition: ZdcRecRun3Decode.cxx:73