37 const std::vector<DetId>& detids(rgeo.
detIds());
40 for (
unsigned int id=0;
id<detids.size(); ++
id){
42 RPCDetId chid(rpcid.region(),rpcid.ring(),rpcid.station(),
43 rpcid.sector(),rpcid.layer(),rpcid.subsector(),0);
45 const auto tranStart = rgeo.
tranStart(
id);
47 const auto rotStart = rgeo.
rotStart(
id);
53 *(rotStart+3),*(rotStart+4),*(rotStart+5),
54 *(rotStart+6),*(rotStart+7),*(rotStart+8));
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);
67 const std::vector<float> pars = {
width, length, nstrip};
73 if ( *(tranStart+2) > -1500.) {
77 rot.rotateAxes (newX, newY,newZ);
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);
92 const std::vector<float> pars = {be , te , ap , nstrip};
102 rot.rotateAxes (newX, newY,newZ);
110 auto rls =
chids.find(chid);
111 if ( rls ==
chids.end() ) rls =
chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
112 rls->second.emplace_back(r);
116 for (
auto & ich :
chids) {
118 const auto& rls = ich.second;
122 if ( !rls.empty() ) {
124 const auto& refSurf = (*rls.begin())->surface();
125 if ( chid.
region() == 0 ) {
126 float corners[6] = {0,0,0,0,0,0};
127 for (
auto rl : rls ) {
128 const double h2 = rl->surface().bounds().length()/2;
129 const double w2 = rl->surface().bounds().width()/2;
130 const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-w2,-h2,0)));
131 const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+w2,+h2,0)));
132 corners[0] =
std::min(corners[0], x1y1AtRef.x());
133 corners[1] =
std::min(corners[1], x1y1AtRef.y());
134 corners[2] =
std::max(corners[2], x2y2AtRef.x());
135 corners[3] =
std::max(corners[3], x2y2AtRef.y());
137 corners[4] =
std::min(corners[4], x1y1AtRef.z());
138 corners[5] =
std::max(corners[5], x1y1AtRef.z());
140 const LocalPoint lpOfCentre((corners[0]+corners[2])/2, (corners[1]+corners[3])/2, 0);
141 const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
142 auto bounds =
new RectangularPlaneBounds((corners[2]-corners[0])/2, (corners[3]-corners[1])/2, (corners[5]-corners[4])+0.5);
143 bp =
new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
146 float cornersLo[3] = {0,0,0}, cornersHi[3] = {0,0,0};
147 float cornersZ[2] = {0,0};
148 for (
auto rl : rls ) {
150 const double w2 = rl->surface().bounds().width()/2;
152 const double r = topo.radius();
153 const double wAtLo = w2/r*(r-h2);
154 const double wAtHi = w2/r*(r+h2);
156 const auto x1y1AtRef = refSurf.
toLocal(rl->toGlobal(
LocalPoint(-wAtLo, -h2, 0)));
157 const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+wAtLo, -h2, 0)));
158 const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-wAtHi, +h2, 0)));
159 const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+wAtHi, +h2, 0)));
161 cornersLo[0] =
std::min(cornersLo[0], x1y1AtRef.x());
162 cornersLo[1] =
std::max(cornersLo[1], x2y1AtRef.x());
163 cornersLo[2] =
std::min(cornersLo[2], x1y1AtRef.y());
165 cornersHi[0] =
std::min(cornersHi[0], x1y2AtRef.x());
166 cornersHi[1] =
std::max(cornersHi[1], x2y2AtRef.x());
167 cornersHi[2] =
std::max(cornersHi[2], x1y2AtRef.y());
169 cornersZ[0] =
std::min(cornersZ[0], x1y1AtRef.z());
170 cornersZ[1] =
std::max(cornersZ[1], x1y1AtRef.z());
172 const LocalPoint lpOfCentre((cornersHi[0]+cornersHi[1])/2, (cornersLo[2]+cornersHi[2])/2, 0);
173 const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
174 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);
175 bp =
new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
183 for(
auto rl : rls ) ch->
add(rl);
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
virtual float length() const =0
common ppss p3p6s2 common epss epspn46 common const1 w2
std::map< RPCDetId, std::list< RPCRoll * > > chids
std::vector< double >::const_iterator rotStart(size_t ind) const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
const Bounds & bounds() const
std::vector< std::string >::const_iterator strStart(size_t ind) const
std::vector< double >::const_iterator tranStart(size_t ind) const
const std::vector< DetId > & detIds() const
std::vector< double >::const_iterator shapeEnd(size_t ind) const
ESHandle< TrackerGeometry > geometry
std::vector< double >::const_iterator shapeStart(size_t ind) const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.