Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:49:12

0001 /** \file
0002  *
0003  *  \author Stefano Lacaprara - INFN Padova <stefano.lacaprara@pd.infn.it>
0004  */
0005 
0006 /* This Class Header */
0007 #include "Geometry/DTGeometry/interface/DTChamber.h"
0008 
0009 /* Collaborating Class Header */
0010 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
0011 #include "Geometry/DTGeometry/interface/DTLayer.h"
0012 
0013 /* C++ Headers */
0014 #include <iostream>
0015 
0016 /* ====================================================================== */
0017 
0018 /* Constructor */
0019 DTChamber::DTChamber(const DTChamberId& id, const ReferenceCountingPointer<BoundPlane>& plane)
0020     : GeomDet(plane), theId(id) {
0021   setDetId(id);
0022 }
0023 
0024 /* Destructor */
0025 DTChamber::~DTChamber() {
0026   for (std::vector<const DTSuperLayer*>::const_iterator isl = theSLs.begin(); isl != theSLs.end(); ++isl)
0027     delete (*isl);
0028 }
0029 
0030 /* Operations */
0031 
0032 DTChamberId DTChamber::id() const { return theId; }
0033 
0034 bool DTChamber::operator==(const DTChamber& ch) const { return id() == ch.id(); }
0035 
0036 void DTChamber::add(DTSuperLayer* sl) { theSLs.emplace_back(sl); }
0037 
0038 std::vector<const GeomDet*> DTChamber::components() const {
0039   return std::vector<const GeomDet*>(theSLs.begin(), theSLs.end());
0040 }
0041 
0042 const GeomDet* DTChamber::component(DetId id) const {
0043   DTLayerId lId(id.rawId());
0044   if (lId.layer() == 0) {  // is a SL id
0045     return superLayer(lId);
0046   } else {  // is a layer id
0047     return layer(lId);
0048   }
0049 }
0050 
0051 const std::vector<const DTSuperLayer*>& DTChamber::superLayers() const { return theSLs; }
0052 
0053 const DTSuperLayer* DTChamber::superLayer(const DTSuperLayerId& id) const {
0054   if (id.chamberId() != theId)
0055     return nullptr;  // not in this SL!
0056   return superLayer(id.superLayer());
0057 }
0058 
0059 const DTSuperLayer* DTChamber::superLayer(int isl) const {
0060   for (auto theSL : theSLs) {
0061     if (theSL->id().superLayer() == isl)
0062       return theSL;
0063   }
0064   return nullptr;
0065 }
0066 
0067 const DTLayer* DTChamber::layer(const DTLayerId& id) const { return (superLayer(id.superlayer()))->layer(id.layer()); }