CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MagCylinder.cc
Go to the documentation of this file.
4 
6  const RotationType& rot,
7  const std::vector<VolumeSide>& faces,
9  : MagVolume(pos, rot, mfp), theFaces(faces), theZmin(0.), theZmax(0.), theInnerR(0.), theOuterR(0.) {
11 
12  unsigned int def = 0;
13  for (std::vector<VolumeSide>::const_iterator i = faces.begin(); i != faces.end(); ++i) {
14  if (i->globalFace() == SurfaceOrientation::zminus) {
15  theZmin = MagVolume::toLocal(i->surface().position()).z();
16  ++def;
17  } else if (i->globalFace() == SurfaceOrientation::zplus) {
18  theZmax = MagVolume::toLocal(i->surface().position()).z();
19  ++def;
20  } else if (i->globalFace() == SurfaceOrientation::outer || i->globalFace() == SurfaceOrientation::inner) {
21  const Cylinder* cyl = dynamic_cast<const Cylinder*>(&(i->surface()));
22  if (cyl == nullptr) {
23  throw MagGeometryError("MagCylinder inner/outer surface is not a cylinder");
24  }
25  if (i->globalFace() == SurfaceOrientation::outer)
26  theOuterR = cyl->radius();
27  else
28  theInnerR = cyl->radius();
29  ++def;
30  }
31  }
32  if (def != faces.size()) {
33  throw MagGeometryError("MagCylinder constructed with wrong number/type of faces");
34  }
36 }
37 
38 bool MagCylinder::inside(const GlobalPoint& gp, double tolerance) const { return inside(toLocal(gp), tolerance); }
39 
40 bool MagCylinder::inside(const LocalPoint& lp, double tolerance) const {
41  Scalar r(lp.perp());
42  return lp.z() > theZmin - tolerance && lp.z() < theZmax + tolerance && r > theInnerR - tolerance &&
43  r < theOuterR + tolerance;
44 }
int def(FILE *, FILE *, int)
Scalar theZmax
Definition: MagCylinder.h:36
GloballyPositioned< float >::GlobalPoint GlobalPoint
Definition: MagVolume.h:18
const double tolerance
Scalar theInnerR
Definition: MagCylinder.h:37
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MagVolume.h:16
MagCylinder(const PositionType &pos, const RotationType &rot, const std::vector< VolumeSide > &faces, const MagneticFieldProvider< float > *mfp)
Definition: MagCylinder.cc:5
bool inside(const GlobalPoint &gp, double tolerance=0.) const override
Definition: MagCylinder.cc:38
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:64
LocalPoint toLocal(const GlobalPoint &gp) const
Scalar theOuterR
Definition: MagCylinder.h:38
Scalar theZmin
Definition: MagCylinder.h:35
void setNominalValue()