CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DistanceToCell.cc
Go to the documentation of this file.
2 
6 
7 DistanceToCell::DistanceToCell() : det_(nullptr) { ; }
8 
10  det_ = dist.det_;
12  pivot_ = dist.pivot_;
13 }
14 
15 DistanceToCell::DistanceToCell(const CaloSubdetectorGeometry* det, const DetId& cell) : det_(det), pivot_(cell) {
16  pivotPosition_ = (cell.det() == DetId::Hcal) ? (static_cast<const HcalGeometry*>(det_))->getPosition(cell)
17  : det_->getGeometry(pivot_)->getPosition();
18 }
19 
20 bool DistanceToCell::operator()(const DetId& c1, const DetId& c2) {
21  bool ok = (c1.det() == DetId::Hcal)
22  ? (((static_cast<const HcalGeometry*>(det_))->getPosition(c1) - pivotPosition_).mag2() <
23  ((static_cast<const HcalGeometry*>(det_))->getPosition(c2) - pivotPosition_).mag2())
24  : ((det_->getGeometry(c1)->getPosition() - pivotPosition_).mag2() <
25  (det_->getGeometry(c2)->getPosition() - pivotPosition_).mag2());
26  return ok;
27 }
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
GlobalPoint pivotPosition_
Definition: DetId.h:17
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const CaloSubdetectorGeometry * det_
bool operator()(const DetId &c1, const DetId &c2)
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46