CMS 3D CMS Logo

MTDDiskSectorBuilderFromDet.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
4 
8 
9 #include <iomanip>
10 
11 using namespace std;
12 
13 namespace {
14 
15  pair<DiskSectorBounds*, GlobalVector> computeBounds(const vector<const GeomDet*>& dets) {
16  // go over all corners and compute maximum deviations
17  float rmin(dets.front()->surface().position().perp());
18  float rmax(rmin);
19  float zmin(dets.front()->surface().position().z());
20  float zmax(zmin);
21  float phimin(dets.front()->surface().position().phi());
22  float phimax(phimin);
23 
24  for (auto const& idet : dets) {
25  vector<GlobalPoint> corners = BoundingBox().corners(idet->specificSurface());
26  for (auto const& i : corners) {
27  float r = i.perp();
28  float z = i.z();
29  float phi = 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  }
40 
42  edm::LogError("MTDDetLayers") << " MTDDiskSectorBuilderFromDet : "
43  << "Something went wrong with Phi Sorting !";
44  float zPos = (zmax + zmin) / 2.;
45  float phiWin = phimax - phimin;
46  float phiPos = (phimax + phimin) / 2.;
47  float rmed = (rmin + rmax) / 2.;
48  if (phiWin < 0.) {
49  if ((phimin < Geom::pi() / 2.) || (phimax > -Geom::pi() / 2.)) {
50  edm::LogError("MTDDetLayers") << " something strange going on, please check " << phimin << " " << phimax << " "
51  << phiWin;
52  }
53  phiWin += 2. * Geom::pi();
54  phiPos += Geom::pi();
55  }
56 
57  GlobalVector pos(rmed * cos(phiPos), rmed * sin(phiPos), zPos);
58 
59  LogTrace("MTDDetLayers") << "MTDDiskSectorBuilderFromDet::computeBounds sector at: " << std::fixed << pos << "\n"
60  << "zmin : " << std::setw(14) << zmin << "\n"
61  << "zmax : " << std::setw(14) << zmax << "\n"
62  << "rmin : " << std::setw(14) << rmin << "\n"
63  << "rmax : " << std::setw(14) << rmax << "\n"
64  << "phi ref : " << std::setw(14) << phiPos << "\n"
65  << "phi win : " << std::setw(14) << phiWin;
66 
67  return make_pair(new DiskSectorBounds(rmin, rmax, zmin - zPos, zmax - zPos, phiWin), pos);
68  }
69 
70  Surface::RotationType computeRotation(const vector<const GeomDet*>& dets, const Surface::PositionType pos) {
71  GlobalVector yAxis = (GlobalVector(pos.x(), pos.y(), 0.)).unit();
72 
73  GlobalVector zAxis(0., 0., 1.);
74  GlobalVector xAxis = yAxis.cross(zAxis);
75 
77  }
78 
79 } // namespace
80 
81 BoundDiskSector* MTDDiskSectorBuilderFromDet::operator()(const vector<const GeomDet*>& dets) const {
82  // check that the dets are all at about the same z
83  float zcheck = dets.front()->surface().position().z();
84  constexpr double tol(0.5); // minimal safety check on z position of modules within a sector, width ~ 10 mm
85  for (auto const& idet : dets) {
86  float zdiff = zcheck - (*idet).surface().position().z();
87  if (std::abs(zdiff) > tol) {
88  edm::LogError("MTDDetLayers")
89  << " MTDDiskSectorBuilderFromDet: Trying to build sector from Dets at different z positions !! Delta_z = "
90  << zdiff;
91  }
92  }
93 
94  auto bo = computeBounds(dets);
95 
96  Surface::PositionType pos(bo.second.x(), bo.second.y(), bo.second.z());
97  Surface::RotationType rot = computeRotation(dets, pos);
98  return new BoundDiskSector(pos, rot, bo.first);
99 }
Vector3DBase
Definition: Vector3DBase.h:8
TkRotation< float >
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DiskSectorBounds
Definition: DiskSectorBounds.h:11
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
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
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
BoundingBox.h
GloballyPositioned< float >::RotationType
TkRotation< float > RotationType
Definition: GloballyPositioned.h:22
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
MTDDiskSectorBuilderFromDet.h
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
HLT_FULL_cff.zAxis
zAxis
Definition: HLT_FULL_cff.py:46209
Geom::pi
constexpr double pi()
Definition: Pi.h:31
Point3DBase< float, GlobalTag >
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HLT_FULL_cff.yAxis
yAxis
Definition: HLT_FULL_cff.py:46210
MTDDiskSectorBuilderFromDet::operator()
BoundDiskSector * operator()(const std::vector< const GeomDet * > &dets) const
Definition: MTDDiskSectorBuilderFromDet.cc:81
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
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
HLT_FULL_cff.xAxis
xAxis
Definition: HLT_FULL_cff.py:46208
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
BoundingBox::corners
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:20
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224