CMS 3D CMS Logo

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

#include <RPCGeometryBuilderFromCondDB.h>

Public Member Functions

RPCGeometrybuild (const RecoIdealGeometry &rgeo)
 
 RPCGeometryBuilderFromCondDB ()
 
 ~RPCGeometryBuilderFromCondDB ()
 

Private Attributes

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

Detailed Description

Build the RPCGeometry from the DDD description stored in Condition DB

Author
M. Maggi - INFN Bari

Definition at line 20 of file RPCGeometryBuilderFromCondDB.h.

Constructor & Destructor Documentation

◆ RPCGeometryBuilderFromCondDB()

RPCGeometryBuilderFromCondDB::RPCGeometryBuilderFromCondDB ( )

Definition at line 30 of file RPCGeometryBuilderFromCondDB.cc.

30 {}

◆ ~RPCGeometryBuilderFromCondDB()

RPCGeometryBuilderFromCondDB::~RPCGeometryBuilderFromCondDB ( )

Definition at line 32 of file RPCGeometryBuilderFromCondDB.cc.

32 {}

Member Function Documentation

◆ build()

RPCGeometry * RPCGeometryBuilderFromCondDB::build ( const RecoIdealGeometry rgeo)

Definition at line 34 of file RPCGeometryBuilderFromCondDB.cc.

References RPCChamber::add(), cms::cuda::be, Surface::bounds(), chids, RecoIdealGeometry::detIds(), relativeConstraints::geometry, l1ctLayer2EG_cff::id, RPCDetId::layer(), Bounds::length(), SiStripPI::max, SiStripPI::min, Skims_PA_cff::name, alignCSCRings::r, RPCDetId::region(), RPCDetId::ring(), makeMuonMisalignmentScenario::rot, RecoIdealGeometry::rotStart(), GeomDetEnumerators::RPCBarrel, GeomDetEnumerators::RPCEndcap, RPCDetId::sector(), RecoIdealGeometry::shapeEnd(), RecoIdealGeometry::shapeStart(), RPCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, RecoIdealGeometry::strStart(), RPCDetId::subsector(), Calorimetry_cff::thickness, RecoIdealGeometry::tranStart(), w2, and ApeEstimator_cff::width.

Referenced by RPCGeometryESModule::produce().

34  {
35  const std::vector<DetId>& detids(rgeo.detIds());
37 
38  for (unsigned int id = 0; id < detids.size(); ++id) {
39  RPCDetId rpcid(detids[id]);
40  RPCDetId chid(rpcid.region(), rpcid.ring(), rpcid.station(), rpcid.sector(), rpcid.layer(), rpcid.subsector(), 0);
41 
42  const auto tranStart = rgeo.tranStart(id);
43  const auto shapeStart = rgeo.shapeStart(id);
44  const auto rotStart = rgeo.rotStart(id);
45  const std::string& name = *rgeo.strStart(id);
46 
47  Surface::PositionType pos(*(tranStart) / cm, *(tranStart + 1) / cm, *(tranStart + 2) / cm);
48  // CLHEP way
49  Surface::RotationType rot(*(rotStart + 0),
50  *(rotStart + 1),
51  *(rotStart + 2),
52  *(rotStart + 3),
53  *(rotStart + 4),
54  *(rotStart + 5),
55  *(rotStart + 6),
56  *(rotStart + 7),
57  *(rotStart + 8));
58 
59  RPCRollSpecs* rollspecs = nullptr;
60  Bounds* bounds = nullptr;
61 
62  if (rgeo.shapeEnd(id) - shapeStart == 4) {
63  const float width = *(shapeStart + 0) / cm;
64  const float length = *(shapeStart + 1) / cm;
65  const float thickness = *(shapeStart + 2) / cm;
66  const float nstrip = *(shapeStart + 3);
67 
69  const std::vector<float> pars = {width, length, nstrip};
70 
71  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel, name, pars);
72 
73  } else {
74  const float be = *(shapeStart + 0) / cm;
75  const float te = *(shapeStart + 1) / cm;
76  const float ap = *(shapeStart + 2) / cm;
77  const float ti = *(shapeStart + 3) / cm;
78  const float nstrip = *(shapeStart + 4);
79 
80  bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
81  const std::vector<float> pars = {be, te, ap, nstrip};
82 
83  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap, name, pars);
84 
85  //Change of axes for the forward
86  Basic3DVector<float> newX(1., 0., 0.);
87  Basic3DVector<float> newY(0., 0., 1.);
88 
89  newY *= -1;
90  Basic3DVector<float> newZ(0., 1., 0.);
91  rot.rotateAxes(newX, newY, newZ);
92  }
93 
94  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
96  RPCRoll* r = new RPCRoll(rpcid, surf, rollspecs);
97  geometry->add(r);
98 
99  auto rls = chids.find(chid);
100  if (rls == chids.end())
101  rls = chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
102  rls->second.emplace_back(r);
103  }
104 
105  // Create the RPCChambers and store them on the Geometry
106  for (auto& ich : chids) {
107  const RPCDetId& chid = ich.first;
108  const auto& rls = ich.second;
109 
110  // compute the overall boundplane.
111  BoundPlane* bp = nullptr;
112  if (!rls.empty()) {
113  // First set the baseline plane to calculate relative poisions
114  const auto& refSurf = (*rls.begin())->surface();
115  if (chid.region() == 0) {
116  float corners[6] = {0, 0, 0, 0, 0, 0};
117  for (auto rl : rls) {
118  const double h2 = rl->surface().bounds().length() / 2;
119  const double w2 = rl->surface().bounds().width() / 2;
120  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-w2, -h2, 0)));
121  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+w2, +h2, 0)));
122  corners[0] = std::min(corners[0], x1y1AtRef.x());
123  corners[1] = std::min(corners[1], x1y1AtRef.y());
124  corners[2] = std::max(corners[2], x2y2AtRef.x());
125  corners[3] = std::max(corners[3], x2y2AtRef.y());
126 
127  corners[4] = std::min(corners[4], x1y1AtRef.z());
128  corners[5] = std::max(corners[5], x1y1AtRef.z());
129  }
130  const LocalPoint lpOfCentre((corners[0] + corners[2]) / 2, (corners[1] + corners[3]) / 2, 0);
131  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
132  auto bounds = new RectangularPlaneBounds(
133  (corners[2] - corners[0]) / 2, (corners[3] - corners[1]) / 2, (corners[5] - corners[4]) + 0.5);
134  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
135  } else {
136  float cornersLo[3] = {0, 0, 0}, cornersHi[3] = {0, 0, 0};
137  float cornersZ[2] = {0, 0};
138  for (auto rl : rls) {
139  const double h2 = rl->surface().bounds().length() / 2;
140  const double w2 = rl->surface().bounds().width() / 2;
141  const auto& topo = dynamic_cast<const TrapezoidalStripTopology&>(rl->specificTopology());
142  const double r = topo.radius();
143  const double wAtLo = w2 / r * (r - h2);
144  const double wAtHi = w2 / r * (r + h2);
145 
146  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtLo, -h2, 0)));
147  const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtLo, -h2, 0)));
148  const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtHi, +h2, 0)));
149  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtHi, +h2, 0)));
150 
151  cornersLo[0] = std::min(cornersLo[0], x1y1AtRef.x());
152  cornersLo[1] = std::max(cornersLo[1], x2y1AtRef.x());
153  cornersLo[2] = std::min(cornersLo[2], x1y1AtRef.y());
154 
155  cornersHi[0] = std::min(cornersHi[0], x1y2AtRef.x());
156  cornersHi[1] = std::max(cornersHi[1], x2y2AtRef.x());
157  cornersHi[2] = std::max(cornersHi[2], x1y2AtRef.y());
158 
159  cornersZ[0] = std::min(cornersZ[0], x1y1AtRef.z());
160  cornersZ[1] = std::max(cornersZ[1], x1y1AtRef.z());
161  }
162  const LocalPoint lpOfCentre((cornersHi[0] + cornersHi[1]) / 2, (cornersLo[2] + cornersHi[2]) / 2, 0);
163  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
164  auto bounds = new TrapezoidalPlaneBounds((cornersLo[1] - cornersLo[0]) / 2,
165  (cornersHi[1] - cornersHi[0]) / 2,
166  (cornersHi[2] - cornersLo[2]) / 2,
167  (cornersZ[1] - cornersZ[0]) + 0.5);
168  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
169  }
170  }
171 
173  // Create the chamber
174  RPCChamber* ch = new RPCChamber(chid, surf);
175  // Add the rolls to rhe chamber
176  for (auto rl : rls)
177  ch->add(rl);
178  // Add the chamber to the geometry
179  geometry->add(ch);
180  }
181  return geometry;
182 }
std::vector< std::string >::const_iterator strStart(size_t ind) const
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
Definition: RPCChamber.cc:32
std::vector< double >::const_iterator shapeEnd(size_t ind) const
virtual float length() const =0
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
std::vector< double >::const_iterator rotStart(size_t ind) const
Plane BoundPlane
Definition: Plane.h:94
const std::vector< DetId > & detIds() const
std::map< RPCDetId, std::list< RPCRoll * > > chids
std::vector< double >::const_iterator shapeStart(size_t ind) const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
Definition: Bounds.h:18
std::vector< double >::const_iterator tranStart(size_t ind) const
const Bounds & bounds() const
Definition: Surface.h:87

Member Data Documentation

◆ chids

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

Definition at line 29 of file RPCGeometryBuilderFromCondDB.h.

Referenced by build().