8 const std::vector<float>& bin_centers,
9 const std::vector<unsigned int>&
counts) {
14 double highestPt = 0.;
15 unsigned int numHighPtTracks = 0;
21 std::vector<double> bin_pt(bin_centers.size(), 0.0);
22 unsigned int ibin = 0;
23 unsigned int itrack = 0;
33 if (
trackPt > settings_->vx_TrackMaxPt()) {
37 if (settings_->vx_TrackMaxPtBehavior() == 0)
39 else if (settings_->vx_TrackMaxPtBehavior() == 1)
40 trackPt = settings_->vx_TrackMaxPt();
44 if (bin_centers.empty() &&
counts.empty()) {
49 if (itrack ==
counts[ibin]) {
50 SumZ += bin_centers[ibin] * bin_pt[ibin];
51 z0square += bin_centers[ibin] * bin_centers[ibin];
58 z0 = SumZ / ((settings_->vx_weightedmean() > 0) ?
pt :
vertex.numTracks());
59 z0square /=
vertex.numTracks();
62 vertex.setParameters(
pt, z0, z0width, highPt, numHighPtTracks, highestPt);
65 void VertexFinder::GapClustering() {
69 for (
unsigned int i = 0;
i < fitTracks_.size(); ++
i) {
72 if ((
i + 1 < fitTracks_.size() and fitTracks_[
i + 1].z0() - fitTracks_[
i].z0() > settings_->vx_distance())
or 73 i == fitTracks_.size() - 1) {
75 computeAndSetVertexParameters(
Vertex, {}, {});
76 vertices_.push_back(
Vertex);
110 float distanceSum = 0;
114 distanceSum +=
std::abs(track0->z0() - track1->z0());
123 computeAndSetVertexParameters(cluster0, {}, {});
124 computeAndSetVertexParameters(cluster1, {}, {});
129 void VertexFinder::agglomerativeHierarchicalClustering() {
135 vClusters.resize(fitTracks_.size());
137 for (
unsigned int i = 0;
i < fitTracks_.size(); ++
i) {
138 vClusters[
i].insert(&fitTracks_[
i]);
143 float MinimumScore = 9999;
145 unsigned int clusterId0 = 0;
146 unsigned int clusterId1 = 0;
147 for (
unsigned int iClust = 0; iClust < vClusters.size() - 1; iClust++) {
151 if (settings_->vx_distanceType() == 0)
152 M =
maxDistance(vClusters[iClust], vClusters[iClust + 1]);
153 else if (settings_->vx_distanceType() == 1)
154 M = minDistance(vClusters[iClust], vClusters[iClust + 1]);
155 else if (settings_->vx_distanceType() == 2)
156 M = meanDistance(vClusters[iClust], vClusters[iClust + 1]);
158 M = centralDistance(vClusters[iClust], vClusters[iClust + 1]);
160 if (M < MinimumScore) {
163 clusterId1 = iClust + 1;
166 if (MinimumScore > settings_->vx_distance()
or vClusters[clusterId1].tracks().empty())
169 vClusters[clusterId1].insert(
track);
171 vClusters.erase(vClusters.begin() + clusterId0);
175 if (clust.numTracks() >= settings_->vx_minTracks()) {
176 computeAndSetVertexParameters(clust, {}, {});
177 vertices_.push_back(clust);
182 void VertexFinder::DBSCAN() {
184 std::vector<unsigned int>
visited;
185 std::vector<unsigned int> saved;
190 for (
unsigned int i = 0;
i < fitTracks_.size(); ++
i) {
196 std::set<unsigned int> neighbourTrackIds;
197 unsigned int numDensityTracks = 0;
198 if (fitTracks_[
i].
pt() > settings_->vx_dbscan_pt())
202 for (
unsigned int k = 0;
k < fitTracks_.size(); ++
k) {
204 if (
k !=
i and
std::abs(fitTracks_[
k].z0() - fitTracks_[
i].z0()) < settings_->vx_distance()) {
205 neighbourTrackIds.insert(
k);
206 if (fitTracks_[
k].
pt() > settings_->vx_dbscan_pt()) {
212 if (numDensityTracks < settings_->vx_dbscan_mintracks()) {
218 for (
unsigned int id : neighbourTrackIds) {
221 std::vector<unsigned int> neighbourTrackIds2;
222 for (
unsigned int k = 0;
k < fitTracks_.size(); ++
k) {
224 if (
std::abs(fitTracks_[
k].z0() - fitTracks_[
id].z0()) < settings_->vx_distance()) {
225 neighbourTrackIds2.push_back(
k);
230 for (
unsigned int id2 : neighbourTrackIds2) {
231 neighbourTrackIds.insert(
id2);
235 if (
find(saved.begin(), saved.end(),
id) == saved.end())
236 vertex.insert(&fitTracks_[
id]);
238 computeAndSetVertexParameters(
vertex, {}, {});
239 if (
vertex.numTracks() >= settings_->vx_minTracks())
240 vertices_.push_back(
vertex);
246 void VertexFinder::PVR() {
251 acceptedTracks.push_back(
track);
254 while (discardedTracks.size() >= settings_->vx_minTracks()
or start ==
true) {
256 bool removing =
true;
257 discardedTracks.clear();
259 float oldDistance = 0.;
261 if (settings_->debug() > 2)
262 edm::LogInfo(
"VertexFinder") <<
"PVR::AcceptedTracks " << acceptedTracks.size();
266 z0start +=
track.z0();
270 z0start /= acceptedTracks.size();
271 if (settings_->debug() > 2)
272 edm::LogInfo(
"VertexFinder") <<
"PVR::z0 vertex " << z0start;
273 FitTrackCollection::iterator badTrackIt = acceptedTracks.end();
276 for (FitTrackCollection::iterator it = acceptedTracks.begin(); it < acceptedTracks.end(); ++it) {
279 if (
std::abs(
track->z0() - z0start) > settings_->vx_distance() and
288 const L1Track badTrack = *badTrackIt;
289 if (settings_->debug() > 2)
290 edm::LogInfo(
"VertexFinder") <<
"PVR::Removing track " << badTrack.
z0() <<
" at distance " << oldDistance;
291 discardedTracks.push_back(badTrack);
292 acceptedTracks.erase(badTrackIt);
296 if (acceptedTracks.size() >= settings_->vx_minTracks()) {
301 computeAndSetVertexParameters(
vertex, {}, {});
302 vertices_.push_back(
vertex);
304 if (settings_->debug() > 2)
305 edm::LogInfo(
"VertexFinder") <<
"PVR::DiscardedTracks size " << discardedTracks.size();
306 acceptedTracks.clear();
307 acceptedTracks = discardedTracks;
311 void VertexFinder::adaptiveVertexReconstruction() {
317 discardedTracks.push_back(
track);
320 while (discardedTracks.size() >= settings_->vx_minTracks()
or start ==
true) {
322 discardedTracks2.clear();
323 FitTrackCollection::iterator it = discardedTracks.begin();
325 acceptedTracks.push_back(
track);
326 float z0sum =
track.z0();
328 for (FitTrackCollection::iterator it2 = discardedTracks.begin(); it2 < discardedTracks.end(); ++it2) {
330 const L1Track secondTrack = *it2;
332 z0sum += secondTrack.
z0();
333 float z0vertex = z0sum / (acceptedTracks.size() + 1);
337 for (
const L1Track& accTrack : acceptedTracks) {
339 float Residual = accTrack.z0() - z0vertex;
349 chi2 += Residual * Residual;
350 dof = (acceptedTracks.size() + 1) * 2 - 1;
352 if (
chi2 / dof < settings_->vx_chi2cut()) {
353 acceptedTracks.push_back(secondTrack);
355 discardedTracks2.push_back(secondTrack);
356 z0sum -= secondTrack.
z0();
361 if (acceptedTracks.size() >= settings_->vx_minTracks()) {
366 computeAndSetVertexParameters(
vertex, {}, {});
367 vertices_.push_back(
vertex);
370 acceptedTracks.clear();
371 discardedTracks.clear();
372 discardedTracks = discardedTracks2;
376 void VertexFinder::HPV() {
384 if (
track.pt() < 50.) {
396 computeAndSetVertexParameters(
vertex, {}, {});
398 vertices_.push_back(
vertex);
401 void VertexFinder::Kmeans() {
402 unsigned int NumberOfClusters = settings_->vx_kmeans_nclusters();
404 vertices_.resize(NumberOfClusters);
405 float ClusterSeparation = 30. / NumberOfClusters;
407 for (
unsigned int i = 0;
i < NumberOfClusters; ++
i) {
408 float ClusterCentre = -15. + ClusterSeparation * (
i + 0.5);
409 vertices_[
i].setZ0(ClusterCentre);
411 unsigned int iterations = 0;
413 while (iterations < settings_->vx_kmeans_iterations()) {
414 for (
unsigned int i = 0;
i < NumberOfClusters; ++
i) {
415 vertices_[
i].clear();
420 if (iterations == settings_->vx_kmeans_iterations() - 3)
421 distance = settings_->vx_distance() * 2;
422 if (iterations > settings_->vx_kmeans_iterations() - 3)
423 distance = settings_->vx_distance();
424 unsigned int ClusterId;
426 for (
unsigned int id = 0;
id < NumberOfClusters; ++
id) {
434 vertices_[ClusterId].insert(&
track);
437 for (
unsigned int i = 0;
i < NumberOfClusters; ++
i) {
438 if (vertices_[
i].numTracks() >= settings_->vx_minTracks())
439 computeAndSetVertexParameters(vertices_[
i], {}, {});
445 void VertexFinder::findPrimaryVertex() {
446 if (settings_->vx_precision() == Precision::Emulation) {
448 std::max_element(verticesEmulation_.begin(),
449 verticesEmulation_.end(),
451 return (vertex0.
pt() < vertex1.pt());
458 return (vertex0.
pt() < vertex1.pt());
464 template <
class data_type,
typename stream_type>
465 void VertexFinder::printHistogram(stream_type&
stream,
466 std::vector<data_type>
data,
472 int tableSize =
data.size();
475 maximum =
float(*std::max_element(std::begin(
data), std::end(
data))) * 1.05;
476 }
else if (maximum <= minimum) {
477 maximum =
float(*std::max_element(std::begin(
data), std::end(
data))) * 1.05;
478 minimum =
float(*std::min_element(std::begin(
data), std::end(
data)));
487 std::vector<std::string> intervals(tableSize,
"");
488 std::vector<std::string>
values(tableSize,
"");
490 int intervalswidth = 0, valueswidth = 0, tmpwidth = 0;
491 for (
int i = 0;
i < tableSize;
i++) {
493 tmpwidth = sprintf(
buffer,
"[%-.5g, %-.5g)",
float(
i),
float(
i + 1));
495 if (
i == (tableSize - 1)) {
496 intervals[
i][intervals[
i].size() - 1] =
']';
498 if (tmpwidth > intervalswidth)
499 intervalswidth = tmpwidth;
502 tmpwidth = sprintf(
buffer,
"%-.5g",
float(
data[
i]));
504 if (tmpwidth > valueswidth)
505 valueswidth = tmpwidth;
508 sprintf(
buffer,
"%-.5g",
float(minimum));
510 sprintf(
buffer,
"%-.5g",
float(maximum));
514 std::max(
int(minimumtext.size() + maximumtext.size()),
width - (intervalswidth + 1 + valueswidth + 1 + 2));
516 minimumtext +
std::string(plotwidth + 2 - minimumtext.size() - maximumtext.size(),
' ') + maximumtext;
518 float norm =
float(plotwidth) /
float(maximum - minimum);
519 int zero = std::round((0.0 - minimum) * norm);
520 std::vector<char>
line(plotwidth,
'-');
522 if ((minimum != 0) && (0 <=
zero) && (
zero < plotwidth)) {
528 std::vector<std::string>
out;
529 if (!
title.empty()) {
534 out.push_back(capstone);
535 for (
int i = 0;
i < tableSize;
i++) {
539 std::fill_n(
line.begin(), plotwidth,
' ');
541 int pos = std::round((
float(
x) - minimum) * norm);
548 if ((minimum != 0) && (0 <=
zero) && (
zero < plotwidth)) {
561 out.push_back(capstone);
564 for (
const auto&
o :
out) {
572 void VertexFinder::sortVerticesInPt() {
573 if (settings_->vx_precision() == Precision::Emulation) {
575 verticesEmulation_.begin(),
576 verticesEmulation_.end(),
580 return (vertex0.
pt() > vertex1.pt());
585 void VertexFinder::sortVerticesInZ0() {
586 if (settings_->vx_precision() == Precision::Emulation) {
588 verticesEmulation_.begin(),
589 verticesEmulation_.end(),
593 return (vertex0.
z0() < vertex1.z0());
598 void VertexFinder::associatePrimaryVertex(
double trueZ0) {
600 for (
unsigned int id = 0;
id < vertices_.size(); ++
id) {
608 void VertexFinder::fastHistoLooseAssociation() {
612 for (
float z = settings_->vx_histogram_min(); z < settings_->vx_histogram_max();
613 z += settings_->vx_histogram_binwidth()) {
620 computeAndSetVertexParameters(
vertex, {}, {});
628 vertices_.emplace_back(leading_vertex);
635 std::ceil((settings_->vx_histogram_max() - settings_->vx_histogram_min()) / settings_->vx_histogram_binwidth());
637 std::vector<RecoVertex<>> sums(
nbins - settings_->vx_windowSize() + 1);
639 strided_iota(std::begin(
bounds),
641 settings_->vx_histogram_min(),
642 settings_->vx_histogram_binwidth());
646 if ((
track.z0() < settings_->vx_histogram_min()) || (
track.z0() > settings_->vx_histogram_max()))
648 if (
track.getTTTrackPtr()->chi2() > settings_->vx_TrackMaxChi2())
650 if (
track.pt() < settings_->vx_TrackMinPt())
654 float nPS = 0., nstubs = 0;
657 const auto& theStubs =
track.getTTTrackPtr()->getStubRefs();
658 if (theStubs.empty()) {
659 edm::LogWarning(
"VertexFinder") <<
"fastHisto::Could not retrieve the vector of stubs.";
664 for (
const auto& stub : theStubs) {
677 if (nstubs < settings_->vx_NStubMin())
679 if (nPS < settings_->vx_NStubPSMin())
683 int trk_nstub = (
int)
track.getTTTrackPtr()->getStubRefs().size();
684 float chi2dof =
track.getTTTrackPtr()->chi2() / (2 * trk_nstub - 4);
686 if (settings_->vx_DoPtComp()) {
687 float trk_consistency =
track.getTTTrackPtr()->stubPtConsistency();
688 if (trk_nstub == 4) {
695 if (settings_->vx_DoTightChi2()) {
696 if (
track.pt() > 10.0 && chi2dof > 5.0)
713 std::vector<float> bin_centers(settings_->vx_windowSize(), 0.0);
714 std::vector<unsigned int>
counts(settings_->vx_windowSize(), 0);
715 for (
unsigned int i = 0;
i < sums.size();
i++) {
716 for (
unsigned int j = 0;
j < settings_->vx_windowSize();
j++) {
717 bin_centers[
j] = settings_->vx_histogram_min() + ((
i +
j) * settings_->vx_histogram_binwidth()) +
718 (0.5 * settings_->vx_histogram_binwidth());
722 computeAndSetVertexParameters(sums.at(
i), bin_centers,
counts);
726 float sigma_max = -999;
728 std::vector<int>
found;
729 found.reserve(settings_->vx_nvtx());
730 for (
unsigned int ivtx = 0; ivtx < settings_->vx_nvtx(); ivtx++) {
733 for (
unsigned int i = 0;
i < sums.size();
i++) {
737 if (sums.at(
i).pt() > sigma_max) {
738 sigma_max = sums.at(
i).pt();
742 found.push_back(imax);
743 vertices_.emplace_back(sums.at(imax));
747 if (settings_->debug() >= 1) {
749 log <<
"fastHisto::Checking the output parameters ... \n";
750 std::vector<double>
tmp;
754 printHistogram<double, edm::LogInfo>(
log,
tmp, 80, 0, -1,
"fastHisto::sums",
"\e[92m");
755 for (
unsigned int i = 0;
i <
found.size();
i++) {
756 log <<
"RecoVertex " <<
i <<
": bin index = " <<
found[
i] <<
"\tsumPt = " << sums.at(imax).pt()
757 <<
"\tz0 = " << sums.at(imax).z0();
762 void VertexFinder::fastHistoEmulation() {
764 enum TrackBitWidths {
769 kReducedPrecisionPt = 7,
772 enum HistogramBitWidths {
775 kBinFixedMagSize = 5,
776 kSlidingSumSize = 11,
779 kWeightedSlidingSumSize = 20,
780 kWeightedSlidingSumMagSize = 10,
784 kSumPtWindowBits =
BitsToRepresent(HistogramBitWidths::kWindowSize * (1 << HistogramBitWidths::kSumPtLinkSize)),
786 kSumPtUntruncatedLinkSize = TrackBitWidths::kPtSize + 2,
790 static constexpr
unsigned int kTableSize =
791 ((1 << HistogramBitWidths::kSumPtLinkSize) - 1) * HistogramBitWidths::kWindowSize;
793 typedef ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize, AP_RND_CONV, AP_SAT>
pt_t;
795 typedef ap_int<TrackBitWidths::kZ0Size>
z0_t;
798 typedef ap_ufixed<TrackBitWidths::kReducedPrecisionPt, TrackBitWidths::kReducedPrecisionPt, AP_RND_INF, AP_SAT>
801 typedef ap_uint<HistogramBitWidths::kBinSize> histbin_t;
803 typedef ap_ufixed<HistogramBitWidths::kBinFixedSize, HistogramBitWidths::kBinFixedMagSize, AP_RND_INF, AP_SAT>
807 typedef ap_ufixed<HistogramBitWidths::kSumPtUntruncatedLinkSize,
808 HistogramBitWidths::kSumPtUntruncatedLinkMagSize,
811 histbin_pt_sum_fixed_t;
813 typedef ap_ufixed<HistogramBitWidths::kSumPtLinkSize, HistogramBitWidths::kSumPtLinkSize, AP_RND_INF, AP_SAT>
816 typedef ap_ufixed<HistogramBitWidths::kSumPtWindowBits, HistogramBitWidths::kSumPtWindowBits, AP_RND_INF, AP_SAT>
817 window_pt_sum_fixed_t;
819 typedef ap_fixed<HistogramBitWidths::kWeightedSlidingSumSize,
820 HistogramBitWidths::kWeightedSlidingSumMagSize,
825 typedef ap_uint<HistogramBitWidths::kSlidingSumSize> slidingsum_t;
827 typedef ap_ufixed<HistogramBitWidths::kInverseSize, HistogramBitWidths::kInverseMagSize, AP_RND_INF, AP_SAT>
830 auto track_quality_check = [&](
const track_pt_fixed_t&
pt) ->
bool {
832 if (
pt.to_double() < settings_->vx_TrackMinPt())
837 auto fetch_bin = [&](
const z0_t& z0,
int nbins) -> std::pair<histbin_t, bool> {
839 ap_int<TrackBitWidths::kZ0Size + 1> z0_13 = z0;
841 ap_int<TrackBitWidths::kZ0Size + 1> absz0_13 = z0_13 + (1 << (TrackBitWidths::kZ0Size - 1));
843 ap_int<TrackBitWidths::kZ0Size + 1> absz0_13_reduced =
844 absz0_13 >> (TrackBitWidths::kZ0Size - HistogramBitWidths::kBinFixedSize);
846 histbin_t
bin = absz0_13_reduced.range(HistogramBitWidths::kBinFixedSize - 1, 0);
848 if (settings_->debug() > 2) {
850 <<
"fastHistoEmulation::fetchBin() Checking the mapping from z0 to bin index ... \n" 851 <<
"histbin_fixed_t(1.0 / settings_->vx_histogram_binwidth()) = " 852 << histbin_fixed_t(1.0 / settings_->vx_histogram_binwidth()) <<
"\n" 853 <<
"histbin_t(std::floor(nbins / 2) = " << histbin_t(std::floor(
nbins / 2.)) <<
"\n" 854 <<
"z0 = " << z0 <<
"\n" 859 return std::make_pair(0,
false);
861 return std::make_pair(0,
false);
867 auto init_inversion_table = [&]() -> std::vector<inverse_t> {
868 std::vector<inverse_t> table_out(kTableSize, 0.);
869 for (
unsigned int ii = 1;
ii < (kTableSize - 1);
ii++) {
871 table_out.at(
ii) = (1.0 /
ii);
874 table_out.at(kTableSize - 1) = 1.0 / (kTableSize);
878 auto inversion = [&](slidingsum_t& data_den) -> inverse_t {
879 std::vector<inverse_t> inversion_table = init_inversion_table();
885 if (data_den > (kTableSize - 1))
886 data_den = kTableSize - 1;
888 return inversion_table.at(
index);
892 zsliding_t z = iz - histbin_t(std::floor(
nbins / 2.));
893 std::unique_ptr<edm::LogInfo>
log;
894 if (settings_->debug() >= 1) {
895 log = std::make_unique<edm::LogInfo>(
"VertexProducer");
896 *
log <<
"bin_center information ...\n" 897 <<
"iz = " << iz <<
"\n" 898 <<
"histbin_t(std::floor(nbins / 2.)) = " << histbin_t(std::floor(
nbins / 2.)) <<
"\n" 899 <<
"binwidth = " << zsliding_t(settings_->vx_histogram_binwidth()) <<
"\n" 900 <<
"z = " << z <<
"\n" 901 <<
"zsliding_t(z * zsliding_t(binwidth)) = " << std::setprecision(7)
907 auto weighted_position = [&](histbin_t b_max,
908 const std::vector<link_pt_sum_fixed_t>& binpt,
909 slidingsum_t maximums,
910 int nbins) -> zsliding_t {
911 zsliding_t zvtx_sliding = 0;
912 slidingsum_t zvtx_sliding_sum = 0;
915 std::unique_ptr<edm::LogInfo>
log;
916 if (settings_->debug() >= 1) {
917 log = std::make_unique<edm::LogInfo>(
"VertexProducer");
918 *
log <<
"Progression of weighted_position() ...\n" 919 <<
"zvtx_sliding_sum = ";
923 for (ap_uint<
BitsToRepresent(HistogramBitWidths::kWindowSize)>
w = 0;
w < HistogramBitWidths::kWindowSize; ++
w) {
924 zvtx_sliding_sum += (binpt.at(
w) *
w);
925 if (settings_->debug() >= 1) {
926 *
log <<
"(" <<
w <<
" * " << binpt.at(
w) <<
")";
927 if (
w < HistogramBitWidths::kWindowSize - 1) {
933 if (settings_->debug() >= 1) {
934 *
log <<
" = " << zvtx_sliding_sum <<
"\n";
938 inv = inversion(maximums);
939 zvtx_sliding = zvtx_sliding_sum * inv;
941 zvtx_sliding = (settings_->vx_windowSize() / 2.0) + (((
int(settings_->vx_windowSize()) % 2) != 0) ? 0.5 : 0.0);
943 if (settings_->debug() >= 1) {
944 *
log <<
"inversion(" << maximums <<
") = " << inv <<
"\nzvtx_sliding = " << zvtx_sliding <<
"\n";
948 zvtx_sliding += b_max;
949 zvtx_sliding += ap_ufixed<1, 0>(0.5);
950 if (settings_->debug() >= 1) {
951 *
log <<
"b_max = " << b_max <<
"\n";
952 *
log <<
"zvtx_sliding + b_max + 0.5 = " << zvtx_sliding <<
"\n";
956 zvtx_sliding = bin_center(zvtx_sliding,
nbins);
957 if (settings_->debug() >= 1) {
958 *
log <<
"bin_center(zvtx_sliding + b_max + 0.5, nbins) = " << std::setprecision(7) << zvtx_sliding;
965 unsigned int nbins = std::round((settings_->vx_histogram_max() - settings_->vx_histogram_min()) /
966 settings_->vx_histogram_binwidth());
967 unsigned int nsums =
nbins - settings_->vx_windowSize() + 1;
968 std::vector<link_pt_sum_fixed_t>
hist(
nbins, 0);
969 std::vector<histbin_pt_sum_fixed_t> hist_untruncated(
nbins, 0);
972 if (settings_->debug() > 2) {
973 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::Processing " << fitTracks_.size() <<
" tracks";
980 tkpt.V =
track.getTTTrackPtr()->getTrackWord()(TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1,
981 TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
982 z0_t tkZ0 =
track.getTTTrackPtr()->getZ0Word();
984 if ((settings_->vx_DoQualityCuts() && track_quality_check(tkpt)) || (!settings_->vx_DoQualityCuts())) {
988 std::pair<histbin_t, bool>
bin = fetch_bin(tkZ0,
nbins);
994 if (settings_->debug() > 2) {
995 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::Checking the track word ... \n" 996 <<
"track word = " <<
track.getTTTrackPtr()->getTrackWord().to_string(2)
998 <<
"tkZ0 = " << tkZ0.to_double() <<
"(" << tkZ0.to_string(2)
999 <<
")\ttkpt = " << tkpt.to_double() <<
"(" << tkpt.to_string(2)
1000 <<
")\tbin = " <<
bin.first.to_int() <<
"\n" 1001 <<
"pt sum in bin " <<
bin.first.to_int()
1002 <<
" BEFORE adding track = " <<
hist.at(
bin.first).to_double();
1005 hist_untruncated.at(
bin.first) = hist_untruncated.at(
bin.first) + tkpt;
1007 if (settings_->debug() > 2) {
1008 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::\npt sum in bin " <<
bin.first.to_int()
1009 <<
" AFTER adding track = " << hist_untruncated.at(
bin.first).to_double();
1012 if (settings_->debug() > 2) {
1013 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::Did not add the following track ... \n" 1014 <<
"track word = " <<
track.getTTTrackPtr()->getTrackWord().to_string(2)
1016 <<
"tkZ0 = " << tkZ0.to_double() <<
"(" << tkZ0.to_string(2)
1017 <<
")\ttkpt = " << tkpt.to_double() <<
"(" << tkpt.to_string(2) <<
")";
1025 for (
unsigned int hb = 0;
hb <
hist.size(); ++
hb) {
1026 link_pt_sum_fixed_t bin_trunc = hist_untruncated.at(
hb).range(
1027 HistogramBitWidths::kSumPtUntruncatedLinkSize - 1,
1028 HistogramBitWidths::kSumPtUntruncatedLinkSize - HistogramBitWidths::kSumPtUntruncatedLinkMagSize);
1030 if (settings_->debug() > 2) {
1031 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::truncating histogram bin pt once filling is complete \n" 1032 <<
"hist_untruncated.at(" <<
hb <<
") = " << hist_untruncated.at(
hb).to_double()
1033 <<
"(" << hist_untruncated.at(
hb).to_string(2)
1034 <<
")\tbin_trunc = " << bin_trunc.to_double() <<
"(" << bin_trunc.to_string(2)
1035 <<
")\n\thist.at(" <<
hb <<
") = " <<
hist.at(
hb).to_double() <<
"(" 1036 <<
hist.at(
hb).to_string(2) <<
")";
1042 std::vector<window_pt_sum_fixed_t> hist_window_sums(nsums, 0);
1043 for (
unsigned int b = 0;
b < nsums; ++
b) {
1044 for (
unsigned int w = 0;
w < HistogramBitWidths::kWindowSize; ++
w) {
1051 std::vector<int>
found;
1052 found.reserve(settings_->vx_nvtx());
1053 for (
unsigned int ivtx = 0; ivtx < settings_->vx_nvtx(); ivtx++) {
1054 histbin_t b_max = 0;
1055 window_pt_sum_fixed_t max_pt = 0;
1056 zsliding_t zvtx_sliding = -999;
1057 std::vector<link_pt_sum_fixed_t> binpt_max(HistogramBitWidths::kWindowSize, 0);
1060 for (
unsigned int i = 0;
i < hist_window_sums.size();
i++) {
1064 if (hist_window_sums.at(
i) > max_pt) {
1066 max_pt = hist_window_sums.at(b_max);
1068 std::begin(
hist) + b_max + HistogramBitWidths::kWindowSize,
1069 std::begin(binpt_max));
1072 zvtx_sliding = weighted_position(b_max, binpt_max, max_pt,
nbins);
1075 if (settings_->debug() >= 1) {
1077 log <<
"fastHistoEmulation::Checking the output parameters ... \n";
1078 if (
found.empty()) {
1079 printHistogram<link_pt_sum_fixed_t, edm::LogInfo>(
log,
hist, 80, 0, -1,
"fastHistoEmulation::hist",
"\e[92m");
1080 printHistogram<window_pt_sum_fixed_t, edm::LogInfo>(
1081 log, hist_window_sums, 80, 0, -1,
"fastHistoEmulation::hist_window_sums",
"\e[92m");
1083 printHistogram<link_pt_sum_fixed_t, edm::LogInfo>(
1084 log, binpt_max, 80, 0, -1,
"fastHistoEmulation::binpt_max",
"\e[92m");
1085 log <<
"bin index (not a VertexWord parameter) = " << b_max <<
"\n" 1086 <<
"sumPt = " << max_pt.to_double() <<
"\n" 1087 <<
"z0 = " << zvtx_sliding.to_double();
1089 found.push_back(b_max);
static double constexpr NA
Avogadro's number.
constexpr int32_t ceil(float num)
double pt() const
Sum of fitted tracks transverse momentum [GeV].
unsigned int tobLayer(const DetId &id) const
::ecal::reco::ComputationScalarType data_type
ap_uint< VertexBitWidths::kUnassignedSize > vtxunassigned_t
ap_ufixed< VertexBitWidths::kNTrackInPVSize, VertexBitWidths::kNTrackInPVSize, AP_RND_CONV, AP_SAT > vtxmultiplicity_t
std::vector< L1Track > FitTrackCollection
double z0() const
Vertex z0 position [cm].
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const std::vector< const T * > & tracks() const
Tracks in the vertex.
void insert(TP &tp)
Assign TP to this vertex.
ap_ufixed< VertexBitWidths::kNTrackOutPVSize, VertexBitWidths::kNTrackOutPVSize, AP_RND_CONV, AP_SAT > vtxinversemult_t
unsigned int numTracks() const
Number of tracks originating from this vertex.
ap_fixed< VertexBitWidths::kZ0Size, VertexBitWidths::kZ0MagSize, AP_RND_CONV, AP_SAT > vtxz0_t
static constexpr unsigned BitsToRepresent(unsigned x)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Simple wrapper class for TTTrack.
Abs< T >::type abs(const T &t)
ap_ufixed< VertexBitWidths::kSumPtSize, VertexBitWidths::kSumPtMagSize, AP_RND_CONV, AP_SAT > vtxsumpt_t
static constexpr auto TOB
ap_uint< VertexBitWidths::kQualitySize > vtxquality_t
Log< level::Info, false > LogInfo
std::vector< RecoVertex<> > RecoVertexCollection
const unsigned int kPtMagSize
char data[epos_bytes_allocation]
unsigned int tidRing(const DetId &id) const
Log< level::Warning, false > LogWarning
static constexpr auto TID
unsigned int numTracks() const
Number of tracks originating from this vertex.
ap_uint< VertexBitWidths::kValidSize > vtxvalid_t