CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
CaloCellCrossing Class Reference

#include <CaloCellCrossing.h>

Public Types

typedef std::vector< DetIdDetIds
 
typedef std::vector< double > Lengths
 
typedef std::vector< GlobalPointPoints
 

Public Member Functions

 CaloCellCrossing (const GlobalPoint &gp, const GlobalVector &gv, const DetIds *di, const CaloSubdetectorGeometry *sg, DetId::Detector det, int subdet, double small=1.e-10, bool onewayonly=false)
 
 CaloCellCrossing (const CaloCellCrossing &)=delete
 
const Pointscenters () const
 
const DetIdsdetIds () const
 
const Pointsentrances () const
 
const Pointsexits () const
 
const GlobalPointgp () const
 
const GlobalVectorgv () const
 
const Lengthslengths () const
 
CaloCellCrossing operator= (const CaloCellCrossing &)=delete
 
virtual ~CaloCellCrossing ()
 

Private Attributes

Points m_ctr
 
DetIds m_detId
 
Points m_entr
 
Points m_exit
 
GlobalPoint m_gp
 
GlobalVector m_gv
 
Lengths m_len
 

Detailed Description

Definition at line 12 of file CaloCellCrossing.h.

Member Typedef Documentation

◆ DetIds

typedef std::vector<DetId> CaloCellCrossing::DetIds

Definition at line 14 of file CaloCellCrossing.h.

◆ Lengths

typedef std::vector<double> CaloCellCrossing::Lengths

Definition at line 16 of file CaloCellCrossing.h.

◆ Points

typedef std::vector<GlobalPoint> CaloCellCrossing::Points

Definition at line 15 of file CaloCellCrossing.h.

Constructor & Destructor Documentation

◆ CaloCellCrossing() [1/2]

CaloCellCrossing::CaloCellCrossing ( const GlobalPoint gp,
const GlobalVector gv,
const DetIds di,
const CaloSubdetectorGeometry sg,
DetId::Detector  det,
int  subdet,
double  small = 1.e-10,
bool  onewayonly = false 
)

Definition at line 5 of file CaloCellCrossing.cc.

References cms::cuda::assert(), dqmiodatasetharvest::ctr, cuy::cv, dot(), MillePedeFileConverter_cfg::e, HLT_2022v12_cff::eps, newFWLiteAna::found, CaloSubdetectorGeometry::getGeometry(), CaloSubdetectorGeometry::getValidDetIds(), gp(), gv(), mps_fire::i, mps_splice::line, LogDebug, m_ctr, m_detId, m_entr, m_exit, m_len, mag(), mag2(), HepLine3D::point(), DiDispStaMuonMonitor_cfi::pt, mathSSE::sqrt(), x, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

13  : m_gp(gp), m_gv(gv) {
14  const double eps(fabs(small) > 1.e-15 ? fabs(small) : 1.e-10);
15  static unsigned int k_rlen(30);
16  m_detId.reserve(k_rlen);
17  m_ctr.reserve(k_rlen);
18  m_entr.reserve(k_rlen);
19  m_exit.reserve(k_rlen);
20  //------------------------------------------------------------
21  const HepLine3D line(
22  HepGeom::Point3D<double>(gp.x(), gp.y(), gp.z()), HepGeom::Vector3D<double>(gv.x(), gv.y(), gv.z()), eps);
23 
24  LogDebug("CaloCellCrossing") << "*** Line: pt=" << line.pt() << ", unitvec=" << line.uv();
25 
26  const DetIds& ids(nullptr == di ? sg->getValidDetIds(det, subdet) : *di);
27  //------------------------------------------------------------
28  for (auto dId : ids) {
29  unsigned int found(0);
30  auto cg = sg->getGeometry(dId);
31  const CaloCellGeometry::CornersVec& gc(cg->getCorners());
32  const HepGeom::Point3D<double> fr(cg->getPosition().x(), cg->getPosition().y(), cg->getPosition().z());
33  const double bCut2((gc[0] - gc[6]).mag2());
34 
35  if ((!onewayonly || eps < HepGeom::Vector3D<double>(fr - line.pt()).dot(line.uv())) &&
36  bCut2 > line.dist2(fr)) // first loose cut
37  {
38  LogDebug("CaloCellCrossing") << "*** fr=" << fr << ", bCut =" << sqrt(bCut2) << ", dis=" << line.dist(fr);
39  const HepGeom::Point3D<double> cv[8] = {HepGeom::Point3D<double>(gc[0].x(), gc[0].y(), gc[0].z()),
40  HepGeom::Point3D<double>(gc[1].x(), gc[1].y(), gc[1].z()),
41  HepGeom::Point3D<double>(gc[2].x(), gc[2].y(), gc[2].z()),
42  HepGeom::Point3D<double>(gc[3].x(), gc[3].y(), gc[3].z()),
43  HepGeom::Point3D<double>(gc[4].x(), gc[4].y(), gc[4].z()),
44  HepGeom::Point3D<double>(gc[5].x(), gc[5].y(), gc[5].z()),
45  HepGeom::Point3D<double>(gc[6].x(), gc[6].y(), gc[6].z()),
46  HepGeom::Point3D<double>(gc[7].x(), gc[7].y(), gc[7].z())};
47  const HepGeom::Point3D<double> ctr(0.125 * (cv[0] + cv[1] + cv[2] + cv[3] + cv[4] + cv[5] + cv[6] + cv[7]));
48  const double dCut2(bCut2 / 4.);
49  if (dCut2 > line.dist2(ctr)) // tighter cut
50  {
51  LogDebug("CaloCellCrossing") << "** 2nd cut: ctr=" << ctr << ", dist=" << line.dist(ctr);
52  static const unsigned int nc[6][4] = {
53  {0, 1, 2, 3}, {0, 4, 5, 1}, {0, 4, 7, 3}, {6, 7, 4, 5}, {6, 2, 3, 7}, {6, 2, 1, 5}};
54  for (unsigned int face(0); face != 6; ++face) {
55  const unsigned int* ic(&nc[face][0]);
56  const HepGeom::Plane3D<double> pl(cv[ic[0]], cv[ic[1]], cv[ic[2]]);
57  bool parallel;
58  const HepGeom::Point3D<double> pt(line.point(pl, parallel));
59  LogDebug("CaloCellCrossing") << "***Face: " << face << ", pt=" << pt;
60  if (!parallel) {
61  LogDebug("CaloCellCrossing") << "Not parallel";
62  const HepLine3D la(cv[ic[0]], cv[ic[1]], eps);
63  const HepLine3D lb(cv[ic[2]], cv[ic[3]], eps);
64  LogDebug("CaloCellCrossing") << "la.point=" << la.point(pt);
65 
66  // const double dot ( ( la.point( pt ) - pt ).dot( ( lb.point( pt ) - pt ) ) ) ;
67  // LogDebug("CaloCellCrossing")<<"***Dot1="<<dot;
68  if (eps > (la.point(pt) - pt).dot((lb.point(pt) - pt))) {
69  const HepLine3D lc(cv[ic[0]], cv[ic[3]], eps);
70  const HepLine3D ld(cv[ic[1]], cv[ic[2]], eps);
71  // const double dot ( ( lc.point( pt ) - pt ).dot( ( ld.point( pt ) - pt ) ) ) ;
72  // LogDebug("CaloCellCrossing")<<"***Dot2="<<dot;
73  if (eps > (lc.point(pt) - pt).dot((ld.point(pt) - pt))) {
74  if (0 == found) {
75  ++found;
76  m_detId.emplace_back(dId);
77  m_ctr.emplace_back(GlobalPoint(ctr.x(), ctr.y(), ctr.z()));
78  m_entr.emplace_back(GlobalPoint(pt.x(), pt.y(), pt.z()));
79  } else {
80  if (1 == found) {
81  ++found;
82  m_exit.emplace_back(GlobalPoint(pt.x(), pt.y(), pt.z()));
83  } else {
84  const double dist1(
85  (pt - HepGeom::Point3D<double>(m_entr.back().x(), m_entr.back().y(), m_entr.back().z())).mag());
86  const double dist2(
87  (pt - HepGeom::Point3D<double>(m_exit.back().x(), m_exit.back().y(), m_exit.back().z())).mag());
88  if (eps < dist1 && eps < dist2) {
89  edm::LogWarning("CaloCellCrossing")
90  << "********For DetId = " << dId << " distances too big: " << dist1 << ", " << dist2;
91  }
92  }
93  }
94  }
95  }
96  }
97  }
98  }
99  }
100  assert(2 >= found);
101  if (1 == found)
102  m_exit.emplace_back(m_entr.back());
103  }
104  //------------------------------------------------------------
105  assert(m_detId.size() == m_entr.size() && m_detId.size() == m_ctr.size() && m_detId.size() == m_exit.size());
106 
107  m_len.reserve(m_entr.size());
108  for (unsigned int i(0); i != m_entr.size(); ++i) {
109  m_len.emplace_back((m_exit[i] - m_entr[i]).mag());
110  }
111 }
T z() const
Definition: PV3DBase.h:61
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
cv
Definition: cuy.py:363
assert(be >=bs)
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
const GlobalPoint & gp() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
std::vector< DetId > DetIds
const GlobalVector & gv() const
Log< level::Warning, false > LogWarning
GlobalVector m_gv
#define LogDebug(id)

◆ ~CaloCellCrossing()

virtual CaloCellCrossing::~CaloCellCrossing ( )
inlinevirtual

Definition at line 27 of file CaloCellCrossing.h.

27 {};

◆ CaloCellCrossing() [2/2]

CaloCellCrossing::CaloCellCrossing ( const CaloCellCrossing )
delete

Member Function Documentation

◆ centers()

const Points& CaloCellCrossing::centers ( ) const
inline

Definition at line 33 of file CaloCellCrossing.h.

References m_ctr.

33 { return m_ctr; }

◆ detIds()

const DetIds& CaloCellCrossing::detIds ( ) const
inline

Definition at line 32 of file CaloCellCrossing.h.

References m_detId.

32 { return m_detId; }

◆ entrances()

const Points& CaloCellCrossing::entrances ( ) const
inline

Definition at line 34 of file CaloCellCrossing.h.

References m_entr.

34 { return m_entr; }

◆ exits()

const Points& CaloCellCrossing::exits ( ) const
inline

Definition at line 35 of file CaloCellCrossing.h.

References m_exit.

35 { return m_exit; }

◆ gp()

const GlobalPoint& CaloCellCrossing::gp ( ) const
inline

Definition at line 29 of file CaloCellCrossing.h.

References m_gp.

Referenced by CaloCellCrossing().

29 { return m_gp; }

◆ gv()

const GlobalVector& CaloCellCrossing::gv ( ) const
inline

Definition at line 30 of file CaloCellCrossing.h.

References m_gv.

Referenced by CaloCellCrossing().

30 { return m_gv; }
GlobalVector m_gv

◆ lengths()

const Lengths& CaloCellCrossing::lengths ( ) const
inline

Definition at line 36 of file CaloCellCrossing.h.

References m_len.

36 { return m_len; }

◆ operator=()

CaloCellCrossing CaloCellCrossing::operator= ( const CaloCellCrossing )
delete

Member Data Documentation

◆ m_ctr

Points CaloCellCrossing::m_ctr
private

Definition at line 47 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and centers().

◆ m_detId

DetIds CaloCellCrossing::m_detId
private

Definition at line 45 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and detIds().

◆ m_entr

Points CaloCellCrossing::m_entr
private

Definition at line 49 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and entrances().

◆ m_exit

Points CaloCellCrossing::m_exit
private

Definition at line 50 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and exits().

◆ m_gp

GlobalPoint CaloCellCrossing::m_gp
private

Definition at line 42 of file CaloCellCrossing.h.

Referenced by gp().

◆ m_gv

GlobalVector CaloCellCrossing::m_gv
private

Definition at line 43 of file CaloCellCrossing.h.

Referenced by gv().

◆ m_len

Lengths CaloCellCrossing::m_len
private

Definition at line 51 of file CaloCellCrossing.h.

Referenced by CaloCellCrossing(), and lengths().