Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-06 04:13:36

0001 #ifndef DTGeometry_DTGeometry_h
0002 #define DTGeometry_DTGeometry_h
0003 
0004 /** \class DTGeometry
0005  *
0006  *  The model of the geometry of Muon Drift Tube detectors.
0007  *
0008  *  The geometry owns the DTChamber s; these own their DTSuperLayer s which 
0009  *  in turn own their DTLayer s.
0010  *
0011  *  \author N. Amapane - CERN
0012  */
0013 
0014 #include <DataFormats/DetId/interface/DetId.h>
0015 #include <Geometry/CommonDetUnit/interface/TrackingGeometry.h>
0016 #include "Geometry/DTGeometry/interface/DTChamber.h"
0017 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
0018 #include "Geometry/DTGeometry/interface/DTLayer.h"
0019 #include <vector>
0020 #include <map>
0021 
0022 class GeomDetType;
0023 
0024 namespace cms {
0025   class DTGeometryBuilder;
0026 }
0027 
0028 class DTGeometry : public TrackingGeometry {
0029   typedef std::map<DetId, GeomDet*> DTDetMap;
0030 
0031 public:
0032   /// Default constructor
0033   DTGeometry();
0034 
0035   /// Destructor
0036   ~DTGeometry() override;
0037 
0038   void clear();
0039 
0040   //---- Base class' interface
0041 
0042   // Return a vector of all det types
0043   const DetTypeContainer& detTypes() const override;
0044 
0045   // Returm a vector of all GeomDetUnit
0046   const DetContainer& detUnits() const override;
0047 
0048   // Returm a vector of all GeomDet (including all GeomDetUnits)
0049   const DetContainer& dets() const override;
0050 
0051   // Returm a vector of all GeomDetUnit DetIds
0052   const DetIdContainer& detUnitIds() const override;
0053 
0054   // Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
0055   const DetIdContainer& detIds() const override;
0056 
0057   // Return the pointer to the GeomDetUnit corresponding to a given DetId
0058   const GeomDet* idToDetUnit(DetId) const override;
0059 
0060   // Return the pointer to the GeomDet corresponding to a given DetId
0061   const GeomDet* idToDet(DetId) const override;
0062 
0063   //---- Extension of the interface
0064 
0065   /// Return a vector of all Chamber
0066   const std::vector<const DTChamber*>& chambers() const;
0067 
0068   /// Return a vector of all SuperLayer
0069   const std::vector<const DTSuperLayer*>& superLayers() const;
0070 
0071   /// Return a vector of all SuperLayer
0072   const std::vector<const DTLayer*>& layers() const;
0073 
0074   /// Return a DTChamber given its id
0075   const DTChamber* chamber(const DTChamberId& id) const;
0076 
0077   /// Return a DTSuperLayer given its id
0078   const DTSuperLayer* superLayer(const DTSuperLayerId& id) const;
0079 
0080   /// Return a layer given its id
0081   const DTLayer* layer(const DTLayerId& id) const;
0082 
0083 private:
0084   friend class cms::DTGeometryBuilder;
0085   friend class DTGeometryBuilderFromDDD;
0086   friend class DTGeometryBuilderFromDD4hep;
0087   friend class DTGeometryBuilderFromCondDB;
0088 
0089   friend class GeometryAligner;
0090 
0091   void deallocate();
0092 
0093   /// Add a DTChamber to Geometry
0094   void add(DTChamber* ch);
0095 
0096   /// Add a DTSuperLayer to Geometry
0097   void add(DTSuperLayer* sl);
0098 
0099   /// Add a DTLayer to Geometry
0100   void add(DTLayer* l);
0101 
0102   // The chambers are owned by the geometry (and in turn own superlayers
0103   // and layers)
0104   std::vector<const DTChamber*> theChambers;
0105 
0106   // All following pointers are redundant; they are used only for an
0107   // efficient implementation of the interface, and are NOT owned.
0108 
0109   std::vector<const DTSuperLayer*> theSuperLayers;
0110   std::vector<const DTLayer*> theLayers;
0111 
0112   // Map for efficient lookup by DetId
0113   DTDetMap theMap;
0114 
0115   // These are used rarely; they could be computed at runtime
0116   // to save memory.
0117   DetContainer theDetUnits;  // all layers
0118   DetContainer theDets;      // all chambers, SL, layers
0119 
0120   // Replace local static with mutable members
0121   // to allow lazy evaluation if (ever) needed.
0122   DetTypeContainer theDetTypes;
0123   DetIdContainer theDetUnitIds;
0124   DetIdContainer theDetIds;
0125 };
0126 
0127 #endif