20 template <
typename TILES>
24 criticalDensity_(conf.getParameter<double>(
"criticalDensity")),
25 densitySiblingLayers_(conf.getParameter<int>(
"densitySiblingLayers")),
26 densityEtaPhiDistanceSqr_(conf.getParameter<double>(
"densityEtaPhiDistanceSqr")),
27 densityOnSameLayer_(conf.getParameter<bool>(
"densityOnSameLayer")),
28 criticalEtaPhiDistance_(conf.getParameter<double>(
"criticalEtaPhiDistance")),
29 outlierMultiplier_(conf.getParameter<double>(
"outlierMultiplier")),
30 minNumLayerCluster_(conf.getParameter<int>(
"minNumLayerCluster")),
31 eidInputName_(conf.getParameter<std::
string>(
"eid_input_name")),
32 eidOutputNameEnergy_(conf.getParameter<std::
string>(
"eid_output_name_energy")),
33 eidOutputNameId_(conf.getParameter<std::
string>(
"eid_output_name_id")),
34 eidMinClusterEnergy_(conf.getParameter<double>(
"eid_min_cluster_energy")),
35 eidNLayers_(conf.getParameter<int>(
"eid_n_layers")),
36 eidNClusters_(conf.getParameter<int>(
"eid_n_clusters")){};
38 template <
typename TILES>
42 auto lastLayerPerSide =
static_cast<int>(rhtools_.lastLayer(
false));
43 int maxLayer = 2 * lastLayerPerSide - 1;
45 for (
int ieta = 0; ieta < nEtaBin; ieta++) {
46 auto offset = ieta * nPhiBin;
47 for (
int phi = 0; phi < nPhiBin; phi++) {
48 int iphi = ((phi % nPhiBin + nPhiBin) % nPhiBin);
50 if (this->algo_verbosity_ > this->Advanced) {
51 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Layer: " <<
layer <<
" ieta: " << ieta <<
" phi: " << phi
60 template <
typename TILES>
62 const int eventNumber,
63 const std::vector<Trackster> &tracksters)
const {
66 <<
"[evt, tracksterId, cells, prob_photon, prob_ele, prob_chad, prob_nhad, layer_i, x_i, y_i, eta_i, phi_i, "
67 "energy_i, radius_i, rho_i, delta_i, isSeed_i";
72 for (
auto const &
t : tracksters) {
73 for (
auto v :
t.vertices()) {
74 auto [lyrIdx, soaIdx] = layerIdx2layerandSoa[
v];
75 auto const &thisLayer = clusters_[lyrIdx];
78 <<
"TracksterInfo: " << eventNumber << sep << num << sep <<
t.vertices().size() << sep
83 << thisLayer.x[soaIdx] << sep << thisLayer.y[soaIdx] << sep << thisLayer.eta[soaIdx] << sep
84 << thisLayer.phi[soaIdx] << sep << thisLayer.energy[soaIdx] << sep << thisLayer.radius[soaIdx] << sep
85 << thisLayer.rho[soaIdx] << sep << thisLayer.delta[soaIdx] << sep << thisLayer.isSeed[soaIdx] <<
'\n';
92 template <
typename TILES>
94 const int eventNumber)
const {
96 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"[evt, layer, x, y, eta, phi, cells, energy, radius, rho, delta, "
97 "isSeed, clusterIdx, layerClusterOriginalIdx";
104 auto const &thisLayer = clusters_[
layer];
106 for (
auto v : thisLayer.x) {
109 <<
"ClusterInfo: " << eventNumber <<
", " <<
layer <<
", " <<
v <<
", " << thisLayer.y[
num] <<
", "
110 << thisLayer.eta[
num] <<
", " << thisLayer.phi[
num] <<
", " << thisLayer.cells[
num] <<
", "
111 << thisLayer.energy[
num] <<
", " << thisLayer.radius[
num] <<
", " << thisLayer.rho[
num] <<
", "
112 << thisLayer.delta[
num] <<
", " << thisLayer.isSeed[
num] <<
", " << thisLayer.clusterIndex[
num] <<
", "
113 << thisLayer.layerClusterOriginalIdx[
num];
118 for (
unsigned int lcIdx = 0; lcIdx < layerIdx2layerandSoa.size(); lcIdx++) {
119 auto const &layerandSoa = layerIdx2layerandSoa[lcIdx];
121 if ((layerandSoa.first == -1) && (layerandSoa.second == -1))
125 <<
"lcIdx: " << lcIdx <<
" on Layer: " << layerandSoa.first <<
" SOA: " << layerandSoa.second;
130 template <
typename TILES>
133 std::vector<Trackster> &
result,
134 std::unordered_map<
int, std::vector<int>> &seedToTracksterAssociation) {
146 rhtools_.setGeometry(geom);
149 clusters_.resize(2 * rhtools_.lastLayer(
false));
150 std::vector<std::pair<int, int>> layerIdx2layerandSoa;
153 unsigned int layerIdx = 0;
155 if (input.
mask[layerIdx] == 0.) {
157 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Skipping masked clustrer: " << layerIdx;
159 layerIdx2layerandSoa.emplace_back(-1, -1);
163 const auto firstHitDetId = lc.hitsAndFractions()[0].first;
164 int layer = rhtools_.getLayerWithOffset(firstHitDetId) - 1 +
165 rhtools_.lastLayer(
false) * ((rhtools_.zside(firstHitDetId) + 1) >> 1);
168 layerIdx2layerandSoa.emplace_back(layer, clusters_[layer].
x.size());
171 float sum_sqr_x = 0.;
172 float sum_sqr_y = 0.;
173 float ref_x = lc.x();
174 float ref_y = lc.y();
175 float invClsize = 1. / lc.hitsAndFractions().size();
176 for (
auto const &hitsAndFractions : lc.hitsAndFractions()) {
177 auto const &
point = rhtools_.getPosition(hitsAndFractions.first);
178 sum_x +=
point.x() - ref_x;
179 sum_sqr_x += (
point.x() - ref_x) * (
point.x() - ref_x);
180 sum_y +=
point.y() - ref_y;
181 sum_sqr_y += (
point.y() - ref_y) * (
point.y() - ref_y);
188 float radius_x =
sqrt((sum_sqr_x - (sum_x * sum_x) * invClsize) * invClsize);
189 float radius_y =
sqrt((sum_sqr_y - (sum_y * sum_y) * invClsize) * invClsize);
190 clusters_[
layer].x.emplace_back(lc.x());
191 clusters_[
layer].y.emplace_back(lc.y());
192 clusters_[
layer].radius.emplace_back(radius_x + radius_y);
193 clusters_[
layer].eta.emplace_back(lc.eta());
194 clusters_[
layer].phi.emplace_back(lc.phi());
195 clusters_[
layer].cells.push_back(lc.hitsAndFractions().size());
196 clusters_[
layer].energy.emplace_back(lc.energy());
197 clusters_[
layer].isSeed.push_back(
false);
198 clusters_[
layer].clusterIndex.emplace_back(-1);
199 clusters_[
layer].layerClusterOriginalIdx.emplace_back(layerIdx++);
200 clusters_[
layer].nearestHigher.emplace_back(-1, -1);
201 clusters_[
layer].rho.emplace_back(0.
f);
205 clusters_[
layer].followers.resize(clusters_[
layer].
x.size());
208 auto lastLayerPerSide =
static_cast<int>(rhtools_.lastLayer(
false));
209 int maxLayer = 2 * lastLayerPerSide - 1;
210 std::vector<int> numberOfClustersPerLayer(maxLayer, 0);
211 for (
int i = 0;
i <= maxLayer;
i++) {
212 calculateLocalDensity(input.
tiles,
i, layerIdx2layerandSoa);
214 for (
int i = 0;
i <= maxLayer;
i++) {
215 calculateDistanceToHigher(input.
tiles,
i, layerIdx2layerandSoa);
218 auto nTracksters = findAndAssignTracksters(input.
tiles, layerIdx2layerandSoa);
220 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Reconstructed " << nTracksters <<
" tracksters" << std::endl;
221 dumpClusters(layerIdx2layerandSoa, eventNumber);
225 result.resize(nTracksters);
228 const auto &thisLayer = clusters_[
layer];
232 for (
unsigned int lc = 0; lc < thisLayer.x.size(); ++lc) {
234 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Trackster " << thisLayer.clusterIndex[lc];
236 if (thisLayer.clusterIndex[lc] >= 0) {
238 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
" adding lcIdx: " << thisLayer.layerClusterOriginalIdx[lc];
240 result[thisLayer.clusterIndex[lc]].vertices().push_back(thisLayer.layerClusterOriginalIdx[lc]);
241 result[thisLayer.clusterIndex[lc]].vertex_multiplicity().push_back(1);
243 for (
auto [follower_lyrIdx, follower_soaIdx] : thisLayer.followers[lc]) {
244 std::array<unsigned int, 2> edge = {
245 {(
unsigned int)thisLayer.layerClusterOriginalIdx[lc],
246 (
unsigned int)clusters_[follower_lyrIdx].layerClusterOriginalIdx[follower_soaIdx]}};
247 result[thisLayer.clusterIndex[lc]].edges().push_back(edge);
256 [&](
auto const &
v) {
return static_cast<int>(
v.vertices().size()) < minNumLayerCluster_; }),
258 result.shrink_to_fit();
263 rhtools_.getPositionLayer(rhtools_.lastLayerEE(
false),
false).z());
268 for (
auto const &
t : result) {
269 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Barycenter: " <<
t.barycenter();
272 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Regressed: " <<
t.regressed_energy();
278 dumpTracksters(layerIdx2layerandSoa, eventNumber, result);
288 template <
typename TILES>
290 const tensorflow::Session *eidSession,
291 std::vector<Trackster> &tracksters) {
315 std::vector<int> tracksterIndices;
316 for (
int i = 0; i < static_cast<int>(tracksters.size());
i++) {
320 float sumClusterEnergy = 0.;
321 for (
const unsigned int &vertex : tracksters[
i].
vertices()) {
322 sumClusterEnergy +=
static_cast<float>(layerClusters[vertex].energy());
324 if (sumClusterEnergy >= eidMinClusterEnergy_) {
326 tracksters[
i].setRegressedEnergy(0.
f);
327 tracksters[
i].zeroProbabilities();
328 tracksterIndices.push_back(
i);
335 int batchSize =
static_cast<int>(tracksterIndices.size());
336 if (batchSize == 0) {
341 tensorflow::TensorShape shape({batchSize, eidNLayers_, eidNClusters_, eidNFeatures_});
342 tensorflow::Tensor
input(tensorflow::DT_FLOAT, shape);
345 std::vector<tensorflow::Tensor> outputs;
346 std::vector<std::string> outputNames;
347 if (!eidOutputNameEnergy_.empty()) {
348 outputNames.push_back(eidOutputNameEnergy_);
350 if (!eidOutputNameId_.empty()) {
351 outputNames.push_back(eidOutputNameId_);
355 for (
int i = 0;
i < batchSize;
i++) {
356 const Trackster &trackster = tracksters[tracksterIndices[
i]];
361 std::vector<int> clusterIndices(trackster.vertices().size());
362 for (
int k = 0;
k < (int)trackster.vertices().size();
k++) {
363 clusterIndices[
k] =
k;
365 sort(clusterIndices.begin(), clusterIndices.end(), [&layerClusters, &trackster](
const int &
a,
const int &
b) {
366 return layerClusters[trackster.vertices(a)].energy() > layerClusters[trackster.vertices(
b)].energy();
370 std::vector<int> seenClusters(eidNLayers_);
373 for (
const int &
k : clusterIndices) {
377 if (j < eidNLayers_ && seenClusters[j] < eidNClusters_) {
379 float *
features = &input.tensor<float, 4>()(
i, j, seenClusters[j], 0);
382 *(features++) =
float(cluster.
energy() / float(trackster.vertex_multiplicity(
k)));
392 for (
int j = 0;
j < eidNLayers_;
j++) {
393 for (
int k = seenClusters[
j];
k < eidNClusters_;
k++) {
394 float *
features = &input.tensor<float, 4>()(
i,
j,
k, 0);
395 for (
int l = 0;
l < eidNFeatures_;
l++) {
403 tensorflow::run(const_cast<tensorflow::Session *>(eidSession), inputList, outputNames, &outputs);
406 if (!eidOutputNameEnergy_.empty()) {
408 float *
energy = outputs[0].flat<
float>().
data();
410 for (
const int &
i : tracksterIndices) {
411 tracksters[
i].setRegressedEnergy(*(energy++));
416 if (!eidOutputNameId_.empty()) {
418 int probsIdx = eidOutputNameEnergy_.empty() ? 0 : 1;
419 float *probs = outputs[probsIdx].flat<
float>().
data();
421 for (
const int &
i : tracksterIndices) {
422 tracksters[
i].setProbabilities(probs);
423 probs += tracksters[
i].id_probabilities().size();
428 template <
typename TILES>
430 const TILES &tiles,
const int layerId,
const std::vector<std::pair<int, int>> &layerIdx2layerandSoa) {
433 auto &clustersOnLayer = clusters_[layerId];
434 unsigned int numberOfClusters = clustersOnLayer.x.size();
436 auto isReachable = [&](
float x1,
float x2,
float y1,
float y2,
float delta_sqr) ->
bool {
439 << ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) <<
" vs " << delta_sqr <<
"["
440 << ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) < delta_sqr) <<
"]\n";
442 return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) < delta_sqr;
445 for (
unsigned int i = 0;
i < numberOfClusters;
i++) {
447 auto lastLayerPerSide =
static_cast<int>(rhtools_.lastLayer(
false));
449 int maxLayer = 2 * lastLayerPerSide - 1;
450 if (layerId < lastLayerPerSide) {
451 minLayer =
std::max(layerId - densitySiblingLayers_, minLayer);
452 maxLayer =
std::min(layerId + densitySiblingLayers_, lastLayerPerSide - 1);
454 minLayer =
std::max(layerId - densitySiblingLayers_, lastLayerPerSide);
455 maxLayer =
std::min(layerId + densitySiblingLayers_, maxLayer);
457 for (
int currentLayer = minLayer; currentLayer <= maxLayer; currentLayer++) {
459 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"RefLayer: " << layerId <<
" SoaIDX: " <<
i;
460 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"NextLayer: " << currentLayer;
462 const auto &tileOnLayer = tiles[currentLayer];
463 bool onSameLayer = (currentLayer == layerId);
465 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"onSameLayer: " << onSameLayer;
467 const int etaWindow = 2;
468 const int phiWindow = 2;
469 int etaBinMin =
std::max(tileOnLayer.etaBin(clustersOnLayer.eta[
i]) - etaWindow, 0);
470 int etaBinMax =
std::min(tileOnLayer.etaBin(clustersOnLayer.eta[
i]) + etaWindow, nEtaBin);
471 int phiBinMin = tileOnLayer.phiBin(clustersOnLayer.phi[
i]) - phiWindow;
472 int phiBinMax = tileOnLayer.phiBin(clustersOnLayer.phi[
i]) + phiWindow;
474 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"eta: " << clustersOnLayer.eta[
i];
475 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"phi: " << clustersOnLayer.phi[
i];
476 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"etaBinMin: " << etaBinMin <<
", etaBinMax: " << etaBinMax;
477 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"phiBinMin: " << phiBinMin <<
", phiBinMax: " << phiBinMax;
479 for (
int ieta = etaBinMin; ieta <= etaBinMax; ++ieta) {
480 auto offset = ieta * nPhiBin;
484 for (
int iphi_it = phiBinMin; iphi_it <= phiBinMax; ++iphi_it) {
485 int iphi = ((iphi_it % nPhiBin + nPhiBin) % nPhiBin);
489 <<
"Entries in tileBin: " << tileOnLayer[
offset + iphi].size();
491 for (
auto otherClusterIdx : tileOnLayer[
offset + iphi]) {
492 auto const &layerandSoa = layerIdx2layerandSoa[otherClusterIdx];
494 if ((layerandSoa.first == -1) && (layerandSoa.second == -1)) {
496 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"Skipping masked layerIdx " << otherClusterIdx;
500 auto const &clustersLayer = clusters_[layerandSoa.first];
503 <<
"OtherLayer: " << layerandSoa.first <<
" SoaIDX: " << layerandSoa.second;
504 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"OtherEta: " << clustersLayer.eta[layerandSoa.second];
505 edm::LogVerbatim(
"PatternRecogntionbyCLUE3D") <<
"OtherPhi: " << clustersLayer.phi[layerandSoa.second];
508 float delta = clustersOnLayer.radius[
i] + clustersLayer.radius[layerandSoa.second] + 2.6f;
509 if (densityOnSameLayer_ && onSameLayer) {
510 if (isReachable(clustersOnLayer.x[
i],
511 clustersLayer.x[layerandSoa.second],
512 clustersOnLayer.y[
i],
513 clustersLayer.y[layerandSoa.second],
515 clustersOnLayer.rho[
i] += (clustersOnLayer.layerClusterOriginalIdx[
i] == otherClusterIdx ? 1.f : 0.2f) *
516 clustersLayer.energy[layerandSoa.second];
522 clustersOnLayer.phi[
i],
523 clustersLayer.eta[layerandSoa.second],
524 clustersLayer.phi[layerandSoa.second]);
527 clustersOnLayer.phi[
i],
528 clustersLayer.eta[layerandSoa.second],
529 clustersLayer.phi[layerandSoa.second]) < densityEtaPhiDistanceSqr_) {
530 auto energyToAdd = (clustersOnLayer.layerClusterOriginalIdx[
i] == otherClusterIdx ? 1.f : 0.5f) *
531 clustersLayer.energy[layerandSoa.second];
532 clustersOnLayer.rho[
i] += energyToAdd;
534 <<
"Adding " << energyToAdd <<
" partial " << clustersOnLayer.rho[
i];
547 template <
typename TILES>
549 const TILES &tiles,
const int layerId,
const std::vector<std::pair<int, int>> &layerIdx2layerandSoa) {
552 auto &clustersOnLayer = clusters_[layerId];
553 unsigned int numberOfClusters = clustersOnLayer.x.size();
555 for (
unsigned int i = 0;
i < numberOfClusters;
i++) {
558 <<
"Starting searching nearestHigher on " << layerId <<
" with rho: " << clustersOnLayer.rho[
i]
559 <<
" at eta, phi: " << tiles[layerId].etaBin(clustersOnLayer.eta[
i]) <<
", "
560 << tiles[layerId].etaBin(clustersOnLayer.phi[
i]);
563 auto lastLayerPerSide =
static_cast<int>(rhtools_.lastLayer(
false));
565 int maxLayer = 2 * lastLayerPerSide - 1;
566 if (layerId < lastLayerPerSide) {
567 minLayer =
std::max(layerId - densitySiblingLayers_, minLayer);
568 maxLayer =
std::min(layerId + densitySiblingLayers_, lastLayerPerSide - 1);
570 minLayer =
std::max(layerId - densitySiblingLayers_, lastLayerPerSide + 1);
571 maxLayer =
std::min(layerId + densitySiblingLayers_, maxLayer);
574 float i_delta = maxDelta;
575 std::pair<int, int> i_nearestHigher(-1, -1);
576 for (
int currentLayer = minLayer; currentLayer <= maxLayer; currentLayer++) {
577 const auto &tileOnLayer = tiles[currentLayer];
580 int etaBinMin =
std::max(tileOnLayer.etaBin(clustersOnLayer.eta[
i]) - etaWindow, 0);
581 int etaBinMax =
std::min(tileOnLayer.etaBin(clustersOnLayer.eta[
i]) + etaWindow, nEtaBin);
582 int phiBinMin = tileOnLayer.phiBin(clustersOnLayer.phi[
i]) - phiWindow;
583 int phiBinMax = tileOnLayer.phiBin(clustersOnLayer.phi[
i]) + phiWindow;
584 for (
int ieta = etaBinMin; ieta <= etaBinMax; ++ieta) {
585 auto offset = ieta * nPhiBin;
586 for (
int iphi_it = phiBinMin; iphi_it <= phiBinMax; ++iphi_it) {
587 int iphi = ((iphi_it % nPhiBin + nPhiBin) % nPhiBin);
590 <<
"Searching nearestHigher on " << currentLayer <<
" eta, phi: " << ieta <<
", " << iphi_it;
592 for (
auto otherClusterIdx : tileOnLayer[
offset + iphi]) {
593 auto const &layerandSoa = layerIdx2layerandSoa[otherClusterIdx];
595 if ((layerandSoa.first == -1) && (layerandSoa.second == -1))
597 auto const &clustersOnOtherLayer = clusters_[layerandSoa.first];
599 clustersOnLayer.phi[
i],
600 clustersOnOtherLayer.eta[layerandSoa.second],
601 clustersOnOtherLayer.phi[layerandSoa.second]);
602 bool foundHigher = (clustersOnOtherLayer.rho[layerandSoa.second] > clustersOnLayer.rho[
i]) ||
603 (clustersOnOtherLayer.rho[layerandSoa.second] == clustersOnLayer.rho[
i] &&
604 clustersOnOtherLayer.layerClusterOriginalIdx[layerandSoa.second] >
605 clustersOnLayer.layerClusterOriginalIdx[
i]);
608 <<
"Searching nearestHigher on " << currentLayer
609 <<
" with rho: " << clustersOnOtherLayer.rho[layerandSoa.second]
610 <<
" on layerIdxInSOA: " << layerandSoa.first <<
", " << layerandSoa.second
611 <<
" with distance: " <<
sqrt(dist) <<
" foundHigher: " << foundHigher;
613 if (foundHigher && dist <= i_delta) {
617 i_nearestHigher = layerandSoa;
624 bool foundNearestHigherInEtaPhiCylinder = (i_delta != maxDelta);
627 <<
"i_delta: " <<
sqrt(i_delta) <<
" passed: " << foundNearestHigherInEtaPhiCylinder <<
" "
628 << i_nearestHigher.first <<
" " << i_nearestHigher.second;
630 if (foundNearestHigherInEtaPhiCylinder) {
631 clustersOnLayer.delta[
i] =
sqrt(i_delta);
632 clustersOnLayer.nearestHigher[
i] = i_nearestHigher;
636 clustersOnLayer.delta[
i] = maxDelta;
637 clustersOnLayer.nearestHigher[
i] = {-1, -1};
642 template <
typename TILES>
644 const TILES &tiles,
const std::vector<std::pair<int, int>> &layerIdx2layerandSoa) {
645 unsigned int nTracksters = 0;
647 std::vector<std::pair<int, int>> localStack;
649 for (
unsigned int layer = 0;
layer < 2 * rhtools_.lastLayer();
layer++) {
650 auto &clustersOnLayer = clusters_[
layer];
651 unsigned int numberOfClusters = clustersOnLayer.x.size();
652 for (
unsigned int i = 0;
i < numberOfClusters;
i++) {
654 clustersOnLayer.clusterIndex[
i] = -1;
656 (clustersOnLayer.delta[
i] > criticalEtaPhiDistance_) && (clustersOnLayer.rho[
i] >= criticalDensity_);
657 bool isOutlier = (clustersOnLayer.delta[
i] > outlierMultiplier_ * criticalEtaPhiDistance_) &&
658 (clustersOnLayer.rho[
i] < criticalDensity_);
662 <<
"Found seed on Layer " <<
layer <<
" SOAidx: " <<
i <<
" assigned ClusterIdx: " << nTracksters;
664 clustersOnLayer.clusterIndex[
i] = nTracksters++;
665 clustersOnLayer.isSeed[
i] =
true;
666 localStack.emplace_back(
layer,
i);
667 }
else if (!isOutlier) {
668 auto [lyrIdx, soaIdx] = clustersOnLayer.nearestHigher[
i];
671 <<
"Found follower on Layer " <<
layer <<
" SOAidx: " <<
i <<
" attached to cluster on layer: " << lyrIdx
672 <<
" SOAidx: " << soaIdx;
675 clusters_[lyrIdx].followers[soaIdx].emplace_back(
layer,
i);
679 <<
"Found Outlier on Layer " <<
layer <<
" SOAidx: " <<
i <<
" with rho: " << clustersOnLayer.rho[
i]
680 <<
" and delta: " << clustersOnLayer.delta[
i];
687 while (!localStack.empty()) {
688 auto [lyrIdx, soaIdx] = localStack.back();
689 auto &thisSeed = clusters_[lyrIdx].followers[soaIdx];
690 localStack.pop_back();
693 for (
auto [follower_lyrIdx, follower_soaIdx] : thisSeed) {
695 clusters_[follower_lyrIdx].clusterIndex[follower_soaIdx] = clusters_[lyrIdx].clusterIndex[soaIdx];
697 localStack.emplace_back(follower_lyrIdx, follower_soaIdx);
703 template <
typename TILES>
705 iDesc.
add<
int>(
"algo_verbosity", 0);
706 iDesc.
add<
double>(
"criticalDensity", 4)->setComment(
"in GeV");
707 iDesc.
add<
int>(
"densitySiblingLayers", 3);
708 iDesc.
add<
double>(
"densityEtaPhiDistanceSqr", 0.0008);
709 iDesc.
add<
bool>(
"densityOnSameLayer",
false);
710 iDesc.
add<
double>(
"criticalEtaPhiDistance", 0.035);
711 iDesc.
add<
double>(
"outlierMultiplier", 2);
712 iDesc.
add<
int>(
"minNumLayerCluster", 2)->setComment(
"Not Inclusive");
714 iDesc.
add<
std::string>(
"eid_output_name_energy",
"output/regressed_energy");
715 iDesc.
add<
std::string>(
"eid_output_name_id",
"output/id_probabilities");
716 iDesc.
add<
double>(
"eid_min_cluster_energy", 1.);
717 iDesc.
add<
int>(
"eid_n_layers", 50);
718 iDesc.
add<
int>(
"eid_n_clusters", 10);
Log< level::Info, true > LogVerbatim
std::vector< NamedTensor > NamedTensorList
void dumpTracksters(const std::vector< std::pair< int, int >> &layerIdx2layerandSoa, const int, const std::vector< Trackster > &) const
void energyRegressionAndID(const std::vector< reco::CaloCluster > &layerClusters, const tensorflow::Session *, std::vector< Trackster > &result)
PatternRecognitionbyCLUE3D(const edm::ParameterSet &conf, edm::ConsumesCollector)
EventAuxiliary const & eventAuxiliary() const override
void calculateDistanceToHigher(const TILES &, const int layerId, const std::vector< std::pair< int, int >> &)
double eta() const
pseudorapidity of cluster centroid
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
bool getData(T &iHolder) const
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, const edm::ValueMap< std::pair< float, float >> &, double, bool energyWeight=true)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
void makeTracksters(const typename PatternRecognitionAlgoBaseT< TILES >::Inputs &input, std::vector< Trackster > &result, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation) override
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
void dumpTiles(const TILES &) const
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Abs< T >::type abs(const T &t)
double energy() const
cluster energy
int findAndAssignTracksters(const TILES &, const std::vector< std::pair< int, int >> &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void dumpClusters(const std::vector< std::pair< int, int >> &layerIdx2layerandSoa, const int) const
void calculateLocalDensity(const TILES &, const int layerId, const std::vector< std::pair< int, int >> &)
char data[epos_bytes_allocation]
double phi() const
azimuthal angle of cluster centroid
void reset(double vett[256])
int sum_x
More diagnostics.
EventNumber_t event() const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point