ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
AtlasTest
DatabaseTest
AthenaPoolTest
src
LArCellContFakeReader.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
15
16
17
18
#include "
LArCellContFakeReader.h
"
19
20
// DetDescr includes
21
#include "
CaloIdentifier/CaloCell_ID.h
"
22
23
// test includes
24
#include "
LArCellContFakeCreator.h
"
25
26
27
// Constructor with parameters:
28
LArCellContFakeReader::LArCellContFakeReader
(
const
std::string &name,
29
ISvcLocator *pSvcLocator) :
30
AthAlgorithm
(name,pSvcLocator),
31
m_calocellId
(nullptr)
32
{}
33
34
// Initialize method:
35
StatusCode
LArCellContFakeReader::initialize
()
36
{
37
ATH_MSG_INFO
(
"LArCellContFakeReader::initialize()"
);
38
ATH_CHECK
(
detStore
()->retrieve(
m_calocellId
,
"CaloCell_ID"
) );
39
ATH_CHECK
(
m_caloMgrKey
.initialize());
40
return
StatusCode::SUCCESS;
41
}
42
43
// Execute method:
44
StatusCode
LArCellContFakeReader::execute
(
const
EventContext& ctx)
45
{
46
ATH_MSG_DEBUG
(
"LArCellContFakeReader::execute()"
);
47
48
SG::ReadCondHandle<CaloDetDescrManager>
caloMgrHandle{
m_caloMgrKey
, ctx};
49
ATH_CHECK
(caloMgrHandle.
isValid
());
50
51
// Retrieve container
52
const
CaloCellContainer
* caloCont =
nullptr
;
53
ATH_CHECK
(
evtStore
()->retrieve(caloCont,
"CaloCellCont1"
) );
54
ATH_MSG_DEBUG
(
"Container '"
<<
"CaloCellCont"
55
<<
"' retrieved from StoreGate"
);
56
57
LArCellContFakeCreator
creator;
58
59
// Create container
60
MsgStream log(msgSvc(), name());
61
const
CaloCellContainer
* caloCont1 = creator.
createCaloCellContainer
(
m_calocellId
,
62
*caloMgrHandle,
63
msg
());
64
65
CaloCellContainer::const_iterator
first = caloCont->
begin
();
66
CaloCellContainer::const_iterator
last = caloCont->
end
();
67
CaloCellContainer::const_iterator
first1 = caloCont1->
begin
();
68
CaloCellContainer::const_iterator
last1 = caloCont1->
end
();
69
70
bool
error
=
false
;
71
int
ncells = 0;
72
int
ncellErrs = 0;
73
74
for
(; first != last && first1 != last1; ++first, ++first1) {
75
if
(((*first)->ID() != (*first1)->ID()) ||
76
(fabs((*first)->energy() - (*first1)->energy() ) > 0.01*fabs((*first)->energy())) ||
77
(fabs((*first)->time() - (*first1)->time() ) > 0.0002*fabs((*first)->time())) ||
78
(std::abs((*first)->quality() - (*first1)->quality() ) > 0) ||
79
(std::abs((*first)->provenance() - (*first1)->provenance() ) > 0) ||
80
(fabs((*first)->eta() - (*first1)->eta() ) > 0.0000001) ||
81
(fabs((*first)->phi() - (*first1)->phi() ) > 0.0000001)) {
82
ATH_MSG_ERROR
(
"CaloCell1,2 differ: id "
83
<<
m_calocellId
->show_to_string((*first)->ID())
84
<<
m_calocellId
->show_to_string((*first1)->ID())
85
<<
" energy "
<< (*first)->energy() <<
" "
86
<< (*first1)->energy()
87
<<
" time "
<< (*first)->time() <<
" "
88
<< (*first1)->time()
89
<<
" quality "
<< (*first)->quality() <<
" "
90
<< (*first1)->quality()
91
<<
" provenance "
<< (*first)->provenance() <<
" "
92
<< (*first1)->provenance()
93
<<
" eta "
<< (*first)->eta() <<
" "
94
<< (*first1)->eta()
95
<<
" phi "
<< (*first)->phi() <<
" "
96
<< (*first1)->phi());
97
error
=
true
;
98
ncellErrs++;
99
}
100
ncells++;
101
}
102
103
printCells
(caloCont);
104
105
if
(
error
) {
106
ATH_MSG_ERROR
(
"Errors: "
<< ncellErrs );
107
return
StatusCode::FAILURE;
108
}
109
else
{
110
ATH_MSG_INFO
(
"Successful check of CaloCellContainer I/O. Cells read: "
<< ncells );
111
}
112
113
return
StatusCode::SUCCESS;
114
}
115
116
// Print cells
117
void
LArCellContFakeReader::printCells
(
const
CaloCellContainer
* caloCont)
const
118
{
119
120
ATH_MSG_INFO
(
"LArCellContFakeReader::printRDOs()"
);
121
122
// loop on all cells
123
124
CaloCellContainer::const_iterator
first = caloCont->
begin
();
125
CaloCellContainer::const_iterator
last = caloCont->
end
();
126
127
for
(; first != last; ++first) {
128
129
ATH_MSG_INFO
(
"CaloCell: id "
130
<<
m_calocellId
->show_to_string((*first)->ID())
131
<< std::setprecision(5)
132
<<
" energy "
<< (*first)->energy()
133
<<
" time "
<< (*first)->time()
134
<<
" quality "
<< (*first)->quality()
135
<<
" provenance "
<< (*first)->provenance()
136
<<
" eta "
<< (*first)->eta()
137
<<
" phi "
<< (*first)->phi()
138
);
139
}
140
141
ATH_MSG_DEBUG
(
"LArCellContFakeReader::printCells() end"
);
142
143
}
144
145
146
// Finalize method:
147
StatusCode
LArCellContFakeReader::finalize
()
148
{
149
ATH_MSG_INFO
(
"LArCellContFakeReader::finalize()"
);
150
151
return
StatusCode::SUCCESS;
152
}
153
154
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCell_ID.h
LArCellContFakeCreator.h
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
LArCellContFakeReader.h
Test Algorithm for POOL I/O uses CaloCellContainer as test data.
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
DataVector< CaloCell >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
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.
LArCellContFakeCreator
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
Definition
LArCellContFakeCreator.h:37
LArCellContFakeCreator::createCaloCellContainer
CaloCellContainer * createCaloCellContainer(const CaloCell_ID *calocellId, const CaloDetDescrManager *caloMgr, MsgStream &log) const
Create a CaloCellContainer with LAr cells.
Definition
LArCellContFakeCreator.h:61
LArCellContFakeReader::finalize
virtual StatusCode finalize() override
Algorithm finalize at end of job.
Definition
LArCellContFakeReader.cxx:147
LArCellContFakeReader::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Need DD mgr to create cells.
Definition
LArCellContFakeReader.h:75
LArCellContFakeReader::execute
virtual StatusCode execute(const EventContext &ctx) override
Algorithm execute once per event.
Definition
LArCellContFakeReader.cxx:44
LArCellContFakeReader::initialize
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
Definition
LArCellContFakeReader.cxx:35
LArCellContFakeReader::m_calocellId
const CaloCell_ID * m_calocellId
Need id helper to create cells.
Definition
LArCellContFakeReader.h:81
LArCellContFakeReader::LArCellContFakeReader
LArCellContFakeReader()
Avoid use of default constructor.
LArCellContFakeReader::printCells
void printCells(const CaloCellContainer *larCont) const
Print out cell info.
Definition
LArCellContFakeReader.cxx:117
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
error
Definition
IImpactPoint3dEstimator.h:72
Generated on
for ATLAS Offline Software by
1.17.0