ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTowerStoreTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
10
11#undef NDEBUG
12
15#include <iostream>
16#include <cmath>
17#include <cassert>
18
19
24 ISvcLocator* pSvcLocator)
25 : AthAlgorithm (name, pSvcLocator)
26{
27}
28
29
31{
32 ATH_CHECK(m_caloMgrKey.initialize());
33 return StatusCode::SUCCESS;
34}
35
36void
38 test_tows_t& tows)
39{
40 CaloTowerStore::tower_iterator it = store.towers();
41 size_t sz = store.size();
42 tows.resize (sz);
43 for (size_t i = 0; i < sz; ++i, ++it) {
44 CaloTowerStore::cell_iterator cit = it.firstCell();
45 CaloTowerStore::cell_iterator cit_end = it.lastCell();
46 for (; cit != cit_end; ++cit)
47 tows[i].push_back (std::make_pair (cit.hash(), cit.weight()));
48 }
49}
50
51
52void
54 const CaloTowerSeg::SubSeg& subseg,
55 test_tows_t& tows)
56{
57 CaloTowerStore::tower_subseg_iterator it = store.towers(subseg);
58 size_t sz = subseg.size();
59 tows.resize (sz);
60 for (size_t i = 0; i < sz; ++i, ++it) {
61 size_t itower = it.itower();
62 CaloTowerStore::cell_iterator cit = it.firstCell();
63 CaloTowerStore::cell_iterator cit_end = it.lastCell();
64 for (; cit != cit_end; ++cit)
65 tows[itower].push_back (std::make_pair (cit.hash(), cit.weight()));
66 }
67}
68
69
70void
72{
73 for (size_t i = 0; i < t.size(); i++) {
74 const test_tow_t& tt = t[i];
75 std::cout << " " << i << ": ";
76 for (size_t j = 0; j < tt.size(); j++)
77 std::cout << tt[j].first << "/" << tt[j].second << " ";
78 std::cout << "\n";
79 }
80}
81
82void
84 const CaloTowerStore& store1,
85 const std::vector<CaloCell_ID::SUBCALO>& calos,
86 const CaloTowerSeg::SubSeg& subseg)
87{
88 CaloTowerSeg seg = subseg.segmentation();
89 CaloTowerStore store2;
90 if (!store2.buildLookUp (*caloDDM, seg, calos)) {
91 std::abort();
92 }
93
94 assert (subseg.size() == store2.size());
95
96 test_tows_t tows_full;
97 iterate_full (store2, tows_full);
98
99 test_tows_t tows_subseg;
100 iterate_subseg (store1, subseg, tows_subseg);
101
102 assert (tows_full == tows_subseg);
103}
104
105
107{
108 std::cout << "test1\n";
109
110 // Cannot do this in initialize: see ATLASRECTS-5012
112 if(!caloMgrHandle.isValid()) std::abort();
113
114 const CaloDetDescrManager* caloDDM = *caloMgrHandle;
115
116 CaloTowerSeg seg (50, 64, -2.5, 2.5);
117 std::vector<CaloCell_ID::SUBCALO> calos;
118 calos.push_back (CaloCell_ID::LAREM);
119 calos.push_back (CaloCell_ID::LARHEC);
120 calos.push_back (CaloCell_ID::TILE);
121 CaloTowerStore store;
122 if (!store.buildLookUp (*caloDDM, seg, calos)) {
123 std::abort();
124 }
125
126 CaloTowerSeg::SubSeg subseg1 = seg.subseg (0.7, 0.3, -0.2, 0.4);
127 test_subseg_iter (caloDDM, store, calos, subseg1);
128
129 CaloTowerSeg::SubSeg subseg2 = seg.subseg (0.7, 0.3, 3.1, 0.4);
130 test_subseg_iter (caloDDM, store, calos, subseg2);
131}
132
133
138{
139 test1();
140 return StatusCode::SUCCESS;
141}
#define ATH_CHECK
Evaluate an expression and check for errors.
Regression test for CaloTowerStore.
static Double_t sz
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
This class provides the client interface for accessing the detector description information common to...
A rectangular window within the segmentation.
size_t size() const
The number of towers in this window.
CaloTowerSeg segmentation() const
Return a new segmentation object corresponding to this window.
Data object stores CaloTower segmentation.
SubSeg subseg(double eta, double deta, double phi, double dphi) const
Return a window within the current segmentation.
CaloTowerStoreTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
std::vector< std::pair< unsigned, double > > test_tow_t
virtual StatusCode execute() override
Standard Gaudi execute method.
static void dump_tows(const test_tows_t &t)
static void iterate_subseg(const CaloTowerStore &store, const CaloTowerSeg::SubSeg &subseg, test_tows_t &tows)
static void test_subseg_iter(const CaloDetDescrManager *, const CaloTowerStore &, const std::vector< CaloCell_ID::SUBCALO > &, const CaloTowerSeg::SubSeg &)
static void iterate_full(const CaloTowerStore &store, test_tows_t &tows)
std::vector< test_tow_t > test_tows_t
virtual StatusCode initialize() override
Standard Gaudi initialize method.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
size_t size() const
bool buildLookUp(const CaloDetDescrManager &theManager, const CaloTowerSeg &theTowerSeg, const std::vector< CaloCell_ID::SUBCALO > &theCalos)
setup trigger
CaloTowerSeg::SubSegIterator< tower_iterator > tower_subseg_iterator