CMS 3D CMS Logo

DTSuperLayer.cc
Go to the documentation of this file.
1 
7 /* This Class Header */
8 
9 /* Base Class Headers */
11 
12 /* Collaborating Class Header */
14 
15 /* C++ Headers */
16 #include <iostream>
17 
18 /* ====================================================================== */
19 
20 /* Constructor */
22  : GeomDet(plane), theId(id), theLayers(4, (const DTLayer*)nullptr), theCh(ch) {
23  setDetId(id);
24 }
25 
26 /* Destructor */
28  for (std::vector<const DTLayer*>::const_iterator il = theLayers.begin(); il != theLayers.end(); ++il)
29  delete (*il);
30 }
31 
32 /* Operations */
33 
35 
36 bool DTSuperLayer::operator==(const DTSuperLayer& sl) const { return id() == sl.id(); }
37 
39 std::vector<const GeomDet*> DTSuperLayer::components() const {
40  return std::vector<const GeomDet*>(theLayers.begin(), theLayers.end());
41 }
42 
43 const GeomDet* DTSuperLayer::component(DetId id) const { return layer(DTLayerId(id.rawId())); }
44 
45 const std::vector<const DTLayer*>& DTSuperLayer::layers() const { return theLayers; }
46 
48  // theLayers size is preallocated.
49  theLayers[l->id().layer() - 1] = l;
50 }
51 
52 const DTChamber* DTSuperLayer::chamber() const { return theCh; }
53 
54 const DTLayer* DTSuperLayer::layer(const DTLayerId& id) const {
55  if (id.superlayerId() != theId)
56  return nullptr; // not in this SL!
57  return layer(id.layer());
58 }
59 
60 const DTLayer* DTSuperLayer::layer(int ilay) const {
61  if ((ilay >= 1) && (ilay <= 4)) {
62  return theLayers[ilay - 1];
63  } else {
64  return nullptr;
65  }
66 }
void setDetId(DetId id)
Definition: GeomDet.h:99
std::vector< const DTLayer * > theLayers
Definition: DTSuperLayer.h:68
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:47
const std::vector< const DTLayer * > & layers() const
Return the layers in the SL.
Definition: DTSuperLayer.cc:45
const DTChamber * chamber() const
Definition: DTSuperLayer.cc:52
DTSuperLayerId theId
Definition: DTSuperLayer.h:66
DTSuperLayer(const DTSuperLayerId &id, ReferenceCountingPointer< BoundPlane > &plane, const DTChamber *ch=nullptr)
Definition: DTSuperLayer.cc:21
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:54
const DTChamber * theCh
Definition: DTSuperLayer.h:69
Definition: DetId.h:17
const GeomDet * component(DetId id) const override
Return the layer with a given id in this SL.
Definition: DTSuperLayer.cc:43
bool operator==(const DTSuperLayer &sl) const
True if id are the same.
Definition: DTSuperLayer.cc:36
~DTSuperLayer() override
Definition: DTSuperLayer.cc:27
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:34
std::vector< const GeomDet * > components() const override
Return the layers in the SL.
Definition: DTSuperLayer.cc:39