Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:38

0001 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
0002 #include "CLHEP/Geometry/Plane3D.h"
0003 #include "CLHEP/Geometry/Transform3D.h"
0004 #include <cmath>
0005 
0006 typedef CaloCellGeometry::CCGFloat CCGFloat;
0007 typedef CaloCellGeometry::Pt3D Pt3D;
0008 typedef CaloCellGeometry::Pt3DVec Pt3DVec;
0009 typedef CaloCellGeometry::Tr3D Tr3D;
0010 
0011 IdealCastorTrapezoid::IdealCastorTrapezoid() : CaloCellGeometry() {}
0012 
0013 IdealCastorTrapezoid::IdealCastorTrapezoid(const IdealCastorTrapezoid& idct) : CaloCellGeometry(idct) { *this = idct; }
0014 
0015 IdealCastorTrapezoid& IdealCastorTrapezoid::operator=(const IdealCastorTrapezoid& idct) {
0016   if (&idct != this)
0017     CaloCellGeometry::operator=(idct);
0018   return *this;
0019 }
0020 
0021 IdealCastorTrapezoid::IdealCastorTrapezoid(const GlobalPoint& faceCenter, CornersMgr* mgr, const CCGFloat* parm)
0022     : CaloCellGeometry(faceCenter, mgr, parm) {
0023   initSpan();
0024 }
0025 
0026 IdealCastorTrapezoid::~IdealCastorTrapezoid() {}
0027 
0028 CCGFloat IdealCastorTrapezoid::dxl() const { return param()[0]; }
0029 
0030 CCGFloat IdealCastorTrapezoid::dxh() const { return param()[1]; }
0031 
0032 CCGFloat IdealCastorTrapezoid::dx() const { return (dxl() + dxh()) / 2.; }
0033 
0034 CCGFloat IdealCastorTrapezoid::dh() const { return param()[2]; }
0035 
0036 CCGFloat IdealCastorTrapezoid::dy() const { return dh() * sin(an()); }
0037 
0038 CCGFloat IdealCastorTrapezoid::dz() const { return param()[3]; }
0039 
0040 CCGFloat IdealCastorTrapezoid::dhz() const { return dh() * cos(an()); }
0041 
0042 CCGFloat IdealCastorTrapezoid::dzb() const { return dz() + dhz(); }
0043 
0044 CCGFloat IdealCastorTrapezoid::dzs() const { return dz() - dhz(); }
0045 
0046 CCGFloat IdealCastorTrapezoid::an() const { return param()[4]; }
0047 
0048 CCGFloat IdealCastorTrapezoid::dR() const { return param()[5]; }
0049 
0050 void IdealCastorTrapezoid::vocalCorners(Pt3DVec& vec, const CCGFloat* pv, Pt3D& ref) const {
0051   localCorners(vec, pv, ref);
0052 }
0053 
0054 void IdealCastorTrapezoid::localCorners(Pt3DVec& lc, const CCGFloat* pv, Pt3D& ref) {
0055   assert(8 == lc.size());
0056   assert(nullptr != pv);
0057 
0058   const CCGFloat dxl(pv[0]);
0059   const CCGFloat dxh(pv[1]);
0060   const CCGFloat dh(pv[2]);
0061   const CCGFloat dz(pv[3]);
0062   const CCGFloat an(pv[4]);
0063   const CCGFloat dx((dxl + dxh) / 2.);
0064   const CCGFloat dy(dh * sin(an));
0065   const CCGFloat dhz(dh * cos(an));
0066   const CCGFloat dzb(dz + dhz);
0067   const CCGFloat dzs(dz - dhz);
0068 
0069   assert(0 < (dxl * dxh));
0070 
0071   lc[0] = Pt3D(-dx, -dy, dzb);
0072   lc[1] = Pt3D(-dx, +dy, dzs);
0073   lc[2] = Pt3D(+2 * dxh - dx, +dy, dzs);
0074   lc[3] = Pt3D(+2 * dxl - dx, -dy, dzb);
0075   lc[4] = Pt3D(-dx, -dy, -dzs);
0076   lc[5] = Pt3D(-dx, +dy, -dzb);
0077   lc[6] = Pt3D(+2 * dxh - dx, +dy, -dzb);
0078   lc[7] = Pt3D(+2 * dxl - dx, -dy, -dzs);
0079 
0080   ref = 0.25 * (lc[0] + lc[1] + lc[2] + lc[3]);
0081 }
0082 
0083 void IdealCastorTrapezoid::initCorners(CaloCellGeometry::CornersVec& corners) {
0084   if (corners.uninitialized()) {
0085     const GlobalPoint& p(getPosition());
0086     const CCGFloat zsign(0 < p.z() ? 1. : -1.);
0087     const Pt3D gf(p.x(), p.y(), p.z());
0088 
0089     Pt3D lf;
0090     Pt3DVec lc(8, Pt3D(0, 0, 0));
0091     localCorners(lc, param(), lf);
0092     const Pt3D lb(lf.x(), lf.y(), lf.z() - 2. * dz());
0093     const Pt3D ls(lf.x() - dx(), lf.y(), lf.z());
0094 
0095     const CCGFloat fphi(atan(dx() / (dR() + dy())));
0096     const Pt3D gb(gf.x(), gf.y(), gf.z() + 2. * zsign * dz());
0097 
0098     const CCGFloat rho(dR() + dy());
0099     const CCGFloat phi(gf.phi() + fphi);
0100     const Pt3D gs(rho * cos(phi), rho * sin(phi), gf.z());
0101 
0102     const Tr3D tr(lf, lb, ls, gf, gb, gs);
0103 
0104     for (unsigned int i(0); i != 8; ++i) {
0105       const Pt3D gl(tr * lc[i]);
0106       corners[i] = GlobalPoint(gl.x(), gl.y(), gl.z());
0107     }
0108   }
0109 }
0110 
0111 std::ostream& operator<<(std::ostream& s, const IdealCastorTrapezoid& cell) {
0112   s << "Center: " << cell.getPosition() << std::endl;
0113   //      s      << ", dx = " << cell.dx()
0114   //<< "TiltAngle = " << cell.an()
0115   //    << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl ;
0116   return s;
0117 }