CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMGeometryParsFromDD.cc
Go to the documentation of this file.
1 
7 
12 
16 
18 
19 #include "CLHEP/Units/GlobalSystemOfUnits.h"
20 
21 #include <iostream>
22 #include <algorithm>
23 
25 { }
26 
28 { }
29 
30 void
32  const MuonDDDConstants& muonConstants, RecoIdealGeometry& rgeo )
33 {
34  std::string attribute = "ReadOutName"; // could come from .orcarc
35  std::string value = "MuonGEMHits"; // could come from .orcarc
36  DDValue val(attribute, value, 0.0);
37 
38  // Asking only for the MuonGEM's
40  filter.setCriteria(val, // name & value of a variable
42  DDLogOp::AND,
43  true, // compare strings otherwise doubles
44  true // use merged-specifics or simple-specifics
45  );
46  DDFilteredView fview(*cview);
47  fview.addFilter(filter);
48 
49  this->buildGeometry(fview, muonConstants, rgeo);
50 }
51 
52 void
54 {
55 
56  bool doSubDets = fview.firstChild();
57 
58  while (doSubDets){
59 
60  // Get the Base Muon Number
61  MuonDDDNumbering mdddnum(muonConstants);
62  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
63 
64  // Get the The GEM det Id
65  GEMNumberingScheme gemnum(muonConstants);
66  int detid = 0;
67 
68  detid = gemnum.baseNumberToUnitNumber(mbn);
69  GEMDetId gemid(detid);
70 
71  DDValue numbOfStrips("nStrips");
72  DDValue numbOfPads("nPads");
73 
74  std::vector<const DDsvalues_type* > specs(fview.specifics());
75  std::vector<const DDsvalues_type* >::iterator is = specs.begin();
76  double nStrips = 0., nPads = 0.;
77  for (;is!=specs.end(); is++)
78  {
79  if (DDfetch( *is, numbOfStrips)) nStrips = numbOfStrips.doubles()[0];
80  if (DDfetch( *is, numbOfPads)) nPads = numbOfPads.doubles()[0];
81  }
82  LogDebug("GEMGeometryBuilderFromDDD") << ((nStrips == 0. ) ? ("No nStrips found!!") : (""));
83  LogDebug("GEMGeometryBuilderFromDDD") << ((nPads == 0. ) ? ("No nPads found!!") : (""));
84  //std::cout <<"# strips, pads: "<< nStrips<<", "<<nPads<<std::endl;
85 
86  std::vector<double> dpar = fview.logicalPart().solid().parameters();
87 
88  std::vector<std::string> strpars;
89  std::string name = fview.logicalPart().name().name();
90  strpars.push_back(name);
91  DDTranslation tran = fview.translation();
92 
93  DDRotationMatrix rota = fview.rotation();//.Inverse();
94  DD3Vector x, y, z;
95  rota.GetComponents(x,y,z);
96  std::vector<double> pars;
97  pars.push_back(dpar[4]); //b/2;
98  pars.push_back(dpar[8]); //B/2;
99  pars.push_back(dpar[0]); //h/2;
100  pars.push_back(0.4); // XXX: what is that? hardcoded thickness?
101  pars.push_back(nStrips);
102  pars.push_back(nPads);
103 
104  std::vector<double> vtra(3);
105  std::vector<double> vrot(9);
106  vtra[0]=(float) 1.0 * (tran.x());
107  vtra[1]=(float) 1.0 * (tran.y());
108  vtra[2]=(float) 1.0 * (tran.z());
109  vrot[0]=(float) 1.0 * x.X();
110  vrot[1]=(float) 1.0 * x.Y();
111  vrot[2]=(float) 1.0 * x.Z();
112  vrot[3]=(float) 1.0 * y.X();
113  vrot[4]=(float) 1.0 * y.Y();
114  vrot[5]=(float) 1.0 * y.Z();
115  vrot[6]=(float) 1.0 * z.X();
116  vrot[7]=(float) 1.0 * z.Y();
117  vrot[8]=(float) 1.0 * z.Z();
118  rgeo.insert(gemid.rawId(), vtra, vrot, pars, strpars);
119  doSubDets = fview.nextSibling(); // go to next layer
120  }
121 
122 }
#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.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:139
const N & name() const
Definition: DDBase.h:78
void build(const DDCompactView *cview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rgeo)
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
void buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rgeo)
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars)
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.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
bool firstChild()
set the current node to the first child ...
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< const DDsvalues_type * > specifics() const
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