ATLAS Offline Software
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 
18 #include "LArCellContFakeReader.h"
19 
20 // DetDescr includes
22 
23 // test includes
24 #include "LArCellContFakeCreator.h"
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") );
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 
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 
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 
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArCellContFakeReader::printCells
void printCells(const CaloCellContainer *larCont) const
Print out cell info.
Definition: LArCellContFakeReader.cxx:117
LArCellContFakeReader::initialize
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
Definition: LArCellContFakeReader.cxx:35
CaloCell_ID.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArCellContFakeCreator::createCaloCellContainer
CaloCellContainer * createCaloCellContainer(const CaloCell_ID *calocellId, const CaloDetDescrManager *caloMgr, MsgStream &log) const
Create a CaloCellContainer with LAr cells.
Definition: LArCellContFakeCreator.h:61
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArCellContFakeReader::execute
virtual StatusCode execute() override
Algorithm execute once per event.
Definition: LArCellContFakeReader.cxx:44
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArCellContFakeReader::finalize
virtual StatusCode finalize() override
Algorithm finalize at end of job.
Definition: LArCellContFakeReader.cxx:147
AthAlgorithm
Definition: AthAlgorithm.h:47
LArCellContFakeCreator
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
Definition: LArCellContFakeCreator.h:37
LArCellContFakeReader.h
Test Algorithm for POOL I/O uses CaloCellContainer as test data.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArCellContFakeCreator.h
Create a CaloCellContainer with LArCells for POOL I/O tests algs.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
LArCellContFakeReader::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Need DD mgr to create cells.
Definition: LArCellContFakeReader.h:75
DeMoScan.first
bool first
Definition: DeMoScan.py:536
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArCellContFakeReader::LArCellContFakeReader
LArCellContFakeReader()
Avoid use of default constructor.
error
Definition: IImpactPoint3dEstimator.h:70
LArCellContFakeReader::m_calocellId
const CaloCell_ID * m_calocellId
Need id helper to create cells.
Definition: LArCellContFakeReader.h:81
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.