33 using namespace cms_units::operators;
45 return this->buildGeometry(fview, muonConstants);
55 return this->buildGeometry(fview, muonConstants);
61 LogDebug(
"RPCGeometryBuilder") <<
"Building the geometry service";
62 std::unique_ptr<RPCGeometry>
geometry = std::make_unique<RPCGeometry>();
63 LogDebug(
"RPCGeometryBuilder") <<
"About to run through the RPC structure\n"
66 LogDebug(
"RPCGeometryBuilder") <<
"doSubDets = " << doSubDets;
68 LogDebug(
"RPCGeometryBuilder") <<
"start the loop";
70 LogDebug(
"RPCGeometryBuilder") <<
"Getting the Muon base Number";
72 LogDebug(
"RPCGeometryBuilder") <<
"Start the Rpc Numbering Schema";
74 LogDebug(
"RPCGeometryBuilder") <<
"Getting the Unit Number";
76 LogDebug(
"RPCGeometryBuilder") <<
"Getting the RPC det Id " << detid;
79 LogDebug(
"RPCGeometryBuilder") <<
"The RPCDetid is " << rpcid;
81 DDValue numbOfStrips(
"nStrips");
83 std::vector<const DDsvalues_type*> specs(fview.
specifics());
85 for (
auto& spec : specs) {
86 if (
DDfetch(spec, numbOfStrips)) {
87 nStrips = int(numbOfStrips.
doubles()[0]);
91 LogDebug(
"RPCGeometryBuilder") << ((nStrips == 0) ? (
"No strip found!!") : (
""));
98 <<
"detid: " << detid <<
" name: " << name <<
" number of Strips: " <<
nStrips;
110 rota.GetComponents(x, y, z);
124 if (dpar.size() == 3) {
131 <<
"(3) dpar.size() == 3, width: " << width <<
" length: " << length <<
" thickness: " <<
thickness;
134 const std::vector<float> pars = {width, length, float(numbOfStrips.
doubles()[0])};
142 const float ti = 0.4;
149 float(numbOfStrips.
doubles()[0])};
152 <<
"(4), else, dpar[4]: " << be <<
" dpar[8]: " << te <<
" dpar[0]: " << ap <<
" ti: " << ti;
169 auto rls = chids.find(chid);
170 if (rls == chids.end())
171 rls = chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
172 rls->second.emplace_back(r);
176 for (
auto& ich : chids) {
178 const auto& rls = ich.second;
182 const auto& refSurf = (*rls.begin())->surface();
184 float corners[6] = {0, 0, 0, 0, 0, 0};
185 for (
auto rl : rls) {
186 const double h2 = rl->surface().bounds().length() / 2;
187 const double w2 = rl->surface().bounds().width() / 2;
188 const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-w2, -h2, 0)));
189 const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+w2, +h2, 0)));
190 corners[0] =
std::min(corners[0], x1y1AtRef.x());
191 corners[1] =
std::min(corners[1], x1y1AtRef.y());
192 corners[2] =
std::max(corners[2], x2y2AtRef.x());
193 corners[3] =
std::max(corners[3], x2y2AtRef.y());
194 corners[4] =
std::min(corners[4], x1y1AtRef.z());
195 corners[5] =
std::max(corners[5], x1y1AtRef.z());
197 const LocalPoint lpOfCentre((corners[0] + corners[2]) / 2, (corners[1] + corners[3]) / 2, 0);
198 const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
200 (corners[2] - corners[0]) / 2, (corners[3] - corners[1]) / 2, (corners[5] - corners[4]) + 0.5);
201 bp =
new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
203 float cornersLo[3] = {0, 0, 0}, cornersHi[3] = {0, 0, 0};
204 float cornersZ[2] = {0, 0};
205 for (
auto rl : rls) {
207 const double w2 = rl->surface().bounds().width() / 2;
209 const double r = topo.radius();
210 const double wAtLo = w2 / r * (r - h2);
211 const double wAtHi = w2 / r * (r + h2);
213 const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-wAtLo, -h2, 0)));
214 const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+wAtLo, -h2, 0)));
215 const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-wAtHi, +h2, 0)));
216 const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+wAtHi, +h2, 0)));
218 cornersLo[0] =
std::min(cornersLo[0], x1y1AtRef.x());
219 cornersLo[1] =
std::max(cornersLo[1], x2y1AtRef.x());
220 cornersLo[2] =
std::min(cornersLo[2], x1y1AtRef.y());
222 cornersHi[0] =
std::min(cornersHi[0], x1y2AtRef.x());
223 cornersHi[1] =
std::max(cornersHi[1], x2y2AtRef.x());
224 cornersHi[2] =
std::max(cornersHi[2], x1y2AtRef.y());
226 cornersZ[0] =
std::min(cornersZ[0], x1y1AtRef.z());
227 cornersZ[1] =
std::max(cornersZ[1], x1y1AtRef.z());
229 const LocalPoint lpOfCentre((cornersHi[0] + cornersHi[1]) / 2, (cornersLo[2] + cornersHi[2]) / 2, 0);
230 const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
232 (cornersHi[1] - cornersHi[0]) / 2,
233 (cornersHi[2] - cornersLo[2]) / 2,
234 (cornersZ[1] - cornersZ[0]) + 0.5);
235 bp =
new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
253 std::unique_ptr<RPCGeometry> geometry = std::make_unique<RPCGeometry>();
263 auto nStrips = fview.
get<
double>(
"nStrips");
265 std::vector<double> dpar = fview.
parameters();
267 std::string_view name = fview.
name();
270 <<
"(1), detid: " << rawidCh <<
" name: " <<
std::string(name) <<
" number of Strips: " <<
nStrips;
272 const Double_t* tran = fview.
trans();
279 <<
"(2), tran.x(): " << tran[0] / dd4hep::cm <<
" tran.y(): " << tran[1] / dd4hep::cm
280 <<
" tran.z(): " << tran[2] / dd4hep::cm;
282 rota.GetComponents(x, y, z);
296 if (dd4hep::isA<dd4hep::Box>(fview.
solid())) {
297 const float width = dpar[0] / dd4hep::cm;
298 const float length = dpar[1] / dd4hep::cm;
299 const float thickness = dpar[2] / dd4hep::cm;
301 <<
"(3), dd4hep::Box, width: " << dpar[0] / dd4hep::cm <<
" length: " << dpar[1] / dd4hep::cm
302 <<
" thickness: " << dpar[2] / dd4hep::cm;
305 const std::vector<float> pars = {width, length, float(nStrips)};
310 const float be = dpar[0] / dd4hep::cm;
311 const float te = dpar[1] / dd4hep::cm;
312 const float ap = dpar[3] / dd4hep::cm;
313 const float ti = 0.4 / dd4hep::cm;
316 const std::vector<float> pars = {
317 float(dpar[0] / dd4hep::cm), float(dpar[1] / dd4hep::cm), float(dpar[3] / dd4hep::cm), float(nStrips)};
319 <<
"(4), else, dpar[0] (i.e. dpar[4] for DD): " << dpar[0] / dd4hep::cm
320 <<
" dpar[1] (i.e. dpar[8] for DD): " << dpar[1] / dd4hep::cm
321 <<
" dpar[3] (i.e. dpar[0] for DD): " << dpar[3] / dd4hep::cm <<
" ti: " << ti / dd4hep::cm;
336 auto rls = chids.find(chid);
337 if (rls == chids.end())
338 rls = chids.insert(std::make_pair(chid, std::list<RPCRoll*>())).first;
339 rls->second.emplace_back(r);
342 for (
auto& ich : chids) {
344 const auto& rls = ich.second;
348 const auto& refSurf = (*rls.begin())->surface();
350 float corners[6] = {0, 0, 0, 0, 0, 0};
351 for (
auto rl : rls) {
352 const double h2 = rl->surface().bounds().length() / 2;
353 const double w2 = rl->surface().bounds().width() / 2;
354 const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-w2, -h2, 0)));
355 const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+w2, +h2, 0)));
356 corners[0] =
std::min(corners[0], x1y1AtRef.x());
357 corners[1] =
std::min(corners[1], x1y1AtRef.y());
358 corners[2] =
std::max(corners[2], x2y2AtRef.x());
359 corners[3] =
std::max(corners[3], x2y2AtRef.y());
361 corners[4] =
std::min(corners[4], x1y1AtRef.z());
362 corners[5] =
std::max(corners[5], x1y1AtRef.z());
364 const LocalPoint lpOfCentre((corners[0] + corners[2]) / 2, (corners[1] + corners[3]) / 2, 0);
365 const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
367 (corners[2] - corners[0]) / 2, (corners[3] - corners[1]) / 2, (corners[5] - corners[4]) + 0.5);
368 bp =
new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
371 float cornersLo[3] = {0, 0, 0}, cornersHi[3] = {0, 0, 0};
372 float cornersZ[2] = {0, 0};
373 for (
auto rl : rls) {
375 const double w2 = rl->surface().bounds().width() / 2;
377 const double r = topo.radius();
378 const double wAtLo = w2 / r * (r - h2);
379 const double wAtHi = w2 / r * (r + h2);
380 const auto x1y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-wAtLo, -h2, 0)));
381 const auto x2y1AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+wAtLo, -h2, 0)));
382 const auto x1y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(-wAtHi, +h2, 0)));
383 const auto x2y2AtRef = refSurf.toLocal(rl->toGlobal(
LocalPoint(+wAtHi, +h2, 0)));
385 cornersLo[0] =
std::min(cornersLo[0], x1y1AtRef.x());
386 cornersLo[1] =
std::max(cornersLo[1], x2y1AtRef.x());
387 cornersLo[2] =
std::min(cornersLo[2], x1y1AtRef.y());
389 cornersHi[0] =
std::min(cornersHi[0], x1y2AtRef.x());
390 cornersHi[1] =
std::max(cornersHi[1], x2y2AtRef.x());
391 cornersHi[2] =
std::max(cornersHi[2], x1y2AtRef.y());
393 cornersZ[0] =
std::min(cornersZ[0], x1y1AtRef.z());
394 cornersZ[1] =
std::max(cornersZ[1], x1y1AtRef.z());
396 const LocalPoint lpOfCentre((cornersHi[0] + cornersHi[1]) / 2, (cornersLo[2] + cornersHi[2]) / 2, 0);
397 const auto gpOfCentre = refSurf.toGlobal(lpOfCentre);
399 (cornersHi[1] - cornersHi[0]) / 2,
400 (cornersHi[2] - cornersLo[2]) / 2,
401 (cornersZ[1] - cornersZ[0]) + 0.5);
402 bp =
new BoundPlane(gpOfCentre, refSurf.rotation(), bounds);
Log< level::Info, true > LogVerbatim
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history) const
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> DD3Vector
virtual float length() const =0
common ppss p3p6s2 common epss epspn46 common const1 w2
bool nextSibling()
set the current node to the next sibling ...
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
const Bounds & bounds() const
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Compact representation of the geometrical detector hierarchy.
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 *.
tuple nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
TkRotation & rotateAxes(const Basic3DVector< T > &newX, const Basic3DVector< T > &newY, const Basic3DVector< T > &newZ)
std::unique_ptr< RPCGeometry > buildGeometry(DDFilteredView &fview, const MuonGeometryConstants &muonConstants)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const ExpandedNodes & history()
The numbering history of the current node.
const Double_t * rot() const
The absolute rotation of the current node.
std::string_view name() const
bool firstChild()
set the current node to the first child
T get(const std::string &)
extract attribute value
constexpr NumType convertMmToCm(NumType millimeters)
const Double_t * trans() const
The absolute translation of the current node.
std::unique_ptr< RPCGeometry > build(const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
bool firstChild()
set the current node to the first child ...
const std::vector< double > parameters() const
extract shape parameters
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< const DDsvalues_type * > specifics() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
const std::string & name() const
Returns the name.
dd4hep::Solid solid() const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.