CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RPCGeometryBuilderFromDDD Class Reference

#include <RPCGeometryBuilderFromDDD.h>

Public Member Functions

RPCGeometrybuild (const DDCompactView *cview, const MuonDDDConstants &muonConstants)
 
 RPCGeometryBuilderFromDDD (bool comp11)
 
 ~RPCGeometryBuilderFromDDD ()
 

Private Member Functions

RPCGeometrybuildGeometry (DDFilteredView &fview, const MuonDDDConstants &muonConstants)
 

Private Attributes

std::map< RPCDetId, std::list< RPCRoll * > > chids
 
bool theComp11Flag
 

Detailed Description

Build the RPCGeometry ftom the DDD description

Author
Port of: MuDDDRPCBuilder, MuonRPCGeometryBuilder (ORCA)
M. Maggi - INFN Bari

Definition at line 23 of file RPCGeometryBuilderFromDDD.h.

Constructor & Destructor Documentation

RPCGeometryBuilderFromDDD::RPCGeometryBuilderFromDDD ( bool  comp11)

Implementation of the RPC Geometry Builder from DDD

Author
Port of: MuDDDRPCBuilder (ORCA)
M. Maggi - INFN Bari

Definition at line 29 of file RPCGeometryBuilderFromDDD.cc.

RPCGeometryBuilderFromDDD::~RPCGeometryBuilderFromDDD ( )

Definition at line 32 of file RPCGeometryBuilderFromDDD.cc.

33 { }

Member Function Documentation

RPCGeometry * RPCGeometryBuilderFromDDD::build ( const DDCompactView cview,
const MuonDDDConstants muonConstants 
)

Definition at line 35 of file RPCGeometryBuilderFromDDD.cc.

References buildGeometry(), ALCARECOTkAlBeamHalo_cff::filter, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by RPCGeometryESModule::produce().

36 {
37  const std::string attribute = "ReadOutName"; // could come from .orcarc
38  const std::string value = "MuonRPCHits"; // could come from .orcarc
39 
40  // Asking only for the MuonRPC's
41  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
42  DDFilteredView fview(*cview,filter);
43 
44  return this->buildGeometry(fview, muonConstants);
45 }
RPCGeometry * buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants)
Definition: value.py:1
RPCGeometry * RPCGeometryBuilderFromDDD::buildGeometry ( DDFilteredView fview,
const MuonDDDConstants muonConstants 
)
private

Definition at line 47 of file RPCGeometryBuilderFromDDD.cc.

References RPCChamber::add(), RPCGeometry::add(), RPCNumberingScheme::baseNumberToUnitNumber(), Surface::bounds(), chids, DDfetch(), DDValue::doubles(), DDFilteredView::firstChild(), objects.autophobj::float, DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), geometry, createfilelist::int, RPCDetId::layer(), Bounds::length(), LogDebug, DDFilteredView::logicalPart(), SiStripPI::max, min(), DDName::name(), dataset::name, DDBase< N, C >::name(), DDFilteredView::nextSibling(), DDSolid::parameters(), alignCSCRings::r, RPCDetId::region(), RPCDetId::ring(), makeMuonMisalignmentScenario::rot, TkRotation< T >::rotateAxes(), DDFilteredView::rotation(), GeomDetEnumerators::RPCBarrel, GeomDetEnumerators::RPCEndcap, RPCDetId::sector(), DDLogicalPart::solid(), DDFilteredView::specifics(), SiPixelPhase1DigisV_cfi::specs, RPCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, RPCDetId::subsector(), theComp11Flag, DDFilteredView::translation(), w2, ApeEstimator_cff::width, x, y, and z.

Referenced by build().

48 {
49  LogDebug("RPCGeometryBuilderFromDDD") <<"Building the geometry service";
51 
52  LogDebug("RPCGeometryBuilderFromDDD") << "About to run through the RPC structure\n"
53  <<" First logical part "
54  <<fview.logicalPart().name().name();
55  bool doSubDets = fview.firstChild();
56 
57  LogDebug("RPCGeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
58  while (doSubDets){
59  LogDebug("RPCGeometryBuilderFromDDD") <<"start the loop";
60 
61  // Get the Base Muon Number
62  MuonDDDNumbering mdddnum(muonConstants);
63  LogDebug("RPCGeometryBuilderFromDDD") <<"Getting the Muon base Number";
64  MuonBaseNumber mbn=mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
65  LogDebug("RPCGeometryBuilderFromDDD") <<"Start the Rpc Numbering Schema";
66  // Get the The Rpc det Id
67  RPCNumberingScheme rpcnum(muonConstants);
68 
69  LogDebug("RPCGeometryBuilderFromDDD") <<"Getting the Unit Number";
70  const int detid = rpcnum.baseNumberToUnitNumber(mbn);
71  LogDebug("RPCGeometryBuilderFromDDD") <<"Getting the RPC det Id "<<detid;
72 
73  RPCDetId rpcid(detid);
74  RPCDetId chid(rpcid.region(),rpcid.ring(),rpcid.station(),rpcid.sector(),rpcid.layer(),rpcid.subsector(),0);
75 
76  LogDebug("RPCGeometryBuilderFromDDD") <<"The RPCDetid is "<<rpcid;
77 
78  DDValue numbOfStrips("nStrips");
79 
80  std::vector<const DDsvalues_type* > specs(fview.specifics());
81  int nStrips=0;
82  for (auto & spec : specs){
83  if (DDfetch( spec, numbOfStrips)){
84  nStrips=int(numbOfStrips.doubles()[0]);
85  }
86  }
87 
88  LogDebug("RPCGeometryBuilderFromDDD") << ((nStrips == 0 ) ? ("No strip found!!") : (""));
89 
90  std::vector<double> dpar=fview.logicalPart().solid().parameters();
91  std::string name=fview.logicalPart().name().name();
92  DDTranslation tran = fview.translation();
93  //removed .Inverse after comparing to DT...
94  DDRotationMatrix rota = fview.rotation();//.Inverse();
95  Surface::PositionType pos(tran.x()/cm,tran.y()/cm, tran.z()/cm);
96  // CLHEP way
97  // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
98  // rota.yx(),rota.yy(),rota.yz(),
99  // rota.zx(),rota.zy(),rota.zz());
100 
101  //ROOT::Math way
102  DD3Vector x, y, z;
103  rota.GetComponents(x,y,z);
104  // doesn't this just re-inverse???
105  Surface::RotationType rot (float(x.X()),float(x.Y()),float(x.Z()),
106  float(y.X()),float(y.Y()),float(y.Z()),
107  float(z.X()),float(z.Y()),float(z.Z()));
108 
109  RPCRollSpecs* rollspecs= nullptr;
110  Bounds* bounds = nullptr;
111 
112  if (dpar.size()==3){
113  const float width = dpar[0]/cm;
114  const float length = dpar[1]/cm;
115  const float thickness = dpar[2]/cm;
116  //RectangularPlaneBounds*
117  bounds = new RectangularPlaneBounds(width,length,thickness);
118  const std::vector<float> pars = {width, length, float(numbOfStrips.doubles()[0]) /*h/2*/};
119 
120  if (!theComp11Flag) {
121  //Correction of the orientation to get the REAL geometry.
122  //Change of axes for the +z part only.
123  //Including the 0 wheel
124  if (tran.z() >-1500. ){
125  Basic3DVector<float> newX(-1.,0.,0.);
126  Basic3DVector<float> newY(0.,-1.,0.);
127  Basic3DVector<float> newZ(0.,0.,1.);
128  rot.rotateAxes(newX, newY,newZ);
129  }
130  }
131 
132  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel,name,pars);
133  LogDebug("RPCGeometryBuilderFromDDD") <<"Barrel "<<name
134  <<" par "<<width
135  <<" "<<length<<" "<<thickness;
136  }
137  else {
138  const float be = dpar[4]/cm;
139  const float te = dpar[8]/cm;
140  const float ap = dpar[0]/cm;
141  const float ti = 0.4/cm;
142  // TrapezoidalPlaneBounds*
143  bounds = new TrapezoidalPlaneBounds(be,te,ap,ti);
144  const std::vector<float> pars = {float(dpar[4]/cm) /*b/2*/, float(dpar[8]/cm) /*B/2*/,
145  float(dpar[0]/cm) /*h/2*/, float(numbOfStrips.doubles()[0]) /*h/2*/};
146 
147  LogDebug("RPCGeometryBuilderFromDDD") <<"Forward "<<name
148  <<" par "<<dpar[4]/cm
149  <<" "<<dpar[8]/cm<<" "<<dpar[3]/cm<<" "
150  <<dpar[0];
151 
152  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap,name,pars);
153 
154  //Change of axes for the forward
155  Basic3DVector<float> newX(1.,0.,0.);
156  Basic3DVector<float> newY(0.,0.,1.);
157  // if (tran.z() > 0. )
158  newY *= -1;
159  Basic3DVector<float> newZ(0.,1.,0.);
160  rot.rotateAxes (newX, newY,newZ);
161  }
162  LogDebug("RPCGeometryBuilderFromDDD") <<" Number of strips "<<nStrips;
163 
164  BoundPlane* bp = new BoundPlane(pos,rot,bounds);
166  RPCRoll* r=new RPCRoll(rpcid,surf,rollspecs);
167  geometry->add(r);
168 
169  auto rls = chids.find(chid);
170  if ( rls == chids.end() ) rls = chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
171  rls->second.emplace_back(r);
172 
173  doSubDets = fview.nextSibling(); // go to next layer
174  }
175  // Create the RPCChambers and store them on the Geometry
176  for (auto & ich : chids) {
177  const RPCDetId& chid = ich.first;
178  const auto& rls = ich.second;
179 
180  // compute the overall boundplane.
181  BoundPlane* bp=nullptr;
182  if ( !rls.empty() ) {
183  // First set the baseline plane to calculate relative poisions
184  const auto& refSurf = (*rls.begin())->surface();
185  if ( chid.region() == 0 ) {
186  float corners[6] = {0,0,0,0,0,0};
187  for ( auto rl : rls ) {
188  const double h2 = rl->surface().bounds().length()/2;
189  const double w2 = rl->surface().bounds().width()/2;
190  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-w2,-h2,0)));
191  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+w2,+h2,0)));
192  corners[0] = std::min(corners[0], x1y1AtRef.x());
193  corners[1] = std::min(corners[1], x1y1AtRef.y());
194  corners[2] = std::max(corners[2], x2y2AtRef.x());
195  corners[3] = std::max(corners[3], x2y2AtRef.y());
196 
197  corners[4] = std::min(corners[4], x1y1AtRef.z());
198  corners[5] = std::max(corners[5], x1y1AtRef.z());
199  }
200  const LocalPoint lpOfCentre((corners[0]+corners[2])/2, (corners[1]+corners[3])/2, 0);
201  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
202  auto bounds = new RectangularPlaneBounds((corners[2]-corners[0])/2, (corners[3]-corners[1])/2, (corners[5]-corners[4])+0.5);
203  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
204  }
205  else {
206  float cornersLo[3] = {0,0,0}, cornersHi[3] = {0,0,0};
207  float cornersZ[2] = {0,0};
208  for ( auto rl : rls ) {
209  const double h2 = rl->surface().bounds().length()/2;
210  const double w2 = rl->surface().bounds().width()/2;
211  const auto& topo = dynamic_cast<const TrapezoidalStripTopology&>(rl->specificTopology());
212  const double r = topo.radius();
213  const double wAtLo = w2/r*(r-h2); // tan(theta/2) = (w/2)/r = x/(r-h/2)
214  const double wAtHi = w2/r*(r+h2);
215 
216  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtLo, -h2, 0)));
217  const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtLo, -h2, 0)));
218  const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtHi, +h2, 0)));
219  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtHi, +h2, 0)));
220 
221  cornersLo[0] = std::min(cornersLo[0], x1y1AtRef.x());
222  cornersLo[1] = std::max(cornersLo[1], x2y1AtRef.x());
223  cornersLo[2] = std::min(cornersLo[2], x1y1AtRef.y());
224 
225  cornersHi[0] = std::min(cornersHi[0], x1y2AtRef.x());
226  cornersHi[1] = std::max(cornersHi[1], x2y2AtRef.x());
227  cornersHi[2] = std::max(cornersHi[2], x1y2AtRef.y());
228 
229  cornersZ[0] = std::min(cornersZ[0], x1y1AtRef.z());
230  cornersZ[1] = std::max(cornersZ[1], x1y1AtRef.z());
231  }
232  const LocalPoint lpOfCentre((cornersHi[0]+cornersHi[1])/2, (cornersLo[2]+cornersHi[2])/2, 0);
233  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
234  auto bounds = new TrapezoidalPlaneBounds((cornersLo[1]-cornersLo[0])/2, (cornersHi[1]-cornersHi[0])/2, (cornersHi[2]-cornersLo[2])/2, (cornersZ[1]-cornersZ[0])+0.5);
235  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
236  }
237  }
238 
240  // Create the chamber
241  RPCChamber* ch = new RPCChamber (chid, surf);
242  // Add the rolls to rhe chamber
243  for ( auto rl : rls ) ch->add(rl);
244  // Add the chamber to the geometry
245  geometry->add(ch);
246 
247  }
248  return geometry;
249 }
#define LogDebug(id)
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
virtual float length() const =0
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const N & name() const
Definition: DDBase.h:78
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
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
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
const Bounds & bounds() const
Definition: Surface.h:120
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
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:81
void add(RPCRoll *roll)
Add a RPC roll to the Geometry.
Definition: RPCGeometry.cc:81
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
std::map< RPCDetId, std::list< RPCRoll * > > chids
T min(T a, T b)
Definition: MathUtil.h:58
ESHandle< TrackerGeometry > geometry
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
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
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63

Member Data Documentation

std::map<RPCDetId,std::list<RPCRoll *> > RPCGeometryBuilderFromDDD::chids
private

Definition at line 36 of file RPCGeometryBuilderFromDDD.h.

Referenced by buildGeometry().

bool RPCGeometryBuilderFromDDD::theComp11Flag
private

Definition at line 38 of file RPCGeometryBuilderFromDDD.h.

Referenced by buildGeometry().