CMS 3D CMS Logo

DTGeometryParsFromDD.cc
Go to the documentation of this file.
1 
29 #include <iostream>
30 #include <algorithm>
31 #include <string>
32 
33 using namespace std;
34 using namespace geant_units;
35 using namespace geant_units::operators;
36 
38 
40 
41 // DD
43  const MuonGeometryConstants& muonConstants,
44  RecoIdealGeometry& rig) {
45  // cout << "DTGeometryParsFromDD::build" << endl;
46  // static const string t0 = "DTGeometryParsFromDD::build";
47  // TimeMe timer(t0,true);
48 
49  std::string attribute = "MuStructure";
50  std::string value = "MuonBarrelDT";
51 
52  // Asking only for the Muon DTs
54  DDFilteredView fview(*cview, filter);
55  buildGeometry(fview, muonConstants, rig);
56  //cout << "RecoIdealGeometry " << rig.size() << endl;
57 }
58 
59 // DD4Hep
60 
62  const MuonGeometryConstants& muonConstants,
63  RecoIdealGeometry& rgeo) {
64  const std::string attribute = "MuStructure";
65  const std::string value = "MuonBarrelDT";
66  const cms::DDFilter filter(attribute, value);
67  cms::DDFilteredView fview(*cview, filter);
68  buildGeometry(fview, muonConstants, rgeo);
69 }
70 
71 // DD
73  const MuonGeometryConstants& muonConstants,
74  RecoIdealGeometry& rig) const {
75  // static const string t0 = "DTGeometryParsFromDD::buildGeometry";
76  // TimeMe timer(t0,true);
77 
78  edm::LogVerbatim("DTGeometryParsFromDD") << "(0) DTGeometryParsFromDD - DDD ";
79 
80  bool doChamber = fv.firstChild();
81 
82  // Loop on chambers
83  int ChamCounter = 0;
84  while (doChamber) {
85  ChamCounter++;
86  DDValue val("Type");
88  string type;
89  if (DDfetch(&params, val))
90  type = val.strings()[0];
91  // FIXME
92  val = DDValue("FEPos");
93  string FEPos;
94  if (DDfetch(&params, val))
95  FEPos = val.strings()[0];
96  insertChamber(fv, type, muonConstants, rig);
97 
98  // Loop on SLs
99  bool doSL = fv.firstChild();
100  int SLCounter = 0;
101  while (doSL) {
102  SLCounter++;
103  insertSuperLayer(fv, type, muonConstants, rig);
104 
105  bool doL = fv.firstChild();
106  int LCounter = 0;
107  // Loop on SLs
108  while (doL) {
109  LCounter++;
110  insertLayer(fv, type, muonConstants, rig);
111 
112  // fv.parent();
113  doL = fv.nextSibling(); // go to next layer
114  } // layers
115 
116  fv.parent();
117  doSL = fv.nextSibling(); // go to next SL
118  } // sls
119 
120  fv.parent();
121  doChamber = fv.nextSibling(); // go to next chamber
122  } // chambers
123 }
124 
126  const string& type,
127  const MuonGeometryConstants& muonConstants,
128  RecoIdealGeometry& rig) const {
129  MuonGeometryNumbering mdddnum(muonConstants);
130  DTNumberingScheme dtnum(muonConstants);
131  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
132  DTChamberId detId(rawid);
133  //cout << "inserting Chamber " << detId << endl;
134 
135  // Chamber specific parameter (size)
136  vector<double> par;
137  par.emplace_back(DTChamberTag);
138  vector<double> size = extractParameters(fv);
139  par.insert(par.end(), size.begin(), size.end());
140  edm::LogVerbatim("DTGeometryParsFromDD")
141  << "(1) DDD, Chamber DetID " << rawid << " " << par[0] << " " << par[1] << " " << par[2] << " " << par[3];
143  // width is along local X
144  // length is along local Y
145  // thickness is long local Z
146 
147  PosRotPair posRot(plane(fv));
148  rig.insert(rawid, posRot.first, posRot.second, par);
149 }
150 
152  const std::string& type,
153  const MuonGeometryConstants& muonConstants,
154  RecoIdealGeometry& rig) const {
155  MuonGeometryNumbering mdddnum(muonConstants);
156  DTNumberingScheme dtnum(muonConstants);
157  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
158  DTSuperLayerId slId(rawid);
159  //cout << "inserting SuperLayer " << slId << endl;
160 
161  // Slayer specific parameter (size)
162  vector<double> par;
163  par.emplace_back(DTSuperLayerTag);
164  vector<double> size = extractParameters(fv);
165  par.insert(par.end(), size.begin(), size.end());
166  edm::LogVerbatim("DTGeometryParsFromDD")
167  << "(2) DDD, Super Layer DetID " << rawid << " " << par[0] << " " << par[1] << " " << par[2] << " " << par[3];
168  // Ok this is the slayer position...
169  PosRotPair posRot(plane(fv));
170  rig.insert(slId, posRot.first, posRot.second, par);
171 }
172 
174  const std::string& type,
175  const MuonGeometryConstants& muonConstants,
176  RecoIdealGeometry& rig) const {
177  MuonGeometryNumbering mdddnum(muonConstants);
178  DTNumberingScheme dtnum(muonConstants);
179  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
180  DTLayerId layId(rawid);
181  //cout << "inserting Layer " << layId << endl;
182 
183  // Layer specific parameter (size)
184  vector<double> par;
185  par.emplace_back(DTLayerTag);
186  vector<double> size = extractParameters(fv);
187  par.insert(par.end(), size.begin(), size.end());
188 
189  // Loop on wires
190  bool doWire = fv.firstChild();
191  int WCounter = 0;
192  int firstWire = fv.copyno();
193  //float wireLength = par[1]/cm;
194  while (doWire) {
195  WCounter++;
196  doWire = fv.nextSibling(); // next wire
197  }
198  vector<double> sensSize = extractParameters(fv);
199  //int lastWire=fv.copyno();
200  par.emplace_back(firstWire);
201  par.emplace_back(WCounter);
202  par.emplace_back(sensSize[1]);
203  fv.parent();
204 
205  PosRotPair posRot(plane(fv));
206 
207  edm::LogVerbatim("DTGeometryParsFromDD")
208  << "(3) DDD, Layer DetID " << rawid << " " << par[0] << " " << par[1] << " " << par[2] << " " << par[3] << " "
209  << par[4] << " " << par[5] << " " << par[6];
210  rig.insert(layId, posRot.first, posRot.second, par);
211 }
212 
214  vector<double> par;
215  if (fv.logicalPart().solid().shape() != DDSolidShape::ddbox) {
217  DDSolid A = bs.solidA();
218  while (A.shape() != DDSolidShape::ddbox) {
220  A = bs.solidA();
221  }
222  par = A.parameters();
223  } else {
224  par = fv.logicalPart().solid().parameters();
225  }
226  return par;
227 }
228 
230  // extract the position
231  const DDTranslation& trans(fv.translation());
232 
233  std::vector<double> gtran(3);
234  gtran[0] = convertMmToCm(trans.x());
235  gtran[1] = convertMmToCm(trans.y());
236  gtran[2] = convertMmToCm(trans.z());
237 
238  edm::LogVerbatim("DTGeometryParsFromDD") << "(4) DDD, Position "
239  << " " << gtran[0] << " " << gtran[1] << " " << gtran[2];
240  // now the rotation
241  // 'active' and 'passive' rotations are inverse to each other
242  const DDRotationMatrix& rotation = fv.rotation(); //REMOVED .Inverse();
243  DD3Vector x, y, z;
244  rotation.GetComponents(x, y, z);
245 
246  std::vector<double> grmat(9);
247  grmat[0] = x.X();
248  grmat[1] = x.Y();
249  grmat[2] = x.Z();
250 
251  grmat[3] = y.X();
252  grmat[4] = y.Y();
253  grmat[5] = y.Z();
254 
255  grmat[6] = z.X();
256  grmat[7] = z.Y();
257  grmat[8] = z.Z();
258 
259  return pair<std::vector<double>, std::vector<double> >(gtran, grmat);
260 }
261 
262 // DD4Hep
263 
265  const MuonGeometryConstants& muonConstants,
266  RecoIdealGeometry& rig) const {
267  edm::LogVerbatim("DTGeometryParsFromDD") << "(0) DTGeometryParsFromDD - DD4HEP ";
268 
269  bool doChamber = fv.firstChild();
270 
271  while (doChamber) {
272  insertChamber(fv, muonConstants, rig);
273 
274  bool doSL = fv.nextSibling();
275  while (doSL) {
276  insertSuperLayer(fv, muonConstants, rig);
277 
278  fv.down();
279  bool doLayers = fv.sibling();
280  while (doLayers) {
281  insertLayer(fv, muonConstants, rig);
282 
283  doLayers = fv.sibling();
284  }
285 
286  doSL = fv.nextSibling();
287  }
288 
289  fv.parent();
290  doChamber = fv.firstChild();
291  }
292 }
293 
295  const Double_t* tr = fv.trans();
296 
297  std::vector<double> gtran(3);
298 
299  gtran[0] = tr[0] / dd4hep::cm;
300  gtran[1] = tr[1] / dd4hep::cm;
301  gtran[2] = tr[2] / dd4hep::cm;
302 
303  edm::LogVerbatim("DTGeometryParsFromDD") << "(4) DD4HEP, Position "
304  << " " << gtran[0] << " " << gtran[1] << " " << gtran[2];
305 
307  DD3Vector x, y, z;
308  rotation.GetComponents(x, y, z);
309 
310  std::vector<double> grmat(9);
311 
312  grmat[0] = x.X();
313  grmat[1] = x.Y();
314  grmat[2] = x.Z();
315 
316  grmat[3] = y.X();
317  grmat[4] = y.Y();
318  grmat[5] = y.Z();
319 
320  grmat[6] = z.X();
321  grmat[7] = z.Y();
322  grmat[8] = z.Z();
323 
324  return pair<std::vector<double>, std::vector<double> >(gtran, grmat);
325 }
326 
328  const MuonGeometryConstants& muonConstants,
329  RecoIdealGeometry& rig) const {
330  MuonGeometryNumbering mdddnum(muonConstants);
331  DTNumberingScheme dtnum(muonConstants);
332  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.history()));
333  DTChamberId detId(rawid);
334 
335  vector<double> par_temp = fv.parameters();
336  vector<double> par(4);
337  par[0] = DTChamberTag; //DTChamberTag is the ID of a Chamber
338  par[1] = par_temp[0] / dd4hep::mm;
339  par[2] = par_temp[1] / dd4hep::mm;
340  par[3] = par_temp[2] / dd4hep::mm;
341 
342  edm::LogVerbatim("DTGeometryParsFromDD")
343  << "(1) DD4HEP, Chamber DetID " << rawid << " " << par[0] << " " << par[1] << " " << par[2] << " " << par[3];
344  PosRotPair posRot(plane(fv));
345  rig.insert(rawid, posRot.first, posRot.second, par);
346 }
347 
349  const MuonGeometryConstants& muonConstants,
350  RecoIdealGeometry& rig) const {
351  MuonGeometryNumbering mdddnum(muonConstants);
352  DTNumberingScheme dtnum(muonConstants);
353  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.history()));
354  DTSuperLayerId slId(rawid);
355 
356  vector<double> par_temp = fv.parameters();
357  vector<double> par(4);
358  par[0] = DTSuperLayerTag; //DTSuperLayerTag is the ID of a SuperLayer
359  par[1] = par_temp[0] / dd4hep::mm;
360  par[2] = par_temp[1] / dd4hep::mm;
361  par[3] = par_temp[2] / dd4hep::mm;
362 
363  edm::LogVerbatim("DTGeometryParsFromDD")
364  << "(2) DD4HEP, Super Layer DetID " << rawid << " " << par[0] << " " << par[1] << " " << par[2] << " " << par[3];
365  PosRotPair posRot(plane(fv));
366  rig.insert(slId, posRot.first, posRot.second, par);
367 }
368 
370  const MuonGeometryConstants& muonConstants,
371  RecoIdealGeometry& rig) const {
372  MuonGeometryNumbering mdddnum(muonConstants);
373  DTNumberingScheme dtnum(muonConstants);
374  int rawid = dtnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.history()));
375  DTLayerId layId(rawid);
376 
377  vector<double> par_temp = fv.parameters();
378  vector<double> par(4);
379  par[0] = DTLayerTag; //DTLayerTag is the ID of a Layer
380  par[1] = par_temp[0] / dd4hep::mm;
381  par[2] = par_temp[1] / dd4hep::mm;
382  par[3] = par_temp[2] / dd4hep::mm;
383 
384  fv.down();
385  bool doWire = fv.sibling();
386  int firstWire = fv.volume()->GetNumber();
387  auto const& wpar = fv.parameters();
388  float wireLength = wpar[1] / dd4hep::mm;
389 
390  int WCounter = 0;
391  while (doWire) {
392  doWire = fv.checkChild();
393  WCounter++;
394  }
395 
396  par.emplace_back(firstWire);
397  par.emplace_back(WCounter);
398  par.emplace_back(wireLength);
399 
400  fv.up();
401 
402  PosRotPair posRot(plane(fv));
403 
404  edm::LogVerbatim("DTGeometryParsFromDD")
405  << "(3) DD4HEP, Layer DetID " << rawid << " " << par[0] << " " << par[1] << " " << par[2] << " " << par[3] << " "
406  << par[4] << " " << par[5] << " " << par[6];
407  rig.insert(layId, posRot.first, posRot.second, par);
408 }
cms::DDFilteredView::rotation
const RotationMatrix rotation() const
Definition: DDFilteredView.cc:122
cms::DDFilteredView::volume
const PlacedVolume volume() const
The physical volume of the current node.
Definition: DDFilteredView.cc:68
DTSuperLayerId
Definition: DTSuperLayerId.h:12
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
DTGeometryParsFromDD::insertLayer
void insertLayer(DDFilteredView &fv, const std::string &type, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rig) const
create the layer
Definition: DTGeometryParsFromDD.cc:173
cms::DDFilteredView::parameters
const std::vector< double > parameters() const
extract shape parameters
Definition: DDFilteredView.cc:536
MessageLogger.h
cms::DDFilteredView::sibling
bool sibling()
set the current node to the next sub sibling
Definition: DDFilteredView.cc:450
MuonGeometryNumbering::geoHistoryToBaseNumber
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history) const
Definition: MuonGeometryNumbering.cc:38
DTGeometryParsFromDD::insertChamber
void insertChamber(DDFilteredView &fv, const std::string &type, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rig) const
create the chamber
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
DDFilteredView::mergedSpecifics
DDsvalues_type mergedSpecifics() const
Definition: DDFilteredView.cc:42
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
cms::DDFilteredView::parent
bool parent()
set the current node to the parent node ...
Definition: DDFilteredView.cc:481
Basic3DVector.h
MuonGeometryNumbering.h
geant_units::operators
Definition: GeantUnits.h:18
cms::DDFilteredView
Definition: DDFilteredView.h:70
DDFilteredView::parent
bool parent()
set the current node to the parent node ...
Definition: DDFilteredView.cc:161
cms::DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling
Definition: DDFilteredView.cc:427
DTNumberingScheme::getDetId
int getDetId(const MuonBaseNumber &num) const
Definition: DTNumberingScheme.cc:75
DDBooleanSolid
Definition: DDSolid.h:173
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
DTGeometryParsFromDD::plane
PosRotPair plane(const DDFilteredView &fv) const
Definition: DTGeometryParsFromDD.cc:229
cms::DDFilteredView::trans
const Double_t * trans() const
The absolute translation of the current node.
Definition: DDFilteredView.cc:101
cms::cuda::bs
bs
Definition: HistoContainer.h:127
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDFilteredView.h
cms::DDFilter
Definition: DDFilteredView.h:59
DTGeometryParsFromDD::buildGeometry
void buildGeometry(DDFilteredView &fv, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rig) const
Definition: DTGeometryParsFromDD.cc:72
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DTGeometryParsFromDD::DTGeometryParsFromDD
DTGeometryParsFromDD()
Constructor.
Definition: DTGeometryParsFromDD.cc:37
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DTGeometryParsFromDD::~DTGeometryParsFromDD
virtual ~DTGeometryParsFromDD()
Destructor.
Definition: DTGeometryParsFromDD.cc:39
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:268
RectangularPlaneBounds.h
DDSolid.h
DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling ...
Definition: DDFilteredView.cc:124
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
DTNumberingScheme::baseNumberToUnitNumber
int baseNumberToUnitNumber(const MuonBaseNumber &num) const override
Definition: DTNumberingScheme.cc:38
cms::DDFilteredView::down
void down()
set current node to the child node in the filtered tree
Definition: DDFilteredView.cc:505
DDCompactView.h
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
DTChamberId.h
DTLayerId
Definition: DTLayerId.h:12
RecoIdealGeometry.h
DTLayer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
Definition: PGeometricDetBuilder.cc:19
DDSpecParRegistry.h
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DTGeometryParsFromDD::extractParameters
std::vector< double > extractParameters(DDFilteredView &fv) const
get parameter also for boolean solid.
Definition: DTGeometryParsFromDD.cc:213
GeantUnits.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
DTGeometryParsFromDD.h
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
MuonBaseNumber.h
cms::DDFilteredView::history
const ExpandedNodes & history()
The numbering history of the current node.
Definition: DDFilteredView.cc:683
cms::DDFilteredView::up
void up()
set current node to the parent node in the filtered tree
Definition: DDFilteredView.cc:516
DDFilter.h
value
Definition: value.py:1
DDFilteredView::geoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
Definition: DDFilteredView.cc:30
DTNumberingScheme.h
DTGeometryParsFromDD::PosRotPair
std::pair< std::vector< double >, std::vector< double > > PosRotPair
Definition: DTGeometryParsFromDD.h:68
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
DTGeometryParsFromDD::build
void build(const DDCompactView *cview, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rig)
Definition: DTGeometryParsFromDD.cc:42
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
DDSolidShape::ddbox
cms::DDFilteredView::checkChild
bool checkChild()
count the number of children matching selection
Definition: DDFilteredView.cc:466
DDValue
Definition: DDValue.h:21
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDFilteredView::translation
const DDTranslation & translation() const
The absolute translation of the current node.
Definition: DDFilteredView.cc:26
cms::DDCompactView
Definition: DDCompactView.h:31
DDSolid::parameters
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:121
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDSpecificsMatchesValueFilter
Definition: DDFilter.h:70
DDFilteredView::rotation
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Definition: DDFilteredView.cc:28
MuonGeometryNumbering
Definition: MuonGeometryNumbering.h:24
DDFilteredView
Definition: DDFilteredView.h:20
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:62
DTChamber.h
DTGeometryParsFromDD::insertSuperLayer
void insertSuperLayer(DDFilteredView &fv, const std::string &type, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rig) const
create the SL
Definition: DTGeometryParsFromDD.cc:151
geant_units
Definition: GeantUnits.h:11
DTChamberId
Definition: DTChamberId.h:14
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
A
RecoIdealGeometry::insert
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars)
Definition: RecoIdealGeometry.h:33
DDLogicalPart::solid
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Definition: DDLogicalPart.cc:120
DDFilteredView::copyno
int copyno() const
Copy number associated with the current node.
Definition: DDFilteredView.cc:48
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28
DTNumberingScheme
Definition: DTNumberingScheme.h:20
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443