CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HGCGraphT< TILES > Class Template Reference

#include <HGCGraph.h>

Public Member Functions

bool areOverlappingOnSiblingLayers (int innerIdx, int outerIdx, const std::vector< reco::CaloCluster > &layerClusters, float maxRSquared)
 
bool areTimeCompatible (int innerIdx, int outerIdx, const edm::ValueMap< std::pair< float, 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 TILES &h, const std::vector< TICLSeedingRegion > &regions, int nEtaBins, int nPhiBins, const std::vector< reco::CaloCluster > &layerClusters, const std::vector< float > &mask, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, int deltaIEta, int deltaIPhi, float minCosThetai, float maxCosPointing, float root_doublet_max_distance_from_seed_squared, float etaLimitIncreaseWindow, int skip_layers, int maxNumberOfLayers, float maxDeltaTime, int lastLayerEE, int lastLayerFH, const std::vector< double > &siblings_maxRSquared)
 
void setVerbosity (int level)
 

Private Attributes

std::vector< HGCDoubletallDoublets_
 
std::vector< std::vector< int > > isOuterClusterOfDoublets_
 
std::vector< unsigned int > theRootDoublets_
 
int verbosity_
 

Detailed Description

template<typename TILES>
class HGCGraphT< TILES >

Definition at line 14 of file HGCGraph.h.

Member Function Documentation

◆ areOverlappingOnSiblingLayers()

template<typename TILES >
bool HGCGraphT< TILES >::areOverlappingOnSiblingLayers ( int  innerIdx,
int  outerIdx,
const std::vector< reco::CaloCluster > &  layerClusters,
float  maxRSquared 
)

Definition at line 243 of file HGCGraph.cc.

References reco::deltaR2(), PVValHelper::eta, hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, and PVValHelper::phi.

246  {
247  return reco::deltaR2(layerClusters[outerIdx].eta(),
248  layerClusters[outerIdx].phi(),
249  layerClusters[innerIdx].eta(),
250  layerClusters[innerIdx].phi()) < maxRSquared;
251 }
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

◆ areTimeCompatible()

template<typename TILES >
bool HGCGraphT< TILES >::areTimeCompatible ( int  innerIdx,
int  outerIdx,
const edm::ValueMap< std::pair< float, float >> &  layerClustersTime,
float  maxDeltaTime 
)

Definition at line 229 of file HGCGraph.cc.

References funct::abs(), and mathSSE::sqrt().

232  {
233  float timeIn = layerClustersTime.get(innerIdx).first;
234  float timeInE = layerClustersTime.get(innerIdx).second;
235  float timeOut = layerClustersTime.get(outerIdx).first;
236  float timeOutE = layerClustersTime.get(outerIdx).second;
237 
238  return (timeIn == -99. || timeOut == -99. ||
239  std::abs(timeIn - timeOut) < maxDeltaTime * sqrt(timeInE * timeInE + timeOutE * timeOutE));
240 }
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:138
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ clear()

template<typename TILES >
void HGCGraphT< TILES >::clear ( void  )
inline

Definition at line 52 of file HGCGraph.h.

References HGCGraphT< TILES >::allDoublets_, HGCGraphT< TILES >::isOuterClusterOfDoublets_, and HGCGraphT< TILES >::theRootDoublets_.

52  {
53  allDoublets_.clear();
54  theRootDoublets_.clear();
56  allDoublets_.shrink_to_fit();
57  theRootDoublets_.shrink_to_fit();
58  isOuterClusterOfDoublets_.shrink_to_fit();
59  }
std::vector< std::vector< int > > isOuterClusterOfDoublets_
Definition: HGCGraph.h:65
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:63
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:64

◆ findNtuplets()

template<typename TILES >
void HGCGraphT< TILES >::findNtuplets ( std::vector< HGCDoublet::HGCntuplet > &  foundNtuplets,
std::vector< int > &  seedIndices,
const unsigned int  minClustersPerNtuplet,
const bool  outInDFS,
const unsigned int  maxOutInHops 
)

Definition at line 255 of file HGCGraph.cc.

References caHitNtupletGeneratorKernels::foundNtuplets.

259  {
260  HGCDoublet::HGCntuplet tmpNtuplet;
261  tmpNtuplet.reserve(minClustersPerNtuplet);
262  std::vector<std::pair<unsigned int, unsigned int>> outInToVisit;
263  for (auto rootDoublet : theRootDoublets_) {
264  tmpNtuplet.clear();
265  outInToVisit.clear();
266  int seedIndex = allDoublets_[rootDoublet].seedIndex();
267  int outInHops = 0;
268  allDoublets_[rootDoublet].findNtuplets(
269  allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInHops, maxOutInHops, outInToVisit);
270  while (!outInToVisit.empty()) {
271  allDoublets_[outInToVisit.back().first].findNtuplets(
272  allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInToVisit.back().second, maxOutInHops, outInToVisit);
273  outInToVisit.pop_back();
274  }
275 
276  if (tmpNtuplet.size() > minClustersPerNtuplet) {
277  foundNtuplets.push_back(tmpNtuplet);
278  seedIndices.push_back(seedIndex);
279  }
280  }
281 }
std::vector< unsigned int > HGCntuplet
Definition: HGCDoublet.h:16
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:63
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:64

◆ getAllDoublets()

template<typename TILES >
std::vector<HGCDoublet>& HGCGraphT< TILES >::getAllDoublets ( )
inline

Definition at line 46 of file HGCGraph.h.

References HGCGraphT< TILES >::allDoublets_.

46 { return allDoublets_; }
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:63

◆ makeAndConnectDoublets()

template<typename TILES >
void HGCGraphT< TILES >::makeAndConnectDoublets ( const TILES &  h,
const std::vector< TICLSeedingRegion > &  regions,
int  nEtaBins,
int  nPhiBins,
const std::vector< reco::CaloCluster > &  layerClusters,
const std::vector< float > &  mask,
const edm::ValueMap< std::pair< float, float >> &  layerClustersTime,
int  deltaIEta,
int  deltaIPhi,
float  minCosThetai,
float  maxCosPointing,
float  root_doublet_max_distance_from_seed_squared,
float  etaLimitIncreaseWindow,
int  skip_layers,
int  maxNumberOfLayers,
float  maxDeltaTime,
int  lastLayerEE,
int  lastLayerFH,
const std::vector< double > &  siblings_maxRSquared 
)

Definition at line 12 of file HGCGraph.cc.

References funct::abs(), ticl::Advanced, reco::deltaR2(), PVValHelper::eta, hltTiclTrackstersCLUE3DHigh_cfi::etaLimitIncreaseWindow, ticl::Expert, ticl::Guru, timingPdfMaker::histo, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, nano_mu_reco_cff::isGlobal, hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, LogDebug, M_PI, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, SiStripPI::max, SiStripPI::min, L1TMuonDQMOffline_cfi::nEtaBins, None, ecaldqm::binning::nPhiBins, hltrates_dqm_sourceclient-live_cfg::offset, PVValHelper::phi, trackingPOGFilters_cfi::phiWindow, alignCSCRings::r, hltTiclTrackstersCLUE3DHigh_cfi::root_doublet_max_distance_from_seed_squared, hltTiclTrackstersCLUE3DHigh_cfi::siblings_maxRSquared, findQualityFiles::size, and hltTiclTrackstersCLUE3DHigh_cfi::skip_layers.

30  {
33  allDoublets_.clear();
34  theRootDoublets_.clear();
35  bool checkDistanceRootDoubletVsSeed = root_doublet_max_distance_from_seed_squared < 9999;
36  float origin_eta;
37  float origin_phi;
38  float maxRSquared;
39  for (const auto &r : regions) {
40  bool isGlobal = (r.index == -1);
41  auto zSide = r.zSide;
42  int startEtaBin, endEtaBin, startPhiBin, endPhiBin;
43 
44  if (isGlobal) {
45  startEtaBin = 0;
46  startPhiBin = 0;
47  endEtaBin = nEtaBins;
48  endPhiBin = nPhiBins;
49  origin_eta = 0;
50  origin_phi = 0;
51  } else {
52  auto firstLayerOnZSide = maxNumberOfLayers * zSide;
53  const auto &firstLayerHisto = histo[firstLayerOnZSide];
54  origin_eta = r.origin.eta();
55  origin_phi = r.origin.phi();
56  int entryEtaBin = firstLayerHisto.etaBin(origin_eta);
57  int entryPhiBin = firstLayerHisto.phiBin(origin_phi);
58  // For track-seeded iterations, if the impact point is below a certain
59  // eta-threshold, i.e., it has higher eta, make the initial search
60  // window bigger in both eta and phi by one bin, to contain better low
61  // energy showers.
62  auto etaWindow = deltaIEta;
63  auto phiWindow = deltaIPhi;
64  if (std::abs(origin_eta) > etaLimitIncreaseWindow) {
65  etaWindow++;
66  phiWindow++;
67  LogDebug("HGCGraph") << "Limit of Eta for increase: " << etaLimitIncreaseWindow
68  << " reached! Increasing inner search window" << std::endl;
69  }
70  startEtaBin = std::max(entryEtaBin - etaWindow, 0);
71  endEtaBin = std::min(entryEtaBin + etaWindow + 1, nEtaBins);
72  startPhiBin = entryPhiBin - phiWindow;
73  endPhiBin = entryPhiBin + phiWindow + 1;
75  LogDebug("HGCGraph") << " Entrance eta, phi: " << origin_eta << ", " << origin_phi
76  << " entryEtaBin: " << entryEtaBin << " entryPhiBin: " << entryPhiBin
77  << " globalBin: " << firstLayerHisto.globalBin(origin_eta, origin_phi)
78  << " on layer: " << firstLayerOnZSide << " startEtaBin: " << startEtaBin
79  << " endEtaBin: " << endEtaBin << " startPhiBin: " << startPhiBin
80  << " endPhiBin: " << endPhiBin << " phiBin(0): " << firstLayerHisto.phiBin(0.)
81  << " phiBin(" << M_PI / 2. << "): " << firstLayerHisto.phiBin(M_PI / 2.) << " phiBin("
82  << M_PI << "): " << firstLayerHisto.phiBin(M_PI) << " phiBin(" << -M_PI / 2.
83  << "): " << firstLayerHisto.phiBin(-M_PI / 2.) << " phiBin(" << -M_PI
84  << "): " << firstLayerHisto.phiBin(-M_PI) << " phiBin(" << 2. * M_PI
85  << "): " << firstLayerHisto.phiBin(2. * M_PI) << std::endl;
86  }
87  }
88 
89  for (int il = 0; il < maxNumberOfLayers - 1; ++il) {
90  for (int outer_layer = 0; outer_layer < std::min(1 + skip_layers, maxNumberOfLayers - 1 - il); ++outer_layer) {
91  int currentInnerLayerId = il + maxNumberOfLayers * zSide;
92  int currentOuterLayerId = currentInnerLayerId + 1 + outer_layer;
93  auto const &outerLayerHisto = histo[currentOuterLayerId];
94  auto const &innerLayerHisto = histo[currentInnerLayerId];
95  maxRSquared = (il <= lastLayerEE) ? siblings_maxRSquared[0]
96  : (il <= lastLayerFH) ? siblings_maxRSquared[1]
98  const int etaLimitIncreaseWindowBin = innerLayerHisto.etaBin(etaLimitIncreaseWindow);
100  LogDebug("HGCGraph") << "Limit of Eta for increase: " << etaLimitIncreaseWindow
101  << " at etaBin: " << etaLimitIncreaseWindowBin << std::endl;
102  }
103 
104  for (int ieta = startEtaBin; ieta < endEtaBin; ++ieta) {
105  auto offset = ieta * nPhiBins;
106  for (int iphi_it = startPhiBin; iphi_it < endPhiBin; ++iphi_it) {
107  int iphi = ((iphi_it % nPhiBins + nPhiBins) % nPhiBins);
109  LogDebug("HGCGraph") << "Inner Global Bin: " << (offset + iphi)
110  << " on layers I/O: " << currentInnerLayerId << "/" << currentOuterLayerId
111  << " with clusters: " << innerLayerHisto[offset + iphi].size() << std::endl;
112  }
113  for (auto innerClusterId : innerLayerHisto[offset + iphi]) {
114  // Skip masked clusters
115  if (mask[innerClusterId] == 0.) {
117  LogDebug("HGCGraph") << "Skipping inner masked cluster " << innerClusterId << std::endl;
118  continue;
119  }
120 
121  // For global-seeded iterations, if the inner cluster is above a certain
122  // eta-threshold, i.e., it has higher eta, make the outer search
123  // window bigger in both eta and phi by one bin, to contain better low
124  // energy showers. Track-Seeded iterations are excluded since, in
125  // that case, the inner search window has already been enlarged.
126  auto etaWindow = deltaIEta;
127  auto phiWindow = deltaIPhi;
128  if (isGlobal && ieta > etaLimitIncreaseWindowBin) {
129  etaWindow++;
130  phiWindow++;
132  LogDebug("HGCGraph") << "Eta and Phi window increased by one" << std::endl;
133  }
134  }
135  const auto etaRangeMin = std::max(0, ieta - etaWindow);
136  const auto etaRangeMax = std::min(ieta + etaWindow + 1, nEtaBins);
137 
138  for (int oeta = etaRangeMin; oeta < etaRangeMax; ++oeta) {
139  // wrap phi bin
140  for (int phiRange = 0; phiRange < 2 * phiWindow + 1; ++phiRange) {
141  // The first wrapping is to take into account the
142  // cases in which we would have to seach in
143  // negative bins. The second wrap is mandatory to
144  // account for all other cases, since we add in
145  // between a full nPhiBins slot.
146  auto ophi = ((iphi + phiRange - phiWindow) % nPhiBins + nPhiBins) % nPhiBins;
148  LogDebug("HGCGraph") << "Outer Global Bin: " << (oeta * nPhiBins + ophi)
149  << " on layers I/O: " << currentInnerLayerId << "/" << currentOuterLayerId
150  << " with clusters: " << innerLayerHisto[oeta * nPhiBins + ophi].size()
151  << std::endl;
152  }
153  for (auto outerClusterId : outerLayerHisto[oeta * nPhiBins + ophi]) {
154  // Skip masked clusters
155  if (mask[outerClusterId] == 0.) {
157  LogDebug("HGCGraph") << "Skipping outer masked cluster " << outerClusterId << std::endl;
158  continue;
159  }
160  auto doubletId = allDoublets_.size();
161  if (maxDeltaTime != -1 &&
162  !areTimeCompatible(innerClusterId, outerClusterId, layerClustersTime, maxDeltaTime)) {
164  LogDebug("HGCGraph") << "Rejecting doublets due to timing!" << std::endl;
165  continue;
166  }
167  if (currentOuterLayerId - currentInnerLayerId == 1) {
168  if (areOverlappingOnSiblingLayers(innerClusterId, outerClusterId, layerClusters, maxRSquared)) {
169  allDoublets_.emplace_back(
170  innerClusterId, outerClusterId, doubletId, &layerClusters, r.index, true);
171  } else {
172  continue;
173  }
174  } else {
175  allDoublets_.emplace_back(
176  innerClusterId, outerClusterId, doubletId, &layerClusters, r.index, false);
177  }
179  LogDebug("HGCGraph")
180  << "Creating doubletsId: " << doubletId << " layerLink in-out: [" << currentInnerLayerId
181  << ", " << currentOuterLayerId << "] clusterLink in-out: [" << innerClusterId << ", "
182  << outerClusterId << "]" << std::endl;
183  }
184  isOuterClusterOfDoublets_[outerClusterId].push_back(doubletId);
185  auto &neigDoublets = isOuterClusterOfDoublets_[innerClusterId];
186  auto &thisDoublet = allDoublets_[doubletId];
188  LogDebug("HGCGraph")
189  << "Checking compatibility of doubletId: " << doubletId
190  << " with all possible inners doublets link by the innerClusterId: " << innerClusterId
191  << std::endl;
192  }
193  bool isRootDoublet =
194  thisDoublet.checkCompatibilityAndTag(allDoublets_,
195  neigDoublets,
196  r.directionAtOrigin,
197  minCosTheta,
198  minCosPointing,
200  if (isRootDoublet and checkDistanceRootDoubletVsSeed) {
201  if (reco::deltaR2(layerClusters[innerClusterId].eta(),
202  layerClusters[innerClusterId].phi(),
203  origin_eta,
205  isRootDoublet = false;
206  }
207  }
208  if (isRootDoublet) {
209  theRootDoublets_.push_back(doubletId);
210  }
211  }
212  }
213  }
214  }
215  }
216  }
217  }
218  }
219  }
220  // #ifdef FP_DEBUG
222  LogDebug("HGCGraph") << "number of Root doublets " << theRootDoublets_.size() << " over a total number of doublets "
223  << allDoublets_.size() << std::endl;
224  }
225  // #endif
226 }
size
Write out results.
std::vector< std::vector< int > > isOuterClusterOfDoublets_
Definition: HGCGraph.h:65
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:63
bool areOverlappingOnSiblingLayers(int innerIdx, int outerIdx, const std::vector< reco::CaloCluster > &layerClusters, float maxRSquared)
Definition: HGCGraph.cc:243
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:64
#define M_PI
bool areTimeCompatible(int innerIdx, int outerIdx, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, float maxDeltaTime)
Definition: HGCGraph.cc:229
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
int verbosity_
Definition: HGCGraph.h:66
static constexpr int nPhiBins
#define LogDebug(id)

◆ setVerbosity()

template<typename TILES >
void HGCGraphT< TILES >::setVerbosity ( int  level)
inline

Definition at line 60 of file HGCGraph.h.

References personalPlayback::level, and HGCGraphT< TILES >::verbosity_.

Member Data Documentation

◆ allDoublets_

template<typename TILES >
std::vector<HGCDoublet> HGCGraphT< TILES >::allDoublets_
private

Definition at line 63 of file HGCGraph.h.

Referenced by HGCGraphT< TILES >::clear(), and HGCGraphT< TILES >::getAllDoublets().

◆ isOuterClusterOfDoublets_

template<typename TILES >
std::vector<std::vector<int> > HGCGraphT< TILES >::isOuterClusterOfDoublets_
private

Definition at line 65 of file HGCGraph.h.

Referenced by HGCGraphT< TILES >::clear().

◆ theRootDoublets_

template<typename TILES >
std::vector<unsigned int> HGCGraphT< TILES >::theRootDoublets_
private

Definition at line 64 of file HGCGraph.h.

Referenced by HGCGraphT< TILES >::clear().

◆ verbosity_

template<typename TILES >
int HGCGraphT< TILES >::verbosity_
private

Definition at line 66 of file HGCGraph.h.

Referenced by HGCGraphT< TILES >::setVerbosity().