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