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 
28 RPCGeometryBuilderFromCondDB::RPCGeometryBuilderFromCondDB(bool comp11) : theComp11Flag(comp11) {}
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 (dpar.size()==4){
61  if (rgeo.shapeEnd(id) - shapeStart == 4) {
62  const float width = *(shapeStart + 0) / cm;
63  const float length = *(shapeStart + 1) / cm;
64  const float thickness = *(shapeStart + 2) / cm;
65  const float nstrip = *(shapeStart + 3);
66  //RectangularPlaneBounds*
67  bounds = new RectangularPlaneBounds(width, length, thickness);
68  const std::vector<float> pars = {width, length, nstrip};
69 
70  if (!theComp11Flag) {
71  //Correction of the orientation to get the REAL geometry.
72  //Change of axes for the +z part only.
73  //Including the 0 whell
74  if (*(tranStart + 2) > -1500.) { //tran[2] >-1500. ){
75  Basic3DVector<float> newX(-1., 0., 0.);
76  Basic3DVector<float> newY(0., -1., 0.);
77  Basic3DVector<float> newZ(0., 0., 1.);
78  rot.rotateAxes(newX, newY, newZ);
79  }
80  }
81 
82  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel, name, pars);
83 
84  } else {
85  const float be = *(shapeStart + 0) / cm;
86  const float te = *(shapeStart + 1) / cm;
87  const float ap = *(shapeStart + 2) / cm;
88  const float ti = *(shapeStart + 3) / cm;
89  const float nstrip = *(shapeStart + 4);
90  // TrapezoidalPlaneBounds*
91  bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
92  const std::vector<float> pars = {be /*b/2*/, te /*B/2*/, ap /*h/2*/, nstrip};
93 
94  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap, name, pars);
95 
96  //Change of axes for the forward
97  Basic3DVector<float> newX(1., 0., 0.);
98  Basic3DVector<float> newY(0., 0., 1.);
99  // if (tran[2] > 0. )
100  newY *= -1;
101  Basic3DVector<float> newZ(0., 1., 0.);
102  rot.rotateAxes(newX, newY, newZ);
103  }
104 
105  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
107  RPCRoll* r = new RPCRoll(rpcid, surf, rollspecs);
108  geometry->add(r);
109 
110  auto rls = chids.find(chid);
111  if (rls == chids.end())
112  rls = chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
113  rls->second.emplace_back(r);
114  }
115 
116  // Create the RPCChambers and store them on the Geometry
117  for (auto& ich : chids) {
118  const RPCDetId& chid = ich.first;
119  const auto& rls = ich.second;
120 
121  // compute the overall boundplane.
122  BoundPlane* bp = nullptr;
123  if (!rls.empty()) {
124  // First set the baseline plane to calculate relative poisions
125  const auto& refSurf = (*rls.begin())->surface();
126  if (chid.region() == 0) {
127  float corners[6] = {0, 0, 0, 0, 0, 0};
128  for (auto rl : rls) {
129  const double h2 = rl->surface().bounds().length() / 2;
130  const double w2 = rl->surface().bounds().width() / 2;
131  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-w2, -h2, 0)));
132  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+w2, +h2, 0)));
133  corners[0] = std::min(corners[0], x1y1AtRef.x());
134  corners[1] = std::min(corners[1], x1y1AtRef.y());
135  corners[2] = std::max(corners[2], x2y2AtRef.x());
136  corners[3] = std::max(corners[3], x2y2AtRef.y());
137 
138  corners[4] = std::min(corners[4], x1y1AtRef.z());
139  corners[5] = std::max(corners[5], x1y1AtRef.z());
140  }
141  const LocalPoint lpOfCentre((corners[0] + corners[2]) / 2, (corners[1] + corners[3]) / 2, 0);
142  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
143  auto bounds = new RectangularPlaneBounds(
144  (corners[2] - corners[0]) / 2, (corners[3] - corners[1]) / 2, (corners[5] - corners[4]) + 0.5);
145  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
146  } else {
147  float cornersLo[3] = {0, 0, 0}, cornersHi[3] = {0, 0, 0};
148  float cornersZ[2] = {0, 0};
149  for (auto rl : rls) {
150  const double h2 = rl->surface().bounds().length() / 2;
151  const double w2 = rl->surface().bounds().width() / 2;
152  const auto& topo = dynamic_cast<const TrapezoidalStripTopology&>(rl->specificTopology());
153  const double r = topo.radius();
154  const double wAtLo = w2 / r * (r - h2); // tan(theta/2) = (w/2)/r = x/(r-h/2)
155  const double wAtHi = w2 / r * (r + h2);
156 
157  const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtLo, -h2, 0)));
158  const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtLo, -h2, 0)));
159  const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(-wAtHi, +h2, 0)));
160  const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(LocalPoint(+wAtHi, +h2, 0)));
161 
162  cornersLo[0] = std::min(cornersLo[0], x1y1AtRef.x());
163  cornersLo[1] = std::max(cornersLo[1], x2y1AtRef.x());
164  cornersLo[2] = std::min(cornersLo[2], x1y1AtRef.y());
165 
166  cornersHi[0] = std::min(cornersHi[0], x1y2AtRef.x());
167  cornersHi[1] = std::max(cornersHi[1], x2y2AtRef.x());
168  cornersHi[2] = std::max(cornersHi[2], x1y2AtRef.y());
169 
170  cornersZ[0] = std::min(cornersZ[0], x1y1AtRef.z());
171  cornersZ[1] = std::max(cornersZ[1], x1y1AtRef.z());
172  }
173  const LocalPoint lpOfCentre((cornersHi[0] + cornersHi[1]) / 2, (cornersLo[2] + cornersHi[2]) / 2, 0);
174  const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
175  auto bounds = new TrapezoidalPlaneBounds((cornersLo[1] - cornersLo[0]) / 2,
176  (cornersHi[1] - cornersHi[0]) / 2,
177  (cornersHi[2] - cornersLo[2]) / 2,
178  (cornersZ[1] - cornersZ[0]) + 0.5);
179  bp = new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
180  }
181  }
182 
184  // Create the chamber
185  RPCChamber* ch = new RPCChamber(chid, surf);
186  // Add the rolls to rhe chamber
187  for (auto rl : rls)
188  ch->add(rl);
189  // Add the chamber to the geometry
190  geometry->add(ch);
191  }
192  return geometry;
193 }
RPCRoll
Definition: RPCRoll.h:12
TkRotation< float >
RPCGeometryBuilderFromCondDB::theComp11Flag
bool theComp11Flag
Definition: RPCGeometryBuilderFromCondDB.h:30
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
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 >
RPCGeometryBuilderFromCondDB::RPCGeometryBuilderFromCondDB
RPCGeometryBuilderFromCondDB(bool comp11)
Definition: RPCGeometryBuilderFromCondDB.cc:28
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
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
MuonDDDNumbering.h
RPCDetId::layer
int layer() const
Definition: RPCDetId.h:85
RPCGeometry.h
Basic3DVector< float >
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28