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