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