CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  DDValue val(attribute, value, 0.0);
45 
46  // Asking only for the MuonME0's
48  filter.setCriteria(val, // name & value of a variable
50  DDLogOp::AND,
51  true, // compare strings otherwise doubles
52  true // use merged-specifics or simple-specifics
53  );
54  DDFilteredView fview(*cview);
55  fview.addFilter(filter);
56 
57  return this->buildGeometry(fview, muonConstants);
58 }
59 
61 {
62  LogDebug("ME0GeometryBuilderFromDDD") <<"Building the geometry service";
64 
65  LogDebug("ME0GeometryBuilderFromDDD") << "About to run through the ME0 structure\n"
66  <<" First logical part "
67  <<fview.logicalPart().name().name();
68 
69 
70  bool doSubDets = fview.firstChild();
71 
72  LogDebug("ME0GeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
73 
74  LogDebug("ME0GeometryBuilderFromDDD") <<"start the loop";
75 
76  int nChambers(0);
77  while (doSubDets)
78  {
79  // Get the Base Muon Number
80  MuonDDDNumbering mdddnum(muonConstants);
81  LogDebug("ME0GeometryBuilderFromDDD") <<"Getting the Muon base Number";
82  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
83 
84  LogDebug("ME0GeometryBuilderFromDDD") <<"Start the ME0 Numbering Schema";
85  ME0NumberingScheme me0num(muonConstants);
86 
87  ME0DetId rollDetId(me0num.baseNumberToUnitNumber(mbn));
88  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 eta partition rawId: " << rollDetId.rawId() << ", detId: " << rollDetId;
89 
90  // chamber id for this partition. everything is the same; but partition number is 0.
91  ME0DetId chamberId(rollDetId.chamberId());
92  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 chamber rawId: " << chamberId.rawId() << ", detId: " << chamberId;
93 
94  //Commented out, we don't have stations
95  //const int stationId(rollDetId.station());
96  //if (stationId > maxStation) maxStation = stationId;
97 
98  if (rollDetId.roll()==1) ++nChambers;
99 
100 
101  std::vector<double> dpar=fview.logicalPart().solid().parameters();
102  std::string name = fview.logicalPart().name().name();
103  DDTranslation tran = fview.translation();
104  DDRotationMatrix rota = fview.rotation();
105  Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
106  // CLHEP way
107  // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
108  // rota.yx(),rota.yy(),rota.yz(),
109  // rota.zx(),rota.zy(),rota.zz());
110 
111  //ROOT::Math way
112  DD3Vector x, y, z;
113  rota.GetComponents(x,y,z);
114  // doesn't this just re-inverse???
115  Surface::RotationType rot(float(x.X()), float(x.Y()), float(x.Z()),
116  float(y.X()), float(y.Y()), float(y.Z()),
117  float(z.X()), float(z.Y()), float(z.Z()));
118 
119  float be = dpar[4]/cm; // half bottom edge
120  float te = dpar[8]/cm; // half top edge
121  float ap = dpar[0]/cm; // half apothem
122  float ti = 0.4/cm; // half thickness
123 
124  // TrapezoidalPlaneBounds*
125  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
126 
127  std::vector<float> pars;
128  pars.push_back(be);
129  pars.push_back(te);
130  pars.push_back(ap);
131  float nStrips = -999.;
132  float nPads = -999.;
133  pars.push_back(nStrips);
134  pars.push_back(nPads);
135 
136  LogDebug("ME0GeometryBuilderFromDDD")
137  << "ME0 " << name << " par " << be << " " << te << " " << ap << " " << dpar[0];
138 
140 
141  //Change of axes for the forward
142  Basic3DVector<float> newX(1.,0.,0.);
143  Basic3DVector<float> newY(0.,0.,1.);
144  // if (tran.z() > 0. )
145  newY *= -1;
146  Basic3DVector<float> newZ(0.,1.,0.);
147  rot.rotateAxes (newX, newY, newZ);
148 
149  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
151  ME0EtaPartition* mep = new ME0EtaPartition(rollDetId, surf, e_p_specs);
152 
153  // Add the eta partition to the geometry
154  geometry->add(mep);
155  // go to next layer
156  doSubDets = fview.nextSibling();
157  }
158 
159 
160  auto& partitions(geometry->etaPartitions());
161  // build the chambers and add them to the geometry
162  std::vector<ME0DetId> vDetId;
163  //int oldRollNumber = 1;
164  int oldLayerNumber = 1;
165  for (unsigned i=1; i<=partitions.size(); ++i){
166  ME0DetId detId(partitions.at(i-1)->id());
167  LogDebug("ME0GeometryBuilderFromDDD") << "Making ME0DetId = " <<detId;
168 
169  //The GEM methodology depended on rollNumber changing from chamber to chamber, we need to use layer ID
170  //const int rollNumber(detId.roll());
171  // new batch of eta partitions --> new chamber
172  //if (rollNumber < oldRollNumber || i == partitions.size()) {
173 
174  const int layerNumber(detId.layer());
175  if (layerNumber < oldLayerNumber || i == partitions.size()) {
176 
177  // don't forget the last partition for the last chamber
178  if (i == partitions.size()) vDetId.push_back(detId);
179 
180  ME0DetId fId(vDetId.front());
181  ME0DetId chamberId(fId.chamberId());
182  LogDebug("ME0GeometryBuilderFromDDD") << "ME0DetId = " << fId ;
183  LogDebug("ME0GeometryBuilderFromDDD") << "ME0ChamberId = " << chamberId ;
184  // compute the overall boundplane using the first eta partition
185  const ME0EtaPartition* p(geometry->etaPartition(fId));
186  const BoundPlane& bps = p->surface();
187  BoundPlane* bp = const_cast<BoundPlane*>(&bps);
189 
190  ME0Chamber* ch = new ME0Chamber(chamberId, surf);
191  LogDebug("ME0GeometryBuilderFromDDD") << "Creating chamber " << chamberId << " with " << vDetId.size() << " eta partitions";
192 
193  for(auto id : vDetId){
194  LogDebug("ME0GeometryBuilderFromDDD") << "Adding eta partition " << id << " to ME0 chamber";
195  ch->add(const_cast<ME0EtaPartition*>(geometry->etaPartition(id)));
196  }
197 
198  LogDebug("ME0GeometryBuilderFromDDD") << "Adding the chamber to the geometry";
199  geometry->add(ch);
200  vDetId.clear();
201  }
202  vDetId.push_back(detId);
203  oldLayerNumber = layerNumber;
204  }
205 
206 
207  return geometry;
208 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
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
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
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
void add(ME0EtaPartition *roll)
Add EtaPartition to the chamber which takes ownership.
Definition: ME0Chamber.cc:28
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:61
type of data representation of DDCompactView
Definition: DDCompactView.h:77
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
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)
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:57
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
unsigned int layerNumber(align::ID, const TrackerTopology *)
Layer number increases with rho from 1 to 8.
Definition: TIBNameSpace.h:86
void add(ME0EtaPartition *etaPartition)
Add a ME0 etaPartition to the Geometry.
Definition: ME0Geometry.cc:67
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:87
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32