CMS 3D CMS Logo

RPCGeometryBuilderFromCondDB.cc
Go to the documentation of this file.
1 
8 
12 
16 
20 
22 
23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
24 
25 #include <iostream>
26 #include <algorithm>
27 
29 
31 
33  const std::vector<DetId>& detids(rgeo.detIds());
35 
36  for (unsigned int id = 0; id < detids.size(); ++id) {
37  RPCDetId rpcid(detids[id]);
38  RPCDetId chid(rpcid.region(), rpcid.ring(), rpcid.station(), rpcid.sector(), rpcid.layer(), rpcid.subsector(), 0);
39 
40  const auto tranStart = rgeo.tranStart(id);
41  const auto shapeStart = rgeo.shapeStart(id);
42  const auto rotStart = rgeo.rotStart(id);
43  const std::string& name = *rgeo.strStart(id);
44 
45  Surface::PositionType pos(*(tranStart) / cm, *(tranStart + 1) / cm, *(tranStart + 2) / cm);
46  // CLHEP way
47  Surface::RotationType rot(*(rotStart + 0),
48  *(rotStart + 1),
49  *(rotStart + 2),
50  *(rotStart + 3),
51  *(rotStart + 4),
52  *(rotStart + 5),
53  *(rotStart + 6),
54  *(rotStart + 7),
55  *(rotStart + 8));
56 
57  RPCRollSpecs* rollspecs = nullptr;
58  Bounds* bounds = nullptr;
59 
60  if (rgeo.shapeEnd(id) - shapeStart == 4) {
61  const float width = *(shapeStart + 0) / cm;
62  const float length = *(shapeStart + 1) / cm;
63  const float thickness = *(shapeStart + 2) / cm;
64  const float nstrip = *(shapeStart + 3);
65 
66  bounds = new RectangularPlaneBounds(width, length, thickness);
67  const std::vector<float> pars = {width, length, nstrip};
68 
69  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel, name, pars);
70 
71  } else {
72  const float be = *(shapeStart + 0) / cm;
73  const float te = *(shapeStart + 1) / cm;
74  const float ap = *(shapeStart + 2) / cm;
75  const float ti = *(shapeStart + 3) / cm;
76  const float nstrip = *(shapeStart + 4);
77 
78  bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
79  const std::vector<float> pars = {be, te, ap, nstrip};
80 
81  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap, name, pars);
82 
83  //Change of axes for the forward
84  Basic3DVector<float> newX(1., 0., 0.);
85  Basic3DVector<float> newY(0., 0., 1.);
86 
87  newY *= -1;
88  Basic3DVector<float> newZ(0., 1., 0.);
89  rot.rotateAxes(newX, newY, newZ);
90  }
91 
92  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
94  RPCRoll* r = new RPCRoll(rpcid, surf, rollspecs);
95  geometry->add(r);
96 
97  auto rls = chids.find(chid);
98  if (rls == chids.end())
99  rls = chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
100  rls->second.emplace_back(r);
101  }
102 
103  // Create the RPCChambers and store them on the Geometry
104  for (auto& ich : chids) {
105  const RPCDetId& chid = ich.first;
106  const auto& rls = ich.second;
107 
108  // compute the overall boundplane.
109  BoundPlane* bp = nullptr;
110  if (!rls.empty()) {
111  // First set the baseline plane to calculate relative poisions
112  const auto& refSurf = (*rls.begin())->surface();
113  if (chid.region() == 0) {
114  float corners[6] = {0, 0, 0, 0, 0, 0};
115  for (auto rl : rls) {
116  const double h2 = rl->surface().bounds().length() / 2;
117  const double w2 = rl->surface().bounds().width() / 2;
118  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-w2, -h2, 0)));
119  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+w2, +h2, 0)));
120  corners[0] = std::min(corners[0], x1y1AtRef.x());
121  corners[1] = std::min(corners[1], x1y1AtRef.y());
122  corners[2] = std::max(corners[2], x2y2AtRef.x());
123  corners[3] = std::max(corners[3], x2y2AtRef.y());
124 
125  corners[4] = std::min(corners[4], x1y1AtRef.z());
126  corners[5] = std::max(corners[5], x1y1AtRef.z());
127  }
128  const LocalPoint lpOfCentre((corners[0] + corners[2]) / 2, (corners[1] + corners[3]) / 2, 0);
129  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
130  auto bounds = new RectangularPlaneBounds(
131  (corners[2] - corners[0]) / 2, (corners[3] - corners[1]) / 2, (corners[5] - corners[4]) + 0.5);
132  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
133  } else {
134  float cornersLo[3] = {0, 0, 0}, cornersHi[3] = {0, 0, 0};
135  float cornersZ[2] = {0, 0};
136  for (auto rl : rls) {
137  const double h2 = rl->surface().bounds().length() / 2;
138  const double w2 = rl->surface().bounds().width() / 2;
139  const auto& topo = dynamic_cast<const TrapezoidalStripTopology&>(rl->specificTopology());
140  const double r = topo.radius();
141  const double wAtLo = w2 / r * (r - h2);
142  const double wAtHi = w2 / r * (r + h2);
143 
144  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtLo, -h2, 0)));
145  const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtLo, -h2, 0)));
146  const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtHi, +h2, 0)));
147  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtHi, +h2, 0)));
148 
149  cornersLo[0] = std::min(cornersLo[0], x1y1AtRef.x());
150  cornersLo[1] = std::max(cornersLo[1], x2y1AtRef.x());
151  cornersLo[2] = std::min(cornersLo[2], x1y1AtRef.y());
152 
153  cornersHi[0] = std::min(cornersHi[0], x1y2AtRef.x());
154  cornersHi[1] = std::max(cornersHi[1], x2y2AtRef.x());
155  cornersHi[2] = std::max(cornersHi[2], x1y2AtRef.y());
156 
157  cornersZ[0] = std::min(cornersZ[0], x1y1AtRef.z());
158  cornersZ[1] = std::max(cornersZ[1], x1y1AtRef.z());
159  }
160  const LocalPoint lpOfCentre((cornersHi[0] + cornersHi[1]) / 2, (cornersLo[2] + cornersHi[2]) / 2, 0);
161  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
162  auto bounds = new TrapezoidalPlaneBounds((cornersLo[1] - cornersLo[0]) / 2,
163  (cornersHi[1] - cornersHi[0]) / 2,
164  (cornersHi[2] - cornersLo[2]) / 2,
165  (cornersZ[1] - cornersZ[0]) + 0.5);
166  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
167  }
168  }
169 
171  // Create the chamber
172  RPCChamber* ch = new RPCChamber(chid, surf);
173  // Add the rolls to rhe chamber
174  for (auto rl : rls)
175  ch->add(rl);
176  // Add the chamber to the geometry
177  geometry->add(ch);
178  }
179  return geometry;
180 }
RPCRoll
Definition: RPCRoll.h:12
TkRotation< float >
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
w2
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
GeomDetEnumerators::RPCEndcap
Definition: GeomDetEnumerators.h:20
RPCDetId::subsector
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel,...
Definition: RPCDetId.h:88
RPCRollSpecs
Definition: RPCRollSpecs.h:18
min
T min(T a, T b)
Definition: MathUtil.h:58
MuonGeometryConstants.h
RPCDetId
Definition: RPCDetId.h:16
geometry
Definition: geometry.py:1
pos
Definition: PixelAliasList.h:18
RPCGeometryBuilderFromCondDB.h
Basic3DVector.h
Bounds
Definition: Bounds.h:18
RPCGeometryBuilderFromCondDB::chids
std::map< RPCDetId, std::list< RPCRoll * > > chids
Definition: RPCGeometryBuilderFromCondDB.h:29
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
RPCChamber
Definition: RPCChamber.h:19
Bounds::length
virtual float length() const =0
RecoIdealGeometry::shapeEnd
std::vector< double >::const_iterator shapeEnd(size_t ind) const
Definition: RecoIdealGeometry.h:97
RecoIdealGeometry::rotStart
std::vector< double >::const_iterator rotStart(size_t ind) const
Definition: RecoIdealGeometry.h:91
DDFilteredView.h
TrapezoidalPlaneBounds.h
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:114
RPCNumberingScheme.h
RPCGeometryBuilderFromCondDB::build
RPCGeometry * build(const RecoIdealGeometry &rgeo)
Definition: RPCGeometryBuilderFromCondDB.cc:32
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
RectangularPlaneBounds.h
DDSolid.h
Point3DBase< float, GlobalTag >
RPCChamber::add
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
Definition: RPCChamber.cc:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCGeometryBuilderFromCondDB::~RPCGeometryBuilderFromCondDB
~RPCGeometryBuilderFromCondDB()
Definition: RPCGeometryBuilderFromCondDB.cc:30
RPCGeometryBuilderFromCondDB::RPCGeometryBuilderFromCondDB
RPCGeometryBuilderFromCondDB()
Definition: RPCGeometryBuilderFromCondDB.cc:28
RPCRollSpecs.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MuonBaseNumber.h
RecoIdealGeometry::detIds
const std::vector< DetId > & detIds() const
Definition: RecoIdealGeometry.h:85
DDFilter.h
TrapezoidalPlaneBounds
Definition: TrapezoidalPlaneBounds.h:15
RecoIdealGeometry::tranStart
std::vector< double >::const_iterator tranStart(size_t ind) const
Definition: RecoIdealGeometry.h:87
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
alignCSCRings.r
r
Definition: alignCSCRings.py:93
RectangularPlaneBounds
Definition: RectangularPlaneBounds.h:12
BoundPlane
Plane BoundPlane
Definition: Plane.h:94
TrapezoidalStripTopology.h
RecoIdealGeometry::strStart
std::vector< std::string >::const_iterator strStart(size_t ind) const
Definition: RecoIdealGeometry.h:101
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
BoundPlane
RPCDetId::sector
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
RecoIdealGeometry::shapeStart
std::vector< double >::const_iterator shapeStart(size_t ind) const
Definition: RecoIdealGeometry.h:95
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
GeomDetEnumerators::RPCBarrel
Definition: GeomDetEnumerators.h:19
RPCGeometry
Definition: RPCGeometry.h:20
cms::cuda::be
int be
Definition: HistoContainer.h:126
RPCDetId::layer
int layer() const
Definition: RPCDetId.h:85
RPCGeometry.h
Basic3DVector< float >
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28