ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
ZDC
ZdcRec
src
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"
15
#include "
StoreGate/StoreGateSvc.h
"
16
//#include "Identifier/Identifier.h"
17
18
#include "
ZdcEvent/ZdcDigitsCollection.h
"
19
#include "
ZdcEvent/ZdcCalibEvent.h
"
20
#include "
ZdcRec/ZdcRec.h
"
21
#include "
ZdcRec/ZdcRecChannelTool.h
"
22
#include "
ZdcRec/ZdcRecNoiseTool.h
"
23
24
//==================================================================================================
25
ZdcRec::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),
35
m_complainContain
(1),
36
m_complainRetrieve
(1),
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
//==================================================================================================
50
ZdcRec::~ZdcRec
() {}
51
//==================================================================================================
52
53
//==================================================================================================
54
StatusCode
ZdcRec::initialize
()
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
;
88
if
(
m_ownPolicy
==
SG::OWN_ELEMENTS
)
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
//==================================================================================================
101
StatusCode
ZdcRec::execute
(
const
EventContext&
/*ctx*/
)
102
{
103
104
ZdcRawChannelCollection::iterator
iter;
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
117
bool
dg =
m_storeGate
->contains<
ZdcDigitsCollection
>(
m_digitsContainerName
);
118
if
(!dg) {
119
if
(
m_complainContain
) mLog << MSG::WARNING <<
"--> ZDC: StoreGate does not contain "
<<
m_digitsContainerName
<<
endmsg
;
120
m_complainContain
= 0;
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
{
128
if
(
m_complainRetrieve
)
129
mLog << MSG::WARNING
130
<<
"--> ZDC: Could not retrieve "
131
<<
m_digitsContainerName
132
<<
" from StoreGate"
133
<<
endmsg
;
134
m_complainRetrieve
= 0;
135
return
StatusCode::SUCCESS;
136
}
137
138
if
(digitsLookupSC.isSuccess() && !
m_digitsCollection
)
139
{
140
mLog << MSG::ERROR
141
<<
"--> ZDC: Storegate returned zero pointer for "
142
<<
m_digitsContainerName
143
<<
endmsg
;
144
return
StatusCode::SUCCESS;
145
}
146
147
//Create the containers to hold the reconstructed information
148
m_rawCollection
=
new
ZdcRawChannelCollection
(
static_cast<
SG::OwnershipPolicy
>
(
m_ownPolicy
));
149
ZdcRawChannelCollection
tmpCollection (
static_cast<
SG::OwnershipPolicy
>
(
SG::VIEW_ELEMENTS
));
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 "
189
<<
m_rawContainerName
190
<<
endmsg
;
191
192
return
StatusCode::SUCCESS;
193
}
194
195
return
StatusCode::SUCCESS;
196
197
}
198
//==================================================================================================
199
200
//==================================================================================================
201
StatusCode
ZdcRec::finalize
()
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
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
StoreGateSvc.h
ZdcCalibEvent.h
ZdcDigitsCollection.h
ZdcRecChannelTool.h
ZdcRecNoiseTool.h
ZdcRec.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
DataVector< ZdcRawChannel >::iterator
DataModel_detail::iterator< DataVector > iterator
Definition
DataVector.h:842
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ZdcDigitsCollection
Definition
ZdcDigitsCollection.h:20
ZdcRawChannelCollection
Definition
ZdcRawChannelCollection.h:20
ZdcRec::m_digitsCollection
const ZdcDigitsCollection * m_digitsCollection
Pointer to Zdc input "digits" data.
Definition
ZdcRec.h:77
ZdcRec::~ZdcRec
~ZdcRec()
Definition
ZdcRec.cxx:50
ZdcRec::m_rawContainerName
std::string m_rawContainerName
Raw data object name.
Definition
ZdcRec.h:74
ZdcRec::finalize
StatusCode finalize()
Definition
ZdcRec.cxx:201
ZdcRec::m_ownPolicy
int m_ownPolicy
Does the collection own it's objects ?
Definition
ZdcRec.h:68
ZdcRec::m_ChannelTool
ToolHandle< ZdcRecChannelTool > m_ChannelTool
Definition
ZdcRec.h:89
ZdcRec::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
class member version of retrieving StoreGate
Definition
ZdcRec.h:64
ZdcRec::m_complainRetrieve
bool m_complainRetrieve
Definition
ZdcRec.h:84
ZdcRec::ZdcRec
ZdcRec(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ZdcRec.cxx:25
ZdcRec::m_complainContain
bool m_complainContain
Definition
ZdcRec.h:83
ZdcRec::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
ZdcRec.cxx:101
ZdcRec::m_eventCount
int m_eventCount
Definition
ZdcRec.h:82
ZdcRec::initialize
StatusCode initialize()
Definition
ZdcRec.cxx:54
ZdcRec::m_rawCollection
ZdcRawChannelCollection * m_rawCollection
Pointer to Zdc output "raw" reconstructed data.
Definition
ZdcRec.h:80
ZdcRec::m_digitsContainerName
std::string m_digitsContainerName
Digits data container name.
Definition
ZdcRec.h:71
ZdcRec::m_NoiseTool
ToolHandle< ZdcRecNoiseTool > m_NoiseTool
Definition
ZdcRec.h:90
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::OwnershipPolicy
OwnershipPolicy
Definition
OwnershipPolicy.h:16
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition
OwnershipPolicy.h:17
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
Generated on
for ATLAS Offline Software by
1.17.0