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
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 #ifdef LOCAL_DEBUG
57  std::cout <<"Building the geometry service"<<std::endl;
58 #endif
60 
61 #ifdef LOCAL_DEBUG
62  std::cout << "About to run through the RPC structure" << std::endl;
63  std::cout <<" First logical part "
64  <<fview.logicalPart().name().name()<<std::endl;
65 #endif
66  bool doSubDets = fview.firstChild();
67 
68 #ifdef LOCAL_DEBUG
69  std::cout << "doSubDets = " << doSubDets << std::endl;
70 #endif
71  while (doSubDets){
72 
73 #ifdef LOCAL_DEBUG
74  std::cout <<"start the loop"<<std::endl;
75 #endif
76 
77  // Get the Base Muon Number
78  MuonDDDNumbering mdddnum(muonConstants);
79 #ifdef LOCAL_DEBUG
80  std::cout <<"Getting the Muon base Number"<<std::endl;
81 #endif
83 
84 #ifdef LOCAL_DEBUG
85  std::cout <<"Start the Rpc Numbering Schema"<<std::endl;
86 #endif
87  // Get the The Rpc det Id
88  RPCNumberingScheme rpcnum(muonConstants);
89  int detid = 0;
90 
91 #ifdef LOCAL_DEBUG
92  std::cout <<"Getting the Unit Number"<<std::endl;
93 #endif
94  detid = rpcnum.baseNumberToUnitNumber(mbn);
95 #ifdef LOCAL_DEBUG
96  std::cout <<"Getting the RPC det Id "<<detid <<std::endl;
97 #endif
98  RPCDetId rpcid(detid);
99  RPCDetId chid(rpcid.region(),rpcid.ring(),rpcid.station(),rpcid.sector(),rpcid.layer(),rpcid.subsector(),0);
100 
101 #ifdef LOCAL_DEBUG
102  std::cout <<"The RPCDetid is "<<rpcid<<std::endl;
103 #endif
104 
105  DDValue numbOfStrips("nStrips");
106 
107  std::vector<const DDsvalues_type* > specs(fview.specifics());
108  std::vector<const DDsvalues_type* >::iterator is=specs.begin();
109  int nStrips=0;
110  for (;is!=specs.end(); is++){
111  if (DDfetch( *is, numbOfStrips)){
112  nStrips=int(numbOfStrips.doubles()[0]);
113  }
114  }
115 #ifdef LOCAL_DEBUG
116  if (nStrips == 0 )
117  std::cout <<"No strip found!!"<<std::endl;
118 #endif
119 
120  std::vector<double> dpar=fview.logicalPart().solid().parameters();
121  std::string name=fview.logicalPart().name().name();
122  DDTranslation tran = fview.translation();
123  //removed .Inverse after comparing to DT...
124  DDRotationMatrix rota = fview.rotation();//.Inverse();
125  Surface::PositionType pos(tran.x()/cm,tran.y()/cm, tran.z()/cm);
126  // CLHEP way
127 // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
128 // rota.yx(),rota.yy(),rota.yz(),
129 // rota.zx(),rota.zy(),rota.zz());
130 
131 //ROOT::Math way
132  DD3Vector x, y, z;
133  rota.GetComponents(x,y,z);
134  // doesn't this just re-inverse???
135  Surface::RotationType rot (float(x.X()),float(x.Y()),float(x.Z()),
136  float(y.X()),float(y.Y()),float(y.Z()),
137  float(z.X()),float(z.Y()),float(z.Z()));
138 
139  std::vector<float> pars;
140  RPCRollSpecs* rollspecs= 0;
141  Bounds* bounds = 0;
142 
143 
144 
145  if (dpar.size()==3){
146  float width = dpar[0]/cm;
147  float length = dpar[1]/cm;
148  float thickness = dpar[2]/cm;
149  //RectangularPlaneBounds*
150  bounds =
151  new RectangularPlaneBounds(width,length,thickness);
152  pars.push_back(width);
153  pars.push_back(length);
154  pars.push_back(numbOfStrips.doubles()[0]); //h/2;
155 
156  if (!theComp11Flag) {
157  //Correction of the orientation to get the REAL geometry.
158  //Change of axes for the +z part only.
159  //Including the 0 whell
160  if (tran.z() >-1500. ){
161  Basic3DVector<float> newX(-1.,0.,0.);
162  Basic3DVector<float> newY(0.,-1.,0.);
163  Basic3DVector<float> newZ(0.,0.,1.);
164  rot.rotateAxes (newX, newY,newZ);
165  }
166  }
167 
168  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel,name,pars);
169 #ifdef LOCAL_DEBUG
170  std::cout <<"Barrel "<<name
171  <<" par "<<width
172  <<" "<<length<<" "<<thickness;
173 #endif
174  }else{
175  float be = dpar[4]/cm;
176  float te = dpar[8]/cm;
177  float ap = dpar[0]/cm;
178  float ti = 0.4/cm;
179  // TrapezoidalPlaneBounds*
180  bounds =
181  new TrapezoidalPlaneBounds(be,te,ap,ti);
182  pars.push_back(dpar[4]/cm); //b/2;
183  pars.push_back(dpar[8]/cm); //B/2;
184  pars.push_back(dpar[0]/cm); //h/2;
185  pars.push_back(numbOfStrips.doubles()[0]); //h/2;
186 
187 #ifdef LOCAL_DEBUG
188  std::cout <<"Forward "<<name
189  <<" par "<<dpar[4]/cm
190  <<" "<<dpar[8]/cm<<" "<<dpar[3]/cm<<" "
191  <<dpar[0];
192 #endif
193 
194  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap,name,pars);
195 
196  //Change of axes for the forward
197  Basic3DVector<float> newX(1.,0.,0.);
198  Basic3DVector<float> newY(0.,0.,1.);
199  // if (tran.z() > 0. )
200  newY *= -1;
201  Basic3DVector<float> newZ(0.,1.,0.);
202  rot.rotateAxes (newX, newY,newZ);
203 
204  }
205 #ifdef LOCAL_DEBUG
206  std::cout <<" Number of strips "<<nStrips<<std::endl;
207 #endif
208 
209 
210 
211  BoundPlane* bp = new BoundPlane(pos,rot,bounds);
213  RPCRoll* r=new RPCRoll(rpcid,surf,rollspecs);
214  geometry->add(r);
215 
216 
217  std::list<RPCRoll *> rls;
218  if (chids.find(chid)!=chids.end()){
219  rls = chids[chid];
220  }
221  rls.push_back(r);
222  chids[chid]=rls;
223 
224  doSubDets = fview.nextSibling(); // go to next layer
225  }
226  // Create the RPCChambers and store them on the Geometry
227  for( std::map<RPCDetId, std::list<RPCRoll *> >::iterator ich=chids.begin();
228  ich != chids.end(); ich++){
229  RPCDetId chid = ich->first;
230  std::list<RPCRoll * > rls = ich->second;
231 
232  // compute the overall boundplane. At the moment we use just the last
233  // surface
234  BoundPlane* bp=0;
235  for(std::list<RPCRoll *>::iterator rl=rls.begin();
236  rl!=rls.end(); rl++){
237  const BoundPlane& bps = (*rl)->surface();
238  bp = const_cast<BoundPlane *>(&bps);
239  }
240 
242  // Create the chamber
243  RPCChamber* ch = new RPCChamber (chid, surf);
244  // Add the rolls to rhe chamber
245  for(std::list<RPCRoll *>::iterator rl=rls.begin();
246  rl!=rls.end(); rl++){
247  ch->add(*rl);
248  }
249  // Add the chamber to the geometry
250  geometry->add(ch);
251  }
252  return geometry;
253 }
254 
255 
256 
const std::vector< double > & parameters() const
Don&#39;t use (only meant to be used by DDbox(), DDtub(), ...)
Definition: DDSolid.cc:153
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
Definition: RPCChamber.cc:50
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:151
void addFilter(const DDFilter &, log_op op=AND)
const N & name() const
Definition: DDBase.h:88
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
type of data representation of DDCompactView
Definition: DDCompactView.h:81
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:102
void add(RPCRoll *roll)
Add a RPC roll to the Geometry.
Definition: RPCGeometry.cc:76
TkRotation & rotateAxes(const Basic3DVector< T > &newX, const Basic3DVector< T > &newY, const Basic3DVector< T > &newZ)
dictionary map
Definition: Association.py:160
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
RPCGeometry * buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants)
Definition: DDAxes.h:10
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:74
std::map< RPCDetId, std::list< RPCRoll * > > chids
virtual int baseNumberToUnitNumber(const MuonBaseNumber)
int layer() const
Definition: RPCDetId.h:110
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:104
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:116
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
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
tuple cout
Definition: gather_cfg.py:41
Definition: Bounds.h:18
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
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:65
int station() const
Definition: RPCDetId.h:98
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37