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  RectangularPlaneBounds bound(width, length, thickness);
137 
138  RCPPlane surf(plane(fv,bound));
139 
140  DTChamber* chamber = new DTChamber(detId, surf);
141 
142  return chamber;
143 }
144 
146  DTChamber* chamber,
147  const std::string& type,
148  const MuonDDDConstants& muonConstants) const {
149 
150  MuonDDDNumbering mdddnum(muonConstants);
151  DTNumberingScheme dtnum(muonConstants);
152  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
153  DTSuperLayerId slId(rawid);
154 
155  // Slayer specific parameter (size)
156  vector<double> par = extractParameters(fv);
157 
158  float width = par[0]/cm; // r-phi dimension - changes in different chambers
159  float length = par[1]/cm; // z dimension - constant 126.8 cm
160  float thickness = par[2]/cm; // radial thickness - almost constant about 20 cm
161 
162  RectangularPlaneBounds bound(width, length, thickness);
163 
164  // Ok this is the slayer position...
165  RCPPlane surf(plane(fv,bound));
166 
167  DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
168 
169  //LocalPoint lpos(10,20,30);
170  //GlobalPoint gpos=slayer->toGlobal(lpos);
171 
172  // add to the chamber
173  chamber->add(slayer);
174  return slayer;
175 }
176 
177 
179  DTSuperLayer* sl,
180  const std::string& type,
181  const MuonDDDConstants& muonConstants) const {
182 
183  MuonDDDNumbering mdddnum(muonConstants);
184  DTNumberingScheme dtnum(muonConstants);
185  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
186  DTLayerId layId(rawid);
187 
188  // Layer specific parameter (size)
189  vector<double> par = extractParameters(fv);
190  float width = par[0]/cm; // r-phi dimension - changes in different chambers
191  float length = par[1]/cm; // z dimension - constant 126.8 cm
192  float thickness = par[2]/cm; // radial thickness - almost constant about 20 cm
193 
194  // define Bounds
195  RectangularPlaneBounds bound(width, length, thickness);
196 
197  RCPPlane surf(plane(fv,bound));
198 
199  // Loop on wires
200  bool doWire = fv.firstChild();
201  int WCounter=0;
202  int firstWire=fv.copyno();
203  par = extractParameters(fv);
204  float wireLength = par[1]/cm;
205  while (doWire) {
206  WCounter++;
207  doWire = fv.nextSibling(); // next wire
208  }
209  //int lastWire=fv.copyno();
210  DTTopology topology(firstWire, WCounter, wireLength);
211 
212  DTLayerType layerType;
213 
214  DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
215 
216  sl->add(layer);
217  return layer;
218 }
219 
220 vector<double>
222  vector<double> par;
223  if (fv.logicalPart().solid().shape() != ddbox) {
224  DDBooleanSolid bs(fv.logicalPart().solid());
225  DDSolid A = bs.solidA();
226  while (A.shape() != ddbox) {
227  DDBooleanSolid bs(A);
228  A = bs.solidA();
229  }
230  par=A.parameters();
231  } else {
232  par = fv.logicalPart().solid().parameters();
233  }
234  return par;
235 }
236 
239  const Bounds& bounds) const {
240  // extract the position
241  const DDTranslation & trans(fv.translation());
242 
243  const Surface::PositionType posResult(float(trans.x()/cm),
244  float(trans.y()/cm),
245  float(trans.z()/cm));
246  // now the rotation
247  // DDRotationMatrix tmp = fv.rotation();
248  // === DDD uses 'active' rotations - see CLHEP user guide ===
249  // ORCA uses 'passive' rotation.
250  // 'active' and 'passive' rotations are inverse to each other
251  // DDRotationMatrix tmp = fv.rotation();
252  DDRotationMatrix rotation = fv.rotation();//REMOVED .Inverse();
253  DD3Vector x, y, z;
254  rotation.GetComponents(x,y,z);
255 // std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
256 // std::cout << "INVERSE rotation manually: "
257 // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
258 // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
259 // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
260 
261  Surface::RotationType rotResult(float(x.X()),float(x.Y()),float(x.Z()),
262  float(y.X()),float(y.Y()),float(y.Z()),
263  float(z.X()),float(z.Y()),float(z.Z()));
264 
265 // std::cout << "rotation by its own operator: "<< tmp << std::endl;
266 // DD3Vector tx, ty,tz;
267 // tmp.GetComponents(tx, ty, tz);
268 // std::cout << "rotation manually: "
269 // << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
270 // << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
271 // << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;
272 
273  return RCPPlane( new BoundPlane( posResult, rotResult, bounds));
274 }
const std::vector< double > & parameters() const
Don&#39;t use (only meant to be used by DDbox(), DDtub(), ...)
Definition: DDSolid.cc:153
type
Definition: HCALResponse.h:22
virtual ~DTGeometryBuilderFromDDD()
Destructor.
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)
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
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:61
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:81
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
double double double z
A DDSolid represents the shape of a part.
Definition: DDSolid.h:42
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
int copyno() const
Copy number associated with the current node.
RCPPlane plane(const DDFilteredView &fv, const Bounds &bounds) const
DTChamber * buildChamber(DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants) const
create the chamber
DDSolid solidA() const
Definition: DDSolid.cc:548
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
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:76
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
void build(boost::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
DDsvalues_type mergedSpecifics() const
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
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
std::string extractParameters(xoap::MessageReference, xdaq::Application *)
Definition: SoapUtils.cc:25
Definition: Bounds.h:18
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.
const double par[8 *NPar][4]
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37