Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:39

0001 #include "Geometry/GEMGeometry/interface/GEMSuperChamber.h"
0002 #include "Geometry/GEMGeometry/interface/GEMChamber.h"
0003 
0004 GEMSuperChamber::GEMSuperChamber(GEMDetId id, const ReferenceCountingPointer<BoundPlane>& plane)
0005     : GeomDet(plane), detId_(id) {
0006   setDetId(id);
0007 }
0008 
0009 GEMSuperChamber::~GEMSuperChamber() {}
0010 
0011 GEMDetId GEMSuperChamber::id() const { return detId_; }
0012 
0013 bool GEMSuperChamber::operator==(const GEMSuperChamber& sch) const { return this->id() == sch.id(); }
0014 
0015 void GEMSuperChamber::add(const GEMChamber* ch) { chambers_.emplace_back(ch); }
0016 
0017 std::vector<const GeomDet*> GEMSuperChamber::components() const {
0018   return std::vector<const GeomDet*>(chambers_.begin(), chambers_.end());
0019 }
0020 
0021 const GeomDet* GEMSuperChamber::component(DetId id) const { return chamber(GEMDetId(id.rawId())); }
0022 
0023 const std::vector<const GEMChamber*>& GEMSuperChamber::chambers() const { return chambers_; }
0024 
0025 int GEMSuperChamber::nChambers() const { return chambers_.size(); }
0026 
0027 const GEMChamber* GEMSuperChamber::chamber(GEMDetId id) const {
0028   if (id.chamber() != detId_.chamber())
0029     return nullptr;  // not in this super chamber!
0030   return chamber(id.layer());
0031 }
0032 
0033 const GEMChamber* GEMSuperChamber::chamber(int isl) const {
0034   for (auto ch : chambers_) {
0035     if (ch->id().layer() == isl)
0036       return ch;
0037   }
0038   return nullptr;
0039 }
0040 
0041 float GEMSuperChamber::computeDeltaPhi(const LocalPoint& position, const LocalVector& direction) const {
0042   auto extrap = [](const LocalPoint& point, const LocalVector& dir, double extZ) -> LocalPoint {
0043     if (dir.z() == 0)
0044       return LocalPoint(0.f, 0.f, extZ);
0045     double extX = point.x() + extZ * dir.x() / dir.z();
0046     double extY = point.y() + extZ * dir.y() / dir.z();
0047     return LocalPoint(extX, extY, extZ);
0048   };
0049   if (nChambers() < 2) {
0050     return 0.f;
0051   }
0052 
0053   const float beginOfChamber = chamber(1)->position().z();
0054   const float centerOfChamber = this->position().z();
0055   const float endOfChamber = chamber(nChambers())->position().z();
0056 
0057   LocalPoint projHigh =
0058       extrap(position, direction, (centerOfChamber < 0 ? -1.0 : 1.0) * (endOfChamber - centerOfChamber));
0059   LocalPoint projLow =
0060       extrap(position, direction, (centerOfChamber < 0 ? -1.0 : 1.0) * (beginOfChamber - centerOfChamber));
0061   auto globLow = toGlobal(projLow);
0062   auto globHigh = toGlobal(projHigh);
0063   return globHigh.phi() - globLow.phi();  //Geom::phi automatically normalizes to [-pi, pi]
0064 }