CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCGeometryBuilderFromDDD.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 
28 RPCGeometryBuilderFromDDD::RPCGeometryBuilderFromDDD(bool comp11) : theComp11Flag(comp11)
29 { }
30 
32 { }
33 
35 {
36  std::string attribute = "ReadOutName"; // could come from .orcarc
37  std::string value = "MuonRPCHits"; // could come from .orcarc
38  DDValue val(attribute, value, 0.0);
39 
40  // Asking only for the MuonRPC's
42  filter.setCriteria(val, // name & value of a variable
44  DDLogOp::AND,
45  true, // compare strings otherwise doubles
46  true // use merged-specifics or simple-specifics
47  );
48  DDFilteredView fview(*cview);
49  fview.addFilter(filter);
50 
51  return this->buildGeometry(fview, muonConstants);
52 }
53 
55 {
56  LogDebug("RPCGeometryBuilderFromDDD") <<"Building the geometry service";
58 
59  LogDebug("RPCGeometryBuilderFromDDD") << "About to run through the RPC structure\n"
60  <<" First logical part "
61  <<fview.logicalPart().name().name();
62  bool doSubDets = fview.firstChild();
63 
64  LogDebug("RPCGeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
65  while (doSubDets){
66  LogDebug("RPCGeometryBuilderFromDDD") <<"start the loop";
67 
68  // Get the Base Muon Number
69  MuonDDDNumbering mdddnum(muonConstants);
70  LogDebug("RPCGeometryBuilderFromDDD") <<"Getting the Muon base Number";
72  LogDebug("RPCGeometryBuilderFromDDD") <<"Start the Rpc Numbering Schema";
73  // Get the The Rpc det Id
74  RPCNumberingScheme rpcnum(muonConstants);
75  int detid = 0;
76 
77  LogDebug("RPCGeometryBuilderFromDDD") <<"Getting the Unit Number";
78  detid = rpcnum.baseNumberToUnitNumber(mbn);
79  LogDebug("RPCGeometryBuilderFromDDD") <<"Getting the RPC det Id "<<detid;
80 
81  RPCDetId rpcid(detid);
82  RPCDetId chid(rpcid.region(),rpcid.ring(),rpcid.station(),rpcid.sector(),rpcid.layer(),rpcid.subsector(),0);
83 
84  LogDebug("RPCGeometryBuilderFromDDD") <<"The RPCDetid is "<<rpcid;
85 
86  DDValue numbOfStrips("nStrips");
87 
88  std::vector<const DDsvalues_type* > specs(fview.specifics());
89  std::vector<const DDsvalues_type* >::iterator is=specs.begin();
90  int nStrips=0;
91  for (;is!=specs.end(); is++){
92  if (DDfetch( *is, numbOfStrips)){
93  nStrips=int(numbOfStrips.doubles()[0]);
94  }
95  }
96 
97  LogDebug("RPCGeometryBuilderFromDDD") << ((nStrips == 0 ) ? ("No strip found!!") : (""));
98 
99  std::vector<double> dpar=fview.logicalPart().solid().parameters();
100  std::string name=fview.logicalPart().name().name();
101  DDTranslation tran = fview.translation();
102  //removed .Inverse after comparing to DT...
103  DDRotationMatrix rota = fview.rotation();//.Inverse();
104  Surface::PositionType pos(tran.x()/cm,tran.y()/cm, tran.z()/cm);
105  // CLHEP way
106 // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
107 // rota.yx(),rota.yy(),rota.yz(),
108 // rota.zx(),rota.zy(),rota.zz());
109 
110 //ROOT::Math way
111  DD3Vector x, y, z;
112  rota.GetComponents(x,y,z);
113  // doesn't this just re-inverse???
114  Surface::RotationType rot (float(x.X()),float(x.Y()),float(x.Z()),
115  float(y.X()),float(y.Y()),float(y.Z()),
116  float(z.X()),float(z.Y()),float(z.Z()));
117 
118  std::vector<float> pars;
119  RPCRollSpecs* rollspecs= 0;
120  Bounds* bounds = 0;
121 
122 
123 
124  if (dpar.size()==3){
125  float width = dpar[0]/cm;
126  float length = dpar[1]/cm;
127  float thickness = dpar[2]/cm;
128  //RectangularPlaneBounds*
129  bounds =
130  new RectangularPlaneBounds(width,length,thickness);
131  pars.push_back(width);
132  pars.push_back(length);
133  pars.push_back(numbOfStrips.doubles()[0]); //h/2;
134 
135  if (!theComp11Flag) {
136  //Correction of the orientation to get the REAL geometry.
137  //Change of axes for the +z part only.
138  //Including the 0 whell
139  if (tran.z() >-1500. ){
140  Basic3DVector<float> newX(-1.,0.,0.);
141  Basic3DVector<float> newY(0.,-1.,0.);
142  Basic3DVector<float> newZ(0.,0.,1.);
143  rot.rotateAxes (newX, newY,newZ);
144  }
145  }
146 
147  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel,name,pars);
148  LogDebug("RPCGeometryBuilderFromDDD") <<"Barrel "<<name
149  <<" par "<<width
150  <<" "<<length<<" "<<thickness;
151  }
152  else{
153  float be = dpar[4]/cm;
154  float te = dpar[8]/cm;
155  float ap = dpar[0]/cm;
156  float ti = 0.4/cm;
157  // TrapezoidalPlaneBounds*
158  bounds =
159  new TrapezoidalPlaneBounds(be,te,ap,ti);
160  pars.push_back(dpar[4]/cm); //b/2;
161  pars.push_back(dpar[8]/cm); //B/2;
162  pars.push_back(dpar[0]/cm); //h/2;
163  pars.push_back(numbOfStrips.doubles()[0]); //h/2;
164 
165  LogDebug("RPCGeometryBuilderFromDDD") <<"Forward "<<name
166  <<" par "<<dpar[4]/cm
167  <<" "<<dpar[8]/cm<<" "<<dpar[3]/cm<<" "
168  <<dpar[0];
169 
170  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap,name,pars);
171 
172  //Change of axes for the forward
173  Basic3DVector<float> newX(1.,0.,0.);
174  Basic3DVector<float> newY(0.,0.,1.);
175  // if (tran.z() > 0. )
176  newY *= -1;
177  Basic3DVector<float> newZ(0.,1.,0.);
178  rot.rotateAxes (newX, newY,newZ);
179 
180  }
181  LogDebug("RPCGeometryBuilderFromDDD") <<" Number of strips "<<nStrips;
182 
183  BoundPlane* bp = new BoundPlane(pos,rot,bounds);
185  RPCRoll* r=new RPCRoll(rpcid,surf,rollspecs);
186  geometry->add(r);
187 
188  std::list<RPCRoll *> rls;
189  if (chids.find(chid)!=chids.end()){
190  rls = chids[chid];
191  }
192  rls.push_back(r);
193  chids[chid]=rls;
194 
195  doSubDets = fview.nextSibling(); // go to next layer
196  }
197  // Create the RPCChambers and store them on the Geometry
198  for( std::map<RPCDetId, std::list<RPCRoll *> >::iterator ich=chids.begin();
199  ich != chids.end(); ich++){
200  RPCDetId chid = ich->first;
201  std::list<RPCRoll * > rls = ich->second;
202 
203  // compute the overall boundplane. At the moment we use just the last
204  // surface
205  BoundPlane* bp=0;
206  for(std::list<RPCRoll *>::iterator rl=rls.begin();
207  rl!=rls.end(); rl++){
208  const BoundPlane& bps = (*rl)->surface();
209  bp = const_cast<BoundPlane *>(&bps);
210  }
211 
213  // Create the chamber
214  RPCChamber* ch = new RPCChamber (chid, surf);
215  // Add the rolls to rhe chamber
216  for(std::list<RPCRoll *>::iterator rl=rls.begin();
217  rl!=rls.end(); rl++){
218  ch->add(*rl);
219  }
220  // Add the chamber to the geometry
221  geometry->add(ch);
222  }
223  return geometry;
224 }
#define LogDebug(id)
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
Definition: RPCChamber.cc:48
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 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:76
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
RPCGeometry * build(const DDCompactView *cview, const MuonDDDConstants &muonConstants)
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
void add(RPCRoll *roll)
Add a RPC roll to the Geometry.
Definition: RPCGeometry.cc:81
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
RPCGeometry * buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
int ring() const
Definition: RPCDetId.h:72
std::map< RPCDetId, std::list< RPCRoll * > > chids
int layer() const
Definition: RPCDetId.h:108
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
ESHandle< TrackerGeometry > geometry
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:114
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.
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
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32