CMS 3D CMS Logo

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

#include <HGCDoublet.h>

Public Types

using HGCntuplet = std::vector< unsigned int >
 

Public Member Functions

int areAligned (double xi, double yi, double zi, double xo, double yo, double zo, float minCosTheta, float minCosPointing, const GlobalVector &refDir, bool debug=false) const
 
bool areSiblingClusters () const
 
bool checkCompatibilityAndTag (std::vector< HGCDoublet > &allDoublets, const std::vector< int > &innerDoublets, const GlobalVector &refDir, float minCosTheta, float minCosPointing=1., bool debug=false)
 
void findNtuplets (std::vector< HGCDoublet > &allDoublets, HGCntuplet &tmpNtuplet, int seedIndex, const bool outInDFS, const unsigned int outInHops, const unsigned int maxOutInHops, std::vector< std::pair< unsigned int, unsigned int > > &outInToVisit)
 
 HGCDoublet (const int innerClusterId, const int outerClusterId, const int doubletId, const std::vector< reco::CaloCluster > *layerClusters, const int seedIndex, bool areSiblingClusters=false)
 
int innerClusterId () const
 
double innerR () const
 
double innerX () const
 
double innerY () const
 
double innerZ () const
 
int outerClusterId () const
 
double outerR () const
 
double outerX () const
 
double outerY () const
 
double outerZ () const
 
int seedIndex () const
 
void setVisited (bool visited)
 
void tagAsInnerNeighbor (unsigned int otherDoublet)
 
void tagAsOuterNeighbor (unsigned int otherDoublet)
 

Private Attributes

bool alreadyVisited_
 
bool areSiblingClusters_
 
const int innerClusterId_
 
std::vector< int > innerNeighbors_
 
const double innerR_
 
const double innerX_
 
const double innerY_
 
const double innerZ_
 
const std::vector< reco::CaloCluster > * layerClusters_
 
const int outerClusterId_
 
std::vector< int > outerNeighbors_
 
const double outerR_
 
const double outerX_
 
const double outerY_
 
const double outerZ_
 
int seedIndex_
 
const int theDoubletId_
 

Detailed Description

Definition at line 14 of file HGCDoublet.h.

Member Typedef Documentation

◆ HGCntuplet

using HGCDoublet::HGCntuplet = std::vector<unsigned int>

Definition at line 16 of file HGCDoublet.h.

Constructor & Destructor Documentation

◆ HGCDoublet()

HGCDoublet::HGCDoublet ( const int  innerClusterId,
const int  outerClusterId,
const int  doubletId,
const std::vector< reco::CaloCluster > *  layerClusters,
const int  seedIndex,
bool  areSiblingClusters = false 
)
inline

Definition at line 18 of file HGCDoublet.h.

25  theDoubletId_(doubletId),
37  alreadyVisited_(false),
const double outerR_
Definition: HGCDoublet.h:106
int seedIndex_
Definition: HGCDoublet.h:113
const double innerY_
Definition: HGCDoublet.h:109
int innerClusterId() const
Definition: HGCDoublet.h:58
bool alreadyVisited_
Definition: HGCDoublet.h:114
const std::vector< reco::CaloCluster > * layerClusters_
Definition: HGCDoublet.h:97
const double innerZ_
Definition: HGCDoublet.h:111
const double outerY_
Definition: HGCDoublet.h:110
const double innerR_
Definition: HGCDoublet.h:105
const int theDoubletId_
Definition: HGCDoublet.h:101
bool areSiblingClusters() const
Definition: HGCDoublet.h:62
const int outerClusterId_
Definition: HGCDoublet.h:103
const double outerZ_
Definition: HGCDoublet.h:112
const double innerX_
Definition: HGCDoublet.h:107
int seedIndex() const
Definition: HGCDoublet.h:56
static int position[264][3]
Definition: ReadPGInfo.cc:289
bool areSiblingClusters_
Definition: HGCDoublet.h:115
int outerClusterId() const
Definition: HGCDoublet.h:60
const double outerX_
Definition: HGCDoublet.h:108
const int innerClusterId_
Definition: HGCDoublet.h:102

Member Function Documentation

◆ areAligned()

int HGCDoublet::areAligned ( double  xi,
double  yi,
double  zi,
double  xo,
double  yo,
double  zo,
float  minCosTheta,
float  minCosPointing,
const GlobalVector refDir,
bool  debug = false 
) const

Definition at line 70 of file HGCDoublet.cc.

References debug, Vector3DBase< T, FrameTag >::dot(), dot(), innerX(), innerY(), innerZ(), LogDebug, PV3DBase< T, PVType, FrameType >::mag2(), seedIndex_, and protons_cff::xi.

Referenced by checkCompatibilityAndTag().

79  {
80  auto dx1 = xo - xi;
81  auto dy1 = yo - yi;
82  auto dz1 = zo - zi;
83 
84  auto dx2 = innerX() - xi;
85  auto dy2 = innerY() - yi;
86  auto dz2 = innerZ() - zi;
87 
88  // inner product
89  auto dot = dx1 * dx2 + dy1 * dy2 + dz1 * dz2;
90  auto dotsq = dot * dot;
91  // magnitudes
92  auto mag1sq = dx1 * dx1 + dy1 * dy1 + dz1 * dz1;
93  auto mag2sq = dx2 * dx2 + dy2 * dy2 + dz2 * dz2;
94 
95  auto minCosTheta_sq = minCosTheta * minCosTheta;
96  bool isWithinLimits = (dotsq > minCosTheta_sq * mag1sq * mag2sq);
97 
98  if (debug) {
99  LogDebug("HGCDoublet") << "-- Are Aligned -- dotsq: " << dotsq << " mag1sq: " << mag1sq << " mag2sq: " << mag2sq
100  << "minCosTheta_sq:" << minCosTheta_sq << " isWithinLimits: " << isWithinLimits << std::endl;
101  }
102 
103  // Now check the compatibility with the pointing origin.
104  // Pointing origin is a vector obtained by the seed (track extrapolation i.e.)
105  // or the direction wrt (0,0,0)
106  // The compatibility is checked only for the innermost doublets: the
107  // one with the outer doublets comes in by the alignment requirement of
108  // the doublets themeselves
109 
110  const GlobalVector firstDoublet(dx2, dy2, dz2);
111  const GlobalVector pointingDir = (seedIndex_ == -1) ? GlobalVector(innerX(), innerY(), innerZ()) : refDir;
112 
113  auto dot_pointing = pointingDir.dot(firstDoublet);
114  auto dot_pointing_sq = dot_pointing * dot_pointing;
115  auto mag_pointing_sq = pointingDir.mag2();
116  auto minCosPointing_sq = minCosPointing * minCosPointing;
117  bool isWithinLimitsPointing = (dot_pointing_sq > minCosPointing_sq * mag_pointing_sq * mag2sq);
118  if (debug) {
119  LogDebug("HGCDoublet") << "Pointing direction: " << pointingDir << std::endl;
120  LogDebug("HGCDoublet") << "-- Are Aligned -- dot_pointing_sq: " << dot_pointing_sq
121  << " mag_pointing_sq: " << mag_pointing_sq << " mag2sq: " << mag2sq
122  << " isWithinLimitsPointing: " << isWithinLimitsPointing << std::endl;
123  }
124  // by squaring cosTheta and multiplying by the squares of the magnitudes
125  // an equivalent comparison is made without the division and square root which are costly FP ops.
126  return isWithinLimits && isWithinLimitsPointing;
127 }
int seedIndex_
Definition: HGCDoublet.h:113
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
T mag2() const
Definition: PV3DBase.h:63
double innerZ() const
Definition: HGCDoublet.h:48
double innerX() const
Definition: HGCDoublet.h:40
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
#define debug
Definition: HDRShower.cc:19
double innerY() const
Definition: HGCDoublet.h:44
Global3DVector GlobalVector
Definition: GlobalVector.h:10
#define LogDebug(id)

◆ areSiblingClusters()

bool HGCDoublet::areSiblingClusters ( ) const
inline

Definition at line 62 of file HGCDoublet.h.

References areSiblingClusters_.

62 { return areSiblingClusters_; }
bool areSiblingClusters_
Definition: HGCDoublet.h:115

◆ checkCompatibilityAndTag()

bool HGCDoublet::checkCompatibilityAndTag ( std::vector< HGCDoublet > &  allDoublets,
const std::vector< int > &  innerDoublets,
const GlobalVector refDir,
float  minCosTheta,
float  minCosPointing = 1.,
bool  debug = false 
)

Definition at line 3 of file HGCDoublet.cc.

References areAligned(), areSiblingClusters_, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), debug, mps_fire::i, innerNeighbors_, dqmiolumiharvest::j, LogDebug, heppy_loop::loop, convertSQLiteXML::ok, outerX(), outerY(), outerZ(), seedIndex_, theDoubletId_, and protons_cff::xi.

8  {
9  int nDoublets = innerDoublets.size();
10  int constexpr VSIZE = 4;
11  int ok[VSIZE];
12  double xi[VSIZE];
13  double yi[VSIZE];
14  double zi[VSIZE];
15  int seedi[VSIZE];
16  bool siblingsClusters[VSIZE];
17  auto xo = outerX();
18  auto yo = outerY();
19  auto zo = outerZ();
20  unsigned int doubletId = theDoubletId_;
21 
22  auto loop = [&](int i, int vs) {
23  for (int j = 0; j < vs; ++j) {
24  auto otherDoubletId = innerDoublets[i + j];
25  auto &otherDoublet = allDoublets[otherDoubletId];
26  xi[j] = otherDoublet.innerX();
27  yi[j] = otherDoublet.innerY();
28  zi[j] = otherDoublet.innerZ();
29  seedi[j] = otherDoublet.seedIndex();
30  siblingsClusters[j] = otherDoublet.areSiblingClusters();
31  if (debug) {
32  LogDebug("HGCDoublet") << i + j << " is doublet " << otherDoubletId << std::endl;
33  }
34  }
35  for (int j = 0; j < vs; ++j) {
36  if (seedi[j] != seedIndex_) {
37  ok[j] = 0;
38  continue;
39  }
40  if (areSiblingClusters_ and siblingsClusters[j]) {
41  ok[j] = 1;
42  continue;
43  }
44  ok[j] = areAligned(xi[j], yi[j], zi[j], xo, yo, zo, minCosTheta, minCosPointing, refDir, debug);
45  if (debug) {
46  LogDebug("HGCDoublet") << "Are aligned for InnerDoubletId: " << i + j << " is " << ok[j] << std::endl;
47  }
48  }
49  for (int j = 0; j < vs; ++j) {
50  auto otherDoubletId = innerDoublets[i + j];
51  auto &otherDoublet = allDoublets[otherDoubletId];
52  if (ok[j]) {
53  otherDoublet.tagAsOuterNeighbor(doubletId);
54  allDoublets[doubletId].tagAsInnerNeighbor(otherDoubletId);
55  }
56  }
57  };
58  auto lim = VSIZE * (nDoublets / VSIZE);
59  for (int i = 0; i < lim; i += VSIZE)
60  loop(i, VSIZE);
61  loop(lim, nDoublets - lim);
62 
63  if (debug) {
64  LogDebug("HGCDoublet") << "Found " << innerNeighbors_.size() << " compatible doublets out of " << nDoublets
65  << " considered" << std::endl;
66  }
67  return innerNeighbors_.empty();
68 }
int seedIndex_
Definition: HGCDoublet.h:113
double outerX() const
Definition: HGCDoublet.h:42
int areAligned(double xi, double yi, double zi, double xo, double yo, double zo, float minCosTheta, float minCosPointing, const GlobalVector &refDir, bool debug=false) const
Definition: HGCDoublet.cc:70
const int theDoubletId_
Definition: HGCDoublet.h:101
std::vector< int > innerNeighbors_
Definition: HGCDoublet.h:99
#define debug
Definition: HDRShower.cc:19
double outerZ() const
Definition: HGCDoublet.h:50
double outerY() const
Definition: HGCDoublet.h:46
bool areSiblingClusters_
Definition: HGCDoublet.h:115
#define LogDebug(id)

◆ findNtuplets()

void HGCDoublet::findNtuplets ( std::vector< HGCDoublet > &  allDoublets,
HGCntuplet tmpNtuplet,
int  seedIndex,
const bool  outInDFS,
const unsigned int  outInHops,
const unsigned int  maxOutInHops,
std::vector< std::pair< unsigned int, unsigned int > > &  outInToVisit 
)

Definition at line 129 of file HGCDoublet.cc.

References alreadyVisited_, mps_fire::i, innerNeighbors_, outerNeighbors_, seedIndex(), seedIndex_, and theDoubletId_.

135  {
136  if (!alreadyVisited_ && seedIndex == seedIndex_) {
137  alreadyVisited_ = true;
138  tmpNtuplet.push_back(theDoubletId_);
139  unsigned int numberOfOuterNeighbors = outerNeighbors_.size();
140  for (unsigned int i = 0; i < numberOfOuterNeighbors; ++i) {
141  allDoublets[outerNeighbors_[i]].findNtuplets(
142  allDoublets, tmpNtuplet, seedIndex, outInDFS, outInHops, maxOutInHops, outInToVisit);
143  }
144  if (outInDFS && outInHops < maxOutInHops) {
145  for (auto inN : innerNeighbors_) {
146  outInToVisit.emplace_back(inN, outInHops + 1);
147  }
148  }
149  }
150 }
std::vector< int > outerNeighbors_
Definition: HGCDoublet.h:98
int seedIndex_
Definition: HGCDoublet.h:113
bool alreadyVisited_
Definition: HGCDoublet.h:114
const int theDoubletId_
Definition: HGCDoublet.h:101
std::vector< int > innerNeighbors_
Definition: HGCDoublet.h:99
int seedIndex() const
Definition: HGCDoublet.h:56

◆ innerClusterId()

int HGCDoublet::innerClusterId ( ) const
inline

Definition at line 58 of file HGCDoublet.h.

References innerClusterId_.

58 { return innerClusterId_; }
const int innerClusterId_
Definition: HGCDoublet.h:102

◆ innerR()

double HGCDoublet::innerR ( ) const
inline

Definition at line 52 of file HGCDoublet.h.

References innerR_.

52 { return innerR_; }
const double innerR_
Definition: HGCDoublet.h:105

◆ innerX()

double HGCDoublet::innerX ( ) const
inline

Definition at line 40 of file HGCDoublet.h.

References innerX_.

Referenced by areAligned().

40 { return innerX_; }
const double innerX_
Definition: HGCDoublet.h:107

◆ innerY()

double HGCDoublet::innerY ( ) const
inline

Definition at line 44 of file HGCDoublet.h.

References innerY_.

Referenced by areAligned().

44 { return innerY_; }
const double innerY_
Definition: HGCDoublet.h:109

◆ innerZ()

double HGCDoublet::innerZ ( ) const
inline

Definition at line 48 of file HGCDoublet.h.

References innerZ_.

Referenced by areAligned().

48 { return innerZ_; }
const double innerZ_
Definition: HGCDoublet.h:111

◆ outerClusterId()

int HGCDoublet::outerClusterId ( ) const
inline

Definition at line 60 of file HGCDoublet.h.

References outerClusterId_.

60 { return outerClusterId_; }
const int outerClusterId_
Definition: HGCDoublet.h:103

◆ outerR()

double HGCDoublet::outerR ( ) const
inline

Definition at line 54 of file HGCDoublet.h.

References outerR_.

54 { return outerR_; }
const double outerR_
Definition: HGCDoublet.h:106

◆ outerX()

double HGCDoublet::outerX ( ) const
inline

Definition at line 42 of file HGCDoublet.h.

References outerX_.

Referenced by checkCompatibilityAndTag().

42 { return outerX_; }
const double outerX_
Definition: HGCDoublet.h:108

◆ outerY()

double HGCDoublet::outerY ( ) const
inline

Definition at line 46 of file HGCDoublet.h.

References outerY_.

Referenced by checkCompatibilityAndTag().

46 { return outerY_; }
const double outerY_
Definition: HGCDoublet.h:110

◆ outerZ()

double HGCDoublet::outerZ ( ) const
inline

Definition at line 50 of file HGCDoublet.h.

References outerZ_.

Referenced by checkCompatibilityAndTag().

50 { return outerZ_; }
const double outerZ_
Definition: HGCDoublet.h:112

◆ seedIndex()

int HGCDoublet::seedIndex ( ) const
inline

Definition at line 56 of file HGCDoublet.h.

References seedIndex_.

Referenced by findNtuplets().

56 { return seedIndex_; }
int seedIndex_
Definition: HGCDoublet.h:113

◆ setVisited()

void HGCDoublet::setVisited ( bool  visited)
inline

Definition at line 94 of file HGCDoublet.h.

References alreadyVisited_, and class-composition::visited.

◆ tagAsInnerNeighbor()

void HGCDoublet::tagAsInnerNeighbor ( unsigned int  otherDoublet)
inline

Definition at line 66 of file HGCDoublet.h.

References innerNeighbors_.

66 { innerNeighbors_.push_back(otherDoublet); }
std::vector< int > innerNeighbors_
Definition: HGCDoublet.h:99

◆ tagAsOuterNeighbor()

void HGCDoublet::tagAsOuterNeighbor ( unsigned int  otherDoublet)
inline

Definition at line 64 of file HGCDoublet.h.

References outerNeighbors_.

64 { outerNeighbors_.push_back(otherDoublet); }
std::vector< int > outerNeighbors_
Definition: HGCDoublet.h:98

Member Data Documentation

◆ alreadyVisited_

bool HGCDoublet::alreadyVisited_
private

Definition at line 114 of file HGCDoublet.h.

Referenced by findNtuplets(), and setVisited().

◆ areSiblingClusters_

bool HGCDoublet::areSiblingClusters_
private

Definition at line 115 of file HGCDoublet.h.

Referenced by areSiblingClusters(), and checkCompatibilityAndTag().

◆ innerClusterId_

const int HGCDoublet::innerClusterId_
private

Definition at line 102 of file HGCDoublet.h.

Referenced by innerClusterId().

◆ innerNeighbors_

std::vector<int> HGCDoublet::innerNeighbors_
private

Definition at line 99 of file HGCDoublet.h.

Referenced by checkCompatibilityAndTag(), findNtuplets(), and tagAsInnerNeighbor().

◆ innerR_

const double HGCDoublet::innerR_
private

Definition at line 105 of file HGCDoublet.h.

Referenced by innerR().

◆ innerX_

const double HGCDoublet::innerX_
private

Definition at line 107 of file HGCDoublet.h.

Referenced by innerX().

◆ innerY_

const double HGCDoublet::innerY_
private

Definition at line 109 of file HGCDoublet.h.

Referenced by innerY().

◆ innerZ_

const double HGCDoublet::innerZ_
private

Definition at line 111 of file HGCDoublet.h.

Referenced by innerZ().

◆ layerClusters_

const std::vector<reco::CaloCluster>* HGCDoublet::layerClusters_
private

Definition at line 97 of file HGCDoublet.h.

◆ outerClusterId_

const int HGCDoublet::outerClusterId_
private

Definition at line 103 of file HGCDoublet.h.

Referenced by outerClusterId().

◆ outerNeighbors_

std::vector<int> HGCDoublet::outerNeighbors_
private

Definition at line 98 of file HGCDoublet.h.

Referenced by findNtuplets(), and tagAsOuterNeighbor().

◆ outerR_

const double HGCDoublet::outerR_
private

Definition at line 106 of file HGCDoublet.h.

Referenced by outerR().

◆ outerX_

const double HGCDoublet::outerX_
private

Definition at line 108 of file HGCDoublet.h.

Referenced by outerX().

◆ outerY_

const double HGCDoublet::outerY_
private

Definition at line 110 of file HGCDoublet.h.

Referenced by outerY().

◆ outerZ_

const double HGCDoublet::outerZ_
private

Definition at line 112 of file HGCDoublet.h.

Referenced by outerZ().

◆ seedIndex_

int HGCDoublet::seedIndex_
private

Definition at line 113 of file HGCDoublet.h.

Referenced by areAligned(), checkCompatibilityAndTag(), findNtuplets(), and seedIndex().

◆ theDoubletId_

const int HGCDoublet::theDoubletId_
private

Definition at line 101 of file HGCDoublet.h.

Referenced by checkCompatibilityAndTag(), and findNtuplets().