ATLAS Offline Software
Loading...
Searching...
No Matches
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
19
20// DetDescr includes
22
23// test includes
25
26
27// Constructor with parameters:
29 ISvcLocator *pSvcLocator) :
30 AthAlgorithm(name,pSvcLocator),
31 m_calocellId(nullptr)
32{}
33
34// Initialize method:
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:
45{
46 ATH_MSG_DEBUG("LArCellContFakeReader::execute()" );
47
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
58
59 // Create container
60 MsgStream log(msgSvc(), name());
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
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:
148{
149 ATH_MSG_INFO("LArCellContFakeReader::finalize()" );
150
151 return StatusCode::SUCCESS;
152}
153
154
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
Test Algorithm for POOL I/O uses CaloCellContainer as test data.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
Container class for CaloCell.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
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.
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
CaloCellContainer * createCaloCellContainer(const CaloCell_ID *calocellId, const CaloDetDescrManager *caloMgr, MsgStream &log) const
Create a CaloCellContainer with LAr cells.
virtual StatusCode finalize() override
Algorithm finalize at end of job.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Need DD mgr to create cells.
virtual StatusCode execute() override
Algorithm execute once per event.
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
const CaloCell_ID * m_calocellId
Need id helper to create cells.
LArCellContFakeReader()
Avoid use of default constructor.
void printCells(const CaloCellContainer *larCont) const
Print out cell info.