Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TowerInfoContainerv1.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TowerInfoContainerv1.cc
1
#include "
TowerInfoContainerv1.h
"
2
#include "
TowerInfoDefs.h
"
3
#include "
TowerInfov1.h
"
4
5
#include <
phool/PHObject.h
>
6
#include <
phool/phool.h
>
7
8
#include <TClonesArray.h>
9
10
#include <cassert>
11
12
TowerInfoContainerv1::TowerInfoContainerv1
(
DETECTOR
detec)
13
: _detector(detec)
14
{
15
int
nchannels = 744;
16
if
(
_detector
==
DETECTOR::SEPD
)
17
{
18
nchannels = 744;
19
}
20
else
if
(
_detector
== DETECTOR::EMCAL)
21
{
22
nchannels = 24576;
23
}
24
else
if
(
_detector
== DETECTOR::HCAL)
25
{
26
nchannels = 1536;
27
}
28
else
if
(
_detector
==
DETECTOR::MBD
)
29
{
30
nchannels = 256;
31
}
32
else
if
(
_detector
==
DETECTOR::ZDC
)
33
{
34
nchannels = 16;
35
}
36
_clones
=
new
TClonesArray(
"TowerInfov1"
, nchannels);
37
_clones
->SetOwner();
38
_clones
->SetName(
"TowerInfoContainerv1"
);
39
for
(
int
i
= 0;
i
< nchannels; ++
i
)
40
{
41
// as tower numbers are fixed per event
42
// construct towers once per run, and clear the towers for first use
43
_clones
->ConstructedAt(
i
,
"C"
);
44
}
45
}
46
47
TowerInfoContainerv1::~TowerInfoContainerv1
()
48
{
49
delete
_clones
;
50
}
51
52
TowerInfoContainerv1::TowerInfoContainerv1
(
const
TowerInfoContainerv1
&
source
)
53
{
54
_detector
= source.
get_detectorid
();
55
_clones
=
new
TClonesArray(
"TowerInfov1"
, source.
size
());
56
_clones
->SetOwner();
57
_clones
->SetName(
"TowerInfoContainerv1"
);
58
for
(
unsigned
int
i
= 0;
i
< source.
size
(); ++
i
)
59
{
60
// as tower numbers are fixed per event
61
// construct towers once per run, and clear the towers for first use
62
_clones
->ConstructedAt(
i
,
"C"
);
63
}
64
}
65
66
void
TowerInfoContainerv1::identify
(std::ostream&
os
)
const
67
{
68
os <<
"TowerInfoContainerv1 of size "
<<
size
() << std::endl;
69
}
70
71
void
TowerInfoContainerv1::Reset
()
72
{
73
// clear content of towers in the container for the next event
74
75
for
(Int_t
i
= 0;
i
<
_clones
->GetEntriesFast(); ++
i
)
76
{
77
TObject* obj =
_clones
->UncheckedAt(
i
);
78
79
if
(obj ==
nullptr
)
80
{
81
std::cout << __PRETTY_FUNCTION__ <<
" Fatal access error:"
82
<<
" _clones->GetSize() = "
<<
_clones
->GetSize()
83
<<
" _clones->GetEntriesFast() = "
<<
_clones
->GetEntriesFast()
84
<<
" i = "
<<
i
<< std::endl;
85
_clones
->Print();
86
}
87
88
assert
(obj);
89
// same as TClonesArray::Clear() but only clear but not to erase all towers
90
obj->Clear();
91
obj->ResetBit(kHasUUID);
92
obj->ResetBit(kIsReferenced);
93
obj->SetUniqueID(0);
94
}
95
}
96
97
TowerInfov1
*
TowerInfoContainerv1::get_tower_at_channel
(
int
pos
)
98
{
99
return
(
TowerInfov1
*)
_clones
->At(pos);
100
}
101
102
TowerInfov1
*
TowerInfoContainerv1::get_tower_at_key
(
int
pos
)
103
{
104
int
index
=
decode_key
(pos);
105
return
(
TowerInfov1
*)
_clones
->At(index);
106
}
107
108
unsigned
int
TowerInfoContainerv1::encode_key
(
unsigned
int
towerIndex)
109
{
110
int
key = 0;
111
if
(
_detector
== DETECTOR::EMCAL)
112
{
113
key =
TowerInfoContainerv1::encode_emcal
(towerIndex);
114
}
115
else
if
(
_detector
== DETECTOR::HCAL)
116
{
117
key =
TowerInfoContainerv1::encode_hcal
(towerIndex);
118
}
119
else
if
(
_detector
==
DETECTOR::SEPD
)
120
{
121
key =
TowerInfoContainerv1::encode_epd
(towerIndex);
122
}
123
else
if
(
_detector
==
DETECTOR::MBD
)
124
{
125
key =
TowerInfoContainerv1::encode_mbd
(towerIndex);
126
}
127
else
if
(
_detector
==
DETECTOR::ZDC
)
128
{
129
key =
TowerInfoContainerv1::encode_zdc
(towerIndex);
130
}
131
return
key;
132
}
133
134
unsigned
int
TowerInfoContainerv1::decode_key
(
unsigned
int
tower_key)
135
{
136
int
index
= 0;
137
138
if
(
_detector
== DETECTOR::EMCAL)
139
{
140
index =
TowerInfoContainerv1::decode_emcal
(tower_key);
141
}
142
else
if
(
_detector
== DETECTOR::HCAL)
143
{
144
index =
TowerInfoContainerv1::decode_hcal
(tower_key);
145
}
146
else
if
(
_detector
==
DETECTOR::SEPD
)
147
{
148
index =
TowerInfoContainerv1::decode_epd
(tower_key);
149
}
150
else
if
(
_detector
==
DETECTOR::MBD
)
151
{
152
index =
TowerInfoContainerv1::decode_mbd
(tower_key);
153
}
154
else
if
(
_detector
==
DETECTOR::ZDC
)
155
{
156
index =
TowerInfoContainerv1::decode_zdc
(tower_key);
157
}
158
return
index
;
159
}
coresoftware
blob
master
offline
packages
CaloBase
TowerInfoContainerv1.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:05
using
1.8.2 with
sPHENIX GitHub integration