CMS 3D CMS Logo

BladeShapeBuilderFromDet.cc
Go to the documentation of this file.
2 
6 
7 #include <iomanip>
8 
9 using namespace std;
10 
11 namespace {
12 
13  pair<DiskSectorBounds*, GlobalVector> computeBounds(const vector<const GeomDet*>& dets, const Plane& plane) {
14  Surface::PositionType tmpPos = dets.front()->surface().position();
15 
16  float rmin(plane.toLocal(tmpPos).perp());
17  float rmax(plane.toLocal(tmpPos).perp());
18  float zmin(plane.toLocal(tmpPos).z());
19  float zmax(plane.toLocal(tmpPos).z());
20  float phimin(plane.toLocal(tmpPos).phi());
21  float phimax(plane.toLocal(tmpPos).phi());
22 
23  for (vector<const GeomDet*>::const_iterator it = dets.begin(); it != dets.end(); it++) {
24  vector<GlobalPoint> corners = BoundingBox().corners((*it)->specificSurface());
25 
26  for (vector<GlobalPoint>::const_iterator i = corners.begin(); i != corners.end(); i++) {
27  float r = plane.toLocal(*i).perp();
28  float z = plane.toLocal(*i).z();
29  float phi = plane.toLocal(*i).phi();
30  rmin = min(rmin, r);
31  rmax = max(rmax, r);
32  zmin = min(zmin, z);
33  zmax = max(zmax, z);
34  if (Geom::phiLess(phi, phimin))
35  phimin = phi;
36  if (Geom::phiLess(phimax, phi))
37  phimax = phi;
38  }
39  // in addition to the corners we have to check the middle of the
40  // det +/- length/2, since the min (max) radius for typical fw
41  // dets is reached there
42 
43  float rdet = (*it)->position().perp();
44  float height = (*it)->surface().bounds().width();
45  rmin = min(rmin, rdet - height / 2.F);
46  rmax = max(rmax, rdet + height / 2.F);
47  }
48 
50  edm::LogError("TkDetLayers") << " BladeShapeBuilderFromDet : "
51  << "Something went wrong with Phi Sorting !";
52  float zPos = (zmax + zmin) / 2.;
53  float phiWin = phimax - phimin;
54  float phiPos = (phimax + phimin) / 2.;
55  float rmed = (rmin + rmax) / 2.;
56  if (phiWin < 0.) {
57  if ((phimin < Geom::pi() / 2.) || (phimax > -Geom::pi() / 2.)) {
58  edm::LogError("TkDetLayers") << " something strange going on, please check " << phimin << " " << phimax << " "
59  << phiWin;
60  }
61  //edm::LogInfo(TkDetLayers) << " Wedge at pi: phi " << phimin << " " << phimax << " " << phiWin
62  // << " " << 2.*Geom::pi()+phiWin << " " ;
63  phiWin += 2. * Geom::pi();
64  phiPos += Geom::pi();
65  }
66 
67  LocalVector localPos(rmed * cos(phiPos), rmed * sin(phiPos), zPos);
68 
69  LogDebug("TkDetLayers") << "localPos in computeBounds: " << localPos << "\n"
70  << "rmin: " << rmin << "\n"
71  << "rmax: " << rmax << "\n"
72  << "zmin: " << zmin << "\n"
73  << "zmax: " << zmax << "\n"
74  << "phiWin: " << phiWin;
75 
76  return make_pair(new DiskSectorBounds(rmin, rmax, zmin, zmax, phiWin), plane.toGlobal(localPos));
77  }
78 
79  Surface::RotationType computeRotation(const vector<const GeomDet*>& dets, const Surface::PositionType& meanPos) {
80  const Plane& plane = dets.front()->surface();
81 
85 
86  GlobalVector planeXAxis = plane.toGlobal(LocalVector(1, 0, 0));
87  const GlobalPoint& planePosition = plane.position();
88 
89  if (planePosition.x() * planeXAxis.x() + planePosition.y() * planeXAxis.y() > 0.) {
90  yAxis = planeXAxis;
91  } else {
92  yAxis = -planeXAxis;
93  }
94 
95  GlobalVector planeZAxis = plane.toGlobal(LocalVector(0, 0, 1));
96  if (planeZAxis.z() * planePosition.z() > 0.) {
97  zAxis = planeZAxis;
98  } else {
99  zAxis = -planeZAxis;
100  }
101 
102  xAxis = yAxis.cross(zAxis);
103 
105  }
106 
107 } // namespace
108 
109 BoundDiskSector* BladeShapeBuilderFromDet::build(const vector<const GeomDet*>& dets) {
110  // find mean position
112  Vector posSum(0, 0, 0);
113  for (vector<const GeomDet*>::const_iterator i = dets.begin(); i != dets.end(); i++) {
114  posSum += (**i).surface().position().basicVector();
115  }
116  Surface::PositionType meanPos(0., 0., posSum.z() / float(dets.size()));
117 
118  // temporary plane - for the computation of bounds
119  Surface::RotationType rotation = computeRotation(dets, meanPos);
120  Plane tmpPlane(meanPos, rotation);
121 
122  auto bo = computeBounds(dets, tmpPlane);
123  GlobalPoint pos = meanPos + bo.second;
124  //edm::LogInfo(TkDetLayers) << "global pos in operator: " << pos ;
125  return new BoundDiskSector(pos, rotation, bo.first);
126 }
Vector3DBase< float, LocalTag >
TkRotation< float >
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
DiskSectorBounds
Definition: DiskSectorBounds.h:11
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
min
T min(T a, T b)
Definition: MathUtil.h:58
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
VectorUtil.h
pos
Definition: PixelAliasList.h:18
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
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
BoundingBox
Definition: BoundingBox.h:12
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
HLT_FULL_cff.zAxis
zAxis
Definition: HLT_FULL_cff.py:46143
Geom::pi
constexpr double pi()
Definition: Pi.h:31
Point3DBase< float, GlobalTag >
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
BladeShapeBuilderFromDet::build
static BoundDiskSector * build(const std::vector< const GeomDet * > &dets) __attribute__((cold))
Definition: BladeShapeBuilderFromDet.cc:109
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HLT_FULL_cff.yAxis
yAxis
Definition: HLT_FULL_cff.py:46144
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
BladeShapeBuilderFromDet.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
BoundDiskSector
Definition: BoundDiskSector.h:7
alignCSCRings.r
r
Definition: alignCSCRings.py:93
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
std
Definition: JetResolutionObject.h:76
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
Plane
Definition: Plane.h:16
HLT_FULL_cff.xAxis
xAxis
Definition: HLT_FULL_cff.py:46142
BoundingBox::corners
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:20
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Basic3DVector< float >