CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  * $date : 19/11/2008 19:15:14 CET $
9  *
10  * Modification:
11  *
12  *********************************/
13 
14 /* This Class Header */
16 
17 /* Collaborating Class Header */
24 #include "CLHEP/Units/GlobalSystemOfUnits.h"
25 
26 /* C++ Headers */
27 #include <iostream>
28 using namespace std;
29 
30 /* ====================================================================== */
31 
32 /* Constructor */
34 }
35 
36 /* Destructor */
38 }
39 
40 /* Operations */
41 void
42 DTGeometryBuilderFromCondDB::build(boost::shared_ptr<DTGeometry> theGeometry,
43  const RecoIdealGeometry& rig) {
44  // cout << "DTGeometryBuilderFromCondDB " << endl;
45  const std::vector<DetId>& detids(rig.detIds());
46  // cout << "size " << detids.size() << endl;
47 
48  size_t idt = 0;
49  DTChamber* chamber(0);
50  DTSuperLayer* sl(0);
51  while(idt < detids.size()) {
52  //copy(par.begin(), par.end(), ostream_iterator<double>(std::cout," "));
53  if (int(*(rig.shapeStart(idt)))==0){ // a Chamber
54  // add the provious chamber which by now has been updated with SL and
55  // layers
56  if (chamber) theGeometry->add(chamber);
57  // go for the actual one
58  DTChamberId chid(detids[idt]);
59  //cout << "CH: " << chid << endl;
60  chamber = buildChamber(chid, rig, idt);
61  }
62  else if (int(*(rig.shapeStart(idt)))==1){ // a SL
63  DTSuperLayerId slid(detids[idt]);
64  //cout << " SL: " << slid << endl;
65  sl = buildSuperLayer(chamber, slid, rig, idt);
66  theGeometry->add(sl);
67  }
68  else if (int(*(rig.shapeStart(idt)))==2){ // a Layer
69  DTLayerId lid(detids[idt]);
70  //cout << " LAY: " << lid << endl;
71  DTLayer* lay = buildLayer(sl, lid, rig, idt);
72  theGeometry->add(lay);
73  } else {
74  cout << "What is this?" << endl;
75  }
76  ++idt;
77  }
78  if (chamber) theGeometry->add(chamber); // add the last chamber
79 }
80 
82  const RecoIdealGeometry& rig,
83  size_t idt ) const {
84  DTChamberId detId(id);
85 
86 
87  float width = (*(rig.shapeStart(idt) + 1))/cm; // r-phi dimension - different in different chambers
88  float length = (*(rig.shapeStart(idt) + 2))/cm; // z dimension - constant 125.55 cm
89  float thickness = (*(rig.shapeStart(idt) + 3))/cm; // radial thickness - almost constant about 18 cm
90 
92  // width is along local X
93  // length is along local Y
94  // thickness is long local Z
95  RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), new RectangularPlaneBounds(width, length, thickness) ));
96 
97  DTChamber* chamber = new DTChamber(detId, surf);
98 
99  return chamber;
100 }
101 
104  const DetId& id,
105  const RecoIdealGeometry& rig,
106  size_t idt) const {
107 
108  DTSuperLayerId slId(id);
109 
110  float width = (*(rig.shapeStart(idt) + 1))/cm; // r-phi dimension - different in different chambers
111  float length = (*(rig.shapeStart(idt) + 2))/cm; // z dimension - constant 126.8 cm
112  float thickness = (*(rig.shapeStart(idt) + 3))/cm; // radial thickness - almost constant about 5 cm
113 
114  // Ok this is the slayer position...
115  RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), new RectangularPlaneBounds(width, length, thickness) ));
116 
117  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
118 
119  // cout << "adding slayer " << slayer->id() << " to chamber "<< chamber->id() << endl;
120  chamber->add(slayer);
121  return slayer;
122 }
123 
124 DTLayer*
126  const DetId& id,
127  const RecoIdealGeometry& rig,
128  size_t idt) const {
129 
130  DTLayerId layId(id);
131 
132  // Layer specific parameter (size)
133  float width = (*(rig.shapeStart(idt) + 1))/cm; // r-phi dimension - changes in different chambers
134  float length = (*(rig.shapeStart(idt) + 2))/cm; // z dimension - constant 126.8 cm
135  float thickness = (*(rig.shapeStart(idt) + 3))/cm; // radial thickness - almost constant about 20 cm
136 
137 
138  RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), new RectangularPlaneBounds(width, length, thickness) ));
139 
140  // Loop on wires
141  int firstWire=int(*(rig.shapeStart(idt) + 4 ));//par[4]);
142  int WCounter=int(*(rig.shapeStart(idt) + 5 ));//par[5]);
143  double sensibleLenght=(*(rig.shapeStart(idt) + 6 ))/cm;//par[6]/cm;
144  DTTopology topology(firstWire, WCounter, sensibleLenght);
145 
146  DTLayerType layerType;
147 
148  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
149  // cout << "adding layer " << layer->id() << " to sl "<< sl->id() << endl;
150 
151  sl->add(layer);
152  return layer;
153 }
154 
156 DTGeometryBuilderFromCondDB::plane(const vector<double>::const_iterator tranStart,
157  const vector<double>::const_iterator rotStart,
158  Bounds * bounds) const {
159  // extract the position
160  const Surface::PositionType posResult(*(tranStart), *(tranStart+1), *(tranStart+2));
161  // now the rotation
162  Surface::RotationType rotResult( *(rotStart+0), *(rotStart+1), *(rotStart+2),
163  *(rotStart+3), *(rotStart+4), *(rotStart+5),
164  *(rotStart+6), *(rotStart+7), *(rotStart+8) );
165 
166  return RCPPlane( new Plane( posResult, rotResult, bounds));
167 }
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:61
Definition: Plane.h:17
void build(boost::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
const std::vector< DetId > & detIds() const
Definition: DetId.h:20
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:43
tuple cout
Definition: gather_cfg.py:121
Definition: Bounds.h:22
DTSuperLayer * buildSuperLayer(DTChamber *chamber, 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