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