CMS 3D CMS Logo

ME0GeometryBuilderFromDDD.cc
Go to the documentation of this file.
1 
11 
15 
19 
22 
24 
25 #include "CLHEP/Units/GlobalSystemOfUnits.h"
27 
28 #include <iostream>
29 #include <algorithm>
30 #include <boost/lexical_cast.hpp>
31 
33 {
34  LogDebug("ME0GeometryBuilderfromDDD") <<"[ME0GeometryBuilderFromDDD::constructor]";
35 }
36 
38 { }
39 
41 {
42  std::string attribute = "ReadOutName";
43  std::string value = "MuonME0Hits";
44 
45  // Asking only for the MuonME0's
46  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
47  DDFilteredView fview(*cview,filter);
48 
49  return this->buildGeometry(fview, muonConstants);
50 }
51 
53 {
54  LogDebug("ME0GeometryBuilderFromDDD") <<"Building the geometry service";
56 
57  LogDebug("ME0GeometryBuilderFromDDD") << "About to run through the ME0 structure\n"
58  <<" First logical part "
59  <<fview.logicalPart().name().name();
60 
61 
62  bool doSubDets = fview.firstChild();
63 
64  LogDebug("ME0GeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
65 
66  LogDebug("ME0GeometryBuilderFromDDD") <<"start the loop";
67 
68  int nChambers(0);
69  while (doSubDets)
70  {
71  // Get the Base Muon Number
72  MuonDDDNumbering mdddnum(muonConstants);
73  LogDebug("ME0GeometryBuilderFromDDD") <<"Getting the Muon base Number";
74  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
75 
76  LogDebug("ME0GeometryBuilderFromDDD") <<"Start the ME0 Numbering Schema";
77  ME0NumberingScheme me0num(muonConstants);
78 
79  ME0DetId rollDetId(me0num.baseNumberToUnitNumber(mbn));
80  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 eta partition rawId: " << rollDetId.rawId() << ", detId: " << rollDetId;
81 
82  // chamber id for this partition. everything is the same; but partition number is 0 and layer number is 0.
83  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 chamber rawId: " << ME0DetId(rollDetId.chamberId()).rawId() << ", detId: " << ME0DetId(rollDetId.chamberId());
84 
85  //Commented out, we don't have stations
86  //const int stationId(rollDetId.station());
87  //if (stationId > maxStation) maxStation = stationId;
88 
89  if (rollDetId.roll()==1) ++nChambers;
90 
91 
92  std::vector<double> dpar=fview.logicalPart().solid().parameters();
93  std::string name = fview.logicalPart().name().name();
94  DDTranslation tran = fview.translation();
95  DDRotationMatrix rota = fview.rotation();
96  Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
97  // CLHEP way
98  // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
99  // rota.yx(),rota.yy(),rota.yz(),
100  // rota.zx(),rota.zy(),rota.zz());
101 
102  //ROOT::Math way
103  DD3Vector x, y, z;
104  rota.GetComponents(x,y,z);
105  // doesn't this just re-inverse???
106  Surface::RotationType rot(float(x.X()), float(x.Y()), float(x.Z()),
107  float(y.X()), float(y.Y()), float(y.Z()),
108  float(z.X()), float(z.Y()), float(z.Z()));
109 
110  float be = dpar[4]/cm; // half bottom edge
111  float te = dpar[8]/cm; // half top edge
112  float ap = dpar[0]/cm; // half apothem
113  float ti = 0.4/cm; // half thickness
114 
115  // TrapezoidalPlaneBounds*
116  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
117 
118  std::vector<float> pars;
119  pars.emplace_back(be);
120  pars.emplace_back(te);
121  pars.emplace_back(ap);
122  float nStrips = -999.;
123  float nPads = -999.;
124  pars.emplace_back(nStrips);
125  pars.emplace_back(nPads);
126 
127  LogDebug("ME0GeometryBuilderFromDDD")
128  << "ME0 " << name << " par " << be << " " << te << " " << ap << " " << dpar[0];
129 
131 
132  //Change of axes for the forward
133  Basic3DVector<float> newX(1.,0.,0.);
134  Basic3DVector<float> newY(0.,0.,1.);
135  // if (tran.z() > 0. )
136  newY *= -1;
137  Basic3DVector<float> newZ(0.,1.,0.);
138  rot.rotateAxes (newX, newY, newZ);
139 
140  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
142 
143  // Set EtaPartition of RollDetId equal to 1
144  ME0DetId rollDetId2(rollDetId.region(),rollDetId.layer(),rollDetId.station(),1);
145  ME0EtaPartition* mep = new ME0EtaPartition(rollDetId2, surf, e_p_specs);
146 
147  // For Nick ... build also the layer
148  ME0DetId layerDetId(rollDetId.layerId());
149  ME0Layer* ml = new ME0Layer(layerDetId, surf);
150 
151  // Add the eta partition to the geometry
152  geometry->add(mep);
153  // Add the eta partition to the layer
154  ml->add(mep);
155  // Add the layer to the geometry
156  geometry->add(ml);
157 
158  // go to next layer
159  doSubDets = fview.nextSibling();
160 
161 
162  }
163 
164 
165  auto& partitions(geometry->etaPartitions());
166  // build the chambers and add them to the geometry
167  std::vector<ME0DetId> vDetId;
168  //int oldRollNumber = 1;
169  int oldLayerNumber = 1;
170  for (unsigned i=1; i<=partitions.size(); ++i){
171  ME0DetId detId(partitions.at(i-1)->id());
172  LogDebug("ME0GeometryBuilderFromDDD") << "Making ME0DetId = " <<detId;
173 
174  //The GEM methodology depended on rollNumber changing from chamber to chamber, we need to use layer ID
175  //const int rollNumber(detId.roll());
176  // new batch of eta partitions --> new chamber
177  //if (rollNumber < oldRollNumber || i == partitions.size()) {
178 
179  const int layerNumber(detId.layer());
180  if (layerNumber < oldLayerNumber || i == partitions.size()) {
181 
182  // don't forget the last partition for the last chamber
183  if (i == partitions.size()) vDetId.emplace_back(detId);
184 
185  ME0DetId fId(vDetId.front());
186  ME0DetId chamberId(fId.chamberId());
187  LogDebug("ME0GeometryBuilderFromDDD") << "ME0DetId = " << fId ;
188  LogDebug("ME0GeometryBuilderFromDDD") << "ME0ChamberId = " << chamberId ;
189  // compute the overall boundplane using the first eta partition
190  const ME0EtaPartition* p(geometry->etaPartition(fId));
191  const BoundPlane& bps = p->surface();
192  BoundPlane* bp = const_cast<BoundPlane*>(&bps);
194 
195  ME0Chamber* ch = new ME0Chamber(chamberId, surf);
196  LogDebug("ME0GeometryBuilderFromDDD") << "Creating chamber " << chamberId << " with " << vDetId.size() << " eta partitions";
197 
198  for(auto id : vDetId){
199  LogDebug("ME0GeometryBuilderFromDDD") << "Adding eta partition " << id << " to ME0 chamber";
200  ch->add(const_cast<ME0EtaPartition*>(geometry->etaPartition(id)));
201  }
202 
203  LogDebug("ME0GeometryBuilderFromDDD") << "Adding the chamber to the geometry";
204  geometry->add(ch);
205  vDetId.clear();
206  }
207  vDetId.emplace_back(detId);
208  oldLayerNumber = layerNumber;
209  }
210 
211 
212  return geometry;
213 }
#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