test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ME0GeometryBuilderFromDDD10EtaPart.cc
Go to the documentation of this file.
4 
8 
12 
14 
16 
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
19 #include <iostream>
20 #include <algorithm>
21 #include <boost/lexical_cast.hpp>
22 
24 { }
25 
27 { }
28 
29 
31 {
32 
33  std::string attribute = "MuStructure";
34  std::string value = "MuonEndCapME0";
35 
36  DDValue val(attribute, value, 0.0);
37 
38  // Asking only for the MuonME0's
40  filter.setCriteria(val, // name & value of a variable
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  return this->buildGeometry(fview, muonConstants);
50 }
51 
52 
54 {
55 
57 
58  LogTrace("ME0GeometryBuilderFromDDD") <<"Building the geometry service";
59  LogTrace("ME0GeometryBuilderFromDDD") <<"About to run through the ME0 structure\n"
60  <<"Top level logical part: "
61  <<fv.logicalPart().name().name();
62 
63  // ==========================================
64  // === Test to understand the structure ===
65  // ==========================================
66  #ifdef EDM_ML_DEBUG
67  bool testChambers = fv.firstChild();
68  LogTrace("ME0GeometryBuilderFromDDD") << "doChamber = fv.firstChild() = " << testChambers;
69  // ----------------------------------------------------------------------------------------------------------------------------------------------
70  while (testChambers) {
71  // to etapartitions
72  LogTrace("ME0GeometryBuilderFromDDD")<<"to layer "<<fv.firstChild(); // commented out in case only looping over sensitive volumes
73  LogTrace("ME0GeometryBuilderFromDDD")<<"to etapt "<<fv.firstChild(); // commented out in case only looping over sensitive volumes
74  MuonDDDNumbering mdddnum(muonConstants);
75  ME0NumberingScheme me0Num(muonConstants);
76  int rawId = me0Num.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
77  ME0DetId detId = ME0DetId(rawId);
78  ME0DetId detIdCh = detId.chamberId();
79  // back to chambers
80  LogTrace("ME0GeometryBuilderFromDDD")<<"back to layer "<<fv.parent(); // commented out in case only looping over sensitive volumes
81  LogTrace("ME0GeometryBuilderFromDDD")<<"back to chamb "<<fv.parent(); // commented out in case only looping over sensitive volumes
82  // ok lets get started ...
83  LogTrace("ME0GeometryBuilderFromDDD") << "In DoChambers Loop :: ME0DetId "<<detId<<" = "<<detId.rawId()<<" (which belongs to ME0Chamber "<<detIdCh<<" = "<<detIdCh.rawId()<<")";
84  LogTrace("ME0GeometryBuilderFromDDD") << "Second level logical part: " << fv.logicalPart().name().name();
86  std::vector<double> dpar2 = solid2.parameters();
87  std::stringstream parameters2;
88  for(unsigned int i=0; i<dpar2.size(); ++i) {
89  parameters2 << " dpar["<<i<<"]="<< dpar2[i]/10 << "cm ";
90  }
91  LogTrace("ME0GeometryBuilderFromDDD") << "Second level parameters: vector with size = "<<dpar2.size()<<" and elements "<<parameters2.str();
92  // from GEM
93  // DDBooleanSolid solid = (DDBooleanSolid)(fv.logicalPart().solid());
94  // std::vector<double> dpar = solid.solidA().parameters();
95  /*
96  if(solid2.solidA()) {
97  std::vector<double> dpar2a = solid2.solidA().parameters();
98  std::stringstream parameters2a;
99  for(unsigned int i=0; i<dpar2a.size(); ++i) {
100  parameters2a << " dpara["<<i<<"]="<< dpar2a[i]/10 << "cm ";
101  }
102  LogTrace("ME0GeometryBuilderFromDDD") << "Second level parameters: vector with size = "<<dpar2a.size()<<" and elements "<<parameters2.str();
103  }
104  if(solid2.solidB()) {
105  std::vector<double> dpar2b = solid2.solidB().parameters();
106  std::stringstream parameters2b;
107  for(unsigned int i=0; i<dpar2b.size(); ++i) {
108  parameters2b << " dparb["<<i<<"]="<< dpar2b[i]/10 << "cm ";
109  }
110  LogTrace("ME0GeometryBuilderFromDDD") << "Second level parameters: vector with size = "<<dpar2b.size()<<" and elements "<<parameters2.str();
111  }
112  */
113  bool doLayers = fv.firstChild();
114  // --------------------------------------------------------------------------------------------------------------------------------------------
115  LogTrace("ME0GeometryBuilderFromDDD") << "doLayer = fv.firstChild() = " << doLayers;
116  while (doLayers) {
117  // to etapartitions
118  LogTrace("ME0GeometryBuilderFromDDD")<<"to etapt "<<fv.firstChild(); // commented out in case only looping over sensitive volumes
119  MuonDDDNumbering mdddnum(muonConstants);
120  ME0NumberingScheme me0Num(muonConstants);
121  int rawId = me0Num.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
122  ME0DetId detId = ME0DetId(rawId);
123  ME0DetId detIdLa = detId.layerId();
124  // back to layers
125  LogTrace("ME0GeometryBuilderFromDDD")<<"back to layer "<<fv.parent(); // commented out in case only looping over sensitive volumes
126  LogTrace("ME0GeometryBuilderFromDDD") << "In DoLayers Loop :: ME0DetId "<<detId<<" = "<<detId.rawId()<<" (which belongs to ME0Layer "<<detIdLa<<" = "<<detIdLa.rawId()<<")";
127  LogTrace("ME0GeometryBuilderFromDDD") << "Third level logical part: " << fv.logicalPart().name().name();
128  DDBooleanSolid solid3 = (DDBooleanSolid)(fv.logicalPart().solid());
129  std::vector<double> dpar3 = solid3.parameters();
130  std::stringstream parameters3;
131  for(unsigned int i=0; i<dpar3.size(); ++i) {
132  parameters3 << " dpar["<<i<<"]="<< dpar3[i]/10 << "cm ";
133  }
134  LogTrace("ME0GeometryBuilderFromDDD") << "Third level parameters: vector with size = "<<dpar3.size()<<" and elements "<<parameters3.str();
135  bool doEtaParts = fv.firstChild();
136  // --------------------------------------------------------------------------------------------------------------------------------------------
137  LogTrace("ME0GeometryBuilderFromDDD") << "doEtaPart = fv.firstChild() = " << doEtaParts;
138  while (doEtaParts) {
139  LogTrace("ME0GeometryBuilderFromDDD") << "In DoEtaParts Loop :: ME0DetId "<<detId<<" = "<<detId.rawId();
140  LogTrace("ME0GeometryBuilderFromDDD") << "Fourth level logical part: " << fv.logicalPart().name().name();
141  DDBooleanSolid solid4 = (DDBooleanSolid)(fv.logicalPart().solid());
142  std::vector<double> dpar4 = solid4.parameters();
143  std::stringstream parameters4;
144  for(unsigned int i=0; i<dpar4.size(); ++i) {
145  parameters4 << " dpar["<<i<<"]="<< dpar4[i]/10 << "cm ";
146  }
147  LogTrace("ME0GeometryBuilderFromDDD") << "Fourth level parameters: vector with size = "<<dpar4.size()<<" and elements "<<parameters4.str();
148  // --------------------------------------------------------------------------------------------------------------------------------------------
149  doEtaParts = fv.nextSibling();
150  LogTrace("ME0GeometryBuilderFromDDD") << "doEtaPart = fv.nextSibling() = " << doEtaParts;
151  }
152  fv.parent(); // commented out in case only looping over sensitive volumes
153  LogTrace("ME0GeometryBuilderFromDDD") << "went back to parent :: name = "<<fv.logicalPart().name().name()<<" will now ask for nextSibling";
154  doLayers = fv.nextSibling();
155  LogTrace("ME0GeometryBuilderFromDDD") << "doLayer = fv.nextSibling() = " << doLayers;
156  }
157  fv.parent(); // commented out in case only looping over sensitive volumes
158  LogTrace("ME0GeometryBuilderFromDDD") << "went back to parent :: name = "<<fv.logicalPart().name().name()<<" will now ask for nextSibling";
159  testChambers = fv.nextSibling();
160  LogTrace("ME0GeometryBuilderFromDDD") << "doChamber = fv.nextSibling() = " << testChambers;
161  }
162  fv.parent();
163  #endif
164 
165 
166  // ==========================================
167  // === Here the Real ME0 Geometry Builder ===
168  // ==========================================
169  bool doChambers = fv.firstChild();
170  while (doChambers) {
171  // to etapartitions and back again to pick up DetId
172  fv.firstChild();
173  fv.firstChild();
174  MuonDDDNumbering mdddnum(muonConstants);
175  ME0NumberingScheme me0Num(muonConstants);
176  int rawId = me0Num.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
177  ME0DetId detId = ME0DetId(rawId);
178  ME0DetId detIdCh = detId.chamberId();
179  fv.parent();
180  fv.parent();
181 
182  // build chamber
183  ME0Chamber *me0Chamber = buildChamber(fv, detIdCh);
184  geometry->add(me0Chamber);
185 
186  // loop over layers of the chamber
187  bool doLayers = fv.firstChild();
188  while (doLayers) {
189  // to etapartitions and back again to pick up DetId
190  fv.firstChild();
191  MuonDDDNumbering mdddnum(muonConstants);
192  ME0NumberingScheme me0Num(muonConstants);
193  int rawId = me0Num.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
194  ME0DetId detId = ME0DetId(rawId);
195  ME0DetId detIdLa = detId.layerId();
196  fv.parent();
197 
198  // build layer
199  ME0Layer *me0Layer = buildLayer(fv, detIdLa);
200  me0Chamber->add(me0Layer);
201  geometry->add(me0Layer);
202 
203 
204  // loop over etapartitions of the layer
205  bool doEtaParts = fv.firstChild();
206  while (doEtaParts) {
207  // pick up DetId
208  MuonDDDNumbering mdddnum(muonConstants);
209  ME0NumberingScheme me0Num(muonConstants);
210  int rawId = me0Num.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
211  ME0DetId detId = ME0DetId(rawId);
212 
213  // build etapartition
214  ME0EtaPartition *etaPart = buildEtaPartition(fv, detId);
215  me0Layer->add(etaPart);
216  geometry->add(etaPart);
217 
218  doEtaParts = fv.nextSibling();
219  }
220  fv.parent();
221  doLayers = fv.nextSibling();
222  }
223  fv.parent();
224  doChambers = fv.nextSibling();
225  }
226 
227  return geometry;
228 }
229 
231  LogTrace("ME0GeometryBuilderFromDDD") << "buildChamber "<<fv.logicalPart().name().name() <<" "<< detId <<std::endl;
232 
234  // std::vector<double> dpar = solid.solidA().parameters();
235  std::vector<double> dpar = solid.parameters();
236  double L = dpar[0]/cm;// length is along local Y
237  double T = dpar[3]/cm;// thickness is long local Z
238  double b = dpar[4]/cm;// bottom width is along local X
239  double B = dpar[8]/cm;// top width is along local X
240  // hardcoded :: double b = 21.9859, B = 52.7261, L = 87.1678, T = 12.9;
241 
242  #ifdef EDM_ML_DEBUG
243  LogTrace("ME0GeometryBuilderFromDDD") << " name of logical part = "<<fv.logicalPart().name().name()<<std::endl;
244  LogTrace("ME0GeometryBuilderFromDDD") << " dpar is vector with size = "<<dpar.size()<<std::endl;
245  for(unsigned int i=0; i<dpar.size(); ++i) {
246  LogTrace("ME0GeometryBuilderFromDDD") << " dpar ["<<i<<"] = "<< dpar[i]/10 << " cm "<<std::endl;
247  }
248  LogTrace("ME0GeometryBuilderFromDDD") << "size b: "<< b << "cm, B: " << B << "cm, L: " << L << "cm, T: " << T <<"cm "<<std::endl;
249  #endif
250 
251  bool isOdd = false; // detId.chamber()%2;
252  ME0BoundPlane surf(boundPlane(fv, new TrapezoidalPlaneBounds(b,B,L,T), isOdd ));
253  ME0Chamber* chamber = new ME0Chamber(detId.chamberId(), surf);
254  return chamber;
255 }
256 
258  LogTrace("ME0GeometryBuilderFromDDD") << "buildLayer "<<fv.logicalPart().name().name() <<" "<< detId <<std::endl;
259 
261  // std::vector<double> dpar = solid.solidA().parameters();
262  std::vector<double> dpar = solid.parameters();
263  double L = dpar[0]/cm;// length is along local Y
264  double t = dpar[3]/cm;// thickness is long local Z
265  double b = dpar[4]/cm;// bottom width is along local X
266  double B = dpar[8]/cm;// top width is along local X
267  // dpar = solid.solidB().parameters();
268  // dz += dpar[3]/cm; // layer thickness --- to be checked !!! layer thickness should be same as eta part thickness
269  // hardcoded :: double b = 21.9859, B = 52.7261, L = 87.1678, t = 0.4;
270 
271  #ifdef EDM_ML_DEBUG
272  LogTrace("ME0GeometryBuilderFromDDD") << " name of logical part = "<<fv.logicalPart().name().name()<<std::endl;
273  LogTrace("ME0GeometryBuilderFromDDD") << " dpar is vector with size = "<<dpar.size()<<std::endl;
274  for(unsigned int i=0; i<dpar.size(); ++i) {
275  LogTrace("ME0GeometryBuilderFromDDD") << " dpar ["<<i<<"] = "<< dpar[i]/10 << " cm "<<std::endl;
276  }
277  LogTrace("ME0GeometryBuilderFromDDD") << "size b: "<< b << "cm, B: " << B << "cm, L: " << L << "cm, t: " << t <<"cm "<<std::endl;
278  #endif
279 
280  bool isOdd = false; // detId.chamber()%2;
281  ME0BoundPlane surf(boundPlane(fv, new TrapezoidalPlaneBounds(b,B,L,t), isOdd ));
282  ME0Layer* layer = new ME0Layer(detId.layerId(), surf);
283  return layer;
284 }
285 
287  LogTrace("ME0GeometryBuilderFromDDD") << "buildEtaPartition "<<fv.logicalPart().name().name() <<" "<< detId <<std::endl;
288 
289  // EtaPartition specific parameter (nstrips and npads)
290  DDValue numbOfStrips("nStrips");
291  DDValue numbOfPads("nPads");
292  std::vector<const DDsvalues_type* > specs(fv.specifics());
293  std::vector<const DDsvalues_type* >::iterator is = specs.begin();
294  double nStrips = 0., nPads = 0.;
295  for (;is != specs.end(); is++){
296  if (DDfetch( *is, numbOfStrips)) nStrips = numbOfStrips.doubles()[0];
297  if (DDfetch( *is, numbOfPads)) nPads = numbOfPads.doubles()[0];
298  }
299  LogTrace("ME0GeometryBuilderFromDDD")
300  << ((nStrips == 0. ) ? ("No nStrips found!!") : ("Number of strips: " + boost::lexical_cast<std::string>(nStrips)));
301  LogTrace("ME0GeometryBuilderFromDDD")
302  << ((nPads == 0. ) ? ("No nPads found!!") : ("Number of pads: " + boost::lexical_cast<std::string>(nPads)));
303 
304  // EtaPartition specific parameter (size)
305  std::vector<double> dpar = fv.logicalPart().solid().parameters();
306  double b = dpar[4]/cm; // half bottom edge
307  double B = dpar[8]/cm; // half top edge
308  double L = dpar[0]/cm; // half apothem
309  double t = dpar[3]/cm; // half thickness
310 
311  #ifdef EDM_ML_DEBUG
312  LogTrace("ME0GeometryBuilderFromDDD") << " name of logical part = "<<fv.logicalPart().name().name()<<std::endl;
313  LogTrace("ME0GeometryBuilderFromDDD") << " dpar is vector with size = "<<dpar.size()<<std::endl;
314  for(unsigned int i=0; i<dpar.size(); ++i) {
315  LogTrace("ME0GeometryBuilderFromDDD") << " dpar ["<<i<<"] = "<< dpar[i]/10 << " cm "<<std::endl;
316  }
317  LogTrace("ME0GeometryBuilderFromDDD") << "size b: "<< b << "cm, B: " << B << "cm, L: " << L << "cm, t: " << t <<"cm "<<std::endl;
318  #endif
319 
320  std::vector<float> pars;
321  pars.push_back(b);
322  pars.push_back(B);
323  pars.push_back(L);
324  pars.push_back(nStrips);
325  pars.push_back(nPads);
326 
327  bool isOdd = false; // detId.chamber()%2; // this gives the opportunity (in future) to change the face of the chamber (electronics facing IP or electronics away from IP)
328  ME0BoundPlane surf(boundPlane(fv, new TrapezoidalPlaneBounds(b, B, L, t), isOdd ));
329  std::string name = fv.logicalPart().name().name();
331 
332  ME0EtaPartition* etaPartition = new ME0EtaPartition(detId, surf, e_p_specs);
333  return etaPartition;
334 }
335 
338  Bounds* bounds, bool isOddChamber) const {
339  // extract the position
340  const DDTranslation & trans(fv.translation());
341  const Surface::PositionType posResult(float(trans.x()/cm),
342  float(trans.y()/cm),
343  float(trans.z()/cm));
344 
345  // now the rotation
346  // DDRotationMatrix tmp = fv.rotation();
347  // === DDD uses 'active' rotations - see CLHEP user guide ===
348  // ORCA uses 'passive' rotation.
349  // 'active' and 'passive' rotations are inverse to each other
350  // DDRotationMatrix tmp = fv.rotation();
351  DDRotationMatrix rotation = fv.rotation();//REMOVED .Inverse();
352  DD3Vector x, y, z;
353  rotation.GetComponents(x,y,z);
354  // LogTrace("GEMGeometryBuilderFromDDD") << "translation: "<< fv.translation() << std::endl;
355  // LogTrace("GEMGeometryBuilderFromDDD") << "rotation : "<< fv.rotation() << std::endl;
356  // LogTrace("GEMGeometryBuilderFromDDD") << "INVERSE rotation manually: \n"
357  // << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
358  // << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
359  // << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;
360 
361  Surface::RotationType rotResult(float(x.X()),float(x.Y()),float(x.Z()),
362  float(y.X()),float(y.Y()),float(y.Z()),
363  float(z.X()),float(z.Y()),float(z.Z()));
364 
365  //Change of axes for the forward
366  Basic3DVector<float> newX(1.,0.,0.);
367  Basic3DVector<float> newY(0.,0.,1.);
368  Basic3DVector<float> newZ(0.,1.,0.);
369  // Odd chambers are inverted in gem.xml
370  if (isOddChamber) newY *= -1;
371 
372  rotResult.rotateAxes(newX, newY, newZ);
373 
374  return ME0BoundPlane( new BoundPlane( posResult, rotResult, bounds));
375 }
376 
int i
Definition: DBlmapReader.cc:9
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:157
bool parent()
set the current node to the parent node ...
ME0DetId layerId() const
Return the corresponding LayerId (mask eta partition)
Definition: ME0DetId.h:71
ME0Chamber * buildChamber(DDFilteredView &fv, ME0DetId detId) const
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:137
ME0Geometry * buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants)
const N & name() const
Definition: DDBase.h:78
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
ME0DetId chamberId() const
Return the corresponding ChamberId (mask layers)
Definition: ME0DetId.h:67
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.
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
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
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
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
ReferenceCountingPointer< BoundPlane > ME0BoundPlane
ME0BoundPlane boundPlane(const DDFilteredView &fv, Bounds *bounds, bool isOddChamber) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
void add(const ME0EtaPartition *roll)
Add EtaPartition to the layer which takes ownership.
Definition: ME0Layer.cc:21
#define LogTrace(id)
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
ME0EtaPartition * buildEtaPartition(DDFilteredView &fv, ME0DetId detId) const
double b
Definition: hdecay.h:120
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 ...
ME0Geometry * build(const DDCompactView *cview, const MuonDDDConstants &muonConstants)
ME0Layer * buildLayer(DDFilteredView &fv, ME0DetId detId) const
Definition: Bounds.h:22
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< const DDsvalues_type * > specifics() const
long double T
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
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:253
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:33