CMS 3D CMS Logo

DTChamber.cc
Go to the documentation of this file.
1 
6 /* This Class Header */
8 
9 /* Collaborating Class Header */
12 
13 /* C++ Headers */
14 #include <iostream>
15 
16 /* ====================================================================== */
17 
18 /* Constructor */
20  : GeomDet(plane), theId(id) {
21  setDetId(id);
22 }
23 
24 /* Destructor */
26  for (std::vector<const DTSuperLayer*>::const_iterator isl = theSLs.begin(); isl != theSLs.end(); ++isl)
27  delete (*isl);
28 }
29 
30 /* Operations */
31 
32 DTChamberId DTChamber::id() const { return theId; }
33 
34 bool DTChamber::operator==(const DTChamber& ch) const { return id() == ch.id(); }
35 
36 void DTChamber::add(DTSuperLayer* sl) { theSLs.emplace_back(sl); }
37 
38 std::vector<const GeomDet*> DTChamber::components() const {
39  return std::vector<const GeomDet*>(theSLs.begin(), theSLs.end());
40 }
41 
43  DTLayerId lId(id.rawId());
44  if (lId.layer() == 0) { // is a SL id
45  return superLayer(lId);
46  } else { // is a layer id
47  return layer(lId);
48  }
49 }
50 
51 const std::vector<const DTSuperLayer*>& DTChamber::superLayers() const { return theSLs; }
52 
54  if (id.chamberId() != theId)
55  return nullptr; // not in this SL!
56  return superLayer(id.superLayer());
57 }
58 
59 const DTSuperLayer* DTChamber::superLayer(int isl) const {
60  for (auto theSL : theSLs) {
61  if (theSL->id().superLayer() == isl)
62  return theSL;
63  }
64  return nullptr;
65 }
66 
67 const DTLayer* DTChamber::layer(const DTLayerId& id) const { return (superLayer(id.superlayer()))->layer(id.layer()); }
bool operator==(const DTChamber &ch) const
equal if the id is the same
Definition: DTChamber.cc:34
DTChamberId id() const
Return the DTChamberId of this chamber.
Definition: DTChamber.cc:32
void setDetId(DetId id)
Definition: GeomDet.h:99
const GeomDet * component(DetId id) const override
Return the sub-component (SL or layer) with a given id in this chamber.
Definition: DTChamber.cc:42
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
std::vector< const GeomDet * > components() const override
Return the superlayers in the chamber.
Definition: DTChamber.cc:38
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Definition: DTChamber.cc:51
Definition: DetId.h:17
DTChamberId theId
Definition: DTChamber.h:64
std::vector< const DTSuperLayer * > theSLs
Definition: DTChamber.h:67
~DTChamber() override
Destructor.
Definition: DTChamber.cc:25
int layer() const
Return the layer number.
Definition: DTLayerId.h:45
void add(DTSuperLayer *sl)
Add SL to the chamber which takes ownership.
Definition: DTChamber.cc:36
DTChamber(const DTChamberId &id, const ReferenceCountingPointer< BoundPlane > &plane)
Constructor.
Definition: DTChamber.cc:19
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
Definition: DTChamber.cc:67