CMS 3D CMS Logo

ME0GeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
10 
14 
18 
21 
23 
24 #include "CLHEP/Units/GlobalSystemOfUnits.h"
26 
27 #include <algorithm>
28 #include <iostream>
29 #include <string>
30 
32 {
33  LogDebug("ME0GeometryBuilderfromDDD") <<"[ME0GeometryBuilderFromDDD::constructor]";
34 }
35 
37 { }
38 
40 {
41  std::string attribute = "ReadOutName";
42  std::string value = "MuonME0Hits";
43 
44  // Asking only for the MuonME0's
45  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
46  DDFilteredView fview(*cview,filter);
47 
48  return this->buildGeometry(fview, muonConstants);
49 }
50 
52 {
53  LogDebug("ME0GeometryBuilderFromDDD") <<"Building the geometry service";
55 
56  LogDebug("ME0GeometryBuilderFromDDD") << "About to run through the ME0 structure\n"
57  <<" First logical part "
58  <<fview.logicalPart().name().name();
59 
60  bool doSubDets = fview.firstChild();
61 
62  LogDebug("ME0GeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
63 
64  LogDebug("ME0GeometryBuilderFromDDD") <<"start the loop";
65 
66  int nChambers(0);
67  while (doSubDets)
68  {
69  // Get the Base Muon Number
70  MuonDDDNumbering mdddnum(muonConstants);
71  LogDebug("ME0GeometryBuilderFromDDD") <<"Getting the Muon base Number";
72  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
73 
74  LogDebug("ME0GeometryBuilderFromDDD") <<"Start the ME0 Numbering Schema";
75  ME0NumberingScheme me0num(muonConstants);
76 
77  ME0DetId rollDetId(me0num.baseNumberToUnitNumber(mbn));
78  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 eta partition rawId: " << rollDetId.rawId() << ", detId: " << rollDetId;
79 
80  // chamber id for this partition. everything is the same; but partition number is 0 and layer number is 0.
81  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 chamber rawId: " << ME0DetId(rollDetId.chamberId()).rawId() << ", detId: " << ME0DetId(rollDetId.chamberId());
82 
83  if (rollDetId.roll()==1) ++nChambers;
84 
85  std::vector<double> dpar=fview.logicalPart().solid().parameters();
86  std::string name = fview.logicalPart().name().name();
87  DDTranslation tran = fview.translation();
88  DDRotationMatrix rota = fview.rotation();
89  Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
90 
91  DD3Vector x, y, z;
92  rota.GetComponents(x,y,z);
93 
94  Surface::RotationType rot(float(x.X()), float(x.Y()), float(x.Z()),
95  float(y.X()), float(y.Y()), float(y.Z()),
96  float(z.X()), float(z.Y()), float(z.Z()));
97 
98  float be = dpar[4]/cm; // half bottom edge
99  float te = dpar[8]/cm; // half top edge
100  float ap = dpar[0]/cm; // half apothem
101  float ti = 0.4/cm; // half thickness
102 
103  // TrapezoidalPlaneBounds*
104  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
105 
106  std::vector<float> pars;
107  pars.emplace_back(be);
108  pars.emplace_back(te);
109  pars.emplace_back(ap);
110  float nStrips = -999.;
111  float nPads = -999.;
112  pars.emplace_back(nStrips);
113  pars.emplace_back(nPads);
114 
115  LogDebug("ME0GeometryBuilderFromDDD")
116  << "ME0 " << name << " par " << be << " " << te << " " << ap << " " << dpar[0];
117 
119 
120  //Change of axes for the forward
121  Basic3DVector<float> newX(1.,0.,0.);
122  Basic3DVector<float> newY(0.,0.,1.);
123  newY *= -1;
124  Basic3DVector<float> newZ(0.,1.,0.);
125  rot.rotateAxes (newX, newY, newZ);
126 
127  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
129 
130  // Set EtaPartition of RollDetId equal to 1
131  ME0DetId rollDetId2(rollDetId.region(),rollDetId.layer(),rollDetId.station(),1);
132  ME0EtaPartition* mep = new ME0EtaPartition(rollDetId2, surf, e_p_specs);
133 
134  // For Nick ... build also the layer
135  ME0DetId layerDetId(rollDetId.layerId());
136  ME0Layer* ml = new ME0Layer(layerDetId, surf);
137 
138  // Add the eta partition to the geometry
139  geometry->add(mep);
140  // Add the eta partition to the layer
141  ml->add(mep);
142  // Add the layer to the geometry
143  geometry->add(ml);
144 
145  // go to next layer
146  doSubDets = fview.nextSibling();
147  }
148 
149  auto& partitions(geometry->etaPartitions());
150  // build the chambers and add them to the geometry
151  std::vector<ME0DetId> vDetId;
152  int oldLayerNumber = 1;
153  for (unsigned i=1; i<=partitions.size(); ++i){
154  ME0DetId detId(partitions.at(i-1)->id());
155  LogDebug("ME0GeometryBuilderFromDDD") << "Making ME0DetId = " <<detId;
156 
157  const int layerNumber(detId.layer());
158  if (layerNumber < oldLayerNumber || i == partitions.size()) {
159 
160  // don't forget the last partition for the last chamber
161  if (i == partitions.size()) vDetId.emplace_back(detId);
162 
163  ME0DetId fId(vDetId.front());
164  ME0DetId chamberId(fId.chamberId());
165  LogDebug("ME0GeometryBuilderFromDDD") << "ME0DetId = " << fId ;
166  LogDebug("ME0GeometryBuilderFromDDD") << "ME0ChamberId = " << chamberId ;
167  // compute the overall boundplane using the first eta partition
168  const ME0EtaPartition* p(geometry->etaPartition(fId));
169  const BoundPlane& bps = p->surface();
170  BoundPlane* bp = const_cast<BoundPlane*>(&bps);
172 
173  ME0Chamber* ch = new ME0Chamber(chamberId, surf);
174  LogDebug("ME0GeometryBuilderFromDDD") << "Creating chamber " << chamberId << " with " << vDetId.size() << " eta partitions";
175 
176  for(auto id : vDetId){
177  LogDebug("ME0GeometryBuilderFromDDD") << "Adding eta partition " << id << " to ME0 chamber";
178  ch->add(const_cast<ME0EtaPartition*>(geometry->etaPartition(id)));
179  }
180 
181  LogDebug("ME0GeometryBuilderFromDDD") << "Adding the chamber to the geometry";
182  geometry->add(ch);
183  vDetId.clear();
184  }
185  vDetId.emplace_back(detId);
186  oldLayerNumber = layerNumber;
187  }
188 
189  return geometry;
190 }
#define LogDebug(id)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
ME0Geometry * build(const DDCompactView *cview, const MuonDDDConstants &muonConstants)
const N & name() const
Definition: DDBase.h:78
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
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
Definition: ME0Geometry.cc:64
type of data representation of DDCompactView
Definition: DDCompactView.h:90
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
void add(ME0Layer *layer)
Add Layer to the chamber which takes ownership.
Definition: ME0Chamber.cc:22
TkRotation & rotateAxes(const Basic3DVector< T > &newX, const Basic3DVector< T > &newY, const Basic3DVector< T > &newZ)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
int baseNumberToUnitNumber(const MuonBaseNumber &) override
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
ME0Geometry * buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants)
Definition: value.py:1
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:59
void add(ME0EtaPartition *etaPartition)
Add a ME0 etaPartition to the Geometry.
Definition: ME0Geometry.cc:79
ESHandle< TrackerGeometry > geometry
bool firstChild()
set the current node to the first child ...
Definition: Bounds.h:22
const DDTranslation & translation() const
The absolute translation of the current node.
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:90