Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:40

0001 #include "Geometry/CaloGeometry/interface/IdealZPrism.h"
0002 #include <cmath>
0003 #include <memory>
0004 
0005 typedef IdealZPrism::CCGFloat CCGFloat;
0006 typedef IdealZPrism::Pt3D Pt3D;
0007 typedef IdealZPrism::Pt3DVec Pt3DVec;
0008 
0009 IdealZPrism::IdealZPrism() : CaloCellGeometry() {}
0010 
0011 namespace {
0012 
0013   // magic numbers determined by ParticleFlow
0014   constexpr float EMDepthCorrection = 22.;
0015   constexpr float HADDepthCorrection = 25.;
0016 
0017   GlobalPoint correct(GlobalPoint const& ori, IdealZPrism::DEPTH depth) {
0018     if (depth == IdealZPrism::None)
0019       return ori;
0020     float zcorr = depth == IdealZPrism::EM ? EMDepthCorrection : HADDepthCorrection;
0021     if (ori.z() < 0)
0022       zcorr = -zcorr;
0023     return ori + GlobalVector(0., 0., zcorr);
0024   }
0025 }  // namespace
0026 
0027 IdealZPrism::IdealZPrism(const IdealZPrism& idzp) : CaloCellGeometry(idzp) {
0028   if (idzp.forPF())
0029     m_geoForPF = std::make_unique<IdealZPrism>(*idzp.forPF());
0030 }
0031 
0032 IdealZPrism& IdealZPrism::operator=(const IdealZPrism& idzp) {
0033   if (&idzp != this) {
0034     CaloCellGeometry::operator=(idzp);
0035     if (idzp.forPF())
0036       m_geoForPF = std::make_unique<IdealZPrism>(*idzp.forPF());
0037   }
0038   return *this;
0039 }
0040 
0041 IdealZPrism::IdealZPrism(const GlobalPoint& faceCenter, CornersMgr* mgr, const CCGFloat* parm, IdealZPrism::DEPTH depth)
0042     : CaloCellGeometry(faceCenter, mgr, parm),
0043       m_geoForPF(depth == None ? nullptr : new IdealZPrism(correct(faceCenter, depth), mgr, parm, None)) {
0044   initSpan();
0045 }
0046 
0047 IdealZPrism::~IdealZPrism() {}
0048 
0049 CCGFloat IdealZPrism::dEta() const { return param()[IdealZPrism::k_dEta]; }
0050 
0051 CCGFloat IdealZPrism::dPhi() const { return param()[IdealZPrism::k_dPhi]; }
0052 
0053 CCGFloat IdealZPrism::dz() const { return param()[IdealZPrism::k_dZ]; }
0054 
0055 CCGFloat IdealZPrism::eta() const { return param()[IdealZPrism::k_Eta]; }
0056 
0057 CCGFloat IdealZPrism::z() const { return param()[IdealZPrism::k_Z]; }
0058 
0059 void IdealZPrism::vocalCorners(Pt3DVec& vec, const CCGFloat* pv, Pt3D& ref) const { localCorners(vec, pv, ref); }
0060 
0061 GlobalPoint IdealZPrism::etaPhiR(float eta, float phi, float rad) {
0062   return GlobalPoint(rad * cosf(phi) / coshf(eta), rad * sinf(phi) / coshf(eta), rad * tanhf(eta));
0063 }
0064 
0065 GlobalPoint IdealZPrism::etaPhiPerp(float eta, float phi, float perp) {
0066   return GlobalPoint(perp * cosf(phi), perp * sinf(phi), perp * sinhf(eta));
0067 }
0068 
0069 GlobalPoint IdealZPrism::etaPhiZ(float eta, float phi, float z) {
0070   return GlobalPoint(z * cosf(phi) / sinhf(eta), z * sinf(phi) / sinhf(eta), z);
0071 }
0072 
0073 void IdealZPrism::localCorners(Pt3DVec& lc, const CCGFloat* pv, Pt3D& ref) {
0074   assert(8 == lc.size());
0075   assert(nullptr != pv);
0076 
0077   const CCGFloat dEta(pv[IdealZPrism::k_dEta]);
0078   const CCGFloat dPhi(pv[IdealZPrism::k_dPhi]);
0079   const CCGFloat dz(pv[IdealZPrism::k_dZ]);
0080   const CCGFloat eta(pv[IdealZPrism::k_Eta]);
0081   const CCGFloat z(pv[IdealZPrism::k_Z]);
0082 
0083   std::vector<GlobalPoint> gc(8, GlobalPoint(0, 0, 0));
0084 
0085   const GlobalPoint p(etaPhiZ(eta, 0, z));
0086 
0087   const float z_near(z);
0088   const float z_far(z * (1 - 2 * dz / p.mag()));
0089   gc[0] = etaPhiZ(eta + dEta, +dPhi, z_near);        // (+,+,near)
0090   gc[1] = etaPhiZ(eta + dEta, -dPhi, z_near);        // (+,-,near)
0091   gc[2] = etaPhiZ(eta - dEta, -dPhi, z_near);        // (-,-,near)
0092   gc[3] = etaPhiZ(eta - dEta, +dPhi, z_near);        // (-,+,far)
0093   gc[4] = GlobalPoint(gc[0].x(), gc[0].y(), z_far);  // (+,+,far)
0094   gc[5] = GlobalPoint(gc[1].x(), gc[1].y(), z_far);  // (+,-,far)
0095   gc[6] = GlobalPoint(gc[2].x(), gc[2].y(), z_far);  // (-,-,far)
0096   gc[7] = GlobalPoint(gc[3].x(), gc[3].y(), z_far);  // (-,+,far)
0097 
0098   for (unsigned int i(0); i != 8; ++i) {
0099     lc[i] = Pt3D(gc[i].x(), gc[i].y(), gc[i].z());
0100   }
0101 
0102   ref = 0.25 * (lc[0] + lc[1] + lc[2] + lc[3]);
0103 }
0104 
0105 void IdealZPrism::initCorners(CaloCellGeometry::CornersVec& co) {
0106   if (co.uninitialized()) {
0107     CornersVec& corners(co);
0108 
0109     const GlobalPoint p(getPosition());
0110     const CCGFloat z_near(p.z());
0111     const CCGFloat z_far(z_near + 2 * dz() * p.z() / fabs(p.z()));
0112     const CCGFloat eta(p.eta());
0113     const CCGFloat phi(p.phi());
0114 
0115     corners[0] = etaPhiZ(eta + dEta(), phi + dPhi(), z_near);         // (+,+,near)
0116     corners[1] = etaPhiZ(eta + dEta(), phi - dPhi(), z_near);         // (+,-,near)
0117     corners[2] = etaPhiZ(eta - dEta(), phi - dPhi(), z_near);         // (-,-,near)
0118     corners[3] = etaPhiZ(eta - dEta(), phi + dPhi(), z_near);         // (-,+,near)
0119     corners[4] = GlobalPoint(corners[0].x(), corners[0].y(), z_far);  // (+,+,far)
0120     corners[5] = GlobalPoint(corners[1].x(), corners[1].y(), z_far);  // (+,-,far)
0121     corners[6] = GlobalPoint(corners[2].x(), corners[2].y(), z_far);  // (-,-,far)
0122     corners[7] = GlobalPoint(corners[3].x(), corners[3].y(), z_far);  // (-,+,far)
0123   }
0124 }
0125 
0126 std::ostream& operator<<(std::ostream& s, const IdealZPrism& cell) {
0127   s << "Center: " << cell.getPosition() << std::endl;
0128   s << "dEta = " << cell.dEta() << ", dPhi = " << cell.dPhi() << ", dz = " << cell.dz() << std::endl;
0129   return s;
0130 }