CMS 3D CMS Logo

DTGeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
10 
19 
20 
22 
23 #include <string>
24 
25 using namespace std;
26 using namespace geant_units;
27 using namespace geant_units::operators;
28 
29 #include <string>
30 #include <utility>
31 
32 using namespace std;
33 
35 
37 
38 
40  const DDCompactView* cview,
41  const MuonDDDConstants& muonConstants){
42  // cout << "DTGeometryBuilderFromDDD::build" << endl;
43  // static const string t0 = "DTGeometryBuilderFromDDD::build";
44  // TimeMe timer(t0,true);
45 
46  std::string attribute = "MuStructure";
47  std::string value = "MuonBarrelDT";
48 
49  // Asking only for the Muon DTs
50  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
51 
52  DDFilteredView fview(*cview,filter);
53  buildGeometry(theGeometry, fview, muonConstants);
54 }
55 
56 
58  DDFilteredView& fv,
59  const MuonDDDConstants& muonConstants) const {
60  bool doChamber = fv.firstChild();
61 
62  // Loop on chambers
63  int ChamCounter=0;
64  while (doChamber){
65  ChamCounter++;
66  DDValue val("Type");
67  const DDsvalues_type params(fv.mergedSpecifics());
68  string type;
69  if (DDfetch(&params,val)) type = val.strings()[0];
70  // FIXME
71  val=DDValue("FEPos");
72  string FEPos;
73  if (DDfetch(&params,val)) 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, const MuonDDDConstants& muonConstants) const {
108  MuonDDDNumbering mdddnum (muonConstants);
109  DTNumberingScheme dtnum (muonConstants);
110  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
111  DTChamberId detId(rawid);
112 
113  // Chamber specific parameter (size)
114  // FIXME: some trouble for boolean solids?
115  vector<double> par = extractParameters(fv);
116 
118  // width is along local X. r-phi dimension - different in different chambers
119  // length is along local Y. z dimension - constant 125.55 cm
120  // thickness is long local Z. radial thickness - almost constant about 18 cm
121 
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 MuonDDDConstants& muonConstants) const {
134 
135  MuonDDDNumbering mdddnum(muonConstants);
136  DTNumberingScheme dtnum(muonConstants);
137  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
138  DTSuperLayerId slId(rawid);
139 
140  // Slayer specific parameter (size)
141  vector<double> par = extractParameters(fv);
142 
143  // r-phi dimension - different in different chambers
144  // z dimension - constant 126.8 cm
145  // radial thickness - almost constant about 20 cm
146 
147  // Ok this is the s-layer position...
148  RCPPlane surf(plane(fv, dtGeometryBuilder::getRecPlaneBounds(par.begin())));
149 
150  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
151 
152  //LocalPoint lpos(10,20,30);
153  //GlobalPoint gpos=slayer->toGlobal(lpos);
154 
155  // add to the chamber
156  chamber->add(slayer);
157  return slayer;
158 }
159 
160 
162  DTSuperLayer* sl,
163  const std::string& type,
164  const MuonDDDConstants& muonConstants) const {
165 
166  MuonDDDNumbering 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  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  // Loop on wires
180  bool doWire = fv.firstChild();
181  int WCounter=0;
182  int firstWire=fv.copyno();
183  par = extractParameters(fv);
184  float wireLength = convertMmToCm( par[1] );
185  while (doWire) {
186  WCounter++;
187  doWire = fv.nextSibling(); // next wire
188  }
189  //int lastWire=fv.copyno();
190  DTTopology topology(firstWire, WCounter, wireLength);
191 
192  DTLayerType layerType;
193 
194  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
195 
196  sl->add(layer);
197  return layer;
198 }
199 
200 vector<double>
202  vector<double> par;
203  if (fv.logicalPart().solid().shape() != DDSolidShape::ddbox) {
204  DDBooleanSolid bs(fv.logicalPart().solid());
205  DDSolid A = bs.solidA();
206  while (A.shape() != DDSolidShape::ddbox) {
207  DDBooleanSolid bs(A);
208  A = bs.solidA();
209  }
210  par=A.parameters();
211  } else {
212  par = fv.logicalPart().solid().parameters();
213  }
214  return par;
215 }
216 
219  Bounds * bounds) const {
220  // extract the position
221  const DDTranslation & trans(fv.translation());
222 
223  const Surface::PositionType posResult(float(convertMmToCm( trans.x() )),
224  float(convertMmToCm( trans.y() )),
225  float(convertMmToCm( trans.z() )));
226  LogTrace("DTGeometryBuilderFromDDD") << "DTGeometryBuilderFromDDD::plane " <<" posResult: "
227  << posResult << std::endl;
228  // now the rotation
229  // 'active' and 'passive' rotations are inverse to each other
230  const DDRotationMatrix& rotation = fv.rotation();//REMOVED .Inverse();
231  DD3Vector x, y, z;
232  rotation.GetComponents(x,y,z);
233 // std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
234 // std::cout << "INVERSE rotation manually: "
235 // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
236 // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
237 // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
238 
239  Surface::RotationType rotResult(float(x.X()),float(x.Y()),float(x.Z()),
240  float(y.X()),float(y.Y()),float(y.Z()),
241  float(z.X()),float(z.Y()),float(z.Z()));
242 
243 // std::cout << "rotation by its own operator: "<< tmp << std::endl;
244 // DD3Vector tx, ty,tz;
245 // tmp.GetComponents(tx, ty, tz);
246 // std::cout << "rotation manually: "
247 // << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
248 // << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
249 // << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;
250 
251  return RCPPlane( new Plane( posResult, rotResult, bounds));
252 }
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.
RectangularPlaneBounds * getRecPlaneBounds(const std::vector< double >::const_iterator &shapeStart)
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
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
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
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
#define LogTrace(id)
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 buildGeometry(DTGeometry &theGeometry, DDFilteredView &fv, const MuonDDDConstants &muonConstants) const
void add(DTSuperLayer *sl)
Add SL to the chamber which takes ownership.
Definition: DTChamber.cc:41
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 ...
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:110
Definition: Bounds.h:22
const DDTranslation & translation() const
The absolute translation of the current node.
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
void add(DTChamber *ch)
Add a DTChamber to Geometry.
Definition: DTGeometry.cc:44