ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcRec.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 * ZdcRecChannel.cxx
7 *
8 * Created on: Nov 24, 2009
9 * Author: leite
10 */
11
12#include "GaudiKernel/ISvcLocator.h"
13#include "GaudiKernel/MsgStream.h"
14#include "GaudiKernel/StatusCode.h"
16//#include "Identifier/Identifier.h"
17
20#include "ZdcRec/ZdcRec.h"
23
24//==================================================================================================
25ZdcRec::ZdcRec(const std::string& name, ISvcLocator* pSvcLocator) :
26
27 AthAlgorithm(name, pSvcLocator),
28 m_storeGate("StoreGateSvc", name),
29 m_ownPolicy(static_cast<int> (SG::OWN_ELEMENTS)),
30 m_digitsContainerName("ZdcDigitsCollection"),
31 m_rawContainerName("ZdcRawChannelCollection"),
32 m_digitsCollection(nullptr),
33 m_rawCollection(nullptr),
34 m_eventCount(0),
37 m_ChannelTool("ZdcRecChannelTool"),
38 m_NoiseTool("ZdcRecNoiseTool")
39
40{
41 declareProperty("OwnPolicy",m_ownPolicy) ;
42
43 declareProperty("DigitsContainerName", m_digitsContainerName, "ZdcDigitsCollection");
44
45 declareProperty("RawContainerName", m_rawContainerName, "ZdcRawChannelCollection");
46}
47//==================================================================================================
48
49//==================================================================================================
51//==================================================================================================
52
53//==================================================================================================
55{
56 MsgStream mLog(msgSvc(), name());
57
58 // Look up the Storegate service
59 StatusCode sc = m_storeGate.retrieve();
60 if (sc.isFailure())
61 {
62 mLog << MSG::FATAL << "--> ZDC: Unable to retrieve pointer to StoreGateSvc" << endmsg;
63 return sc;
64 }
65
66
67 // Reconstruction Tool
68 StatusCode scTool = m_ChannelTool.retrieve();
69 if (scTool.isFailure())
70 {
71 mLog << MSG::WARNING << "--> ZDC: Could not retrieve " << m_ChannelTool << endmsg;
72 return StatusCode::FAILURE;
73 }
74 mLog << MSG::INFO << "--> ZDC: SUCCESS retrieving " << m_ChannelTool << endmsg;
75
76 // Noise and Pedestal Tool
77 scTool = m_NoiseTool.retrieve();
78 if (scTool.isFailure())
79 {
80 mLog << MSG::WARNING << "--> ZDC: Could not retrieve " << m_NoiseTool << endmsg;
81 return StatusCode::FAILURE;
82 }
83 mLog << MSG::INFO << "--> ZDC: SUCCESS retrieving " << m_NoiseTool << endmsg;
84
85 // Container output name
86 //TODO: change MESSAGE !!
87 mLog << MSG::INFO << " Output Container Name " << m_rawContainerName << endmsg;
89 mLog << MSG::INFO << "...will OWN its cells." << endmsg;
90 else
91 mLog << MSG::INFO << "...will VIEW its cells." << endmsg;
92
93
94 mLog << MSG::INFO << "--> ZDC: ZdcRec initialization complete" << endmsg;
95
96 return StatusCode::SUCCESS;
97}
98//==================================================================================================
99
100//==================================================================================================
101StatusCode ZdcRec::execute()
102{
103
105 int ncha = 0;
106
107 MsgStream mLog(msgSvc(), name());
108 mLog << MSG::DEBUG
109 << "--> ZDC: ZdcRec execute starting on "
110 << m_eventCount
111 << "th event"
112 << endmsg;
113
114 m_eventCount++;
115
116 //Look for the container presence
118 if (!dg) {
119 if (m_complainContain) mLog << MSG::WARNING << "--> ZDC: StoreGate does not contain " << m_digitsContainerName << endmsg;
121 return StatusCode::SUCCESS;
122 }
123
124 // Look up the Digits "ZdcDigitsCollection" in Storegate
125 StatusCode digitsLookupSC = m_storeGate->retrieve(m_digitsCollection, m_digitsContainerName);
126 if (digitsLookupSC.isFailure())
127 {
129 mLog << MSG::WARNING
130 << "--> ZDC: Could not retrieve "
132 << " from StoreGate"
133 << endmsg;
135 return StatusCode::SUCCESS;
136 }
137
138 if (digitsLookupSC.isSuccess() && !m_digitsCollection)
139 {
140 mLog << MSG::ERROR
141 << "--> ZDC: Storegate returned zero pointer for "
143 << endmsg;
144 return StatusCode::SUCCESS;
145 }
146
147 //Create the containers to hold the reconstructed information
150
151 ncha = m_ChannelTool->makeRawFromDigits(*m_digitsCollection, tmpCollection);
152
153
154 // SG has the ownership of m_rawCollection, and it should be copyed intead of just
155 // being passed around.
156 for (iter=tmpCollection.begin();iter!=tmpCollection.end();++iter) {
157 m_rawCollection->push_back(*iter);
158 }
159
160 StatusCode sc = evtStore()->record(m_rawCollection, m_rawContainerName,false);
161
162 mLog << MSG::DEBUG
163 << "--> ZDC: ZdcRawChannelCollection size recorded into SG: "
164 << m_rawCollection->size()
165 << ".. and from tool " << ncha
166 << endmsg;
167
168 // For Debugging only
169 /*
170 ZdcRawChannel *z;
171 int i = 0;
172 int ss = 0;
173 for (iter=m_rawCollection->begin();iter!=m_rawCollection->end();iter++) {
174 i++;
175 z = *iter;
176 ss = z->getSize();
177 for (int cc = 0; cc < ss ; cc++) {
178 std::cout << "...." << i << " " << " " << cc << "E = " << z->getEnergy(cc) << " T = " << z->getTime(cc);
179 }
180 std::cout << std::endl;
181 }
182 */
183
184
185 if (sc.isFailure())
186 {
187 mLog << MSG::WARNING
188 << "execute() : cannot record Container "
190 << endmsg;
191
192 return StatusCode::SUCCESS;
193 }
194
195 return StatusCode::SUCCESS;
196
197}
198//==================================================================================================
199
200//==================================================================================================
202{
203 MsgStream mLog(msgSvc(),name());
204
205 mLog << MSG::INFO
206 << "--> ZDC: ZdcRec finalize complete"
207 << endmsg;
208 return StatusCode::SUCCESS;
209}
210//==================================================================================================
211
#define endmsg
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
StatusCode execute()
Definition ZdcRec.cxx:101
const ZdcDigitsCollection * m_digitsCollection
Pointer to Zdc input "digits" data.
Definition ZdcRec.h:77
~ZdcRec()
Definition ZdcRec.cxx:50
std::string m_rawContainerName
Raw data object name.
Definition ZdcRec.h:74
StatusCode finalize()
Definition ZdcRec.cxx:201
int m_ownPolicy
Does the collection own it's objects ?
Definition ZdcRec.h:68
ToolHandle< ZdcRecChannelTool > m_ChannelTool
Definition ZdcRec.h:89
ServiceHandle< StoreGateSvc > m_storeGate
class member version of retrieving StoreGate
Definition ZdcRec.h:64
bool m_complainRetrieve
Definition ZdcRec.h:84
ZdcRec(const std::string &name, ISvcLocator *pSvcLocator)
Definition ZdcRec.cxx:25
bool m_complainContain
Definition ZdcRec.h:83
int m_eventCount
Definition ZdcRec.h:82
StatusCode initialize()
Definition ZdcRec.cxx:54
ZdcRawChannelCollection * m_rawCollection
Pointer to Zdc output "raw" reconstructed data.
Definition ZdcRec.h:80
std::string m_digitsContainerName
Digits data container name.
Definition ZdcRec.h:71
ToolHandle< ZdcRecNoiseTool > m_NoiseTool
Definition ZdcRec.h:90
Forward declaration.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts