ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCafJobs
src
CellInfo.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCafJobs/CellInfo.h
"
6
7
#include "
LArCafJobs/ShapeInfo.h
"
8
#include "
LArCafJobs/Geometry.h
"
9
#include "
LArCafJobs/ClassCounts.h
"
10
#include <sstream>
11
#include <iostream>
12
13
using
std::cout;
14
using
std::endl;
15
16
using namespace
LArSamples
;
17
18
// Add raw here:--
19
CellInfo::CellInfo
()
20
:
m_calo
(
UNKNOWN_CALO
),
m_layer
(-1),
21
m_iEta
(-1),
m_iPhi
(-1),
m_feedThrough
(-1),
22
m_slot
(-1),
m_channel
(-1),
m_shapeL
(nullptr),
m_shapeM
(nullptr),
m_shapeH
(nullptr),
23
m_rt
(0),
m_eta
(0),
m_phi
(0),
m_onlid
(-1)
24
{
25
ClassCounts::incrementInstanceCount
(
"CellInfo"
);
26
}
27
28
29
CellInfo::CellInfo
(
CaloId
calo
,
short
layer
,
30
short
iEta
,
short
iPhi
,
short
feedThrough
,
short
slot
,
short
channel
,
31
ShapeInfo
* shapeL,
ShapeInfo
* shapeM,
ShapeInfo
* shapeH,
32
const
TVector3&
position
, ULong64_t
onlid
)
33
:
m_calo
(
calo
),
m_layer
(
layer
),
34
m_iEta
(
iEta
),
m_iPhi
(
iPhi
),
m_feedThrough
(
feedThrough
),
35
m_slot
(
slot
),
m_channel
(
channel
),
36
m_shapeL
(shapeL),
m_shapeM
(shapeM),
m_shapeH
(shapeH),
37
m_rt
(
position
.Pt()),
m_eta
(
position
.Eta()),
m_phi
(
position
.Phi()),
m_onlid
(
onlid
)
38
{
39
ClassCounts::incrementInstanceCount
(
"CellInfo"
);
40
}
41
42
CellInfo::CellInfo
(
const
CellInfo
& other,
bool
withShapes)
43
:
m_calo
(other.
m_calo
),
m_layer
(other.
m_layer
),
44
m_iEta
(other.
m_iEta
),
m_iPhi
(other.
m_iPhi
),
45
m_feedThrough
(other.
m_feedThrough
),
m_slot
(other.
m_slot
),
m_channel
(other.
m_channel
),
46
m_shapeL
(nullptr),
m_shapeM
(nullptr),
m_shapeH
(nullptr),
47
m_rt
(other.
m_rt
),
m_eta
(other.
m_eta
),
m_phi
(other.
m_phi
),
m_onlid
(other.
m_onlid
)
48
{
49
ClassCounts::incrementInstanceCount
(
"CellInfo"
);
50
if
(withShapes && other.m_shapeL)
m_shapeL
=
new
ShapeInfo
(*other.m_shapeL);
51
if
(withShapes && other.m_shapeM)
m_shapeM
=
new
ShapeInfo
(*other.m_shapeM);
52
if
(withShapes && other.m_shapeH)
m_shapeH
=
new
ShapeInfo
(*other.m_shapeH);
53
}
54
55
CellInfo::CellInfo
(
CellInfo
&& other) noexcept :
m_calo
(other.m_calo),
m_layer
(other.m_layer),
56
m_iEta
(other.m_iEta),
m_iPhi
(other.m_iPhi),
57
m_feedThrough
(other.m_feedThrough),
m_slot
(other.m_slot),
m_channel
(other.m_channel),
58
m_shapeL
(
nullptr
),
m_shapeM
(
nullptr
),
m_shapeH
(
nullptr
),
59
m_rt
(other.m_rt),
m_eta
(other.m_eta),
m_phi
(other.m_phi),
m_onlid
(other.m_onlid)
60
{
61
ClassCounts::incrementInstanceCount
(
"CellInfo"
);
62
std::swap
(
m_shapeL
, other.m_shapeL);
63
std::swap
(
m_shapeM
, other.m_shapeM);
64
std::swap
(
m_shapeH
, other.m_shapeH);
65
}
66
68
69
CellInfo::~CellInfo
()
70
{
71
ClassCounts::decrementInstanceCount
(
"CellInfo"
);
72
if
(
m_shapeL
)
delete
m_shapeL
;
73
if
(
m_shapeM
)
delete
m_shapeM
;
74
if
(
m_shapeH
)
delete
m_shapeH
;
75
}
76
77
78
const
ShapeInfo
*
CellInfo::shape
(
CaloGain::CaloGain
gain)
const
79
{
80
switch
(gain) {
81
case
CaloGain::LARLOWGAIN
:
return
m_shapeL
;
82
case
CaloGain::LARMEDIUMGAIN
:
return
m_shapeM
;
83
case
CaloGain::LARHIGHGAIN
:
return
m_shapeH
;
84
default :
return
nullptr
;
85
}
86
return
nullptr
;
87
}
88
89
90
bool
CellInfo::setShape
(
CaloGain::CaloGain
gain,
ShapeInfo
*
shape
)
91
{
92
switch
(gain) {
93
case
CaloGain::LARLOWGAIN
:
m_shapeL
=
shape
;
return
true
;
94
case
CaloGain::LARMEDIUMGAIN
:
m_shapeM
=
shape
;
return
true
;
95
case
CaloGain::LARHIGHGAIN
:
m_shapeH
=
shape
;
return
true
;
96
default :
return
false
;
97
}
98
return
false
;
99
}
100
101
102
short
CellInfo::feb
()
const
103
{
104
// slot starts at 1!
105
return
slot
() - 1 +
Geo::nSlots
(
partition
())*
feedThrough
();
106
}
107
108
109
short
CellInfo::globalFeb
()
const
110
{
111
short
offset = 0;
112
PartitionId
part;
113
part =
EMB_A_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
114
part =
EMB_C_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
115
part =
EMEC_A_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
116
part =
EMEC_C_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
117
part =
HEC_A_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
118
part =
HEC_C_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
119
part =
FCAL_A_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
(); offset +=
Geo::nSlots
(part);
120
part =
FCAL_C_PARTITION
;
if
(
partition
() == part)
return
offset +
feb
();
121
return
-1;
122
}
123
124
125
short
CellInfo::globalPhiRing
()
const
126
{
127
short
offset = 0;
128
CaloId
cal[10] = {
EMB_A
,
EMB_C
,
EMEC_OUTER_A
,
EMEC_OUTER_C
,
EMEC_INNER_A
,
EMEC_INNER_C
,
HEC_A
,
HEC_C
,
FCAL_A
,
FCAL_C
};
129
for
(
unsigned
int
c = 0; c < 10; c++)
130
for
(
unsigned
short
l =
Geo::firstLayer
(cal[c]); l <
Geo::firstLayer
(cal[c]) +
Geo::nLayers
(cal[c]); l++)
131
for
(
unsigned
short
r
= 0;
r
<
Geo::nRegions
(cal[c], l);
r
++) {
132
if
(
calo
() == cal[c] &&
layer
() == l &&
region
() ==
r
)
return
offset + (
iEta
() -
Geo::firstEta
(
calo
(),
layer
(),
region
()));
133
offset +=
Geo::nEta
(cal[c], l,
r
);
134
}
135
136
return
-1;
137
}
138
139
TString
CellInfo::location
(
int
verbose
)
const
140
{
141
TString loc =
Id::str
(
calo
());
142
if
(loc ==
Id::str
(
UNKNOWN_CALO
))
return
loc;
143
144
if
(
verbose
== 0) {
145
std::ostringstream
ss
;
146
ss
<<
"("
<<
m_layer
<<
")"
;
147
loc +=
" "
+
ss
.str();
148
return
loc;
149
}
150
151
if
(
verbose
== 1) {
152
std::ostringstream
ss
;
153
ss
<<
"("
<<
layer
() <<
")"
<<
" "
<<
feedThrough
() <<
"/"
<<
slot
() <<
"/"
<<
channel
();
154
loc +=
" "
+
ss
.str();
155
return
loc;
156
}
157
158
std::ostringstream
ss
;
159
ss
<<
"layer "
<<
layer
() <<
", FT "
<<
feedThrough
()
160
<<
", slot "
<<
slot
() <<
", channel "
<<
channel
()
161
<<
", (eta, phi) = "
<< Form(
"(%4.2f, %4.2f)"
,
eta
(),
phi
());
162
163
if
(
verbose
== 2) {
164
loc +=
" "
+
ss
.str();
165
return
loc;
166
}
167
ss
<<
", (iEta, iPhi, region) = ("
<<
iEta
() <<
", "
<<
iPhi
() <<
", "
<<
region
() <<
")"
;
168
loc +=
" "
+
ss
.str();
169
return
loc;
170
}
171
172
173
bool
CellInfo::isValid
()
const
174
{
175
//if (!m_shape || !m_shape->isValid()) return false;
176
177
if
(
m_calo
==
UNKNOWN_CALO
)
return
false
;
178
if
(
m_layer
< 0)
return
false
;
179
if
(
m_iEta
< 0)
return
false
;
180
if
(
m_iPhi
< 0)
return
false
;
181
if
(
m_feedThrough
< 0)
return
false
;
182
if
(
m_slot
< 0)
return
false
;
183
if
(
m_channel
< 0)
return
false
;
184
185
return
true
;
186
}
187
188
189
double
CellInfo::footprint
()
const
190
{
191
return
sizeof
(*this)
192
+ (
m_shapeL
?
m_shapeL
->footprint() : 0)
193
+ (
m_shapeM
?
m_shapeM
->footprint() : 0)
194
+ (
m_shapeH
?
m_shapeH
->footprint() : 0);
195
}
196
197
198
PartitionId
CellInfo::partition
()
const
199
{
200
return
Id::partition
(
calo
());
201
}
202
203
204
TVector3
CellInfo::position
()
const
205
{
206
TVector3 v;
207
v.SetPtEtaPhi(
m_rt
,
m_eta
,
m_phi
);
208
return
v;
209
}
210
CellInfo.h
Geometry.h
ClassCounts.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
ShapeInfo.h
LArSamples::CellInfo::feb
short feb() const
Definition
CellInfo.cxx:102
LArSamples::CellInfo::eta
double eta() const
Definition
CellInfo.h:93
LArSamples::CellInfo::isValid
bool isValid() const
Definition
CellInfo.cxx:173
LArSamples::CellInfo::slot
short slot() const
Definition
CellInfo.h:68
LArSamples::CellInfo::layer
short layer() const
Definition
CellInfo.h:53
LArSamples::CellInfo::position
TVector3 position() const
Definition
CellInfo.cxx:204
LArSamples::CellInfo::m_eta
double m_eta
Definition
CellInfo.h:103
LArSamples::CellInfo::setShape
bool setShape(CaloGain::CaloGain gain, ShapeInfo *shape)
Definition
CellInfo.cxx:90
LArSamples::CellInfo::feedThrough
short feedThrough() const
Definition
CellInfo.h:65
LArSamples::CellInfo::m_feedThrough
short m_feedThrough
Definition
CellInfo.h:101
LArSamples::CellInfo::location
TString location(int verbose=1) const
Definition
CellInfo.cxx:139
LArSamples::CellInfo::m_layer
short m_layer
Definition
CellInfo.h:101
LArSamples::CellInfo::m_shapeM
ShapeInfo * m_shapeM
Definition
CellInfo.h:102
LArSamples::CellInfo::region
short region() const
Definition
CellInfo.h:59
LArSamples::CellInfo::partition
PartitionId partition() const
Definition
CellInfo.cxx:198
LArSamples::CellInfo::phi
double phi() const
Definition
CellInfo.h:94
LArSamples::CellInfo::onlid
ULong64_t onlid() const
Definition
CellInfo.h:90
LArSamples::CellInfo::m_slot
short m_slot
Definition
CellInfo.h:101
LArSamples::CellInfo::m_shapeL
ShapeInfo * m_shapeL
Definition
CellInfo.h:102
LArSamples::CellInfo::m_channel
short m_channel
Definition
CellInfo.h:101
LArSamples::CellInfo::iPhi
short iPhi() const
Definition
CellInfo.h:62
LArSamples::CellInfo::m_rt
double m_rt
Definition
CellInfo.h:103
LArSamples::CellInfo::globalPhiRing
short globalPhiRing() const
Definition
CellInfo.cxx:125
LArSamples::CellInfo::m_iPhi
short m_iPhi
Definition
CellInfo.h:101
LArSamples::CellInfo::m_onlid
ULong64_t m_onlid
Definition
CellInfo.h:104
LArSamples::CellInfo::m_iEta
short m_iEta
Definition
CellInfo.h:101
LArSamples::CellInfo::shape
const ShapeInfo * shape(CaloGain::CaloGain gain) const
Definition
CellInfo.cxx:78
LArSamples::CellInfo::calo
CaloId calo() const
Definition
CellInfo.h:50
LArSamples::CellInfo::m_phi
double m_phi
Definition
CellInfo.h:103
LArSamples::CellInfo::m_shapeH
ShapeInfo * m_shapeH
Definition
CellInfo.h:102
LArSamples::CellInfo::footprint
double footprint() const
Definition
CellInfo.cxx:189
LArSamples::CellInfo::CellInfo
CellInfo()
Constructor.
Definition
CellInfo.cxx:19
LArSamples::CellInfo::~CellInfo
~CellInfo()
Destructor.
Definition
CellInfo.cxx:69
LArSamples::CellInfo::globalFeb
short globalFeb() const
Definition
CellInfo.cxx:109
LArSamples::CellInfo::channel
short channel() const
Definition
CellInfo.h:76
LArSamples::CellInfo::m_calo
unsigned int m_calo
Definition
CellInfo.h:100
LArSamples::CellInfo::iEta
short iEta() const
Definition
CellInfo.h:56
LArSamples::ClassCounts::incrementInstanceCount
void incrementInstanceCount() const
Definition
LArCafJobs/LArCafJobs/ClassCounts.h:32
LArSamples::ClassCounts::decrementInstanceCount
void decrementInstanceCount() const
Definition
LArCafJobs/LArCafJobs/ClassCounts.h:33
LArSamples::Geo::firstEta
static short firstEta(CaloId calo, short layer, short region=0)
Definition
Geometry.cxx:146
LArSamples::Geo::firstLayer
static short firstLayer(CaloId calo)
Definition
Geometry.cxx:104
LArSamples::Geo::nEta
static short nEta(CaloId calo, short layer, short region, short iPhi=1)
Definition
Geometry.cxx:169
LArSamples::Geo::nLayers
static short nLayers(CaloId calo)
Definition
Geometry.cxx:114
LArSamples::Geo::nRegions
static short nRegions(CaloId calo, short layer)
Definition
Geometry.cxx:124
LArSamples::Geo::nSlots
static short nSlots(PartitionId part)
Definition
Geometry.cxx:59
LArSamples::Id::partition
static PartitionId partition(CaloId id)
Definition
CaloId.cxx:157
LArSamples::Id::str
static TString str(CaloId id)
Definition
CaloId.cxx:15
LArSamples::ShapeInfo
Definition
ShapeInfo.h:24
r
int r
Definition
globals.cxx:22
verbose
bool verbose
Definition
hcg.cxx:75
CaloGain::CaloGain
CaloGain
Definition
CaloGain.h:11
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition
CaloGain.h:18
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition
CaloGain.h:18
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
LArSamples
Definition
AbsShape.h:24
LArSamples::CaloId
CaloId
Definition
CaloId.h:21
LArSamples::EMB_C
@ EMB_C
Definition
CaloId.h:22
LArSamples::HEC_C
@ HEC_C
Definition
CaloId.h:22
LArSamples::FCAL_A
@ FCAL_A
Definition
CaloId.h:24
LArSamples::EMEC_INNER_C
@ EMEC_INNER_C
Definition
CaloId.h:22
LArSamples::HEC_A
@ HEC_A
Definition
CaloId.h:24
LArSamples::UNKNOWN_CALO
@ UNKNOWN_CALO
Definition
CaloId.h:23
LArSamples::EMEC_INNER_A
@ EMEC_INNER_A
Definition
CaloId.h:24
LArSamples::EMB_A
@ EMB_A
Definition
CaloId.h:24
LArSamples::FCAL_C
@ FCAL_C
Definition
CaloId.h:22
LArSamples::EMEC_OUTER_C
@ EMEC_OUTER_C
Definition
CaloId.h:22
LArSamples::EMEC_OUTER_A
@ EMEC_OUTER_A
Definition
CaloId.h:24
LArSamples::PartitionId
PartitionId
Definition
CaloId.h:29
LArSamples::EMEC_A_PARTITION
@ EMEC_A_PARTITION
Definition
CaloId.h:30
LArSamples::FCAL_C_PARTITION
@ FCAL_C_PARTITION
Definition
CaloId.h:31
LArSamples::HEC_C_PARTITION
@ HEC_C_PARTITION
Definition
CaloId.h:31
LArSamples::EMB_A_PARTITION
@ EMB_A_PARTITION
Definition
CaloId.h:30
LArSamples::FCAL_A_PARTITION
@ FCAL_A_PARTITION
Definition
CaloId.h:31
LArSamples::EMB_C_PARTITION
@ EMB_C_PARTITION
Definition
CaloId.h:30
LArSamples::EMEC_C_PARTITION
@ EMEC_C_PARTITION
Definition
CaloId.h:30
LArSamples::HEC_A_PARTITION
@ HEC_A_PARTITION
Definition
CaloId.h:31
std::swap
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Definition
AthLinks/ElementLinkVector.h:484
Generated on
for ATLAS Offline Software by
1.17.0