CMS 3D CMS Logo

DTGeometryBuilderFromCondDB.cc
Go to the documentation of this file.
1 /******* \class DTGeometryBuilderFromCondDB *******
2  *
3  * Description:
4  *
5  * detailed description
6  *
7  * \author : Stefano Lacaprara - INFN LNL <stefano.lacaprara@pd.infn.it>
8  *
9  * Modification:
10  *
11  *********************************/
12 
13 /* This Class Header */
15 
16 /* Collaborating Class Header */
24 
25 /* C++ Headers */
26 #include <iostream>
27 using namespace std;
28 
29 using namespace geant_units;
30 using namespace geant_units::operators;
31 
32 /* ====================================================================== */
33 
34 /* Constructor */
36 
37 /* Destructor */
39 
40 /* Operations */
41 void DTGeometryBuilderFromCondDB::build(const std::shared_ptr<DTGeometry>& theGeometry, const RecoIdealGeometry& rig) {
42  // cout << "DTGeometryBuilderFromCondDB " << endl;
43  const std::vector<DetId>& detids(rig.detIds());
44  // cout << "size " << detids.size() << endl;
45 
46  size_t idt = 0;
47  DTChamber* chamber(nullptr);
48  DTSuperLayer* sl(nullptr);
49  while (idt < detids.size()) {
50  //copy(par.begin(), par.end(), ostream_iterator<double>(std::cout," "));
51  if (int(*(rig.shapeStart(idt))) == 0) { // a Chamber
52  // add the provious chamber which by now has been updated with SL and
53  // layers
54  if (chamber)
55  theGeometry->add(chamber);
56  // go for the actual one
57  DTChamberId chid(detids[idt]);
58  //cout << "CH: " << chid << endl;
59  chamber = buildChamber(chid, rig, idt);
60  } else if (int(*(rig.shapeStart(idt))) == 1) { // a SL
61  DTSuperLayerId slid(detids[idt]);
62  //cout << " SL: " << slid << endl;
63  sl = buildSuperLayer(chamber, slid, rig, idt);
64  theGeometry->add(sl);
65  } else if (int(*(rig.shapeStart(idt))) == 2) { // a Layer
66  DTLayerId lid(detids[idt]);
67  //cout << " LAY: " << lid << endl;
68  DTLayer* lay = buildLayer(sl, lid, rig, idt);
69  theGeometry->add(lay);
70  } else {
71  cout << "What is this?" << endl;
72  }
73  ++idt;
74  }
75  if (chamber)
76  theGeometry->add(chamber); // add the last chamber
77 }
78 
79 // Calling function has the responsibility to delete the allocated RectangularPlaneBounds object
80 RectangularPlaneBounds* dtGeometryBuilder::getRecPlaneBounds(const std::vector<double>::const_iterator& shapeStart) {
81  float width = convertMmToCm(*(shapeStart)); // r-phi dimension - different in different chambers
82  float length = convertMmToCm(*(shapeStart + 1)); // z dimension - constant
83  float thickness = convertMmToCm(*(shapeStart + 2)); // radial thickness - almost constant
84  return new RectangularPlaneBounds(width, length, thickness);
85 }
86 
88  DTChamberId detId(id);
89 
91  // width is along local X
92  // length is along local Y
93  // length z dimension - constant 125.55 cm
94  // thickness is along local Z
95  // radial thickness - almost constant about 18 cm
96  RCPPlane surf(
97  plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds(++rig.shapeStart(idt))));
98 
99  DTChamber* chamber = new DTChamber(detId, surf);
100 
101  return chamber;
102 }
103 
105  const DetId& id,
106  const RecoIdealGeometry& rig,
107  size_t idt) const {
108  DTSuperLayerId slId(id);
109 
110  // r-phi dimension - different in different chambers
111  // z dimension - constant 126.8 cm
112  // radial thickness - almost constant about 5 cm
113 
114  // Ok this is the slayer position...
115  RCPPlane surf(
116  plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds(++rig.shapeStart(idt))));
117 
118  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
119 
120  // cout << "adding slayer " << slayer->id() << " to chamber "<< chamber->id() << endl;
121  assert(chamber);
122  chamber->add(slayer);
123  return slayer;
124 }
125 
127  const DetId& id,
128  const RecoIdealGeometry& rig,
129  size_t idt) const {
130  DTLayerId layId(id);
131 
132  // Layer specific parameter (size)
133  // r-phi dimension - different in different chambers
134  // z dimension - constant 126.8 cm
135  // radial thickness - almost constant about 20 cm
136 
137  auto shapeStartPtr = rig.shapeStart(idt);
138  RCPPlane surf(
139  plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds((shapeStartPtr + 1))));
140 
141  // Loop on wires
142  int firstWire = static_cast<int>(*(shapeStartPtr + 4)); //par[4]);
143  int WCounter = static_cast<int>(*(shapeStartPtr + 5)); //par[5]);
144  double sensibleLength = convertMmToCm(*(shapeStartPtr + 6)); //par[6] in cm;
145  DTTopology topology(firstWire, WCounter, sensibleLength);
146 
147  DTLayerType layerType;
148 
149  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
150  // cout << "adding layer " << layer->id() << " to sl "<< sl->id() << endl;
151 
152  assert(sl);
153  sl->add(layer);
154  return layer;
155 }
156 
157 DTGeometryBuilderFromCondDB::RCPPlane DTGeometryBuilderFromCondDB::plane(const vector<double>::const_iterator tranStart,
158  const vector<double>::const_iterator rotStart,
159  Bounds* bounds) const {
160  // extract the position
161  const Surface::PositionType posResult(*(tranStart), *(tranStart + 1), *(tranStart + 2));
162  // now the rotation
163  Surface::RotationType rotResult(*(rotStart + 0),
164  *(rotStart + 1),
165  *(rotStart + 2),
166  *(rotStart + 3),
167  *(rotStart + 4),
168  *(rotStart + 5),
169  *(rotStart + 6),
170  *(rotStart + 7),
171  *(rotStart + 8));
172 
173  return RCPPlane(new Plane(posResult, rotResult, bounds));
174 }
DTLayer * buildLayer(DTSuperLayer *sl, const DetId &id, const RecoIdealGeometry &rig, size_t idt) const
RCPPlane plane(const std::vector< double >::const_iterator tranStart, const std::vector< double >::const_iterator rotStart, Bounds *bounds) const
RectangularPlaneBounds * getRecPlaneBounds(const std::vector< double >::const_iterator &shapeStart)
std::vector< double >::const_iterator rotStart(size_t ind) const
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:47
assert(be >=bs)
Definition: Plane.h:16
constexpr std::array< uint8_t, layerIndexSize > layer
const std::vector< DetId > & detIds() const
DTSuperLayer * buildSuperLayer(DTChamber *chamber, const DetId &id, const RecoIdealGeometry &rig, size_t idt) const
Definition: DetId.h:17
std::vector< double >::const_iterator shapeStart(size_t ind) const
constexpr NumType convertMmToCm(NumType millimeters)
Definition: angle_units.h:44
Definition: Bounds.h:18
void build(const std::shared_ptr< DTGeometry > &theGeometry, const RecoIdealGeometry &rig)
std::vector< double >::const_iterator tranStart(size_t ind) const
DTChamber * buildChamber(const DetId &id, const RecoIdealGeometry &rig, size_t idt) const