CMS 3D CMS Logo

CaloGeometry.cc
Go to the documentation of this file.
4 
6 
7 const std::vector<DetId> CaloGeometry::k_emptyVec(0);
8 
9 CaloGeometry::CaloGeometry() : m_geos(kLength, nullptr) {}
10 
11 unsigned int CaloGeometry::makeIndex(DetId::Detector det, int subdet, bool& ok) const {
12  const unsigned int idet(det);
13 
14  ok = (kMinDet <= idet && kMaxDet >= idet && 0 <= subdet && kMaxSub >= subdet);
15  if (!ok)
16  edm::LogWarning("CaloGeometry") << "Det:Subdet " << idet << ":" << subdet << " min|max Det " << kMinDet << ":"
17  << kMaxDet << " min|max subdet 0:" << kMaxSub;
18 
19  return ((det - kMinDet) * kNSubDets + subdet);
20 }
21 
23  bool ok;
24  const unsigned int index = makeIndex(det, subdet, ok);
25  if (ok)
26  m_geos[index] = geom;
27 
28  edm::LogVerbatim("CaloGeometry") << "Detector=" << (int)det << ", subset=" << subdet << ", index=" << index
29  << ", size=" << m_geos.size();
30 
31  assert(ok);
32 }
33 
35  bool ok;
36 
37  const unsigned int index(makeIndex(id.det(), id.subdetId(), ok));
38  return (ok ? m_geos[index] : nullptr);
39 }
40 
42  bool ok;
43 
44  const unsigned int index(makeIndex(det, subdet, ok));
45  return (ok ? m_geos[index] : nullptr);
46 }
47 
48 static const GlobalPoint notFound(0, 0, 0);
49 
52  if (geom) {
53  GlobalPoint pos = geom->getGeometry(id)->getPosition();
54  return pos;
55  } else {
56  return notFound;
57  }
58 }
59 
60 std::shared_ptr<const CaloCellGeometry> CaloGeometry::getGeometry(const DetId& id) const {
62  if (geom) {
63  auto cell = geom->getGeometry(id);
64  return cell;
65  } else {
66  return std::shared_ptr<const CaloCellGeometry>();
67  }
68 }
69 
70 bool CaloGeometry::present(const DetId& id) const {
72  return (nullptr == geom ? false : geom->present(id));
73 }
74 
75 std::vector<DetId> CaloGeometry::getValidDetIds() const {
76  std::vector<DetId> returnValue;
77  returnValue.reserve(kLength);
78 
79  bool doneHcal(false);
80  for (unsigned int i(0); i != m_geos.size(); ++i) {
81  if (nullptr != m_geos[i]) {
82  const std::vector<DetId>& aVec = m_geos[i]->getValidDetIds();
83  if (aVec.empty()) {
84  edm::LogWarning("CaloGeometry") << "Valid det id list at index " << i << " is empty!";
85  }
86  const bool isHcal(!aVec.empty() && DetId::Hcal == aVec.front().det());
87  if (!doneHcal || !isHcal) {
88  returnValue.insert(returnValue.end(), aVec.begin(), aVec.end());
89  if (!doneHcal && isHcal)
90  doneHcal = true;
91  }
92  }
93  }
94  return returnValue;
95 }
96 
97 const std::vector<DetId>& CaloGeometry::getValidDetIds(DetId::Detector det, int subdet) const {
98  bool ok;
99 
100  const unsigned int index(makeIndex(det, subdet, ok));
101 
102  return (ok && (nullptr != m_geos[index]) ? m_geos[index]->getValidDetIds(det, subdet) : k_emptyVec);
103 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
CaloGeometry::kNSubDets
Definition: CaloGeometry.h:64
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
pos
Definition: PixelAliasList.h:18
DetId::Hcal
Definition: DetId.h:28
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
cms::cuda::assert
assert(be >=bs)
CaloGeometry::kMaxSub
Definition: CaloGeometry.h:63
CaloGeometry::present
bool present(const DetId &id) const
is this detid present in the geometry?
Definition: CaloGeometry.cc:70
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
CaloGeometry::CaloGeometry
CaloGeometry()
Definition: CaloGeometry.cc:9
CaloGeometry::k_emptyVec
static const std::vector< DetId > k_emptyVec
Definition: CaloGeometry.h:53
CaloGeometry::kLength
Definition: CaloGeometry.h:65
DetId
Definition: DetId.h:17
CaloGeometry::makeIndex
unsigned int makeIndex(DetId::Detector det, int subdet, bool &ok) const
Definition: CaloGeometry.cc:11
CaloGeometry::m_geos
std::vector< const CaloSubdetectorGeometry * > m_geos
Definition: CaloGeometry.h:55
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, GlobalTag >
edm::LogWarning
Definition: MessageLogger.h:141
CaloSubdetectorGeometry.h
CaloGeometry::getGeometry
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60
notFound
static const GlobalPoint notFound(0, 0, 0)
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogVerbatim
Definition: MessageLogger.h:297
DetId::Detector
Detector
Definition: DetId.h:24
CaloCellGeometry.h
CaloGeometry::getValidDetIds
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:75
CaloGeometry.h
CaloGeometry::kMaxDet
Definition: CaloGeometry.h:60
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CaloGeometry::setSubdetGeometry
void setSubdetGeometry(DetId::Detector det, int subdet, const CaloSubdetectorGeometry *geom)
Register a subdetector geometry.
Definition: CaloGeometry.cc:22
CaloGeometry::kMinDet
Definition: CaloGeometry.h:61