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 //#define EDM_ML_DEBUG
33 /* ====================================================================== */
34 
35 /* Constructor */
37 
38 /* Destructor */
40 
41 /* Operations */
42 void DTGeometryBuilderFromCondDB::build(const std::shared_ptr<DTGeometry>& theGeometry, const RecoIdealGeometry& rig) {
43 #ifdef EDM_ML_DEBUG
44  edm::LogVerbatim("DTGeometry") << "DTGeometryBuilderFromCondDB ";
45 #endif
46  const std::vector<DetId>& detids(rig.detIds());
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("DTGeometry") << "size " << detids.size();
49 #endif
50 
51  size_t idt = 0;
52  DTChamber* chamber(nullptr);
53  DTSuperLayer* sl(nullptr);
54  while (idt < detids.size()) {
55  //copy(par.begin(), par.end(), ostream_iterator<double>(std::cout," "));
56  if (int(*(rig.shapeStart(idt))) == 0) { // a Chamber
57  // add the provious chamber which by now has been updated with SL and
58  // layers
59  if (chamber)
60  theGeometry->add(chamber);
61  // go for the actual one
62  DTChamberId chid(detids[idt]);
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("DTGeometry") << "CH: " << chid;
65 #endif
66  chamber = buildChamber(chid, rig, idt);
67  } else if (int(*(rig.shapeStart(idt))) == 1) { // a SL
68  DTSuperLayerId slid(detids[idt]);
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("DTGeometry") << " SL: " << slid;
71 #endif
72  sl = buildSuperLayer(chamber, slid, rig, idt);
73  theGeometry->add(sl);
74  } else if (int(*(rig.shapeStart(idt))) == 2) { // a Layer
75  DTLayerId lid(detids[idt]);
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("DTGeometry") << " LAY: " << lid;
78 #endif
79  DTLayer* lay = buildLayer(sl, lid, rig, idt);
80  theGeometry->add(lay);
81  } else {
82  edm::LogVerbatim("DTGeometry") << "What is this?";
83  }
84  ++idt;
85  }
86  if (chamber)
87  theGeometry->add(chamber); // add the last chamber
88 }
89 
90 // Calling function has the responsibility to delete the allocated RectangularPlaneBounds object
91 RectangularPlaneBounds* dtGeometryBuilder::getRecPlaneBounds(const std::vector<double>::const_iterator& shapeStart) {
92  float width = convertMmToCm(*(shapeStart)); // r-phi dimension - different in different chambers
93  float length = convertMmToCm(*(shapeStart + 1)); // z dimension - constant
94  float thickness = convertMmToCm(*(shapeStart + 2)); // radial thickness - almost constant
95  return new RectangularPlaneBounds(width, length, thickness);
96 }
97 
99  DTChamberId detId(id);
100 
102  // width is along local X
103  // length is along local Y
104  // length z dimension - constant 125.55 cm
105  // thickness is along local Z
106  // radial thickness - almost constant about 18 cm
107  RCPPlane surf(
108  plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds(++rig.shapeStart(idt))));
109 
110  DTChamber* chamber = new DTChamber(detId, surf);
111 
112  return chamber;
113 }
114 
116  const DetId& id,
117  const RecoIdealGeometry& rig,
118  size_t idt) const {
119  DTSuperLayerId slId(id);
120 
121  // r-phi dimension - different in different chambers
122  // z dimension - constant 126.8 cm
123  // radial thickness - almost constant about 5 cm
124 
125  // Ok this is the slayer position...
126  RCPPlane surf(
127  plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds(++rig.shapeStart(idt))));
128 
129  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
130 
131 #ifdef EDM_ML_DEBUG
132  edm::LogVerbatim("DTGeometry") << "adding slayer " << slayer->id() << " to chamber " << chamber->id();
133 #endif
134  assert(chamber);
135  chamber->add(slayer);
136  return slayer;
137 }
138 
140  const DetId& id,
141  const RecoIdealGeometry& rig,
142  size_t idt) const {
143  DTLayerId layId(id);
144 
145  // Layer specific parameter (size)
146  // r-phi dimension - different in different chambers
147  // z dimension - constant 126.8 cm
148  // radial thickness - almost constant about 20 cm
149 
150  auto shapeStartPtr = rig.shapeStart(idt);
151  RCPPlane surf(
152  plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds((shapeStartPtr + 1))));
153 
154  // Loop on wires
155  int firstWire = static_cast<int>(*(shapeStartPtr + 4)); //par[4]);
156  int WCounter = static_cast<int>(*(shapeStartPtr + 5)); //par[5]);
157  double sensibleLength = convertMmToCm(*(shapeStartPtr + 6)); //par[6] in cm;
158  DTTopology topology(firstWire, WCounter, sensibleLength);
159 
160  DTLayerType layerType;
161 
162  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
163 #ifdef EDM_ML_DEBUG
164  edm::LogVerbatim("DTGeometry") << "adding layer " << layer->id() << " to sl " << sl->id();
165 #endif
166  assert(sl);
167  sl->add(layer);
168  return layer;
169 }
170 
171 DTGeometryBuilderFromCondDB::RCPPlane DTGeometryBuilderFromCondDB::plane(const vector<double>::const_iterator tranStart,
172  const vector<double>::const_iterator rotStart,
173  Bounds* bounds) const {
174  // extract the position
175  const Surface::PositionType posResult(*(tranStart), *(tranStart + 1), *(tranStart + 2));
176  // now the rotation
177  Surface::RotationType rotResult(*(rotStart + 0),
178  *(rotStart + 1),
179  *(rotStart + 2),
180  *(rotStart + 3),
181  *(rotStart + 4),
182  *(rotStart + 5),
183  *(rotStart + 6),
184  *(rotStart + 7),
185  *(rotStart + 8));
186 
187  return RCPPlane(new Plane(posResult, rotResult, bounds));
188 }
Log< level::Info, true > LogVerbatim
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
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
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:34
DTChamber * buildChamber(const DetId &id, const RecoIdealGeometry &rig, size_t idt) const