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 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)
 
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_
 
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

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

Definition at line 16 of file HGCDoublet.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file HGCDoublet.h.

23  : layerClusters_(layerClusters),
24  theDoubletId_(doubletId),
27  innerR_((*layerClusters)[innerClusterId].position().r()),
28  outerR_((*layerClusters)[outerClusterId].position().r()),
29  innerX_((*layerClusters)[innerClusterId].x()),
30  outerX_((*layerClusters)[outerClusterId].x()),
31  innerY_((*layerClusters)[innerClusterId].y()),
32  outerY_((*layerClusters)[outerClusterId].y()),
33  innerZ_((*layerClusters)[innerClusterId].z()),
34  outerZ_((*layerClusters)[outerClusterId].z()),
36  alreadyVisited_(false) {}
const double outerR_
Definition: HGCDoublet.h:102
int outerClusterId() const
Definition: HGCDoublet.h:58
int seedIndex_
Definition: HGCDoublet.h:109
const double innerY_
Definition: HGCDoublet.h:105
int innerClusterId() const
Definition: HGCDoublet.h:56
bool alreadyVisited_
Definition: HGCDoublet.h:110
const std::vector< reco::CaloCluster > * layerClusters_
Definition: HGCDoublet.h:93
const double innerZ_
Definition: HGCDoublet.h:107
const double outerY_
Definition: HGCDoublet.h:106
const double innerR_
Definition: HGCDoublet.h:101
const int theDoubletId_
Definition: HGCDoublet.h:97
const int outerClusterId_
Definition: HGCDoublet.h:99
const double outerZ_
Definition: HGCDoublet.h:108
const double innerX_
Definition: HGCDoublet.h:103
int seedIndex() const
Definition: HGCDoublet.h:54
static int position[264][3]
Definition: ReadPGInfo.cc:289
const double outerX_
Definition: HGCDoublet.h:104
const int innerClusterId_
Definition: HGCDoublet.h:98

Member Function Documentation

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 61 of file HGCDoublet.cc.

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

Referenced by checkCompatibilityAndTag(), and tagAsInnerNeighbor().

70  {
71  auto dx1 = xo - xi;
72  auto dy1 = yo - yi;
73  auto dz1 = zo - zi;
74 
75  auto dx2 = innerX() - xi;
76  auto dy2 = innerY() - yi;
77  auto dz2 = innerZ() - zi;
78 
79  // inner product
80  auto dot = dx1 * dx2 + dy1 * dy2 + dz1 * dz2;
81  // magnitudes
82  auto mag1 = std::sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
83  auto mag2 = std::sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
84  // angle between the vectors
85  auto cosTheta = dot / (mag1 * mag2);
86  if (debug) {
87  LogDebug("HGCDoublet") << "dot: " << dot << " mag1: " << mag1 << " mag2: " << mag2 << " cosTheta: " << cosTheta
88  << " isWithinLimits: " << (cosTheta > minCosTheta) << std::endl;
89  }
90 
91  // Now check the compatibility with the pointing origin.
92  // Pointing origin is a vector obtained by the seed (track extrapolation i.e.)
93  // or the direction wrt (0,0,0)
94  // The compatibility is checked only for the innermost doublets: the
95  // one with the outer doublets comes in by the alignment requirement of
96  // the doublets themeselves
97 
98  const GlobalVector firstDoublet(dx2, dy2, dz2);
99  const GlobalVector pointingDir = (seedIndex_ == -1) ? GlobalVector(innerX(), innerY(), innerZ()) : refDir;
100 
101  auto dot_pointing = pointingDir.dot(firstDoublet);
102  auto mag_pointing = sqrt(pointingDir.mag2());
103  auto cosTheta_pointing = dot_pointing / (mag2 * mag_pointing);
104  if (debug) {
105  LogDebug("HGCDoublet") << "dot_pointing: " << dot_pointing << " mag_pointing: " << mag_pointing << " mag2: " << mag2
106  << " cosTheta_pointing: " << cosTheta_pointing
107  << " isWithinLimits: " << (cosTheta_pointing < minCosPointing) << std::endl;
108  }
109 
110  return (cosTheta > minCosTheta) && (cosTheta_pointing > minCosPointing);
111 }
#define LogDebug(id)
T mag2() const
Definition: PV3DBase.h:63
int seedIndex_
Definition: HGCDoublet.h:109
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
T sqrt(T t)
Definition: SSEVec.h:19
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double innerX() const
Definition: HGCDoublet.h:38
double innerY() const
Definition: HGCDoublet.h:42
#define debug
Definition: HDRShower.cc:19
double innerZ() const
Definition: HGCDoublet.h:46
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
Global3DVector GlobalVector
Definition: GlobalVector.h:10
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(), constexpr, mps_fire::i, innerNeighbors_, dqmiolumiharvest::j, LogDebug, heppy_loop::loop, convertSQLiteXML::ok, outerX(), outerY(), outerZ(), seedIndex_, theDoubletId_, and hybridSuperClusters_cfi::xi.

Referenced by tagAsInnerNeighbor().

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  auto xo = outerX();
17  auto yo = outerY();
18  auto zo = outerZ();
19  unsigned int doubletId = theDoubletId_;
20 
21  auto loop = [&](int i, int vs) {
22  for (int j = 0; j < vs; ++j) {
23  auto otherDoubletId = innerDoublets[i + j];
24  auto &otherDoublet = allDoublets[otherDoubletId];
25  xi[j] = otherDoublet.innerX();
26  yi[j] = otherDoublet.innerY();
27  zi[j] = otherDoublet.innerZ();
28  seedi[j] = otherDoublet.seedIndex();
29  }
30  for (int j = 0; j < vs; ++j) {
31  if (seedi[j] != seedIndex_) {
32  ok[j] = 0;
33  continue;
34  }
35  ok[j] = areAligned(xi[j], yi[j], zi[j], xo, yo, zo, minCosTheta, minCosPointing, refDir, debug);
36  if (debug) {
37  LogDebug("HGCDoublet") << "Are aligned for InnerDoubletId: " << i + j << " is " << ok[j] << std::endl;
38  }
39  }
40  for (int j = 0; j < vs; ++j) {
41  auto otherDoubletId = innerDoublets[i + j];
42  auto &otherDoublet = allDoublets[otherDoubletId];
43  if (ok[j]) {
44  otherDoublet.tagAsOuterNeighbor(doubletId);
45  allDoublets[doubletId].tagAsInnerNeighbor(otherDoubletId);
46  }
47  }
48  };
49  auto lim = VSIZE * (nDoublets / VSIZE);
50  for (int i = 0; i < lim; i += VSIZE)
51  loop(i, VSIZE);
52  loop(lim, nDoublets - lim);
53 
54  if (debug) {
55  LogDebug("HGCDoublet") << "Found " << innerNeighbors_.size() << " compatible doublets out of " << nDoublets
56  << " considered" << std::endl;
57  }
58  return innerNeighbors_.empty();
59 }
#define LogDebug(id)
int seedIndex_
Definition: HGCDoublet.h:109
double outerZ() const
Definition: HGCDoublet.h:48
double outerX() const
Definition: HGCDoublet.h:40
const int theDoubletId_
Definition: HGCDoublet.h:97
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:61
std::vector< int > innerNeighbors_
Definition: HGCDoublet.h:95
#define debug
Definition: HDRShower.cc:19
double outerY() const
Definition: HGCDoublet.h:44
#define constexpr
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 113 of file HGCDoublet.cc.

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

Referenced by tagAsInnerNeighbor().

119  {
120  if (!alreadyVisited_ && seedIndex == seedIndex_) {
121  alreadyVisited_ = true;
122  tmpNtuplet.push_back(theDoubletId_);
123  unsigned int numberOfOuterNeighbors = outerNeighbors_.size();
124  for (unsigned int i = 0; i < numberOfOuterNeighbors; ++i) {
125  allDoublets[outerNeighbors_[i]].findNtuplets(
126  allDoublets, tmpNtuplet, seedIndex, outInDFS, outInHops, maxOutInHops, outInToVisit);
127  }
128  if (outInDFS && outInHops < maxOutInHops) {
129  for (auto inN : innerNeighbors_) {
130  outInToVisit.emplace_back(inN, outInHops + 1);
131  }
132  }
133  }
134 }
std::vector< int > outerNeighbors_
Definition: HGCDoublet.h:94
int seedIndex_
Definition: HGCDoublet.h:109
bool alreadyVisited_
Definition: HGCDoublet.h:110
const int theDoubletId_
Definition: HGCDoublet.h:97
std::vector< int > innerNeighbors_
Definition: HGCDoublet.h:95
int seedIndex() const
Definition: HGCDoublet.h:54
int HGCDoublet::innerClusterId ( ) const
inline

Definition at line 56 of file HGCDoublet.h.

References innerClusterId_.

56 { return innerClusterId_; }
const int innerClusterId_
Definition: HGCDoublet.h:98
double HGCDoublet::innerR ( ) const
inline

Definition at line 50 of file HGCDoublet.h.

References innerR_.

50 { return innerR_; }
const double innerR_
Definition: HGCDoublet.h:101
double HGCDoublet::innerX ( ) const
inline

Definition at line 38 of file HGCDoublet.h.

References innerX_.

Referenced by areAligned().

38 { return innerX_; }
const double innerX_
Definition: HGCDoublet.h:103
double HGCDoublet::innerY ( ) const
inline

Definition at line 42 of file HGCDoublet.h.

References innerY_.

Referenced by areAligned().

42 { return innerY_; }
const double innerY_
Definition: HGCDoublet.h:105
double HGCDoublet::innerZ ( ) const
inline

Definition at line 46 of file HGCDoublet.h.

References innerZ_.

Referenced by areAligned().

46 { return innerZ_; }
const double innerZ_
Definition: HGCDoublet.h:107
int HGCDoublet::outerClusterId ( ) const
inline

Definition at line 58 of file HGCDoublet.h.

References outerClusterId_.

58 { return outerClusterId_; }
const int outerClusterId_
Definition: HGCDoublet.h:99
double HGCDoublet::outerR ( ) const
inline

Definition at line 52 of file HGCDoublet.h.

References outerZ_.

52 { return outerZ_; }
const double outerZ_
Definition: HGCDoublet.h:108
double HGCDoublet::outerX ( ) const
inline

Definition at line 40 of file HGCDoublet.h.

References outerX_.

Referenced by checkCompatibilityAndTag().

40 { return outerX_; }
const double outerX_
Definition: HGCDoublet.h:104
double HGCDoublet::outerY ( ) const
inline

Definition at line 44 of file HGCDoublet.h.

References outerY_.

Referenced by checkCompatibilityAndTag().

44 { return outerY_; }
const double outerY_
Definition: HGCDoublet.h:106
double HGCDoublet::outerZ ( ) const
inline

Definition at line 48 of file HGCDoublet.h.

References outerZ_.

Referenced by checkCompatibilityAndTag().

48 { return outerZ_; }
const double outerZ_
Definition: HGCDoublet.h:108
int HGCDoublet::seedIndex ( ) const
inline

Definition at line 54 of file HGCDoublet.h.

References seedIndex_.

Referenced by tagAsInnerNeighbor().

54 { return seedIndex_; }
int seedIndex_
Definition: HGCDoublet.h:109
void HGCDoublet::setVisited ( bool  visited)
inline

Definition at line 90 of file HGCDoublet.h.

References alreadyVisited_, and class-composition::visited.

void HGCDoublet::tagAsInnerNeighbor ( unsigned int  otherDoublet)
inline

Definition at line 62 of file HGCDoublet.h.

References areAligned(), checkCompatibilityAndTag(), debug, findNtuplets(), innerNeighbors_, seedIndex(), and hybridSuperClusters_cfi::xi.

62 { innerNeighbors_.push_back(otherDoublet); }
std::vector< int > innerNeighbors_
Definition: HGCDoublet.h:95
void HGCDoublet::tagAsOuterNeighbor ( unsigned int  otherDoublet)
inline

Definition at line 60 of file HGCDoublet.h.

References outerNeighbors_.

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

Member Data Documentation

bool HGCDoublet::alreadyVisited_
private

Definition at line 110 of file HGCDoublet.h.

Referenced by findNtuplets(), and setVisited().

const int HGCDoublet::innerClusterId_
private

Definition at line 98 of file HGCDoublet.h.

Referenced by innerClusterId().

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

Definition at line 95 of file HGCDoublet.h.

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

const double HGCDoublet::innerR_
private

Definition at line 101 of file HGCDoublet.h.

Referenced by innerR().

const double HGCDoublet::innerX_
private

Definition at line 103 of file HGCDoublet.h.

Referenced by innerX().

const double HGCDoublet::innerY_
private

Definition at line 105 of file HGCDoublet.h.

Referenced by innerY().

const double HGCDoublet::innerZ_
private

Definition at line 107 of file HGCDoublet.h.

Referenced by innerZ().

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

Definition at line 93 of file HGCDoublet.h.

const int HGCDoublet::outerClusterId_
private

Definition at line 99 of file HGCDoublet.h.

Referenced by outerClusterId().

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

Definition at line 94 of file HGCDoublet.h.

Referenced by findNtuplets(), and tagAsOuterNeighbor().

const double HGCDoublet::outerR_
private

Definition at line 102 of file HGCDoublet.h.

const double HGCDoublet::outerX_
private

Definition at line 104 of file HGCDoublet.h.

Referenced by outerX().

const double HGCDoublet::outerY_
private

Definition at line 106 of file HGCDoublet.h.

Referenced by outerY().

const double HGCDoublet::outerZ_
private

Definition at line 108 of file HGCDoublet.h.

Referenced by outerR(), and outerZ().

int HGCDoublet::seedIndex_
private

Definition at line 109 of file HGCDoublet.h.

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

const int HGCDoublet::theDoubletId_
private

Definition at line 97 of file HGCDoublet.h.

Referenced by checkCompatibilityAndTag(), and findNtuplets().