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 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 36 of file RodPlaneBuilderFromDet.cc.

References BoundingBox::corners(), 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(), SiStripMonitorClusterAlca_cfi::ymax, SiStripMonitorClusterAlca_cfi::ymin, PV3DBase< T, PVType, FrameType >::z(), SiStripMonitorClusterAlca_cfi::zmax, and SiStripMonitorClusterAlca_cfi::zmin.

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

Definition at line 82 of file RodPlaneBuilderFromDet.cc.

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

84 {
85  // choose first mono out-pointing rotation
86  // the rotations of GluedDets coincide with the mono part
87  // Simply take the x,y of the first Det if z points out,
88  // or -x, y if it doesn't
89  const Plane& plane =
90  dynamic_cast<const Plane&>(dets.front()->surface());
91  //GlobalVector n = plane.normalVector();
92 
93  GlobalVector xAxis;
94  GlobalVector yAxis;
95  GlobalVector planeYAxis = plane.toGlobal( LocalVector( 0, 1, 0));
96  if (planeYAxis.z() < 0) yAxis = -planeYAxis;
97  else yAxis = planeYAxis;
98 
99  GlobalVector planeXAxis = plane.toGlobal( LocalVector( 1, 0, 0));
100  GlobalVector n = planeXAxis.cross( planeYAxis);
101 
102  if (n.x() * meanPos.x() + n.y() * meanPos.y() > 0) {
103  xAxis = planeXAxis;
104  }
105  else {
106  xAxis = -planeXAxis;
107  }
108 
109 // LogDebug("DetLayers") << "Creating rotation with x,y axis "
110 // << xAxis << ", " << yAxis ;
111 
112  return Surface::RotationType( xAxis, yAxis);
113 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
Local3DVector LocalVector
Definition: LocalVector.h:12
T y() const
Definition: PV3DBase.h:63
Definition: Plane.h:17
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
TkRotation< float > RotationType
T x() const
Definition: PV3DBase.h:62
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 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  Plane tmpPlane( meanPos, rotation);
24  auto bo = computeBounds( dets, tmpPlane);
25 
26 // LogDebug("DetLayers") << "Creating plane at position " << meanPos
27 // << " displaced by " << bo.second ;
28 // LogDebug("DetLayers") << "Bounds are (wid/len/thick) " << bo.first.width()
29 // << " / " << bo.first.length()
30 // << " / " << bo.first.thickness() ;
31 
32  return new Plane( meanPos+bo.second, rotation, bo.first);
33 }
Surface::RotationType computeRotation(const std::vector< const Det * > &dets, const Surface::PositionType &meanPos) const
int i
Definition: DBlmapReader.cc:9
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:17