CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IdealZPrism.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <memory>
4 
8 
10 
11 namespace {
12 
13  // magic numbers determined by ParticleFlow
14  constexpr float EMDepthCorrection = 22.;
15  constexpr float HADDepthCorrection = 25.;
16 
17  GlobalPoint correct(GlobalPoint const& ori, IdealZPrism::DEPTH depth) {
18  if (depth == IdealZPrism::None)
19  return ori;
20  float zcorr = depth == IdealZPrism::EM ? EMDepthCorrection : HADDepthCorrection;
21  if (ori.z() < 0)
22  zcorr = -zcorr;
23  return ori + GlobalVector(0., 0., zcorr);
24  }
25 } // namespace
26 
28  if (idzp.forPF())
29  m_geoForPF = std::make_unique<IdealZPrism>(*idzp.forPF());
30 }
31 
33  if (&idzp != this) {
34  CaloCellGeometry::operator=(idzp);
35  if (idzp.forPF())
36  m_geoForPF = std::make_unique<IdealZPrism>(*idzp.forPF());
37  }
38  return *this;
39 }
40 
41 IdealZPrism::IdealZPrism(const GlobalPoint& faceCenter, CornersMgr* mgr, const CCGFloat* parm, IdealZPrism::DEPTH depth)
42  : CaloCellGeometry(faceCenter, mgr, parm),
43  m_geoForPF(depth == None ? nullptr : new IdealZPrism(correct(faceCenter, depth), mgr, parm, None)) {
44  initSpan();
45 }
46 
48 
50 
52 
54 
56 
58 
59 void IdealZPrism::vocalCorners(Pt3DVec& vec, const CCGFloat* pv, Pt3D& ref) const { localCorners(vec, pv, ref); }
60 
61 GlobalPoint IdealZPrism::etaPhiR(float eta, float phi, float rad) {
62  return GlobalPoint(rad * cosf(phi) / coshf(eta), rad * sinf(phi) / coshf(eta), rad * tanhf(eta));
63 }
64 
66  return GlobalPoint(perp * cosf(phi), perp * sinf(phi), perp * sinhf(eta));
67 }
68 
69 GlobalPoint IdealZPrism::etaPhiZ(float eta, float phi, float z) {
70  return GlobalPoint(z * cosf(phi) / sinhf(eta), z * sinf(phi) / sinhf(eta), z);
71 }
72 
74  assert(8 == lc.size());
75  assert(nullptr != pv);
76 
79  const CCGFloat dz(pv[IdealZPrism::k_dZ]);
80  const CCGFloat eta(pv[IdealZPrism::k_Eta]);
81  const CCGFloat z(pv[IdealZPrism::k_Z]);
82 
83  std::vector<GlobalPoint> gc(8, GlobalPoint(0, 0, 0));
84 
85  const GlobalPoint p(etaPhiZ(eta, 0, z));
86 
87  const float z_near(z);
88  const float z_far(z * (1 - 2 * dz / p.mag()));
89  gc[0] = etaPhiZ(eta + dEta, +dPhi, z_near); // (+,+,near)
90  gc[1] = etaPhiZ(eta + dEta, -dPhi, z_near); // (+,-,near)
91  gc[2] = etaPhiZ(eta - dEta, -dPhi, z_near); // (-,-,near)
92  gc[3] = etaPhiZ(eta - dEta, +dPhi, z_near); // (-,+,far)
93  gc[4] = GlobalPoint(gc[0].x(), gc[0].y(), z_far); // (+,+,far)
94  gc[5] = GlobalPoint(gc[1].x(), gc[1].y(), z_far); // (+,-,far)
95  gc[6] = GlobalPoint(gc[2].x(), gc[2].y(), z_far); // (-,-,far)
96  gc[7] = GlobalPoint(gc[3].x(), gc[3].y(), z_far); // (-,+,far)
97 
98  for (unsigned int i(0); i != 8; ++i) {
99  lc[i] = Pt3D(gc[i].x(), gc[i].y(), gc[i].z());
100  }
101 
102  ref = 0.25 * (lc[0] + lc[1] + lc[2] + lc[3]);
103 }
104 
106  if (co.uninitialized()) {
107  CornersVec& corners(co);
108 
109  const GlobalPoint p(getPosition());
110  const CCGFloat z_near(p.z());
111  const CCGFloat z_far(z_near + 2 * dz() * p.z() / fabs(p.z()));
112  const CCGFloat eta(p.eta());
113  const CCGFloat phi(p.phi());
114 
115  corners[0] = etaPhiZ(eta + dEta(), phi + dPhi(), z_near); // (+,+,near)
116  corners[1] = etaPhiZ(eta + dEta(), phi - dPhi(), z_near); // (+,-,near)
117  corners[2] = etaPhiZ(eta - dEta(), phi - dPhi(), z_near); // (-,-,near)
118  corners[3] = etaPhiZ(eta - dEta(), phi + dPhi(), z_near); // (-,+,near)
119  corners[4] = GlobalPoint(corners[0].x(), corners[0].y(), z_far); // (+,+,far)
120  corners[5] = GlobalPoint(corners[1].x(), corners[1].y(), z_far); // (+,-,far)
121  corners[6] = GlobalPoint(corners[2].x(), corners[2].y(), z_far); // (-,-,far)
122  corners[7] = GlobalPoint(corners[3].x(), corners[3].y(), z_far); // (-,+,far)
123  }
124 }
125 
126 std::ostream& operator<<(std::ostream& s, const IdealZPrism& cell) {
127  s << "Center: " << cell.getPosition() << std::endl;
128  s << "dEta = " << cell.dEta() << ", dPhi = " << cell.dPhi() << ", dz = " << cell.dz() << std::endl;
129  return s;
130 }
static constexpr uint32_t k_dEta
Definition: IdealZPrism.h:34
CaloCellGeometry::CCGFloat CCGFloat
Definition: IdealZPrism.h:30
CCGFloat eta() const
Definition: IdealZPrism.cc:55
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
static GlobalPoint etaPhiZ(float eta, float phi, float z)
Definition: IdealZPrism.cc:69
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void initCorners(CornersVec &) override
Definition: IdealZPrism.cc:105
static constexpr uint32_t k_dZ
Definition: IdealZPrism.h:36
std::shared_ptr< const IdealZPrism > forPF() const
Definition: IdealZPrism.h:61
static GlobalPoint etaPhiR(float eta, float phi, float rad)
Definition: IdealZPrism.cc:61
std::vector< Pt3D > Pt3DVec
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
assert(be >=bs)
__host__ __device__ VT * co
Definition: prefixScan.h:47
CCGFloat dz() const
Definition: IdealZPrism.cc:53
float float float z
const CCGFloat * param() const
T mag() const
Definition: PV3DBase.h:64
T z() const
Definition: PV3DBase.h:61
std::unique_ptr< IdealZPrism > m_geoForPF
Definition: IdealZPrism.h:78
static constexpr uint32_t k_Z
Definition: IdealZPrism.h:38
CaloCellGeometry::CCGFloat CCGFloat
static constexpr uint32_t k_Eta
Definition: IdealZPrism.h:37
IdealZPrism & operator=(const IdealZPrism &idzp)
Definition: IdealZPrism.cc:32
CaloCellGeometry::Pt3D Pt3D
void vocalCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref) const override
Definition: IdealZPrism.cc:59
~IdealZPrism() override
Definition: IdealZPrism.cc:47
static constexpr uint32_t k_dPhi
Definition: IdealZPrism.h:35
CCGFloat dEta() const
Definition: IdealZPrism.cc:49
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: IdealZPrism.cc:73
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
CaloCellGeometry::Pt3D Pt3D
Definition: IdealZPrism.h:31
Definition: EZMgrFL.h:8
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: IdealZPrism.h:32
CCGFloat dPhi() const
Definition: IdealZPrism.cc:51
T eta() const
Definition: PV3DBase.h:73
T perp() const
Magnitude of transverse component.
static GlobalPoint etaPhiPerp(float eta, float phi, float perp)
Definition: IdealZPrism.cc:65
bool uninitialized() const
Definition: EZArrayFL.h:63
CCGFloat z() const
Definition: IdealZPrism.cc:57
Global3DVector GlobalVector
Definition: GlobalVector.h:10