CMS 3D CMS Logo

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

#include <PlaneBuilderForGluedDet.h>

Public Types

typedef
ReferenceCountingPointer
< Plane
ResultType
 

Public Member Functions

ResultType plane (const std::vector< const GeomDetUnit * > &dets) const
 

Private Member Functions

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

Detailed Description

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

Definition at line 15 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 19 of file PlaneBuilderForGluedDet.h.

Member Function Documentation

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

Definition at line 31 of file PlaneBuilderForGluedDet.cc.

References BoundingBox::corners(), mps_fire::i, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), hlt_dqm_clientPB-live_cfg::xmax, hlt_dqm_clientPB-live_cfg::xmin, PV3DBase< T, PVType, FrameType >::y(), SiStrip_OfflineMonitoring_cff::ymax, SiStrip_OfflineMonitoring_cff::ymin, and PV3DBase< T, PVType, FrameType >::z().

Referenced by plane().

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

Definition at line 67 of file PlaneBuilderForGluedDet.cc.

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

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

Definition at line 10 of file PlaneBuilderForGluedDet.cc.

References computeRectBounds(), MediumProperties::radLen(), idealTransformation::rotation, and MediumProperties::xi().

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

10  {
11  // find mean position
13  Vector posSum(0, 0, 0);
14  for (auto det : dets) {
15  posSum += (*det).surface().position().basicVector();
16  }
17  Surface::PositionType meanPos(posSum / float(dets.size()));
18 
19  Surface::RotationType rotation = dets.front()->surface().rotation();
20  // Surface::RotationType rotation = computeRotation( dets, meanPos);
21  Plane tmpPlane = Plane(meanPos, rotation);
22 
23  // Take the medium properties from the first DetUnit
24  const MediumProperties& mp = dets.front()->surface().mediumProperties();
25  MediumProperties newmp(mp.radLen() * 2.0, mp.xi() * 2.0);
26 
27  std::pair<RectangularPlaneBounds*, GlobalVector> bo = computeRectBounds(dets, tmpPlane);
28  return new Plane(meanPos + bo.second, rotation, newmp, bo.first);
29 }
float radLen() const
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
Definition: Plane.h:16
std::pair< RectangularPlaneBounds *, GlobalVector > computeRectBounds(const std::vector< const GeomDetUnit * > &dets, const Plane &plane) const
float xi() const