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 
9 
13 
17 
20 
22 
23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
25 
26 #include <iostream>
27 #include <algorithm>
28 #include <boost/lexical_cast.hpp>
29 
31 {
32  LogDebug("ME0GeometryBuilderfromDDD") <<"[ME0GeometryBuilderFromDDD::constructor]";
33 }
34 
36 { }
37 
39 {
40  std::string attribute = "ReadOutName";
41  std::string value = "MuonME0Hits";
42  DDValue val(attribute, value, 0.0);
43 
44  // Asking only for the MuonME0's
46  filter.setCriteria(val, // name & value of a variable
48  DDLogOp::AND,
49  true, // compare strings otherwise doubles
50  true // use merged-specifics or simple-specifics
51  );
52  DDFilteredView fview(*cview);
53  fview.addFilter(filter);
54 
55  return this->buildGeometry(fview, muonConstants);
56 }
57 
59 {
60  LogDebug("ME0GeometryBuilderFromDDD") <<"Building the geometry service";
62 
63  LogDebug("ME0GeometryBuilderFromDDD") << "About to run through the ME0 structure\n"
64  <<" First logical part "
65  <<fview.logicalPart().name().name();
66 
67 
68  bool doSubDets = fview.firstChild();
69 
70  LogDebug("ME0GeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
71 
72  LogDebug("ME0GeometryBuilderFromDDD") <<"start the loop";
73  while (doSubDets)
74  {
75  // Get the Base Muon Number
76  MuonDDDNumbering mdddnum(muonConstants);
77  LogDebug("ME0GeometryBuilderFromDDD") <<"Getting the Muon base Number";
78  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
79 
80  LogDebug("ME0GeometryBuilderFromDDD") <<"Start the ME0 Numbering Schema";
81  ME0NumberingScheme me0num(muonConstants);
82 
83  ME0DetId rollDetId(me0num.baseNumberToUnitNumber(mbn));
84  LogDebug("ME0GeometryBuilderFromDDD") << "ME0 eta partition rawId: " << rollDetId.rawId() << ", detId: " << rollDetId;
85 
86  std::vector<double> dpar=fview.logicalPart().solid().parameters();
87  std::string name = fview.logicalPart().name().name();
88  DDTranslation tran = fview.translation();
89  DDRotationMatrix rota = fview.rotation();
90  Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
91  // CLHEP way
92  // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
93  // rota.yx(),rota.yy(),rota.yz(),
94  // rota.zx(),rota.zy(),rota.zz());
95 
96  //ROOT::Math way
97  DD3Vector x, y, z;
98  rota.GetComponents(x,y,z);
99  // doesn't this just re-inverse???
100  Surface::RotationType rot(float(x.X()), float(x.Y()), float(x.Z()),
101  float(y.X()), float(y.Y()), float(y.Z()),
102  float(z.X()), float(z.Y()), float(z.Z()));
103 
104  float be = dpar[4]/cm; // half bottom edge
105  float te = dpar[8]/cm; // half top edge
106  float ap = dpar[0]/cm; // half apothem
107  float ti = 0.4/cm; // half thickness
108 
109  // TrapezoidalPlaneBounds*
110  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
111 
112  std::vector<float> pars;
113  pars.push_back(be);
114  pars.push_back(te);
115  pars.push_back(ap);
116  // pars.push_back(nStrips);
117  // pars.push_back(nPads);
118 
119  LogDebug("ME0GeometryBuilderFromDDD")
120  << "ME0 " << name << " par " << be << " " << te << " " << ap << " " << dpar[0];
121 
123 
124  //Change of axes for the forward
125  Basic3DVector<float> newX(1.,0.,0.);
126  Basic3DVector<float> newY(0.,0.,1.);
127  // if (tran.z() > 0. )
128  newY *= -1;
129  Basic3DVector<float> newZ(0.,1.,0.);
130  rot.rotateAxes (newX, newY, newZ);
131 
132  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
134  ME0EtaPartition* mep = new ME0EtaPartition(rollDetId, surf, e_p_specs);
135 
136  // Add the eta partition to the geometry
137  geometry->add(mep);
138  // go to next layer
139  doSubDets = fview.nextSibling();
140  }
141  return geometry;
142 }
#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
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.
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
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)
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
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