ATLAS Offline Software
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 
19 #include "ZdcEvent/ZdcCalibEvent.h"
20 #include "ZdcRec/ZdcRec.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 //==================================================================================================
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 //==================================================================================================
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;
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 "
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 "
143  << endmsg;
144  return StatusCode::SUCCESS;
145  }
146 
147  //Create the containers to hold the reconstructed information
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 
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 
ZdcRec::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
class member version of retrieving StoreGate
Definition: ZdcRec.h:64
ZdcRecChannelTool.h
ZdcRec::m_complainRetrieve
bool m_complainRetrieve
Definition: ZdcRec.h:84
ZdcRec::finalize
StatusCode finalize()
Definition: ZdcRec.cxx:201
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
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ZdcRec::m_rawContainerName
std::string m_rawContainerName
Raw data object name.
Definition: ZdcRec.h:74
ZdcRec::m_digitsContainerName
std::string m_digitsContainerName
Digits data container name.
Definition: ZdcRec.h:71
ZdcDigitsCollection.h
ZdcRec::m_complainContain
bool m_complainContain
Definition: ZdcRec.h:83
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
ZdcRec::execute
StatusCode execute()
Definition: ZdcRec.cxx:101
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
ZdcRec::~ZdcRec
~ZdcRec()
Definition: ZdcRec.cxx:50
ZdcCalibEvent.h
ZdcRawChannelCollection
Definition: ZdcRawChannelCollection.h:20
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ZdcRec::m_ChannelTool
ToolHandle< ZdcRecChannelTool > m_ChannelTool
Definition: ZdcRec.h:89
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ZdcRec::m_NoiseTool
ToolHandle< ZdcRecNoiseTool > m_NoiseTool
Definition: ZdcRec.h:90
ZdcRec.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ZdcRecNoiseTool.h
ZdcRec::initialize
StatusCode initialize()
Definition: ZdcRec.cxx:54
DEBUG
#define DEBUG
Definition: page_access.h:11
ZdcRec::m_rawCollection
ZdcRawChannelCollection * m_rawCollection
Pointer to Zdc output "raw" reconstructed data.
Definition: ZdcRec.h:80
ZdcDigitsCollection
Definition: ZdcDigitsCollection.h:20
ZdcRec::m_digitsCollection
const ZdcDigitsCollection * m_digitsCollection
Pointer to Zdc input "digits" data.
Definition: ZdcRec.h:77
ZdcRec::m_eventCount
int m_eventCount
Definition: ZdcRec.h:82
ZdcRec::ZdcRec
ZdcRec(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZdcRec.cxx:25
StoreGateSvc.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ZdcRec::m_ownPolicy
int m_ownPolicy
Does the collection own it's objects ?
Definition: ZdcRec.h:68