CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions
PlaneBuilderForGluedDet Class Reference

#include <PlaneBuilderForGluedDet.h>

Public Types

typedef
ReferenceCountingPointer
< BoundPlane
ResultType
 

Public Member Functions

std::pair
< RectangularPlaneBounds,
GlobalVector
computeRectBounds (const std::vector< const GeomDetUnit * > &dets, const BoundPlane &plane) const
 
Surface::RotationType computeRotation (const std::vector< GeomDetUnit * > &dets, const Surface::PositionType &meanPos) const
 
ResultType plane (const std::vector< const GeomDetUnit * > &dets) const
 

Detailed Description

Builds the minimal rectangular box that contains all input GeomDetUnits fully.

Definition at line 16 of file PlaneBuilderForGluedDet.h.

Member Typedef Documentation

Warning, remember to assign this pointer to a ReferenceCountingPointer! Should be changed to return a ReferenceCountingPointer<BoundPlane>

Definition at line 21 of file PlaneBuilderForGluedDet.h.

Member Function Documentation

std::pair< RectangularPlaneBounds, GlobalVector > PlaneBuilderForGluedDet::computeRectBounds ( const std::vector< const GeomDetUnit * > &  dets,
const BoundPlane plane 
) const

Definition at line 34 of file PlaneBuilderForGluedDet.cc.

References BoundingBox::corners(), i, evf::evtn::offset(), L1TEmulatorMonitor_cff::p, query::result, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by plane().

34  {
35  // go over all corners and compute maximum deviations from mean pos.
36  std::vector<GlobalPoint> corners;
37  for (std::vector<const GeomDetUnit*>::const_iterator idet=dets.begin();
38  idet != dets.end(); idet++) {
39  const BoundPlane& plane = dynamic_cast<const BoundPlane&>((*idet)->surface());
40  std::vector<GlobalPoint> dc = BoundingBox().corners(plane);
41  corners.insert( corners.end(), dc.begin(), dc.end());
42  }
43 
44  float xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0);
45  for (std::vector<GlobalPoint>::const_iterator i=corners.begin();
46  i!=corners.end(); i++) {
47  LocalPoint p = plane.toLocal(*i);
48  if (p.x() < xmin) xmin = p.x();
49  if (p.x() > xmax) xmax = p.x();
50  if (p.y() < ymin) ymin = p.y();
51  if (p.y() > ymax) ymax = p.y();
52  if (p.z() < zmin) zmin = p.z();
53  if (p.z() > zmax) zmax = p.z();
54  }
55 
56  LocalVector localOffset( (xmin+xmax)/2., (ymin+ymax)/2., (zmin+zmax)/2.);
57  GlobalVector offset( plane.toGlobal(localOffset));
58 
59  std::pair<RectangularPlaneBounds, GlobalVector> result(RectangularPlaneBounds((xmax-xmin)/2, (ymax-ymin)/2, (zmax-zmin)/2), offset);
60 
61  return result;
62 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
int i
Definition: DBlmapReader.cc:9
T y() const
Definition: PV3DBase.h:57
static std::vector< GlobalPoint > corners(const BoundPlane &)
Definition: BoundingBox.cc:24
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
unsigned int offset(bool)
T x() const
Definition: PV3DBase.h:56
Surface::RotationType PlaneBuilderForGluedDet::computeRotation ( const std::vector< GeomDetUnit * > &  dets,
const Surface::PositionType meanPos 
) const

Definition at line 64 of file PlaneBuilderForGluedDet.cc.

References Vector3DBase< T, FrameTag >::cross(), n, plane(), Surface::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

64  {
65 
66  // choose first mono out-pointing rotation
67  // the rotations of GluedDets coincide with the mono part
68  // Simply take the x,y of the first Det if z points out,
69  // or -x, y if it doesn't
70  const BoundPlane& plane = dynamic_cast<const BoundPlane&>(dets.front()->surface());
71  //GlobalVector n = plane.normalVector();
72 
73  GlobalVector xAxis;
74  GlobalVector yAxis;
75  GlobalVector planeYAxis = plane.toGlobal( LocalVector( 0, 1, 0));
76  if (planeYAxis.z() < 0) yAxis = -planeYAxis;
77  else yAxis = planeYAxis;
78 
79  GlobalVector planeXAxis = plane.toGlobal( LocalVector( 1, 0, 0));
80  GlobalVector n = planeXAxis.cross( planeYAxis);
81 
82  if (n.x() * meanPos.x() + n.y() * meanPos.y() > 0) {
83  xAxis = planeXAxis;
84  }
85  else {
86  xAxis = -planeXAxis;
87  }
88 
89  return Surface::RotationType( xAxis, yAxis);
90 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
Local3DVector LocalVector
Definition: LocalVector.h:12
T y() const
Definition: PV3DBase.h:57
ResultType plane(const std::vector< const GeomDetUnit * > &dets) const
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:58
TkRotation< float > RotationType
T x() const
Definition: PV3DBase.h:56
PlaneBuilderForGluedDet::ResultType PlaneBuilderForGluedDet::plane ( const std::vector< const GeomDetUnit * > &  dets) const

Definition at line 11 of file PlaneBuilderForGluedDet.cc.

References BoundPlane::build(), computeRectBounds(), i, MediumProperties::radLen(), and MediumProperties::xi().

Referenced by TrackerGeomBuilderFromGeometricDet::buildGeomDet(), and computeRotation().

11  {
12  // find mean position
14  Vector posSum(0,0,0);
15  for (std::vector<const GeomDetUnit*>::const_iterator i=dets.begin(); i!=dets.end(); i++) {
16  posSum += (**i).surface().position().basicVector();
17  }
18  Surface::PositionType meanPos( posSum/float(dets.size()));
19 
20  Surface::RotationType rotation = dets.front()->surface().rotation();
21  // Surface::RotationType rotation = computeRotation( dets, meanPos);
22  BoundPlane::BoundPlanePointer tmpPlane = BoundPlane::build( meanPos, rotation, OpenBounds());
23 
24  // Take the medium properties from the first DetUnit
25  const MediumProperties* mp = dets.front()->surface().mediumProperties();
26  MediumProperties newmp(0,0);
27  if (mp != 0) newmp = MediumProperties( mp->radLen()*2.0,mp->xi()*2.0);
28 
29  std::pair<RectangularPlaneBounds,GlobalVector> bo = computeRectBounds( dets, *tmpPlane);
30  return new BoundPlane( meanPos+bo.second, rotation, bo.first, &newmp);
31 }
int i
Definition: DBlmapReader.cc:9
float radLen() const
std::pair< RectangularPlaneBounds, GlobalVector > computeRectBounds(const std::vector< const GeomDetUnit * > &dets, const BoundPlane &plane) const
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:28
static BoundPlanePointer build(const PositionType &pos, const RotationType &rot, const Bounds *bounds, MediumProperties *mp=0)
Definition: BoundPlane.h:26
float xi() const
Unlimited (trivial) bounds.
Definition: OpenBounds.h:10