CMS 3D CMS Logo

DTGeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
10 
21 #include <string>
22 
23 using namespace std;
24 using namespace geant_units;
25 using namespace geant_units::operators;
26 
27 #include <string>
28 #include <utility>
29 
30 using namespace std;
31 
33 
35 
37  const DDCompactView* cview,
38  const MuonGeometryConstants& 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
48 
49  DDFilteredView fview(*cview, filter);
50  buildGeometry(theGeometry, fview, muonConstants);
51 }
52 
54  DDFilteredView& fv,
55  const MuonGeometryConstants& muonConstants) const {
56  edm::LogVerbatim("DTGeometryBuilder") << "(0) DTGeometryBuilder - DDD ";
57 
58  bool doChamber = fv.firstChild();
59 
60  // Loop on chambers
61  int ChamCounter = 0;
62  while (doChamber) {
63  ChamCounter++;
64  DDValue val("Type");
66  string type;
67  if (DDfetch(&params, val))
68  type = val.strings()[0];
69  // FIXME
70  val = DDValue("FEPos");
71  string FEPos;
72  if (DDfetch(&params, val))
73  FEPos = val.strings()[0];
74  DTChamber* chamber = buildChamber(fv, type, muonConstants);
75 
76  // Loop on SLs
77  bool doSL = fv.firstChild();
78  int SLCounter = 0;
79  while (doSL) {
80  SLCounter++;
81  DTSuperLayer* sl = buildSuperLayer(fv, chamber, type, muonConstants);
82  theGeometry.add(sl);
83 
84  bool doL = fv.firstChild();
85  int LCounter = 0;
86  // Loop on SLs
87  while (doL) {
88  LCounter++;
89  DTLayer* layer = buildLayer(fv, sl, type, muonConstants);
90  theGeometry.add(layer);
91 
92  fv.parent();
93  doL = fv.nextSibling(); // go to next layer
94  } // layers
95 
96  fv.parent();
97  doSL = fv.nextSibling(); // go to next SL
98  } // sls
99  theGeometry.add(chamber);
100 
101  fv.parent();
102  doChamber = fv.nextSibling(); // go to next chamber
103  } // chambers
104 }
105 
107  const string& type,
108  const MuonGeometryConstants& muonConstants) const {
109  MuonGeometryNumbering mdddnum(muonConstants);
110  DTNumberingScheme dtnum(muonConstants);
111  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
112  DTChamberId detId(rawid);
113 
114  // Chamber specific parameter (size)
115  // FIXME: some trouble for boolean solids?
116  vector<double> par = extractParameters(fv);
117 
119  // width is along local X. r-phi dimension - different in different chambers
120  // length is along local Y. z dimension - constant 125.55 cm
121  // thickness is long local Z. radial thickness - almost constant about 18 cm
122 
123  edm::LogVerbatim("DTGeometryBuilder") << "(1) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
124  << " par[2]: " << par[2];
125 
126  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
127 
128  DTChamber* chamber = new DTChamber(detId, surf);
129 
130  return chamber;
131 }
132 
135  const std::string& type,
136  const MuonGeometryConstants& muonConstants) const {
137  MuonGeometryNumbering 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  edm::LogVerbatim("DTGeometryBuilder") << "(2) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
146  << " par[2]: " << par[2];
147 
148  // r-phi dimension - different in different chambers
149  // z dimension - constant 126.8 cm
150  // radial thickness - almost constant about 20 cm
151 
152  // Ok this is the s-layer position...
153  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
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 
166  DTSuperLayer* sl,
167  const std::string& type,
168  const MuonGeometryConstants& muonConstants) const {
169  MuonGeometryNumbering mdddnum(muonConstants);
170  DTNumberingScheme dtnum(muonConstants);
171  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
172  DTLayerId layId(rawid);
173 
174  // Layer specific parameter (size)
175  vector<double> par = extractParameters(fv);
176  // width -- r-phi dimension - different in different chambers
177  // length -- z dimension - constant 126.8 cm
178  // thickness -- radial thickness - almost constant about 20 cm
179 
180  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
181 
182  edm::LogVerbatim("DTGeometryBuilder") << "(3) detId: " << rawid << " par[0]: " << par[0] << " par[1]: " << par[1]
183  << " par[2]: " << par[2];
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 = convertMmToCm(par[1]);
191 
192  edm::LogVerbatim("DTGeometryBuilder") << "(4) detId: " << rawid
193  << " wireLenght in ddd, wpar[1] in dd4hep: " << wireLength
194  << " firstWire: " << firstWire;
195 
196  while (doWire) {
197  WCounter++;
198  doWire = fv.nextSibling(); // next wire
199  }
200  //int lastWire=fv.copyno();
201  DTTopology topology(firstWire, WCounter, wireLength);
202 
203  DTLayerType layerType;
204 
205  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
206 
207  sl->add(layer);
208  return layer;
209 }
210 
212  vector<double> par;
213  if (fv.logicalPart().solid().shape() != DDSolidShape::ddbox) {
215  DDSolid A = bs.solidA();
216  while (A.shape() != DDSolidShape::ddbox) {
218  A = bs.solidA();
219  }
220  par = A.parameters();
221  } else {
222  par = fv.logicalPart().solid().parameters();
223  }
224  return par;
225 }
226 
228  // extract the position
229  const DDTranslation& trans(fv.translation());
230 
231  const Surface::PositionType posResult(
232  float(convertMmToCm(trans.x())), float(convertMmToCm(trans.y())), float(convertMmToCm(trans.z())));
233  LogTrace("DTGeometryBuilderFromDDD") << "DTGeometryBuilderFromDDD::plane "
234  << " posResult: " << posResult << std::endl;
235  // now the rotation
236  // 'active' and 'passive' rotations are inverse to each other
237  const 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()),
247  float(x.Y()),
248  float(x.Z()),
249  float(y.X()),
250  float(y.Y()),
251  float(y.Z()),
252  float(z.X()),
253  float(z.Y()),
254  float(z.Z()));
255 
256  // std::cout << "rotation by its own operator: "<< tmp << std::endl;
257  // DD3Vector tx, ty,tz;
258  // tmp.GetComponents(tx, ty, tz);
259  // std::cout << "rotation manually: "
260  // << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
261  // << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
262  // << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;
263 
264  return RCPPlane(new Plane(posResult, rotResult, bounds));
265 }
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)
std::vector< double > extractParameters(DDFilteredView &fv) const
get parameter also for boolean solid.
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)
constexpr std::array< uint8_t, layerIndexSize > layer
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
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