10 template <
typename TILES>
12 const std::vector<TICLSeedingRegion> &
regions,
16 const std::vector<float> &mask,
17 const edm::ValueMap<std::pair<float, float>> &layerClustersTime,
25 int maxNumberOfLayers,
27 isOuterClusterOfDoublets_.clear();
30 theRootDoublets_.clear();
37 int startEtaBin, endEtaBin, startPhiBin, endPhiBin;
47 auto firstLayerOnZSide = maxNumberOfLayers * zSide;
48 const auto &firstLayerHisto =
histo[firstLayerOnZSide];
49 origin_eta =
r.origin.eta();
50 origin_phi =
r.origin.phi();
51 int entryEtaBin = firstLayerHisto.etaBin(origin_eta);
52 int entryPhiBin = firstLayerHisto.phiBin(origin_phi);
57 auto etaWindow = deltaIEta;
63 <<
" reached! Increasing inner search window" << std::endl;
65 startEtaBin =
std::max(entryEtaBin - etaWindow, 0);
69 if (verbosity_ > Guru) {
70 LogDebug(
"HGCGraph") <<
" Entrance eta, phi: " << origin_eta <<
", " << origin_phi
71 <<
" entryEtaBin: " << entryEtaBin <<
" entryPhiBin: " << entryPhiBin
72 <<
" globalBin: " << firstLayerHisto.globalBin(origin_eta, origin_phi)
73 <<
" on layer: " << firstLayerOnZSide <<
" startEtaBin: " << startEtaBin
74 <<
" endEtaBin: " << endEtaBin <<
" startPhiBin: " << startPhiBin
75 <<
" endPhiBin: " << endPhiBin <<
" phiBin(0): " << firstLayerHisto.phiBin(0.)
76 <<
" phiBin(" <<
M_PI / 2. <<
"): " << firstLayerHisto.phiBin(
M_PI / 2.) <<
" phiBin("
77 <<
M_PI <<
"): " << firstLayerHisto.phiBin(
M_PI) <<
" phiBin(" << -
M_PI / 2.
78 <<
"): " << firstLayerHisto.phiBin(-
M_PI / 2.) <<
" phiBin(" << -
M_PI
79 <<
"): " << firstLayerHisto.phiBin(-
M_PI) <<
" phiBin(" << 2. *
M_PI
80 <<
"): " << firstLayerHisto.phiBin(2. *
M_PI) << std::endl;
84 for (
int il = 0; il < maxNumberOfLayers - 1; ++il) {
85 for (
int outer_layer = 0; outer_layer <
std::min(1 +
skip_layers, maxNumberOfLayers - 1 - il); ++outer_layer) {
86 int currentInnerLayerId = il + maxNumberOfLayers * zSide;
87 int currentOuterLayerId = currentInnerLayerId + 1 + outer_layer;
88 auto const &outerLayerHisto =
histo[currentOuterLayerId];
89 auto const &innerLayerHisto =
histo[currentInnerLayerId];
91 if (verbosity_ > Advanced) {
93 <<
" at etaBin: " << etaLimitIncreaseWindowBin << std::endl;
98 for (
int iphi_it = startPhiBin; iphi_it < endPhiBin; ++iphi_it) {
100 if (verbosity_ > Guru) {
102 <<
" on layers I/O: " << currentInnerLayerId <<
"/" << currentOuterLayerId
103 <<
" with clusters: " << innerLayerHisto[
offset +
iphi].
size() << std::endl;
105 for (
auto innerClusterId : innerLayerHisto[
offset +
iphi]) {
107 if (mask[innerClusterId] == 0.) {
108 if (verbosity_ > Advanced)
109 LogDebug(
"HGCGraph") <<
"Skipping inner masked cluster " << innerClusterId << std::endl;
118 auto etaWindow = deltaIEta;
123 if (verbosity_ > Advanced) {
124 LogDebug(
"HGCGraph") <<
"Eta and Phi window increased by one" << std::endl;
130 for (
int oeta = etaRangeMin; oeta < etaRangeMax; ++oeta) {
132 for (
int phiRange = 0; phiRange < 2 *
phiWindow + 1; ++phiRange) {
139 if (verbosity_ > Guru) {
141 <<
" on layers I/O: " << currentInnerLayerId <<
"/" << currentOuterLayerId
142 <<
" with clusters: " << innerLayerHisto[oeta *
nPhiBins + ophi].
size()
145 for (
auto outerClusterId : outerLayerHisto[oeta *
nPhiBins + ophi]) {
147 if (mask[outerClusterId] == 0.) {
148 if (verbosity_ > Advanced)
149 LogDebug(
"HGCGraph") <<
"Skipping outer masked cluster " << outerClusterId << std::endl;
152 auto doubletId = allDoublets_.size();
153 if (maxDeltaTime != -1 &&
154 !areTimeCompatible(innerClusterId, outerClusterId, layerClustersTime, maxDeltaTime)) {
155 if (verbosity_ > Advanced)
156 LogDebug(
"HGCGraph") <<
"Rejecting doublets due to timing!" << std::endl;
159 allDoublets_.emplace_back(innerClusterId, outerClusterId, doubletId, &
layerClusters,
r.index);
160 if (verbosity_ > Advanced) {
162 <<
"Creating doubletsId: " << doubletId <<
" layerLink in-out: [" << currentInnerLayerId
163 <<
", " << currentOuterLayerId <<
"] clusterLink in-out: [" << innerClusterId <<
", "
164 << outerClusterId <<
"]" << std::endl;
166 isOuterClusterOfDoublets_[outerClusterId].push_back(doubletId);
167 auto &neigDoublets = isOuterClusterOfDoublets_[innerClusterId];
168 auto &thisDoublet = allDoublets_[doubletId];
169 if (verbosity_ > Expert) {
171 <<
"Checking compatibility of doubletId: " << doubletId
172 <<
" with all possible inners doublets link by the innerClusterId: " << innerClusterId
175 bool isRootDoublet = thisDoublet.checkCompatibilityAndTag(allDoublets_,
180 verbosity_ > Advanced);
181 if (isRootDoublet and checkDistanceRootDoubletVsSeed) {
182 auto dEtaSquared = (
layerClusters[innerClusterId].eta() - origin_eta);
183 dEtaSquared *= dEtaSquared;
184 auto dPhiSquared = (
layerClusters[innerClusterId].phi() - origin_phi);
185 dPhiSquared *= dPhiSquared;
187 isRootDoublet =
false;
190 theRootDoublets_.push_back(doubletId);
202 if (verbosity_ >
None) {
203 LogDebug(
"HGCGraph") <<
"number of Root doublets " << theRootDoublets_.size() <<
" over a total number of doublets "
204 << allDoublets_.size() << std::endl;
209 template <
typename TILES>
212 const edm::ValueMap<std::pair<float, float>> &layerClustersTime,
213 float maxDeltaTime) {
214 float timeIn = layerClustersTime.get(innerIdx).first;
215 float timeInE = layerClustersTime.get(innerIdx).second;
216 float timeOut = layerClustersTime.get(outerIdx).first;
217 float timeOutE = layerClustersTime.get(outerIdx).second;
219 return (timeIn == -99. || timeOut == -99. ||
220 std::abs(timeIn - timeOut) < maxDeltaTime *
sqrt(timeInE * timeInE + timeOutE * timeOutE));
224 template <
typename TILES>
226 std::vector<int> &seedIndices,
227 const unsigned int minClustersPerNtuplet,
229 unsigned int maxOutInHops) {
231 tmpNtuplet.reserve(minClustersPerNtuplet);
232 std::vector<std::pair<unsigned int, unsigned int>> outInToVisit;
233 for (
auto rootDoublet : theRootDoublets_) {
235 outInToVisit.clear();
236 int seedIndex = allDoublets_[rootDoublet].seedIndex();
238 allDoublets_[rootDoublet].findNtuplets(
239 allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInHops, maxOutInHops, outInToVisit);
240 while (!outInToVisit.empty()) {
241 allDoublets_[outInToVisit.back().first].findNtuplets(
242 allDoublets_, tmpNtuplet, seedIndex, outInDFS, outInToVisit.back().second, maxOutInHops, outInToVisit);
243 outInToVisit.pop_back();
246 if (tmpNtuplet.size() > minClustersPerNtuplet) {
247 foundNtuplets.push_back(tmpNtuplet);
248 seedIndices.push_back(seedIndex);