CMS 3D CMS Logo

DTGeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
10 
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
19 
20 
22 
23 #include <string>
24 
25 using namespace std;
26 
27 #include <string>
28 #include <utility>
29 
30 using namespace std;
31 
33 
35 
36 
38  const DDCompactView* cview,
39  const MuonDDDConstants& muonConstants){
40  // cout << "DTGeometryBuilderFromDDD::build" << endl;
41  // static const string t0 = "DTGeometryBuilderFromDDD::build";
42  // TimeMe timer(t0,true);
43 
44  std::string attribute = "MuStructure";
45  std::string value = "MuonBarrelDT";
46 
47  // Asking only for the Muon DTs
48  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
49 
50  DDFilteredView fview(*cview,filter);
51  buildGeometry(theGeometry, fview, muonConstants);
52 }
53 
54 
56  DDFilteredView& fv,
57  const MuonDDDConstants& muonConstants) const {
58 
59  bool doChamber = fv.firstChild();
60 
61  // Loop on chambers
62  int ChamCounter=0;
63  while (doChamber){
64  ChamCounter++;
65  DDValue val("Type");
66  const DDsvalues_type params(fv.mergedSpecifics());
67  string type;
68  if (DDfetch(&params,val)) type = val.strings()[0];
69  // FIXME
70  val=DDValue("FEPos");
71  string FEPos;
72  if (DDfetch(&params,val)) FEPos = val.strings()[0];
73  DTChamber* chamber = buildChamber(fv,type, muonConstants);
74 
75  // Loop on SLs
76  bool doSL = fv.firstChild();
77  int SLCounter=0;
78  while (doSL) {
79  SLCounter++;
80  DTSuperLayer* sl = buildSuperLayer(fv, chamber, type, muonConstants);
81  theGeometry.add(sl);
82 
83  bool doL = fv.firstChild();
84  int LCounter=0;
85  // Loop on SLs
86  while (doL) {
87  LCounter++;
88  DTLayer* layer = buildLayer(fv, sl, type, muonConstants);
89  theGeometry.add(layer);
90 
91  fv.parent();
92  doL = fv.nextSibling(); // go to next layer
93  } // layers
94 
95  fv.parent();
96  doSL = fv.nextSibling(); // go to next SL
97  } // sls
98  theGeometry.add(chamber);
99 
100  fv.parent();
101  doChamber = fv.nextSibling(); // go to next chamber
102  } // chambers
103 }
104 
106  const string& type, const MuonDDDConstants& muonConstants) const {
107  MuonDDDNumbering mdddnum (muonConstants);
108  DTNumberingScheme dtnum (muonConstants);
109  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
110  DTChamberId detId(rawid);
111 
112  // Chamber specific parameter (size)
113  // FIXME: some trouble for boolean solids?
114  vector<double> par = extractParameters(fv);
115 
116  float width = par[0]/cm; // r-phi dimension - different in different chambers
117  float length = par[1]/cm; // z dimension - constant 125.55 cm
118  float thickness = par[2]/cm; // radial thickness - almost constant about 18 cm
119 
121  // width is along local X
122  // length is along local Y
123  // thickness is long local Z
124 
125  RCPPlane surf(plane(fv, new RectangularPlaneBounds(width, length, thickness) ));
126 
127  DTChamber* chamber = new DTChamber(detId, surf);
128 
129  return chamber;
130 }
131 
134  const std::string& type,
135  const MuonDDDConstants& muonConstants) const {
136 
137  MuonDDDNumbering mdddnum(muonConstants);
138  DTNumberingScheme dtnum(muonConstants);
139  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
140  DTSuperLayerId slId(rawid);
141 
142  // Slayer specific parameter (size)
143  vector<double> par = extractParameters(fv);
144 
145  float width = par[0]/cm; // r-phi dimension - changes in different chambers
146  float length = par[1]/cm; // z dimension - constant 126.8 cm
147  float thickness = par[2]/cm; // radial thickness - almost constant about 20 cm
148 
149  // Ok this is the slayer position...
150  RCPPlane surf(plane(fv, new RectangularPlaneBounds(width, length, thickness) ));
151 
152  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
153 
154  //LocalPoint lpos(10,20,30);
155  //GlobalPoint gpos=slayer->toGlobal(lpos);
156 
157  // add to the chamber
158  chamber->add(slayer);
159  return slayer;
160 }
161 
162 
164  DTSuperLayer* sl,
165  const std::string& type,
166  const MuonDDDConstants& muonConstants) const {
167 
168  MuonDDDNumbering mdddnum(muonConstants);
169  DTNumberingScheme dtnum(muonConstants);
170  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
171  DTLayerId layId(rawid);
172 
173  // Layer specific parameter (size)
174  vector<double> par = extractParameters(fv);
175  float width = par[0]/cm; // r-phi dimension - changes in different chambers
176  float length = par[1]/cm; // z dimension - constant 126.8 cm
177  float thickness = par[2]/cm; // radial thickness - almost constant about 20 cm
178 
179  RCPPlane surf(plane(fv, new RectangularPlaneBounds(width, length, thickness) ));
180 
181  // Loop on wires
182  bool doWire = fv.firstChild();
183  int WCounter=0;
184  int firstWire=fv.copyno();
185  par = extractParameters(fv);
186  float wireLength = par[1]/cm;
187  while (doWire) {
188  WCounter++;
189  doWire = fv.nextSibling(); // next wire
190  }
191  //int lastWire=fv.copyno();
192  DTTopology topology(firstWire, WCounter, wireLength);
193 
194  DTLayerType layerType;
195 
196  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
197 
198  sl->add(layer);
199  return layer;
200 }
201 
202 vector<double>
204  vector<double> par;
205  if (fv.logicalPart().solid().shape() != DDSolidShape::ddbox) {
206  DDBooleanSolid bs(fv.logicalPart().solid());
207  DDSolid A = bs.solidA();
208  while (A.shape() != DDSolidShape::ddbox) {
209  DDBooleanSolid bs(A);
210  A = bs.solidA();
211  }
212  par=A.parameters();
213  } else {
214  par = fv.logicalPart().solid().parameters();
215  }
216  return par;
217 }
218 
221  Bounds * bounds) const {
222  // extract the position
223  const DDTranslation & trans(fv.translation());
224 
225  const Surface::PositionType posResult(float(trans.x()/cm),
226  float(trans.y()/cm),
227  float(trans.z()/cm));
228  // now the rotation
229  // DDRotationMatrix tmp = fv.rotation();
230  // === DDD uses 'active' rotations - see CLHEP user guide ===
231  // ORCA uses 'passive' rotation.
232  // 'active' and 'passive' rotations are inverse to each other
233  // DDRotationMatrix tmp = fv.rotation();
234  const DDRotationMatrix& rotation = fv.rotation();//REMOVED .Inverse();
235  DD3Vector x, y, z;
236  rotation.GetComponents(x,y,z);
237 // std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
238 // std::cout << "INVERSE rotation manually: "
239 // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
240 // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
241 // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
242 
243  Surface::RotationType rotResult(float(x.X()),float(x.Y()),float(x.Z()),
244  float(y.X()),float(y.Y()),float(y.Z()),
245  float(z.X()),float(z.Y()),float(z.Z()));
246 
247 // std::cout << "rotation by its own operator: "<< tmp << std::endl;
248 // DD3Vector tx, ty,tz;
249 // tmp.GetComponents(tx, ty, tz);
250 // std::cout << "rotation manually: "
251 // << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
252 // << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
253 // << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;
254 
255  return RCPPlane( new Plane( posResult, rotResult, bounds));
256 }
type
Definition: HCALResponse.h:21
virtual ~DTGeometryBuilderFromDDD()
Destructor.
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:144
bool parent()
set the current node to the parent node ...
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
CaloTopology const * topology(0)
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:59
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
DTLayer * buildLayer(DDFilteredView &fv, DTSuperLayer *sl, const std::string &type, const MuonDDDConstants &muonConstants) const
create the layer
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
Definition: Plane.h:17
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
int copyno() const
Copy number associated with the current node.
DTChamber * buildChamber(DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants) const
create the chamber
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
DTSuperLayer * buildSuperLayer(DDFilteredView &fv, DTChamber *chamber, const std::string &type, const MuonDDDConstants &muonConstants) const
create the SL
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
Definition: value.py:1
std::vector< double > extractParameters(DDFilteredView &fv) const
get parameter also for boolean solid.
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:61
DDSolid solidA(void) const
Definition: DDSolid.cc:610
RCPPlane plane(const DDFilteredView &fv, Bounds *bounds) const
DDsvalues_type mergedSpecifics() const
void buildGeometry(DTGeometry &theGeometry, DDFilteredView &fv, const MuonDDDConstants &muonConstants) const
void add(DTSuperLayer *sl)
Add SL to the chamber which takes ownership.
Definition: DTChamber.cc:41
int getDetId(const MuonBaseNumber &num) const
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
bool firstChild()
set the current node to the first child ...
Definition: Bounds.h:22
const DDTranslation & translation() const
The absolute translation of the current node.
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
void add(DTChamber *ch)
Add a DTChamber to Geometry.
Definition: DTGeometry.cc:44