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