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< 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 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< std::pair< float, float >> &layerClustersTime, int deltaIEta, int deltaIPhi, float minCosThetai, float maxCosPointing, float etaLimitIncreaseWindow, int missing_layers, int maxNumberOfLayers, float maxDeltaTime)
 
void setVerbosity (int level)
 

Private Attributes

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

Detailed Description

Definition at line 14 of file HGCGraph.h.

Member Enumeration Documentation

◆ VerbosityLevel

Enumerator
None 
Basic 
Advanced 
Expert 
Guru 

Definition at line 52 of file HGCGraph.h.

52 { None = 0, Basic, Advanced, Expert, Guru };

Member Function Documentation

◆ areTimeCompatible()

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

Definition at line 192 of file HGCGraph.cc.

195  {
196  float timeIn = layerClustersTime.get(innerIdx).first;
197  float timeInE = layerClustersTime.get(innerIdx).second;
198  float timeOut = layerClustersTime.get(outerIdx).first;
199  float timeOutE = layerClustersTime.get(outerIdx).second;
200 
201  return (timeIn == -99. || timeOut == -99. ||
202  std::abs(timeIn - timeOut) < maxDeltaTime * sqrt(timeInE * timeInE + timeOutE * timeOutE));
203 }

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

Referenced by makeAndConnectDoublets().

◆ clear()

void HGCGraph::clear ( void  )
inline

Definition at line 43 of file HGCGraph.h.

43  {
44  allDoublets_.clear();
45  theRootDoublets_.clear();
47  allDoublets_.shrink_to_fit();
48  theRootDoublets_.shrink_to_fit();
49  isOuterClusterOfDoublets_.shrink_to_fit();
50  }

References allDoublets_, isOuterClusterOfDoublets_, and theRootDoublets_.

◆ findNtuplets()

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 206 of file HGCGraph.cc.

210  {
211  HGCDoublet::HGCntuplet tmpNtuplet;
212  tmpNtuplet.reserve(minClustersPerNtuplet);
213  std::vector<std::pair<unsigned int, unsigned int>> outInToVisit;
214  for (auto rootDoublet : theRootDoublets_) {
215  tmpNtuplet.clear();
216  outInToVisit.clear();
217  int seedIndex = allDoublets_[rootDoublet].seedIndex();
218  int outInHops = 0;
219  allDoublets_[rootDoublet].findNtuplets(
220  allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInHops, maxOutInHops, outInToVisit);
221  while (!outInToVisit.empty()) {
222  allDoublets_[outInToVisit.back().first].findNtuplets(
223  allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInToVisit.back().second, maxOutInHops, outInToVisit);
224  outInToVisit.pop_back();
225  }
226 
227  if (tmpNtuplet.size() > minClustersPerNtuplet) {
228  foundNtuplets.push_back(tmpNtuplet);
229  seedIndices.push_back(seedIndex);
230  }
231  }
232 }

References allDoublets_, and theRootDoublets_.

◆ getAllDoublets()

std::vector<HGCDoublet>& HGCGraph::getAllDoublets ( )
inline

Definition at line 37 of file HGCGraph.h.

37 { return allDoublets_; }

References allDoublets_.

◆ makeAndConnectDoublets()

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< std::pair< float, float >> &  layerClustersTime,
int  deltaIEta,
int  deltaIPhi,
float  minCosThetai,
float  maxCosPointing,
float  etaLimitIncreaseWindow,
int  missing_layers,
int  maxNumberOfLayers,
float  maxDeltaTime 
)

Definition at line 10 of file HGCGraph.cc.

24  {
26  isOuterClusterOfDoublets_.resize(layerClusters.size());
27  allDoublets_.clear();
28  theRootDoublets_.clear();
29  for (const auto &r : regions) {
30  bool isGlobal = (r.index == -1);
31  auto zSide = r.zSide;
32  int startEtaBin, endEtaBin, startPhiBin, endPhiBin;
33 
34  if (isGlobal) {
35  startEtaBin = 0;
36  startPhiBin = 0;
37  endEtaBin = nEtaBins;
38  endPhiBin = nPhiBins;
39  } else {
40  auto firstLayerOnZSide = maxNumberOfLayers * zSide;
41  const auto &firstLayerHisto = histo[firstLayerOnZSide];
42 
43  int entryEtaBin = firstLayerHisto.etaBin(r.origin.eta());
44  int entryPhiBin = firstLayerHisto.phiBin(r.origin.phi());
45  // For track-seeded iterations, if the impact point is below a certain
46  // eta-threshold, i.e., it has higher eta, make the initial search
47  // window bigger in both eta and phi by one bin, to contain better low
48  // energy showers.
49  auto etaWindow = deltaIEta;
50  auto phiWindow = deltaIPhi;
51  if (std::abs(r.origin.eta()) > etaLimitIncreaseWindow) {
52  etaWindow++;
53  phiWindow++;
54  LogDebug("HGCGraph") << "Limit of Eta for increase: " << etaLimitIncreaseWindow
55  << " reached! Increasing inner search window" << std::endl;
56  }
57  startEtaBin = std::max(entryEtaBin - etaWindow, 0);
58  endEtaBin = std::min(entryEtaBin + etaWindow + 1, nEtaBins);
59  startPhiBin = entryPhiBin - phiWindow;
60  endPhiBin = entryPhiBin + phiWindow + 1;
61  if (verbosity_ > Guru) {
62  LogDebug("HGCGraph") << " Entrance eta, phi: " << r.origin.eta() << ", " << r.origin.phi()
63  << " entryEtaBin: " << entryEtaBin << " entryPhiBin: " << entryPhiBin
64  << " globalBin: " << firstLayerHisto.globalBin(r.origin.eta(), r.origin.phi())
65  << " on layer: " << firstLayerOnZSide << " startEtaBin: " << startEtaBin
66  << " endEtaBin: " << endEtaBin << " startPhiBin: " << startPhiBin
67  << " endPhiBin: " << endPhiBin << " phiBin(0): " << firstLayerHisto.phiBin(0.)
68  << " phiBin(" << M_PI / 2. << "): " << firstLayerHisto.phiBin(M_PI / 2.) << " phiBin("
69  << M_PI << "): " << firstLayerHisto.phiBin(M_PI) << " phiBin(" << -M_PI / 2.
70  << "): " << firstLayerHisto.phiBin(-M_PI / 2.) << " phiBin(" << -M_PI
71  << "): " << firstLayerHisto.phiBin(-M_PI) << " phiBin(" << 2. * M_PI
72  << "): " << firstLayerHisto.phiBin(2. * M_PI) << std::endl;
73  }
74  }
75 
76  for (int il = 0; il < maxNumberOfLayers - 1; ++il) {
77  for (int outer_layer = 0; outer_layer < std::min(1 + missing_layers, maxNumberOfLayers - 1 - il); ++outer_layer) {
78  int currentInnerLayerId = il + maxNumberOfLayers * zSide;
79  int currentOuterLayerId = currentInnerLayerId + 1 + outer_layer;
80  auto const &outerLayerHisto = histo[currentOuterLayerId];
81  auto const &innerLayerHisto = histo[currentInnerLayerId];
82  const int etaLimitIncreaseWindowBin = innerLayerHisto.etaBin(etaLimitIncreaseWindow);
83  if (verbosity_ > Advanced) {
84  LogDebug("HGCGraph") << "Limit of Eta for increase: " << etaLimitIncreaseWindow
85  << " at etaBin: " << etaLimitIncreaseWindowBin << std::endl;
86  }
87 
88  for (int ieta = startEtaBin; ieta < endEtaBin; ++ieta) {
89  auto offset = ieta * nPhiBins;
90  for (int iphi_it = startPhiBin; iphi_it < endPhiBin; ++iphi_it) {
91  int iphi = ((iphi_it % nPhiBins + nPhiBins) % nPhiBins);
92  if (verbosity_ > Guru) {
93  LogDebug("HGCGraph") << "Inner Global Bin: " << (offset + iphi)
94  << " on layers I/O: " << currentInnerLayerId << "/" << currentOuterLayerId
95  << " with clusters: " << innerLayerHisto[offset + iphi].size() << std::endl;
96  }
97  for (auto innerClusterId : innerLayerHisto[offset + iphi]) {
98  // Skip masked clusters
99  if (mask[innerClusterId] == 0.) {
100  if (verbosity_ > Advanced)
101  LogDebug("HGCGraph") << "Skipping inner masked cluster " << innerClusterId << std::endl;
102  continue;
103  }
104 
105  // For global-seeded iterations, if the inner cluster is above a certain
106  // eta-threshold, i.e., it has higher eta, make the outer search
107  // window bigger in both eta and phi by one bin, to contain better low
108  // energy showers. Track-Seeded iterations are excluded since, in
109  // that case, the inner search window has already been enlarged.
110  auto etaWindow = deltaIEta;
111  auto phiWindow = deltaIPhi;
112  if (isGlobal && ieta > etaLimitIncreaseWindowBin) {
113  etaWindow++;
114  phiWindow++;
115  if (verbosity_ > Advanced) {
116  LogDebug("HGCGraph") << "Eta and Phi window increased by one" << std::endl;
117  }
118  }
119  const auto etaRangeMin = std::max(0, ieta - etaWindow);
120  const auto etaRangeMax = std::min(ieta + etaWindow + 1, nEtaBins);
121 
122  for (int oeta = etaRangeMin; oeta < etaRangeMax; ++oeta) {
123  // wrap phi bin
124  for (int phiRange = 0; phiRange < 2 * phiWindow + 1; ++phiRange) {
125  // The first wrapping is to take into account the
126  // cases in which we would have to seach in
127  // negative bins. The second wrap is mandatory to
128  // account for all other cases, since we add in
129  // between a full nPhiBins slot.
130  auto ophi = ((iphi + phiRange - phiWindow) % nPhiBins + nPhiBins) % nPhiBins;
131  if (verbosity_ > Guru) {
132  LogDebug("HGCGraph") << "Outer Global Bin: " << (oeta * nPhiBins + ophi)
133  << " on layers I/O: " << currentInnerLayerId << "/" << currentOuterLayerId
134  << " with clusters: " << innerLayerHisto[oeta * nPhiBins + ophi].size()
135  << std::endl;
136  }
137  for (auto outerClusterId : outerLayerHisto[oeta * nPhiBins + ophi]) {
138  // Skip masked clusters
139  if (mask[outerClusterId] == 0.) {
140  if (verbosity_ > Advanced)
141  LogDebug("HGCGraph") << "Skipping outer masked cluster " << outerClusterId << std::endl;
142  continue;
143  }
144  auto doubletId = allDoublets_.size();
145  if (maxDeltaTime != -1 &&
146  !areTimeCompatible(innerClusterId, outerClusterId, layerClustersTime, maxDeltaTime)) {
147  if (verbosity_ > Advanced)
148  LogDebug("HGCGraph") << "Rejecting doublets due to timing!" << std::endl;
149  continue;
150  }
151  allDoublets_.emplace_back(innerClusterId, outerClusterId, doubletId, &layerClusters, r.index);
152  if (verbosity_ > Advanced) {
153  LogDebug("HGCGraph")
154  << "Creating doubletsId: " << doubletId << " layerLink in-out: [" << currentInnerLayerId
155  << ", " << currentOuterLayerId << "] clusterLink in-out: [" << innerClusterId << ", "
156  << outerClusterId << "]" << std::endl;
157  }
158  isOuterClusterOfDoublets_[outerClusterId].push_back(doubletId);
159  auto &neigDoublets = isOuterClusterOfDoublets_[innerClusterId];
160  auto &thisDoublet = allDoublets_[doubletId];
161  if (verbosity_ > Expert) {
162  LogDebug("HGCGraph")
163  << "Checking compatibility of doubletId: " << doubletId
164  << " with all possible inners doublets link by the innerClusterId: " << innerClusterId
165  << std::endl;
166  }
167  bool isRootDoublet = thisDoublet.checkCompatibilityAndTag(allDoublets_,
168  neigDoublets,
169  r.directionAtOrigin,
170  minCosTheta,
171  minCosPointing,
172  verbosity_ > Advanced);
173  if (isRootDoublet)
174  theRootDoublets_.push_back(doubletId);
175  }
176  }
177  }
178  }
179  }
180  }
181  }
182  }
183  }
184  // #ifdef FP_DEBUG
185  if (verbosity_ > None) {
186  LogDebug("HGCGraph") << "number of Root doublets " << theRootDoublets_.size() << " over a total number of doublets "
187  << allDoublets_.size() << std::endl;
188  }
189  // #endif
190 }

References funct::abs(), Advanced, allDoublets_, areTimeCompatible(), Expert, Guru, timingPdfMaker::histo, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, muons_cff::isGlobal, isOuterClusterOfDoublets_, LogDebug, M_PI, SiStripPI::max, min(), EMStep_cff::missing_layers, L1TMuonDQMOffline_cfi::nEtaBins, None, ecaldqm::binning::nPhiBins, hltrates_dqm_sourceclient-live_cfg::offset, trackingPOGFilters_cfi::phiWindow, alignCSCRings::r, findQualityFiles::size, theRootDoublets_, and verbosity_.

◆ setVerbosity()

void HGCGraph::setVerbosity ( int  level)
inline

Definition at line 51 of file HGCGraph.h.

51 { verbosity_ = level; }

References personalPlayback::level, and verbosity_.

Member Data Documentation

◆ allDoublets_

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

Definition at line 55 of file HGCGraph.h.

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

◆ isOuterClusterOfDoublets_

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

Definition at line 57 of file HGCGraph.h.

Referenced by clear(), and makeAndConnectDoublets().

◆ theRootDoublets_

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

Definition at line 56 of file HGCGraph.h.

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

◆ verbosity_

int HGCGraph::verbosity_
private

Definition at line 58 of file HGCGraph.h.

Referenced by makeAndConnectDoublets(), and setVerbosity().

personalPlayback.level
level
Definition: personalPlayback.py:22
HGCGraph::theRootDoublets_
std::vector< unsigned int > theRootDoublets_
Definition: HGCGraph.h:56
min
T min(T a, T b)
Definition: MathUtil.h:58
HGCGraph::verbosity_
int verbosity_
Definition: HGCGraph.h:58
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
HGCGraph::areTimeCompatible
bool areTimeCompatible(int innerIdx, int outerIdx, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, float maxDeltaTime)
Definition: HGCGraph.cc:192
HGCGraph::None
Definition: HGCGraph.h:52
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
HGCGraph::allDoublets_
std::vector< HGCDoublet > allDoublets_
Definition: HGCGraph.h:55
HGCGraph::isOuterClusterOfDoublets_
std::vector< std::vector< int > > isOuterClusterOfDoublets_
Definition: HGCGraph.h:57
HGCDoublet::HGCntuplet
std::vector< unsigned int > HGCntuplet
Definition: HGCDoublet.h:16
HGCGraph::Basic
Definition: HGCGraph.h:52
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
trackingPOGFilters_cfi.phiWindow
phiWindow
Definition: trackingPOGFilters_cfi.py:109
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
EMStep_cff.missing_layers
missing_layers
Definition: EMStep_cff.py:28
HGCGraph::Advanced
Definition: HGCGraph.h:52
muons_cff.isGlobal
isGlobal
Definition: muons_cff.py:153
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HGCGraph::Guru
Definition: HGCGraph.h:52
edm::ValueMap::get
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:144
L1TMuonDQMOffline_cfi.nEtaBins
nEtaBins
Definition: L1TMuonDQMOffline_cfi.py:21
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:76
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ecaldqm::binning::nPhiBins
Definition: MESetBinningUtils.h:69
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
HGCGraph::Expert
Definition: HGCGraph.h:52
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443