CMS 3D CMS Logo

GEMGeometryParsFromDD.cc
Go to the documentation of this file.
1 
7 
12 
16 
18 
19 #include "CLHEP/Units/GlobalSystemOfUnits.h"
20 
21 #include <iostream>
22 #include <algorithm>
23 
25 
27 
29  const MuonDDDConstants& muonConstants,
30  RecoIdealGeometry& rgeo) {
31  std::string attribute = "MuStructure";
32  std::string value = "MuonEndCapGEM";
33 
34  // Asking only for the MuonGEM's
35  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
36  DDFilteredView fv(*cview, filter);
37 
38  this->buildGeometry(fv, muonConstants, rgeo);
39 }
40 
42  const MuonDDDConstants& muonConstants,
43  RecoIdealGeometry& rgeo) {
44  LogDebug("GEMGeometryParsFromDD") << "Building the geometry service";
45  LogDebug("GEMGeometryParsFromDD") << "About to run through the GEM structure\n"
46  << " First logical part " << fv.logicalPart().name().name();
47 
48  MuonDDDNumbering muonDDDNumbering(muonConstants);
49  GEMNumberingScheme gemNumbering(muonConstants);
50 
51  bool doSuper = fv.firstChild();
52  LogDebug("GEMGeometryParsFromDD") << "doSuperChamber = " << doSuper;
53  // loop over superchambers
54  while (doSuper) {
55  // getting chamber id from eta partitions
56  fv.firstChild();
57  fv.firstChild();
58  GEMDetId detIdCh =
59  GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory())));
60  // back to chambers
61  fv.parent();
62  fv.parent();
63 
64  // currently there is no superchamber in the geometry
65  // only 2 chambers are present separated by a gap.
66  // making superchamber out of the first chamber layer including the gap between chambers
67  if (detIdCh.layer() == 1) { // only make superChambers when doing layer 1
68  buildSuperChamber(fv, detIdCh, rgeo);
69  }
70  buildChamber(fv, detIdCh, rgeo);
71 
72  // loop over chambers
73  // only 1 chamber
74  bool doChambers = fv.firstChild();
75  while (doChambers) {
76  // loop over GEMEtaPartitions
77  bool doEtaPart = fv.firstChild();
78  while (doEtaPart) {
79  GEMDetId detId =
80  GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory())));
81  buildEtaPartition(fv, detId, rgeo);
82 
83  doEtaPart = fv.nextSibling();
84  }
85  fv.parent();
86  doChambers = fv.nextSibling();
87  }
88  fv.parent();
89  doSuper = fv.nextSibling();
90  }
91 }
92 
94  LogDebug("GEMGeometryParsFromDD") << "buildSuperChamber " << fv.logicalPart().name().name() << " " << detId
95  << std::endl;
96 
98  std::vector<double> dpar = solid.solidA().parameters();
99 
100  double dy = dpar[0]; //length is along local Y
101  double dz = dpar[3]; // thickness is long local Z
102  double dx1 = dpar[4]; // bottom width is along local X
103  double dx2 = dpar[8]; // top width is along local X
104  dpar = solid.solidB().parameters();
105  dz += dpar[3]; // chamber thickness
106  dz *= 2; // 2 chambers in superchamber
107  dz += 2.105; // gap between chambers
108 
109  GEMDetId gemid = detId.superChamberId();
110 
111  std::vector<double> pars{dx1, dx2, dy, dz};
112  std::vector<double> vtra = getTranslation(fv);
113  std::vector<double> vrot = getRotation(fv);
114 
115  LogDebug("GEMGeometryParsFromDD") << "dimension dx1 " << dx1 << ", dx2 " << dx2 << ", dy " << dy << ", dz " << dz;
116  rgeo.insert(gemid.rawId(), vtra, vrot, pars, {fv.logicalPart().name().name()});
117 }
118 
120  LogDebug("GEMGeometryParsFromDD") << "buildChamber " << fv.logicalPart().name().name() << " " << detId << std::endl;
121 
123  std::vector<double> dpar = solid.solidA().parameters();
124 
125  double dy = dpar[0]; //length is along local Y
126  double dz = dpar[3]; // thickness is long local Z
127  double dx1 = dpar[4]; // bottom width is along local X
128  double dx2 = dpar[8]; // top width is along local X
129  dpar = solid.solidB().parameters();
130  dz += dpar[3]; // chamber thickness
131 
132  GEMDetId gemid = detId.chamberId();
133 
134  std::vector<double> pars{dx1, dx2, dy, dz};
135  std::vector<double> vtra = getTranslation(fv);
136  std::vector<double> vrot = getRotation(fv);
137 
138  LogDebug("GEMGeometryParsFromDD") << "dimension dx1 " << dx1 << ", dx2 " << dx2 << ", dy " << dy << ", dz " << dz;
139  rgeo.insert(gemid.rawId(), vtra, vrot, pars, {fv.logicalPart().name().name()});
140 }
141 
143  LogDebug("GEMGeometryParsFromDD") << "buildEtaPartition " << fv.logicalPart().name().name() << " " << detId
144  << std::endl;
145 
146  // EtaPartition specific parameter (nstrips and npads)
147  DDValue numbOfStrips("nStrips");
148  DDValue numbOfPads("nPads");
149  const std::vector<const DDsvalues_type*>& specs = fv.specifics();
150  double nStrips = 0., nPads = 0.;
151  for (auto const& is : specs) {
152  if (DDfetch(is, numbOfStrips))
153  nStrips = numbOfStrips.doubles()[0];
154  if (DDfetch(is, numbOfPads))
155  nPads = numbOfPads.doubles()[0];
156  }
157  LogDebug("GEMGeometryParsFromDD") << ((nStrips == 0.) ? ("No nStrips found!!")
158  : ("Number of strips: " + std::to_string(nStrips)));
159  LogDebug("GEMGeometryParsFromDD") << ((nPads == 0.) ? ("No nPads found!!")
160  : ("Number of pads: " + std::to_string(nPads)));
161 
162  // EtaPartition specific parameter (size)
163  std::vector<double> dpar = fv.logicalPart().solid().parameters();
164 
165  double dy = dpar[0]; //length is along local Y
166  double dz = dpar[3]; //0.4;// thickness is long local Z
167  double dx1 = dpar[4]; // bottom width is along local X
168  double dx2 = dpar[8]; // top width is along local X
169 
170  std::vector<double> pars{dx1, dx2, dy, dz, nStrips, nPads};
171  std::vector<double> vtra = getTranslation(fv);
172  std::vector<double> vrot = getRotation(fv);
173 
174  LogDebug("GEMGeometryParsFromDD") << "dimension dx1 " << dx1 << ", dx2 " << dx2 << ", dy " << dy << ", dz " << dz;
175  rgeo.insert(detId.rawId(), vtra, vrot, pars, {fv.logicalPart().name().name()});
176 }
177 
179  const DDTranslation& tran = fv.translation();
180  return {tran.x(), tran.y(), tran.z()};
181 }
182 
184  const DDRotationMatrix& rota = fv.rotation(); //.Inverse();
185  DD3Vector x, y, z;
186  rota.GetComponents(x, y, z);
187  return {x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z()};
188 }
#define LogDebug(id)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:121
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.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:111
const N & name() const
Definition: DDBase.h:59
void build(const DDCompactView *cview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rgeo)
void buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rgeo)
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)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
GEMDetId superChamberId() const
Definition: GEMDetId.h:196
void buildEtaPartition(DDFilteredView &fv, GEMDetId detId, RecoIdealGeometry &rgeo)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
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:79
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
DDSolid solidB(void) const
Definition: DDSolid.cc:468
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
GEMDetId chamberId() const
Definition: GEMDetId.h:193
std::vector< double > getRotation(DDFilteredView &fv)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
int layer() const
Definition: GEMDetId.h:184
void buildChamber(DDFilteredView &fv, GEMDetId detId, RecoIdealGeometry &rgeo)
Definition: value.py:1
DDSolid solidA(void) const
Definition: DDSolid.cc:466
std::vector< double > getTranslation(DDFilteredView &fv)
void buildSuperChamber(DDFilteredView &fv, GEMDetId detId, RecoIdealGeometry &rgeo)
bool firstChild()
set the current node to the first child ...
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< const DDsvalues_type * > specifics() const
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
int baseNumberToUnitNumber(const MuonBaseNumber &) override
const std::string & name() const
Returns the name.
Definition: DDName.cc:40