CMS 3D CMS Logo

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.)
10 {
12 
13  unsigned int def = 0;
14  for (std::vector<VolumeSide>::const_iterator i=faces.begin(); i!= faces.end(); ++i) {
15  if (i->globalFace() == SurfaceOrientation::zminus) {
16  theZmin = MagVolume::toLocal( i->surface().position()).z();
17  ++def;
18  }
19  else if (i->globalFace() == SurfaceOrientation::zplus) {
20  theZmax = MagVolume::toLocal( i->surface().position()).z();
21  ++def;
22  }
23  else if (i->globalFace() == SurfaceOrientation::outer || i->globalFace() == SurfaceOrientation::inner) {
24  const Cylinder* cyl = dynamic_cast<const Cylinder*>(&(i->surface()));
25  if (cyl == nullptr) {
26  throw MagGeometryError("MagCylinder inner/outer surface is not a cylinder");
27  }
28  if (i->globalFace() == SurfaceOrientation::outer) theOuterR = cyl->radius();
29  else theInnerR = cyl->radius();
30  ++def;
31  }
32  }
33  if (def != faces.size()) {
34  throw MagGeometryError("MagCylinder constructed with wrong number/type of faces");
35  }
36 
37 }
38 
39 bool MagCylinder::inside( const GlobalPoint& gp, double tolerance) const
40 {
41  return inside( toLocal(gp), tolerance);
42 }
43 
44 bool MagCylinder::inside( const LocalPoint& lp, double tolerance) const
45 {
46  Scalar r( lp.perp());
47  return
48  lp.z() > theZmin - tolerance &&
49  lp.z() < theZmax + tolerance &&
50  r > theInnerR - tolerance &&
51  r < theOuterR + tolerance;
52 }
Scalar theZmax
Definition: MagCylinder.h:37
GloballyPositioned< float >::GlobalPoint GlobalPoint
Definition: MagVolume.h:19
const double tolerance
Scalar theInnerR
Definition: MagCylinder.h:38
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MagVolume.h:17
MagCylinder(const PositionType &pos, const RotationType &rot, const std::vector< VolumeSide > &faces, const MagneticFieldProvider< float > *mfp)
Definition: MagCylinder.cc:5
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:67
LocalPoint toLocal(const GlobalPoint &gp) const
bool inside(const GlobalPoint &gp, double tolerance=0.) const override
Definition: MagCylinder.cc:39
Scalar theOuterR
Definition: MagCylinder.h:39
Scalar theZmin
Definition: MagCylinder.h:36
JetCorrectorParameters::Definitions def
Definition: classes.h:6