Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:34

0001 #include "FastSimulation/CaloGeometryTools/interface/DistanceToCell.h"
0002 
0003 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0004 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0005 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
0006 
0007 DistanceToCell::DistanceToCell() : det_(nullptr) { ; }
0008 
0009 DistanceToCell::DistanceToCell(const DistanceToCell& dist) {
0010   det_ = dist.det_;
0011   pivotPosition_ = dist.pivotPosition_;
0012   pivot_ = dist.pivot_;
0013 }
0014 
0015 DistanceToCell::DistanceToCell(const CaloSubdetectorGeometry* det, const DetId& cell) : det_(det), pivot_(cell) {
0016   pivotPosition_ = (cell.det() == DetId::Hcal) ? (static_cast<const HcalGeometry*>(det_))->getPosition(cell)
0017                                                : det_->getGeometry(pivot_)->getPosition();
0018 }
0019 
0020 bool DistanceToCell::operator()(const DetId& c1, const DetId& c2) {
0021   bool ok = (c1.det() == DetId::Hcal)
0022                 ? (((static_cast<const HcalGeometry*>(det_))->getPosition(c1) - pivotPosition_).mag2() <
0023                    ((static_cast<const HcalGeometry*>(det_))->getPosition(c2) - pivotPosition_).mag2())
0024                 : ((det_->getGeometry(c1)->getPosition() - pivotPosition_).mag2() <
0025                    (det_->getGeometry(c2)->getPosition() - pivotPosition_).mag2());
0026   return ok;
0027 }