File indexing completed on 2024-04-06 12:14:39
0001 #include "Geometry/GEMGeometry/interface/ME0Chamber.h"
0002 #include "Geometry/GEMGeometry/interface/ME0Layer.h"
0003 #include "Geometry/GEMGeometry/interface/ME0EtaPartition.h"
0004 #include <iostream>
0005
0006 ME0Chamber::ME0Chamber(ME0DetId id, const ReferenceCountingPointer<BoundPlane>& plane) : GeomDet(plane), detId_(id) {
0007 setDetId(id);
0008 }
0009
0010 ME0Chamber::~ME0Chamber() {}
0011
0012 ME0DetId ME0Chamber::id() const { return detId_; }
0013
0014 bool ME0Chamber::operator==(const ME0Chamber& ch) const { return this->id() == ch.id(); }
0015
0016 void ME0Chamber::add(ME0Layer* rl) { layers_.emplace_back(rl); }
0017
0018 std::vector<const GeomDet*> ME0Chamber::components() const {
0019 return std::vector<const GeomDet*>(layers_.begin(), layers_.end());
0020 }
0021
0022 const GeomDet* ME0Chamber::component(DetId id) const { return layer(ME0DetId(id.rawId())); }
0023
0024 const std::vector<const ME0Layer*>& ME0Chamber::layers() const { return layers_; }
0025
0026 int ME0Chamber::nLayers() const { return layers_.size(); }
0027
0028 const ME0Layer* ME0Chamber::layer(ME0DetId id) const {
0029 if (id.chamberId() != detId_)
0030 return nullptr;
0031 return layer(id.layer());
0032 }
0033
0034 const ME0Layer* ME0Chamber::layer(int isl) const {
0035 for (auto layer : layers_) {
0036 if (layer->id().layer() == isl)
0037 return layer;
0038 }
0039 return nullptr;
0040 }
0041
0042
0043
0044 void ME0Chamber::add(ME0EtaPartition* rl) { etaPartitions_.emplace_back(rl); }
0045
0046 const std::vector<const ME0EtaPartition*>& ME0Chamber::etaPartitions() const { return etaPartitions_; }
0047
0048 int ME0Chamber::nEtaPartitions() const { return etaPartitions_.size(); }
0049
0050 const ME0EtaPartition* ME0Chamber::etaPartition(ME0DetId id) const {
0051 if (id.chamberId() != detId_)
0052 return nullptr;
0053 return etaPartition(id.roll());
0054 }
0055
0056 const ME0EtaPartition* ME0Chamber::etaPartition(int isl) const {
0057 for (auto roll : etaPartitions_) {
0058 if (roll->id().roll() == isl)
0059 return roll;
0060 }
0061 return nullptr;
0062 }
0063
0064 float ME0Chamber::computeDeltaPhi(const LocalPoint& position, const LocalVector& direction) const {
0065 auto extrap = [](const LocalPoint& point, const LocalVector& dir, double extZ) -> LocalPoint {
0066 double extX = point.x() + extZ * dir.x() / dir.z();
0067 double extY = point.y() + extZ * dir.y() / dir.z();
0068 return LocalPoint(extX, extY, extZ);
0069 };
0070 if (nLayers() < 2) {
0071 return 0;
0072 }
0073
0074 const float beginOfChamber = layer(1)->position().z();
0075 const float centerOfChamber = this->position().z();
0076 const float endOfChamber = layer(nLayers())->position().z();
0077
0078 LocalPoint projHigh =
0079 extrap(position, direction, (centerOfChamber < 0 ? -1.0 : 1.0) * (endOfChamber - centerOfChamber));
0080 LocalPoint projLow =
0081 extrap(position, direction, (centerOfChamber < 0 ? -1.0 : 1.0) * (beginOfChamber - centerOfChamber));
0082 auto globLow = toGlobal(projLow);
0083 auto globHigh = toGlobal(projHigh);
0084 return globHigh.phi() - globLow.phi();
0085 }