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  while (doChamber) {
59  DDValue val("Type");
62  if (DDfetch(&params, val))
63  type = val.strings()[0];
64  // FIXME
65  val = DDValue("FEPos");
66  std::string FEPos;
67  if (DDfetch(&params, val))
68  FEPos = val.strings()[0];
69  DTChamber* chamber = buildChamber(fv, type, muonConstants);
70 
71  // Loop on SLs
72  bool doSL = fv.firstChild();
73  while (doSL) {
74  DTSuperLayer* sl = buildSuperLayer(fv, chamber, type, muonConstants);
75  theGeometry.add(sl);
76 
77  bool doL = fv.firstChild();
78  // Loop on SLs
79  while (doL) {
80  DTLayer* layer = buildLayer(fv, sl, type, muonConstants);
81  theGeometry.add(layer);
82 
83  fv.parent();
84  doL = fv.nextSibling(); // go to next layer
85  } // layers
86 
87  fv.parent();
88  doSL = fv.nextSibling(); // go to next SL
89  } // sls
90  theGeometry.add(chamber);
91 
92  fv.parent();
93  doChamber = fv.nextSibling(); // go to next chamber
94  } // chambers
95 }
96 
98  const std::string& type,
99  const MuonGeometryConstants& muonConstants) const {
100  MuonGeometryNumbering mdddnum(muonConstants);
101  DTNumberingScheme dtnum(muonConstants);
102  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
103  DTChamberId detId(rawid);
104 
105  // Chamber specific parameter (size)
106  // FIXME: some trouble for boolean solids?
107  std::vector<double> par = extractParameters(fv);
108 
110  // width is along local X. r-phi dimension - different in different chambers
111  // length is along local Y. z dimension - constant 125.55 cm
112  // thickness is long local Z. radial thickness - almost constant about 18 cm
113 
114  edm::LogVerbatim("DTGeometryBuilder") << "(1) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
115  << " par[2]: " << par[2];
116 
117  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
118 
119  DTChamber* chamber = new DTChamber(detId, surf);
120 
121  return chamber;
122 }
123 
126  const std::string& type,
127  const MuonGeometryConstants& muonConstants) const {
128  MuonGeometryNumbering mdddnum(muonConstants);
129  DTNumberingScheme dtnum(muonConstants);
130  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
131  DTSuperLayerId slId(rawid);
132 
133  // Slayer specific parameter (size)
134  std::vector<double> par = extractParameters(fv);
135 
136  edm::LogVerbatim("DTGeometryBuilder") << "(2) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
137  << " par[2]: " << par[2];
138 
139  // r-phi dimension - different in different chambers
140  // z dimension - constant 126.8 cm
141  // radial thickness - almost constant about 20 cm
142 
143  // Ok this is the s-layer position...
144  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
145 
146  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
147 
148  //LocalPoint lpos(10,20,30);
149  //GlobalPoint gpos=slayer->toGlobal(lpos);
150 
151  // add to the chamber
152  chamber->add(slayer);
153  return slayer;
154 }
155 
157  DTSuperLayer* sl,
158  const std::string& type,
159  const MuonGeometryConstants& muonConstants) const {
160  MuonGeometryNumbering mdddnum(muonConstants);
161  DTNumberingScheme dtnum(muonConstants);
162  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
163  DTLayerId layId(rawid);
164 
165  // Layer specific parameter (size)
166  std::vector<double> par = extractParameters(fv);
167  // width -- r-phi dimension - different in different chambers
168  // length -- z dimension - constant 126.8 cm
169  // thickness -- radial thickness - almost constant about 20 cm
170 
171  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
172 
173  edm::LogVerbatim("DTGeometryBuilder") << "(3) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
174  << " par[2]: " << par[2];
175 
176  // Loop on wires
177  bool doWire = fv.firstChild();
178  int WCounter = 0;
179  int firstWire = fv.copyno();
180  par = extractParameters(fv);
181  float wireLength = convertMmToCm(par[1]);
182 
183  edm::LogVerbatim("DTGeometryBuilder") << "(4) detId: " << rawid
184  << " wireLenght in ddd, wpar[1] in dd4hep: " << wireLength
185  << " firstWire: " << firstWire;
186 
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 
203  std::vector<double> par;
204  if (fv.logicalPart().solid().shape() != DDSolidShape::ddbox) {
206  DDSolid A = bs.solidA();
207  while (A.shape() != DDSolidShape::ddbox) {
209  A = bs.solidA();
210  }
211  par = A.parameters();
212  } else {
213  par = fv.logicalPart().solid().parameters();
214  }
215  return par;
216 }
217 
219  // extract the position
220  const DDTranslation& trans(fv.translation());
221 
222  const Surface::PositionType posResult(
223  float(convertMmToCm(trans.x())), float(convertMmToCm(trans.y())), float(convertMmToCm(trans.z())));
224  LogTrace("DTGeometryBuilderFromDDD") << "DTGeometryBuilderFromDDD::plane posResult: " << posResult;
225  // now the rotation
226  // 'active' and 'passive' rotations are inverse to each other
227  const DDRotationMatrix& rotation = fv.rotation(); //REMOVED .Inverse();
228  DD3Vector x, y, z;
229  rotation.GetComponents(x, y, z);
230 #ifdef EDM_ML_DEBUG
231  edm::LogVerbatim("DTGeometry") << "INVERSE rotation by its own operator: " << fv.rotation();
232  edm::LogVerbatim("DTGeometry") << "INVERSE rotation manually: " << x.X() << ", " << x.Y() << ", " << x.Z()
233  << std::endl
234  << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
235  << z.X() << ", " << z.Y() << ", " << z.Z();
236 #endif
237  Surface::RotationType rotResult(float(x.X()),
238  float(x.Y()),
239  float(x.Z()),
240  float(y.X()),
241  float(y.Y()),
242  float(y.Z()),
243  float(z.X()),
244  float(z.Y()),
245  float(z.Z()));
246 
247  return RCPPlane(new Plane(posResult, rotResult, bounds));
248 }
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