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
RodPlaneBuilderFromDet Class Reference

#include <RodPlaneBuilderFromDet.h>

Public Types

typedef GeomDet Det
 

Public Member Functions

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

Detailed Description

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

Definition at line 15 of file RodPlaneBuilderFromDet.h.

Member Typedef Documentation

Definition at line 17 of file RodPlaneBuilderFromDet.h.

Member Function Documentation

pair< RectangularPlaneBounds *, GlobalVector > RodPlaneBuilderFromDet::computeBounds ( const std::vector< const Det * > &  dets,
const Plane plane 
) const

Definition at line 33 of file RodPlaneBuilderFromDet.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().

34  {
35  // go over all corners and compute maximum deviations from mean pos.
36  vector<GlobalPoint> corners;
37  for (vector<const Det*>::const_iterator idet = dets.begin(); idet != dets.end(); idet++) {
38  /* ---- original implementation. Is it obsolete?
39  vector<const DetUnit*> detUnits = (**idet).basicComponents();
40  for (vector<const DetUnit*>::const_iterator detu=detUnits.begin();
41  detu!=detUnits.end(); detu++) {
42  vector<GlobalPoint> dc =
43  BoundingBox().corners((**detu).specificSurface());
44  corners.insert( corners.end(), dc.begin(), dc.end());
45  }
46  ---- */
47 
48  // temporary implementation (May be the final one if the GluedDet surface
49  // really contains both the mono and the stereo surfaces
50  vector<GlobalPoint> dc = BoundingBox().corners((**idet).specificSurface());
51  corners.insert(corners.end(), dc.begin(), dc.end());
52  }
53 
54  float xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0);
55  for (vector<GlobalPoint>::const_iterator i = corners.begin(); i != corners.end(); i++) {
56  LocalPoint p = plane.toLocal(*i);
57  if (p.x() < xmin)
58  xmin = p.x();
59  if (p.x() > xmax)
60  xmax = p.x();
61  if (p.y() < ymin)
62  ymin = p.y();
63  if (p.y() > ymax)
64  ymax = p.y();
65  if (p.z() < zmin)
66  zmin = p.z();
67  if (p.z() > zmax)
68  zmax = p.z();
69  }
70 
71  LocalVector localOffset((xmin + xmax) / 2., (ymin + ymax) / 2., (zmin + zmax) / 2.);
72  GlobalVector offset(plane.toGlobal(localOffset));
73 
74  pair<RectangularPlaneBounds*, GlobalVector> result(
75  new RectangularPlaneBounds((xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2), offset);
76 
77  return result;
78 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
T y() const
Definition: PV3DBase.h:60
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 RodPlaneBuilderFromDet::computeRotation ( const std::vector< const Det * > &  dets,
const Surface::PositionType meanPos 
) const

Definition at line 80 of file RodPlaneBuilderFromDet.cc.

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

81  {
82  // choose first mono out-pointing rotation
83  // the rotations of GluedDets coincide with the mono part
84  // Simply take the x,y of the first Det if z points out,
85  // or -x, y if it doesn't
86  const Plane& plane = dynamic_cast<const Plane&>(dets.front()->surface());
87  //GlobalVector n = plane.normalVector();
88 
89  GlobalVector xAxis;
90  GlobalVector yAxis;
91  GlobalVector planeYAxis = plane.toGlobal(LocalVector(0, 1, 0));
92  if (planeYAxis.z() < 0)
93  yAxis = -planeYAxis;
94  else
95  yAxis = planeYAxis;
96 
97  GlobalVector planeXAxis = plane.toGlobal(LocalVector(1, 0, 0));
98  GlobalVector n = planeXAxis.cross(planeYAxis);
99 
100  if (n.x() * meanPos.x() + n.y() * meanPos.y() > 0) {
101  xAxis = planeXAxis;
102  } else {
103  xAxis = -planeXAxis;
104  }
105 
106  // LogDebug("DetLayers") << "Creating rotation with x,y axis "
107  // << xAxis << ", " << yAxis ;
108 
109  return Surface::RotationType(xAxis, yAxis);
110 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
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
Definition: Plane.h:16
T z() const
Definition: PV3DBase.h:61
TkRotation< float > RotationType
T x() const
Definition: PV3DBase.h:59
Plane * RodPlaneBuilderFromDet::operator() ( const std::vector< const Det * > &  dets) const

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

Definition at line 10 of file RodPlaneBuilderFromDet.cc.

References mps_fire::i, and idealTransformation::rotation.

10  {
11  // find mean position
13  Vector posSum(0, 0, 0);
14  for (vector<const Det*>::const_iterator i = dets.begin(); i != dets.end(); i++) {
15  posSum += (**i).surface().position().basicVector();
16  }
17  Surface::PositionType meanPos(posSum / float(dets.size()));
18 
19  // temporary plane - for the computation of bounds
21  Plane tmpPlane(meanPos, rotation);
22  auto bo = computeBounds(dets, tmpPlane);
23 
24  // LogDebug("DetLayers") << "Creating plane at position " << meanPos
25  // << " displaced by " << bo.second ;
26  // LogDebug("DetLayers") << "Bounds are (wid/len/thick) " << bo.first.width()
27  // << " / " << bo.first.length()
28  // << " / " << bo.first.thickness() ;
29 
30  return new Plane(meanPos + bo.second, rotation, bo.first);
31 }
Surface::RotationType computeRotation(const std::vector< const Det * > &dets, const Surface::PositionType &meanPos) const
std::pair< RectangularPlaneBounds *, GlobalVector > computeBounds(const std::vector< const Det * > &dets, const Plane &plane) const
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
Definition: Plane.h:16