ATLAS Offline Software
ZdcRecV2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * ZdcRecV2.cxx
7  *
8  * Created on: Nov 24, 2009
9  * Author: leite
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 "Identifier/Identifier.h"
20 
23 #include "ZdcRec/ZdcRecV2.h"
26 
28 
29 //==================================================================================================
30 ZdcRecV2::ZdcRecV2(const std::string& name, ISvcLocator* pSvcLocator) :
31 
32  AthAlgorithm(name, pSvcLocator),
33  m_storeGate("StoreGateSvc", name),
34  m_ownPolicy(static_cast<int> (SG::OWN_ELEMENTS)),
35  m_ttContainerName("ZdcTriggerTowers"),
36  m_zdcModuleContainerName("ZdcModules"),
37  m_zdcModuleAuxContainerName("ZdcModulesAux."),
38  m_ttContainer(nullptr),
39  m_eventCount(0),
40  m_complainContain(1),
41  m_complainRetrieve(1),
42  m_ChannelTool("ZdcRecChannelToolV2")
43 
44 {
45  declareProperty("OwnPolicy",m_ownPolicy) ;
46 
47  declareProperty("DigitsContainerName", m_ttContainerName, "ZdcTriggerTowers");
48  declareProperty("ZdcModuleContainerName", m_zdcModuleContainerName, "ZdcModules");
49  declareProperty("ZdcModuleAuxContainerName", m_zdcModuleAuxContainerName, "ZdcModulesAux.");
50 }
51 //==================================================================================================
52 
53 //==================================================================================================
55 //==================================================================================================
56 
57 //==================================================================================================
59 {
60  MsgStream mLog(msgSvc(), name());
61 
62  // Look up the Storegate service
63  StatusCode sc = m_storeGate.retrieve();
64  if (sc.isFailure())
65  {
66  mLog << MSG::FATAL << "--> ZDC: Unable to retrieve pointer to StoreGateSvc" << endmsg;
67  return sc;
68  }
69 
70 
71  // Reconstruction Tool
72  StatusCode scTool = m_ChannelTool.retrieve();
73  if (scTool.isFailure())
74  {
75  mLog << MSG::WARNING << "--> ZDC: Could not retrieve " << m_ChannelTool << endmsg;
76  return StatusCode::FAILURE;
77  }
78  mLog << MSG::DEBUG << "--> ZDC: SUCCESS retrieving " << m_ChannelTool << endmsg;
79 
80  // Container output name
81  //TODO: change MESSAGE !!
82  mLog << MSG::DEBUG << " Output Container Name " << m_zdcModuleContainerName << endmsg;
84  mLog << MSG::DEBUG << "...will OWN its cells." << endmsg;
85  else
86  mLog << MSG::DEBUG << "...will VIEW its cells." << endmsg;
87 
88 
89  mLog << MSG::DEBUG << "--> ZDC: ZdcRecV2 initialization complete" << endmsg;
90 
91  return StatusCode::SUCCESS;
92 }
93 //==================================================================================================
94 
95 //==================================================================================================
97 {
98 
99  MsgStream mLog(msgSvc(), name());
100  mLog << MSG::DEBUG
101  << "--> ZDC: ZdcRecV2 execute starting on "
102  << m_eventCount
103  << "th event"
104  << endmsg;
105 
106  m_eventCount++;
107 
108  //Look for the container presence
110  if (!dg) {
111  if (m_complainContain) mLog << MSG::WARNING << "--> ZDC: StoreGate does not contain " << m_ttContainerName << endmsg;
112  m_complainContain = 0;
113  return StatusCode::SUCCESS;
114  }
115 
116  // Look up the Digits "TriggerTowerContainer" in Storegate
117  StatusCode digitsLookupSC = m_storeGate->retrieve(m_ttContainer, m_ttContainerName);
118  if (digitsLookupSC.isFailure())
119  {
120  if (m_complainRetrieve)
121  mLog << MSG::WARNING
122  << "--> ZDC: Could not retrieve "
124  << " from StoreGate"
125  << endmsg;
126  m_complainRetrieve = 0;
127  return StatusCode::SUCCESS;
128  }
129 
130  if (digitsLookupSC.isSuccess() && !m_ttContainer)
131  {
132  mLog << MSG::ERROR
133  << "--> ZDC: Storegate returned zero pointer for "
135  << endmsg;
136  return StatusCode::SUCCESS;
137  }
138 
139  //Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
140  std::unique_ptr<xAOD::ZdcModuleContainer> moduleContainer( new xAOD::ZdcModuleContainer());
141  std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleAuxContainer( new xAOD::ZdcModuleAuxContainer() );
142  moduleContainer->setStore( moduleAuxContainer.get() );
143 
144  // Disabled for Run 3 since this code isn't being run anyway
145  //int ncha = m_ChannelTool->convertTT2ZM(m_ttContainer, moduleContainer.get() );
146  //msg( MSG::DEBUG ) << "Channel tool returns " << ncha << endmsg;
147 
148  msg( MSG::DEBUG ) << ZdcModuleToString(*moduleContainer) << endmsg;
149  //msg( MSG::INFO ) << ZdcModuleToString(*moduleContainer) << endmsg;
150 
151  ATH_CHECK( evtStore()->record( std::move(moduleContainer), m_zdcModuleContainerName) );
152  ATH_CHECK( evtStore()->record( std::move(moduleAuxContainer), m_zdcModuleAuxContainerName) );
153 
154  return StatusCode::SUCCESS;
155 
156 }
157 //==================================================================================================
158 
159 //==================================================================================================
161 {
162 
163  MsgStream mLog(msgSvc(),name());
164 
165  mLog << MSG::DEBUG
166  << "--> ZDC: ZdcRecV2 finalize complete"
167  << endmsg;
168 
169  return StatusCode::SUCCESS;
170 
171 }
172 //==================================================================================================
173 
ZdcRecV2::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
class member version of retrieving StoreGate
Definition: ZdcRecV2.h:63
checkCoolLatestUpdate.dg
dg
Definition: checkCoolLatestUpdate.py:9
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::ZdcModuleAuxContainer_v2
Auxiliary store for xAOD::ZdcModuleContainer_v2.
Definition: ZdcModuleAuxContainer_v2.h:31
ZdcRecV2::m_zdcModuleAuxContainerName
std::string m_zdcModuleAuxContainerName
Definition: ZdcRecV2.h:75
ZdcRecV2::finalize
StatusCode finalize()
Definition: ZdcRecV2.cxx:160
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ZdcRecV2.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ZdcModuleAuxContainer.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ZdcRecV2::~ZdcRecV2
~ZdcRecV2()
Definition: ZdcRecV2.cxx:54
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
ZdcRecV2::m_eventCount
int m_eventCount
Definition: ZdcRecV2.h:81
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
ZdcRecV2::m_zdcModuleContainerName
std::string m_zdcModuleContainerName
Raw data object name.
Definition: ZdcRecV2.h:74
ZdcRecV2::m_ttContainer
const xAOD::TriggerTowerContainer * m_ttContainer
Pointer to Zdc input "digits" data.
Definition: ZdcRecV2.h:79
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
ZdcRecV2::m_ownPolicy
int m_ownPolicy
Does the collection own it's objects ?
Definition: ZdcRecV2.h:67
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
ZdcToString.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ZdcRecChannelToolV2.h
ZdcRecV2::execute
StatusCode execute()
Definition: ZdcRecV2.cxx:96
ZdcRecV2::initialize
StatusCode initialize()
Definition: ZdcRecV2.cxx:58
ZdcRecV2::m_ChannelTool
ToolHandle< ZdcRecChannelToolV2 > m_ChannelTool
Definition: ZdcRecV2.h:88
ZdcRecV2::m_ttContainerName
std::string m_ttContainerName
Digits data container name.
Definition: ZdcRecV2.h:71
ZdcModuleToString.h
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ZdcRecV2::m_complainContain
bool m_complainContain
Definition: ZdcRecV2.h:82
ZdcRecV2::m_complainRetrieve
bool m_complainRetrieve
Definition: ZdcRecV2.h:83
StoreGateSvc.h
ZdcModuleContainer.h
ZdcRecV2::ZdcRecV2
ZdcRecV2(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZdcRecV2.cxx:30
ZdcModuleToString
std::string ZdcModuleToString(const xAOD::ZdcModule &zm)
Definition: ZdcModuleToString.cxx:9