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  ME0DetId chamberId(rollDetId.chamberId());
84  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 chamber rawId: " << chamberId.rawId() << ", detId: " << chamberId;
85 
86  //Commented out, we don't have stations
87  //const int stationId(rollDetId.station());
88  //if (stationId > maxStation) maxStation = stationId;
89 
90  if (rollDetId.roll()==1) ++nChambers;
91 
92 
93  std::vector<double> dpar=fview.logicalPart().solid().parameters();
94  std::string name = fview.logicalPart().name().name();
95  DDTranslation tran = fview.translation();
96  DDRotationMatrix rota = fview.rotation();
97  Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
98  // CLHEP way
99  // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
100  // rota.yx(),rota.yy(),rota.yz(),
101  // rota.zx(),rota.zy(),rota.zz());
102 
103  //ROOT::Math way
104  DD3Vector x, y, z;
105  rota.GetComponents(x,y,z);
106  // doesn't this just re-inverse???
107  Surface::RotationType rot(float(x.X()), float(x.Y()), float(x.Z()),
108  float(y.X()), float(y.Y()), float(y.Z()),
109  float(z.X()), float(z.Y()), float(z.Z()));
110 
111  float be = dpar[4]/cm; // half bottom edge
112  float te = dpar[8]/cm; // half top edge
113  float ap = dpar[0]/cm; // half apothem
114  float ti = 0.4/cm; // half thickness
115 
116  // TrapezoidalPlaneBounds*
117  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
118 
119  std::vector<float> pars;
120  pars.push_back(be);
121  pars.push_back(te);
122  pars.push_back(ap);
123  float nStrips = -999.;
124  float nPads = -999.;
125  pars.push_back(nStrips);
126  pars.push_back(nPads);
127 
128  LogDebug("ME0GeometryBuilderFromDDD")
129  << "ME0 " << name << " par " << be << " " << te << " " << ap << " " << dpar[0];
130 
132 
133  //Change of axes for the forward
134  Basic3DVector<float> newX(1.,0.,0.);
135  Basic3DVector<float> newY(0.,0.,1.);
136  // if (tran.z() > 0. )
137  newY *= -1;
138  Basic3DVector<float> newZ(0.,1.,0.);
139  rot.rotateAxes (newX, newY, newZ);
140 
141  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
143 
144  // Set EtaPartition of RollDetId equal to 1
145  ME0DetId rollDetId2(rollDetId.region(),rollDetId.layer(),rollDetId.station(),1);
146  ME0EtaPartition* mep = new ME0EtaPartition(rollDetId2, surf, e_p_specs);
147 
148  // For Nick ... build also the layer
149  ME0DetId layerDetId(rollDetId.layerId());
150  ME0Layer* ml = new ME0Layer(layerDetId, surf);
151 
152  // Add the eta partition to the geometry
153  geometry->add(mep);
154  // Add the eta partition to the layer
155  ml->add(mep);
156  // Add the layer to the geometry
157  geometry->add(ml);
158 
159  // go to next layer
160  doSubDets = fview.nextSibling();
161 
162 
163  }
164 
165 
166  auto& partitions(geometry->etaPartitions());
167  // build the chambers and add them to the geometry
168  std::vector<ME0DetId> vDetId;
169  //int oldRollNumber = 1;
170  int oldLayerNumber = 1;
171  for (unsigned i=1; i<=partitions.size(); ++i){
172  ME0DetId detId(partitions.at(i-1)->id());
173  LogDebug("ME0GeometryBuilderFromDDD") << "Making ME0DetId = " <<detId;
174 
175  //The GEM methodology depended on rollNumber changing from chamber to chamber, we need to use layer ID
176  //const int rollNumber(detId.roll());
177  // new batch of eta partitions --> new chamber
178  //if (rollNumber < oldRollNumber || i == partitions.size()) {
179 
180  const int layerNumber(detId.layer());
181  if (layerNumber < oldLayerNumber || i == partitions.size()) {
182 
183  // don't forget the last partition for the last chamber
184  if (i == partitions.size()) vDetId.push_back(detId);
185 
186  ME0DetId fId(vDetId.front());
187  ME0DetId chamberId(fId.chamberId());
188  LogDebug("ME0GeometryBuilderFromDDD") << "ME0DetId = " << fId ;
189  LogDebug("ME0GeometryBuilderFromDDD") << "ME0ChamberId = " << chamberId ;
190  // compute the overall boundplane using the first eta partition
191  const ME0EtaPartition* p(geometry->etaPartition(fId));
192  const BoundPlane& bps = p->surface();
193  BoundPlane* bp = const_cast<BoundPlane*>(&bps);
195 
196  ME0Chamber* ch = new ME0Chamber(chamberId, surf);
197  LogDebug("ME0GeometryBuilderFromDDD") << "Creating chamber " << chamberId << " with " << vDetId.size() << " eta partitions";
198 
199  for(auto id : vDetId){
200  LogDebug("ME0GeometryBuilderFromDDD") << "Adding eta partition " << id << " to ME0 chamber";
201  ch->add(const_cast<ME0EtaPartition*>(geometry->etaPartition(id)));
202  }
203 
204  LogDebug("ME0GeometryBuilderFromDDD") << "Adding the chamber to the geometry";
205  geometry->add(ch);
206  vDetId.clear();
207  }
208  vDetId.push_back(detId);
209  oldLayerNumber = layerNumber;
210  }
211 
212 
213  return geometry;
214 }
#define LogDebug(id)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:147
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
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
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
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