CMS 3D CMS Logo

GEMGeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
8 
12 
16 
19 
20 #include "CLHEP/Units/GlobalSystemOfUnits.h"
21 
22 #include <algorithm>
23 #include <iostream>
24 #include <string>
25 
27 { }
28 
30 { }
31 
32 void
34  const DDCompactView* cview,
35  const MuonDDDConstants& muonConstants )
36 {
37  std::string attribute = "MuStructure";
38  std::string value = "MuonEndCapGEM";
39 
40  // Asking only for the MuonGEM's
41  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
42  DDFilteredView fv(*cview,filter);
43 
44  LogDebug("GEMGeometryBuilderFromDDD") << "Building the geometry service";
45  LogDebug("GEMGeometryBuilderFromDDD") << "About to run through the GEM structure\n"
46  << " First logical part "
47  << fv.logicalPart().name().name();
48 
49  bool doSuper = fv.firstChild();
50  LogDebug("GEMGeometryBuilderFromDDD") << "doSuperChamber = " << doSuper;
51  // loop over superchambers
52  std::vector<GEMSuperChamber*> superChambers;
53  while (doSuper){
54 
55  // getting chamber id from eta partitions
56  fv.firstChild();fv.firstChild();
57  MuonDDDNumbering mdddnumCh(muonConstants);
58  GEMNumberingScheme gemNumCh(muonConstants);
59  int rawidCh = gemNumCh.baseNumberToUnitNumber(mdddnumCh.geoHistoryToBaseNumber(fv.geoHistory()));
60  GEMDetId detIdCh = GEMDetId(rawidCh);
61  // back to chambers
62  fv.parent();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  GEMSuperChamber *gemSuperChamber = buildSuperChamber(fv, detIdCh);
69  superChambers.push_back(gemSuperChamber);
70  }
71  GEMChamber *gemChamber = buildChamber(fv, detIdCh);
72 
73  // loop over chambers
74  // only 1 chamber
75  bool doChambers = fv.firstChild();
76  bool loopExecuted = false;
77  while (doChambers){
78  loopExecuted = true;
79 
80  // loop over GEMEtaPartitions
81  bool doEtaPart = fv.firstChild();
82  while (doEtaPart){
83 
84  MuonDDDNumbering mdddnum(muonConstants);
85  GEMNumberingScheme gemNum(muonConstants);
86  int rawid = gemNum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
87  GEMDetId detId = GEMDetId(rawid);
88 
89  GEMEtaPartition *etaPart = buildEtaPartition(fv, detId);
90  gemChamber->add(etaPart);
91  theGeometry.add(etaPart);
92  doEtaPart = fv.nextSibling();
93  }
94  fv.parent();
95 
96  theGeometry.add(gemChamber);
97 
98  doChambers = fv.nextSibling();
99  }
100  fv.parent();
101 
102  doSuper = fv.nextSibling();
103  if (!loopExecuted) delete gemChamber;
104  }
105 
106  // construct the regions, stations and rings.
107  for (int re = -1; re <= 1; re = re+2) {
108  GEMRegion* region = new GEMRegion(re);
109  for (int st=1; st<=GEMDetId::maxStationId; ++st) {
110  GEMStation* station = new GEMStation(re, st);
111  std::string sign( re==-1 ? "-" : "");
112  std::string name("GE" + sign + std::to_string(st) + "/1");
113  station->setName(name);
114  for (int ri=1; ri<=1; ++ri) {
115  GEMRing* ring = new GEMRing(re, st, ri);
116  for (auto superChamber : superChambers){
117  const GEMDetId detId(superChamber->id());
118  if (detId.region() != re || detId.station() != st || detId.ring() != ri) continue;
119 
120  superChamber->add( theGeometry.chamber(GEMDetId(detId.region(),detId.ring(),detId.station(),1,detId.chamber(),0)));
121  superChamber->add( theGeometry.chamber(GEMDetId(detId.region(),detId.ring(),detId.station(),2,detId.chamber(),0)));
122 
123  ring->add(superChamber);
124  theGeometry.add(superChamber);
125  LogDebug("GEMGeometryBuilderFromDDD") << "Adding super chamber " << detId << " to ring: "
126  << "re " << re << " st " << st << " ri " << ri << std::endl;
127  }
128  LogDebug("GEMGeometryBuilderFromDDD") << "Adding ring " << ri << " to station " << "re " << re << " st " << st << std::endl;
129  station->add(ring);
130  theGeometry.add(ring);
131  }
132  LogDebug("GEMGeometryBuilderFromDDD") << "Adding station " << st << " to region " << re << std::endl;
133  region->add(station);
134  theGeometry.add(station);
135  }
136  LogDebug("GEMGeometryBuilderFromDDD") << "Adding region " << re << " to the geometry " << std::endl;
137  theGeometry.add(region);
138  }
139 }
140 
143  GEMDetId detId ) const
144 {
145  LogDebug("GEMGeometryBuilderFromDDD") << "buildSuperChamber "
146  << fv.logicalPart().name().name()
147  << " " << detId << std::endl;
148 
150  std::vector<double> dpar = solid.solidA().parameters();
151 
152  double dy = dpar[0]/cm;//length is along local Y
153  double dz = dpar[3]/cm;// thickness is long local Z
154  double dx1= dpar[4]/cm;// bottom width is along local X
155  double dx2= dpar[8]/cm;// top width is along local X
156  dpar = solid.solidB().parameters();
157  dz += dpar[3]/cm;// chamber thickness
158  dz *=2; // 2 chambers in superchamber
159  dz += 2.105;// gap between chambers
160 
161  bool isOdd = detId.chamber()%2;
162  RCPBoundPlane surf( boundPlane( fv, new TrapezoidalPlaneBounds( dx1, dx2, dy, dz), isOdd ));
163 
164  LogDebug("GEMGeometryBuilderFromDDD") << "size "<< dx1 << " " << dx2 << " " << dy << " " << dz <<std::endl;
165 
166  GEMSuperChamber* superChamber = new GEMSuperChamber(detId.superChamberId(), surf);
167  return superChamber;
168 }
169 
170 GEMChamber*
172  GEMDetId detId ) const
173 {
174  LogDebug("GEMGeometryBuilderFromDDD") << "buildChamber "
175  << fv.logicalPart().name().name()
176  << " " << detId << std::endl;
177 
179  std::vector<double> dpar = solid.solidA().parameters();
180 
181  double dy = dpar[0]/cm;//length is along local Y
182  double dz = dpar[3]/cm;// thickness is long local Z
183  double dx1= dpar[4]/cm;// bottom width is along local X
184  double dx2= dpar[8]/cm;// top width is along local X
185  dpar = solid.solidB().parameters();
186  dz += dpar[3]/cm;// chamber thickness
187 
188  bool isOdd = detId.chamber()%2;
189  RCPBoundPlane surf(boundPlane(fv, new TrapezoidalPlaneBounds(dx1,dx2,dy,dz), isOdd ));
190 
191  LogDebug("GEMGeometryBuilderFromDDD") << "size "<< dx1 << " " << dx2 << " " << dy << " " << dz << std::endl;
192 
193  GEMChamber* chamber = new GEMChamber(detId.chamberId(), surf);
194  return chamber;
195 }
196 
199  GEMDetId detId ) const
200 {
201  LogDebug("GEMGeometryBuilderFromDDD") << "buildEtaPartition "
202  << fv.logicalPart().name().name()
203  << " " << detId << std::endl;
204 
205  // EtaPartition specific parameter (nstrips and npads)
206  DDValue numbOfStrips("nStrips");
207  DDValue numbOfPads("nPads");
208  std::vector<const DDsvalues_type* > specs(fv.specifics());
209  std::vector<const DDsvalues_type* >::iterator is = specs.begin();
210  double nStrips = 0., nPads = 0.;
211  for (;is != specs.end(); is++){
212  if (DDfetch( *is, numbOfStrips)) nStrips = numbOfStrips.doubles()[0];
213  if (DDfetch( *is, numbOfPads)) nPads = numbOfPads.doubles()[0];
214  }
215  LogDebug("GEMGeometryBuilderFromDDD")
216  << ((nStrips == 0. ) ? ("No nStrips found!!") : ("Number of strips: " + std::to_string(nStrips)));
217  LogDebug("GEMGeometryBuilderFromDDD")
218  << ((nPads == 0. ) ? ("No nPads found!!") : ("Number of pads: " + std::to_string(nPads)));
219 
220  // EtaPartition specific parameter (size)
221  std::vector<double> dpar = fv.logicalPart().solid().parameters();
222 
223  double be = dpar[4]/cm; // half bottom edge
224  double te = dpar[8]/cm; // half top edge
225  double ap = dpar[0]/cm; // half apothem
226  double ti = 0.4/cm; // half thickness
227 
228  std::vector<float> pars;
229  pars.emplace_back(be);
230  pars.emplace_back(te);
231  pars.emplace_back(ap);
232  pars.emplace_back(nStrips);
233  pars.emplace_back(nPads);
234 
235  bool isOdd = detId.chamber()%2;
236  RCPBoundPlane surf(boundPlane(fv, new TrapezoidalPlaneBounds(be, te, ap, ti), isOdd ));
237  std::string name = fv.logicalPart().name().name();
239 
240  LogDebug("GEMGeometryBuilderFromDDD") << "size "<< be << " " << te << " " << ap << " " << ti <<std::endl;
241  GEMEtaPartition* etaPartition = new GEMEtaPartition(detId, surf, e_p_specs);
242  return etaPartition;
243 }
244 
247  Bounds* bounds, bool isOddChamber) const {
248  // extract the position
249  const DDTranslation & trans(fv.translation());
250  const Surface::PositionType posResult(float(trans.x()/cm),
251  float(trans.y()/cm),
252  float(trans.z()/cm));
253 
254  // now the rotation
255  const DDRotationMatrix& rotation = fv.rotation();
256  DD3Vector x, y, z;
257  rotation.GetComponents(x,y,z);
258 
259  Surface::RotationType rotResult(float(x.X()),float(x.Y()),float(x.Z()),
260  float(y.X()),float(y.Y()),float(y.Z()),
261  float(z.X()),float(z.Y()),float(z.Z()));
262 
263  //Change of axes for the forward
264  Basic3DVector<float> newX(1.,0.,0.);
265  Basic3DVector<float> newY(0.,0.,1.);
266  Basic3DVector<float> newZ(0.,1.,0.);
267 
268  // Odd chambers are inverted in gem.xml
269  if (isOddChamber) newY *= -1;
270 
271  rotResult.rotateAxes(newX, newY, newZ);
272 
273  return RCPBoundPlane( new BoundPlane( posResult, rotResult, bounds));
274 }
#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:74
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Plane BoundPlane
Definition: Plane.h:95
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
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
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:81
void add(GEMRing *ring)
Add ring to the station which takes ownership.
Definition: GEMStation.cc:28
void add(GEMSuperChamber *ch)
Add super chamber to the ring which takes ownership.
Definition: GEMRing.cc:22
ReferenceCountingPointer< BoundPlane > RCPBoundPlane
TkRotation & rotateAxes(const Basic3DVector< T > &newX, const Basic3DVector< T > &newY, const Basic3DVector< T > &newZ)
DDSolid solidB(void) const
Definition: DDSolid.cc:616
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
GEMDetId chamberId() const
Return the corresponding ChamberId.
Definition: GEMDetId.h:85
GEMSuperChamber * buildSuperChamber(DDFilteredView &fv, GEMDetId detId) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
void build(GEMGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
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
RCPBoundPlane boundPlane(const DDFilteredView &fv, Bounds *bounds, bool isOddChamber) const
void add(GEMEtaPartition *roll)
Add EtaPartition to the chamber which takes ownership.
Definition: GEMChamber.cc:27
static const int maxStationId
Definition: GEMDetId.h:101
void setName(std::string name)
Set the station name.
Definition: GEMStation.cc:77
Definition: value.py:1
DDSolid solidA(void) const
Definition: DDSolid.cc:610
GEMChamber * buildChamber(DDFilteredView &fv, GEMDetId detId) const
GEMEtaPartition * buildEtaPartition(DDFilteredView &fv, GEMDetId detId) const
const GEMChamber * chamber(GEMDetId id) const
Definition: GEMGeometry.cc:95
bool firstChild()
set the current node to the first child ...
void add(GEMStation *st)
Add station to the region which takes ownership.
Definition: GEMRegion.cc:25
Definition: Bounds.h:22
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:53
void add(const GEMRegion *region)
Add a GEMRegion to the Geometry.
Definition: GEMGeometry.cc:104