CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
29 using namespace std;
30 
32 
34 
35 
36 void DTGeometryBuilderFromDDD::build(boost::shared_ptr<DTGeometry> theGeometry,
37  const DDCompactView* cview,
38  const MuonDDDConstants& 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  DDValue val(attribute, value, 0.0);
46 
47  // Asking only for the Muon DTs
49  filter.setCriteria(val, // name & value of a variable
52  true, // compare strings otherwise doubles
53  true // use merged-specifics or simple-specifics
54  );
55  DDFilteredView fview(*cview);
56  fview.addFilter(filter);
57  buildGeometry(theGeometry, fview, muonConstants);
58 }
59 
60 
61 void DTGeometryBuilderFromDDD::buildGeometry(boost::shared_ptr<DTGeometry> theGeometry,
62  DDFilteredView& fv,
63  const MuonDDDConstants& muonConstants) const {
64  // static const string t0 = "DTGeometryBuilderFromDDD::buildGeometry";
65  // TimeMe timer(t0,true);
66 
67  //DTGeometry* theGeometry = new DTGeometry;
68 
69  bool doChamber = fv.firstChild();
70 
71  // Loop on chambers
72  int ChamCounter=0;
73  while (doChamber){
74  ChamCounter++;
75  DDValue val("Type");
76  const DDsvalues_type params(fv.mergedSpecifics());
77  string type;
78  if (DDfetch(&params,val)) type = val.strings()[0];
79  // FIXME
80  val=DDValue("FEPos");
81  string FEPos;
82  if (DDfetch(&params,val)) FEPos = val.strings()[0];
83  DTChamber* chamber = buildChamber(fv,type, muonConstants);
84 
85  // Loop on SLs
86  bool doSL = fv.firstChild();
87  int SLCounter=0;
88  while (doSL) {
89  SLCounter++;
90  DTSuperLayer* sl = buildSuperLayer(fv, chamber, type, muonConstants);
91  theGeometry->add(sl);
92 
93  bool doL = fv.firstChild();
94  int LCounter=0;
95  // Loop on SLs
96  while (doL) {
97  LCounter++;
98  DTLayer* layer = buildLayer(fv, sl, type, muonConstants);
99  theGeometry->add(layer);
100 
101  fv.parent();
102  doL = fv.nextSibling(); // go to next layer
103  } // layers
104 
105  fv.parent();
106  doSL = fv.nextSibling(); // go to next SL
107  } // sls
108  theGeometry->add(chamber);
109 
110  fv.parent();
111  doChamber = fv.nextSibling(); // go to next chamber
112  } // chambers
113 }
114 
116  const string& type, const MuonDDDConstants& muonConstants) const {
117  MuonDDDNumbering mdddnum (muonConstants);
118  DTNumberingScheme dtnum (muonConstants);
119  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
120  DTChamberId detId(rawid);
121 
122  // Chamber specific parameter (size)
123  // FIXME: some trouble for boolean solids?
124  vector<double> par = extractParameters(fv);
125 
126  float width = par[0]/cm; // r-phi dimension - different in different chambers
127  float length = par[1]/cm; // z dimension - constant 125.55 cm
128  float thickness = par[2]/cm; // radial thickness - almost constant about 18 cm
129 
131  // width is along local X
132  // length is along local Y
133  // thickness is long local Z
134 
135  RCPPlane surf(plane(fv, new RectangularPlaneBounds(width, length, thickness) ));
136 
137  DTChamber* chamber = new DTChamber(detId, surf);
138 
139  return chamber;
140 }
141 
143  DTChamber* chamber,
144  const std::string& type,
145  const MuonDDDConstants& muonConstants) const {
146 
147  MuonDDDNumbering mdddnum(muonConstants);
148  DTNumberingScheme dtnum(muonConstants);
149  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
150  DTSuperLayerId slId(rawid);
151 
152  // Slayer specific parameter (size)
153  vector<double> par = extractParameters(fv);
154 
155  float width = par[0]/cm; // r-phi dimension - changes in different chambers
156  float length = par[1]/cm; // z dimension - constant 126.8 cm
157  float thickness = par[2]/cm; // radial thickness - almost constant about 20 cm
158 
159  // Ok this is the slayer position...
160  RCPPlane surf(plane(fv, new RectangularPlaneBounds(width, length, thickness) ));
161 
162  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
163 
164  //LocalPoint lpos(10,20,30);
165  //GlobalPoint gpos=slayer->toGlobal(lpos);
166 
167  // add to the chamber
168  chamber->add(slayer);
169  return slayer;
170 }
171 
172 
174  DTSuperLayer* sl,
175  const std::string& type,
176  const MuonDDDConstants& muonConstants) const {
177 
178  MuonDDDNumbering mdddnum(muonConstants);
179  DTNumberingScheme dtnum(muonConstants);
180  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
181  DTLayerId layId(rawid);
182 
183  // Layer specific parameter (size)
184  vector<double> par = extractParameters(fv);
185  float width = par[0]/cm; // r-phi dimension - changes in different chambers
186  float length = par[1]/cm; // z dimension - constant 126.8 cm
187  float thickness = par[2]/cm; // radial thickness - almost constant about 20 cm
188 
189  RCPPlane surf(plane(fv, new RectangularPlaneBounds(width, length, thickness) ));
190 
191  // Loop on wires
192  bool doWire = fv.firstChild();
193  int WCounter=0;
194  int firstWire=fv.copyno();
195  par = extractParameters(fv);
196  float wireLength = par[1]/cm;
197  while (doWire) {
198  WCounter++;
199  doWire = fv.nextSibling(); // next wire
200  }
201  //int lastWire=fv.copyno();
202  DTTopology topology(firstWire, WCounter, wireLength);
203 
204  DTLayerType layerType;
205 
206  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
207 
208  sl->add(layer);
209  return layer;
210 }
211 
212 vector<double>
214  vector<double> par;
215  if (fv.logicalPart().solid().shape() != ddbox) {
216  DDBooleanSolid bs(fv.logicalPart().solid());
217  DDSolid A = bs.solidA();
218  while (A.shape() != ddbox) {
219  DDBooleanSolid bs(A);
220  A = bs.solidA();
221  }
222  par=A.parameters();
223  } else {
224  par = fv.logicalPart().solid().parameters();
225  }
226  return par;
227 }
228 
231  Bounds * bounds) const {
232  // extract the position
233  const DDTranslation & trans(fv.translation());
234 
235  const Surface::PositionType posResult(float(trans.x()/cm),
236  float(trans.y()/cm),
237  float(trans.z()/cm));
238  // now the rotation
239  // DDRotationMatrix tmp = fv.rotation();
240  // === DDD uses 'active' rotations - see CLHEP user guide ===
241  // ORCA uses 'passive' rotation.
242  // 'active' and 'passive' rotations are inverse to each other
243  // DDRotationMatrix tmp = fv.rotation();
244  DDRotationMatrix rotation = fv.rotation();//REMOVED .Inverse();
245  DD3Vector x, y, z;
246  rotation.GetComponents(x,y,z);
247 // std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
248 // std::cout << "INVERSE rotation manually: "
249 // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
250 // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
251 // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
252 
253  Surface::RotationType rotResult(float(x.X()),float(x.Y()),float(x.Z()),
254  float(y.X()),float(y.Y()),float(y.Z()),
255  float(z.X()),float(z.Y()),float(z.Z()));
256 
257 // std::cout << "rotation by its own operator: "<< tmp << std::endl;
258 // DD3Vector tx, ty,tz;
259 // tmp.GetComponents(tx, ty, tz);
260 // std::cout << "rotation manually: "
261 // << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
262 // << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
263 // << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;
264 
265  return RCPPlane( new Plane( posResult, rotResult, bounds));
266 }
type
Definition: HCALResponse.h:21
virtual ~DTGeometryBuilderFromDDD()
Destructor.
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
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.
void buildGeometry(boost::shared_ptr< DTGeometry > theGeometry, DDFilteredView &fv, const MuonDDDConstants &muonConstants) const
void addFilter(const DDFilter &, log_op op=AND)
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.
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
type of data representation of DDCompactView
Definition: DDCompactView.h:77
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:80
Definition: Plane.h:17
float float float z
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
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
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
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:144
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:62
DDSolid solidA(void) const
Definition: DDSolid.cc:545
void build(boost::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
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
int getDetId(const MuonBaseNumber &num) const
bool firstChild()
set the current node to the first child ...
void setCriteria(const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:285
Definition: Bounds.h:22
const DDTranslation & translation() const
The absolute translation of the current node.
Definition: DDAxes.h:10
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37