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 
12 
21 #include "CLHEP/Units/GlobalSystemOfUnits.h"
22 
23 
25 
26 #include <string>
27 
28 using namespace std;
29 
30 #include <string>
31 
32 using namespace std;
33 
35 
37 
38 
40  const MuonDDDConstants& muonConstants,
41  RecoIdealGeometry& rig) {
42  // cout << "DTGeometryParsFromDD::build" << endl;
43  // static const string t0 = "DTGeometryParsFromDD::build";
44  // TimeMe timer(t0,true);
45 
46  std::string attribute = "MuStructure";
47  std::string value = "MuonBarrelDT";
48  DDValue val(attribute, value, 0.0);
49 
50  // Asking only for the Muon DTs
52  filter.setCriteria(val, // name & value of a variable
55  true, // compare strings otherwise doubles
56  true // use merged-specifics or simple-specifics
57  );
58  DDFilteredView fview(*cview);
59  fview.addFilter(filter);
60  buildGeometry(fview, muonConstants, rig);
61  //cout << "RecoIdealGeometry " << rig.size() << endl;
62 }
63 
64 
66  const MuonDDDConstants& muonConstants,
67  RecoIdealGeometry& rig) const {
68  // static const string t0 = "DTGeometryParsFromDD::buildGeometry";
69  // TimeMe timer(t0,true);
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  insertChamber(fv,type, muonConstants,rig);
86 
87  // Loop on SLs
88  bool doSL = fv.firstChild();
89  int SLCounter=0;
90  while (doSL) {
91  SLCounter++;
92  insertSuperLayer(fv, type, muonConstants,rig);
93 
94  bool doL = fv.firstChild();
95  int LCounter=0;
96  // Loop on SLs
97  while (doL) {
98  LCounter++;
99  insertLayer(fv, type, muonConstants, rig);
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 
109  fv.parent();
110  doChamber = fv.nextSibling(); // go to next chamber
111  } // chambers
112 }
113 
115  const string& type,
116  const MuonDDDConstants& muonConstants,
117  RecoIdealGeometry& rig) const {
118  MuonDDDNumbering mdddnum (muonConstants);
119  DTNumberingScheme dtnum (muonConstants);
120  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
121  DTChamberId detId(rawid);
122  //cout << "inserting Chamber " << detId << endl;
123 
124  // Chamber specific parameter (size)
125  vector<double> par;
126  par.push_back(DTChamberTag);
127  vector<double> size= extractParameters(fv);
128  par.insert(par.end(), size.begin(), size.end());
129 
131  // width is along local X
132  // length is along local Y
133  // thickness is long local Z
134 
135  PosRotPair posRot(plane(fv));
136 
137  rig.insert(rawid, posRot.first, posRot.second, par);
138 }
139 
141  const std::string& type,
142  const MuonDDDConstants& muonConstants,
143  RecoIdealGeometry& rig) const {
144 
145  MuonDDDNumbering mdddnum(muonConstants);
146  DTNumberingScheme dtnum(muonConstants);
147  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
148  DTSuperLayerId slId(rawid);
149  //cout << "inserting SuperLayer " << slId << endl;
150 
151  // Slayer specific parameter (size)
152  vector<double> par;
153  par.push_back(DTSuperLayerTag);
154  vector<double> size= extractParameters(fv);
155  par.insert(par.end(), size.begin(), size.end());
156 
157  // Ok this is the slayer position...
158  PosRotPair posRot(plane(fv));
159 
160  rig.insert(slId, posRot.first, posRot.second, par);
161 }
162 
164  const std::string& type,
165  const MuonDDDConstants& muonConstants,
166  RecoIdealGeometry& rig) const {
167 
168  MuonDDDNumbering mdddnum(muonConstants);
169  DTNumberingScheme dtnum(muonConstants);
170  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
171  DTLayerId layId(rawid);
172  //cout << "inserting Layer " << layId << endl;
173 
174  // Layer specific parameter (size)
175  vector<double> par;
176  par.push_back(DTLayerTag);
177  vector<double> size= extractParameters(fv);
178  par.insert(par.end(), size.begin(), size.end());
179 
180  // Loop on wires
181  bool doWire = fv.firstChild();
182  int WCounter=0;
183  int firstWire=fv.copyno();
184  //float wireLength = par[1]/cm;
185  while (doWire) {
186  WCounter++;
187  doWire = fv.nextSibling(); // next wire
188  }
189  vector<double> sensSize= extractParameters(fv);
190  //int lastWire=fv.copyno();
191  par.push_back(firstWire);
192  par.push_back(WCounter);
193  par.push_back(sensSize[1]);
194  fv.parent();
195 
196  PosRotPair posRot(plane(fv));
197 
198  rig.insert(layId, posRot.first, posRot.second, par);
199 
200 }
201 
202 vector<double>
204  vector<double> par;
205  if (fv.logicalPart().solid().shape() != ddbox) {
206  DDBooleanSolid bs(fv.logicalPart().solid());
207  DDSolid A = bs.solidA();
208  while (A.shape() != ddbox) {
209  DDBooleanSolid bs(A);
210  A = bs.solidA();
211  }
212  par=A.parameters();
213  } else {
214  par = fv.logicalPart().solid().parameters();
215  }
216  return par;
217 }
218 
221  // extract the position
222  const DDTranslation & trans(fv.translation());
223 
224  std::vector<double> gtran( 3 );
225  gtran[0] = (float) 1.0 * (trans.x() / cm);
226  gtran[1] = (float) 1.0 * (trans.y() / cm);
227  gtran[2] = (float) 1.0 * (trans.z() / cm);
228 
229  // now the rotation
230  // DDRotationMatrix tmp = fv.rotation();
231  // === DDD uses 'active' rotations - see CLHEP user guide ===
232  // ORCA uses 'passive' rotation.
233  // 'active' and 'passive' rotations are inverse to each other
234  // DDRotationMatrix tmp = fv.rotation();
235  DDRotationMatrix rotation = fv.rotation();//REMOVED .Inverse();
236  DD3Vector x, y, z;
237  rotation.GetComponents(x,y,z);
238 // std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
239 // std::cout << "INVERSE rotation manually: "
240 // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
241 // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
242 // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
243 
244  std::vector<double> grmat( 9 );
245  grmat[0] = (float) 1.0 * x.X();
246  grmat[1] = (float) 1.0 * x.Y();
247  grmat[2] = (float) 1.0 * x.Z();
248 
249  grmat[3] = (float) 1.0 * y.X();
250  grmat[4] = (float) 1.0 * y.Y();
251  grmat[5] = (float) 1.0 * y.Z();
252 
253  grmat[6] = (float) 1.0 * z.X();
254  grmat[7] = (float) 1.0 * z.Y();
255  grmat[8] = (float) 1.0 * 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 pair<std::vector<double>, std::vector<double> >(gtran, grmat);
266 }
type
Definition: HCALResponse.h:22
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 &, 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.
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: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
double double double 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.
virtual ~DTGeometryParsFromDD()
Destructor.
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
int getDetId(const MuonBaseNumber num) const
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
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
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
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.
void insertSuperLayer(DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
create the SL
tuple size
Write out results.
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:37