ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
10#include <sstream>
11#include <iostream>
12
13using std::cout;
14using std::endl;
15
16using namespace LArSamples;
17
18// Add raw here:--
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{
26}
27
28
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)
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{
40}
41
42CellInfo::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),
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{
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
55CellInfo::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{
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
70{
72 if (m_shapeL) delete m_shapeL;
73 if (m_shapeM) delete m_shapeM;
74 if (m_shapeH) delete m_shapeH;
75}
76
77
79{
80 switch (gain) {
81 case CaloGain::LARLOWGAIN : return m_shapeL;
83 case CaloGain::LARHIGHGAIN : return m_shapeH;
84 default : return nullptr;
85 }
86 return nullptr;
87}
88
89
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
102short CellInfo::feb() const
103{
104 // slot starts at 1!
105 return slot() - 1 + Geo::nSlots(partition())*feedThrough();
106}
107
108
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
126{
127 short offset = 0;
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
139TString 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
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
189double 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
199{
200 return Id::partition(calo());
201}
202
203
204TVector3 CellInfo::position() const
205{
206 TVector3 v;
207 v.SetPtEtaPhi(m_rt, m_eta, m_phi);
208 return v;
209}
210
static Double_t ss
short feb() const
Definition CellInfo.cxx:102
double eta() const
Definition CellInfo.h:93
bool isValid() const
Definition CellInfo.cxx:173
short slot() const
Definition CellInfo.h:68
short layer() const
Definition CellInfo.h:53
TVector3 position() const
Definition CellInfo.cxx:204
bool setShape(CaloGain::CaloGain gain, ShapeInfo *shape)
Definition CellInfo.cxx:90
short feedThrough() const
Definition CellInfo.h:65
TString location(int verbose=1) const
Definition CellInfo.cxx:139
ShapeInfo * m_shapeM
Definition CellInfo.h:102
short region() const
Definition CellInfo.h:59
PartitionId partition() const
Definition CellInfo.cxx:198
double phi() const
Definition CellInfo.h:94
ULong64_t onlid() const
Definition CellInfo.h:90
ShapeInfo * m_shapeL
Definition CellInfo.h:102
short iPhi() const
Definition CellInfo.h:62
short globalPhiRing() const
Definition CellInfo.cxx:125
const ShapeInfo * shape(CaloGain::CaloGain gain) const
Definition CellInfo.cxx:78
CaloId calo() const
Definition CellInfo.h:50
ShapeInfo * m_shapeH
Definition CellInfo.h:102
double footprint() const
Definition CellInfo.cxx:189
CellInfo()
Constructor.
Definition CellInfo.cxx:19
~CellInfo()
Destructor.
Definition CellInfo.cxx:69
short globalFeb() const
Definition CellInfo.cxx:109
short channel() const
Definition CellInfo.h:76
unsigned int m_calo
Definition CellInfo.h:100
short iEta() const
Definition CellInfo.h:56
static short firstEta(CaloId calo, short layer, short region=0)
Definition Geometry.cxx:146
static short firstLayer(CaloId calo)
Definition Geometry.cxx:104
static short nEta(CaloId calo, short layer, short region, short iPhi=1)
Definition Geometry.cxx:169
static short nLayers(CaloId calo)
Definition Geometry.cxx:114
static short nRegions(CaloId calo, short layer)
Definition Geometry.cxx:124
static short nSlots(PartitionId part)
Definition Geometry.cxx:59
static PartitionId partition(CaloId id)
Definition CaloId.cxx:157
static TString str(CaloId id)
Definition CaloId.cxx:15
int r
Definition globals.cxx:22
bool verbose
Definition hcg.cxx:73
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ LARHIGHGAIN
Definition CaloGain.h:18
@ EMEC_INNER_C
Definition CaloId.h:22
@ UNKNOWN_CALO
Definition CaloId.h:23
@ EMEC_INNER_A
Definition CaloId.h:24
@ EMEC_OUTER_C
Definition CaloId.h:22
@ EMEC_OUTER_A
Definition CaloId.h:24
@ EMEC_A_PARTITION
Definition CaloId.h:30
@ FCAL_C_PARTITION
Definition CaloId.h:31
@ HEC_C_PARTITION
Definition CaloId.h:31
@ EMB_A_PARTITION
Definition CaloId.h:30
@ FCAL_A_PARTITION
Definition CaloId.h:31
@ EMB_C_PARTITION
Definition CaloId.h:30
@ EMEC_C_PARTITION
Definition CaloId.h:30
@ HEC_A_PARTITION
Definition CaloId.h:31
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)