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  {
97  {
98  ATH_MSG_WARNING( " cannot set EventInfo error state for ForwardDet " );
99  }
101  {
102  ATH_MSG_WARNING( " cannot set flag bit for ForwardDet " );
103  }
104  }
105 
106  //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
107  std::unique_ptr<xAOD::ZdcModuleContainer> moduleContainer( new xAOD::ZdcModuleContainer());
108  std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleAuxContainer( new xAOD::ZdcModuleAuxContainer() );
109  moduleContainer->setStore( moduleAuxContainer.get() );
110 
111  //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
112  std::unique_ptr<xAOD::ZdcModuleContainer> moduleSumContainer( new xAOD::ZdcModuleContainer());
113  std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleSumAuxContainer( new xAOD::ZdcModuleAuxContainer() );
114  moduleSumContainer->setStore( moduleSumAuxContainer.get() );
115 
116  ATH_MSG_DEBUG("Trying to convert!");
117 
118  // rearrange ZDC channels and perform fast reco on all channels (including non-big tubes)
119  int ncha = m_ChannelTool->convertLucrod2ZM(zldContainer.get(), moduleContainer.get(), moduleSumContainer.get() );
120  ATH_MSG_DEBUG("m_ChannelTool->convertLucrod2ZM returned " << ncha << " channels");
121 
122  ATH_MSG_DEBUG("Dumping modules");
123  ATH_MSG_DEBUG( ZdcModuleToString(*moduleContainer) );
124  ATH_MSG_DEBUG("Dumping module sums");
125  ATH_MSG_DEBUG( ZdcModuleToString(*moduleSumContainer) );
126 
127  // eventually reconstruct RPD, using ML libraries
128  // ATH_CHECK( m_rpdTool...)
129 
131  ATH_CHECK( moduleContainerH.record (std::move(moduleContainer),
132  std::move(moduleAuxContainer)) );
133 
135  ATH_CHECK( moduleSumContainerH.record (std::move(moduleSumContainer),
136  std::move(moduleSumAuxContainer)) );
137 
138  return StatusCode::SUCCESS;
139 
140 }
141 //==================================================================================================
142 
143 //==================================================================================================
145 {
146 
147  ATH_MSG_DEBUG( "--> ZDC: ZdcRecRun3Decode finalize complete" );
148 
149  return StatusCode::SUCCESS;
150 
151 }
152 //==================================================================================================
153 
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
ZdcRecRun3Decode::~ZdcRecRun3Decode
~ZdcRecRun3Decode()
Definition: ZdcRecRun3Decode.cxx:41
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::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
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
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:581
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition: EventInfo_v1.h:338
AthAlgorithm
Definition: AthAlgorithm.h:47
ZdcToString.h
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:144
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
ZdcRecRun3Decode::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ZdcRecRun3Decode.h:59
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
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.
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.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
ZdcRecRun3Decode::execute
StatusCode execute() override
Definition: ZdcRecRun3Decode.cxx:73