ATLAS Offline Software
Loading...
Searching...
No Matches
AbsLArCells.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11
12#include <iostream>
13using std::cout;
14using std::endl;
15
16using namespace LArSamples;
17
18
19//std::vector<CellInfo*> AbsLArCells::m_cellInfoCache(Definitions::nChannels,nullptr);
20
25
30
31
33{
34 m_cellCache.reset();
35 m_pos = nChannels() + 1;
36}
37
38
39std::unique_ptr<const History> AbsLArCells::newCellHistory(unsigned int i) const
40{
41 std::unique_ptr<const History> history = getCellHistory(i);
42 if (!history) return nullptr;
43 if (!m_cellInfoCache[i]) {
44 const CellInfo* ci=history->cellInfo();
45 if (ci) {
46 m_cellInfoCache[i]=std::make_unique<CellInfo>(*ci,false);
47 }
48 }
49 // m_cellInfoCache[i] = (history->cellInfo() ? new CellInfo(*history->cellInfo(), false) : new CellInfo());
50 return history;
51}
52
53
54const History* AbsLArCells::cellHistory(unsigned int i) const
55{
56 if (m_pos == i) return m_cellCache.get();
57 resetCache();
58 std::unique_ptr<const History> history = newCellHistory(i);
59 if (!history) return nullptr;
60 m_cellCache = std::move(history);
61 m_pos = i;
62 return m_cellCache.get();
63}
64
65
66std::unique_ptr<const CellInfo> AbsLArCells::cellInfo(unsigned int i) const
67{
68 const CellInfo* info = cellInfoCache(i);
69 if (info) {
70 if (info->isValid()) {
71 return std::make_unique<CellInfo> (*info);
72 }
73 return nullptr;
74 }
75 std::unique_ptr<const CellInfo> infop = getCellInfo(i);
76 if (infop) m_cellInfoCache[i] = std::make_unique<CellInfo>(*infop, false);
77 return infop;
78}
79
80
81const CellInfo* AbsLArCells::cellInfoCache(unsigned int i) const
82{
83 return m_cellInfoCache[i].get();
84}
85
86
87std::unique_ptr<const CellInfo> AbsLArCells::getCellInfo(unsigned int i) const
88{
89 std::unique_ptr<const History> history = this->getCellHistory(i);
90 if (!history) return nullptr;
91 if (!history->cellInfo()) return nullptr;
92 return std::make_unique<CellInfo>(*history->cellInfo());
93}
94
95
96const History* AbsLArCells::pass(unsigned int i, const FilterParams& f) const
97{
98 //std::cout << "Called AbsLArCells with hash " << i << std::endl;
99 if (!f.passHash(i)) return nullptr;
100 std::unique_ptr<const CellInfo> info = cellInfo(i);
101 if (!info) {
102 return nullptr;
103 }
104 //std::cout << "Called AbsLArCells::pass on a cell belonging to " << Id::str(info->calo()) << std::endl;
105 bool result = f.passCell(*info);
106 return result ? cellHistory(i) : nullptr;
107}
108
109
virtual std::unique_ptr< const History > getCellHistory(unsigned int i) const =0
virtual unsigned int nChannels() const
Definition AbsLArCells.h:35
const History * pass(unsigned int i, const FilterParams &f) const
std::unique_ptr< const History > m_cellCache
Definition AbsLArCells.h:55
virtual std::unique_ptr< const CellInfo > getCellInfo(unsigned int i) const
virtual const History * cellHistory(unsigned int i) const
virtual void resetCache() const
std::vector< std::unique_ptr< CellInfo > > m_cellInfoCache
Definition AbsLArCells.h:56
virtual std::unique_ptr< const History > newCellHistory(unsigned int i) const
const CellInfo * cellInfoCache(unsigned int i) const
virtual std::unique_ptr< const CellInfo > cellInfo(unsigned int i) const