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
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 BoundPlane &plane) const
 
Surface::RotationType computeRotation (const std::vector< const Det * > &dets, const Surface::PositionType &meanPos) const
 
BoundPlaneoperator() (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 BoundPlane plane 
) const

Definition at line 37 of file RodPlaneBuilderFromDet.cc.

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

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

Definition at line 83 of file RodPlaneBuilderFromDet.cc.

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

85 {
86  // choose first mono out-pointing rotation
87  // the rotations of GluedDets coincide with the mono part
88  // Simply take the x,y of the first Det if z points out,
89  // or -x, y if it doesn't
90  const BoundPlane& plane =
91  dynamic_cast<const BoundPlane&>(dets.front()->surface());
92  //GlobalVector n = plane.normalVector();
93 
94  GlobalVector xAxis;
95  GlobalVector yAxis;
96  GlobalVector planeYAxis = plane.toGlobal( LocalVector( 0, 1, 0));
97  if (planeYAxis.z() < 0) yAxis = -planeYAxis;
98  else yAxis = planeYAxis;
99 
100  GlobalVector planeXAxis = plane.toGlobal( LocalVector( 1, 0, 0));
101  GlobalVector n = planeXAxis.cross( planeYAxis);
102 
103  if (n.x() * meanPos.x() + n.y() * meanPos.y() > 0) {
104  xAxis = planeXAxis;
105  }
106  else {
107  xAxis = -planeXAxis;
108  }
109 
110 // LogDebug("DetLayers") << "Creating rotation with x,y axis "
111 // << xAxis << ", " << yAxis ;
112 
113  return Surface::RotationType( xAxis, yAxis);
114 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
Local3DVector LocalVector
Definition: LocalVector.h:12
T y() const
Definition: PV3DBase.h:62
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:63
TkRotation< float > RotationType
T x() const
Definition: PV3DBase.h:61
BoundPlane * 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<BoundPlane>

Definition at line 11 of file RodPlaneBuilderFromDet.cc.

References i, and idealTransformation::rotation.

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