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