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
TowerInfoContainerv2.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TowerInfoContainerv2.cc
1
#include "
TowerInfoContainerv2.h
"
2
#include "
TowerInfoDefs.h
"
3
#include "
TowerInfov2.h
"
4
5
#include <
phool/PHObject.h
>
6
#include <
phool/phool.h
>
7
8
#include <TClonesArray.h>
9
10
#include <cassert>
11
12
TowerInfoContainerv2::TowerInfoContainerv2
(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(
"TowerInfov2"
, nchannels);
37
_clones
->SetOwner();
38
_clones
->SetName(
"TowerInfoContainerv2"
);
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
TowerInfoContainerv2::TowerInfoContainerv2
(
const
TowerInfoContainerv2
&
source
)
48
{
49
_detector
= source.
get_detectorid
();
50
_clones
=
new
TClonesArray(
"TowerInfov2"
, source.
size
());
51
_clones
->SetOwner();
52
_clones
->SetName(
"TowerInfoContainerv2"
);
53
for
(
unsigned
int
i
= 0;
i
< source.
size
(); ++
i
)
54
{
55
// as tower numbers are fixed per event
56
// construct towers once per run, and clear the towers for first use
57
_clones
->ConstructedAt(
i
,
"C"
);
58
}
59
}
60
61
TowerInfoContainerv2::~TowerInfoContainerv2
()
62
{
63
delete
_clones
;
64
}
65
66
void
TowerInfoContainerv2::identify
(std::ostream&
os
)
const
67
{
68
os <<
"TowerInfoContainerv2 of size "
<<
size
() << std::endl;
69
}
70
71
void
TowerInfoContainerv2::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
TowerInfov2
*
TowerInfoContainerv2::get_tower_at_channel
(
int
pos
)
98
{
99
return
(
TowerInfov2
*)
_clones
->At(pos);
100
}
101
102
TowerInfov2
*
TowerInfoContainerv2::get_tower_at_key
(
int
pos
)
103
{
104
int
index
=
decode_key
(pos);
105
return
(
TowerInfov2
*)
_clones
->At(index);
106
}
107
108
unsigned
int
TowerInfoContainerv2::encode_key
(
unsigned
int
towerIndex)
109
{
110
int
key = 0;
111
if
(
_detector
== DETECTOR::EMCAL)
112
{
113
key =
TowerInfoContainer::encode_emcal
(towerIndex);
114
}
115
else
if
(
_detector
== DETECTOR::HCAL)
116
{
117
key =
TowerInfoContainer::encode_hcal
(towerIndex);
118
}
119
else
if
(
_detector
==
DETECTOR::SEPD
)
120
{
121
key =
TowerInfoContainer::encode_epd
(towerIndex);
122
}
123
else
if
(
_detector
==
DETECTOR::MBD
)
124
{
125
key =
TowerInfoContainer::encode_mbd
(towerIndex);
126
}
127
else
if
(
_detector
==
DETECTOR::ZDC
)
128
{
129
key =
TowerInfoContainer::encode_zdc
(towerIndex);
130
}
131
return
key;
132
}
133
134
unsigned
int
TowerInfoContainerv2::decode_key
(
unsigned
int
tower_key)
135
{
136
int
index
= 0;
137
138
if
(
_detector
== DETECTOR::EMCAL)
139
{
140
index =
TowerInfoContainer::decode_emcal
(tower_key);
141
}
142
else
if
(
_detector
== DETECTOR::HCAL)
143
{
144
index =
TowerInfoContainer::decode_hcal
(tower_key);
145
}
146
else
if
(
_detector
==
DETECTOR::SEPD
)
147
{
148
index =
TowerInfoContainer::decode_epd
(tower_key);
149
}
150
else
if
(
_detector
==
DETECTOR::MBD
)
151
{
152
index =
TowerInfoContainer::decode_mbd
(tower_key);
153
}
154
else
if
(
_detector
==
DETECTOR::ZDC
)
155
{
156
index =
TowerInfoContainer::decode_zdc
(tower_key);
157
}
158
return
index
;
159
}
coresoftware
blob
master
offline
packages
CaloBase
TowerInfoContainerv2.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:05
using
1.8.2 with
sPHENIX GitHub integration