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