CMS 3D CMS Logo

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

#include <HGCGraph.h>

Public Types

enum  VerbosityLevel {
  None = 0, Basic, Advanced, Expert,
  Guru
}
 

Public Member Functions

bool areTimeCompatible (int innerIdx, int outerIdx, const edm::ValueMap< float > &layerClustersTime, float maxDeltaTime)
 
void clear ()
 
void findNtuplets (std::vector< HGCDoublet::HGCntuplet > &foundNtuplets, std::vector< int > &seedIndices, const unsigned int minClustersPerNtuplet, const bool outInDFS, const unsigned int maxOutInHops)
 
std::vector< HGCDoublet > & getAllDoublets ()
 
void makeAndConnectDoublets (const TICLLayerTiles &h, const std::vector< TICLSeedingRegion > &regions, int nEtaBins, int nPhiBins, const std::vector< reco::CaloCluster > &layerClusters, const std::vector< float > &mask, const edm::ValueMap< float > &layerClustersTime, int deltaIEta, int deltaIPhi, float minCosThetai, float maxCosPointing, int missing_layers, int maxNumberOfLayers, float maxDeltaTime)
 
void setVerbosity (int level)
 

Private Attributes

std::vector< HGCDoubletallDoublets_
 
std::vector< std::vector< int > > isOuterClusterOfDoublets_
 
std::vector< std::vector< HGCDoublet * > > theNtuplets_
 
std::vector< unsigned int > theRootDoublets_
 
int verbosity_
 

Detailed Description

Definition at line 14 of file HGCGraph.h.

Member Enumeration Documentation

Enumerator
None 
Basic 
Advanced 
Expert 
Guru 

Definition at line 46 of file HGCGraph.h.

Member Function Documentation

bool HGCGraph::areTimeCompatible ( int  innerIdx,
int  outerIdx,
const edm::ValueMap< float > &  layerClustersTime,
float  maxDeltaTime 
)

Definition at line 126 of file HGCGraph.cc.

References funct::abs(), and edm::ValueMap< T >::get().

Referenced by makeAndConnectDoublets().

129  {
130  float timeIn = layerClustersTime.get(innerIdx);
131  float timeOut = layerClustersTime.get(outerIdx);
132 
133  return (timeIn == -99 || timeOut == -99 || std::abs(timeIn - timeOut) < maxDeltaTime);
134 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:144
void HGCGraph::clear ( void  )
inline

Definition at line 39 of file HGCGraph.h.

References allDoublets_, isOuterClusterOfDoublets_, theNtuplets_, and theRootDoublets_.

39  {
40  allDoublets_.clear();
41  theRootDoublets_.clear();
42  theNtuplets_.clear();
44  }
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:50
std::vector< std::vector< HGCDoublet * > > theNtuplets_
Definition: HGCGraph.h:51
std::vector< std::vector< int > > isOuterClusterOfDoublets_
Definition: HGCGraph.h:52
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:49
void HGCGraph::findNtuplets ( std::vector< HGCDoublet::HGCntuplet > &  foundNtuplets,
std::vector< int > &  seedIndices,
const unsigned int  minClustersPerNtuplet,
const bool  outInDFS,
const unsigned int  maxOutInHops 
)

Definition at line 137 of file HGCGraph.cc.

References allDoublets_, and theRootDoublets_.

Referenced by getAllDoublets().

141  {
142  HGCDoublet::HGCntuplet tmpNtuplet;
143  tmpNtuplet.reserve(minClustersPerNtuplet);
144  std::vector<std::pair<unsigned int, unsigned int> > outInToVisit;
145  for (auto rootDoublet : theRootDoublets_) {
146  tmpNtuplet.clear();
147  outInToVisit.clear();
148  int seedIndex = allDoublets_[rootDoublet].seedIndex();
149  int outInHops = 0;
150  allDoublets_[rootDoublet].findNtuplets(
151  allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInHops, maxOutInHops, outInToVisit);
152  while (!outInToVisit.empty()) {
153  allDoublets_[outInToVisit.back().first].findNtuplets(
154  allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInToVisit.back().second, maxOutInHops, outInToVisit);
155  outInToVisit.pop_back();
156  }
157 
158  if (tmpNtuplet.size() > minClustersPerNtuplet) {
159  foundNtuplets.push_back(tmpNtuplet);
160  seedIndices.push_back(seedIndex);
161  }
162  }
163 }
std::vector< unsigned int > HGCntuplet
Definition: HGCDoublet.h:16
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:50
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:49
std::vector<HGCDoublet>& HGCGraph::getAllDoublets ( )
inline

Definition at line 33 of file HGCGraph.h.

References allDoublets_, and findNtuplets().

33 { return allDoublets_; }
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:49
void HGCGraph::makeAndConnectDoublets ( const TICLLayerTiles h,
const std::vector< TICLSeedingRegion > &  regions,
int  nEtaBins,
int  nPhiBins,
const std::vector< reco::CaloCluster > &  layerClusters,
const std::vector< float > &  mask,
const edm::ValueMap< float > &  layerClustersTime,
int  deltaIEta,
int  deltaIPhi,
float  minCosThetai,
float  maxCosPointing,
int  missing_layers,
int  maxNumberOfLayers,
float  maxDeltaTime 
)

Definition at line 10 of file HGCGraph.cc.

References Advanced, allDoublets_, areTimeCompatible(), Expert, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, muons_cff::isGlobal, isOuterClusterOfDoublets_, LogDebug, SiStripPI::max, min(), ticl::constants::nEtaBins, None, ticl::constants::nPhiBins, hltrates_dqm_sourceclient-live_cfg::offset, alignCSCRings::r, theRootDoublets_, and verbosity_.

23  {
25  isOuterClusterOfDoublets_.resize(layerClusters.size());
26  allDoublets_.clear();
27  theRootDoublets_.clear();
28  for (const auto &r : regions) {
29  bool isGlobal = (r.index == -1);
30  auto zSide = r.zSide;
31  int startEtaBin, endEtaBin, startPhiBin, endPhiBin;
32 
33  if (isGlobal) {
34  startEtaBin = 0;
35  startPhiBin = 0;
36  endEtaBin = nEtaBins;
37  endPhiBin = nPhiBins;
38  } else {
39  auto firstLayerOnZSide = maxNumberOfLayers * zSide;
40  const auto &firstLayerHisto = histo[firstLayerOnZSide];
41 
42  int entryEtaBin = firstLayerHisto.etaBin(r.origin.eta());
43  int entryPhiBin = firstLayerHisto.phiBin(r.origin.phi());
44  startEtaBin = std::max(entryEtaBin - deltaIEta, 0);
45  endEtaBin = std::min(entryEtaBin + deltaIEta + 1, nEtaBins);
46  startPhiBin = entryPhiBin - deltaIPhi;
47  endPhiBin = entryPhiBin + deltaIPhi;
48  }
49 
50  for (int il = 0; il < maxNumberOfLayers - 1; ++il) {
51  for (int outer_layer = 0; outer_layer < std::min(1 + missing_layers, maxNumberOfLayers - 1 - il); ++outer_layer) {
52  int currentInnerLayerId = il + maxNumberOfLayers * zSide;
53  int currentOuterLayerId = currentInnerLayerId + 1 + outer_layer;
54  auto const &outerLayerHisto = histo[currentOuterLayerId];
55  auto const &innerLayerHisto = histo[currentInnerLayerId];
56 
57  for (int oeta = startEtaBin; oeta < endEtaBin; ++oeta) {
58  auto offset = oeta * nPhiBins;
59  for (int ophi_it = startPhiBin; ophi_it < endPhiBin; ++ophi_it) {
60  int ophi = ((ophi_it % nPhiBins + nPhiBins) % nPhiBins);
61  for (auto outerClusterId : outerLayerHisto[offset + ophi]) {
62  // Skip masked clusters
63  if (mask[outerClusterId] == 0.)
64  continue;
65  const auto etaRangeMin = std::max(0, oeta - deltaIEta);
66  const auto etaRangeMax = std::min(oeta + deltaIEta + 1, nEtaBins);
67 
68  for (int ieta = etaRangeMin; ieta < etaRangeMax; ++ieta) {
69  // wrap phi bin
70  for (int phiRange = 0; phiRange < 2 * deltaIPhi + 1; ++phiRange) {
71  // The first wrapping is to take into account the
72  // cases in which we would have to seach in
73  // negative bins. The second wrap is mandatory to
74  // account for all other cases, since we add in
75  // between a full nPhiBins slot.
76  auto iphi = ((ophi + phiRange - deltaIPhi) % nPhiBins + nPhiBins) % nPhiBins;
77  for (auto innerClusterId : innerLayerHisto[ieta * nPhiBins + iphi]) {
78  // Skip masked clusters
79  if (mask[innerClusterId] == 0.)
80  continue;
81  auto doubletId = allDoublets_.size();
82  if (maxDeltaTime != -1 &&
83  !areTimeCompatible(innerClusterId, outerClusterId, layerClustersTime, maxDeltaTime))
84  continue;
85  allDoublets_.emplace_back(innerClusterId, outerClusterId, doubletId, &layerClusters, r.index);
86  if (verbosity_ > Advanced) {
87  LogDebug("HGCGraph")
88  << "Creating doubletsId: " << doubletId << " layerLink in-out: [" << currentInnerLayerId
89  << ", " << currentOuterLayerId << "] clusterLink in-out: [" << innerClusterId << ", "
90  << outerClusterId << "]" << std::endl;
91  }
92  isOuterClusterOfDoublets_[outerClusterId].push_back(doubletId);
93  auto &neigDoublets = isOuterClusterOfDoublets_[innerClusterId];
94  auto &thisDoublet = allDoublets_[doubletId];
95  if (verbosity_ > Expert) {
96  LogDebug("HGCGraph")
97  << "Checking compatibility of doubletId: " << doubletId
98  << " with all possible inners doublets link by the innerClusterId: " << innerClusterId
99  << std::endl;
100  }
101  bool isRootDoublet = thisDoublet.checkCompatibilityAndTag(allDoublets_,
102  neigDoublets,
103  r.directionAtOrigin,
104  minCosTheta,
105  minCosPointing,
106  verbosity_ > Advanced);
107  if (isRootDoublet)
108  theRootDoublets_.push_back(doubletId);
109  }
110  }
111  }
112  }
113  }
114  }
115  }
116  }
117  }
118  // #ifdef FP_DEBUG
119  if (verbosity_ > None) {
120  LogDebug("HGCGraph") << "number of Root doublets " << theRootDoublets_.size() << " over a total number of doublets "
121  << allDoublets_.size() << std::endl;
122  }
123  // #endif
124 }
#define LogDebug(id)
constexpr int nPhiBins
Definition: Common.h:12
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:50
constexpr int nEtaBins
Definition: Common.h:11
int verbosity_
Definition: HGCGraph.h:53
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< std::vector< int > > isOuterClusterOfDoublets_
Definition: HGCGraph.h:52
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:49
bool areTimeCompatible(int innerIdx, int outerIdx, const edm::ValueMap< float > &layerClustersTime, float maxDeltaTime)
Definition: HGCGraph.cc:126
void HGCGraph::setVerbosity ( int  level)
inline

Definition at line 45 of file HGCGraph.h.

References personalPlayback::level, and verbosity_.

Member Data Documentation

std::vector<HGCDoublet> HGCGraph::allDoublets_
private

Definition at line 49 of file HGCGraph.h.

Referenced by clear(), findNtuplets(), getAllDoublets(), and makeAndConnectDoublets().

std::vector<std::vector<int> > HGCGraph::isOuterClusterOfDoublets_
private

Definition at line 52 of file HGCGraph.h.

Referenced by clear(), and makeAndConnectDoublets().

std::vector<std::vector<HGCDoublet *> > HGCGraph::theNtuplets_
private

Definition at line 51 of file HGCGraph.h.

Referenced by clear().

std::vector<unsigned int> HGCGraph::theRootDoublets_
private

Definition at line 50 of file HGCGraph.h.

Referenced by clear(), findNtuplets(), and makeAndConnectDoublets().

int HGCGraph::verbosity_
private

Definition at line 53 of file HGCGraph.h.

Referenced by makeAndConnectDoublets(), and setVerbosity().