CMS 3D CMS Logo

DTGeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
10 
21 #include <string>
22 #include <utility>
23 
24 using namespace geant_units;
25 using namespace geant_units::operators;
26 
27 //#define EDM_ML_DEBUG
28 
30 
32 
34  const DDCompactView* cview,
35  const MuonGeometryConstants& muonConstants) {
36 #ifdef EDM_ML_DEBUG
37  edm::LogVerbatim("DTGeometry") << "DTGeometryBuilderFromDDD::build";
38 #endif
39 
40  std::string attribute = "MuStructure";
41  std::string value = "MuonBarrelDT";
42 
43  // Asking only for the Muon DTs
45 
46  DDFilteredView fview(*cview, filter);
47  buildGeometry(theGeometry, fview, muonConstants);
48 }
49 
51  DDFilteredView& fv,
52  const MuonGeometryConstants& muonConstants) const {
53  edm::LogVerbatim("DTGeometryBuilder") << "(0) DTGeometryBuilder - DDD ";
54 
55  bool doChamber = fv.firstChild();
56 
57  // Loop on chambers
58  int ChamCounter = 0;
59  while (doChamber) {
60  ChamCounter++;
61  DDValue val("Type");
64  if (DDfetch(&params, val))
65  type = val.strings()[0];
66  // FIXME
67  val = DDValue("FEPos");
68  std::string FEPos;
69  if (DDfetch(&params, val))
70  FEPos = val.strings()[0];
71  DTChamber* chamber = buildChamber(fv, type, muonConstants);
72 
73  // Loop on SLs
74  bool doSL = fv.firstChild();
75  int SLCounter = 0;
76  while (doSL) {
77  SLCounter++;
78  DTSuperLayer* sl = buildSuperLayer(fv, chamber, type, muonConstants);
79  theGeometry.add(sl);
80 
81  bool doL = fv.firstChild();
82  int LCounter = 0;
83  // Loop on SLs
84  while (doL) {
85  LCounter++;
86  DTLayer* layer = buildLayer(fv, sl, type, muonConstants);
87  theGeometry.add(layer);
88 
89  fv.parent();
90  doL = fv.nextSibling(); // go to next layer
91  } // layers
92 
93  fv.parent();
94  doSL = fv.nextSibling(); // go to next SL
95  } // sls
96  theGeometry.add(chamber);
97 
98  fv.parent();
99  doChamber = fv.nextSibling(); // go to next chamber
100  } // chambers
101 }
102 
104  const std::string& type,
105  const MuonGeometryConstants& muonConstants) const {
106  MuonGeometryNumbering mdddnum(muonConstants);
107  DTNumberingScheme dtnum(muonConstants);
108  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
109  DTChamberId detId(rawid);
110 
111  // Chamber specific parameter (size)
112  // FIXME: some trouble for boolean solids?
113  std::vector<double> par = extractParameters(fv);
114 
116  // width is along local X. r-phi dimension - different in different chambers
117  // length is along local Y. z dimension - constant 125.55 cm
118  // thickness is long local Z. radial thickness - almost constant about 18 cm
119 
120  edm::LogVerbatim("DTGeometryBuilder") << "(1) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
121  << " par[2]: " << par[2];
122 
123  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
124 
125  DTChamber* chamber = new DTChamber(detId, surf);
126 
127  return chamber;
128 }
129 
132  const std::string& type,
133  const MuonGeometryConstants& muonConstants) const {
134  MuonGeometryNumbering mdddnum(muonConstants);
135  DTNumberingScheme dtnum(muonConstants);
136  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
137  DTSuperLayerId slId(rawid);
138 
139  // Slayer specific parameter (size)
140  std::vector<double> par = extractParameters(fv);
141 
142  edm::LogVerbatim("DTGeometryBuilder") << "(2) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
143  << " par[2]: " << par[2];
144 
145  // r-phi dimension - different in different chambers
146  // z dimension - constant 126.8 cm
147  // radial thickness - almost constant about 20 cm
148 
149  // Ok this is the s-layer position...
150  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
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 
163  DTSuperLayer* sl,
164  const std::string& type,
165  const MuonGeometryConstants& muonConstants) const {
166  MuonGeometryNumbering mdddnum(muonConstants);
167  DTNumberingScheme dtnum(muonConstants);
168  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
169  DTLayerId layId(rawid);
170 
171  // Layer specific parameter (size)
172  std::vector<double> par = extractParameters(fv);
173  // width -- r-phi dimension - different in different chambers
174  // length -- z dimension - constant 126.8 cm
175  // thickness -- radial thickness - almost constant about 20 cm
176 
177  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
178 
179  edm::LogVerbatim("DTGeometryBuilder") << "(3) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
180  << " par[2]: " << par[2];
181 
182  // Loop on wires
183  bool doWire = fv.firstChild();
184  int WCounter = 0;
185  int firstWire = fv.copyno();
186  par = extractParameters(fv);
187  float wireLength = convertMmToCm(par[1]);
188 
189  edm::LogVerbatim("DTGeometryBuilder") << "(4) detId: " << rawid
190  << " wireLenght in ddd, wpar[1] in dd4hep: " << wireLength
191  << " firstWire: " << firstWire;
192 
193  while (doWire) {
194  WCounter++;
195  doWire = fv.nextSibling(); // next wire
196  }
197  //int lastWire=fv.copyno();
198  DTTopology topology(firstWire, WCounter, wireLength);
199 
200  DTLayerType layerType;
201 
202  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
203 
204  sl->add(layer);
205  return layer;
206 }
207 
209  std::vector<double> par;
210  if (fv.logicalPart().solid().shape() != DDSolidShape::ddbox) {
212  DDSolid A = bs.solidA();
213  while (A.shape() != DDSolidShape::ddbox) {
215  A = bs.solidA();
216  }
217  par = A.parameters();
218  } else {
219  par = fv.logicalPart().solid().parameters();
220  }
221  return par;
222 }
223 
225  // extract the position
226  const DDTranslation& trans(fv.translation());
227 
228  const Surface::PositionType posResult(
229  float(convertMmToCm(trans.x())), float(convertMmToCm(trans.y())), float(convertMmToCm(trans.z())));
230  LogTrace("DTGeometryBuilderFromDDD") << "DTGeometryBuilderFromDDD::plane posResult: " << posResult;
231  // now the rotation
232  // 'active' and 'passive' rotations are inverse to each other
233  const DDRotationMatrix& rotation = fv.rotation(); //REMOVED .Inverse();
234  DD3Vector x, y, z;
235  rotation.GetComponents(x, y, z);
236 #ifdef EDM_ML_DEBUG
237  edm::LogVerbatim("DTGeometry") << "INVERSE rotation by its own operator: " << fv.rotation();
238  edm::LogVerbatim("DTGeometry") << "INVERSE rotation manually: " << x.X() << ", " << x.Y() << ", " << x.Z()
239  << std::endl
240  << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
241  << z.X() << ", " << z.Y() << ", " << z.Z();
242 #endif
243  Surface::RotationType rotResult(float(x.X()),
244  float(x.Y()),
245  float(x.Z()),
246  float(y.X()),
247  float(y.Y()),
248  float(y.Z()),
249  float(z.X()),
250  float(z.Y()),
251  float(z.Z()));
252 
253  return RCPPlane(new Plane(posResult, rotResult, bounds));
254 }
Log< level::Info, true > LogVerbatim
virtual ~DTGeometryBuilderFromDDD()
Destructor.
void buildGeometry(DTGeometry &theGeometry, DDFilteredView &fv, const MuonGeometryConstants &muonConstants) const
bool parent()
set the current node to the parent node ...
RectangularPlaneBounds * getRecPlaneBounds(const std::vector< double >::const_iterator &shapeStart)
bool nextSibling()
set the current node to the next sibling ...
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
void add(DTLayer *l)
Add layer to the SL which owns it.
Definition: DTSuperLayer.cc:47
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
Definition: Plane.h:16
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
#define LogTrace(id)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
RCPPlane plane(const DDFilteredView &fv, Bounds *bounds) const
std::vector< double > extractParameters(DDFilteredView &fv) const
get parameter also for boolean solid.
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
int getDetId(const MuonBaseNumber &num) const
Definition: value.py:1
DTChamber * buildChamber(DDFilteredView &fv, const std::string &type, const MuonGeometryConstants &muonConstants) const
create the chamber
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
DDsvalues_type mergedSpecifics() const
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
constexpr NumType convertMmToCm(NumType millimeters)
Definition: angle_units.h:44
int copyno() const
Copy number associated with the current node.
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
DTSuperLayer * buildSuperLayer(DDFilteredView &fv, DTChamber *chamber, const std::string &type, const MuonGeometryConstants &muonConstants) const
create the SL
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
DTLayer * buildLayer(DDFilteredView &fv, DTSuperLayer *sl, const std::string &type, const MuonGeometryConstants &muonConstants) const
create the layer
bool firstChild()
set the current node to the first child ...
float x
Definition: Bounds.h:18
Definition: APVGainStruct.h:7
const DDTranslation & translation() const
The absolute translation of the current node.
void add(DTChamber *ch)
Add a DTChamber to Geometry.
Definition: DTGeometry.cc:42
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history) const