Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:54

0001 /** \file
0002  *
0003  *  \author N. Amapane - CERN
0004  */
0005 
0006 #include <Geometry/DTGeometry/interface/DTGeometry.h>
0007 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0008 
0009 #include <algorithm>
0010 #include <iostream>
0011 
0012 DTGeometry::DTGeometry() {}
0013 
0014 DTGeometry::~DTGeometry() { deallocate(); }
0015 
0016 void DTGeometry::deallocate() {
0017   // delete all the chambers (which will delete the SL which will delete the
0018   // layers)
0019   for (auto& theChamber : theChambers)
0020     delete theChamber;
0021 }
0022 
0023 void DTGeometry::clear() {
0024   deallocate();
0025 
0026   theChambers.clear();
0027   theSuperLayers.clear();
0028   theLayers.clear();
0029   theMap.clear();
0030   theDetUnits.clear();
0031   theDets.clear();
0032   theDetTypes.clear();
0033   theDetUnitIds.clear();
0034   theDetIds.clear();
0035 }
0036 
0037 const DTGeometry::DetTypeContainer& DTGeometry::detTypes() const {
0038   // FIXME - fill it at runtime
0039   return theDetTypes;
0040 }
0041 
0042 void DTGeometry::add(DTChamber* ch) {
0043   theDets.emplace_back(ch);
0044   theChambers.emplace_back(ch);
0045   theMap.insert(DTDetMap::value_type(ch->geographicalId(), ch));
0046 }
0047 
0048 void DTGeometry::add(DTSuperLayer* sl) {
0049   theDets.emplace_back(sl);
0050   theSuperLayers.emplace_back(sl);
0051   theMap.insert(DTDetMap::value_type(sl->geographicalId(), sl));
0052 }
0053 
0054 void DTGeometry::add(DTLayer* l) {
0055   theDetUnits.emplace_back(l);
0056   theDets.emplace_back(l);
0057   theLayers.emplace_back(l);
0058   theMap.insert(DTDetMap::value_type(l->geographicalId(), l));
0059 }
0060 
0061 const DTGeometry::DetContainer& DTGeometry::detUnits() const { return theDetUnits; }
0062 
0063 const DTGeometry::DetContainer& DTGeometry::dets() const { return theDets; }
0064 
0065 const DTGeometry::DetIdContainer& DTGeometry::detUnitIds() const {
0066   // FIXME - fill it at runtime
0067   return theDetUnitIds;
0068 }
0069 
0070 const DTGeometry::DetIdContainer& DTGeometry::detIds() const {
0071   // FIXME - fill it at runtime
0072   return theDetIds;
0073 }
0074 
0075 const GeomDet* DTGeometry::idToDetUnit(DetId id) const { return dynamic_cast<const GeomDet*>(idToDet(id)); }
0076 
0077 const GeomDet* DTGeometry::idToDet(DetId id) const {
0078   // Strip away wire#, if any!
0079   DTLayerId lId(id.rawId());
0080   DTDetMap::const_iterator i = theMap.find(lId);
0081   return (i != theMap.end()) ? i->second : nullptr;
0082 }
0083 
0084 const std::vector<const DTChamber*>& DTGeometry::chambers() const { return theChambers; }
0085 
0086 const std::vector<const DTSuperLayer*>& DTGeometry::superLayers() const { return theSuperLayers; }
0087 
0088 const std::vector<const DTLayer*>& DTGeometry::layers() const { return theLayers; }
0089 
0090 const DTChamber* DTGeometry::chamber(const DTChamberId& id) const { return (const DTChamber*)(idToDet(id)); }
0091 
0092 const DTSuperLayer* DTGeometry::superLayer(const DTSuperLayerId& id) const {
0093   return (const DTSuperLayer*)(idToDet(id));
0094 }
0095 
0096 const DTLayer* DTGeometry::layer(const DTLayerId& id) const { return (const DTLayer*)(idToDet(id)); }