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