CMS 3D CMS Logo

PlaneBuilderForGluedDet.cc
Go to the documentation of this file.
6 
7 #include <algorithm>
8 
9 // Warning, remember to assign this pointer to a ReferenceCountingPointer!
10 PlaneBuilderForGluedDet::ResultType PlaneBuilderForGluedDet::plane(const std::vector<const GeomDetUnit*>& dets) const {
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 }
30 
31 std::pair<RectangularPlaneBounds*, GlobalVector> PlaneBuilderForGluedDet::computeRectBounds(
32  const std::vector<const GeomDetUnit*>& dets, const Plane& plane) const {
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 }
66 
67 Surface::RotationType PlaneBuilderForGluedDet::computeRotation(const std::vector<GeomDetUnit const*>& dets,
68  const Surface::PositionType& meanPos) const {
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 
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 
94 }
Vector3DBase< float, LocalTag >
OpenBounds.h
TkRotation< float >
mps_fire.i
i
Definition: mps_fire.py:355
PlaneBuilderForGluedDet::computeRectBounds
std::pair< RectangularPlaneBounds *, GlobalVector > computeRectBounds(const std::vector< const GeomDetUnit * > &dets, const Plane &plane) const
Definition: PlaneBuilderForGluedDet.cc:31
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
MediumProperties::radLen
float radLen() const
Definition: MediumProperties.h:20
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ReferenceCountingPointer< Plane >
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
BoundingBox.h
GloballyPositioned< float >::RotationType
TkRotation< float > RotationType
Definition: GloballyPositioned.h:22
Vector
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
PlaneBuilderForGluedDet::plane
ResultType plane(const std::vector< const GeomDetUnit * > &dets) const
Definition: PlaneBuilderForGluedDet.cc:10
BoundingBox
Definition: BoundingBox.h:12
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
Surface.h
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
MediumProperties.h
Point3DBase< float, LocalTag >
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
Vector3DBase::cross
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:110
PlaneBuilderForGluedDet::computeRotation
Surface::RotationType computeRotation(const std::vector< const GeomDetUnit * > &dets, const Surface::PositionType &meanPos) const
Definition: PlaneBuilderForGluedDet.cc:67
PlaneBuilderForGluedDet.h
MediumProperties
Definition: MediumProperties.h:12
RectangularPlaneBounds
Definition: RectangularPlaneBounds.h:12
HLT_2018_cff.xAxis
xAxis
Definition: HLT_2018_cff.py:44410
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
GloballyPositioned< float >::PositionType
Point3DBase< float, GlobalTag > PositionType
Definition: GloballyPositioned.h:21
MediumProperties::xi
float xi() const
Definition: MediumProperties.h:24
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
BoundPlane
Plane
Definition: Plane.h:16
BoundingBox::corners
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:20
mps_fire.result
result
Definition: mps_fire.py:303
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
HLT_2018_cff.yAxis
yAxis
Definition: HLT_2018_cff.py:44412
Basic3DVector< float >