ATLAS Offline Software
CaloTowerStoreTestAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
11 #undef NDEBUG
12 
13 #include "CaloTowerStoreTestAlg.h"
15 #include <iostream>
16 #include <cmath>
17 #include <cassert>
18 
19 
24  ISvcLocator* pSvcLocator)
25  : AthAlgorithm (name, pSvcLocator)
26 {
27 }
28 
29 
31 {
33  return StatusCode::SUCCESS;
34 }
35 
36 void
38  test_tows_t& tows)
39 {
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 
52 void
54  const CaloTowerSeg::SubSeg& subseg,
55  test_tows_t& tows)
56 {
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 
70 void
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 
82 void
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);
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 }
SGTest::store
TestStore store
Definition: TestStore.cxx:23
CaloTowerSeg::SubSegIterator
Iterator over a rectangular window of towers.
Definition: CaloTowerSeg.h:337
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
CaloTowerStoreTestAlg::test_tows_t
std::vector< test_tow_t > test_tows_t
Definition: CaloTowerStoreTestAlg.h:46
fitman.sz
sz
Definition: fitman.py:527
CaloTowerStore.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CaloTowerStoreTestAlg::execute
virtual StatusCode execute() override
Standard Gaudi execute method.
Definition: CaloTowerStoreTestAlg.cxx:137
CaloTowerStore::cell_iterator::hash
unsigned int hash()
Definition: CaloTowerStore.h:252
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
CaloTowerStoreTestAlg::iterate_subseg
static void iterate_subseg(const CaloTowerStore &store, const CaloTowerSeg::SubSeg &subseg, test_tows_t &tows)
Definition: CaloTowerStoreTestAlg.cxx:53
CaloTowerStoreTestAlg::test1
void test1()
Definition: CaloTowerStoreTestAlg.cxx:106
CaloTowerStore::cell_iterator
Definition: CaloTowerStore.h:227
CaloTowerSeg::SubSeg
A rectangular window within the segmentation.
Definition: CaloTowerSeg.h:220
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloTowerStoreTestAlg::iterate_full
static void iterate_full(const CaloTowerStore &store, test_tows_t &tows)
Definition: CaloTowerStoreTestAlg.cxx:37
CaloTowerStoreTestAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: CaloTowerStoreTestAlg.h:62
CaloTowerStoreTestAlg::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: CaloTowerStoreTestAlg.cxx:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
AthAlgorithm
Definition: AthAlgorithm.h:47
CaloTowerStore
Definition: CaloTowerStore.h:157
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloTowerStoreTestAlg::dump_tows
static void dump_tows(const test_tows_t &t)
Definition: CaloTowerStoreTestAlg.cxx:71
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloTowerStoreTestAlg::test_subseg_iter
static void test_subseg_iter(const CaloDetDescrManager *, const CaloTowerStore &, const std::vector< CaloCell_ID::SUBCALO > &, const CaloTowerSeg::SubSeg &)
Definition: CaloTowerStoreTestAlg.cxx:83
CaloTowerStore::tower_iterator
Definition: CaloTowerStore.h:292
CaloTowerSeg::SubSeg::segmentation
CaloTowerSeg segmentation() const
Return a new segmentation object corresponding to this window.
Definition: CaloTowerSeg.cxx:85
CaloTowerStoreTestAlg::CaloTowerStoreTestAlg
CaloTowerStoreTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CaloTowerStoreTestAlg.cxx:23
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloTowerStoreTestAlg.h
Regression test for CaloTowerStore.
DeMoScan.first
bool first
Definition: DeMoScan.py:536
CaloTowerSeg
Data object stores CaloTower segmentation.
Definition: CaloTowerSeg.h:37
CaloTowerSeg::SubSeg::size
size_t size() const
The number of towers in this window.
Definition: CaloTowerSeg.h:591
CaloTowerStore::size
size_t size() const
Definition: CaloTowerStore.h:354
CaloTowerStoreTestAlg::test_tow_t
std::vector< std::pair< unsigned, double > > test_tow_t
Definition: CaloTowerStoreTestAlg.h:45
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
CaloTowerStore::buildLookUp
bool buildLookUp(const CaloDetDescrManager &theManager, const CaloTowerSeg &theTowerSeg, const std::vector< CaloCell_ID::SUBCALO > &theCalos)
setup trigger
Definition: CaloTowerStore.cxx:75
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
CaloTowerStore::cell_iterator::weight
double weight() const
Definition: CaloTowerStore.h:261
CaloTowerSeg::subseg
SubSeg subseg(double eta, double deta, double phi, double dphi) const
Return a window within the current segmentation.
Definition: CaloTowerSeg.cxx:23