CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTGeometryParsFromDD.cc
Go to the documentation of this file.
1 
10 
19 #include "CLHEP/Units/GlobalSystemOfUnits.h"
20 
21 
23 
24 #include <string>
25 
26 using namespace std;
27 
28 #include <string>
29 
30 using namespace std;
31 
33 
35 
36 
38  const MuonDDDConstants& muonConstants,
39  RecoIdealGeometry& rig) {
40  // cout << "DTGeometryParsFromDD::build" << endl;
41  // static const string t0 = "DTGeometryParsFromDD::build";
42  // TimeMe timer(t0,true);
43 
44  std::string attribute = "MuStructure";
45  std::string value = "MuonBarrelDT";
46  DDValue val(attribute, value, 0.0);
47 
48  // Asking only for the Muon DTs
50  filter.setCriteria(val, // name & value of a variable
52  DDLogOp::AND,
53  true, // compare strings otherwise doubles
54  true // use merged-specifics or simple-specifics
55  );
56  DDFilteredView fview(*cview);
57  fview.addFilter(filter);
58  buildGeometry(fview, muonConstants, rig);
59  //cout << "RecoIdealGeometry " << rig.size() << endl;
60 }
61 
62 
64  const MuonDDDConstants& muonConstants,
65  RecoIdealGeometry& rig) const {
66  // static const string t0 = "DTGeometryParsFromDD::buildGeometry";
67  // TimeMe timer(t0,true);
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  insertChamber(fv,type, muonConstants,rig);
84 
85  // Loop on SLs
86  bool doSL = fv.firstChild();
87  int SLCounter=0;
88  while (doSL) {
89  SLCounter++;
90  insertSuperLayer(fv, type, muonConstants,rig);
91 
92  bool doL = fv.firstChild();
93  int LCounter=0;
94  // Loop on SLs
95  while (doL) {
96  LCounter++;
97  insertLayer(fv, type, muonConstants, rig);
98 
99  // fv.parent();
100  doL = fv.nextSibling(); // go to next layer
101  } // layers
102 
103  fv.parent();
104  doSL = fv.nextSibling(); // go to next SL
105  } // sls
106 
107  fv.parent();
108  doChamber = fv.nextSibling(); // go to next chamber
109  } // chambers
110 }
111 
113  const string& type,
114  const MuonDDDConstants& muonConstants,
115  RecoIdealGeometry& rig) const {
116  MuonDDDNumbering mdddnum (muonConstants);
117  DTNumberingScheme dtnum (muonConstants);
118  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
119  DTChamberId detId(rawid);
120  //cout << "inserting Chamber " << detId << endl;
121 
122  // Chamber specific parameter (size)
123  vector<double> par;
124  par.push_back(DTChamberTag);
125  vector<double> size= extractParameters(fv);
126  par.insert(par.end(), size.begin(), size.end());
127 
129  // width is along local X
130  // length is along local Y
131  // thickness is long local Z
132 
133  PosRotPair posRot(plane(fv));
134 
135  rig.insert(rawid, posRot.first, posRot.second, par);
136 }
137 
139  const std::string& type,
140  const MuonDDDConstants& muonConstants,
141  RecoIdealGeometry& rig) const {
142 
143  MuonDDDNumbering mdddnum(muonConstants);
144  DTNumberingScheme dtnum(muonConstants);
145  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
146  DTSuperLayerId slId(rawid);
147  //cout << "inserting SuperLayer " << slId << endl;
148 
149  // Slayer specific parameter (size)
150  vector<double> par;
151  par.push_back(DTSuperLayerTag);
152  vector<double> size= extractParameters(fv);
153  par.insert(par.end(), size.begin(), size.end());
154 
155  // Ok this is the slayer position...
156  PosRotPair posRot(plane(fv));
157 
158  rig.insert(slId, posRot.first, posRot.second, par);
159 }
160 
162  const std::string& type,
163  const MuonDDDConstants& muonConstants,
164  RecoIdealGeometry& rig) const {
165 
166  MuonDDDNumbering mdddnum(muonConstants);
167  DTNumberingScheme dtnum(muonConstants);
168  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
169  DTLayerId layId(rawid);
170  //cout << "inserting Layer " << layId << endl;
171 
172  // Layer specific parameter (size)
173  vector<double> par;
174  par.push_back(DTLayerTag);
175  vector<double> size= extractParameters(fv);
176  par.insert(par.end(), size.begin(), size.end());
177 
178  // Loop on wires
179  bool doWire = fv.firstChild();
180  int WCounter=0;
181  int firstWire=fv.copyno();
182  //float wireLength = par[1]/cm;
183  while (doWire) {
184  WCounter++;
185  doWire = fv.nextSibling(); // next wire
186  }
187  vector<double> sensSize= extractParameters(fv);
188  //int lastWire=fv.copyno();
189  par.push_back(firstWire);
190  par.push_back(WCounter);
191  par.push_back(sensSize[1]);
192  fv.parent();
193 
194  PosRotPair posRot(plane(fv));
195 
196  rig.insert(layId, posRot.first, posRot.second, par);
197 
198 }
199 
200 vector<double>
202  vector<double> par;
203  if (fv.logicalPart().solid().shape() != ddbox) {
204  DDBooleanSolid bs(fv.logicalPart().solid());
205  DDSolid A = bs.solidA();
206  while (A.shape() != 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  // extract the position
220  const DDTranslation & trans(fv.translation());
221 
222  std::vector<double> gtran( 3 );
223  gtran[0] = (float) 1.0 * (trans.x() / cm);
224  gtran[1] = (float) 1.0 * (trans.y() / cm);
225  gtran[2] = (float) 1.0 * (trans.z() / cm);
226 
227  // now the rotation
228  // DDRotationMatrix tmp = fv.rotation();
229  // === DDD uses 'active' rotations - see CLHEP user guide ===
230  // ORCA uses 'passive' rotation.
231  // 'active' and 'passive' rotations are inverse to each other
232  // DDRotationMatrix tmp = fv.rotation();
233  DDRotationMatrix rotation = fv.rotation();//REMOVED .Inverse();
234  DD3Vector x, y, z;
235  rotation.GetComponents(x,y,z);
236 // std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
237 // std::cout << "INVERSE rotation manually: "
238 // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
239 // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
240 // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
241 
242  std::vector<double> grmat( 9 );
243  grmat[0] = (float) 1.0 * x.X();
244  grmat[1] = (float) 1.0 * x.Y();
245  grmat[2] = (float) 1.0 * x.Z();
246 
247  grmat[3] = (float) 1.0 * y.X();
248  grmat[4] = (float) 1.0 * y.Y();
249  grmat[5] = (float) 1.0 * y.Z();
250 
251  grmat[6] = (float) 1.0 * z.X();
252  grmat[7] = (float) 1.0 * z.Y();
253  grmat[8] = (float) 1.0 * z.Z();
254 
255 // std::cout << "rotation by its own operator: "<< tmp << std::endl;
256 // DD3Vector tx, ty,tz;
257 // tmp.GetComponents(tx, ty, tz);
258 // std::cout << "rotation manually: "
259 // << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
260 // << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
261 // << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;
262 
263  return pair<std::vector<double>, std::vector<double> >(gtran, grmat);
264 }
type
Definition: HCALResponse.h:21
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 addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars)
void insertChamber(DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
create the chamber
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
type of data representation of DDCompactView
Definition: DDCompactView.h:76
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
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.
virtual ~DTGeometryParsFromDD()
Destructor.
T x() const
Cartesian x coordinate.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
std::vector< double > extractParameters(DDFilteredView &fv) const
get parameter also for boolean solid.
void insertLayer(DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
create the layer
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
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
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
DTGeometryParsFromDD()
Constructor.
DDSolid solidA(void) const
Definition: DDSolid.cc:545
std::pair< std::vector< double >, std::vector< double > > PosRotPair
DDsvalues_type mergedSpecifics() const
void buildGeometry(DDFilteredView &fv, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
int getDetId(const MuonBaseNumber &num) const
bool firstChild()
set the current node to the first child ...
const DDTranslation & translation() const
The absolute translation of the current node.
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void insertSuperLayer(DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
create the SL
tuple size
Write out results.
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
void build(const DDCompactView *cview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig)
PosRotPair plane(const DDFilteredView &fv) const
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32