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());
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) {
667 DetId detId(stub->getDetId());
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 = 4,
776 kSlidingSumSize = 11,
779 kWeightedSlidingSumSize = 20,
780 kWeightedSlidingSumMagSize = 10,
783 kSumPtWindowBits =
BitsToRepresent(HistogramBitWidths::kWindowSize * (1 << HistogramBitWidths::kSumPtLinkSize)),
786 static constexpr
unsigned int kTableSize =
787 ((1 << HistogramBitWidths::kSumPtLinkSize) - 1) * HistogramBitWidths::kWindowSize;
789 typedef ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize, AP_RND_CONV, AP_SAT>
pt_t;
791 typedef ap_int<TrackBitWidths::kZ0Size>
z0_t;
794 typedef ap_ufixed<TrackBitWidths::kReducedPrecisionPt, TrackBitWidths::kReducedPrecisionPt, AP_RND_INF, AP_SAT>
797 typedef ap_uint<HistogramBitWidths::kBinSize> histbin_t;
799 typedef ap_ufixed<HistogramBitWidths::kBinFixedSize, HistogramBitWidths::kBinFixedMagSize, AP_RND_INF, AP_SAT>
802 typedef ap_ufixed<HistogramBitWidths::kSumPtLinkSize, HistogramBitWidths::kSumPtLinkSize, AP_RND_INF, AP_SAT>
805 typedef ap_ufixed<HistogramBitWidths::kSumPtWindowBits, HistogramBitWidths::kSumPtWindowBits, AP_RND_INF, AP_SAT>
806 window_pt_sum_fixed_t;
808 typedef ap_fixed<HistogramBitWidths::kWeightedSlidingSumSize,
809 HistogramBitWidths::kWeightedSlidingSumMagSize,
814 typedef ap_uint<HistogramBitWidths::kSlidingSumSize> slidingsum_t;
816 typedef ap_ufixed<HistogramBitWidths::kInverseSize, HistogramBitWidths::kInverseMagSize, AP_RND_INF, AP_SAT>
819 auto track_quality_check = [&](
const track_pt_fixed_t&
pt) ->
bool {
821 if (
pt.to_double() < settings_->vx_TrackMinPt())
826 auto fetch_bin = [&](
const z0_t& z0,
int nbins) -> std::pair<histbin_t, bool> {
828 ap_int<TrackBitWidths::kZ0Size + 1> z0_13 = z0;
830 ap_int<TrackBitWidths::kZ0Size + 1> absz0_13 = z0_13 + (1 << (TrackBitWidths::kZ0Size - 1));
832 ap_int<TrackBitWidths::kZ0Size + 1> absz0_13_reduced =
833 absz0_13 >> (TrackBitWidths::kZ0Size - HistogramBitWidths::kBinFixedSize);
835 histbin_t
bin = absz0_13_reduced.range(HistogramBitWidths::kBinFixedSize - 1, 0);
837 if (settings_->debug() > 2) {
839 <<
"fastHistoEmulation::fetchBin() Checking the mapping from z0 to bin index ... \n" 840 <<
"histbin_fixed_t(1.0 / settings_->vx_histogram_binwidth()) = " 841 << histbin_fixed_t(1.0 / settings_->vx_histogram_binwidth()) <<
"\n" 842 <<
"histbin_t(std::floor(nbins / 2) = " << histbin_t(std::floor(
nbins / 2.)) <<
"\n" 843 <<
"z0 = " << z0 <<
"\n" 848 return std::make_pair(0,
false);
850 return std::make_pair(0,
false);
856 auto init_inversion_table = [&]() -> std::vector<inverse_t> {
857 std::vector<inverse_t> table_out(kTableSize, 0.);
858 for (
unsigned int ii = 0;
ii < kTableSize;
ii++) {
860 float in_val = 1533.0 * (
ii /
float(kTableSize));
862 table_out.at(
ii) = (in_val > 0) ? (1.0 / in_val) : 0.0;
867 auto inversion = [&](slidingsum_t& data_den) -> inverse_t {
868 std::vector<inverse_t> inversion_table = init_inversion_table();
874 if (data_den > (kTableSize - 1))
875 data_den = kTableSize - 1;
877 return inversion_table.at(
index);
881 zsliding_t z = iz - histbin_t(std::floor(
nbins / 2.));
882 std::unique_ptr<edm::LogInfo>
log;
883 if (settings_->debug() >= 1) {
884 log = std::make_unique<edm::LogInfo>(
"VertexProducer");
885 *
log <<
"bin_center information ...\n" 886 <<
"iz = " << iz <<
"\n" 887 <<
"histbin_t(std::floor(nbins / 2.)) = " << histbin_t(std::floor(
nbins / 2.)) <<
"\n" 888 <<
"binwidth = " << zsliding_t(settings_->vx_histogram_binwidth()) <<
"\n" 889 <<
"z = " << z <<
"\n" 890 <<
"zsliding_t(z * zsliding_t(binwidth)) = " << std::setprecision(7)
896 auto weighted_position = [&](histbin_t b_max,
897 const std::vector<link_pt_sum_fixed_t>& binpt,
898 slidingsum_t maximums,
899 int nbins) -> zsliding_t {
900 zsliding_t zvtx_sliding = 0;
901 slidingsum_t zvtx_sliding_sum = 0;
904 std::unique_ptr<edm::LogInfo>
log;
905 if (settings_->debug() >= 1) {
906 log = std::make_unique<edm::LogInfo>(
"VertexProducer");
907 *
log <<
"Progression of weighted_position() ...\n" 908 <<
"zvtx_sliding_sum = ";
912 for (ap_uint<
BitsToRepresent(HistogramBitWidths::kWindowSize)>
w = 0;
w < HistogramBitWidths::kWindowSize; ++
w) {
913 zvtx_sliding_sum += (binpt.at(
w) *
w);
914 if (settings_->debug() >= 1) {
915 *
log <<
"(" <<
w <<
" * " << binpt.at(
w) <<
")";
916 if (
w < HistogramBitWidths::kWindowSize - 1) {
922 if (settings_->debug() >= 1) {
923 *
log <<
" = " << zvtx_sliding_sum <<
"\n";
927 inv = inversion(maximums);
928 zvtx_sliding = zvtx_sliding_sum * inv;
930 zvtx_sliding = (settings_->vx_windowSize() / 2.0) + (((
int(settings_->vx_windowSize()) % 2) != 0) ? 0.5 : 0.0);
932 if (settings_->debug() >= 1) {
933 *
log <<
"inversion(" << maximums <<
") = " << inv <<
"\nzvtx_sliding = " << zvtx_sliding <<
"\n";
937 zvtx_sliding += b_max;
938 zvtx_sliding += ap_ufixed<1, 0>(0.5);
939 if (settings_->debug() >= 1) {
940 *
log <<
"b_max = " << b_max <<
"\n";
941 *
log <<
"zvtx_sliding + b_max + 0.5 = " << zvtx_sliding <<
"\n";
945 zvtx_sliding = bin_center(zvtx_sliding,
nbins);
946 if (settings_->debug() >= 1) {
947 *
log <<
"bin_center(zvtx_sliding + b_max + 0.5, nbins) = " << std::setprecision(7) << zvtx_sliding;
954 unsigned int nbins = std::round((settings_->vx_histogram_max() - settings_->vx_histogram_min()) /
955 settings_->vx_histogram_binwidth());
956 unsigned int nsums =
nbins - settings_->vx_windowSize();
957 std::vector<link_pt_sum_fixed_t>
hist(
nbins, 0);
960 if (settings_->debug() > 2) {
961 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::Processing " << fitTracks_.size() <<
" tracks";
968 tkpt.V =
track.getTTTrackPtr()->getTrackWord()(TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1,
969 TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
970 track_pt_fixed_t pt_tmp = tkpt;
971 z0_t tkZ0 =
track.getTTTrackPtr()->getZ0Word();
973 if ((settings_->vx_DoQualityCuts() && track_quality_check(tkpt)) || (!settings_->vx_DoQualityCuts())) {
977 std::pair<histbin_t, bool>
bin = fetch_bin(tkZ0,
nbins);
983 if (settings_->debug() > 2) {
984 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::Checking the track word ... \n" 985 <<
"track word = " <<
track.getTTTrackPtr()->getTrackWord().to_string(2)
987 <<
"tkZ0 = " << tkZ0.to_double() <<
"(" << tkZ0.to_string(2)
988 <<
")\ttkpt = " << tkpt.to_double() <<
"(" << tkpt.to_string(2)
989 <<
")\tpt_tmp = " << pt_tmp <<
"\tbin = " <<
bin.first.to_int() <<
"\n" 990 <<
"pt sum in bin " <<
bin.first.to_int()
991 <<
" BEFORE adding track = " <<
hist.at(
bin.first).to_double();
996 if (settings_->debug() > 2) {
997 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::\npt sum in bin " <<
bin.first.to_int()
998 <<
" AFTER adding track = " <<
hist.at(
bin.first).to_double();
1001 if (settings_->debug() > 2) {
1002 edm::LogInfo(
"VertexProducer") <<
"fastHistoEmulation::Did not add the following track ... \n" 1003 <<
"track word = " <<
track.getTTTrackPtr()->getTrackWord().to_string(2)
1005 <<
"tkZ0 = " << tkZ0.to_double() <<
"(" << tkZ0.to_string(2)
1006 <<
")\ttkpt = " << tkpt.to_double() <<
"(" << tkpt.to_string(2)
1007 <<
")\tpt_tmp = " << pt_tmp;
1014 std::vector<window_pt_sum_fixed_t> hist_window_sums(nsums, 0);
1015 for (
unsigned int b = 0;
b < nsums; ++
b) {
1016 for (
unsigned int w = 0;
w < HistogramBitWidths::kWindowSize; ++
w) {
1023 std::vector<int>
found;
1024 found.reserve(settings_->vx_nvtx());
1025 for (
unsigned int ivtx = 0; ivtx < settings_->vx_nvtx(); ivtx++) {
1026 histbin_t b_max = 0;
1027 window_pt_sum_fixed_t max_pt = 0;
1028 zsliding_t zvtx_sliding = -999;
1029 std::vector<link_pt_sum_fixed_t> binpt_max(HistogramBitWidths::kWindowSize, 0);
1032 for (
unsigned int i = 0;
i < hist_window_sums.size();
i++) {
1036 if (hist_window_sums.at(
i) > max_pt) {
1038 max_pt = hist_window_sums.at(b_max);
1040 std::begin(
hist) + b_max + HistogramBitWidths::kWindowSize,
1041 std::begin(binpt_max));
1044 zvtx_sliding = weighted_position(b_max, binpt_max, max_pt,
nbins);
1047 if (settings_->debug() >= 1) {
1049 log <<
"fastHistoEmulation::Checking the output parameters ... \n";
1050 if (
found.empty()) {
1051 printHistogram<link_pt_sum_fixed_t, edm::LogInfo>(
log,
hist, 80, 0, -1,
"fastHistoEmulation::hist",
"\e[92m");
1052 printHistogram<window_pt_sum_fixed_t, edm::LogInfo>(
1053 log, hist_window_sums, 80, 0, -1,
"fastHistoEmulation::hist_window_sums",
"\e[92m");
1055 printHistogram<link_pt_sum_fixed_t, edm::LogInfo>(
1056 log, binpt_max, 80, 0, -1,
"fastHistoEmulation::binpt_max",
"\e[92m");
1057 log <<
"bin index (not a VertexWord parameter) = " << b_max <<
"\n" 1058 <<
"sumPt = " << max_pt.to_double() <<
"\n" 1059 <<
"z0 = " << zvtx_sliding.to_double();
1061 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
auto const & tracks
cannot be loose
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
Power< A, B >::type pow(const A &a, const B &b)
unsigned int numTracks() const
Number of tracks originating from this vertex.
ap_uint< VertexBitWidths::kValidSize > vtxvalid_t