File indexing completed on 2024-04-06 12:14:17
0001 #include "Geometry/CaloGeometry/interface/PreshowerStrip.h"
0002 #include <iostream>
0003
0004 typedef PreshowerStrip::CCGFloat CCGFloat;
0005 typedef PreshowerStrip::Pt3D Pt3D;
0006 typedef PreshowerStrip::Pt3DVec Pt3DVec;
0007 typedef PreshowerStrip::Tr3D Tr3D;
0008
0009 PreshowerStrip::PreshowerStrip() : CaloCellGeometry() {}
0010
0011 PreshowerStrip::PreshowerStrip(const PreshowerStrip& tr) : CaloCellGeometry(tr) { *this = tr; }
0012
0013 PreshowerStrip::~PreshowerStrip() {}
0014
0015 PreshowerStrip& PreshowerStrip::operator=(const PreshowerStrip& tr) {
0016 if (&tr != this) {
0017 CaloCellGeometry::operator=(tr);
0018 }
0019 return *this;
0020 }
0021
0022 void PreshowerStrip::initCorners(CaloCellGeometry::CornersVec& corners) {
0023 if (corners.uninitialized()) {
0024 const GlobalPoint& ctr(getPosition());
0025 const CCGFloat x(ctr.x());
0026 const CCGFloat y(ctr.y());
0027 const CCGFloat z(ctr.z());
0028
0029 const double st(sin(tilt()));
0030 const double ct(cos(tilt()));
0031
0032 for (unsigned int ix(0); ix != 2; ++ix) {
0033 const double sx(0 == ix ? -1.0 : +1.0);
0034 for (unsigned int iy(0); iy != 2; ++iy) {
0035 const double sy(0 == iy ? -1.0 : +1.0);
0036 for (unsigned int iz(0); iz != 2; ++iz) {
0037 const double sz(0 == iz ? -1.0 : +1.0);
0038 const unsigned int i(4 * iz + 2 * ix + (1 == ix ? 1 - iy : iy));
0039
0040 corners[i] =
0041 GlobalPoint(dy() > dx() ? x + sx * dx() : x + sx * dx() * ct - sz * dz() * st,
0042 dy() < dx() ? y + sy * dy() : y + sy * dy() * ct - sz * dz() * st,
0043 dy() > dx() ? z + sz * dz() * ct + sy * dy() * st : z + sz * dz() * ct + sx * dx() * st);
0044 }
0045 }
0046 }
0047 }
0048 }
0049
0050 std::ostream& operator<<(std::ostream& s, const PreshowerStrip& cell) {
0051 s << "Center: " << cell.getPosition() << std::endl;
0052 if (cell.param() != nullptr) {
0053 s << "dx = " << cell.dx() << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl;
0054
0055 const CaloCellGeometry::CornersVec& corners(cell.getCorners());
0056 for (unsigned int ci(0); ci != corners.size(); ci++) {
0057 s << "Corner: " << corners[ci] << std::endl;
0058 }
0059 } else {
0060 s << " with empty parameters." << std::endl;
0061 }
0062
0063 return s;
0064 }
0065
0066 void PreshowerStrip::localCorners(Pt3DVec& lc, const CCGFloat* pv, Pt3D& ref) {
0067 assert(8 == lc.size());
0068 assert(nullptr != pv);
0069
0070 const CCGFloat dx(pv[0]);
0071 const CCGFloat dy(pv[1]);
0072 const CCGFloat dz(pv[2]);
0073
0074 lc[0] = Pt3D(-dx, -dy, -dz);
0075 lc[1] = Pt3D(-dx, dy, -dz);
0076 lc[2] = Pt3D(dx, dy, -dz);
0077 lc[3] = Pt3D(dx, -dy, -dz);
0078 lc[4] = Pt3D(-dx, -dy, dz);
0079 lc[5] = Pt3D(-dx, dy, dz);
0080 lc[6] = Pt3D(dx, dy, dz);
0081 lc[7] = Pt3D(dx, -dy, dz);
0082
0083 ref = Pt3D(0, 0, 0);
0084 }