CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Geometry/DTGeometry/src/DTChamber.cc

Go to the documentation of this file.
00001 
00008 /* This Class Header */
00009 #include "Geometry/DTGeometry/interface/DTChamber.h"
00010 
00011 /* Collaborating Class Header */
00012 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
00013 #include "Geometry/DTGeometry/interface/DTLayer.h"
00014 
00015 /* C++ Headers */
00016 #include <iostream>
00017 
00018 /* ====================================================================== */
00019 
00020 /* Constructor */ 
00021 DTChamber::DTChamber(DTChamberId id, const ReferenceCountingPointer<BoundPlane>& plane) :
00022   GeomDet(plane), 
00023   theId(id) {
00024   setDetId(id);
00025 }
00026 
00027 /* Destructor */ 
00028 DTChamber::~DTChamber() {
00029   for (std::vector<const DTSuperLayer*>::const_iterator isl=theSLs.begin();
00030        isl!=theSLs.end(); ++isl) delete (*isl);
00031 }
00032 
00033 /* Operations */ 
00034 
00035 DTChamberId DTChamber::id() const {
00036   return theId;
00037 }
00038 
00039 bool DTChamber::operator==(const DTChamber& ch) const {
00040   return id()==ch.id();
00041 }
00042 
00043 void DTChamber::add(DTSuperLayer* sl) {
00044   theSLs.push_back(sl);
00045 }
00046 
00047 std::vector<const GeomDet*> DTChamber::components() const {
00048   return  std::vector<const GeomDet*>(theSLs.begin(), theSLs.end());
00049 }
00050 
00051 
00052 const GeomDet* DTChamber::component(DetId id) const {
00053   DTLayerId lId(id.rawId());
00054   if (lId.layer()==0) { // is a SL id
00055     return superLayer(lId);
00056   } else { // is a layer id
00057     return layer(lId);
00058   }
00059 }
00060 
00061 
00062 const std::vector<const DTSuperLayer*>& DTChamber::superLayers() const {
00063   return theSLs;
00064 }
00065 
00066 
00067 const DTSuperLayer* DTChamber::superLayer(DTSuperLayerId id) const{
00068   if (id.chamberId()!=theId) return 0; // not in this SL!
00069   return superLayer(id.superLayer());
00070 }
00071 
00072 
00073 const DTSuperLayer* DTChamber::superLayer(int isl) const {
00074   for (std::vector<const DTSuperLayer*>::const_iterator i = theSLs.begin();
00075        i!= theSLs.end(); ++i) {
00076     if ((*i)->id().superLayer()==isl) return (*i);
00077   }
00078   return 0;
00079 }
00080 
00081 
00082 const DTLayer* DTChamber::layer(DTLayerId id) const {
00083   return (superLayer(id.superlayer()))->layer(id.layer());
00084 }
00085