From f2ce998544d4b6413e48987e0c9c69dac5dc1247 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Wed, 6 Apr 2022 00:57:03 -0700 Subject: [PATCH 01/57] Add radix-sort option in binnor. --- RecoTracker/MkFitCore/interface/binnor.h | 86 ++++++--- RecoTracker/MkFitCore/interface/radix_sort.h | 28 +++ RecoTracker/MkFitCore/src/radix_sort.cc | 83 +++++++++ .../MkFitCore/standalone/test/binnor_demo.cxx | 169 +++++++++--------- 4 files changed, 264 insertions(+), 102 deletions(-) create mode 100644 RecoTracker/MkFitCore/interface/radix_sort.h create mode 100644 RecoTracker/MkFitCore/src/radix_sort.cc diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index 8697604e37d06..9b0bd8ec133bc 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -1,12 +1,14 @@ #ifndef RecoTracker_MkFitCore_interface_binnor_h #define RecoTracker_MkFitCore_interface_binnor_h +#include "radix_sort.h" + #include #include #include #include #include -#include +//#include namespace mkfit { @@ -149,6 +151,9 @@ namespace mkfit { // used to fill it). Final counts for all the bins, as well as starting // indices for the bins (within m_ranks), are computed and stored in packed // form (i.e., bit-fields) in m_bins. + // 5. m_cons can be kept to do preselection when determining search ranges. + // Note that additional precision on Axis2 is screened out during sorting. + // // C - bin content type, to hold "bin population coordinates" in packed form (bit-fields) // A1, A2 - axis types @@ -156,17 +161,21 @@ namespace mkfit { template struct binnor { + static_assert(std::is_same() || std::is_same()); static_assert(std::is_same()); static_assert(A1::c_M + A2::c_M <= 32); static constexpr unsigned int c_A1_mask = (1 << A1::c_M) - 1; static constexpr unsigned int c_A2_Mout_mask = ~(((1 << A2::c_M2N_shift) - 1) << A1::c_M); + using sort_func = std::function; + // Pair of axis bin indices packed into unsigned. struct B_pair { unsigned int packed_value; // bin1 in A1::c_M lower bits, bin2 above B_pair() : packed_value(0) {} + B_pair(unsigned int pv) : packed_value(pv) {} B_pair(typename A1::index_t i1, typename A2::index_t i2) : packed_value(i2 << A1::c_M | i1) {} typename A1::index_t bin1() const { return packed_value & c_A1_mask; } @@ -189,10 +198,20 @@ namespace mkfit { const A1 &m_a1; const A2 &m_a2; std::vector m_cons; + std::vector m_cons_masked; std::vector m_bins; std::vector m_ranks; - - binnor(const A1 &a1, const A2 &a2) : m_a1(a1), m_a2(a2), m_bins(m_a1.size_of_N() * m_a2.size_of_N()) {} + const bool m_radix_sort; + const bool m_keep_cons; + const bool m_do_masked; + + binnor(const A1 &a1, const A2 &a2, bool radix = true, bool keep_cons = false) + : m_a1(a1), + m_a2(a2), + m_bins(m_a1.size_of_N() * m_a2.size_of_N()), + m_radix_sort(radix), + m_keep_cons(keep_cons), + m_do_masked(radix || !keep_cons) {} // Access @@ -221,37 +240,60 @@ namespace mkfit { // Filling void reset_contents() { + if (m_keep_cons) { + m_cons.clear(); + m_cons.shrink_to_fit(); + } m_bins.assign(m_bins.size(), C_pair()); m_ranks.clear(); m_ranks.shrink_to_fit(); } - void begin_registration(C n_items) { m_cons.reserve(n_items); } + void begin_registration(C n_items) { + if (m_keep_cons) + m_cons.reserve(n_items); + if (!m_keep_cons || m_radix_sort) + m_cons_masked.reserve(n_items); + } + + void register_entry(B_pair bp) { + m_cons.emplace_back(bp); + if (m_keep_cons) + m_cons.push_back(bp); + if (m_do_masked) + m_cons_masked.push_back(bp.mask_A2_M_bins()); + } void register_entry(typename A1::real_t r1, typename A2::real_t r2) { - m_cons.push_back({m_a1.from_R_to_M_bin(r1), m_a2.from_R_to_M_bin(r2)}); + register_entry({m_a1.from_R_to_M_bin(r1), m_a2.from_R_to_M_bin(r2)}); } void register_entry_safe(typename A1::real_t r1, typename A2::real_t r2) { - m_cons.push_back({m_a1.from_R_to_M_bin_safe(r1), m_a2.from_R_to_M_bin_safe(r2)}); + register_entry({m_a1.from_R_to_M_bin_safe(r1), m_a2.from_R_to_M_bin_safe(r2)}); } // Do M-binning outside, potentially using R_to_M_bin_safe(). - void register_m_bins(typename A1::index_t m1, typename A2::index_t m2) { m_cons.push_back({m1, m2}); } - - void finalize_registration() { - // call internal sort, bin building from icc where template instantiation has to be made. - - m_ranks.resize(m_cons.size()); - std::iota(m_ranks.begin(), m_ranks.end(), 0); - - std::sort(m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { - return m_cons[a].mask_A2_M_bins() < m_cons[b].mask_A2_M_bins(); - }); + void register_m_bins(typename A1::index_t m1, typename A2::index_t m2) { register_entry({m1, m2}); } + + void finalize_registration(sort_func ext_sort = 0) { + if (m_radix_sort) { + radix_sort radix; + radix.sort(m_cons_masked, m_ranks); + } else { + m_ranks.resize(m_cons.size()); + std::iota(m_ranks.begin(), m_ranks.end(), 0); + if (m_keep_cons) + std::sort(m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { + return m_cons[a].mask_A2_M_bins() < m_cons[b].mask_A2_M_bins(); + }); + else + std::sort( + m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { return m_cons_masked[a] < m_cons_masked[b]; }); + } for (C i = 0; i < m_ranks.size(); ++i) { C j = m_ranks[i]; - C_pair &c_bin = ref_content(m_bin_to_n_bin(m_cons[j])); + C_pair &c_bin = ref_content(m_bin_to_n_bin(m_keep_cons ? m_cons[j] : B_pair(m_cons_masked[j]))); if (c_bin.count == 0) c_bin.first = i; ++c_bin.count; @@ -262,10 +304,10 @@ namespace mkfit { #endif } - // Those could be kept to do preselection when determining search ranges. - // Especially since additional precision on Axis2 is screened out during sorting. - m_cons.clear(); - m_cons.shrink_to_fit(); + if (m_do_masked) { + m_cons_masked.clear(); + m_cons_masked.shrink_to_fit(); + } } }; diff --git a/RecoTracker/MkFitCore/interface/radix_sort.h b/RecoTracker/MkFitCore/interface/radix_sort.h new file mode 100644 index 0000000000000..9c10f757b9894 --- /dev/null +++ b/RecoTracker/MkFitCore/interface/radix_sort.h @@ -0,0 +1,28 @@ +#ifndef RecoTracker_MkFitCore_interface_radix_sort_h +#define RecoTracker_MkFitCore_interface_radix_sort_h + +#include +#include + +namespace mkfit { + + template + class radix_sort { + public: + static_assert(std::is_same() || std::is_same()); + static_assert(std::is_same() || std::is_same()); + + typedef unsigned char ubyte_t; + typedef V value_t; + typedef R rank_t; + static constexpr rank_t c_NBytes = sizeof(V); + + void sort(const std::vector& values, std::vector& ranks); + + private: + void histo_loop(const std::vector& values, rank_t* histos); + void radix_loop(const std::vector& values, rank_t* histos, std::vector& ranks); + }; +} // namespace mkfit + +#endif diff --git a/RecoTracker/MkFitCore/src/radix_sort.cc b/RecoTracker/MkFitCore/src/radix_sort.cc new file mode 100644 index 0000000000000..f7aed3e72b153 --- /dev/null +++ b/RecoTracker/MkFitCore/src/radix_sort.cc @@ -0,0 +1,83 @@ +#include "RecoTracker/MkFitCore/interface/radix_sort.h" + +#include + +namespace mkfit { + + // --- Driver function + + template + void radix_sort::sort(const std::vector& values, std::vector& ranks) { + if (values.empty()) { + ranks.clear(); + return; + } + + rank_t histos[c_NBytes * 256] = {0}; + + histo_loop(values, histos); + radix_loop(values, histos, ranks); + } + + // --- Histogramming + + template + void radix_sort::histo_loop(const std::vector& values, rank_t* histos) { + // Create histograms (counters). Counters for all passes are created in one run. + ubyte_t* p = (ubyte_t*)values.data(); + ubyte_t* pe = p + (values.size() * c_NBytes); + std::array ha; + for (rank_t j = 0; j < c_NBytes; ++j) + ha[j] = &histos[j << 8]; + while (p != pe) { + for (rank_t j = 0; j < c_NBytes; ++j) + ha[j][*p++]++; + } + } + + // --- Radix + + template + void radix_sort::radix_loop(const std::vector& values, rank_t* histos, std::vector& ranks) { + const rank_t nb = values.size(); + rank_t* link[256]; + ranks.resize(nb); + std::vector ranks2(nb); + // Radix sort, j is the pass number (0=LSB, 3=MSB) + for (rank_t j = 0; j < c_NBytes; j++) { + // Shortcut to current counters + rank_t* cur_count = &histos[j << 8]; + // Get first byte - f that byte's counter equals nb, all values are the same. + ubyte_t unique_val = *(((ubyte_t*)values.data()) + j); + + if (cur_count[unique_val] != nb) { + // Create offsets + link[0] = ranks2.data(); + for (rank_t i = 1; i < 256; i++) + link[i] = link[i - 1] + cur_count[i - 1]; + + // Perform Radix Sort + ubyte_t* input_bytes = (ubyte_t*)values.data(); + input_bytes += j; + if (j == 0) { + for (rank_t i = 0; i < nb; i++) + *link[input_bytes[i << 2]]++ = i; + } else { + rank_t* indices = &ranks[0]; + rank_t* indices_end = &ranks[nb]; + while (indices != indices_end) { + rank_t id = *indices++; + *link[input_bytes[id << 2]]++ = id; + } + } + + // Swap ranks - valid indices are in ranks after the swap. + ranks.swap(ranks2); + } + } + } + + // Instantiate supported sort types. + template class radix_sort; + template class radix_sort; +} // namespace mkfit diff --git a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx index c7a165674d2af..0a171df1ddfff 100644 --- a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx +++ b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx @@ -2,24 +2,26 @@ #include #include +#include "../../interface/radix_sort.h" + // build as: // c++ -o binnor_demo -std=c++17 binnor_demo.cxx +// with radix_sort: +// c++ -o binnor_demo -O3 -mavx2 -std=c++17 binnor_demo.cxx -I../../../.. ../../src/radix_sort.cc using namespace mkfit; -int main() -{ - constexpr float PI = 3.14159265358979323846; - constexpr float TwoPI = 6.28318530717958647692; - constexpr float PIOver2 = PI / 2.0f; - constexpr float PIOver4 = PI / 4.0f; +int main() { + constexpr float PI = 3.14159265358979323846; + constexpr float TwoPI = 6.28318530717958647692; + constexpr float PIOver2 = PI / 2.0f; + constexpr float PIOver4 = PI / 4.0f; - axis_pow2_u1 phi(-PI, PI); + axis_pow2_u1 phi(-PI, PI); - printf("Axis phi: M-bits=%d, N-bits=%d Masks M:0x%x N:0x%x\n", - phi.c_M, phi.c_N, phi.c_M_mask, phi.c_N_mask); + printf("Axis phi: M-bits=%d, N-bits=%d Masks M:0x%x N:0x%x\n", phi.c_M, phi.c_N, phi.c_M_mask, phi.c_N_mask); - /* + /* for (float p = -TwoPI; p < TwoPI; p += TwoPI / 15.4f) { printf(" phi=%-9f m=%5d n=%3d m2n=%3d n_safe=%3d\n", p, phi.from_R_to_M_bin(p), phi.from_R_to_N_bin(p), @@ -28,78 +30,85 @@ int main() } */ - axis eta(-2.6, 2.6, 20u); - - printf("Axis eta: M-bits=%d, N-bits=%d m_bins=%d n_bins=%d\n", - eta.c_M, eta.c_N, eta.size_of_M(), eta.size_of_N()); - - binnor b(phi, eta); - - // typedef typeof(b) type_b; - printf("Have binnor, size of vec = %zu, sizeof(C_pair) = %d\n", - b.m_bins.size(), sizeof( decltype(b)::C_pair) ); - - std::mt19937 rnd(std::random_device{}()); - std::uniform_real_distribution d_phi(-PI, PI); - std::uniform_real_distribution d_eta(-2.55, 2.55); - - const int NN = 100000; - - struct track { float phi, eta; }; - std::vector tracks; - tracks.reserve(NN); - - auto start = std::chrono::high_resolution_clock::now(); - - b.begin_registration(NN); // optional, reserves construction vector - - for (int i = 0; i < NN; ++i) - { - tracks.push_back( { d_phi(rnd), d_eta(rnd) } ); - b.register_entry(tracks.back().phi, tracks.back().eta); - // printf("made track %3d: phi=%f eta=%f\n", i, tracks.back().phi, tracks.back().eta); - } - - b.finalize_registration(); - - auto stop = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast(stop - start); - - // for (int i = 0; i < NN; ++i) - // { - // const track &t = tracks[ b.m_ranks[i] ]; - // printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); - // } - - printf("\n\n--- Single bin access for (phi, eta) = (0,0):\n\n"); - auto nbin = b.get_n_bin(0.f, 0.f); - auto cbin = b.get_content(0.f, 0.f); - printf("For (phi 0, eta 0; %u, %u) got first %d, count %d\n", nbin.bin1(), nbin.bin2(), cbin.first, cbin.count); - for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { - const track &t = tracks[ b.m_ranks[i] ]; - printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); - } - - printf("\n\n--- Range access for phi=[(-PI+0.02 +- 0.1], eta=[1.3 +- .2]:\n\n"); - auto phi_rng = phi.from_R_rdr_to_N_bins(-PI+0.02, 0.1); - auto eta_rng = eta.from_R_rdr_to_N_bins(1.3, .2); - printf("phi bin range: %u, %u; eta %u, %u\n", phi_rng.begin, phi_rng.end, eta_rng.begin, eta_rng.end); - for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = phi.next_N_bin(i_phi)) - { - for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = eta.next_N_bin(i_eta)) - { - printf(" at i_phi=%u, i_eta=%u\n", i_phi, i_eta); - auto cbin = b.get_content(i_phi, i_eta); - for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { - const track &t = tracks[ b.m_ranks[i] ]; - printf(" %3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); - } - } + axis eta(-2.6, 2.6, 20u); + + printf("Axis eta: M-bits=%d, N-bits=%d m_bins=%d n_bins=%d\n", eta.c_M, eta.c_N, eta.size_of_M(), eta.size_of_N()); + + const int NN = 100000; + const bool use_radix = true; + const bool keep_cons = false; + + binnor b(phi, eta, use_radix, keep_cons); + + // typedef typeof(b) type_b; + printf("Have binnor, size of vec = %zu, sizeof(C_pair) = %d\n", b.m_bins.size(), sizeof(decltype(b)::C_pair)); + + std::mt19937 rnd(std::random_device{}()); + std::uniform_real_distribution d_phi(-PI, PI); + std::uniform_real_distribution d_eta(-2.55, 2.55); + + struct track { + float phi, eta; + }; + std::vector tracks; + tracks.reserve(NN); + + auto start = std::chrono::high_resolution_clock::now(); + + b.begin_registration(NN); // optional, reserves construction vector + + for (int i = 0; i < NN; ++i) { + tracks.push_back({d_phi(rnd), d_eta(rnd)}); + b.register_entry(tracks.back().phi, tracks.back().eta); + // printf("made track %3d: phi=%f eta=%f\n", i, tracks.back().phi, tracks.back().eta); + } + + auto reg_start = std::chrono::high_resolution_clock::now(); + + b.finalize_registration(); + + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(stop - start); + auto fill_duration = std::chrono::duration_cast(reg_start - start); + auto sort_duration = std::chrono::duration_cast(stop - reg_start); + + // for (int i = 0; i < NN; ++i) + // { + // const track &t = tracks[ b.m_ranks[i] ]; + // printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); + // } + + printf("\n\n--- Single bin access for (phi, eta) = (0,0):\n\n"); + auto nbin = b.get_n_bin(0.f, 0.f); + auto cbin = b.get_content(0.f, 0.f); + printf("For (phi 0, eta 0; %u, %u) got first %d, count %d\n", nbin.bin1(), nbin.bin2(), cbin.first, cbin.count); + for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { + const track &t = tracks[b.m_ranks[i]]; + printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); + } + + printf("\n\n--- Range access for phi=[(-PI+0.02 +- 0.1], eta=[1.3 +- .2]:\n\n"); + auto phi_rng = phi.from_R_rdr_to_N_bins(-PI + 0.02, 0.1); + auto eta_rng = eta.from_R_rdr_to_N_bins(1.3, .2); + printf("phi bin range: %u, %u; eta %u, %u\n", phi_rng.begin, phi_rng.end, eta_rng.begin, eta_rng.end); + for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = phi.next_N_bin(i_phi)) { + for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = eta.next_N_bin(i_eta)) { + printf(" at i_phi=%u, i_eta=%u\n", i_phi, i_eta); + auto cbin = b.get_content(i_phi, i_eta); + for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { + const track &t = tracks[b.m_ranks[i]]; + printf(" %3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); + } } + } - printf("\nBinning time for %d points: %f sec\n", NN, 1.e-6*duration.count()); + printf("\nProcessing time for %d points: %f sec (filling %f sec, sort + binning %f sec)\n", + NN, + 1.e-6 * duration.count(), + 1.e-6 * fill_duration.count(), + 1.e-6 * sort_duration.count()); - b.reset_contents(); + b.reset_contents(); - return 0; + return 0; } From 958ba5f7c2bf28c0403a1ef5ef2308b6e8b25ce3 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 7 Apr 2022 11:55:10 -0700 Subject: [PATCH 02/57] Use edm::Log for geometry producer, add MkFit/test/BuildFile.xml. --- .../MkFit/plugins/MkFitGeometryESProducer.cc | 20 ++++++++++++------- RecoTracker/MkFit/test/BuildFile.xml | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 RecoTracker/MkFit/test/BuildFile.xml diff --git a/RecoTracker/MkFit/plugins/MkFitGeometryESProducer.cc b/RecoTracker/MkFit/plugins/MkFitGeometryESProducer.cc index 3dcf7a6667b6c..b8c88a713a291 100644 --- a/RecoTracker/MkFit/plugins/MkFitGeometryESProducer.cc +++ b/RecoTracker/MkFit/plugins/MkFitGeometryESProducer.cc @@ -19,6 +19,8 @@ #include "RecoTracker/MkFitCore/interface/IterationConfig.h" #include "RecoTracker/MkFitCMS/interface/LayerNumberConverter.h" +#include + //------------------------------------------------------------------------------ class MkFitGeometryESProducer : public edm::ESProducer { @@ -46,7 +48,7 @@ class MkFitGeometryESProducer : public edm::ESProducer { void sqrt_elements(); bool find_gap(Interval &itvl, float eps); - void print_gaps(); + void print_gaps(std::ostream &ostr); std::list m_coverage; Interval m_current; @@ -146,19 +148,18 @@ bool MkFitGeometryESProducer::GapCollector::find_gap(Interval &itvl, float eps) return false; } -void MkFitGeometryESProducer::GapCollector::print_gaps() { +void MkFitGeometryESProducer::GapCollector::print_gaps(std::ostream &ostr) { auto i = m_coverage.begin(); while (i != m_coverage.end()) { auto j = i; ++j; if (j != m_coverage.end()) { - printf("(%f, %f)->%f ", i->y, j->x, j->x - i->y); + ostr << "(" << i->y << ", " << j->x << ")->" << j->x - i->y; i = j; } else { break; } } - printf("\n"); } //------------------------------------------------------------------------------ @@ -302,15 +303,20 @@ void MkFitGeometryESProducer::addTECGeometry(mkfit::TrackerInfo &trk_info) { fillShapeAndPlacement(det, trk_info, &lgc_map); } // Now loop over the GapCollectors and see if there is a coverage gap. + std::ostringstream ostr; + ostr << "addTECGeometry() gap report:\n"; GapCollector::Interval itvl; for (auto &[layer, gcol] : lgc_map) { gcol.sqrt_elements(); if (gcol.find_gap(itvl, 0.5)) { - edm::LogInfo("TEC layer with gap") << "layer: " << layer << ", gap: " << itvl.x << " -> " << itvl.y - << " width = " << itvl.y - itvl.x; + ostr << " layer: " << layer << ", gap: " << itvl.x << " -> " << itvl.y << " width = " << itvl.y - itvl.x << "\n"; + ostr << " all gaps: "; + gcol.print_gaps(ostr); + ostr << "\n"; trk_info.layer_nc(layer).set_r_hole_range(itvl.x, itvl.y); } } + edm::LogVerbatim("MkFitGeometryESProducer") << ostr.str(); } //------------------------------------------------------------------------------ @@ -336,7 +342,7 @@ std::unique_ptr MkFitGeometryESProducer::produce(const TrackerRec // std::string path = "Geometry/TrackerCommonData/data/"; if (trackerGeom_->isThere(GeomDetEnumerators::P1PXB) || trackerGeom_->isThere(GeomDetEnumerators::P1PXEC)) { - edm::LogInfo("MkFitGeometryESProducer") << "extracting PhaseI eometry"; + edm::LogInfo("MkFitGeometryESProducer") << "Extracting PhaseI geometry"; trackerInfo->create_layers(18, 27, 27); } else if (trackerGeom_->isThere(GeomDetEnumerators::P2PXB) || trackerGeom_->isThere(GeomDetEnumerators::P2PXEC) || trackerGeom_->isThere(GeomDetEnumerators::P2OTB) || trackerGeom_->isThere(GeomDetEnumerators::P2OTEC)) { diff --git a/RecoTracker/MkFit/test/BuildFile.xml b/RecoTracker/MkFit/test/BuildFile.xml new file mode 100644 index 0000000000000..d6200cf66cba9 --- /dev/null +++ b/RecoTracker/MkFit/test/BuildFile.xml @@ -0,0 +1,7 @@ + + + + + + + From 2258fdb06210554a24cc994ca8d4237f49ffd814 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 7 Apr 2022 12:32:13 -0700 Subject: [PATCH 03/57] while importing seeds use binnor for sorting or rely on previous sorting done during seed cleaning. --- .../plugins/MkFitIterationConfigESProducer.cc | 18 +-- RecoTracker/MkFit/test/dumpMkFitGeometry.py | 3 + RecoTracker/MkFitCMS/src/runFunctions.cc | 2 +- .../MkFitCMS/standalone/buildtestMPlex.cc | 11 +- .../MkFitCore/interface/HitStructures.h | 20 +-- .../MkFitCore/interface/IterationConfig.h | 6 +- RecoTracker/MkFitCore/interface/MkBuilder.h | 8 +- RecoTracker/MkFitCore/interface/binnor.h | 6 +- RecoTracker/MkFitCore/src/MkBuilder.cc | 135 +++++++++--------- 9 files changed, 102 insertions(+), 107 deletions(-) diff --git a/RecoTracker/MkFit/plugins/MkFitIterationConfigESProducer.cc b/RecoTracker/MkFit/plugins/MkFitIterationConfigESProducer.cc index a1f134a3ef3a6..2b87c8cac30af 100644 --- a/RecoTracker/MkFit/plugins/MkFitIterationConfigESProducer.cc +++ b/RecoTracker/MkFit/plugins/MkFitIterationConfigESProducer.cc @@ -31,9 +31,6 @@ namespace { // Region to be defined by propagation / intersection tests TrackerInfo::EtaRegion reg; - // Max eta used for region sorting - constexpr float maxEta_regSort = 7.0; - const LayerInfo &outer_brl = trk_info.outer_barrel_layer(); // Define first (mkFit) layer IDs for each strip subdetector. @@ -82,10 +79,8 @@ namespace { } part.m_region[i] = reg; - - // TrackerInfo::EtaRegion is enum from 0 to 5 (Reg_Endcap_Neg,Reg_Transition_Neg,Reg_Barrel,Reg_Transition_Pos,Reg_Endcap_Pos) - // Symmetrization around TrackerInfo::Reg_Barrel for sorting is required - part.m_sort_score[i] = maxEta_regSort * (reg - TrackerInfo::Reg_Barrel) + eta; + if (part.m_phi_eta_foo) + part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta); } } @@ -158,9 +153,6 @@ namespace { // Region to be defined by propagation / intersection tests TrackerInfo::EtaRegion reg; - // Max eta used for region sorting - constexpr float maxEta_regSort = 7.0; - const bool z_dir_pos = S.pz() > 0; const float maxR = S.maxReachRadius(); @@ -199,10 +191,8 @@ namespace { } part.m_region[i] = reg; - - // TrackerInfo::EtaRegion is enum from 0 to 5 (Reg_Endcap_Neg,Reg_Transition_Neg,Reg_Barrel,Reg_Transition_Pos,Reg_Endcap_Pos) - // Symmetrization around TrackerInfo::Reg_Barrel for sorting is required - part.m_sort_score[i] = maxEta_regSort * (reg - TrackerInfo::Reg_Barrel) + eta; + if (part.m_phi_eta_foo) + part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta); } } } // namespace diff --git a/RecoTracker/MkFit/test/dumpMkFitGeometry.py b/RecoTracker/MkFit/test/dumpMkFitGeometry.py index 0f868638f3e73..06555bcb0358e 100644 --- a/RecoTracker/MkFit/test/dumpMkFitGeometry.py +++ b/RecoTracker/MkFit/test/dumpMkFitGeometry.py @@ -16,6 +16,9 @@ from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2021_realistic', '') +process.MessageLogger.cerr.threshold = "INFO" +process.MessageLogger.cerr.MkFitGeometryESProducer = dict(limit=-1) + process.source = cms.Source("EmptySource") process.maxEvents.input = 1 diff --git a/RecoTracker/MkFitCMS/src/runFunctions.cc b/RecoTracker/MkFitCMS/src/runFunctions.cc index e9a3709f4925d..08c2c1e230029 100644 --- a/RecoTracker/MkFitCMS/src/runFunctions.cc +++ b/RecoTracker/MkFitCMS/src/runFunctions.cc @@ -57,7 +57,7 @@ namespace mkfit { s.sortHitsByLayer(); // sort seed hits for the matched hits (I hope it works here) } - builder.find_tracks_load_seeds(seeds); + builder.find_tracks_load_seeds(seeds, do_seed_clean); builder.findTracksCloneEngine(); diff --git a/RecoTracker/MkFitCMS/standalone/buildtestMPlex.cc b/RecoTracker/MkFitCMS/standalone/buildtestMPlex.cc index e6e83b8e6b441..6ffb9b0d93519 100644 --- a/RecoTracker/MkFitCMS/standalone/buildtestMPlex.cc +++ b/RecoTracker/MkFitCMS/standalone/buildtestMPlex.cc @@ -135,10 +135,11 @@ namespace mkfit { builder.begin_event(&job, &ev, __func__); + bool seeds_sorted = false; // CCCC builder.PrepareSeeds(); // EventOfCandidates event_of_cands; - builder.find_tracks_load_seeds_BH(ev.seedTracks_); + builder.find_tracks_load_seeds_BH(ev.seedTracks_, seeds_sorted); #ifdef USE_VTUNE_PAUSE __SSC_MARK(0x111); // use this to resume Intel SDE at the same point @@ -221,9 +222,10 @@ namespace mkfit { builder.begin_event(&job, &ev, __func__); + bool seeds_sorted = false; // CCCC builder.PrepareSeeds(); - builder.find_tracks_load_seeds(ev.seedTracks_); + builder.find_tracks_load_seeds(ev.seedTracks_, seeds_sorted); #ifdef USE_VTUNE_PAUSE __SSC_MARK(0x111); // use this to resume Intel SDE at the same point @@ -307,9 +309,10 @@ namespace mkfit { builder.begin_event(&job, &ev, __func__); + bool seeds_sorted = false; // CCCC builder.PrepareSeeds(); - builder.find_tracks_load_seeds(ev.seedTracks_); + builder.find_tracks_load_seeds(ev.seedTracks_, seeds_sorted); #ifdef USE_VTUNE_PAUSE __SSC_MARK(0x111); // use this to resume Intel SDE at the same point @@ -446,7 +449,7 @@ namespace mkfit { if (seeds.size() <= 0) continue; - builder.find_tracks_load_seeds(seeds); + builder.find_tracks_load_seeds(seeds, itconf.m_requires_dupclean_tight); double time = dtime(); diff --git a/RecoTracker/MkFitCore/interface/HitStructures.h b/RecoTracker/MkFitCore/interface/HitStructures.h index 5471a51930df5..baff6eb13a1ed 100644 --- a/RecoTracker/MkFitCore/interface/HitStructures.h +++ b/RecoTracker/MkFitCore/interface/HitStructures.h @@ -794,7 +794,7 @@ namespace mkfit { class EventOfCombCandidates { public: - EventOfCombCandidates(int size = 0) : m_cc_pool(), m_candidates(), m_capacity(0), m_size(0) {} + EventOfCombCandidates(int size = 0) : m_cc_pool(), m_candidates() {} void releaseMemory() { { // Get all the destructors called before nuking CcPool. @@ -803,6 +803,7 @@ namespace mkfit { } m_capacity = 0; m_size = 0; + m_n_seeds_inserted = 0; m_cc_pool.release(); } @@ -821,20 +822,22 @@ namespace mkfit { m_candidates[s].reset(0, 0); } - m_size = 0; + m_size = new_capacity; + m_n_seeds_inserted = 0; } void resizeAfterFiltering(int n_removed) { assert(n_removed <= m_size); m_size -= n_removed; + m_n_seeds_inserted -= n_removed; } - void insertSeed(const Track& seed, int region) { - assert(m_size < m_capacity); + void insertSeed(const Track& seed, int region, int pos) { + assert(pos < m_size); - m_candidates[m_size].importSeed(seed, region); + m_candidates[pos].importSeed(seed, region); - ++m_size; + ++m_n_seeds_inserted; } void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) { @@ -867,8 +870,9 @@ namespace mkfit { std::vector m_candidates; - int m_capacity; - int m_size; + int m_capacity = 0; + int m_size = 0; + int m_n_seeds_inserted = 0; }; } // end namespace mkfit diff --git a/RecoTracker/MkFitCore/interface/IterationConfig.h b/RecoTracker/MkFitCore/interface/IterationConfig.h index 93eb5f627f497..28502353cc909 100644 --- a/RecoTracker/MkFitCore/interface/IterationConfig.h +++ b/RecoTracker/MkFitCore/interface/IterationConfig.h @@ -120,10 +120,12 @@ namespace mkfit { class IterationSeedPartition { public: + using register_seed_phi_eta_foo = void(float, float); + std::vector m_region; - std::vector m_sort_score; + std::function m_phi_eta_foo; - IterationSeedPartition(int size) : m_region(size), m_sort_score(size) {} + IterationSeedPartition(int size) : m_region(size) {} }; //============================================================================== diff --git a/RecoTracker/MkFitCore/interface/MkBuilder.h b/RecoTracker/MkFitCore/interface/MkBuilder.h index 6f97874749fe0..c19d547cd7533 100644 --- a/RecoTracker/MkFitCore/interface/MkBuilder.h +++ b/RecoTracker/MkFitCore/interface/MkBuilder.h @@ -55,7 +55,7 @@ namespace mkfit { class MkBuilder { public: - using insert_seed_foo = void(const Track &, int); + using insert_seed_foo = void(const Track &, int, int); using filter_track_cand_foo = bool(const TrackCand &); typedef std::vector> CandIdx_t; @@ -92,7 +92,7 @@ namespace mkfit { void end_event(); void release_memory(); - void import_seeds(const TrackVec &in_seeds, std::function insert_seed); + void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function insert_seed); // filter for rearranging cands that will / will not do backward search. int filter_comb_cands(std::function filter); @@ -116,8 +116,8 @@ namespace mkfit { // -------- - void find_tracks_load_seeds_BH(const TrackVec &in_seeds); // for FindTracksBestHit - void find_tracks_load_seeds(const TrackVec &in_seeds); + void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted); // for FindTracksBestHit + void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted); int find_tracks_unroll_candidates(std::vector> &seed_cand_vec, int start_seed, diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index 9b0bd8ec133bc..9291027f1755f 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -4,11 +4,9 @@ #include "radix_sort.h" #include -#include #include #include #include -//#include namespace mkfit { @@ -168,8 +166,6 @@ namespace mkfit { static constexpr unsigned int c_A1_mask = (1 << A1::c_M) - 1; static constexpr unsigned int c_A2_Mout_mask = ~(((1 << A2::c_M2N_shift) - 1) << A1::c_M); - using sort_func = std::function; - // Pair of axis bin indices packed into unsigned. struct B_pair { unsigned int packed_value; // bin1 in A1::c_M lower bits, bin2 above @@ -275,7 +271,7 @@ namespace mkfit { // Do M-binning outside, potentially using R_to_M_bin_safe(). void register_m_bins(typename A1::index_t m1, typename A2::index_t m2) { register_entry({m1, m2}); } - void finalize_registration(sort_func ext_sort = 0) { + void finalize_registration() { if (m_radix_sort) { radix_sort radix; radix.sort(m_cons_masked, m_ranks); diff --git a/RecoTracker/MkFitCore/src/MkBuilder.cc b/RecoTracker/MkFitCore/src/MkBuilder.cc index 5ba073bfb298f..af20795b255b1 100644 --- a/RecoTracker/MkFitCore/src/MkBuilder.cc +++ b/RecoTracker/MkFitCore/src/MkBuilder.cc @@ -6,6 +6,7 @@ #include "RecoTracker/MkFitCore/interface/MkBuilder.h" #include "RecoTracker/MkFitCore/interface/TrackerInfo.h" +#include "RecoTracker/MkFitCore/interface/binnor.h" #include "Pool.h" #include "CandCloner.h" @@ -17,8 +18,6 @@ #include "RecoTracker/MkFitCore/standalone/Event.h" #endif -#include "Ice/IceRevisitedRadix.h" - //#define DEBUG #include "Debug.h" @@ -208,68 +207,74 @@ namespace mkfit { m_event_of_comb_cands.releaseMemory(); } - void MkBuilder::import_seeds(const TrackVec &in_seeds, std::function insert_seed) { + void MkBuilder::import_seeds(const TrackVec &in_seeds, + const bool seeds_sorted, + std::function insert_seed) { // bool debug = true; const int size = in_seeds.size(); IterationSeedPartition part(size); - - m_job->m_iter_config.m_partition_seeds(m_job->m_trk_info, in_seeds, m_job->m_event_of_hits, part); - - RadixSort radix; - radix.Sort(&part.m_sort_score[0], size); + std::vector ranks; + if (!seeds_sorted) { + axis_pow2_u1 ax_phi(-Const::PI, Const::PI); + axis ax_eta(-3.0, 3.0, 64u); + binnor phi_eta_binnor(ax_phi, ax_eta); + part.m_phi_eta_foo = [&](float phi, float eta) { phi_eta_binnor.register_entry_safe(phi, eta); }; + + phi_eta_binnor.begin_registration(size); + m_job->m_iter_config.m_partition_seeds(m_job->m_trk_info, in_seeds, m_job->m_event_of_hits, part); + phi_eta_binnor.finalize_registration(); + ranks.swap(phi_eta_binnor.m_ranks); + } else { + m_job->m_iter_config.m_partition_seeds(m_job->m_trk_info, in_seeds, m_job->m_event_of_hits, part); + } for (int i = 0; i < size; ++i) { - int j = radix.GetRanks()[i]; + int j = seeds_sorted ? i : ranks[i]; + int reg = part.m_region[j]; + ++m_seedEtaSeparators[reg]; + } - const Track &S = in_seeds[j]; - HitOnTrack hot = S.getLastHitOnTrack(); + // Sum up region counts to contain actual ending indices and prepare insertion cursors. + // Fix min/max layers. + std::vector seed_cursors(m_job->num_regions()); + for (int reg = 1; reg < m_job->num_regions(); ++reg) { + seed_cursors[reg] = m_seedEtaSeparators[reg - 1]; + m_seedEtaSeparators[reg] += m_seedEtaSeparators[reg - 1]; + } + // Actually imports seeds, detect last-hit layer range per region. + for (int i = 0; i < size; ++i) { + int j = seeds_sorted ? i : ranks[i]; int reg = part.m_region[j]; + const Track &seed = in_seeds[j]; + insert_seed(seed, reg, seed_cursors[reg]++); - ++m_seedEtaSeparators[reg]; - + HitOnTrack hot = seed.getLastHitOnTrack(); m_seedMinLastLayer[reg] = std::min(m_seedMinLastLayer[reg], hot.layer); m_seedMaxLastLayer[reg] = std::max(m_seedMaxLastLayer[reg], hot.layer); - - insert_seed(S, reg); } // Fix min/max layers - for (int i = 0; i < m_job->num_regions(); ++i) { - if (m_seedMinLastLayer[i] == 9999) - m_seedMinLastLayer[i] = -1; - if (m_seedMaxLastLayer[i] == 0) - m_seedMaxLastLayer[i] = -1; - } - - dprintf( - "MkBuilder::import_seeds finished import of %d seeds (last seeding layer min, max):\n" - " ec- = %d(%d,%d), t- = %d(%d,%d), brl = %d(%d,%d), t+ = %d(%d,%d), ec+ = %d(%d,%d).\n", - size, - m_seedEtaSeparators[0], - m_seedMinLastLayer[0], - m_seedMaxLastLayer[0], - m_seedEtaSeparators[1], - m_seedMinLastLayer[1], - m_seedMaxLastLayer[1], - m_seedEtaSeparators[2], - m_seedMinLastLayer[2], - m_seedMaxLastLayer[2], - m_seedEtaSeparators[3], - m_seedMinLastLayer[3], - m_seedMaxLastLayer[3], - m_seedEtaSeparators[4], - m_seedMinLastLayer[4], - m_seedMaxLastLayer[4]); - - // Sum up region counts to contain actual separator indices. - for (int i = 1; i < m_job->num_regions(); ++i) { - m_seedEtaSeparators[i] += m_seedEtaSeparators[i - 1]; + for (int reg = 0; reg < m_job->num_regions(); ++reg) { + if (m_seedMinLastLayer[reg] == 9999) + m_seedMinLastLayer[reg] = -1; + if (m_seedMaxLastLayer[reg] == 0) + m_seedMaxLastLayer[reg] = -1; } + // clang-format off + dprintf("MkBuilder::import_seeds finished import of %d seeds (last seeding layer min, max):\n" + " ec- = %d(%d,%d), t- = %d(%d,%d), brl = %d(%d,%d), t+ = %d(%d,%d), ec+ = %d(%d,%d).\n", + size, + m_seedEtaSeparators[0], m_seedMinLastLayer[0], m_seedMaxLastLayer[0], + m_seedEtaSeparators[1] - m_seedEtaSeparators[0], m_seedMinLastLayer[1], m_seedMaxLastLayer[1], + m_seedEtaSeparators[2] - m_seedEtaSeparators[1], m_seedMinLastLayer[2], m_seedMaxLastLayer[2], + m_seedEtaSeparators[3] - m_seedEtaSeparators[2], m_seedMinLastLayer[3], m_seedMaxLastLayer[3], + m_seedEtaSeparators[4] - m_seedEtaSeparators[3], m_seedMinLastLayer[4], m_seedMaxLastLayer[4]); dcall(print_seeds(m_event_of_comb_cands)); + // clang-format on } //------------------------------------------------------------------------------ @@ -328,21 +333,12 @@ namespace mkfit { gmin = std::max(gmin, min[reg]); gmax = std::max(gmax, max[reg]); } - printf( - "MkBuilder::find_min_max_hots_size MIN %3d -- [ %3d | %3d | %3d | %3d | %3d ] MAX %3d -- [ %3d | %3d | %3d | " - "%3d | %3d ]\n", - gmin, - min[0], - min[1], - min[2], - min[3], - min[4], - gmax, - max[0], - max[1], - max[2], - max[3], - max[4]); + // clang-format off + printf("MkBuilder::find_min_max_hots_size MIN %3d -- [ %3d | %3d | %3d | %3d | %3d ] " + "MAX %3d -- [ %3d | %3d | %3d | %3d | %3d ]\n", + gmin, min[0], min[1], min[2], min[3], min[4], + gmax, max[0], max[1], max[2], max[3], max[4]); + // clang-format on } void MkBuilder::select_best_comb_cands(bool clear_m_tracks, bool remove_missing_hits) { @@ -428,16 +424,15 @@ namespace mkfit { // FindTracksBestHit //------------------------------------------------------------------------------ - void MkBuilder::find_tracks_load_seeds_BH(const TrackVec &in_seeds) { + void MkBuilder::find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted) { // bool debug = true; assert(!in_seeds.empty()); - m_tracks.reserve(in_seeds.size()); - m_tracks.clear(); + m_tracks.resize(in_seeds.size()); - import_seeds(in_seeds, [&](const Track &seed, int region) { - m_tracks.push_back(seed); - m_tracks.back().setNSeedHits(seed.nTotalHits()); - m_tracks.back().setEtaRegion(region); + import_seeds(in_seeds, seeds_sorted, [&](const Track &seed, int region, int pos) { + m_tracks[pos] = seed; + m_tracks[pos].setNSeedHits(seed.nTotalHits()); + m_tracks[pos].setEtaRegion(region); }); //dump seeds @@ -593,14 +588,16 @@ namespace mkfit { // FindTracksCombinatorial: Standard TBB and CloneEngine TBB //------------------------------------------------------------------------------ - void MkBuilder::find_tracks_load_seeds(const TrackVec &in_seeds) { + void MkBuilder::find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted) { // This will sort seeds according to iteration configuration. assert(!in_seeds.empty()); m_tracks.clear(); // m_tracks can be used for BkFit. m_event_of_comb_cands.reset((int)in_seeds.size(), m_job->max_max_cands()); - import_seeds(in_seeds, [&](const Track &seed, int region) { m_event_of_comb_cands.insertSeed(seed, region); }); + import_seeds(in_seeds, seeds_sorted, [&](const Track &seed, int region, int pos) { + m_event_of_comb_cands.insertSeed(seed, region, pos); + }); } int MkBuilder::find_tracks_unroll_candidates(std::vector> &seed_cand_vec, From 5ad71f7da2f2756da3165dc1185101c6c7d04ceb Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 8 Apr 2022 11:45:03 -0700 Subject: [PATCH 04/57] Split track-related classes out of HitStructures.h/cc into a new TrackStructures.h/cc file-set. --- .../MkFitCore/interface/HitStructures.h | 647 ----------------- RecoTracker/MkFitCore/interface/MkBuilder.h | 23 +- .../MkFitCore/interface/TrackStructures.h | 656 ++++++++++++++++++ RecoTracker/MkFitCore/src/CandCloner.cc | 1 - RecoTracker/MkFitCore/src/HitStructures.cc | 243 ------- RecoTracker/MkFitCore/src/MkBuilder.cc | 23 +- RecoTracker/MkFitCore/src/MkFinder.cc | 1 - RecoTracker/MkFitCore/src/MkFinder.h | 1 + RecoTracker/MkFitCore/src/MkFitter.h | 2 +- RecoTracker/MkFitCore/src/TrackStructures.cc | 253 +++++++ 10 files changed, 937 insertions(+), 913 deletions(-) create mode 100644 RecoTracker/MkFitCore/interface/TrackStructures.h create mode 100644 RecoTracker/MkFitCore/src/TrackStructures.cc diff --git a/RecoTracker/MkFitCore/interface/HitStructures.h b/RecoTracker/MkFitCore/interface/HitStructures.h index baff6eb13a1ed..4ae787e7138a0 100644 --- a/RecoTracker/MkFitCore/interface/HitStructures.h +++ b/RecoTracker/MkFitCore/interface/HitStructures.h @@ -3,7 +3,6 @@ #include "RecoTracker/MkFitCore/interface/Config.h" #include "RecoTracker/MkFitCore/interface/Hit.h" -#include "RecoTracker/MkFitCore/interface/Track.h" #include "RecoTracker/MkFitCore/interface/TrackerInfo.h" #include @@ -23,14 +22,6 @@ namespace mkfit { typedef std::vector vecvecPhiBinDead_t; - //============================================================================== - - inline bool sortHitsByPhiMT(const Hit& h1, const Hit& h2) { - return std::atan2(h1.position()[1], h1.position()[0]) < std::atan2(h2.position()[1], h2.position()[0]); - } - - inline bool sortTrksByPhiMT(const Track& t1, const Track& t2) { return t1.momPhi() < t2.momPhi(); } - //============================================================================== //============================================================================== @@ -237,643 +228,5 @@ namespace mkfit { BeamSpot m_beam_spot; }; - //============================================================================== - // TrackCand, CombinedCandidate and EventOfCombinedCandidates - //============================================================================== - - struct HoTNode { - HitOnTrack m_hot; - float m_chi2; - int m_prev_idx; - }; - - struct HitMatch { - int m_hit_idx = -1; - int m_module_id = -1; - float m_chi2 = 1e9; - - void reset() { - m_hit_idx = -1; - m_module_id = -1; - m_chi2 = 1e9; - } - }; - - struct HitMatchPair { - HitMatch M[2]; - - void reset() { - M[0].reset(); - M[1].reset(); - } - - void consider_hit_for_overlap(int hit_idx, int module_id, float chi2) { - if (module_id == M[0].m_module_id) { - if (chi2 < M[0].m_chi2) { - M[0].m_chi2 = chi2; - M[0].m_hit_idx = hit_idx; - } - } else if (module_id == M[1].m_module_id) { - if (chi2 < M[1].m_chi2) { - M[1].m_chi2 = chi2; - M[1].m_hit_idx = hit_idx; - } - } else { - if (M[0].m_chi2 > M[1].m_chi2) { - if (chi2 < M[0].m_chi2) { - M[0] = {hit_idx, module_id, chi2}; - } - } else { - if (chi2 < M[1].m_chi2) { - M[1] = {hit_idx, module_id, chi2}; - } - } - } - } - - HitMatch* find_overlap(int hit_idx, int module_id) { - if (module_id == M[0].m_module_id) { - if (M[1].m_hit_idx >= 0) - return &M[1]; - } else if (module_id == M[1].m_module_id) { - if (M[0].m_hit_idx >= 0) - return &M[0]; - } else { - if (M[0].m_chi2 <= M[1].m_chi2) { - if (M[0].m_hit_idx >= 0) - return &M[0]; - } else { - if (M[1].m_hit_idx >= 0) - return &M[1]; - } - } - - return nullptr; - } - }; - - // CcPool - CombCandidate Pool and Allocator - - template - class CcPool { - public: - void reset(std::size_t size) { - if (size > m_mem.size()) - m_mem.resize(size); - m_pos = 0; - m_size = size; - } - - void release() { - std::vector tmp; - m_mem.swap(tmp); - m_pos = 0; - m_size = 0; - } - - CcPool(std::size_t size = 0) { - if (size) - reset(size); - } - - T* allocate(std::size_t n) { - if (m_pos + n > m_size) - throw std::bad_alloc(); - T* ret = &m_mem[m_pos]; - m_pos += n; - return ret; - } - - void deallocate(T* p, std::size_t n) noexcept { - // we do not care, implied deallocation of the whole pool on reset(). - } - - private: - std::vector m_mem; - std::size_t m_pos = 0; - std::size_t m_size = 0; - }; - - template - class CcAlloc { - public: - typedef T value_type; - - CcAlloc(CcPool* p) : m_pool(p) {} - - const void* pool_id() const { return m_pool; } - - T* allocate(std::size_t n) { return m_pool->allocate(n); } - - void deallocate(T* p, std::size_t n) noexcept { m_pool->deallocate(p, n); } - - private: - CcPool* m_pool; - }; - - template - bool operator==(const CcAlloc& a, const CcAlloc& b) { - return a.pool_id() == b.pool_id(); - } - - //------------------------------------------------------------------------------ - - class CombCandidate; - - class TrackCand : public TrackBase { - public: - TrackCand() = default; - - explicit TrackCand(const TrackBase& base, CombCandidate* ccand) : TrackBase(base), m_comb_candidate(ccand) { - // Reset hit counters -- caller has to initialize hits. - lastHitIdx_ = -1; - nFoundHits_ = 0; - } - - // CombCandidate is used as a hit-container for a set of TrackCands originating from - // the same seed and track building functions need this access to be able to add hits - // into this holder class. - // Access is guaranteed to be thread safe as seed ranges pointing into CombCandidate - // vector is assigned to threads doing track-finding and final processing is only done - // when all worker threads have finished. - CombCandidate* combCandidate() const { return m_comb_candidate; } - void setCombCandidate(CombCandidate* cc) { m_comb_candidate = cc; } - - int lastCcIndex() const { return lastHitIdx_; } - int nFoundHits() const { return nFoundHits_; } - int nMissingHits() const { return nMissingHits_; } - int nOverlapHits() const { return nOverlapHits_; } - int nTotalHits() const { return nFoundHits_ + nMissingHits_; } - - void setLastCcIndex(int i) { lastHitIdx_ = i; } - void setNFoundHits(int n) { nFoundHits_ = n; } - void setNMissingHits(int n) { nMissingHits_ = n; } - void setNOverlapHits(int n) { nOverlapHits_ = n; } - - int nInsideMinusOneHits() const { return nInsideMinusOneHits_; } - int nTailMinusOneHits() const { return nTailMinusOneHits_; } - - void setNInsideMinusOneHits(int n) { nInsideMinusOneHits_ = n; } - void setNTailMinusOneHits(int n) { nTailMinusOneHits_ = n; } - - int originIndex() const { return m_origin_index; } - void setOriginIndex(int oi) { m_origin_index = oi; } - - void resetOverlaps() { m_overlap_hits.reset(); } - void considerHitForOverlap(int hit_idx, int module_id, float chi2) { - m_overlap_hits.consider_hit_for_overlap(hit_idx, module_id, chi2); - } - HitMatch* findOverlap(int hit_idx, int module_id) { return m_overlap_hits.find_overlap(hit_idx, module_id); } - - // Inlines after definition of CombCandidate - - HitOnTrack getLastHitOnTrack() const; - int getLastHitIdx() const; - int getLastHitLyr() const; - - // For additional filter - int getLastFoundPixelHitLyr() const; - int getLastFoundHitLyr() const; - int nUniqueLayers() const; - - int nLayersByTypeEncoded(const TrackerInfo& trk_inf) const; - int nHitsByTypeEncoded(const TrackerInfo& trk_inf) const; - - int nPixelDecoded(const int& encoded) const { return encoded % 100; } - int nStereoDecoded(const int& encoded) const { return (encoded / 100) % 100; } - int nMonoDecoded(const int& encoded) const { return (encoded / 10000) % 100; } - int nMatchedDecoded(const int& encoded) const { return encoded / 1000000; } - int nTotMatchDecoded(const int& encoded) const { - return encoded % 100 + (encoded / 100) % 100 + (encoded / 10000) % 100 - encoded / 1000000; - } - - void addHitIdx(int hitIdx, int hitLyr, float chi2); - - HoTNode& refLastHoTNode(); // for filling up overlap info - const HoTNode& refLastHoTNode() const; // for dump traversal - - void incOverlapCount() { ++nOverlapHits_; } - - Track exportTrack(bool remove_missing_hits = false) const; - - void resetShortTrack() { - score_ = getScoreWorstPossible(); - m_comb_candidate = nullptr; - } - - private: - CombCandidate* m_comb_candidate = nullptr; - HitMatchPair m_overlap_hits; - - // using TrackBase::lastHitIdx_ to point into hit-on-track-node vector of CombCandidate - short int nMissingHits_ = 0; - short int nOverlapHits_ = 0; - - short int nInsideMinusOneHits_ = 0; - short int nTailMinusOneHits_ = 0; - - short int m_origin_index = -1; // index of origin candidate (used for overlaps in Standard) - }; - - inline bool sortByScoreTrackCand(const TrackCand& cand1, const TrackCand& cand2) { - return cand1.score() > cand2.score(); - } - - inline float getScoreCand(const TrackCand& cand1, bool penalizeTailMissHits = false, bool inFindCandidates = false) { - int nfoundhits = cand1.nFoundHits(); - int noverlaphits = cand1.nOverlapHits(); - int nmisshits = cand1.nInsideMinusOneHits(); - int ntailmisshits = penalizeTailMissHits ? cand1.nTailMinusOneHits() : 0; - float pt = cand1.pT(); - float chi2 = cand1.chi2(); - // Do not allow for chi2<0 in score calculation - if (chi2 < 0) - chi2 = 0.f; - return getScoreCalc(nfoundhits, ntailmisshits, noverlaphits, nmisshits, chi2, pt, inFindCandidates); - } - - // CombCandidate -- a set of candidates from a given seed. - - class CombCandidate { - public: - using trk_cand_vec_type = std::vector>; - using allocator_type = CcAlloc; - - enum SeedState_e { Dormant = 0, Finding, Finished }; - - CombCandidate(const allocator_type& alloc) : m_trk_cands(alloc), m_state(Dormant), m_pickup_layer(-1) {} - - // Required by std::uninitialized_fill_n when declaring vector in EventOfCombCandidates - CombCandidate(const CombCandidate& o) - : m_trk_cands(o.m_trk_cands), - m_state(o.m_state), - m_pickup_layer(o.m_pickup_layer), - m_lastHitIdx_before_bkwsearch(o.m_lastHitIdx_before_bkwsearch), - m_nInsideMinusOneHits_before_bkwsearch(o.m_nInsideMinusOneHits_before_bkwsearch), - m_nTailMinusOneHits_before_bkwsearch(o.m_nTailMinusOneHits_before_bkwsearch), -#ifdef DUMPHITWINDOW - m_seed_algo(o.m_seed_algo), - m_seed_label(o.m_seed_label), -#endif - m_hots_size(o.m_hots_size), - m_hots(o.m_hots) { - } - - // Required for std::swap(). - CombCandidate(CombCandidate&& o) - : m_trk_cands(std::move(o.m_trk_cands)), - m_best_short_cand(std::move(o.m_best_short_cand)), - m_state(o.m_state), - m_pickup_layer(o.m_pickup_layer), - m_lastHitIdx_before_bkwsearch(o.m_lastHitIdx_before_bkwsearch), - m_nInsideMinusOneHits_before_bkwsearch(o.m_nInsideMinusOneHits_before_bkwsearch), - m_nTailMinusOneHits_before_bkwsearch(o.m_nTailMinusOneHits_before_bkwsearch), -#ifdef DUMPHITWINDOW - m_seed_algo(o.m_seed_algo), - m_seed_label(o.m_seed_label), -#endif - m_hots_size(o.m_hots_size), - m_hots(std::move(o.m_hots)) { - // This is not needed as we do EOCC::reset() after EOCCS::resize which - // calls Reset here and all CombCands get cleared. - // However, if at some point we start using this for other purposes this needs - // to be called as well. - // for (auto &tc : *this) tc.setCombCandidate(this); - } - - // Required for std::swap when filtering EventOfCombinedCandidates::m_candidates. - // We do not call clear() on vectors as this will be done via EoCCs reset. - // Probably would be better (clearer) if there was a special function that does - // the swap in here or in EoCCs. - CombCandidate& operator=(CombCandidate&& o) { - m_trk_cands = (std::move(o.m_trk_cands)); - m_best_short_cand = std::move(o.m_best_short_cand); - m_state = o.m_state; - m_pickup_layer = o.m_pickup_layer; - m_lastHitIdx_before_bkwsearch = o.m_lastHitIdx_before_bkwsearch; - m_nInsideMinusOneHits_before_bkwsearch = o.m_nInsideMinusOneHits_before_bkwsearch; - m_nTailMinusOneHits_before_bkwsearch = o.m_nTailMinusOneHits_before_bkwsearch; -#ifdef DUMPHITWINDOW - m_seed_algo = o.m_seed_algo; - m_seed_label = o.m_seed_label; -#endif - m_hots_size = o.m_hots_size; - m_hots = std::move(o.m_hots); - - for (auto& tc : m_trk_cands) - tc.setCombCandidate(this); - - return *this; - } - - // std::vector-like interface to access m_trk_cands - bool empty() const { return m_trk_cands.empty(); } - trk_cand_vec_type::size_type size() const { return m_trk_cands.size(); } - void resize(trk_cand_vec_type::size_type count) { m_trk_cands.resize(count); } - TrackCand& operator[](int i) { return m_trk_cands[i]; } - const TrackCand& operator[](int i) const { return m_trk_cands[i]; } - TrackCand& front() { return m_trk_cands.front(); } - const TrackCand& front() const { return m_trk_cands.front(); } - trk_cand_vec_type::reference emplace_back(TrackCand& tc) { return m_trk_cands.emplace_back(tc); } - void clear() { m_trk_cands.clear(); } - - void reset(int max_cands_per_seed, int expected_num_hots) { - std::vector> tmp(m_trk_cands.get_allocator()); - m_trk_cands.swap(tmp); - m_trk_cands.reserve(max_cands_per_seed); // we *must* never exceed this - - m_best_short_cand.setScore(getScoreWorstPossible()); - - // state and pickup_layer set in importSeed. - - // expected_num_hots is different for CloneEngine and Std, especially as long as we - // instantiate all candidates before purging them. - // ce: N_layer * N_cands ~~ 20 * 6 = 120 - // std: i don't know, maybe double? - m_hots.reserve(expected_num_hots); - m_hots_size = 0; - m_hots.clear(); - } - - void importSeed(const Track& seed, int region); - - int addHit(const HitOnTrack& hot, float chi2, int prev_idx) { - m_hots.push_back({hot, chi2, prev_idx}); - return m_hots_size++; - } - - void mergeCandsAndBestShortOne(const IterationParams& params, bool update_score, bool sort_cands); - - void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits); - void beginBkwSearch(); - void endBkwSearch(); - - // Accessors - //----------- - int hotsSize() const { return m_hots_size; } - const HoTNode& hot_node(int i) const { return m_hots[i]; } - HoTNode& hot_node_nc(int i) { return m_hots[i]; } - HitOnTrack hot(int i) const { return m_hots[i].m_hot; } - // Direct access into array for vectorized code in MkFinder - const HoTNode* hotsData() const { return m_hots.data(); } - - const TrackCand& refBestShortCand() const { return m_best_short_cand; } - void setBestShortCand(const TrackCand& tc) { m_best_short_cand = tc; } - - SeedState_e state() const { return m_state; } - void setState(SeedState_e ss) { m_state = ss; } - - int pickupLayer() const { return m_pickup_layer; } - -#ifdef DUMPHITWINDOW - int seed_algo() const { return m_seed_algo; } - int seed_label() const { return m_seed_label; } -#endif - - private: - trk_cand_vec_type m_trk_cands; - TrackCand m_best_short_cand; - SeedState_e m_state : 8; - int m_pickup_layer : 16; - short int m_lastHitIdx_before_bkwsearch = -1; - short int m_nInsideMinusOneHits_before_bkwsearch = -1; - short int m_nTailMinusOneHits_before_bkwsearch = -1; - -#ifdef DUMPHITWINDOW - int m_seed_algo = 0; - int m_seed_label = 0; -#endif - int m_hots_size = 0; - std::vector m_hots; - }; - - //============================================================================== - - inline HitOnTrack TrackCand::getLastHitOnTrack() const { return m_comb_candidate->hot(lastHitIdx_); } - - inline int TrackCand::getLastHitIdx() const { return m_comb_candidate->hot(lastHitIdx_).index; } - - inline int TrackCand::getLastHitLyr() const { return m_comb_candidate->hot(lastHitIdx_).layer; } - - inline int TrackCand::getLastFoundHitLyr() const { - int nh = nTotalHits(); - int ch = lastHitIdx_; - int ll = -1; - while (--nh >= 0) { - const HoTNode& hot_node = m_comb_candidate->hot_node(ch); - if (hot_node.m_hot.index < 0) { - ch = hot_node.m_prev_idx; - } else { - ll = hot_node.m_hot.layer; - break; - } - } - return ll; - } - - inline int TrackCand::getLastFoundPixelHitLyr() const { - int nh = nTotalHits(); - int ch = lastHitIdx_; - int ll = -1; - while (--nh >= 0) { - const HoTNode& hot_node = m_comb_candidate->hot_node(ch); - int tl = hot_node.m_hot.layer; - if (hot_node.m_hot.index < 0 || !((0 <= tl && tl <= 3) || (18 <= tl && tl <= 20) || (45 <= tl && tl <= 47))) { - ch = hot_node.m_prev_idx; - } else if ((0 <= tl && tl <= 3) || (18 <= tl && tl <= 20) || (45 <= tl && tl <= 47)) { - ll = hot_node.m_hot.layer; - break; - } - } - return ll; - } - - inline int TrackCand::nUniqueLayers() const { - int nUL = 0; - int prevL = -1; - int nh = nTotalHits(); - int ch = lastHitIdx_; - - while (--nh >= 0) { - const HoTNode& hot_node = m_comb_candidate->hot_node(ch); - int thisL = hot_node.m_hot.layer; - if (thisL >= 0 && (hot_node.m_hot.index >= 0 || hot_node.m_hot.index == -9) && thisL != prevL) { - ++nUL; - prevL = thisL; - } - ch = hot_node.m_prev_idx; - } - return nUL; - } - - inline int TrackCand::nHitsByTypeEncoded(const TrackerInfo& trk_inf) const { - int prevL = -1; - bool prevStereo = false; - int nh = nTotalHits(); - int ch = lastHitIdx_; - int pix = 0, stereo = 0, mono = 0, matched = 0; - int doubleStereo = -1; - while (--nh >= 0) { - const HoTNode& hot_node = m_comb_candidate->hot_node(ch); - int thisL = hot_node.m_hot.layer; - if (thisL >= 0 && (hot_node.m_hot.index >= 0 || hot_node.m_hot.index == -9)) { - if (trk_inf[thisL].is_pixel()) - ++pix; - else if (trk_inf[thisL].is_stereo()) { - ++stereo; - if (thisL == prevL) - doubleStereo = thisL; - } else { - //mono if not pixel, nor stereo - can be matched to stereo - ++mono; - if (prevStereo && thisL == prevL - 1) - ++matched; - else if (thisL == prevL && thisL == doubleStereo - 1) - ++matched; //doubleMatch, the first is counted early on - } - prevL = thisL; - prevStereo = stereo; - } - ch = hot_node.m_prev_idx; - } - return pix + 100 * stereo + 10000 * mono + 1000000 * matched; - } - - inline int TrackCand::nLayersByTypeEncoded(const TrackerInfo& trk_inf) const { - int prevL = -1; - bool prevStereo = false; - int nh = nTotalHits(); - int ch = lastHitIdx_; - int pix = 0, stereo = 0, mono = 0, matched = 0; - while (--nh >= 0) { - const HoTNode& hot_node = m_comb_candidate->hot_node(ch); - int thisL = hot_node.m_hot.layer; - if (thisL >= 0 && (hot_node.m_hot.index >= 0 || hot_node.m_hot.index == -9) && thisL != prevL) { - if (trk_inf[thisL].is_pixel()) - ++pix; - else if (trk_inf[thisL].is_stereo()) - ++stereo; - else { - //mono if not pixel, nor stereo - can be matched to stereo - ++mono; - if (prevStereo && thisL == prevL - 1) - ++matched; - } - prevL = thisL; - prevStereo = stereo; - } - ch = hot_node.m_prev_idx; - } - return pix + 100 * stereo + 10000 * mono + 1000000 * matched; - } - - inline HoTNode& TrackCand::refLastHoTNode() { return m_comb_candidate->hot_node_nc(lastHitIdx_); } - - inline const HoTNode& TrackCand::refLastHoTNode() const { return m_comb_candidate->hot_node(lastHitIdx_); } - - //------------------------------------------------------------------------------ - - inline void TrackCand::addHitIdx(int hitIdx, int hitLyr, float chi2) { - lastHitIdx_ = m_comb_candidate->addHit({hitIdx, hitLyr}, chi2, lastHitIdx_); - - if (hitIdx >= 0 || hitIdx == -9) { - ++nFoundHits_; - chi2_ += chi2; - nInsideMinusOneHits_ += nTailMinusOneHits_; - nTailMinusOneHits_ = 0; - } - //Note that for tracks passing through an inactive module (hitIdx = -7), we do not count the -7 hit against the track when scoring. - else { - ++nMissingHits_; - if (hitIdx == -1) - ++nTailMinusOneHits_; - } - } - - //============================================================================== - - class EventOfCombCandidates { - public: - EventOfCombCandidates(int size = 0) : m_cc_pool(), m_candidates() {} - - void releaseMemory() { - { // Get all the destructors called before nuking CcPool. - std::vector tmp; - m_candidates.swap(tmp); - } - m_capacity = 0; - m_size = 0; - m_n_seeds_inserted = 0; - m_cc_pool.release(); - } - - void reset(int new_capacity, int max_cands_per_seed, int expected_num_hots = 128) { - m_cc_pool.reset(new_capacity * max_cands_per_seed); - if (new_capacity > m_capacity) { - CcAlloc alloc(&m_cc_pool); - std::vector tmp(new_capacity, alloc); - m_candidates.swap(tmp); - m_capacity = new_capacity; - } - for (int s = 0; s < new_capacity; ++s) { - m_candidates[s].reset(max_cands_per_seed, expected_num_hots); - } - for (int s = new_capacity; s < m_capacity; ++s) { - m_candidates[s].reset(0, 0); - } - - m_size = new_capacity; - m_n_seeds_inserted = 0; - } - - void resizeAfterFiltering(int n_removed) { - assert(n_removed <= m_size); - m_size -= n_removed; - m_n_seeds_inserted -= n_removed; - } - - void insertSeed(const Track& seed, int region, int pos) { - assert(pos < m_size); - - m_candidates[pos].importSeed(seed, region); - - ++m_n_seeds_inserted; - } - - void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) { - for (int i = 0; i < m_size; ++i) - m_candidates[i].compactifyHitStorageForBestCand(remove_seed_hits, backward_fit_min_hits); - } - - void beginBkwSearch() { - for (int i = 0; i < m_size; ++i) - m_candidates[i].beginBkwSearch(); - } - void endBkwSearch() { - for (int i = 0; i < m_size; ++i) - m_candidates[i].endBkwSearch(); - } - - // Accessors - int size() const { return m_size; } - - const CombCandidate& operator[](int i) const { return m_candidates[i]; } - CombCandidate& operator[](int i) { return m_candidates[i]; } - CombCandidate& cand(int i) { return m_candidates[i]; } - - // Direct access for vectorized functions in MkBuilder / MkFinder - const std::vector& refCandidates() const { return m_candidates; } - std::vector& refCandidates_nc() { return m_candidates; } - - private: - CcPool m_cc_pool; - - std::vector m_candidates; - - int m_capacity = 0; - int m_size = 0; - int m_n_seeds_inserted = 0; - }; - } // end namespace mkfit #endif diff --git a/RecoTracker/MkFitCore/interface/MkBuilder.h b/RecoTracker/MkFitCore/interface/MkBuilder.h index c19d547cd7533..b55c15602c40a 100644 --- a/RecoTracker/MkFitCore/interface/MkBuilder.h +++ b/RecoTracker/MkFitCore/interface/MkBuilder.h @@ -2,8 +2,8 @@ #define RecoTracker_MkFitCore_interface_MkBuilder_h #include "RecoTracker/MkFitCore/interface/IterationConfig.h" -#include "RecoTracker/MkFitCore/interface/Track.h" #include "RecoTracker/MkFitCore/interface/HitStructures.h" +#include "RecoTracker/MkFitCore/interface/TrackStructures.h" #include #include @@ -68,25 +68,10 @@ namespace mkfit { static std::unique_ptr make_builder(bool silent = true); static void populate(); - int total_cands() const { - int res = 0; - for (int i = 0; i < m_event_of_comb_cands.size(); ++i) - res += m_event_of_comb_cands[i].size(); - return res; - } + int total_cands() const; + std::pair max_hits_layer(const EventOfHits &eoh) const; - std::pair max_hits_layer(const EventOfHits &eoh) const { - int maxN = 0; - int maxL = 0; - for (int l = 0; l < eoh.nLayers(); ++l) { - int lsize = eoh[l].nHits(); - if (lsize > maxN) { - maxN = lsize; - maxL = eoh[l].layer_id(); - } - } - return {maxN, maxL}; - } + // -------- void begin_event(MkJob *job, Event *ev, const char *build_type); void end_event(); diff --git a/RecoTracker/MkFitCore/interface/TrackStructures.h b/RecoTracker/MkFitCore/interface/TrackStructures.h new file mode 100644 index 0000000000000..ebb000d1dcd9a --- /dev/null +++ b/RecoTracker/MkFitCore/interface/TrackStructures.h @@ -0,0 +1,656 @@ +#ifndef RecoTracker_MkFitCore_interface_TrackStructures_h +#define RecoTracker_MkFitCore_interface_TrackStructures_h + +#include "RecoTracker/MkFitCore/interface/Config.h" +#include "RecoTracker/MkFitCore/interface/Hit.h" +#include "RecoTracker/MkFitCore/interface/Track.h" +#include "RecoTracker/MkFitCore/interface/TrackerInfo.h" + +#include +#include + +namespace mkfit { + + class IterationParams; + + //============================================================================== + // TrackCand, CombinedCandidate and EventOfCombinedCandidates + //============================================================================== + + struct HoTNode { + HitOnTrack m_hot; + float m_chi2; + int m_prev_idx; + }; + + struct HitMatch { + int m_hit_idx = -1; + int m_module_id = -1; + float m_chi2 = 1e9; + + void reset() { + m_hit_idx = -1; + m_module_id = -1; + m_chi2 = 1e9; + } + }; + + struct HitMatchPair { + HitMatch M[2]; + + void reset() { + M[0].reset(); + M[1].reset(); + } + + void consider_hit_for_overlap(int hit_idx, int module_id, float chi2) { + if (module_id == M[0].m_module_id) { + if (chi2 < M[0].m_chi2) { + M[0].m_chi2 = chi2; + M[0].m_hit_idx = hit_idx; + } + } else if (module_id == M[1].m_module_id) { + if (chi2 < M[1].m_chi2) { + M[1].m_chi2 = chi2; + M[1].m_hit_idx = hit_idx; + } + } else { + if (M[0].m_chi2 > M[1].m_chi2) { + if (chi2 < M[0].m_chi2) { + M[0] = {hit_idx, module_id, chi2}; + } + } else { + if (chi2 < M[1].m_chi2) { + M[1] = {hit_idx, module_id, chi2}; + } + } + } + } + + HitMatch* find_overlap(int hit_idx, int module_id) { + if (module_id == M[0].m_module_id) { + if (M[1].m_hit_idx >= 0) + return &M[1]; + } else if (module_id == M[1].m_module_id) { + if (M[0].m_hit_idx >= 0) + return &M[0]; + } else { + if (M[0].m_chi2 <= M[1].m_chi2) { + if (M[0].m_hit_idx >= 0) + return &M[0]; + } else { + if (M[1].m_hit_idx >= 0) + return &M[1]; + } + } + + return nullptr; + } + }; + + // CcPool - CombCandidate Pool and Allocator + + template + class CcPool { + public: + void reset(std::size_t size) { + if (size > m_mem.size()) + m_mem.resize(size); + m_pos = 0; + m_size = size; + } + + void release() { + std::vector tmp; + m_mem.swap(tmp); + m_pos = 0; + m_size = 0; + } + + CcPool(std::size_t size = 0) { + if (size) + reset(size); + } + + T* allocate(std::size_t n) { + if (m_pos + n > m_size) + throw std::bad_alloc(); + T* ret = &m_mem[m_pos]; + m_pos += n; + return ret; + } + + void deallocate(T* p, std::size_t n) noexcept { + // we do not care, implied deallocation of the whole pool on reset(). + } + + private: + std::vector m_mem; + std::size_t m_pos = 0; + std::size_t m_size = 0; + }; + + template + class CcAlloc { + public: + typedef T value_type; + + CcAlloc(CcPool* p) : m_pool(p) {} + + const void* pool_id() const { return m_pool; } + + T* allocate(std::size_t n) { return m_pool->allocate(n); } + + void deallocate(T* p, std::size_t n) noexcept { m_pool->deallocate(p, n); } + + private: + CcPool* m_pool; + }; + + template + bool operator==(const CcAlloc& a, const CcAlloc& b) { + return a.pool_id() == b.pool_id(); + } + + //------------------------------------------------------------------------------ + + class CombCandidate; + + class TrackCand : public TrackBase { + public: + TrackCand() = default; + + explicit TrackCand(const TrackBase& base, CombCandidate* ccand) : TrackBase(base), m_comb_candidate(ccand) { + // Reset hit counters -- caller has to initialize hits. + lastHitIdx_ = -1; + nFoundHits_ = 0; + } + + // CombCandidate is used as a hit-container for a set of TrackCands originating from + // the same seed and track building functions need this access to be able to add hits + // into this holder class. + // Access is guaranteed to be thread safe as seed ranges pointing into CombCandidate + // vector is assigned to threads doing track-finding and final processing is only done + // when all worker threads have finished. + CombCandidate* combCandidate() const { return m_comb_candidate; } + void setCombCandidate(CombCandidate* cc) { m_comb_candidate = cc; } + + int lastCcIndex() const { return lastHitIdx_; } + int nFoundHits() const { return nFoundHits_; } + int nMissingHits() const { return nMissingHits_; } + int nOverlapHits() const { return nOverlapHits_; } + int nTotalHits() const { return nFoundHits_ + nMissingHits_; } + + void setLastCcIndex(int i) { lastHitIdx_ = i; } + void setNFoundHits(int n) { nFoundHits_ = n; } + void setNMissingHits(int n) { nMissingHits_ = n; } + void setNOverlapHits(int n) { nOverlapHits_ = n; } + + int nInsideMinusOneHits() const { return nInsideMinusOneHits_; } + int nTailMinusOneHits() const { return nTailMinusOneHits_; } + + void setNInsideMinusOneHits(int n) { nInsideMinusOneHits_ = n; } + void setNTailMinusOneHits(int n) { nTailMinusOneHits_ = n; } + + int originIndex() const { return m_origin_index; } + void setOriginIndex(int oi) { m_origin_index = oi; } + + void resetOverlaps() { m_overlap_hits.reset(); } + void considerHitForOverlap(int hit_idx, int module_id, float chi2) { + m_overlap_hits.consider_hit_for_overlap(hit_idx, module_id, chi2); + } + HitMatch* findOverlap(int hit_idx, int module_id) { return m_overlap_hits.find_overlap(hit_idx, module_id); } + + // Inlines after definition of CombCandidate + + HitOnTrack getLastHitOnTrack() const; + int getLastHitIdx() const; + int getLastHitLyr() const; + + // For additional filter + int getLastFoundPixelHitLyr() const; + int getLastFoundHitLyr() const; + int nUniqueLayers() const; + + int nLayersByTypeEncoded(const TrackerInfo& trk_inf) const; + int nHitsByTypeEncoded(const TrackerInfo& trk_inf) const; + + int nPixelDecoded(const int& encoded) const { return encoded % 100; } + int nStereoDecoded(const int& encoded) const { return (encoded / 100) % 100; } + int nMonoDecoded(const int& encoded) const { return (encoded / 10000) % 100; } + int nMatchedDecoded(const int& encoded) const { return encoded / 1000000; } + int nTotMatchDecoded(const int& encoded) const { + return encoded % 100 + (encoded / 100) % 100 + (encoded / 10000) % 100 - encoded / 1000000; + } + + void addHitIdx(int hitIdx, int hitLyr, float chi2); + + HoTNode& refLastHoTNode(); // for filling up overlap info + const HoTNode& refLastHoTNode() const; // for dump traversal + + void incOverlapCount() { ++nOverlapHits_; } + + Track exportTrack(bool remove_missing_hits = false) const; + + void resetShortTrack() { + score_ = getScoreWorstPossible(); + m_comb_candidate = nullptr; + } + + private: + CombCandidate* m_comb_candidate = nullptr; + HitMatchPair m_overlap_hits; + + // using TrackBase::lastHitIdx_ to point into hit-on-track-node vector of CombCandidate + short int nMissingHits_ = 0; + short int nOverlapHits_ = 0; + + short int nInsideMinusOneHits_ = 0; + short int nTailMinusOneHits_ = 0; + + short int m_origin_index = -1; // index of origin candidate (used for overlaps in Standard) + }; + + inline bool sortByScoreTrackCand(const TrackCand& cand1, const TrackCand& cand2) { + return cand1.score() > cand2.score(); + } + + inline float getScoreCand(const TrackCand& cand1, bool penalizeTailMissHits = false, bool inFindCandidates = false) { + int nfoundhits = cand1.nFoundHits(); + int noverlaphits = cand1.nOverlapHits(); + int nmisshits = cand1.nInsideMinusOneHits(); + int ntailmisshits = penalizeTailMissHits ? cand1.nTailMinusOneHits() : 0; + float pt = cand1.pT(); + float chi2 = cand1.chi2(); + // Do not allow for chi2<0 in score calculation + if (chi2 < 0) + chi2 = 0.f; + return getScoreCalc(nfoundhits, ntailmisshits, noverlaphits, nmisshits, chi2, pt, inFindCandidates); + } + + // CombCandidate -- a set of candidates from a given seed. + + class CombCandidate { + public: + using trk_cand_vec_type = std::vector>; + using allocator_type = CcAlloc; + + enum SeedState_e { Dormant = 0, Finding, Finished }; + + CombCandidate(const allocator_type& alloc) : m_trk_cands(alloc), m_state(Dormant), m_pickup_layer(-1) {} + + // Required by std::uninitialized_fill_n when declaring vector in EventOfCombCandidates + CombCandidate(const CombCandidate& o) + : m_trk_cands(o.m_trk_cands), + m_state(o.m_state), + m_pickup_layer(o.m_pickup_layer), + m_lastHitIdx_before_bkwsearch(o.m_lastHitIdx_before_bkwsearch), + m_nInsideMinusOneHits_before_bkwsearch(o.m_nInsideMinusOneHits_before_bkwsearch), + m_nTailMinusOneHits_before_bkwsearch(o.m_nTailMinusOneHits_before_bkwsearch), +#ifdef DUMPHITWINDOW + m_seed_algo(o.m_seed_algo), + m_seed_label(o.m_seed_label), +#endif + m_hots_size(o.m_hots_size), + m_hots(o.m_hots) { + } + + // Required for std::swap(). + CombCandidate(CombCandidate&& o) + : m_trk_cands(std::move(o.m_trk_cands)), + m_best_short_cand(std::move(o.m_best_short_cand)), + m_state(o.m_state), + m_pickup_layer(o.m_pickup_layer), + m_lastHitIdx_before_bkwsearch(o.m_lastHitIdx_before_bkwsearch), + m_nInsideMinusOneHits_before_bkwsearch(o.m_nInsideMinusOneHits_before_bkwsearch), + m_nTailMinusOneHits_before_bkwsearch(o.m_nTailMinusOneHits_before_bkwsearch), +#ifdef DUMPHITWINDOW + m_seed_algo(o.m_seed_algo), + m_seed_label(o.m_seed_label), +#endif + m_hots_size(o.m_hots_size), + m_hots(std::move(o.m_hots)) { + // This is not needed as we do EOCC::reset() after EOCCS::resize which + // calls Reset here and all CombCands get cleared. + // However, if at some point we start using this for other purposes this needs + // to be called as well. + // for (auto &tc : *this) tc.setCombCandidate(this); + } + + // Required for std::swap when filtering EventOfCombinedCandidates::m_candidates. + // We do not call clear() on vectors as this will be done via EoCCs reset. + // Probably would be better (clearer) if there was a special function that does + // the swap in here or in EoCCs. + CombCandidate& operator=(CombCandidate&& o) { + m_trk_cands = (std::move(o.m_trk_cands)); + m_best_short_cand = std::move(o.m_best_short_cand); + m_state = o.m_state; + m_pickup_layer = o.m_pickup_layer; + m_lastHitIdx_before_bkwsearch = o.m_lastHitIdx_before_bkwsearch; + m_nInsideMinusOneHits_before_bkwsearch = o.m_nInsideMinusOneHits_before_bkwsearch; + m_nTailMinusOneHits_before_bkwsearch = o.m_nTailMinusOneHits_before_bkwsearch; +#ifdef DUMPHITWINDOW + m_seed_algo = o.m_seed_algo; + m_seed_label = o.m_seed_label; +#endif + m_hots_size = o.m_hots_size; + m_hots = std::move(o.m_hots); + + for (auto& tc : m_trk_cands) + tc.setCombCandidate(this); + + return *this; + } + + // std::vector-like interface to access m_trk_cands + bool empty() const { return m_trk_cands.empty(); } + trk_cand_vec_type::size_type size() const { return m_trk_cands.size(); } + void resize(trk_cand_vec_type::size_type count) { m_trk_cands.resize(count); } + TrackCand& operator[](int i) { return m_trk_cands[i]; } + const TrackCand& operator[](int i) const { return m_trk_cands[i]; } + TrackCand& front() { return m_trk_cands.front(); } + const TrackCand& front() const { return m_trk_cands.front(); } + trk_cand_vec_type::reference emplace_back(TrackCand& tc) { return m_trk_cands.emplace_back(tc); } + void clear() { m_trk_cands.clear(); } + + void reset(int max_cands_per_seed, int expected_num_hots) { + std::vector> tmp(m_trk_cands.get_allocator()); + m_trk_cands.swap(tmp); + m_trk_cands.reserve(max_cands_per_seed); // we *must* never exceed this + + m_best_short_cand.setScore(getScoreWorstPossible()); + + // state and pickup_layer set in importSeed. + + // expected_num_hots is different for CloneEngine and Std, especially as long as we + // instantiate all candidates before purging them. + // ce: N_layer * N_cands ~~ 20 * 6 = 120 + // std: i don't know, maybe double? + m_hots.reserve(expected_num_hots); + m_hots_size = 0; + m_hots.clear(); + } + + void importSeed(const Track& seed, int region); + + int addHit(const HitOnTrack& hot, float chi2, int prev_idx) { + m_hots.push_back({hot, chi2, prev_idx}); + return m_hots_size++; + } + + void mergeCandsAndBestShortOne(const IterationParams& params, bool update_score, bool sort_cands); + + void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits); + void beginBkwSearch(); + void endBkwSearch(); + + // Accessors + //----------- + int hotsSize() const { return m_hots_size; } + const HoTNode& hot_node(int i) const { return m_hots[i]; } + HoTNode& hot_node_nc(int i) { return m_hots[i]; } + HitOnTrack hot(int i) const { return m_hots[i].m_hot; } + // Direct access into array for vectorized code in MkFinder + const HoTNode* hotsData() const { return m_hots.data(); } + + const TrackCand& refBestShortCand() const { return m_best_short_cand; } + void setBestShortCand(const TrackCand& tc) { m_best_short_cand = tc; } + + SeedState_e state() const { return m_state; } + void setState(SeedState_e ss) { m_state = ss; } + + int pickupLayer() const { return m_pickup_layer; } + +#ifdef DUMPHITWINDOW + int seed_algo() const { return m_seed_algo; } + int seed_label() const { return m_seed_label; } +#endif + + private: + trk_cand_vec_type m_trk_cands; + TrackCand m_best_short_cand; + SeedState_e m_state : 8; + int m_pickup_layer : 16; + short int m_lastHitIdx_before_bkwsearch = -1; + short int m_nInsideMinusOneHits_before_bkwsearch = -1; + short int m_nTailMinusOneHits_before_bkwsearch = -1; + +#ifdef DUMPHITWINDOW + int m_seed_algo = 0; + int m_seed_label = 0; +#endif + int m_hots_size = 0; + std::vector m_hots; + }; + + //============================================================================== + + inline HitOnTrack TrackCand::getLastHitOnTrack() const { return m_comb_candidate->hot(lastHitIdx_); } + + inline int TrackCand::getLastHitIdx() const { return m_comb_candidate->hot(lastHitIdx_).index; } + + inline int TrackCand::getLastHitLyr() const { return m_comb_candidate->hot(lastHitIdx_).layer; } + + inline int TrackCand::getLastFoundHitLyr() const { + int nh = nTotalHits(); + int ch = lastHitIdx_; + int ll = -1; + while (--nh >= 0) { + const HoTNode& hot_node = m_comb_candidate->hot_node(ch); + if (hot_node.m_hot.index < 0) { + ch = hot_node.m_prev_idx; + } else { + ll = hot_node.m_hot.layer; + break; + } + } + return ll; + } + + inline int TrackCand::getLastFoundPixelHitLyr() const { + int nh = nTotalHits(); + int ch = lastHitIdx_; + int ll = -1; + while (--nh >= 0) { + const HoTNode& hot_node = m_comb_candidate->hot_node(ch); + int tl = hot_node.m_hot.layer; + if (hot_node.m_hot.index < 0 || !((0 <= tl && tl <= 3) || (18 <= tl && tl <= 20) || (45 <= tl && tl <= 47))) { + ch = hot_node.m_prev_idx; + } else if ((0 <= tl && tl <= 3) || (18 <= tl && tl <= 20) || (45 <= tl && tl <= 47)) { + ll = hot_node.m_hot.layer; + break; + } + } + return ll; + } + + inline int TrackCand::nUniqueLayers() const { + int nUL = 0; + int prevL = -1; + int nh = nTotalHits(); + int ch = lastHitIdx_; + + while (--nh >= 0) { + const HoTNode& hot_node = m_comb_candidate->hot_node(ch); + int thisL = hot_node.m_hot.layer; + if (thisL >= 0 && (hot_node.m_hot.index >= 0 || hot_node.m_hot.index == -9) && thisL != prevL) { + ++nUL; + prevL = thisL; + } + ch = hot_node.m_prev_idx; + } + return nUL; + } + + inline int TrackCand::nHitsByTypeEncoded(const TrackerInfo& trk_inf) const { + int prevL = -1; + bool prevStereo = false; + int nh = nTotalHits(); + int ch = lastHitIdx_; + int pix = 0, stereo = 0, mono = 0, matched = 0; + int doubleStereo = -1; + while (--nh >= 0) { + const HoTNode& hot_node = m_comb_candidate->hot_node(ch); + int thisL = hot_node.m_hot.layer; + if (thisL >= 0 && (hot_node.m_hot.index >= 0 || hot_node.m_hot.index == -9)) { + if (trk_inf[thisL].is_pixel()) + ++pix; + else if (trk_inf[thisL].is_stereo()) { + ++stereo; + if (thisL == prevL) + doubleStereo = thisL; + } else { + //mono if not pixel, nor stereo - can be matched to stereo + ++mono; + if (prevStereo && thisL == prevL - 1) + ++matched; + else if (thisL == prevL && thisL == doubleStereo - 1) + ++matched; //doubleMatch, the first is counted early on + } + prevL = thisL; + prevStereo = stereo; + } + ch = hot_node.m_prev_idx; + } + return pix + 100 * stereo + 10000 * mono + 1000000 * matched; + } + + inline int TrackCand::nLayersByTypeEncoded(const TrackerInfo& trk_inf) const { + int prevL = -1; + bool prevStereo = false; + int nh = nTotalHits(); + int ch = lastHitIdx_; + int pix = 0, stereo = 0, mono = 0, matched = 0; + while (--nh >= 0) { + const HoTNode& hot_node = m_comb_candidate->hot_node(ch); + int thisL = hot_node.m_hot.layer; + if (thisL >= 0 && (hot_node.m_hot.index >= 0 || hot_node.m_hot.index == -9) && thisL != prevL) { + if (trk_inf[thisL].is_pixel()) + ++pix; + else if (trk_inf[thisL].is_stereo()) + ++stereo; + else { + //mono if not pixel, nor stereo - can be matched to stereo + ++mono; + if (prevStereo && thisL == prevL - 1) + ++matched; + } + prevL = thisL; + prevStereo = stereo; + } + ch = hot_node.m_prev_idx; + } + return pix + 100 * stereo + 10000 * mono + 1000000 * matched; + } + + inline HoTNode& TrackCand::refLastHoTNode() { return m_comb_candidate->hot_node_nc(lastHitIdx_); } + + inline const HoTNode& TrackCand::refLastHoTNode() const { return m_comb_candidate->hot_node(lastHitIdx_); } + + //------------------------------------------------------------------------------ + + inline void TrackCand::addHitIdx(int hitIdx, int hitLyr, float chi2) { + lastHitIdx_ = m_comb_candidate->addHit({hitIdx, hitLyr}, chi2, lastHitIdx_); + + if (hitIdx >= 0 || hitIdx == -9) { + ++nFoundHits_; + chi2_ += chi2; + nInsideMinusOneHits_ += nTailMinusOneHits_; + nTailMinusOneHits_ = 0; + } + //Note that for tracks passing through an inactive module (hitIdx = -7), we do not count the -7 hit against the track when scoring. + else { + ++nMissingHits_; + if (hitIdx == -1) + ++nTailMinusOneHits_; + } + } + + //============================================================================== + + class EventOfCombCandidates { + public: + EventOfCombCandidates(int size = 0) : m_cc_pool(), m_candidates() {} + + void releaseMemory() { + { // Get all the destructors called before nuking CcPool. + std::vector tmp; + m_candidates.swap(tmp); + } + m_capacity = 0; + m_size = 0; + m_n_seeds_inserted = 0; + m_cc_pool.release(); + } + + void reset(int new_capacity, int max_cands_per_seed, int expected_num_hots = 128) { + m_cc_pool.reset(new_capacity * max_cands_per_seed); + if (new_capacity > m_capacity) { + CcAlloc alloc(&m_cc_pool); + std::vector tmp(new_capacity, alloc); + m_candidates.swap(tmp); + m_capacity = new_capacity; + } + for (int s = 0; s < new_capacity; ++s) { + m_candidates[s].reset(max_cands_per_seed, expected_num_hots); + } + for (int s = new_capacity; s < m_capacity; ++s) { + m_candidates[s].reset(0, 0); + } + + m_size = new_capacity; + m_n_seeds_inserted = 0; + } + + void resizeAfterFiltering(int n_removed) { + assert(n_removed <= m_size); + m_size -= n_removed; + m_n_seeds_inserted -= n_removed; + } + + void insertSeed(const Track& seed, int region, int pos) { + assert(pos < m_size); + + m_candidates[pos].importSeed(seed, region); + + ++m_n_seeds_inserted; + } + + void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) { + for (int i = 0; i < m_size; ++i) + m_candidates[i].compactifyHitStorageForBestCand(remove_seed_hits, backward_fit_min_hits); + } + + void beginBkwSearch() { + for (int i = 0; i < m_size; ++i) + m_candidates[i].beginBkwSearch(); + } + void endBkwSearch() { + for (int i = 0; i < m_size; ++i) + m_candidates[i].endBkwSearch(); + } + + // Accessors + int size() const { return m_size; } + + const CombCandidate& operator[](int i) const { return m_candidates[i]; } + CombCandidate& operator[](int i) { return m_candidates[i]; } + CombCandidate& cand(int i) { return m_candidates[i]; } + + // Direct access for vectorized functions in MkBuilder / MkFinder + const std::vector& refCandidates() const { return m_candidates; } + std::vector& refCandidates_nc() { return m_candidates; } + + private: + CcPool m_cc_pool; + + std::vector m_candidates; + + int m_capacity = 0; + int m_size = 0; + int m_n_seeds_inserted = 0; + }; + +} // namespace mkfit + +#endif diff --git a/RecoTracker/MkFitCore/src/CandCloner.cc b/RecoTracker/MkFitCore/src/CandCloner.cc index 3710bf87962f8..b450c1f964ed4 100644 --- a/RecoTracker/MkFitCore/src/CandCloner.cc +++ b/RecoTracker/MkFitCore/src/CandCloner.cc @@ -1,6 +1,5 @@ #include "CandCloner.h" -#include "RecoTracker/MkFitCore/interface/HitStructures.h" #include "RecoTracker/MkFitCore/interface/IterationConfig.h" //#define DEBUG diff --git a/RecoTracker/MkFitCore/src/HitStructures.cc b/RecoTracker/MkFitCore/src/HitStructures.cc index 7e401ac0bc37e..a830b39f4bfa0 100644 --- a/RecoTracker/MkFitCore/src/HitStructures.cc +++ b/RecoTracker/MkFitCore/src/HitStructures.cc @@ -378,247 +378,4 @@ namespace mkfit { } } - //============================================================================== - // TrackCand - //============================================================================== - - Track TrackCand::exportTrack(bool remove_missing_hits) const { - dprintf("TrackCand::exportTrack label=%5d, total_hits=%2d, overlaps=%2d -- n_seed_hits=%d,prod_type=%d\n", - label(), - nTotalHits(), - nOverlapHits_, - getNSeedHits(), - (int)prodType()); - - Track res(*this); - res.resizeHits(remove_missing_hits ? nFoundHits() : nTotalHits(), nFoundHits()); - res.setNOverlapHits(nOverlapHits()); - - int nh = nTotalHits(); - int ch = lastHitIdx_; - int good_hits_pos = nFoundHits(); - while (--nh >= 0) { - const HoTNode &hot_node = m_comb_candidate->hot_node(ch); - if (remove_missing_hits) { - if (hot_node.m_hot.index >= 0) - res.setHitIdxAtPos(--good_hits_pos, hot_node.m_hot); - } else { - res.setHitIdxAtPos(nh, hot_node.m_hot); - } - dprintf(" nh=%2d, ch=%d, idx=%d lyr=%d prev_idx=%d\n", - nh, - ch, - hot_node.m_hot.index, - hot_node.m_hot.layer, - hot_node.m_prev_idx); - ch = hot_node.m_prev_idx; - } - - return res; - } - - //============================================================================== - // CombCandidate - //============================================================================== - - void CombCandidate::importSeed(const Track &seed, int region) { - m_trk_cands.emplace_back(TrackCand(seed, this)); - - m_state = CombCandidate::Dormant; - m_pickup_layer = seed.getLastHitLyr(); -#ifdef DUMPHITWINDOW - m_seed_algo = seed.algoint(); - m_seed_label = seed.label(); -#endif - - TrackCand &cand = m_trk_cands.back(); - cand.setNSeedHits(seed.nTotalHits()); - cand.setEtaRegion(region); - - dprintf("Importing pt=%f eta=%f, lastCcIndex=%d\n", cand.pT(), cand.momEta(), cand.lastCcIndex()); - - for (const HitOnTrack *hp = seed.beginHitsOnTrack(); hp != seed.endHitsOnTrack(); ++hp) { - dprintf(" hit idx=%d lyr=%d\n", hp->index, hp->layer); - cand.addHitIdx(hp->index, hp->layer, 0.0f); - } - - cand.setScore(getScoreCand(cand)); - } - - void CombCandidate::mergeCandsAndBestShortOne(const IterationParams ¶ms, bool update_score, bool sort_cands) { - TrackCand *best_short = m_best_short_cand.combCandidate() ? &m_best_short_cand : nullptr; - - if (!empty()) { - if (update_score) { - for (auto &c : m_trk_cands) - c.setScore(getScoreCand(c)); - if (best_short) - best_short->setScore(getScoreCand(*best_short)); - } - if (sort_cands) { - std::sort(m_trk_cands.begin(), m_trk_cands.end(), sortByScoreTrackCand); - } - - if (best_short && best_short->score() > m_trk_cands.back().score()) { - auto ci = m_trk_cands.begin(); - while (ci->score() > best_short->score()) - ++ci; - - if ((int)m_trk_cands.size() >= params.maxCandsPerSeed) - m_trk_cands.pop_back(); - - // To print out what has been replaced -- remove when done with short track handling. -#ifdef DEBUG - if (ci == m_trk_cands.begin()) { - printf("FindTracksStd -- Replacing best cand (%f) with short one (%f) in final sorting\n", - m_trk_cands.front().score(), - best_short->score()); - } -#endif - - m_trk_cands.insert(ci, *best_short); - } - - } else if (best_short) { - m_trk_cands.push_back(*best_short); - } - - if (best_short) - best_short->resetShortTrack(); - - // assert(capacity() == (size_t)Config::maxCandsPerSeed); - } - - void CombCandidate::compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) { - // The best candidate is assumed to be in position 0 (after mergeCandsAndBestShortOne - // mergeCandsAndBestShortOne has been called). - // Other cands are dropped, their hits are dropped as well. - // Seed hits are dropped if remove_seed_hits is true. - - /* The following considerations are related to the following implementation: - minNrOfHitsForRebuild (checked against "nHits - nseed") has a default at 5, except - 1 in initialStep - 4 in tobTec and pixelLess - https://github.com/cms-sw/cmssw/blob/master/RecoTracker/CkfPattern/plugins/GroupedCkfTrajectoryBuilder.cc#L1015 - - NOTE: some of those can be matched hits !!! - - the hit splitting is triggered here: https://github.com/cms-sw/cmssw/blob/master/RecoTracker/CkfPattern/src/CkfTrackCandidateMakerBase.cc#L468 - after the rebuild has already happened: https://github.com/cms-sw/cmssw/blob/master/RecoTracker/CkfPattern/src/CkfTrackCandidateMakerBase.cc#L313 - */ - - assert(!m_trk_cands.empty()); - m_trk_cands.resize(1); - TrackCand &tc = m_trk_cands[0]; - - // Do NOT remove any seed hits if fewer than backward_fit_min_hits hits are available. - if (remove_seed_hits && tc.nFoundHits() <= backward_fit_min_hits) { - remove_seed_hits = false; - } - - // Stash HoTNodes at the end of m_hots. - int stash_end = m_hots.size(); - int stash_pos = stash_end; - - int idx = tc.lastCcIndex(); - - if (remove_seed_hits) { - // Skip invalid hits that would now be at the head of the candidate. - // Make sure to subtract / recount number of hits: - // as this is rather involved, just call addHitIdx() repeatedly so counts - // of holes get updated correctly. - // Though one should not care super much ... it's only relevant for relative scores - // and here we are trimming everything down to a single candidate. - - int n_hits_to_pick = std::max(tc.nFoundHits() - tc.getNSeedHits(), backward_fit_min_hits); - while (n_hits_to_pick > 0) { - m_hots[--stash_pos] = m_hots[idx]; - if (m_hots[idx].m_hot.index >= 0) - --n_hits_to_pick; - idx = m_hots[idx].m_prev_idx; - } - - m_hots_size = 0; - m_hots.clear(); - tc.setLastCcIndex(-1); - tc.setNFoundHits(0); - tc.setNMissingHits(0); - tc.setNInsideMinusOneHits(0); - tc.setNTailMinusOneHits(0); - while (stash_pos != stash_end && m_hots[stash_pos].m_hot.index < 0) - ++stash_pos; - while (stash_pos != stash_end) { - HoTNode &hn = m_hots[stash_pos]; - tc.addHitIdx(hn.m_hot.index, hn.m_hot.layer, hn.m_chi2); - ++stash_pos; - } - } else { - while (idx != -1) { - m_hots[--stash_pos] = m_hots[idx]; - idx = m_hots[idx].m_prev_idx; - } - - // If we are not removing seed_hits, track is good as it is, - // just fixup m_hots and t.lastCcIndex. - int pos = 0; - while (stash_pos != stash_end) { - m_hots[pos].m_hot = m_hots[stash_pos].m_hot; - m_hots[pos].m_chi2 = m_hots[stash_pos].m_chi2; - m_hots[pos].m_prev_idx = pos - 1; - ++pos; - ++stash_pos; - } - m_hots.resize(pos); - m_hots_size = pos; - tc.setLastCcIndex(pos - 1); - } - } - - void CombCandidate::beginBkwSearch() { - // Assumes compactifyHitStorageForBestCand() has already been called. - // - // This is to be called before backward-search to start with a single - // input candidate for backward combinatorial search. - // - // m_state and m_pickup_layer are also set. - - TrackCand &tc = m_trk_cands[0]; - - m_state = Dormant; - m_pickup_layer = m_hots[0].m_hot.layer; - m_lastHitIdx_before_bkwsearch = tc.lastCcIndex(); - m_nInsideMinusOneHits_before_bkwsearch = tc.nInsideMinusOneHits(); - m_nTailMinusOneHits_before_bkwsearch = tc.nTailMinusOneHits(); - tc.setLastCcIndex(0); - tc.setNInsideMinusOneHits(0); - tc.setNTailMinusOneHits(0); - } - - void CombCandidate::endBkwSearch() { - // mergeCandsAndBestShortOne() has already been called (from MkBuilder::FindXxx()). - // We have to fixup the best candidate. - - TrackCand &tc = m_trk_cands[0]; - - int curr_idx = tc.lastCcIndex(); - if (curr_idx != 0) { - int last_idx = -1, prev_idx; - do { - prev_idx = m_hots[curr_idx].m_prev_idx; - - m_hots[curr_idx].m_prev_idx = last_idx; - - last_idx = curr_idx; - curr_idx = prev_idx; - } while (prev_idx != -1); - } - - tc.setLastCcIndex(m_lastHitIdx_before_bkwsearch); - tc.setNInsideMinusOneHits(m_nInsideMinusOneHits_before_bkwsearch + tc.nInsideMinusOneHits()); - tc.setNTailMinusOneHits(m_nTailMinusOneHits_before_bkwsearch + tc.nTailMinusOneHits()); - m_lastHitIdx_before_bkwsearch = -1; - m_nInsideMinusOneHits_before_bkwsearch = -1; - m_nTailMinusOneHits_before_bkwsearch = -1; - } - } // end namespace mkfit diff --git a/RecoTracker/MkFitCore/src/MkBuilder.cc b/RecoTracker/MkFitCore/src/MkBuilder.cc index af20795b255b1..aa011ceefad61 100644 --- a/RecoTracker/MkFitCore/src/MkBuilder.cc +++ b/RecoTracker/MkFitCore/src/MkBuilder.cc @@ -169,6 +169,26 @@ namespace mkfit { void MkBuilder::populate() { g_exe_ctx.populate(Config::numThreadsFinder); } + std::pair MkBuilder::max_hits_layer(const EventOfHits &eoh) const { + int maxN = 0; + int maxL = 0; + for (int l = 0; l < eoh.nLayers(); ++l) { + int lsize = eoh[l].nHits(); + if (lsize > maxN) { + maxN = lsize; + maxL = eoh[l].layer_id(); + } + } + return {maxN, maxL}; + } + + int MkBuilder::total_cands() const { + int res = 0; + for (int i = 0; i < m_event_of_comb_cands.size(); ++i) + res += m_event_of_comb_cands[i].size(); + return res; + } + //------------------------------------------------------------------------------ // Common functions //------------------------------------------------------------------------------ @@ -217,7 +237,8 @@ namespace mkfit { IterationSeedPartition part(size); std::vector ranks; if (!seeds_sorted) { - axis_pow2_u1 ax_phi(-Const::PI, Const::PI); + // We don't care about bins in phi, use low N to reduce overall number of bins. + axis_pow2_u1 ax_phi(-Const::PI, Const::PI); axis ax_eta(-3.0, 3.0, 64u); binnor phi_eta_binnor(ax_phi, ax_eta); part.m_phi_eta_foo = [&](float phi, float eta) { phi_eta_binnor.register_entry_safe(phi, eta); }; diff --git a/RecoTracker/MkFitCore/src/MkFinder.cc b/RecoTracker/MkFitCore/src/MkFinder.cc index b4f833298a9b3..3f9df7f203345 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.cc +++ b/RecoTracker/MkFitCore/src/MkFinder.cc @@ -1,7 +1,6 @@ #include "MkFinder.h" #include "CandCloner.h" -#include "RecoTracker/MkFitCore/interface/HitStructures.h" #include "RecoTracker/MkFitCore/interface/IterationConfig.h" #include "FindingFoos.h" diff --git a/RecoTracker/MkFitCore/src/MkFinder.h b/RecoTracker/MkFitCore/src/MkFinder.h index addfa067e8f3c..d77970da3771b 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.h +++ b/RecoTracker/MkFitCore/src/MkFinder.h @@ -6,6 +6,7 @@ #include "RecoTracker/MkFitCore/interface/Track.h" #include "RecoTracker/MkFitCore/interface/HitStructures.h" +#include "RecoTracker/MkFitCore/interface/TrackStructures.h" // Define to get printouts about track and hit chi2. // See also MkBuilder::backwardFit(). diff --git a/RecoTracker/MkFitCore/src/MkFitter.h b/RecoTracker/MkFitCore/src/MkFitter.h index 19bed8937ada7..41b2d4cb0fa2b 100644 --- a/RecoTracker/MkFitCore/src/MkFitter.h +++ b/RecoTracker/MkFitCore/src/MkFitter.h @@ -2,7 +2,7 @@ #define RecoTracker_MkFitCore_src_MkFitter_h #include "MkBase.h" - +#include "RecoTracker/MkFitCore/interface/Track.h" #include "RecoTracker/MkFitCore/interface/HitStructures.h" namespace mkfit { diff --git a/RecoTracker/MkFitCore/src/TrackStructures.cc b/RecoTracker/MkFitCore/src/TrackStructures.cc new file mode 100644 index 0000000000000..8feccd9dd6a2a --- /dev/null +++ b/RecoTracker/MkFitCore/src/TrackStructures.cc @@ -0,0 +1,253 @@ +#include "RecoTracker/MkFitCore/interface/TrackStructures.h" + +#include "RecoTracker/MkFitCore/interface/IterationConfig.h" +#include "Matriplex/Memory.h" + +#include "Debug.h" + +namespace mkfit { + + //============================================================================== + // TrackCand + //============================================================================== + + Track TrackCand::exportTrack(bool remove_missing_hits) const { + dprintf("TrackCand::exportTrack label=%5d, total_hits=%2d, overlaps=%2d -- n_seed_hits=%d,prod_type=%d\n", + label(), + nTotalHits(), + nOverlapHits_, + getNSeedHits(), + (int)prodType()); + + Track res(*this); + res.resizeHits(remove_missing_hits ? nFoundHits() : nTotalHits(), nFoundHits()); + res.setNOverlapHits(nOverlapHits()); + + int nh = nTotalHits(); + int ch = lastHitIdx_; + int good_hits_pos = nFoundHits(); + while (--nh >= 0) { + const HoTNode &hot_node = m_comb_candidate->hot_node(ch); + if (remove_missing_hits) { + if (hot_node.m_hot.index >= 0) + res.setHitIdxAtPos(--good_hits_pos, hot_node.m_hot); + } else { + res.setHitIdxAtPos(nh, hot_node.m_hot); + } + dprintf(" nh=%2d, ch=%d, idx=%d lyr=%d prev_idx=%d\n", + nh, + ch, + hot_node.m_hot.index, + hot_node.m_hot.layer, + hot_node.m_prev_idx); + ch = hot_node.m_prev_idx; + } + + return res; + } + + //============================================================================== + // CombCandidate + //============================================================================== + + void CombCandidate::importSeed(const Track &seed, int region) { + m_trk_cands.emplace_back(TrackCand(seed, this)); + + m_state = CombCandidate::Dormant; + m_pickup_layer = seed.getLastHitLyr(); +#ifdef DUMPHITWINDOW + m_seed_algo = seed.algoint(); + m_seed_label = seed.label(); +#endif + + TrackCand &cand = m_trk_cands.back(); + cand.setNSeedHits(seed.nTotalHits()); + cand.setEtaRegion(region); + + dprintf("Importing pt=%f eta=%f, lastCcIndex=%d\n", cand.pT(), cand.momEta(), cand.lastCcIndex()); + + for (const HitOnTrack *hp = seed.beginHitsOnTrack(); hp != seed.endHitsOnTrack(); ++hp) { + dprintf(" hit idx=%d lyr=%d\n", hp->index, hp->layer); + cand.addHitIdx(hp->index, hp->layer, 0.0f); + } + + cand.setScore(getScoreCand(cand)); + } + + void CombCandidate::mergeCandsAndBestShortOne(const IterationParams ¶ms, bool update_score, bool sort_cands) { + TrackCand *best_short = m_best_short_cand.combCandidate() ? &m_best_short_cand : nullptr; + + if (!empty()) { + if (update_score) { + for (auto &c : m_trk_cands) + c.setScore(getScoreCand(c)); + if (best_short) + best_short->setScore(getScoreCand(*best_short)); + } + if (sort_cands) { + std::sort(m_trk_cands.begin(), m_trk_cands.end(), sortByScoreTrackCand); + } + + if (best_short && best_short->score() > m_trk_cands.back().score()) { + auto ci = m_trk_cands.begin(); + while (ci->score() > best_short->score()) + ++ci; + + if ((int)m_trk_cands.size() >= params.maxCandsPerSeed) + m_trk_cands.pop_back(); + + // To print out what has been replaced -- remove when done with short track handling. +#ifdef DEBUG + if (ci == m_trk_cands.begin()) { + printf("FindTracksStd -- Replacing best cand (%f) with short one (%f) in final sorting\n", + m_trk_cands.front().score(), + best_short->score()); + } +#endif + + m_trk_cands.insert(ci, *best_short); + } + + } else if (best_short) { + m_trk_cands.push_back(*best_short); + } + + if (best_short) + best_short->resetShortTrack(); + + // assert(capacity() == (size_t)Config::maxCandsPerSeed); + } + + void CombCandidate::compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) { + // The best candidate is assumed to be in position 0 (after mergeCandsAndBestShortOne + // mergeCandsAndBestShortOne has been called). + // Other cands are dropped, their hits are dropped as well. + // Seed hits are dropped if remove_seed_hits is true. + + /* The following considerations are related to the following implementation: + minNrOfHitsForRebuild (checked against "nHits - nseed") has a default at 5, except + 1 in initialStep + 4 in tobTec and pixelLess + https://github.com/cms-sw/cmssw/blob/master/RecoTracker/CkfPattern/plugins/GroupedCkfTrajectoryBuilder.cc#L1015 + + NOTE: some of those can be matched hits !!! + + the hit splitting is triggered here: https://github.com/cms-sw/cmssw/blob/master/RecoTracker/CkfPattern/src/CkfTrackCandidateMakerBase.cc#L468 + after the rebuild has already happened: https://github.com/cms-sw/cmssw/blob/master/RecoTracker/CkfPattern/src/CkfTrackCandidateMakerBase.cc#L313 + */ + + assert(!m_trk_cands.empty()); + m_trk_cands.resize(1); + TrackCand &tc = m_trk_cands[0]; + + // Do NOT remove any seed hits if fewer than backward_fit_min_hits hits are available. + if (remove_seed_hits && tc.nFoundHits() <= backward_fit_min_hits) { + remove_seed_hits = false; + } + + // Stash HoTNodes at the end of m_hots. + int stash_end = m_hots.size(); + int stash_pos = stash_end; + + int idx = tc.lastCcIndex(); + + if (remove_seed_hits) { + // Skip invalid hits that would now be at the head of the candidate. + // Make sure to subtract / recount number of hits: + // as this is rather involved, just call addHitIdx() repeatedly so counts + // of holes get updated correctly. + // Though one should not care super much ... it's only relevant for relative scores + // and here we are trimming everything down to a single candidate. + + int n_hits_to_pick = std::max(tc.nFoundHits() - tc.getNSeedHits(), backward_fit_min_hits); + while (n_hits_to_pick > 0) { + m_hots[--stash_pos] = m_hots[idx]; + if (m_hots[idx].m_hot.index >= 0) + --n_hits_to_pick; + idx = m_hots[idx].m_prev_idx; + } + + m_hots_size = 0; + m_hots.clear(); + tc.setLastCcIndex(-1); + tc.setNFoundHits(0); + tc.setNMissingHits(0); + tc.setNInsideMinusOneHits(0); + tc.setNTailMinusOneHits(0); + while (stash_pos != stash_end && m_hots[stash_pos].m_hot.index < 0) + ++stash_pos; + while (stash_pos != stash_end) { + HoTNode &hn = m_hots[stash_pos]; + tc.addHitIdx(hn.m_hot.index, hn.m_hot.layer, hn.m_chi2); + ++stash_pos; + } + } else { + while (idx != -1) { + m_hots[--stash_pos] = m_hots[idx]; + idx = m_hots[idx].m_prev_idx; + } + + // If we are not removing seed_hits, track is good as it is, + // just fixup m_hots and t.lastCcIndex. + int pos = 0; + while (stash_pos != stash_end) { + m_hots[pos].m_hot = m_hots[stash_pos].m_hot; + m_hots[pos].m_chi2 = m_hots[stash_pos].m_chi2; + m_hots[pos].m_prev_idx = pos - 1; + ++pos; + ++stash_pos; + } + m_hots.resize(pos); + m_hots_size = pos; + tc.setLastCcIndex(pos - 1); + } + } + + void CombCandidate::beginBkwSearch() { + // Assumes compactifyHitStorageForBestCand() has already been called. + // + // This is to be called before backward-search to start with a single + // input candidate for backward combinatorial search. + // + // m_state and m_pickup_layer are also set. + + TrackCand &tc = m_trk_cands[0]; + + m_state = Dormant; + m_pickup_layer = m_hots[0].m_hot.layer; + m_lastHitIdx_before_bkwsearch = tc.lastCcIndex(); + m_nInsideMinusOneHits_before_bkwsearch = tc.nInsideMinusOneHits(); + m_nTailMinusOneHits_before_bkwsearch = tc.nTailMinusOneHits(); + tc.setLastCcIndex(0); + tc.setNInsideMinusOneHits(0); + tc.setNTailMinusOneHits(0); + } + + void CombCandidate::endBkwSearch() { + // mergeCandsAndBestShortOne() has already been called (from MkBuilder::FindXxx()). + // We have to fixup the best candidate. + + TrackCand &tc = m_trk_cands[0]; + + int curr_idx = tc.lastCcIndex(); + if (curr_idx != 0) { + int last_idx = -1, prev_idx; + do { + prev_idx = m_hots[curr_idx].m_prev_idx; + + m_hots[curr_idx].m_prev_idx = last_idx; + + last_idx = curr_idx; + curr_idx = prev_idx; + } while (prev_idx != -1); + } + + tc.setLastCcIndex(m_lastHitIdx_before_bkwsearch); + tc.setNInsideMinusOneHits(m_nInsideMinusOneHits_before_bkwsearch + tc.nInsideMinusOneHits()); + tc.setNTailMinusOneHits(m_nTailMinusOneHits_before_bkwsearch + tc.nTailMinusOneHits()); + m_lastHitIdx_before_bkwsearch = -1; + m_nInsideMinusOneHits_before_bkwsearch = -1; + m_nTailMinusOneHits_before_bkwsearch = -1; + } + +} // namespace mkfit From 33daf8260f573acf86f5e17fed133a1378dab69d Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 8 Apr 2022 23:57:16 -0700 Subject: [PATCH 05/57] Use binnor with radix_sort in LayerOfHits. Use single std::vector for storing dead-bin information. Remove MkFitCore/src/Ice/ directory. --- .../MkFit/plugins/MkFitEventOfHitsProducer.cc | 2 +- RecoTracker/MkFitCore/BuildFile.xml | 2 +- .../MkFitCore/interface/HitStructures.h | 136 ++--- RecoTracker/MkFitCore/interface/binnor.h | 25 +- RecoTracker/MkFitCore/src/HitStructures.cc | 287 +++------ RecoTracker/MkFitCore/src/Ice/IceFPU.h | 278 --------- .../MkFitCore/src/Ice/IceMemoryMacros.h | 123 ---- .../MkFitCore/src/Ice/IcePreprocessor.h | 23 - .../MkFitCore/src/Ice/IceRevisitedRadix.cc | 547 ------------------ .../MkFitCore/src/Ice/IceRevisitedRadix.h | 73 --- RecoTracker/MkFitCore/src/Ice/IceTypes.h | 119 ---- RecoTracker/MkFitCore/src/MkFinder.cc | 37 +- 12 files changed, 171 insertions(+), 1481 deletions(-) delete mode 100644 RecoTracker/MkFitCore/src/Ice/IceFPU.h delete mode 100644 RecoTracker/MkFitCore/src/Ice/IceMemoryMacros.h delete mode 100644 RecoTracker/MkFitCore/src/Ice/IcePreprocessor.h delete mode 100644 RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.cc delete mode 100644 RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.h delete mode 100644 RecoTracker/MkFitCore/src/Ice/IceTypes.h diff --git a/RecoTracker/MkFit/plugins/MkFitEventOfHitsProducer.cc b/RecoTracker/MkFit/plugins/MkFitEventOfHitsProducer.cc index e3b800314a2a0..ff84b405b70dc 100644 --- a/RecoTracker/MkFit/plugins/MkFitEventOfHitsProducer.cc +++ b/RecoTracker/MkFit/plugins/MkFitEventOfHitsProducer.cc @@ -186,7 +186,7 @@ void MkFitEventOfHitsProducer::produce(edm::StreamID iID, edm::Event& iEvent, co void MkFitEventOfHitsProducer::fill(const std::vector& hits, mkfit::EventOfHits& eventOfHits, const MkFitGeometry& mkFitGeom) const { - for (int i = 0, end = hits.size(); i < end; ++i) { + for (unsigned int i = 0, end = hits.size(); i < end; ++i) { const auto* hit = hits[i]; if (hit != nullptr) { const auto ilay = mkFitGeom.mkFitLayerNumber(hit->geographicalId()); diff --git a/RecoTracker/MkFitCore/BuildFile.xml b/RecoTracker/MkFitCore/BuildFile.xml index e3ad879ac23c2..7ccecdb78f361 100644 --- a/RecoTracker/MkFitCore/BuildFile.xml +++ b/RecoTracker/MkFitCore/BuildFile.xml @@ -1,7 +1,7 @@ - + diff --git a/RecoTracker/MkFitCore/interface/HitStructures.h b/RecoTracker/MkFitCore/interface/HitStructures.h index 4ae787e7138a0..6f63d90c589b2 100644 --- a/RecoTracker/MkFitCore/interface/HitStructures.h +++ b/RecoTracker/MkFitCore/interface/HitStructures.h @@ -4,44 +4,53 @@ #include "RecoTracker/MkFitCore/interface/Config.h" #include "RecoTracker/MkFitCore/interface/Hit.h" #include "RecoTracker/MkFitCore/interface/TrackerInfo.h" - -#include -#include +#include "RecoTracker/MkFitCore/interface/binnor.h" namespace mkfit { class IterationParams; - typedef std::pair PhiBinInfo_t; - - typedef std::array vecPhiBinInfo_t; - - typedef std::vector vecvecPhiBinInfo_t; - - typedef std::array vecPhiBinDead_t; - - typedef std::vector vecvecPhiBinDead_t; - //============================================================================== + // LayerOfHits //============================================================================== // Note: the same code is used for barrel and endcap. In barrel the longitudinal - // bins are in Z and in endcap they are in R -- here this coordinate is called Q + // bins are in Z and in endcap they are in R -- here this coordinate is called Q. - // When not defined, hits are accessed from the original hit vector and - // only sort ranks are kept for proper access. - // - //#define COPY_SORTED_HITS + // When COPY_SORTED_HITS is not defined, hits are accessed from the original hit + // vector and only sort ranks are kept for proper access. + // #define COPY_SORTED_HITS class LayerOfHits { public: - LayerOfHits() = default; + using bin_index_t = unsigned short; + using bin_content_t = unsigned int; + using axis_phi_t = axis_pow2_u1; + using axis_eta_t = axis; + using binnor_t = binnor; + + // Initializator + + struct Initializator { + const LayerInfo& m_linfo; + float m_qmin, m_qmax; + unsigned int m_nq; + + void setup(float qmin, float qmax, float dq); + + Initializator(const LayerInfo& li, float qmin, float qmax, unsigned int nq); + Initializator(const LayerInfo& li, float qmin, float qmax, float dq); + Initializator(const LayerInfo& li); + }; + + // Constructor + + LayerOfHits(const LayerOfHits::Initializator& i); ~LayerOfHits(); // Setup and filling //------------------- - void setupLayer(const LayerInfo& li); void reset() {} @@ -53,39 +62,33 @@ namespace mkfit { // Use external hit-vec and only use hits that are passed to me. void beginRegistrationOfHits(const HitVec& hitv); - void registerHit(int idx); + void registerHit(unsigned int idx); void endRegistrationOfHits(bool build_original_to_internal_map); - int nHits() const { return m_n_hits; } + unsigned int nHits() const { return m_n_hits; } // Bin access / queries //---------------------- - int qBin(float q) const { return (q - m_qmin) * m_fq; } - - int qBinChecked(float q) const { return std::clamp(qBin(q), 0, m_nq - 1); } + bin_index_t qBin(float q) const { return m_ax_eta.from_R_to_N_bin(q); } + bin_index_t qBinChecked(float q) const { return m_ax_eta.from_R_to_N_bin_safe(q); } // if you don't pass phi in (-pi, +pi), mask away the upper bits using m_phi_mask or use the Checked version. - int phiBinFine(float phi) const { return std::floor(m_fphi_fine * (phi + Const::PI)); } - int phiBin(float phi) const { return phiBinFine(phi) >> m_phi_bits_shift; } + bin_index_t phiBin(float phi) const { return m_ax_phi.from_R_to_N_bin(phi); } + bin_index_t phiBinChecked(float phi) const { return m_ax_phi.from_R_to_N_bin_safe(phi); } - int phiBinChecked(float phi) const { return phiBin(phi) & m_phi_mask; } + bin_index_t phiMaskApply(bin_index_t in) const { return in & m_ax_phi.c_N_mask; } - int phiMaskApply(int in) const { return in & m_phi_mask; } + binnor_t::C_pair phiQBinContent(bin_index_t pi, bin_index_t qi) const { return m_binnor.get_content(pi, qi); } - const vecPhiBinInfo_t& vecPhiBinInfo(float q) const { return m_phi_bin_infos[qBin(q)]; } + bool isBinDead(bin_index_t pi, bin_index_t qi) const { return m_dead_bins[qi * m_ax_phi.size_of_N() + pi]; } - const vecvecPhiBinInfo_t& phi_bin_infos() const { return m_phi_bin_infos; } - const vecvecPhiBinDead_t& phi_bin_deads() const { return m_phi_bin_deads; } - PhiBinInfo_t phi_bin_info(int qi, int pi) const { return m_phi_bin_infos[qi][pi]; } - bool phi_bin_dead(int qi, int pi) const { return m_phi_bin_deads[qi][pi]; } - - float hit_q(int i) const { return m_hit_qs[i]; } - float hit_phi(int i) const { return m_hit_phis[i]; } + float hit_q(unsigned int i) const { return m_hit_qs[i]; } + float hit_phi(unsigned int i) const { return m_hit_phis[i]; } // Use this to map original indices to sorted internal ones. m_ext_idcs needs to be initialized. - int getHitIndexFromOriginal(int i) const { return m_ext_idcs[i - m_min_ext_idx]; } + unsigned int getHitIndexFromOriginal(unsigned int i) const { return m_ext_idcs[i - m_min_ext_idx]; } // Use this to remap internal hit index to external one. - int getOriginalHitIndex(int i) const { return m_hit_ranks[i]; } + unsigned int getOriginalHitIndex(unsigned int i) const { return m_binnor.m_ranks[i]; } #ifdef COPY_SORTED_HITS const Hit& refHit(int i) const { return m_hits[i]; } @@ -95,9 +98,6 @@ namespace mkfit { const Hit* hitArray() const { return m_ext_hits->data(); } #endif - // Left to document and demonstrate access to bin-info structures. - // void selectHitIndices(float q, float phi, float dq, float dphi, std::vector& idcs, bool isForSeeding=false, bool dump=false); - void printBins(); // Geometry / LayerInfo accessors @@ -125,41 +125,9 @@ namespace mkfit { int subdet() const { return m_layer_info->subdet(); } private: - // Constants for phi-bin access / index manipulation. - static constexpr float m_fphi = Config::m_nphi / Const::TwoPI; - static constexpr int m_phi_mask = 0xff; - static constexpr int m_phi_bits = 8; - static constexpr float m_fphi_fine = 1024 / Const::TwoPI; - static constexpr int m_phi_mask_fine = 0x3ff; - static constexpr int m_phi_bits_fine = 10; //can't be more than 16 - static constexpr int m_phi_bits_shift = m_phi_bits_fine - m_phi_bits; - static constexpr int m_phi_fine_xmask = ~((1 << m_phi_bits_shift) - 1); - - void setup_bins(float qmin, float qmax, float dq); - - void empty_phi_bins(int q_bin, int phi_bin_1, int phi_bin_2, uint16_t hit_count) { - for (int pb = phi_bin_1; pb < phi_bin_2; ++pb) { - m_phi_bin_infos[q_bin][pb] = {hit_count, hit_count}; - } - } - - void empty_q_bins(int q_bin_1, int q_bin_2, uint16_t hit_count) { - for (int qb = q_bin_1; qb < q_bin_2; ++qb) { - empty_phi_bins(qb, 0, Config::m_nphi, hit_count); - } - } - - void empty_phi_bins_dead(int q_bin, int phi_bin_1, int phi_bin_2) { - for (int pb = phi_bin_1; pb < phi_bin_2; ++pb) { - m_phi_bin_deads[q_bin][pb] = false; - } - } - - void empty_q_bins_dead(int q_bin_1, int q_bin_2) { - for (int qb = q_bin_1; qb < q_bin_2; ++qb) { - empty_phi_bins_dead(qb, 0, Config::m_nphi); - } - } + axis_phi_t m_ax_phi; + axis_eta_t m_ax_eta; + binnor_t m_binnor; #ifdef COPY_SORTED_HITS void alloc_hits(int size); @@ -171,13 +139,12 @@ namespace mkfit { const HitVec* m_ext_hits; #endif unsigned int* m_hit_ranks = nullptr; // allocated by IceSort via new [] - std::vector m_ext_idcs; - int m_min_ext_idx, m_max_ext_idx; - int m_n_hits = 0; + std::vector m_ext_idcs; + unsigned int m_min_ext_idx, m_max_ext_idx; + unsigned int m_n_hits = 0; - // Bin information for hits and dead regions - vecvecPhiBinInfo_t m_phi_bin_infos; - vecvecPhiBinDead_t m_phi_bin_deads; + // Bin information for dead regions + std::vector m_dead_bins; // Cached hit phi and q values to minimize Hit memory access std::vector m_hit_phis; @@ -185,8 +152,6 @@ namespace mkfit { // Geometry / q-binning constants - initialized in setupLayer() const LayerInfo* m_layer_info = nullptr; - float m_qmin, m_qmax, m_fq; - int m_nq = 0; bool m_is_barrel; // Data needed during setup @@ -195,7 +160,6 @@ namespace mkfit { float q; }; std::vector m_hit_infos; - std::vector m_qphifines; }; //============================================================================== diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index 9291027f1755f..171ee74ae2de8 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -157,7 +157,11 @@ namespace mkfit { // A1, A2 - axis types // NB_first, NB_count - number of bits for storage of { first, count } pairs - template + template struct binnor { static_assert(std::is_same() || std::is_same()); static_assert(std::is_same()); @@ -188,13 +192,14 @@ namespace mkfit { C_pair() : first(0), count(0) {} C_pair(C f, C c) : first(f), count(c) {} + C begin() const { return first; } C end() const { return first + count; } }; const A1 &m_a1; const A2 &m_a2; std::vector m_cons; - std::vector m_cons_masked; + std::vector m_cons_masked; std::vector m_bins; std::vector m_ranks; const bool m_radix_sort; @@ -209,7 +214,7 @@ namespace mkfit { m_keep_cons(keep_cons), m_do_masked(radix || !keep_cons) {} - // Access + // Access -- bin indices B_pair m_bin_to_n_bin(B_pair m_bin) { return {m_a1.from_M_bin_to_N_bin(m_bin.bin1()), m_a2.from_M_bin_to_N_bin(m_bin.bin2())}; @@ -221,6 +226,8 @@ namespace mkfit { return {m_a1.from_R_to_N_bin(r1), m_a2.from_R_to_N_bin(r2)}; } + // Access -- content of bins + C_pair &ref_content(B_pair n_bin) { return m_bins[n_bin.bin2() * m_a1.size_of_N() + n_bin.bin1()]; } C_pair get_content(B_pair n_bin) const { return m_bins[n_bin.bin2() * m_a1.size_of_N() + n_bin.bin1()]; } @@ -235,20 +242,22 @@ namespace mkfit { // Filling - void reset_contents() { + void reset_contents(bool shrink_vectors = true) { if (m_keep_cons) { m_cons.clear(); - m_cons.shrink_to_fit(); + if (shrink_vectors) + m_cons.shrink_to_fit(); } m_bins.assign(m_bins.size(), C_pair()); m_ranks.clear(); - m_ranks.shrink_to_fit(); + if (shrink_vectors) + m_ranks.shrink_to_fit(); } void begin_registration(C n_items) { if (m_keep_cons) m_cons.reserve(n_items); - if (!m_keep_cons || m_radix_sort) + if (m_do_masked) m_cons_masked.reserve(n_items); } @@ -300,6 +309,8 @@ namespace mkfit { #endif } + if (m_keep_cons) + m_cons.shrink_to_fit(); if (m_do_masked) { m_cons_masked.clear(); m_cons_masked.shrink_to_fit(); diff --git a/RecoTracker/MkFitCore/src/HitStructures.cc b/RecoTracker/MkFitCore/src/HitStructures.cc index a830b39f4bfa0..8ab6019b5a435 100644 --- a/RecoTracker/MkFitCore/src/HitStructures.cc +++ b/RecoTracker/MkFitCore/src/HitStructures.cc @@ -2,17 +2,49 @@ #include "RecoTracker/MkFitCore/interface/IterationConfig.h" #include "Matriplex/Memory.h" -#include "Ice/IceRevisitedRadix.h" #include "Debug.h" namespace mkfit { + void LayerOfHits::Initializator::setup(float qmin, float qmax, float dq) { + assert(qmax > qmin); + float extent = qmax - qmin; + m_nq = std::ceil(extent / dq); + float extra = 0.5f * (m_nq * dq - extent); + m_qmin = qmin - extra; + m_qmax = qmax + extra; + } + + LayerOfHits::Initializator::Initializator(const LayerInfo &li, float qmin, float qmax, unsigned int nq) + : m_linfo(li), m_qmin(qmin), m_qmax(qmax), m_nq(nq) {} + + LayerOfHits::Initializator::Initializator(const LayerInfo &li, float qmin, float qmax, float dq) : m_linfo(li) { + setup(qmin, qmax, dq); + } + + LayerOfHits::Initializator::Initializator(const LayerInfo &li) : m_linfo(li) { + if (li.is_barrel()) + setup(li.zmin(), li.zmax(), li.q_bin()); + else + setup(li.rin(), li.rout(), li.q_bin()); + } + + LayerOfHits::LayerOfHits(const LayerOfHits::Initializator &i) + : m_ax_phi(-Const::PI, Const::PI), + m_ax_eta(i.m_qmin, i.m_qmax, i.m_nq), + m_binnor(m_ax_phi, m_ax_eta, true, false) // yes-radix, no-keep-cons + { + m_layer_info = &i.m_linfo; + m_is_barrel = m_layer_info->is_barrel(); + + m_dead_bins.resize(m_ax_eta.size_of_N() * m_ax_phi.size_of_N()); + } + LayerOfHits::~LayerOfHits() { #ifdef COPY_SORTED_HITS free_hits(); #endif - operator delete[](m_hit_ranks); } #ifdef COPY_SORTED_HITS @@ -27,46 +59,9 @@ namespace mkfit { void LayerOfHits::free_hits() { std::free(m_hits); } #endif - void LayerOfHits::setup_bins(float qmin, float qmax, float dq) { - // Define layer with min/max and number of bins along q. - - if (dq < 0) { - m_nq = (int)-dq; - m_qmin = qmin; - m_qmax = qmax; - } else { - float extent = qmax - qmin; - m_nq = std::ceil(extent / dq); - float extra = 0.5f * (m_nq * dq - extent); - m_qmin = qmin - extra; - m_qmax = qmax + extra; - } - m_fq = m_nq / (qmax - qmin); // used in e.g. qbin = (q_hit - m_qmin) * m_fq; - - m_phi_bin_infos.resize(m_nq); - m_phi_bin_deads.resize(m_nq); - } - - void LayerOfHits::setupLayer(const LayerInfo &li) { - // Note, LayerInfo::q_bin( ==> > 0 - bin width, < 0 - number of bins - - assert(m_layer_info == nullptr && "setupLayer() already called."); - - m_layer_info = &li; - - m_is_barrel = m_layer_info->is_barrel(); - - if (m_is_barrel) - setup_bins(li.zmin(), li.zmax(), li.q_bin()); - else - setup_bins(li.rin(), li.rout(), li.q_bin()); - } - //============================================================================== void LayerOfHits::suckInHits(const HitVec &hitv) { - assert(m_nq > 0 && "setupLayer() was not called."); - m_n_hits = hitv.size(); m_ext_hits = &hitv; @@ -82,101 +77,80 @@ namespace mkfit { m_hit_qs.resize(m_n_hits); m_hit_infos.resize(m_n_hits); } - m_qphifines.resize(m_n_hits); - for (int i = 0; i < m_n_hits; ++i) { + m_binnor.reset_contents(); + m_binnor.begin_registration(m_n_hits); + + for (unsigned int i = 0; i < m_n_hits; ++i) { const Hit &h = hitv[i]; HitInfo hi = {h.phi(), m_is_barrel ? h.z() : h.r()}; - m_qphifines[i] = phiBinFine(hi.phi) + (qBinChecked(hi.q) << 16); + m_binnor.register_entry_safe(hi.phi, hi.q); if (Config::usePhiQArrays) { m_hit_infos[i] = hi; } } - operator delete[](m_hit_ranks); - { - RadixSort sort; - sort.Sort(&m_qphifines[0], m_n_hits, RADIX_UNSIGNED); - m_hit_ranks = sort.RelinquishRanks(); - } - - int curr_qphi = -1; - empty_q_bins(0, m_nq, 0); - - for (int i = 0; i < m_n_hits; ++i) { - int j = m_hit_ranks[i]; + m_binnor.finalize_registration(); + for (unsigned int i = 0; i < m_n_hits; ++i) { + int j = m_binnor.m_ranks[i]; #ifdef COPY_SORTED_HITS memcpy(&m_hits[i], &hitv[j], sizeof(Hit)); #endif - if (Config::usePhiQArrays) { m_hit_phis[i] = m_hit_infos[j].phi; m_hit_qs[i] = m_hit_infos[j].q; } - - // Combined q-phi bin with fine part masked off - const int jqphi = m_qphifines[j] & m_phi_fine_xmask; - - const int phi_bin = (jqphi & m_phi_mask_fine) >> m_phi_bits_shift; - const int q_bin = jqphi >> 16; - - // Fill the bin info - if (jqphi != curr_qphi) { - m_phi_bin_infos[q_bin][phi_bin] = {i, i}; - curr_qphi = jqphi; - } - - m_phi_bin_infos[q_bin][phi_bin].second++; } } //============================================================================== void LayerOfHits::suckInDeads(const DeadVec &deadv) { - assert(m_nq > 0 && "setupLayer() was not called."); - - empty_q_bins_dead(0, m_nq); + m_dead_bins.assign(m_dead_bins.size(), false); for (const auto &d : deadv) { - int q_bin_1 = qBinChecked(d.q1); - int q_bin_2 = qBinChecked(d.q2) + 1; - int phi_bin_1 = phiBin(d.phi1); - int phi_bin_2 = phiBin(d.phi2) + 1; - for (int q_bin = q_bin_1; q_bin < q_bin_2; q_bin++) { + bin_index_t q_bin_1 = m_ax_eta.from_R_to_N_bin_safe(d.q1); + bin_index_t q_bin_2 = m_ax_eta.from_R_to_N_bin_safe(d.q2) + 1; + bin_index_t phi_bin_1 = m_ax_phi.from_R_to_N_bin_safe(d.phi1); + bin_index_t phi_bin_2 = m_ax_phi.from_R_to_N_bin_safe(d.phi2) + 1; + for (bin_index_t q_bin = q_bin_1; q_bin < q_bin_2; q_bin++) { + unsigned int qoff = q_bin * m_ax_phi.size_of_N(); if (phi_bin_1 > phi_bin_2) { - for (int pb = phi_bin_1; pb < Config::m_nphi; pb++) { - m_phi_bin_deads[q_bin][pb] = true; + for (bin_index_t pb = phi_bin_1; pb <= m_ax_phi.m_last_N_bin; pb++) { + m_dead_bins[qoff + pb] = true; } - for (int pb = 0; pb < phi_bin_2; pb++) { - m_phi_bin_deads[q_bin][pb] = true; + for (bin_index_t pb = 0; pb < phi_bin_2; pb++) { + m_dead_bins[qoff + pb] = true; } } else { - for (int pb = phi_bin_1; pb < phi_bin_2; pb++) { - m_phi_bin_deads[q_bin][pb] = true; + for (bin_index_t pb = phi_bin_1; pb < phi_bin_2; pb++) { + m_dead_bins[qoff + pb] = true; } } } } } - void LayerOfHits::beginRegistrationOfHits(const HitVec &hitv) { - assert(m_nq > 0 && "setupLayer() was not called."); + //============================================================================== + void LayerOfHits::beginRegistrationOfHits(const HitVec &hitv) { m_ext_hits = &hitv; m_n_hits = 0; m_hit_infos.clear(); - m_qphifines.clear(); m_ext_idcs.clear(); - m_min_ext_idx = std::numeric_limits::max(); - m_max_ext_idx = std::numeric_limits::min(); + m_min_ext_idx = std::numeric_limits::max(); + m_max_ext_idx = std::numeric_limits::min(); + + m_binnor.reset_contents(); + m_binnor.begin_registration(128); // initial reserve for cons vectors } - void LayerOfHits::registerHit(int idx) { + void LayerOfHits::registerHit(unsigned int idx) { const Hit &h = (*m_ext_hits)[idx]; m_ext_idcs.push_back(idx); @@ -185,7 +159,7 @@ namespace mkfit { HitInfo hi = {h.phi(), m_is_barrel ? h.z() : h.r()}; - m_qphifines.push_back(phiBinFine(hi.phi) + (qBinChecked(hi.q) << 16)); + m_binnor.register_entry_safe(hi.phi, hi.q); if (Config::usePhiQArrays) { m_hit_infos.emplace_back(hi); @@ -197,13 +171,7 @@ namespace mkfit { if (m_n_hits == 0) return; - // radix - operator delete[](m_hit_ranks); - { - RadixSort sort; - sort.Sort(&m_qphifines[0], m_n_hits, RADIX_UNSIGNED); - m_hit_ranks = sort.RelinquishRanks(); - } + m_binnor.finalize_registration(); // copy q/phi @@ -219,12 +187,9 @@ namespace mkfit { m_hit_qs.resize(m_n_hits); } - int curr_qphi = -1; - empty_q_bins(0, m_nq, 0); - - for (int i = 0; i < m_n_hits; ++i) { - int j = m_hit_ranks[i]; // index in intermediate - int k = m_ext_idcs[j]; // index in external hit_vec + for (unsigned int i = 0; i < m_n_hits; ++i) { + int j = m_binnor.m_ranks[i]; // index in intermediate + int k = m_ext_idcs[j]; // index in external hit_vec #ifdef COPY_SORTED_HITS memcpy(&m_hits[i], &hitv[k], sizeof(Hit)); @@ -235,22 +200,8 @@ namespace mkfit { m_hit_qs[i] = m_hit_infos[j].q; } - // Combined q-phi bin with fine part masked off - const int jqphi = m_qphifines[j] & m_phi_fine_xmask; - - const int phi_bin = (jqphi & m_phi_mask_fine) >> m_phi_bits_shift; - const int q_bin = jqphi >> 16; - - // Fill the bin info - if (jqphi != curr_qphi) { - m_phi_bin_infos[q_bin][phi_bin] = {i, i}; - curr_qphi = jqphi; - } - - m_phi_bin_infos[q_bin][phi_bin].second++; - - // m_hit_ranks[i] will never be used again - use it to point to external/original index. - m_hit_ranks[i] = k; + // Redirect m_binnor.m_ranks[i] to point to external/original index. + m_binnor.m_ranks[i] = k; } if (build_original_to_internal_map) { @@ -270,98 +221,25 @@ namespace mkfit { } m_ext_idcs.resize(m_max_ext_idx - m_min_ext_idx + 1); - for (int i = 0; i < m_n_hits; ++i) { + for (unsigned int i = 0; i < m_n_hits; ++i) { m_ext_idcs[m_hit_ranks[i] - m_min_ext_idx] = i; } } - // We can release m_hit_infos and m_qphifines -- and realloc on next BeginInput. - // m_qphifines could still be used as pre-selection in selectHitIndices(). - } - - //============================================================================== - - /* - // Example code for looping over a given (q, phi) 2D range. - // A significantly more complex implementation of this can be found in MkFinder::selectHitIndices(). - void LayerOfHits::selectHitIndices(float q, float phi, float dq, float dphi, std::vector& idcs, bool isForSeeding, bool dump) - { - // Sanitizes q, dq and dphi. phi is expected to be in -pi, pi. - - // Make sure how phi bins work beyond -pi, +pi. - // for (float p = -8; p <= 8; p += 0.05) - // { - // int pb = phiBin(p); - // printf("%5.2f %4d %4d\n", p, pb, pb & m_phi_mask); - // } - - if ( ! isForSeeding) // seeding has set cuts for dq and dphi - { - // XXXX MT: min search windows not enforced here. - dq = std::min(std::abs(dq), max_dq()); - dphi = std::min(std::abs(dphi), max_dphi()); - } - - int qb1 = qBinChecked(q - dq); - int qb2 = qBinChecked(q + dq) + 1; - int pb1 = phiBin(phi - dphi); - int pb2 = phiBin(phi + dphi) + 1; - - // int extra = 2; - // qb1 -= 2; if (qb < 0) qb = 0; - // qb2 += 2; if (qb >= m_nq) qb = m_nq; - - if (dump) - printf("LayerOfHits::SelectHitIndices %6.3f %6.3f %6.4f %7.5f %3d %3d %4d %4d\n", - q, phi, dq, dphi, qb1, qb2, pb1, pb2); - - // This should be input argument, well ... it will be Matriplex op, or sth. // KPM -- it is now! used for seeding - for (int qi = qb1; qi < qb2; ++qi) - { - for (int pi = pb1; pi < pb2; ++pi) - { - int pb = pi & m_phi_mask; - - for (uint16_t hi = m_phi_bin_infos[qi][pb].first; hi < m_phi_bin_infos[qi][pb].second; ++hi) - { - // Here could enforce some furhter selection on hits - if (Config::usePhiQArrays) - { - float ddq = std::abs(q - m_hit_qs[hi]); - float ddphi = std::abs(phi - m_hit_phis[hi]); - if (ddphi > Const::PI) ddphi = Const::TwoPI - ddphi; - - if (dump) - printf(" SHI %3d %4d %4d %5d %6.3f %6.3f %6.4f %7.5f %s\n", - qi, pi, pb, hi, - m_hit_qs[hi], m_hit_phis[hi], ddq, ddphi, - (ddq < dq && ddphi < dphi) ? "PASS" : "FAIL"); - - if (ddq < dq && ddphi < dphi) - { - idcs.push_back(hi); - } - } - else // do not use phi-q arrays - { - idcs.push_back(hi); - } - } - } - } + // We can release m_hit_infos and, if not used, also m_ext_idcs -- and realloc them + // on next beginRegistration(). + // If binnor had keep_cons on we could use it for pre-selection in selectHitIndices() + // instead of q and phi arrays -- assuming sufficient precision can be achieved.. } - */ void LayerOfHits::printBins() { - for (int qb = 0; qb < m_nq; ++qb) { + for (bin_index_t qb = 0; qb <= m_ax_eta.m_last_N_bin; ++qb) { printf("%c bin %d\n", is_barrel() ? 'Z' : 'R', qb); - for (int pb = 0; pb < Config::m_nphi; ++pb) { + for (bin_index_t pb = 0; pb < m_ax_phi.m_last_N_bin; ++pb) { if (pb % 8 == 0) printf(" Phi %4d: ", pb); - printf("%5d,%4d %s", - m_phi_bin_infos[qb][pb].first, - m_phi_bin_infos[qb][pb].second, - ((pb + 1) % 8 == 0) ? "\n" : ""); + auto content = m_binnor.get_content(pb, qb); + printf("%5d,%4d %s", content.first, content.count, ((pb + 1) % 8 == 0) ? "\n" : ""); } } } @@ -370,11 +248,10 @@ namespace mkfit { // EventOfHits //============================================================================== - EventOfHits::EventOfHits(const TrackerInfo &trk_inf) - : m_layers_of_hits(trk_inf.n_layers()), m_n_layers(trk_inf.n_layers()) { + EventOfHits::EventOfHits(const TrackerInfo &trk_inf) : m_n_layers(trk_inf.n_layers()) { + m_layers_of_hits.reserve(trk_inf.n_layers()); for (int ii = 0; ii < trk_inf.n_layers(); ++ii) { - const LayerInfo &li = trk_inf.layer(ii); - m_layers_of_hits[li.layer_id()].setupLayer(li); + m_layers_of_hits.emplace_back(LayerOfHits::Initializator(trk_inf.layer(ii))); } } diff --git a/RecoTracker/MkFitCore/src/Ice/IceFPU.h b/RecoTracker/MkFitCore/src/Ice/IceFPU.h deleted file mode 100644 index f19b622e428c0..0000000000000 --- a/RecoTracker/MkFitCore/src/Ice/IceFPU.h +++ /dev/null @@ -1,278 +0,0 @@ -//---------------------------------------------------------------------- -/** - * Contains FPU related code. - * \file IceFPU.h - * \author Pierre Terdiman - * \date April, 4, 2000 - */ -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -// Include Guard -#ifndef RecoTracker_MkFitCore_src_Ice_IceFPU_h -#define RecoTracker_MkFitCore_src_Ice_IceFPU_h - -#define SIGN_BITMASK 0x80000000 - -//! Integer representation of a floating-point value. -#define IR(x) ((udword&)(x)) - -//! Signed integer representation of a floating-point value. -#define SIR(x) ((sdword&)(x)) - -//! Absolute integer representation of a floating-point value -#define AIR(x) (IR(x) & 0x7fffffff) - -//! Floating-point representation of an integer value. -#define FR(x) ((float&)(x)) - -//! Integer-based comparison of a floating point value. -//! Don't use it blindly, it can be faster or slower than the FPU comparison, depends on the context. -#define IS_NEGATIVE_FLOAT(x) (IR(x) & 0x80000000) - -//! Fast fabs for floating-point values. It just clears the sign bit. -//! Don't use it blindy, it can be faster or slower than the FPU comparison, depends on the context. -inline_ float FastFabs(float x) { - udword FloatBits = IR(x) & 0x7fffffff; - return FR(FloatBits); -} - -#ifdef WIN32 -//! Fast square root for floating-point values. -inline_ float FastSqrt(float square) { - float retval; - - __asm { - mov eax, square - sub eax, 0x3F800000 - sar eax, 1 - add eax, 0x3F800000 - mov [retval], eax - } - return retval; -} -#endif - -//! Saturates positive to zero. -inline_ float fsat(float f) { - udword y = (udword&)f & ~((sdword&)f >> 31); - return (float&)y; -} - -//! Computes 1.0f / sqrtf(x). -inline_ float frsqrt(float f) { - float x = f * 0.5f; - udword y = 0x5f3759df - ((udword&)f >> 1); - // Iteration... - (float&)y = (float&)y * (1.5f - (x * (float&)y * (float&)y)); - // Result - return (float&)y; -} - -//! Computes 1.0f / sqrtf(x). Comes from NVIDIA. -inline_ float InvSqrt(const float& x) { - udword tmp = (udword(IEEE_1_0 << 1) + IEEE_1_0 - *(udword*)&x) >> 1; - float y = *(float*)&tmp; - return y * (1.47f - 0.47f * x * y * y); -} - -//! Computes 1.0f / sqrtf(x). Comes from Quake3. Looks like the first one I had above. -//! See http://www.magic-software.com/3DGEDInvSqrt.html -inline_ float RSqrt(float number) { - long i; - float x2, y; - const float threehalfs = 1.5f; - - x2 = number * 0.5f; - y = number; - i = *(long*)&y; - i = 0x5f3759df - (i >> 1); - y = *(float*)&i; - y = y * (threehalfs - (x2 * y * y)); - - return y; -} - -//! TO BE DOCUMENTED -inline_ float fsqrt(float f) { - udword y = (((sdword&)f - 0x3f800000) >> 1) + 0x3f800000; - // Iteration...? - // (float&)y = (3.0f - ((float&)y * (float&)y) / f) * (float&)y * 0.5f; - // Result - return (float&)y; -} - -//! Returns the float ranged espilon value. -inline_ float fepsilon(float f) { - udword b = (udword&)f & 0xff800000; - udword a = b | 0x00000001; - (float&)a -= (float&)b; - // Result - return (float&)a; -} - -//! Is the float valid ? -inline_ bool IsNAN(float value) { return (IR(value) & 0x7f800000) == 0x7f800000; } -inline_ bool IsIndeterminate(float value) { return IR(value) == 0xffc00000; } -inline_ bool IsPlusInf(float value) { return IR(value) == 0x7f800000; } -inline_ bool IsMinusInf(float value) { return IR(value) == 0xff800000; } - -inline_ bool IsValidFloat(float value) { - if (IsNAN(value)) - return false; - if (IsIndeterminate(value)) - return false; - if (IsPlusInf(value)) - return false; - if (IsMinusInf(value)) - return false; - return true; -} - -#define CHECK_VALID_FLOAT(x) ASSERT(IsValidFloat(x)); - -/* -//! FPU precision setting function. -inline_ void SetFPU() -{ -// This function evaluates whether the floating-point -// control word is set to single precision/round to nearest/ -// exceptions disabled. If these conditions don't hold, the -// function changes the control word to set them and returns -// true, putting the old control word value in the passback -// location pointed to by pwOldCW. -{ -uword wTemp, wSave; - -__asm fstcw wSave -if (wSave & 0x300 || // Not single mode -0x3f != (wSave & 0x3f) || // Exceptions enabled -wSave & 0xC00) // Not round to nearest mode -{ -__asm -{ -mov ax, wSave -and ax, not 300h ;; single mode -or ax, 3fh ;; disable all exceptions -and ax, not 0xC00 ;; round to nearest mode -mov wTemp, ax -fldcw wTemp -} -} -} -} -*/ -//! This function computes the slowest possible floating-point value (you can also directly use FLT_EPSILON) -inline_ float ComputeFloatEpsilon() { - float f = 1.0f; - ((udword&)f) ^= 1; - return f - 1.0f; // You can check it's the same as FLT_EPSILON -} - -inline_ bool IsFloatZero(float x, float epsilon = 1e-6f) { return x * x < epsilon; } - -#ifdef WIN32 -#define FCOMI_ST0 _asm _emit 0xdb _asm _emit 0xf0 -#define FCOMIP_ST0 _asm _emit 0xdf _asm _emit 0xf0 -#define FCMOVB_ST0 _asm _emit 0xda _asm _emit 0xc0 -#define FCMOVNB_ST0 _asm _emit 0xdb _asm _emit 0xc0 - -#define FCOMI_ST1 _asm _emit 0xdb _asm _emit 0xf1 -#define FCOMIP_ST1 _asm _emit 0xdf _asm _emit 0xf1 -#define FCMOVB_ST1 _asm _emit 0xda _asm _emit 0xc1 -#define FCMOVNB_ST1 _asm _emit 0xdb _asm _emit 0xc1 - -#define FCOMI_ST2 _asm _emit 0xdb _asm _emit 0xf2 -#define FCOMIP_ST2 _asm _emit 0xdf _asm _emit 0xf2 -#define FCMOVB_ST2 _asm _emit 0xda _asm _emit 0xc2 -#define FCMOVNB_ST2 _asm _emit 0xdb _asm _emit 0xc2 - -#define FCOMI_ST3 _asm _emit 0xdb _asm _emit 0xf3 -#define FCOMIP_ST3 _asm _emit 0xdf _asm _emit 0xf3 -#define FCMOVB_ST3 _asm _emit 0xda _asm _emit 0xc3 -#define FCMOVNB_ST3 _asm _emit 0xdb _asm _emit 0xc3 - -#define FCOMI_ST4 _asm _emit 0xdb _asm _emit 0xf4 -#define FCOMIP_ST4 _asm _emit 0xdf _asm _emit 0xf4 -#define FCMOVB_ST4 _asm _emit 0xda _asm _emit 0xc4 -#define FCMOVNB_ST4 _asm _emit 0xdb _asm _emit 0xc4 - -#define FCOMI_ST5 _asm _emit 0xdb _asm _emit 0xf5 -#define FCOMIP_ST5 _asm _emit 0xdf _asm _emit 0xf5 -#define FCMOVB_ST5 _asm _emit 0xda _asm _emit 0xc5 -#define FCMOVNB_ST5 _asm _emit 0xdb _asm _emit 0xc5 - -#define FCOMI_ST6 _asm _emit 0xdb _asm _emit 0xf6 -#define FCOMIP_ST6 _asm _emit 0xdf _asm _emit 0xf6 -#define FCMOVB_ST6 _asm _emit 0xda _asm _emit 0xc6 -#define FCMOVNB_ST6 _asm _emit 0xdb _asm _emit 0xc6 - -#define FCOMI_ST7 _asm _emit 0xdb _asm _emit 0xf7 -#define FCOMIP_ST7 _asm _emit 0xdf _asm _emit 0xf7 -#define FCMOVB_ST7 _asm _emit 0xda _asm _emit 0xc7 -#define FCMOVNB_ST7 _asm _emit 0xdb _asm _emit 0xc7 - -//! A global function to find MAX(a,b) using FCOMI/FCMOV -inline_ float FCMax2(float a, float b) { - float Res; - _asm fld[a] _asm fld[b] FCOMI_ST1 FCMOVB_ST1 _asm fstp[Res] _asm fcomp return Res; -} - -//! A global function to find MIN(a,b) using FCOMI/FCMOV -inline_ float FCMin2(float a, float b) { - float Res; - _asm fld[a] _asm fld[b] FCOMI_ST1 FCMOVNB_ST1 _asm fstp[Res] _asm fcomp return Res; -} - -//! A global function to find MAX(a,b,c) using FCOMI/FCMOV -inline_ float FCMax3(float a, float b, float c) { - float Res; - _asm fld[a] _asm fld[b] _asm fld[c] FCOMI_ST1 FCMOVB_ST1 FCOMI_ST2 FCMOVB_ST2 _asm fstp[Res] _asm fcompp return Res; -} - -//! A global function to find MIN(a,b,c) using FCOMI/FCMOV -inline_ float FCMin3(float a, float b, float c) { - float Res; - _asm fld[a] _asm fld[b] _asm fld[c] FCOMI_ST1 FCMOVNB_ST1 FCOMI_ST2 FCMOVNB_ST2 _asm fstp[Res] _asm fcompp return Res; -} -#endif - -inline_ int ConvertToSortable(float f) { - int& Fi = (int&)f; - int Fmask = (Fi >> 31); - Fi ^= Fmask; - Fmask &= ~(1 << 31); - Fi -= Fmask; - return Fi; -} - -enum FPUMode { - FPU_FLOOR = 0, - FPU_CEIL = 1, - FPU_BEST = 2, - - FPU_FORCE_DWORD = 0x7fffffff -}; - -#ifdef WIN32 -FUNCTION ICECORE_API FPUMode GetFPUMode(); -FUNCTION ICECORE_API void SaveFPU(); -FUNCTION ICECORE_API void RestoreFPU(); -FUNCTION ICECORE_API void SetFPUFloorMode(); -FUNCTION ICECORE_API void SetFPUCeilMode(); -FUNCTION ICECORE_API void SetFPUBestMode(); - -FUNCTION ICECORE_API void SetFPUPrecision24(); -FUNCTION ICECORE_API void SetFPUPrecision53(); -FUNCTION ICECORE_API void SetFPUPrecision64(); -FUNCTION ICECORE_API void SetFPURoundingChop(); -FUNCTION ICECORE_API void SetFPURoundingUp(); -FUNCTION ICECORE_API void SetFPURoundingDown(); -FUNCTION ICECORE_API void SetFPURoundingNear(); - -FUNCTION ICECORE_API int intChop(const float& f); -FUNCTION ICECORE_API int intFloor(const float& f); -FUNCTION ICECORE_API int intCeil(const float& f); -#endif - -#endif // __ICEFPU_H__ diff --git a/RecoTracker/MkFitCore/src/Ice/IceMemoryMacros.h b/RecoTracker/MkFitCore/src/Ice/IceMemoryMacros.h deleted file mode 100644 index 65e114cf62043..0000000000000 --- a/RecoTracker/MkFitCore/src/Ice/IceMemoryMacros.h +++ /dev/null @@ -1,123 +0,0 @@ -//---------------------------------------------------------------------- -/** - * Contains all memory macros. - * \file IceMemoryMacros.h - * \author Pierre Terdiman - * \date April, 4, 2000 - */ -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -// Include Guard -#ifndef RecoTracker_MkFitCore_src_Ice_IceMemoryMacros_h -#define RecoTracker_MkFitCore_src_Ice_IceMemoryMacros_h - -#undef ZeroMemory -#undef CopyMemory -#undef MoveMemory -#undef FillMemory - -#include - -//! Clears a buffer. -//! \param addr [in] buffer address -//! \param size [in] buffer length -//! \see FillMemory -//! \see StoreDwords -//! \see CopyMemory -//! \see MoveMemory -inline void ZeroMemory(void* addr, udword size) { memset(addr, 0, size); } - -//! Fills a buffer with a given byte. -//! \param addr [in] buffer address -//! \param size [in] buffer length -//! \param val [in] the byte value -//! \see StoreDwords -//! \see ZeroMemory -//! \see CopyMemory -//! \see MoveMemory -inline void FillMemory(void* dest, udword size, ubyte val) { memset(dest, val, size); } - -#ifdef WIN32 -//! Fills a buffer with a given dword. -//! \param addr [in] buffer address -//! \param nb [in] number of dwords to write -//! \param value [in] the dword value -//! \see FillMemory -//! \see ZeroMemory -//! \see CopyMemory -//! \see MoveMemory -//! \warning writes nb*4 bytes ! -inline_ void StoreDwords(udword* dest, udword nb, udword value) { - // The asm code below **SHOULD** be equivalent to one of those C versions - // or the other if your compiled is good: (checked on VC++ 6.0) - // - // 1) while(nb--) *dest++ = value; - // - // 2) for(udword i=0;irelease(); \ - (x) = 0; \ - } //!< Safe D3D-style release -#define SAFE_DESTRUCT(x) \ - if (x) { \ - (x)->SelfDestruct(); \ - (x) = 0; \ - } //!< Safe ICE-style release - -#ifdef __ICEERROR_H__ -#define CHECKALLOC(x) \ - if (!x) \ - return SetIceError("Out of memory.", EC_OUT_OF_MEMORY); //!< Standard alloc checking. HANDLE WITH CARE. -#else -#define CHECKALLOC(x) \ - if (!x) \ - return false; -#endif - -//! Standard allocation cycle -#define SAFE_ALLOC(ptr, type, count) \ - DELETEARRAY(ptr); \ - ptr = new type[count]; \ - CHECKALLOC(ptr); - -#endif // __ICEMEMORYMACROS_H__ diff --git a/RecoTracker/MkFitCore/src/Ice/IcePreprocessor.h b/RecoTracker/MkFitCore/src/Ice/IcePreprocessor.h deleted file mode 100644 index 1587c63c721a0..0000000000000 --- a/RecoTracker/MkFitCore/src/Ice/IcePreprocessor.h +++ /dev/null @@ -1,23 +0,0 @@ -//---------------------------------------------------------------------- -/** - * Contains preprocessor stuff. This should be the first included header. - * \file IcePreprocessor.h - * \author Pierre Terdiman - * \date April, 4, 2000 - */ -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -// Include Guard -#ifndef RecoTracker_MkFitCore_src_Ice_IcePreprocessor_h -#define RecoTracker_MkFitCore_src_Ice_IcePreprocessor_h - -#define FUNCTION extern "C" - -// Cosmetic stuff [mainly useful with multiple inheritance] -#define override(base_class) virtual - -// Down the hatch -// #pragma inline_depth( 255 ) // MT: this annoys gcc. - -#endif // __ICEPREPROCESSOR_H__ diff --git a/RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.cc b/RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.cc deleted file mode 100644 index 87581d3345e94..0000000000000 --- a/RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.cc +++ /dev/null @@ -1,547 +0,0 @@ -//---------------------------------------------------------------------- -/** - * Contains source code from the article "Radix Sort Revisited". - * \file IceRevisitedRadix.cpp - * \author Pierre Terdiman - * \date April, 4, 2000 - */ -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -/** - * Revisited Radix Sort. - * This is my new radix routine: - * - it uses indices and doesn't recopy the values anymore, hence wasting less ram - * - it creates all the histograms in one run instead of four - * - it sorts words faster than dwords and bytes faster than words - * - it correctly sorts negative floating-point values by patching the offsets - * - it automatically takes advantage of temporal coherence - * - multiple keys support is a side effect of temporal coherence - * - it may be worth recoding in asm... (mainly to use FCOMI, FCMOV, etc) [it's probably memory-bound anyway] - * - * History: - * - 08.15.98: very first version - * - 04.04.00: recoded for the radix article - * - 12.xx.00: code lifting - * - 09.18.01: faster CHECK_PASS_VALIDITY thanks to Mark D. Shattuck (who provided other tips, not included here) - * - 10.11.01: added local ram support - * - 01.20.02: bugfix! In very particular cases the last pass was skipped in the float code-path, leading to incorrect sorting...... - * - 01.02.02: - "mIndices" renamed => "mRanks". That's a rank sorter after all. - * - ranks are not "reset" anymore, but implicit on first calls - * - 07.05.02: - offsets rewritten with one less indirection. - * - 11.03.02: - "bool" replaced with RadixHint enum - * - * \class RadixSort - * \author Pierre Terdiman - * \version 1.4 - * \date August, 15, 1998 - */ -//---------------------------------------------------------------------- - -/* -To do: - - add an offset parameter between two input values (avoid some data recopy sometimes) - - unroll ? asm ? - - 11 bits trick & 3 passes as Michael did - - prefetch stuff the day I have a P3 - - make a version with 16-bits indices ? -*/ - -//------------------------------------------------------------------------------ - -// Snatch from Opcode.h in Gled::Var1 - -#include "IceRevisitedRadix.h" - -#include "IceMemoryMacros.h" - -//------------------------------------------------------------------------------ - -#define INVALIDATE_RANKS mCurrentSize |= 0x80000000 -#define VALIDATE_RANKS mCurrentSize &= 0x7fffffff -#define CURRENT_SIZE (mCurrentSize & 0x7fffffff) -#define INVALID_RANKS (mCurrentSize & 0x80000000) - -#define CHECK_RESIZE(n) \ - if (n != mPreviousSize) { \ - if (n > mCurrentSize) \ - Resize(n); \ - else \ - ResetRanks(); \ - mPreviousSize = n; \ - } - -#define CREATE_HISTOGRAMS(type, buffer) \ - /* Clear counters/histograms */ \ - ZeroMemory(mHistogram, 256 * 4 * sizeof(udword)); \ - \ - /* Prepare to count */ \ - ubyte* p = (ubyte*)input; \ - ubyte* pe = &p[nb * 4]; \ - udword* h0 = &mHistogram[0]; /* Histogram for first pass (LSB) */ \ - udword* h1 = &mHistogram[256]; /* Histogram for second pass */ \ - udword* h2 = &mHistogram[512]; /* Histogram for third pass */ \ - udword* h3 = &mHistogram[768]; /* Histogram for last pass (MSB) */ \ - \ - bool AlreadySorted = true; /* Optimism... */ \ - \ - if (INVALID_RANKS) { \ - /* Prepare for temporal coherence */ \ - type* Running = (type*)buffer; \ - type PrevVal = *Running; \ - \ - while (p != pe) { \ - /* Read input buffer in previous sorted order */ \ - type Val = *Running++; \ - /* Check whether already sorted or not */ \ - if (Val < PrevVal) { \ - AlreadySorted = false; \ - break; \ - } /* Early out */ \ - /* Update for next iteration */ \ - PrevVal = Val; \ - \ - /* Create histograms */ \ - h0[*p++]++; \ - h1[*p++]++; \ - h2[*p++]++; \ - h3[*p++]++; \ - } \ - \ - /* If all input values are already sorted, we just have to return and leave the */ \ - /* previous list unchanged. That way the routine may take advantage of temporal */ \ - /* coherence, for example when used to sort transparent faces. */ \ - if (AlreadySorted) { \ - mNbHits++; \ - for (udword i = 0; i < nb; i++) \ - mRanks[i] = i; \ - return *this; \ - } \ - } else { \ - /* Prepare for temporal coherence */ \ - udword* Indices = mRanks; \ - type PrevVal = (type)buffer[*Indices]; \ - \ - while (p != pe) { \ - /* Read input buffer in previous sorted order */ \ - type Val = (type)buffer[*Indices++]; \ - /* Check whether already sorted or not */ \ - if (Val < PrevVal) { \ - AlreadySorted = false; \ - break; \ - } /* Early out */ \ - /* Update for next iteration */ \ - PrevVal = Val; \ - \ - /* Create histograms */ \ - h0[*p++]++; \ - h1[*p++]++; \ - h2[*p++]++; \ - h3[*p++]++; \ - } \ - \ - /* If all input values are already sorted, we just have to return and leave the */ \ - /* previous list unchanged. That way the routine may take advantage of temporal */ \ - /* coherence, for example when used to sort transparent faces. */ \ - if (AlreadySorted) { \ - mNbHits++; \ - return *this; \ - } \ - } \ - \ - /* Else there has been an early out and we must finish computing the histograms */ \ - while (p != pe) { \ - /* Create histograms without the previous overhead */ \ - h0[*p++]++; \ - h1[*p++]++; \ - h2[*p++]++; \ - h3[*p++]++; \ - } - -#define CHECK_PASS_VALIDITY(pass) \ - /* Shortcut to current counters */ \ - udword* CurCount = &mHistogram[pass << 8]; \ - \ - /* Reset flag. The sorting pass is supposed to be performed. (default) */ \ - bool PerformPass = true; \ - \ - /* Check pass validity */ \ - \ - /* If all values have the same byte, sorting is useless. */ \ - /* It may happen when sorting bytes or words instead of dwords. */ \ - /* This routine actually sorts words faster than dwords, and bytes */ \ - /* faster than words. Standard running time (O(4*n))is reduced to O(2*n) */ \ - /* for words and O(n) for bytes. Running time for floats depends on actual values... */ \ - \ - /* Get first byte */ \ - ubyte UniqueVal = *(((ubyte*)input) + pass); \ - \ - /* Check that byte's counter */ \ - if (CurCount[UniqueVal] == nb) \ - PerformPass = false; - -//---------------------------------------------------------------------- -/** - * Constructor. - */ -//---------------------------------------------------------------------- -RadixSort::RadixSort() : mCurrentSize(0), mRanks(nullptr), mRanks2(nullptr), mTotalCalls(0), mNbHits(0) { -#ifndef RADIX_LOCAL_RAM - // Allocate input-independent ram - mHistogram = new udword[256 * 4]; - mLink = new udword[256]; -#endif - // Initialize indices - INVALIDATE_RANKS; -} - -//---------------------------------------------------------------------- -/** - * Destructor. - */ -//---------------------------------------------------------------------- -RadixSort::~RadixSort() { - // Release everything -#ifndef RADIX_LOCAL_RAM - DELETEARRAY(mLink); - DELETEARRAY(mHistogram); -#endif - DELETEARRAY(mRanks2); - DELETEARRAY(mRanks); -} - -//---------------------------------------------------------------------- -/** - * Detach mRanks. After this the caller is responsible for - * freeing this array via delete [] operator. - */ -//---------------------------------------------------------------------- -udword* RadixSort::RelinquishRanks() { - udword* ranks = mRanks; - mRanks = nullptr; - DELETEARRAY(mRanks2); - mCurrentSize = 0; - return ranks; -} - -//---------------------------------------------------------------------- -/** - * Resizes the inner lists. - * \param nb [in] new size (number of dwords) - * \return true if success - */ -//---------------------------------------------------------------------- -bool RadixSort::Resize(udword nb) { - // Free previously used ram - DELETEARRAY(mRanks2); - DELETEARRAY(mRanks); - - // Get some fresh one - mRanks = new udword[nb]; - CHECKALLOC(mRanks); - mRanks2 = new udword[nb]; - CHECKALLOC(mRanks2); - - return true; -} - -inline_ void RadixSort::CheckResize(udword nb) { - udword CurSize = CURRENT_SIZE; - if (nb != CurSize) { - if (nb > CurSize) - Resize(nb); - mCurrentSize = nb; - INVALIDATE_RANKS; - } -} - -//---------------------------------------------------------------------- -/** - * Main sort routine. - * This one is for integer values. After the call, mRanks - * contains a list of indices in sorted order, i.e. in the order - * you may process your data. - * \param input [in] a list of integer values to sort - * \param nb [in] number of values to sort, must be < 2^31 - * \param hint [in] RADIX_SIGNED to handle negative values, - * RADIX_UNSIGNED if you know your input buffer only contains positive values - * \return Self-Reference - */ -//---------------------------------------------------------------------- -RadixSort& RadixSort::Sort(const udword* input, udword nb, RadixHint hint) { - // Checkings - if (!input || !nb || nb & 0x80000000) - return *this; - - // Stats - mTotalCalls++; - - // Resize lists if needed - CheckResize(nb); - -#ifdef RADIX_LOCAL_RAM - // Allocate histograms & offsets on the stack - udword mHistogram[256 * 4]; - udword* mLink[256]; -#endif - - // Create histograms (counters). Counters for all passes are created in one run. - // Pros: read input buffer once instead of four times - // Cons: mHistogram is 4Kb instead of 1Kb - // We must take care of signed/unsigned values for temporal - // coherence.... I just have 2 code paths even if just a single - // opcode changes. Self-modifying code, someone? - if (hint == RADIX_UNSIGNED) { - CREATE_HISTOGRAMS(udword, input); - } else { - CREATE_HISTOGRAMS(sdword, input); - } - - // Compute #negative values involved if needed - udword NbNegativeValues = 0; - if (hint == RADIX_SIGNED) { - // An efficient way to compute the number of negatives values - // we'll have to deal with is simply to sum the 128 last values - // of the last histogram. Last histogram because that's the one - // for the Most Significant Byte, responsible for the sign. 128 - // last values because the 128 first ones are related to - // positive numbers. - udword* h3 = &mHistogram[768]; - for (udword i = 128; i < 256; i++) - NbNegativeValues += h3[i]; // 768 for last histogram, 128 for negative part - } - - // Radix sort, j is the pass number (0=LSB, 3=MSB) - for (udword j = 0; j < 4; j++) { - CHECK_PASS_VALIDITY(j); - - // Sometimes the fourth (negative) pass is skipped because all - // numbers are negative and the MSB is 0xFF (for example). This - // is not a problem, numbers are correctly sorted anyway. - if (PerformPass) { - // Should we care about negative values? - if (j != 3 || hint == RADIX_UNSIGNED) { - // Here we deal with positive values only - - // Create offsets - mLink[0] = mRanks2; - for (udword i = 1; i < 256; i++) - mLink[i] = mLink[i - 1] + CurCount[i - 1]; - } else { - // This is a special case to correctly handle negative - // integers. They're sorted in the right order but at - // the wrong place. - - // Create biased offsets, in order for negative numbers to be sorted as well - mLink[0] = &mRanks2[NbNegativeValues]; // First positive number takes place after the negative ones - for (udword i = 1; i < 128; i++) - mLink[i] = mLink[i - 1] + CurCount[i - 1]; // 1 to 128 for positive numbers - - // Fixing the wrong place for negative values - mLink[128] = mRanks2; - for (udword i = 129; i < 256; i++) - mLink[i] = mLink[i - 1] + CurCount[i - 1]; - } - - // Perform Radix Sort - ubyte* InputBytes = (ubyte*)input; - InputBytes += j; - if (INVALID_RANKS) { - for (udword i = 0; i < nb; i++) - *mLink[InputBytes[i << 2]]++ = i; - VALIDATE_RANKS; - } else { - udword* Indices = mRanks; - udword* IndicesEnd = &mRanks[nb]; - while (Indices != IndicesEnd) { - udword id = *Indices++; - *mLink[InputBytes[id << 2]]++ = id; - } - } - - // Swap pointers for next pass. Valid indices - the most - // recent ones - are in mRanks after the swap. - udword* Tmp = mRanks; - mRanks = mRanks2; - mRanks2 = Tmp; - } - } - return *this; -} - -//---------------------------------------------------------------------- -/** - * Main sort routine. - * This one is for floating-point values. After the call, mRanks - * contains a list of indices in sorted order, i.e. in the order - * you may process your data. - * \param input [in] a list of floating-point values to sort - * \param nb [in] number of values to sort, must be < 2^31 - * \return Self-Reference - * \warning only sorts IEEE floating-point values - */ -//---------------------------------------------------------------------- -RadixSort& RadixSort::Sort(const float* input2, udword nb) { - // Checkings - if (!input2 || !nb || nb & 0x80000000) - return *this; - - // Stats - mTotalCalls++; - - udword* input = (udword*)input2; - - // Resize lists if needed - CheckResize(nb); - -#ifdef RADIX_LOCAL_RAM - // Allocate histograms & offsets on the stack - udword mHistogram[256 * 4]; - udword* mLink[256]; -#endif - - // Create histograms (counters). Counters for all passes are created - // in one run. - // Pros: read input buffer once instead of four times - // Cons: mHistogram is 4Kb instead of 1Kb - // - // Floating-point values are always supposed to be signed values, so - // there's only one code path there. - // Please note the floating point comparison needed for temporal - // coherence! Although the resulting asm code is dreadful, this is - // surprisingly not such a performance hit - well, I suppose that's - // a big one on first generation Pentiums....We can't make - // comparison on integer representations because, as Chris said, it - // just wouldn't work with mixed positive/negative values.... - { CREATE_HISTOGRAMS(float, input2); } - - // Compute #negative values involved if needed - udword NbNegativeValues = 0; - // An efficient way to compute the number of negatives values we'll - // have to deal with is simply to sum the 128 last values of the - // last histogram. Last histogram because that's the one for the - // Most Significant Byte, responsible for the sign. 128 last values - // because the 128 first ones are related to positive numbers. - udword* h3 = &mHistogram[768]; - for (udword i = 128; i < 256; i++) - NbNegativeValues += h3[i]; // 768 for last histogram, 128 for negative part - - // Radix sort, j is the pass number (0=LSB, 3=MSB) - for (udword j = 0; j < 4; j++) { - // Should we care about negative values? - if (j != 3) { - // Here we deal with positive values only - CHECK_PASS_VALIDITY(j); - - if (PerformPass) { - // Create offsets - mLink[0] = mRanks2; - for (udword i = 1; i < 256; i++) - mLink[i] = mLink[i - 1] + CurCount[i - 1]; - - // Perform Radix Sort - ubyte* InputBytes = (ubyte*)input; - InputBytes += j; - if (INVALID_RANKS) { - for (udword i = 0; i < nb; i++) - *mLink[InputBytes[i << 2]]++ = i; - VALIDATE_RANKS; - } else { - udword* Indices = mRanks; - udword* IndicesEnd = &mRanks[nb]; - while (Indices != IndicesEnd) { - udword id = *Indices++; - *mLink[InputBytes[id << 2]]++ = id; - } - } - - // Swap pointers for next pass. Valid indices - the most - // recent ones - are in mRanks after the swap. - udword* Tmp = mRanks; - mRanks = mRanks2; - mRanks2 = Tmp; - } - } else { - // This is a special case to correctly handle negative values - CHECK_PASS_VALIDITY(j); - - if (PerformPass) { - // Create biased offsets, in order for negative numbers - // to be sorted as well - mLink[0] = &mRanks2[NbNegativeValues]; // First positive number takes place after the negative ones - for (udword i = 1; i < 128; i++) - mLink[i] = mLink[i - 1] + CurCount[i - 1]; // 1 to 128 for positive numbers - - // We must reverse the sorting order for negative numbers! - mLink[255] = mRanks2; - for (udword i = 0; i < 127; i++) - mLink[254 - i] = mLink[255 - i] + CurCount[255 - i]; // Fixing the wrong order for negative values - for (udword i = 128; i < 256; i++) - mLink[i] += CurCount[i]; // Fixing the wrong place for negative values - - // Perform Radix Sort - if (INVALID_RANKS) { - for (udword i = 0; i < nb; i++) { - udword Radix = input[i] >> 24; // Radix byte, same as above. AND is useless here (udword). - // ### cmp to be killed. Not good. Later. - if (Radix < 128) - *mLink[Radix]++ = i; // Number is positive, same as above - else - *(--mLink[Radix]) = i; // Number is negative, flip the sorting order - } - VALIDATE_RANKS; - } else { - for (udword i = 0; i < nb; i++) { - udword Radix = input[mRanks[i]] >> 24; // Radix byte, same as above. AND is useless here (udword). - // ### cmp to be killed. Not good. Later. - if (Radix < 128) - *mLink[Radix]++ = mRanks[i]; // Number is positive, same as above - else - *(--mLink[Radix]) = mRanks[i]; // Number is negative, flip the sorting order - } - } - // Swap pointers for next pass. Valid indices - the most - // recent ones - are in mRanks after the swap. - udword* Tmp = mRanks; - mRanks = mRanks2; - mRanks2 = Tmp; - } else { - // The pass is useless, yet we still have to reverse the order of current list if all values are negative. - if (UniqueVal >= 128) { - if (INVALID_RANKS) { - // ###Possible? - for (udword i = 0; i < nb; i++) - mRanks2[i] = nb - i - 1; - VALIDATE_RANKS; - } else { - for (udword i = 0; i < nb; i++) - mRanks2[i] = mRanks[nb - i - 1]; - } - - // Swap pointers for next pass. Valid indices - the - // most recent ones - are in mRanks after the swap. - udword* Tmp = mRanks; - mRanks = mRanks2; - mRanks2 = Tmp; - } - } - } - } - return *this; -} - -//---------------------------------------------------------------------- -/** - * Gets the ram used. - * \return memory used in bytes - */ -//---------------------------------------------------------------------- -udword RadixSort::GetUsedRam() const { - udword UsedRam = sizeof(RadixSort); -#ifndef RADIX_LOCAL_RAM - UsedRam += 256 * 4 * sizeof(udword); // Histograms - UsedRam += 256 * sizeof(udword); // Link -#endif - UsedRam += 2 * CURRENT_SIZE * sizeof(udword); // 2 lists of indices - return UsedRam; -} diff --git a/RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.h b/RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.h deleted file mode 100644 index 790d35f1a9397..0000000000000 --- a/RecoTracker/MkFitCore/src/Ice/IceRevisitedRadix.h +++ /dev/null @@ -1,73 +0,0 @@ -//---------------------------------------------------------------------- -/** - * Contains source code from the article "Radix Sort Revisited". - * \file IceRevisitedRadix.h - * \author Pierre Terdiman - * \date April, 4, 2000 - */ -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -// Include Guard -#ifndef RecoTracker_MkFitCore_src_Ice_IceRevisitedRadix_h -#define RecoTracker_MkFitCore_src_Ice_IceRevisitedRadix_h - -#include "IcePreprocessor.h" -#include "IceTypes.h" - -//! Allocate histograms & offsets locally -#define RADIX_LOCAL_RAM - -enum RadixHint { - RADIX_SIGNED, //!< Input values are signed - RADIX_UNSIGNED, //!< Input values are unsigned - - RADIX_FORCE_DWORD = 0x7fffffff -}; - -class RadixSort { -public: - // Constructor/Destructor - RadixSort(); - ~RadixSort(); - // Sorting methods - RadixSort& Sort(const udword* input, udword nb, RadixHint hint = RADIX_SIGNED); - RadixSort& Sort(const float* input, udword nb); - - //! Access to results. mRanks is a list of indices in sorted order, - //i.e. in the order you may further process your data - const udword* GetRanks() const { return mRanks; } - - //! Detach mRanks. After this the caller is responsible for - //! freeing this array via delete [] operator. - udword* RelinquishRanks(); - - //! mIndices2 gets trashed on calling the sort routine, but - //otherwise you can recycle it the way you want. - udword* GetRecyclable() const { return mRanks2; } - - // Stats - udword GetUsedRam() const; - //! Returns the total number of calls to the radix sorter. - udword GetNbTotalCalls() const { return mTotalCalls; } - //! Returns the number of eraly exits due to temporal coherence. - udword GetNbHits() const { return mNbHits; } - -private: -#ifndef RADIX_LOCAL_RAM - udword* mHistogram; //!< Counters for each byte - udword* mLink; //!< offsets (nearly a cumulative distribution function) -#endif - udword mCurrentSize; //!< Current size of the indices list - udword* mRanks; //!< Two lists, swapped each pass - udword* mRanks2; - // Stats - udword mTotalCalls; //!< Total number of calls to the sort routine - udword mNbHits; //!< Number of early exits due to coherence - - // Internal methods - void CheckResize(udword nb); - bool Resize(udword nb); -}; - -#endif // __ICERADIXSORT_H__ diff --git a/RecoTracker/MkFitCore/src/Ice/IceTypes.h b/RecoTracker/MkFitCore/src/Ice/IceTypes.h deleted file mode 100644 index fcb4f2209074b..0000000000000 --- a/RecoTracker/MkFitCore/src/Ice/IceTypes.h +++ /dev/null @@ -1,119 +0,0 @@ -//---------------------------------------------------------------------- -/** - * Contains custom types. - * \file IceTypes.h - * \author Pierre Terdiman - * \date April, 4, 2000 - */ -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -// Include Guard -#ifndef RecoTracker_MkFitCore_src_Ice_IceTypes_h -#define RecoTracker_MkFitCore_src_Ice_IceTypes_h - -#include -#include - -#define inline_ inline - -// Constants -const float PI = 3.14159265358979323846f; //!< PI -const float HALFPI = 1.57079632679489661923f; //!< 0.5 * PI -const float TWOPI = 6.28318530717958647692f; //!< 2.0 * PI -const float INVPI = 0.31830988618379067154f; //!< 1.0 / PI - -const float RADTODEG = 57.2957795130823208768f; //!< 180.0 / PI -const float DEGTORAD = 0.01745329251994329577f; //!< PI / 180.0 - -const float EXP = 2.71828182845904523536f; //!< e -const float INVLOG2 = 3.32192809488736234787f; //!< 1.0 / log10(2) -const float LN2 = 0.693147180559945f; //!< ln(2) -const float INVLN2 = 1.44269504089f; //!< 1.0f / ln(2) - -const float INV3 = 0.33333333333333333333f; //!< 1/3 -const float INV6 = 0.16666666666666666666f; //!< 1/6 -const float INV7 = 0.14285714285714285714f; //!< 1/7 -const float INV9 = 0.11111111111111111111f; //!< 1/9 -const float INV255 = 0.00392156862745098039f; //!< 1/255 - -const float SQRT2 = 1.41421356237f; //!< sqrt(2) -const float INVSQRT2 = 0.707106781188f; //!< 1 / sqrt(2) - -const float SQRT3 = 1.73205080757f; //!< sqrt(3) -const float INVSQRT3 = 0.577350269189f; //!< 1 / sqrt(3) - -// Custom types used in ICE -typedef signed char sbyte; //!< sizeof(sbyte) must be 1 -typedef unsigned char ubyte; //!< sizeof(ubyte) must be 1 -typedef signed short sword; //!< sizeof(sword) must be 2 -typedef unsigned short uword; //!< sizeof(uword) must be 2 -typedef signed int sdword; //!< sizeof(sdword) must be 4 -typedef unsigned int udword; //!< sizeof(udword) must be 4 -typedef signed long long sqword; //!< sizeof(sqword) must be 8 -typedef unsigned long long uqword; //!< sizeof(uqword) must be 8 - -// Added by M. Tadel (needed for 64-bit port) -typedef unsigned long sxword; //!< pointer-sized signed integer -typedef unsigned long uxword; //!< pointer-sized unsigned integer - -const udword OPC_INVALID_ID = 0xffffffff; //!< Invalid dword ID (counterpart of 0 pointers) -const udword INVALID_NUMBER = 0xDEADBEEF; //!< Standard junk value - -// Type ranges -const sbyte MAX_SBYTE = 0x7f; //!< max possible sbyte value -const sbyte MIN_SBYTE = 0x80; //!< min possible sbyte value -const ubyte MAX_UBYTE = 0xff; //!< max possible ubyte value -const ubyte MIN_UBYTE = 0x00; //!< min possible ubyte value -const sword MAX_SWORD = 0x7fff; //!< max possible sword value -const sword MIN_SWORD = 0x8000; //!< min possible sword value -const uword MAX_UWORD = 0xffff; //!< max possible uword value -const uword MIN_UWORD = 0x0000; //!< min possible uword value -const sdword MAX_SDWORD = 0x7fffffff; //!< max possible sdword value -const sdword MIN_SDWORD = 0x80000000; //!< min possible sdword value -const udword MAX_UDWORD = 0xffffffff; //!< max possible udword value -const udword MIN_UDWORD = 0x00000000; //!< min possible udword value - -const float MAX_FLOAT = FLT_MAX; //!< max possible float value -const float MIN_FLOAT = -FLT_MAX; //!< min possible loat value -const float ONE_OVER_RAND_MAX = 1.0f / float(RAND_MAX); //!< Inverse of the max possible value returned by rand() - -const udword IEEE_1_0 = 0x3f800000; //!< integer representation of 1.0 -const udword IEEE_255_0 = 0x437f0000; //!< integer representation of 255.0 -const udword IEEE_MAX_FLOAT = 0x7f7fffff; //!< integer representation of MAX_FLOAT -const udword IEEE_MIN_FLOAT = 0xff7fffff; //!< integer representation of MIN_FLOAT -const udword IEEE_UNDERFLOW_LIMIT = 0x1a000000; - -#undef MIN -#undef MAX -#define MIN(a, b) ((a) < (b) ? (a) : (b)) //!< Returns the min value between a and b -#define MAX(a, b) ((a) > (b) ? (a) : (b)) //!< Returns the max value between a and b -#define MAXMAX(a, b, c) ((a) > (b) ? MAX(a, c) : MAX(b, c)) //!< Returns the max value between a, b and c - -template -inline_ const T& TMin(const T& a, const T& b) { - return b < a ? b : a; -} -template -inline_ const T& TMax(const T& a, const T& b) { - return a < b ? b : a; -} -template -inline_ void TSetMin(T& a, const T& b) { - if (a > b) - a = b; -} -template -inline_ void TSetMax(T& a, const T& b) { - if (a < b) - a = b; -} - -#ifdef _WIN32 -#define srand48(x) srand((unsigned int)(x)) -#define srandom(x) srand((unsigned int)(x)) -#define random() ((double)rand()) -#define drand48() ((double)(((double)rand()) / ((double)RAND_MAX))) -#endif - -#endif // __ICETYPES_H__ diff --git a/RecoTracker/MkFitCore/src/MkFinder.cc b/RecoTracker/MkFitCore/src/MkFinder.cc index 3f9df7f203345..575e6aef5fae0 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.cc +++ b/RecoTracker/MkFitCore/src/MkFinder.cc @@ -227,7 +227,8 @@ namespace mkfit { void MkFinder::selectHitIndices(const LayerOfHits &layer_of_hits, const int N_proc) { // bool debug = true; - + using bidx_t = LayerOfHits::bin_index_t; + using bcnt_t = LayerOfHits::bin_content_t; const LayerOfHits &L = layer_of_hits; const IterationLayerConfig &ILC = *m_iteration_layer_config; @@ -242,7 +243,7 @@ namespace mkfit { N_proc); float dqv[NN], dphiv[NN], qv[NN], phiv[NN]; - int qb1v[NN], qb2v[NN], qbv[NN], pb1v[NN], pb2v[NN]; + bidx_t qb1v[NN], qb2v[NN], qbv[NN], pb1v[NN], pb2v[NN]; const auto assignbins = [&](int itrack, float q, @@ -264,7 +265,7 @@ namespace mkfit { qbv[itrack] = L.qBinChecked(q); qb1v[itrack] = L.qBinChecked(q - dq); qb2v[itrack] = L.qBinChecked(q + dq) + 1; - pb1v[itrack] = L.phiBin(phi - dphi); + pb1v[itrack] = L.phiBin(phi - dphi); // phi masks applied in loop pb2v[itrack] = L.phiBin(phi + dphi) + 1; }; @@ -362,11 +363,11 @@ namespace mkfit { continue; } - const int qb = qbv[itrack]; - const int qb1 = qb1v[itrack]; - const int qb2 = qb2v[itrack]; - const int pb1 = pb1v[itrack]; - const int pb2 = pb2v[itrack]; + const bidx_t qb = qbv[itrack]; + const bidx_t qb1 = qb1v[itrack]; + const bidx_t qb2 = qb2v[itrack]; + const bidx_t pb1 = pb1v[itrack]; + const bidx_t pb2 = pb2v[itrack]; // Used only by usePhiQArrays const float q = qv[itrack]; @@ -374,7 +375,7 @@ namespace mkfit { const float dphi = dphiv[itrack]; const float dq = dqv[itrack]; - dprintf(" %2d/%2d: %6.3f %6.3f %6.6f %7.5f %3d %3d %4d %4d\n", + dprintf(" %2d/%2d: %6.3f %6.3f %6.6f %7.5f %3u %3u %4u %4u\n", L.layer_id(), itrack, q, @@ -416,12 +417,12 @@ namespace mkfit { } #endif - for (int qi = qb1; qi < qb2; ++qi) { - for (int pi = pb1; pi < pb2; ++pi) { - const int pb = L.phiMaskApply(pi); + for (bidx_t qi = qb1; qi < qb2; ++qi) { + for (bidx_t pi = pb1; pi < pb2; ++pi) { + const bidx_t pb = L.phiMaskApply(pi); // Limit to central Q-bin - if (qi == qb && L.phi_bin_dead(qi, pb) == true) { + if (qi == qb && L.isBinDead(pb, qi) == true) { dprint("dead module for track in layer=" << L.layer_id() << " qb=" << qi << " pb=" << pb << " q=" << q << " phi=" << phi); m_XWsrResult[itrack].m_in_gap = true; @@ -435,15 +436,15 @@ namespace mkfit { //SK: ~20x1024 bin sizes give mostly 1 hit per bin. Commented out for 128 bins or less // #pragma nounroll - auto pbi = L.phi_bin_info(qi, pb); - for (uint16_t hi = pbi.first; hi < pbi.second; ++hi) { + auto pbi = L.phiQBinContent(pb, qi); + for (bcnt_t hi = pbi.begin(); hi < pbi.end(); ++hi) { // MT: Access into m_hit_zs and m_hit_phis is 1% run-time each. - int hi_orig = L.getOriginalHitIndex(hi); + unsigned int hi_orig = L.getOriginalHitIndex(hi); if (m_iteration_hit_mask && (*m_iteration_hit_mask)[hi_orig]) { dprintf( - "Yay, denying masked hit on layer %d, hi %d, orig idx %d\n", L.layer_info()->layer_id(), hi, hi_orig); + "Yay, denying masked hit on layer %u, hi %u, orig idx %u\n", L.layer_info()->layer_id(), hi, hi_orig); continue; } @@ -671,7 +672,7 @@ namespace mkfit { if (ddphi >= dphi) continue; - dprintf(" SHI %3d %4d %4d %5d %6.3f %6.3f %6.4f %7.5f %s\n", + dprintf(" SHI %3u %4u %4u %5u %6.3f %6.3f %6.4f %7.5f %s\n", qi, pi, pb, From b74a3864e279b142ac7eb4e2059f74ae3b9830af Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Sun, 10 Apr 2022 23:26:24 -0700 Subject: [PATCH 06/57] Fixes and improvements in usage of binnor. --- .../MkFitCore/interface/HitStructures.h | 4 +- RecoTracker/MkFitCore/interface/binnor.h | 4 +- RecoTracker/MkFitCore/src/HitStructures.cc | 32 ++-- RecoTracker/MkFitCore/src/MkFinder.cc | 165 ++++++------------ 4 files changed, 70 insertions(+), 135 deletions(-) diff --git a/RecoTracker/MkFitCore/interface/HitStructures.h b/RecoTracker/MkFitCore/interface/HitStructures.h index 6f63d90c589b2..13299358a9a33 100644 --- a/RecoTracker/MkFitCore/interface/HitStructures.h +++ b/RecoTracker/MkFitCore/interface/HitStructures.h @@ -25,8 +25,8 @@ namespace mkfit { public: using bin_index_t = unsigned short; using bin_content_t = unsigned int; - using axis_phi_t = axis_pow2_u1; - using axis_eta_t = axis; + using axis_phi_t = axis_pow2_u1; + using axis_eta_t = axis; using binnor_t = binnor; // Initializator diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index 171ee74ae2de8..c6db75b068fac 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -52,8 +52,8 @@ namespace mkfit { assert(N_size <= (1 << N)); } - I from_R_to_M_bin(R r) const { return (r - m_R_min) * m_M_fac; } - I from_R_to_N_bin(R r) const { return (r - m_R_min) * m_N_fac; } + I from_R_to_M_bin(R r) const { return std::floor((r - m_R_min) * m_M_fac); } + I from_R_to_N_bin(R r) const { return std::floor((r - m_R_min) * m_N_fac); } I from_R_to_M_bin_safe(R r) const { return r <= m_R_min ? 0 : (r >= m_R_max ? m_last_M_bin : from_R_to_M_bin(r)); } I from_R_to_N_bin_safe(R r) const { return r <= m_R_min ? 0 : (r >= m_R_max ? m_last_N_bin : from_R_to_N_bin(r)); } diff --git a/RecoTracker/MkFitCore/src/HitStructures.cc b/RecoTracker/MkFitCore/src/HitStructures.cc index 8ab6019b5a435..0247f3276919b 100644 --- a/RecoTracker/MkFitCore/src/HitStructures.cc +++ b/RecoTracker/MkFitCore/src/HitStructures.cc @@ -96,7 +96,7 @@ namespace mkfit { m_binnor.finalize_registration(); for (unsigned int i = 0; i < m_n_hits; ++i) { - int j = m_binnor.m_ranks[i]; + unsigned int j = m_binnor.m_ranks[i]; #ifdef COPY_SORTED_HITS memcpy(&m_hits[i], &hitv[j], sizeof(Hit)); #endif @@ -113,23 +113,15 @@ namespace mkfit { m_dead_bins.assign(m_dead_bins.size(), false); for (const auto &d : deadv) { - bin_index_t q_bin_1 = m_ax_eta.from_R_to_N_bin_safe(d.q1); - bin_index_t q_bin_2 = m_ax_eta.from_R_to_N_bin_safe(d.q2) + 1; - bin_index_t phi_bin_1 = m_ax_phi.from_R_to_N_bin_safe(d.phi1); - bin_index_t phi_bin_2 = m_ax_phi.from_R_to_N_bin_safe(d.phi2) + 1; - for (bin_index_t q_bin = q_bin_1; q_bin < q_bin_2; q_bin++) { - unsigned int qoff = q_bin * m_ax_phi.size_of_N(); - if (phi_bin_1 > phi_bin_2) { - for (bin_index_t pb = phi_bin_1; pb <= m_ax_phi.m_last_N_bin; pb++) { + bin_index_t q_bin_1 = qBinChecked(d.q1); + bin_index_t q_bin_2 = qBinChecked(d.q2) + 1; + bin_index_t phi_bin_1 = phiBin(d.phi1); + bin_index_t phi_bin_2 = phiMaskApply(phiBin(d.phi2) + 1); + + for (bin_index_t q_bin = q_bin_1; q_bin != q_bin_2; q_bin++) { + const unsigned int qoff = q_bin * m_ax_phi.size_of_N(); + for (bin_index_t pb = phi_bin_1; pb != phi_bin_2; pb = phiMaskApply(pb + 1)) { m_dead_bins[qoff + pb] = true; - } - for (bin_index_t pb = 0; pb < phi_bin_2; pb++) { - m_dead_bins[qoff + pb] = true; - } - } else { - for (bin_index_t pb = phi_bin_1; pb < phi_bin_2; pb++) { - m_dead_bins[qoff + pb] = true; - } } } } @@ -188,8 +180,8 @@ namespace mkfit { } for (unsigned int i = 0; i < m_n_hits; ++i) { - int j = m_binnor.m_ranks[i]; // index in intermediate - int k = m_ext_idcs[j]; // index in external hit_vec + unsigned int j = m_binnor.m_ranks[i]; // index in intermediate + unsigned int k = m_ext_idcs[j]; // index in external hit_vec #ifdef COPY_SORTED_HITS memcpy(&m_hits[i], &hitv[k], sizeof(Hit)); @@ -235,7 +227,7 @@ namespace mkfit { void LayerOfHits::printBins() { for (bin_index_t qb = 0; qb <= m_ax_eta.m_last_N_bin; ++qb) { printf("%c bin %d\n", is_barrel() ? 'Z' : 'R', qb); - for (bin_index_t pb = 0; pb < m_ax_phi.m_last_N_bin; ++pb) { + for (bin_index_t pb = 0; pb <= m_ax_phi.m_last_N_bin; ++pb) { if (pb % 8 == 0) printf(" Phi %4d: ", pb); auto content = m_binnor.get_content(pb, qb); diff --git a/RecoTracker/MkFitCore/src/MkFinder.cc b/RecoTracker/MkFitCore/src/MkFinder.cc index 575e6aef5fae0..a03a9837194aa 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.cc +++ b/RecoTracker/MkFitCore/src/MkFinder.cc @@ -265,8 +265,8 @@ namespace mkfit { qbv[itrack] = L.qBinChecked(q); qb1v[itrack] = L.qBinChecked(q - dq); qb2v[itrack] = L.qBinChecked(q + dq) + 1; - pb1v[itrack] = L.phiBin(phi - dphi); // phi masks applied in loop - pb2v[itrack] = L.phiBin(phi + dphi) + 1; + pb1v[itrack] = L.phiBinChecked(phi - dphi); + pb2v[itrack] = L.phiMaskApply(L.phiBin(phi + dphi) + 1); }; const auto calcdphi2 = [&](int itrack, float dphidx, float dphidy) { @@ -374,19 +374,11 @@ namespace mkfit { const float phi = phiv[itrack]; const float dphi = dphiv[itrack]; const float dq = dqv[itrack]; - + // clang-format off dprintf(" %2d/%2d: %6.3f %6.3f %6.6f %7.5f %3u %3u %4u %4u\n", - L.layer_id(), - itrack, - q, - phi, - dq, - dphi, - qb1, - qb2, - pb1, - pb2); - + L.layer_id(), itrack, q, phi, dq, dphi, + qb1, qb2, pb1, pb2); + // clang-format on // MT: One could iterate in "spiral" order, to pick hits close to the center. // http://stackoverflow.com/questions/398299/looping-in-a-spiral // This would then work best with relatively small bin sizes. @@ -417,13 +409,11 @@ namespace mkfit { } #endif - for (bidx_t qi = qb1; qi < qb2; ++qi) { - for (bidx_t pi = pb1; pi < pb2; ++pi) { - const bidx_t pb = L.phiMaskApply(pi); - + for (bidx_t qi = qb1; qi != qb2; ++qi) { + for (bidx_t pi = pb1; pi != pb2; pi = L.phiMaskApply(pi + 1)) { // Limit to central Q-bin - if (qi == qb && L.isBinDead(pb, qi) == true) { - dprint("dead module for track in layer=" << L.layer_id() << " qb=" << qi << " pb=" << pb << " q=" << q + if (qi == qb && L.isBinDead(pi, qi) == true) { + dprint("dead module for track in layer=" << L.layer_id() << " qb=" << qi << " pi=" << pi << " q=" << q << " phi=" << phi); m_XWsrResult[itrack].m_in_gap = true; } @@ -436,7 +426,7 @@ namespace mkfit { //SK: ~20x1024 bin sizes give mostly 1 hit per bin. Commented out for 128 bins or less // #pragma nounroll - auto pbi = L.phiQBinContent(pb, qi); + auto pbi = L.phiQBinContent(pi, qi); for (bcnt_t hi = pbi.begin(); hi < pbi.end(); ++hi) { // MT: Access into m_hit_zs and m_hit_phis is 1% run-time each. @@ -584,85 +574,44 @@ namespace mkfit { if (!(std::isnan(phi)) && !(std::isnan(getEta(m_Par[iI].At(itrack, 5, 0))))) { //|| std::isnan(ter) || std::isnan(her) || std::isnan(m_Chi2(itrack, 0, 0)) || std::isnan(hchi2))) - printf( - "HITWINDOWSEL " - "%d " - "%d %d %d " - "%d %d %d " - "%6.3f %6.3f %6.3f %6.3f " - "%d " - "%d %d %d %d " - "%d " - "%d %d %d " - "%6.3f %6.3f %6.3f " - "%d %d %6.3f %6.3f " - "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f " - "%6.3f %6.3f %6.3f %6.3f %6.3f " - "%6.6f %6.6f %6.6f %6.6f %6.6f " - "%6.3f %6.3f %6.3f %6.3f %6.3f " - "%6.6f %6.6f %6.6f %6.6f %6.6f " - "%6.3f %6.3f %6.3f " - "%6.3f" - "\n", - m_event->evtID(), - L.layer_id(), - L.is_barrel(), - L.getOriginalHitIndex(hi), - itrack, - m_CandIdx(itrack, 0, 0), - m_Label(itrack, 0, 0), - 1.0f / m_Par[iI].At(itrack, 3, 0), - getEta(m_Par[iI].At(itrack, 5, 0)), - m_Par[iI].At(itrack, 4, 0), - m_Chi2(itrack, 0, 0), - m_NFoundHits(itrack, 0, 0), - m_SeedIdx(itrack, 0, 0), - m_SeedLabel(itrack, 0, 0), - m_SeedAlgo(itrack, 0, 0), - thisseedmcid, - mchid, - st_isfindable, - st_prodtype, - st_label, - st_pt, - st_eta, - st_phi, - st_nhits, - st_charge, - st_r, - st_z, - q, - L.hit_q(hi), - ddq, - dq, - phi, - L.hit_phi(hi), - ddphi, - dphi, - tx, - ty, - tr, - tphi, - tz, - tex, - tey, - ter, - tephi, - tez, - hx, - hy, - hr, - hphi, - hz, - hex, - hey, - her, - hephi, - hez, - ht_dxy, - ht_dz, - ht_dphi, - hchi2); + // clang-format off + printf("HITWINDOWSEL " + "%d " + "%d %d %d " + "%d %d %d " + "%6.3f %6.3f %6.3f %6.3f " + "%d " + "%d %d %d %d " + "%d " + "%d %d %d " + "%6.3f %6.3f %6.3f " + "%d %d %6.3f %6.3f " + "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f " + "%6.3f %6.3f %6.3f %6.3f %6.3f " + "%6.6f %6.6f %6.6f %6.6f %6.6f " + "%6.3f %6.3f %6.3f %6.3f %6.3f " + "%6.6f %6.6f %6.6f %6.6f %6.6f " + "%6.3f %6.3f %6.3f " + "%6.3f" + "\n", + m_event->evtID(), + L.layer_id(), L.is_barrel(), L.getOriginalHitIndex(hi), + itrack, m_CandIdx(itrack, 0, 0), m_Label(itrack, 0, 0), + 1.0f / m_Par[iI].At(itrack, 3, 0), getEta(m_Par[iI].At(itrack, 5, 0)), m_Par[iI].At(itrack, 4, 0), m_Chi2(itrack, 0, 0), + m_NFoundHits(itrack, 0, 0), + m_SeedIdx(itrack, 0, 0), m_SeedLabel(itrack, 0, 0), m_SeedAlgo(itrack, 0, 0), thisseedmcid, + mchid, + st_isfindable, st_prodtype, st_label, + st_pt, st_eta, st_phi, + st_nhits, st_charge, st_r, st_z, + q, L.hit_q(hi), ddq, dq, phi, L.hit_phi(hi), ddphi, dphi, + tx, ty, tr, tphi, tz, + tex, tey, ter, tephi, tez, + hx, hy, hr, hphi, hz, + hex, hey, her, hephi, hez, + ht_dxy, ht_dz, ht_dphi, + hchi2); + // clang-format ofn } } #endif @@ -671,17 +620,11 @@ namespace mkfit { continue; if (ddphi >= dphi) continue; - - dprintf(" SHI %3u %4u %4u %5u %6.3f %6.3f %6.4f %7.5f %s\n", - qi, - pi, - pb, - hi, - L.hit_q(hi), - L.hit_phi(hi), - ddq, - ddphi, - (ddq < dq && ddphi < dphi) ? "PASS" : "FAIL"); + // clang-format off + dprintf(" SHI %3u %4u %5u %6.3f %6.3f %6.4f %7.5f %s\n", + qi, pi, hi, L.hit_q(hi), L.hit_phi(hi), + ddq, ddphi, (ddq < dq && ddphi < dphi) ? "PASS" : "FAIL"); + // clang-format on // MT: Removing extra check gives full efficiency ... // and means our error estimations are wrong! From 9a1c59f15301e6cb38cb9841231e1a195fe43ac6 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Mon, 11 Apr 2022 15:44:51 -0700 Subject: [PATCH 07/57] Bufix - properly account for case when ranks have not yet been initialized, fix std::sort codepath, only use radix if n-entries >= 128. --- RecoTracker/MkFitCore/interface/binnor.h | 17 +++++++++-------- RecoTracker/MkFitCore/src/radix_sort.cc | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index c6db75b068fac..e71d2dd69b678 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace mkfit { @@ -262,7 +263,6 @@ namespace mkfit { } void register_entry(B_pair bp) { - m_cons.emplace_back(bp); if (m_keep_cons) m_cons.push_back(bp); if (m_do_masked) @@ -281,19 +281,20 @@ namespace mkfit { void register_m_bins(typename A1::index_t m1, typename A2::index_t m2) { register_entry({m1, m2}); } void finalize_registration() { - if (m_radix_sort) { - radix_sort radix; + unsigned int n_entries = m_do_masked ? m_cons_masked.size() : m_cons.size(); + if (m_radix_sort && n_entries >= 128) { + radix_sort radix; radix.sort(m_cons_masked, m_ranks); } else { - m_ranks.resize(m_cons.size()); + m_ranks.resize(n_entries); std::iota(m_ranks.begin(), m_ranks.end(), 0); - if (m_keep_cons) + if (m_do_masked) + std::sort( + m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { return m_cons_masked[a] < m_cons_masked[b]; }); + else std::sort(m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { return m_cons[a].mask_A2_M_bins() < m_cons[b].mask_A2_M_bins(); }); - else - std::sort( - m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { return m_cons_masked[a] < m_cons_masked[b]; }); } for (C i = 0; i < m_ranks.size(); ++i) { diff --git a/RecoTracker/MkFitCore/src/radix_sort.cc b/RecoTracker/MkFitCore/src/radix_sort.cc index f7aed3e72b153..5a7f184632d27 100644 --- a/RecoTracker/MkFitCore/src/radix_sort.cc +++ b/RecoTracker/MkFitCore/src/radix_sort.cc @@ -1,6 +1,7 @@ #include "RecoTracker/MkFitCore/interface/radix_sort.h" #include +#include namespace mkfit { @@ -43,14 +44,15 @@ namespace mkfit { rank_t* link[256]; ranks.resize(nb); std::vector ranks2(nb); + bool ranks_are_invalid = true; // Radix sort, j is the pass number (0=LSB, 3=MSB) for (rank_t j = 0; j < c_NBytes; j++) { // Shortcut to current counters rank_t* cur_count = &histos[j << 8]; - // Get first byte - f that byte's counter equals nb, all values are the same. - ubyte_t unique_val = *(((ubyte_t*)values.data()) + j); - if (cur_count[unique_val] != nb) { + // Get first byte - if that byte's counter equals nb, all values are the same. + ubyte_t first_entry_val = *(((ubyte_t*)values.data()) + j); + if (cur_count[first_entry_val] != nb) { // Create offsets link[0] = ranks2.data(); for (rank_t i = 1; i < 256; i++) @@ -59,12 +61,13 @@ namespace mkfit { // Perform Radix Sort ubyte_t* input_bytes = (ubyte_t*)values.data(); input_bytes += j; - if (j == 0) { + if (ranks_are_invalid) { for (rank_t i = 0; i < nb; i++) *link[input_bytes[i << 2]]++ = i; + ranks_are_invalid = false; } else { - rank_t* indices = &ranks[0]; - rank_t* indices_end = &ranks[nb]; + rank_t* indices = ranks.data(); + rank_t* indices_end = indices + nb; while (indices != indices_end) { rank_t id = *indices++; *link[input_bytes[id << 2]]++ = id; @@ -75,6 +78,9 @@ namespace mkfit { ranks.swap(ranks2); } } + // If all values are equal, fill ranks with sequential integers. + if (ranks_are_invalid) + std::iota(ranks.begin(), ranks.end(), 0); } // Instantiate supported sort types. From f3680413014f34c5c8186681ae02905ad94bf3d7 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Mon, 11 Apr 2022 15:45:44 -0700 Subject: [PATCH 08/57] Use same axis parameters as in LayerOfHits; perform timing-loop multiple times. --- .../MkFitCore/standalone/test/binnor_demo.cxx | 95 +++++++++++-------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx index 0a171df1ddfff..6f29afdbc0455 100644 --- a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx +++ b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx @@ -30,15 +30,17 @@ int main() { } */ - axis eta(-2.6, 2.6, 20u); + axis eta(-2.6, 2.6, 20u); printf("Axis eta: M-bits=%d, N-bits=%d m_bins=%d n_bins=%d\n", eta.c_M, eta.c_N, eta.size_of_M(), eta.size_of_N()); - const int NN = 100000; - const bool use_radix = true; - const bool keep_cons = false; + const int NLoop = 100; // Number of time to repeat the loop. + const int NN = 1000; // Number of tracks (eta, phi pairs) to bin. + const bool print_bin_contents = false; + const bool use_radix = true; // NOTE: radix_sort will automatically switch to std::sort for NN < 128 + const bool keep_cons = true; - binnor b(phi, eta, use_radix, keep_cons); + binnor b(phi, eta, use_radix, keep_cons); // typedef typeof(b) type_b; printf("Have binnor, size of vec = %zu, sizeof(C_pair) = %d\n", b.m_bins.size(), sizeof(decltype(b)::C_pair)); @@ -52,25 +54,34 @@ int main() { }; std::vector tracks; tracks.reserve(NN); - - auto start = std::chrono::high_resolution_clock::now(); - - b.begin_registration(NN); // optional, reserves construction vector - for (int i = 0; i < NN; ++i) { tracks.push_back({d_phi(rnd), d_eta(rnd)}); - b.register_entry(tracks.back().phi, tracks.back().eta); // printf("made track %3d: phi=%f eta=%f\n", i, tracks.back().phi, tracks.back().eta); } - auto reg_start = std::chrono::high_resolution_clock::now(); + std::chrono::duration duration, fill_duration, sort_duration; + + for (int n_loop = 0; n_loop < NLoop; ++n_loop) { + b.reset_contents(false); // do not shrink the vectors - b.finalize_registration(); + auto start = std::chrono::high_resolution_clock::now(); + + b.begin_registration(NN); // NN optional, reserves construction vector + + for (int i = 0; i < NN; ++i) { + b.register_entry(tracks[i].phi, tracks[i].eta); + } - auto stop = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast(stop - start); - auto fill_duration = std::chrono::duration_cast(reg_start - start); - auto sort_duration = std::chrono::duration_cast(stop - reg_start); + auto reg_start = std::chrono::high_resolution_clock::now(); + + b.finalize_registration(); + + auto stop = std::chrono::high_resolution_clock::now(); + + duration += std::chrono::duration_cast(stop - start); + fill_duration += std::chrono::duration_cast(reg_start - start); + sort_duration += std::chrono::duration_cast(stop - reg_start); + } // for (int i = 0; i < NN; ++i) // { @@ -78,35 +89,37 @@ int main() { // printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); // } - printf("\n\n--- Single bin access for (phi, eta) = (0,0):\n\n"); - auto nbin = b.get_n_bin(0.f, 0.f); - auto cbin = b.get_content(0.f, 0.f); - printf("For (phi 0, eta 0; %u, %u) got first %d, count %d\n", nbin.bin1(), nbin.bin2(), cbin.first, cbin.count); - for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { - const track &t = tracks[b.m_ranks[i]]; - printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); - } + if (print_bin_contents) { + printf("\n\n--- Single bin access for (phi, eta) = (0,0):\n\n"); + auto nbin = b.get_n_bin(0.f, 0.f); + auto cbin = b.get_content(0.f, 0.f); + printf("For (phi 0, eta 0; %u, %u) got first %d, count %d\n", nbin.bin1(), nbin.bin2(), cbin.first, cbin.count); + for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { + const track &t = tracks[b.m_ranks[i]]; + printf("%3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); + } - printf("\n\n--- Range access for phi=[(-PI+0.02 +- 0.1], eta=[1.3 +- .2]:\n\n"); - auto phi_rng = phi.from_R_rdr_to_N_bins(-PI + 0.02, 0.1); - auto eta_rng = eta.from_R_rdr_to_N_bins(1.3, .2); - printf("phi bin range: %u, %u; eta %u, %u\n", phi_rng.begin, phi_rng.end, eta_rng.begin, eta_rng.end); - for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = phi.next_N_bin(i_phi)) { - for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = eta.next_N_bin(i_eta)) { - printf(" at i_phi=%u, i_eta=%u\n", i_phi, i_eta); - auto cbin = b.get_content(i_phi, i_eta); - for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { - const track &t = tracks[b.m_ranks[i]]; - printf(" %3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); + printf("\n\n--- Range access for phi=[(-PI+0.02 +- 0.1], eta=[1.3 +- .2]:\n\n"); + auto phi_rng = phi.from_R_rdr_to_N_bins(-PI + 0.02, 0.1); + auto eta_rng = eta.from_R_rdr_to_N_bins(1.3, .2); + printf("phi bin range: %u, %u; eta %u, %u\n", phi_rng.begin, phi_rng.end, eta_rng.begin, eta_rng.end); + for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = phi.next_N_bin(i_phi)) { + for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = eta.next_N_bin(i_eta)) { + printf(" at i_phi=%u, i_eta=%u\n", i_phi, i_eta); + auto cbin = b.get_content(i_phi, i_eta); + for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { + const track &t = tracks[b.m_ranks[i]]; + printf(" %3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); + } } } } - printf("\nProcessing time for %d points: %f sec (filling %f sec, sort + binning %f sec)\n", - NN, - 1.e-6 * duration.count(), - 1.e-6 * fill_duration.count(), - 1.e-6 * sort_duration.count()); + printf("\nProcessing time for %d times %d points: %f sec (filling %f sec, sort + binning %f sec)\n", + NLoop, NN, + 1.e-9 * duration.count(), + 1.e-9 * fill_duration.count(), + 1.e-9 * sort_duration.count()); b.reset_contents(); From c4bab3462bba85a4f9b5a01b26fa54d5071245b8 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Mon, 11 Apr 2022 23:44:04 -0700 Subject: [PATCH 09/57] Improve std-vs-radix sort heuristic, cleanup innor_demo.cxx. --- RecoTracker/MkFitCore/interface/binnor.h | 2 +- RecoTracker/MkFitCore/src/HitStructures.cc | 2 +- .../MkFitCore/standalone/test/binnor_demo.cxx | 81 ++++++++++++------- 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index e71d2dd69b678..c273d857bfb2d 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -282,7 +282,7 @@ namespace mkfit { void finalize_registration() { unsigned int n_entries = m_do_masked ? m_cons_masked.size() : m_cons.size(); - if (m_radix_sort && n_entries >= 128) { + if (m_radix_sort && n_entries >= (m_keep_cons ? 128 : 256)) { radix_sort radix; radix.sort(m_cons_masked, m_ranks); } else { diff --git a/RecoTracker/MkFitCore/src/HitStructures.cc b/RecoTracker/MkFitCore/src/HitStructures.cc index 0247f3276919b..b4201f6475757 100644 --- a/RecoTracker/MkFitCore/src/HitStructures.cc +++ b/RecoTracker/MkFitCore/src/HitStructures.cc @@ -121,7 +121,7 @@ namespace mkfit { for (bin_index_t q_bin = q_bin_1; q_bin != q_bin_2; q_bin++) { const unsigned int qoff = q_bin * m_ax_phi.size_of_N(); for (bin_index_t pb = phi_bin_1; pb != phi_bin_2; pb = phiMaskApply(pb + 1)) { - m_dead_bins[qoff + pb] = true; + m_dead_bins[qoff + pb] = true; } } } diff --git a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx index 6f29afdbc0455..c0d90db17084e 100644 --- a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx +++ b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx @@ -1,26 +1,70 @@ -#include "../../interface/binnor.h" #include #include #include "../../interface/radix_sort.h" +#include "../../src/radix_sort.cc" +#include "../../interface/binnor.h" // build as: -// c++ -o binnor_demo -std=c++17 binnor_demo.cxx -// with radix_sort: -// c++ -o binnor_demo -O3 -mavx2 -std=c++17 binnor_demo.cxx -I../../../.. ../../src/radix_sort.cc +// c++ -o binnor_demo -O3 -mavx2 -std=c++17 -I../../../.. binnor_demo.cxx + +bool print_axis_binnor = true; +bool print_bin_contents = true; + +void run_scan(); +void run_test(const int NLoop, int NN, const bool use_radix = true, const bool keep_cons = false); using namespace mkfit; -int main() { +int main() +{ + bool use_radix = true; + bool keep_cons = false; + run_test(100, 10000, use_radix, keep_cons); + + // Run scan over low N-elements to see where radix starts to make more sense. + // NOTE: In binnor.h, finalize_registration(), comment-out the existing heuristics + // that uses std::sort over radix when NN < 256 (128 with keep_cons). + // run_scan(); + +} + +// ------------------------------------------------------------- + +void run_scan() +{ + print_axis_binnor = false; + print_bin_contents = false; + + const bool radix[] = { true, true, false, false }; + const bool keepc[] = { false, true, false, true }; + + for (int t = 0; t < 4; ++t) { + printf("RADIX=%s KEEP-CONS=%s\n", radix[t] ? "true" : "false", keepc[t] ? "true" : "false"); + for (int i = 100; i <= 400; i += 10) { + run_test(100000, i, radix[t], keepc[t]); + } + printf("\n"); + } +} + +// ------------------------------------------------------------- + +void run_test(const int NLoop, int NN, const bool use_radix, const bool keep_cons) { constexpr float PI = 3.14159265358979323846; constexpr float TwoPI = 6.28318530717958647692; constexpr float PIOver2 = PI / 2.0f; constexpr float PIOver4 = PI / 4.0f; axis_pow2_u1 phi(-PI, PI); + axis eta(-2.6, 2.6, 20u); + binnor b(phi, eta, use_radix, keep_cons); - printf("Axis phi: M-bits=%d, N-bits=%d Masks M:0x%x N:0x%x\n", phi.c_M, phi.c_N, phi.c_M_mask, phi.c_N_mask); - + if (print_axis_binnor) { + printf("Axis phi: M-bits=%d, N-bits=%d Masks M:0x%x N:0x%x\n", phi.c_M, phi.c_N, phi.c_M_mask, phi.c_N_mask); + printf("Axis eta: M-bits=%d, N-bits=%d m_bins=%d n_bins=%d\n", eta.c_M, eta.c_N, eta.size_of_M(), eta.size_of_N()); + printf("Have binnor, size of vec = %zu, sizeof(C_pair) = %d\n", b.m_bins.size(), sizeof(decltype(b)::C_pair)); + } /* for (float p = -TwoPI; p < TwoPI; p += TwoPI / 15.4f) { printf(" phi=%-9f m=%5d n=%3d m2n=%3d n_safe=%3d\n", p, @@ -30,21 +74,6 @@ int main() { } */ - axis eta(-2.6, 2.6, 20u); - - printf("Axis eta: M-bits=%d, N-bits=%d m_bins=%d n_bins=%d\n", eta.c_M, eta.c_N, eta.size_of_M(), eta.size_of_N()); - - const int NLoop = 100; // Number of time to repeat the loop. - const int NN = 1000; // Number of tracks (eta, phi pairs) to bin. - const bool print_bin_contents = false; - const bool use_radix = true; // NOTE: radix_sort will automatically switch to std::sort for NN < 128 - const bool keep_cons = true; - - binnor b(phi, eta, use_radix, keep_cons); - - // typedef typeof(b) type_b; - printf("Have binnor, size of vec = %zu, sizeof(C_pair) = %d\n", b.m_bins.size(), sizeof(decltype(b)::C_pair)); - std::mt19937 rnd(std::random_device{}()); std::uniform_real_distribution d_phi(-PI, PI); std::uniform_real_distribution d_eta(-2.55, 2.55); @@ -60,6 +89,7 @@ int main() { } std::chrono::duration duration, fill_duration, sort_duration; + duration = fill_duration = sort_duration = std::chrono::nanoseconds::zero(); for (int n_loop = 0; n_loop < NLoop; ++n_loop) { b.reset_contents(false); // do not shrink the vectors @@ -113,15 +143,12 @@ int main() { } } } + printf("\n"); } - printf("\nProcessing time for %d times %d points: %f sec (filling %f sec, sort + binning %f sec)\n", + printf("Processing time for %d times %d points: %f sec (filling %f sec, sort + binning %f sec)\n", NLoop, NN, 1.e-9 * duration.count(), 1.e-9 * fill_duration.count(), 1.e-9 * sort_duration.count()); - - b.reset_contents(); - - return 0; } From dd2f00a351376cef1db5e6f3b1884284cc89a10b Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Wed, 13 Apr 2022 22:27:08 -0700 Subject: [PATCH 10/57] Fix clamping of real to safe-bin-index calculation, skip empty binned entries in loops over bins. --- RecoTracker/MkFitCMS/src/MkStdSeqs.cc | 2 ++ RecoTracker/MkFitCore/interface/binnor.h | 5 +++-- RecoTracker/MkFitCore/src/MkFinder.cc | 2 ++ RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RecoTracker/MkFitCMS/src/MkStdSeqs.cc b/RecoTracker/MkFitCMS/src/MkStdSeqs.cc index 212ad43d1628e..88507b9702789 100644 --- a/RecoTracker/MkFitCMS/src/MkStdSeqs.cc +++ b/RecoTracker/MkFitCMS/src/MkStdSeqs.cc @@ -185,6 +185,8 @@ namespace mkfit { for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = ax_phi.next_N_bin(i_phi)) { for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = ax_eta.next_N_bin(i_eta)) { const auto cbin = phi_eta_binnor.get_content(i_phi, i_eta); + if (cbin.empty()) + continue; for (auto i = cbin.first; i < cbin.end(); ++i) { int tss = phi_eta_binnor.m_ranks[i]; diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index c273d857bfb2d..48cf5e311dfbd 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -56,8 +56,8 @@ namespace mkfit { I from_R_to_M_bin(R r) const { return std::floor((r - m_R_min) * m_M_fac); } I from_R_to_N_bin(R r) const { return std::floor((r - m_R_min) * m_N_fac); } - I from_R_to_M_bin_safe(R r) const { return r <= m_R_min ? 0 : (r >= m_R_max ? m_last_M_bin : from_R_to_M_bin(r)); } - I from_R_to_N_bin_safe(R r) const { return r <= m_R_min ? 0 : (r >= m_R_max ? m_last_N_bin : from_R_to_N_bin(r)); } + I from_R_to_M_bin_safe(R r) const { return r <= m_R_min ? 0 : std::min(m_last_M_bin, from_R_to_M_bin(r)); } + I from_R_to_N_bin_safe(R r) const { return r <= m_R_min ? 0 : std::min(m_last_N_bin, from_R_to_N_bin(r)); } I from_M_bin_to_N_bin(I m) const { return m >> c_M2N_shift; } @@ -193,6 +193,7 @@ namespace mkfit { C_pair() : first(0), count(0) {} C_pair(C f, C c) : first(f), count(c) {} + bool empty() const { return count == 0; } C begin() const { return first; } C end() const { return first + count; } }; diff --git a/RecoTracker/MkFitCore/src/MkFinder.cc b/RecoTracker/MkFitCore/src/MkFinder.cc index a03a9837194aa..2864dd0e9b320 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.cc +++ b/RecoTracker/MkFitCore/src/MkFinder.cc @@ -427,6 +427,8 @@ namespace mkfit { //SK: ~20x1024 bin sizes give mostly 1 hit per bin. Commented out for 128 bins or less // #pragma nounroll auto pbi = L.phiQBinContent(pi, qi); + if (pbi.empty()) + continue; for (bcnt_t hi = pbi.begin(); hi < pbi.end(); ++hi) { // MT: Access into m_hit_zs and m_hit_phis is 1% run-time each. diff --git a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx index c0d90db17084e..0381d4dcb36b8 100644 --- a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx +++ b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx @@ -137,6 +137,8 @@ void run_test(const int NLoop, int NN, const bool use_radix, const bool keep_con for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = eta.next_N_bin(i_eta)) { printf(" at i_phi=%u, i_eta=%u\n", i_phi, i_eta); auto cbin = b.get_content(i_phi, i_eta); + if (cbin.empty()) + continue; for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { const track &t = tracks[b.m_ranks[i]]; printf(" %3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); From cb4b7ce5d99751cc00bff796a978fbd28c415310 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 14 Apr 2022 00:21:17 -0700 Subject: [PATCH 11/57] Make safe-bin-index calculation safe also when bin-axis uses up all index-type bits. --- RecoTracker/MkFitCore/interface/binnor.h | 37 ++++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index 48cf5e311dfbd..426299d0e02d1 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -26,12 +26,13 @@ namespace mkfit { typedef R real_t; typedef I index_t; - static constexpr unsigned c_M = M; - static constexpr unsigned c_N = N; - static constexpr unsigned c_M2N_shift = M - N; + static constexpr unsigned int c_M = M; + static constexpr unsigned int c_N = N; + static constexpr unsigned int c_M2N_shift = M - N; const R m_R_min, m_R_max; const R m_M_fac, m_N_fac; + const R m_M_lbhp, m_N_lbhp; // last bin half-posts const I m_last_M_bin, m_last_N_bin; struct I_pair { @@ -42,22 +43,26 @@ namespace mkfit { I_pair(I b, I e) : begin(b), end(e) {} }; - axis_base(R min, R max, unsigned M_size, unsigned N_size) + axis_base(R min, R max, unsigned int M_size, unsigned int N_size) : m_R_min(min), m_R_max(max), m_M_fac(M_size / (max - min)), m_N_fac(N_size / (max - min)), + m_M_lbhp(max - 0.5 / m_M_fac), + m_N_lbhp(max - 0.5 / m_N_fac), m_last_M_bin(M_size - 1), m_last_N_bin(N_size - 1) { // Requested number of bins must fit within the intended bit-field (declared by binnor, later). + assert(M_size <= (1 << M)); assert(N_size <= (1 << N)); + assert(max > min); } I from_R_to_M_bin(R r) const { return std::floor((r - m_R_min) * m_M_fac); } I from_R_to_N_bin(R r) const { return std::floor((r - m_R_min) * m_N_fac); } - I from_R_to_M_bin_safe(R r) const { return r <= m_R_min ? 0 : std::min(m_last_M_bin, from_R_to_M_bin(r)); } - I from_R_to_N_bin_safe(R r) const { return r <= m_R_min ? 0 : std::min(m_last_N_bin, from_R_to_N_bin(r)); } + I from_R_to_M_bin_safe(R r) const { return r <= m_R_min ? 0 : (r >= m_M_lbhp ? m_last_M_bin : from_R_to_M_bin(r)); } + I from_R_to_N_bin_safe(R r) const { return r <= m_R_min ? 0 : (r >= m_N_lbhp ? m_last_N_bin : from_R_to_N_bin(r)); } I from_M_bin_to_N_bin(I m) const { return m >> c_M2N_shift; } @@ -74,20 +79,20 @@ namespace mkfit { // Assumes the numbers of fine/normal bins are powers of 2 that are inferred directly from the number of bits. template struct axis_pow2_base : public axis_base { - static constexpr unsigned c_M_end = 1 << M; - static constexpr unsigned c_N_end = 1 << N; + static constexpr unsigned int c_M_end = 1 << M; + static constexpr unsigned int c_N_end = 1 << N; axis_pow2_base(R min, R max) : axis_base(min, max, c_M_end, c_N_end) {} - unsigned size_of_M() const { return c_M_end; } - unsigned size_of_N() const { return c_N_end; } + unsigned int size_of_M() const { return c_M_end; } + unsigned int size_of_N() const { return c_N_end; } }; // axis_pow2_u1 //------------- // Specialization of axis_pow2 for the "U(1)" case where the coordinate is periodic with period (Rmax - Rmin). // In the "safe" methods below, bit masking serves as the modulo operator for out-of-range bin numbers. - template + template struct axis_pow2_u1 : public axis_pow2_base { static constexpr I c_M_mask = (1 << M) - 1; static constexpr I c_N_mask = (1 << N) - 1; @@ -110,7 +115,7 @@ namespace mkfit { // axis_pow2 //---------- - template + template struct axis_pow2 : public axis_pow2_base { axis_pow2(R min, R max) : axis_pow2_base(min, max) {} }; @@ -119,7 +124,7 @@ namespace mkfit { //----- template struct axis : public axis_base { - const unsigned m_num_M_bins, m_num_N_bins; + const unsigned int m_num_M_bins, m_num_N_bins; axis(R min, R max, unsigned n_bins) : axis_base(min, max, n_bins << this->c_M2N_shift, n_bins), @@ -128,14 +133,14 @@ namespace mkfit { axis(R min, R max, R bin_width) { R extent = max - min; - unsigned n_bins = std::ceil(extent / bin_width); + unsigned int n_bins = std::ceil(extent / bin_width); R extra = (n_bins * bin_width - extent) / 2; axis(min - extra, max + extra, n_bins); } - unsigned size_of_M() const { return m_num_M_bins; } - unsigned size_of_N() const { return m_num_N_bins; } + unsigned int size_of_M() const { return m_num_M_bins; } + unsigned int size_of_N() const { return m_num_N_bins; } }; // binnor From bd01102b059c28ba0ebbf2cc6a38d0af85637f68 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 15 Apr 2022 10:54:58 -0700 Subject: [PATCH 12/57] code check, one extra space in front of an in-line comment :) --- RecoTracker/MkFitCore/interface/binnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTracker/MkFitCore/interface/binnor.h b/RecoTracker/MkFitCore/interface/binnor.h index 426299d0e02d1..c3bb150df1794 100644 --- a/RecoTracker/MkFitCore/interface/binnor.h +++ b/RecoTracker/MkFitCore/interface/binnor.h @@ -32,7 +32,7 @@ namespace mkfit { const R m_R_min, m_R_max; const R m_M_fac, m_N_fac; - const R m_M_lbhp, m_N_lbhp; // last bin half-posts + const R m_M_lbhp, m_N_lbhp; // last bin half-posts const I m_last_M_bin, m_last_N_bin; struct I_pair { From 02d29cd34f7070ea7c521866daf548b7498f0646 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 15 Apr 2022 11:21:24 -0700 Subject: [PATCH 13/57] Remove redundant checks. --- RecoTracker/MkFitCMS/src/MkStdSeqs.cc | 2 -- RecoTracker/MkFitCore/src/MkFinder.cc | 2 -- RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx | 6 ++---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/RecoTracker/MkFitCMS/src/MkStdSeqs.cc b/RecoTracker/MkFitCMS/src/MkStdSeqs.cc index 88507b9702789..212ad43d1628e 100644 --- a/RecoTracker/MkFitCMS/src/MkStdSeqs.cc +++ b/RecoTracker/MkFitCMS/src/MkStdSeqs.cc @@ -185,8 +185,6 @@ namespace mkfit { for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = ax_phi.next_N_bin(i_phi)) { for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = ax_eta.next_N_bin(i_eta)) { const auto cbin = phi_eta_binnor.get_content(i_phi, i_eta); - if (cbin.empty()) - continue; for (auto i = cbin.first; i < cbin.end(); ++i) { int tss = phi_eta_binnor.m_ranks[i]; diff --git a/RecoTracker/MkFitCore/src/MkFinder.cc b/RecoTracker/MkFitCore/src/MkFinder.cc index 2864dd0e9b320..a03a9837194aa 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.cc +++ b/RecoTracker/MkFitCore/src/MkFinder.cc @@ -427,8 +427,6 @@ namespace mkfit { //SK: ~20x1024 bin sizes give mostly 1 hit per bin. Commented out for 128 bins or less // #pragma nounroll auto pbi = L.phiQBinContent(pi, qi); - if (pbi.empty()) - continue; for (bcnt_t hi = pbi.begin(); hi < pbi.end(); ++hi) { // MT: Access into m_hit_zs and m_hit_phis is 1% run-time each. diff --git a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx index 0381d4dcb36b8..70b1acc045e93 100644 --- a/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx +++ b/RecoTracker/MkFitCore/standalone/test/binnor_demo.cxx @@ -136,10 +136,8 @@ void run_test(const int NLoop, int NN, const bool use_radix, const bool keep_con for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = phi.next_N_bin(i_phi)) { for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = eta.next_N_bin(i_eta)) { printf(" at i_phi=%u, i_eta=%u\n", i_phi, i_eta); - auto cbin = b.get_content(i_phi, i_eta); - if (cbin.empty()) - continue; - for (auto i = cbin.first; i < cbin.first + cbin.count; ++i) { + const auto cbin = b.get_content(i_phi, i_eta); + for (auto i = cbin.begin(); i < cbin.end(); ++i) { const track &t = tracks[b.m_ranks[i]]; printf(" %3d %3d phi=%f eta=%f\n", i, b.m_ranks[i], t.phi, t.eta); } From 6976fc2c5115867c1c2e3cc1105ccd0582a2632d Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 15 Apr 2022 11:29:16 -0700 Subject: [PATCH 14/57] Fix type in clang-format comment. --- RecoTracker/MkFitCore/src/MkFinder.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTracker/MkFitCore/src/MkFinder.cc b/RecoTracker/MkFitCore/src/MkFinder.cc index a03a9837194aa..914d1737c1049 100644 --- a/RecoTracker/MkFitCore/src/MkFinder.cc +++ b/RecoTracker/MkFitCore/src/MkFinder.cc @@ -611,7 +611,7 @@ namespace mkfit { hex, hey, her, hephi, hez, ht_dxy, ht_dz, ht_dphi, hchi2); - // clang-format ofn + // clang-format on } } #endif From 1a8e9929ff1ae6c8bbcb34c72755f9b414824bfb Mon Sep 17 00:00:00 2001 From: Suvankar Roy Chowdhury Date: Tue, 19 Apr 2022 01:17:55 +0200 Subject: [PATCH 15/57] add validation modules --- .../python/gpuValidationPixel_cff.py | 5 + .../python/gpuValidation_cff.py | 4 +- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 196 ++++++++++++++++++ .../plugins/SiPixelPhase1CompareVertexSoA.cc | 158 ++++++++++++++ ...ixelPhase1HeterogenousDQM_FirstStep_cff.py | 38 ++++ 5 files changed, 400 insertions(+), 1 deletion(-) create mode 100644 Configuration/ProcessModifiers/python/gpuValidationPixel_cff.py create mode 100644 DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc create mode 100644 DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc diff --git a/Configuration/ProcessModifiers/python/gpuValidationPixel_cff.py b/Configuration/ProcessModifiers/python/gpuValidationPixel_cff.py new file mode 100644 index 0000000000000..267e2916b62a9 --- /dev/null +++ b/Configuration/ProcessModifiers/python/gpuValidationPixel_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier is for turning on gpu validation modules for Pixel DQM + +gpuValidationPixel = cms.Modifier() diff --git a/Configuration/ProcessModifiers/python/gpuValidation_cff.py b/Configuration/ProcessModifiers/python/gpuValidation_cff.py index ef616d837263a..58cb45db31b7f 100644 --- a/Configuration/ProcessModifiers/python/gpuValidation_cff.py +++ b/Configuration/ProcessModifiers/python/gpuValidation_cff.py @@ -3,11 +3,13 @@ from Configuration.ProcessModifiers.gpu_cff import * from Configuration.ProcessModifiers.gpuValidationEcal_cff import * from Configuration.ProcessModifiers.gpuValidationHcal_cff import * +from Configuration.ProcessModifiers.gpuValidationPixel_cff import * # This modifier chain is for turning on DQM modules used for gpu validation gpuValidation = cms.ModifierChain( gpu, gpuValidationEcal, - gpuValidationHcal + gpuValidationHcal, + gpuValidationPixel ) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc new file mode 100644 index 0000000000000..263c3e93933d4 --- /dev/null +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -0,0 +1,196 @@ +// -*- C++ -*- +///bookLayer +// Package: SiPixelPhase1CompareTrackSoA +// Class: SiPixelPhase1CompareTrackSoA +// +/**\class SiPixelPhase1CompareTrackSoA SiPixelPhase1CompareTrackSoA.cc +*/ +// +// Author: Suvankar Roy Chowdhury +// +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" +// DQM Histograming +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "CUDADataFormats/Track/interface/PixelTrackHeterogeneous.h" +// for string manipulations +#include + +class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { +public: + explicit SiPixelPhase1CompareTrackSoA(const edm::ParameterSet&); + ~SiPixelPhase1CompareTrackSoA() override = default; + void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; + void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + const edm::EDGetTokenT tokenSoATrackCPU_; + const edm::EDGetTokenT tokenSoATrackGPU_; + const std::string topFolderName_; + const bool useQualityCut_; + const pixelTrack::Quality minQuality_; + const float dr2cut_; + MonitorElement* hnTracks; + MonitorElement* hnLooseAndAboveTracks; + MonitorElement* hnLooseAndAboveTracks_matched; + MonitorElement* hnHits; + MonitorElement* hnHitsVsPhi; + MonitorElement* hnHitsVsEta; + MonitorElement* hnLayers; + MonitorElement* hnLayersVsPhi; + MonitorElement* hnLayersVsEta; + MonitorElement* hchi2; + MonitorElement* hChi2VsPhi; + MonitorElement* hChi2VsEta; + MonitorElement* hpt; + MonitorElement* heta; + MonitorElement* hphi; + MonitorElement* hz; + MonitorElement* htip; + MonitorElement* hquality; +}; + +// +// constructors +// + +SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterSet& iConfig) : + tokenSoATrackCPU_(consumes(iConfig.getParameter("pixelTrackSrcCPU"))), + tokenSoATrackGPU_(consumes(iConfig.getParameter("pixelTrackSrcGPU"))), + topFolderName_(iConfig.getParameter("TopFolderName")), + useQualityCut_(iConfig.getParameter("useQualityCut")), + minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), + dr2cut_(iConfig.getParameter("deltaR2cut")) { + +} + +// +// -- Analyze +// +void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + const auto& tsoaHandleCPU = iEvent.getHandle(tokenSoATrackCPU_); + const auto& tsoaHandleGPU = iEvent.getHandle(tokenSoATrackGPU_); + if (!tsoaHandleCPU.isValid() || !tsoaHandleGPU) { + edm::LogWarning("SiPixelPhase1CompareTrackSoA") << "Either GPU or CPU tracks not found! Hence comparison not run!" << std::endl; + return; + } + + auto const& tsoaCPU = *((tsoaHandleCPU.product())->get()); + auto const& tsoaGPU = *((tsoaHandleGPU.product())->get()); + auto maxTracksCPU = tsoaCPU.stride();//this should be same for both? + auto maxTracksGPU = tsoaGPU.stride();//this should be same for both? + auto const* qualityCPU = tsoaCPU.qualityData(); + auto const* qualityGPU = tsoaGPU.qualityData(); + int32_t nTracksCPU = 0; + int32_t nTracksGPU = 0; + int32_t nLooseAndAboveTracksCPU = 0; + int32_t nLooseAndAboveTracksCPU_matchedGPU = 0; + int32_t nLooseAndAboveTracksGPU = 0; + + //Loop over GPU tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? + std::vector looseTrkidxGPU; + for (int32_t jt = 0; jt < maxTracksGPU; ++jt) { + if (tsoaGPU.nHits(jt) == 0) break; // this is a guard + if (!(tsoaGPU.pt(jt) > 0.)) continue; + nTracksGPU++; + if (useQualityCut_ && qualityGPU[jt] < minQuality_) + continue; + nLooseAndAboveTracksCPU++; + looseTrkidxGPU.emplace_back(jt); + } + + //Now loop over CPU tracks//nested loop for loose gPU tracks + for (int32_t it = 0; it < maxTracksCPU; ++it) { + if (tsoaCPU.nHits(it) == 0) break; // this is a guard + if (!(tsoaCPU.pt(it) > 0.)) continue; + nTracksCPU++; + if (useQualityCut_ && qualityCPU[it] < minQuality_) + continue; + nLooseAndAboveTracksCPU++; + //Now loop over loose GPU trk and find the closest in DeltaR//do we need pt cut? + int32_t closestTkidx = 99999; + float mindr2 = 99.; + float etacpu = tsoaCPU.eta(it); + float phicpu = tsoaCPU.phi(it); + for (auto gid : looseTrkidxGPU) { + float etagpu = tsoaGPU.eta(gid); + float phigpu = tsoaGPU.phi(gid); + float dr2 = reco::deltaR2(etacpu, phicpu, etagpu, phigpu); + if(dr2 > dr2cut_) continue; // this is arbitrary + if(mindr2 > dr2 ) { + mindr2 = dr2; + closestTkidx = gid; + } + } + if(closestTkidx == 99999) continue; + nLooseAndAboveTracksCPU_matchedGPU++; + + hchi2->Fill(tsoaCPU.chi2(it), tsoaGPU.chi2(closestTkidx)); + hnHits->Fill(tsoaCPU.nHits(it), tsoaGPU.nHits(closestTkidx)); + hnLayers->Fill(tsoaCPU.nLayers(it), tsoaGPU.nLayers(closestTkidx)); + hpt->Fill(tsoaCPU.pt(it), tsoaGPU.pt(closestTkidx)); + heta->Fill(etacpu, tsoaGPU.eta(closestTkidx)); + hphi->Fill(phicpu, tsoaGPU.phi(closestTkidx)); + hz->Fill(tsoaCPU.zip(it), tsoaGPU.zip(closestTkidx)); + htip->Fill(tsoaCPU.tip(it), tsoaGPU.tip(closestTkidx)); + } + hnTracks->Fill(nTracksCPU, nTracksGPU); + hnLooseAndAboveTracks->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); + hnLooseAndAboveTracks_matched->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU); +} + +// +// -- Book Histograms +// +void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + iBook.cd(); + iBook.setCurrentFolder(topFolderName_); + + // clang-format off + std::string toRep = "Number of tracks"; + hnTracks = iBook.book2D("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 1001, -0.5, 1000.5, 1001, -0.5, 1000.5); + hnLooseAndAboveTracks = iBook.book2D("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 1001, -0.5, 1000.5, 1001, -0.5, 1000.5); + hnLooseAndAboveTracks_matched = iBook.book2D("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 1001, -0.5, 1000.5, 1001, -0.5, 1000.5); + + toRep = "Number of all RecHits per track (quality #geq loose)"; + hnHits = iBook.book2D("nRecHits", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); + + toRep = "Number of all layers per track (quality #geq loose)"; + hnLayers = iBook.book2D("nLayers", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); + + toRep = "Track (quality #geq loose) #chi^{2}/ndof"; + hchi2 = iBook.book2D("nChi2ndof", fmt::sprintf("%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.); + + + hpt = iBook.book2D("pt", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.); + heta = iBook.book2D("eta", "Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.); + hphi = iBook.book2D("phi", "Track (quality #geq loose) #phi;CPU;GPU", 30, -M_PI, M_PI, 30, -M_PI, M_PI); + hz = iBook.book2D("z", "Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.); + htip = iBook.book2D("tip", "Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5); +} + +void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // monitorpixelTrackSoA + edm::ParameterSetDescription desc; + desc.add("pixelTrackSrcCPU", edm::InputTag("pixelTracksSoA@cpu")); + desc.add("pixelTrackSrcGPU", edm::InputTag("pixelTracksSoA@cuda")); + desc.add("TopFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU/"); + desc.add("useQualityCut", true); + desc.add("minQuality", "loose"); + desc.add("deltaR2cut", 0.04); + descriptions.addWithDefaultLabel(desc); +} +DEFINE_FWK_MODULE(SiPixelPhase1CompareTrackSoA); diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc new file mode 100644 index 0000000000000..3680ffc8a9c1c --- /dev/null +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc @@ -0,0 +1,158 @@ +// -*- C++ -*- +///bookLayer +// Package: SiPixelPhase1CompareVertexSoA +// Class: SiPixelPhase1CompareVertexSoA +// +/**\class SiPixelPhase1CompareVertexSoA SiPixelPhase1CompareVertexSoA.cc +*/ +// +// Author: Suvankar Roy Chowdhury +// +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/Common/interface/Handle.h" +// DQM Histograming +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "CUDADataFormats/Vertex/interface/ZVertexHeterogeneous.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" + +class SiPixelPhase1CompareVertexSoA : public DQMEDAnalyzer { +public: + using IndToEdm = std::vector; + explicit SiPixelPhase1CompareVertexSoA(const edm::ParameterSet&); + ~SiPixelPhase1CompareVertexSoA() override = default; + void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; + void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + const edm::EDGetTokenT tokenSoAVertexCPU_; + const edm::EDGetTokenT tokenSoAVertexGPU_; + const edm::EDGetTokenT tokenBeamSpot_; + const std::string topFolderName_; + const float dzCut_; + MonitorElement* hnVertex; + MonitorElement* hx; + MonitorElement* hy; + MonitorElement* hz; + MonitorElement* hchi2; + MonitorElement* hchi2oNdof; + MonitorElement* hptv2; + MonitorElement* hntrks; +}; + +// +// constructors +// + +SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::ParameterSet& iConfig) : + tokenSoAVertexCPU_(consumes(iConfig.getParameter("pixelVertexSrcCPU"))), + tokenSoAVertexGPU_(consumes(iConfig.getParameter("pixelVertexSrcGPU"))), + tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), + topFolderName_(iConfig.getParameter("TopFolderName")), + dzCut_(iConfig.getParameter("dzCut")) +{ +} + +// +// -- Analyze +// +void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + const auto& vsoaHandleCPU = iEvent.getHandle(tokenSoAVertexCPU_); + const auto& vsoaHandleGPU = iEvent.getHandle(tokenSoAVertexGPU_); + if (!vsoaHandleCPU.isValid() || !vsoaHandleGPU.isValid()) { + edm::LogWarning("SiPixelPhase1MonitorTrackSoA") << "Either vertex SoA found GPU or CPU not found. Comparison not run!" << std::endl; + return; + } + + auto const& vsoaCPU = *((vsoaHandleCPU.product())->get()); + int nVerticesCPU = vsoaCPU.nvFinal; + auto const& vsoaGPU = *((vsoaHandleGPU.product())->get()); + int nVerticesGPU = vsoaGPU.nvFinal; + + auto bsHandle = iEvent.getHandle(tokenBeamSpot_); + float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.; + if (!bsHandle.isValid()) { + edm::LogWarning("PixelVertexProducer") << "No beamspot found. returning vertexes with (0,0,Z) "; + } else { + const reco::BeamSpot& bs = *bsHandle; + x0 = bs.x0(); + y0 = bs.y0(); + z0 = bs.z0(); + dxdz = bs.dxdz(); + dydz = bs.dydz(); + } + + for (int ivc = 0; ivc < nVerticesCPU; ivc++) { + auto sic = vsoaCPU.sortInd[ivc]; + auto zc = vsoaCPU.zv[sic]; + auto xc = x0 + dxdz * zc; + auto yc = y0 + dydz * zc; + zc += z0; + + auto ndofCPU = vsoaCPU.ndof[sic]; + auto chi2CPU = vsoaCPU.chi2[sic]; + for (int ivg = 0; ivg < nVerticesGPU; ivg++) { + auto sig = vsoaGPU.sortInd[ivg]; + auto zg = vsoaGPU.zv[sig]; + auto xg = x0 + dxdz * zg; + auto yg = y0 + dydz * zg; + zg += z0; + auto ndofGPU = vsoaGPU.ndof[sig]; + auto chi2GPU = vsoaGPU.chi2[sig]; + + //insert some matching condition + if(std::abs(zc - zg) > dzCut_) continue; + + hx->Fill(xc, xg); + hy->Fill(yc, yg); + hz->Fill(zc, zg); + hchi2->Fill(chi2CPU, chi2GPU); + hchi2oNdof->Fill(chi2CPU/ndofCPU, chi2GPU/ndofGPU); + hptv2->Fill(vsoaCPU.ptv2[sic], vsoaGPU.ptv2[sig]); + hntrks->Fill(ndofCPU + 1, ndofGPU + 1); + + } + } + hnVertex->Fill(nVerticesCPU, nVerticesGPU); +} + +// +// -- Book Histograms +// +void SiPixelPhase1CompareVertexSoA::bookHistograms(DQMStore::IBooker& ibooker, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + //std::string top_folder = ""// + ibooker.cd(); + ibooker.setCurrentFolder(topFolderName_); + hnVertex = ibooker.book2D("nVertex", "# of Vertex;CPU;GPU", 101, -0.5, 100.5, 101, -0.5, 100.5); + hx = ibooker.book2D("vx", "Vertez x;CPU;GPU", 10, -5., 5., 10, -5., 5.); + hy = ibooker.book2D("vy", "Vertez y;CPU;GPU", 10, -5., 5., 10, -5., 5.); + hz = ibooker.book2D("vz", "Vertez z;CPU;GPU", 30, -30., 30., 30, -30., 30.); + hchi2 = ibooker.book2D("chi2", "Vertex chi-squared;CPU;GPU", 40, 0., 20., 40, 0., 20.); + hchi2oNdof = ibooker.book2D("chi2oNdof", "Vertex chi-squared/Ndof;CPU;GPU", 40, 0., 20., 40, 0., 20.); + hptv2 = ibooker.book2D("ptsq", "Vertex p_T squared;CPU;GPU", 200, 0., 200., 200, 0., 200.); + hntrks = ibooker.book2D("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); + hntrks = ibooker.book2D("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); +} + +void SiPixelPhase1CompareVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // monitorpixelVertexSoA + edm::ParameterSetDescription desc; + desc.add("pixelVertexSrcCPU", edm::InputTag("pixelVerticesSoA@cpu")); + desc.add("pixelVertexSrcGPU", edm::InputTag("pixelVerticesSoA@cuda")); + desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); + desc.add("TopFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoAGPU vs CPU"); + desc.add("dzCut", 1.); + descriptions.addWithDefaultLabel(desc); +} +DEFINE_FWK_MODULE(SiPixelPhase1CompareVertexSoA); diff --git a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py index 666d239441fe7..94139c4756e66 100644 --- a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py @@ -8,3 +8,41 @@ monitorpixelSoASource = cms.Sequence(siPixelPhase1MonitorRecHitsSoA * siPixelPhase1MonitorTrackSoA * siPixelPhase1MonitorVertexSoA) + + +#Define the sequence for GPU vs CPU validation +#This should run:- individual monitor for the 2 collections + comparison module +from DQM.SiPixelPhase1Heterogeneous.siPixelPhase1CompareTrackSoA_cfi import * +from DQM.SiPixelPhase1Heterogeneous.siPixelPhase1CompareVertexSoA_cfi import * + +siPixelPhase1MonitorTrackSoACPU = siPixelPhase1MonitorTrackSoA.clone( + pixelTrackSrc = 'pixelTracksSoA@cpu', + TopFolderName = 'SiPixelHeterogeneous/PixelTrackSoACPU', +) + +siPixelPhase1MonitorTrackSoAGPU = siPixelPhase1MonitorTrackSoA.clone( + pixelTrackSrc = 'pixelTracksSoA@cuda', + TopFolderName = 'SiPixelHeterogeneous/PixelTrackSoAGPU', +) + +siPixelPhase1MonitorVertexSoACPU = siPixelPhase1MonitorVertexSoA.clone( + pixelVertexSrc = 'pixelVerticesSoA@cpu', + TopFolderName = 'SiPixelHeterogeneous/PixelVertexSoACPU', +) + +siPixelPhase1MonitorVertexSoAGPU = siPixelPhase1MonitorVertexSoA.clone( + pixelVertexSrc = 'pixelVerticesSoA@cuda', + TopFolderName = 'SiPixelHeterogeneous/PixelVertexSoAGPU', +) + + +monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorTrackOASoAGPU * + siPixelPhase1MonitorTrackSoACPU * + siPixelPhase1CompareTrackSoA * + siPixelPhase1MonitorVertexSoACPU * + siPixelPhase1MonitorVertexSoAGPU * + siPixelPhase1CompareVertexSoA +) + +from Configuration.ProcessModifiers.gpuValidationPixel_cff import gpuValidationPixel +gpuValidationPixel.toReplaceWith(monitorpixelSoASource, monitorpixelSoACompareSource) From 0824f22ab815e2f3a71d84a0748c1f36900e4e1b Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 19 Apr 2022 13:01:02 +0200 Subject: [PATCH 16/57] fix typo in SiPixelPhase1CompareTrackSoA --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index 263c3e93933d4..6da834aaccad1 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -106,7 +106,7 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: nTracksGPU++; if (useQualityCut_ && qualityGPU[jt] < minQuality_) continue; - nLooseAndAboveTracksCPU++; + nLooseAndAboveTracksGPU++; looseTrkidxGPU.emplace_back(jt); } @@ -161,9 +161,9 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, // clang-format off std::string toRep = "Number of tracks"; - hnTracks = iBook.book2D("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 1001, -0.5, 1000.5, 1001, -0.5, 1000.5); - hnLooseAndAboveTracks = iBook.book2D("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 1001, -0.5, 1000.5, 1001, -0.5, 1000.5); - hnLooseAndAboveTracks_matched = iBook.book2D("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 1001, -0.5, 1000.5, 1001, -0.5, 1000.5); + hnTracks = iBook.book2D("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnLooseAndAboveTracks = iBook.book2D("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnLooseAndAboveTracks_matched = iBook.book2D("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); toRep = "Number of all RecHits per track (quality #geq loose)"; hnHits = iBook.book2D("nRecHits", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); From b6806bd618b1b04a4b18689d6c934b28f9047608 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 19 Apr 2022 13:01:28 +0200 Subject: [PATCH 17/57] fix typo in SiPixelPhase1HeterogenousDQM_FirstStep_cff --- .../python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py index 94139c4756e66..e14cf7f429322 100644 --- a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py @@ -36,7 +36,7 @@ ) -monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorTrackOASoAGPU * +monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorTrackSoAGPU * siPixelPhase1MonitorTrackSoACPU * siPixelPhase1CompareTrackSoA * siPixelPhase1MonitorVertexSoACPU * From cb25dc383fa4f4c476be25ac88f9d93db4ea1bd3 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 19 Apr 2022 13:09:02 +0200 Subject: [PATCH 18/57] code-checks & code-format --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 52 ++++++++++--------- .../plugins/SiPixelPhase1CompareVertexSoA.cc | 26 +++++----- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index 6da834aaccad1..f00cb05798181 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -1,5 +1,4 @@ // -*- C++ -*- -///bookLayer // Package: SiPixelPhase1CompareTrackSoA // Class: SiPixelPhase1CompareTrackSoA // @@ -65,15 +64,13 @@ class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { // constructors // -SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterSet& iConfig) : - tokenSoATrackCPU_(consumes(iConfig.getParameter("pixelTrackSrcCPU"))), - tokenSoATrackGPU_(consumes(iConfig.getParameter("pixelTrackSrcGPU"))), - topFolderName_(iConfig.getParameter("TopFolderName")), - useQualityCut_(iConfig.getParameter("useQualityCut")), - minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), - dr2cut_(iConfig.getParameter("deltaR2cut")) { - -} +SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterSet& iConfig) + : tokenSoATrackCPU_(consumes(iConfig.getParameter("pixelTrackSrcCPU"))), + tokenSoATrackGPU_(consumes(iConfig.getParameter("pixelTrackSrcGPU"))), + topFolderName_(iConfig.getParameter("TopFolderName")), + useQualityCut_(iConfig.getParameter("useQualityCut")), + minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), + dr2cut_(iConfig.getParameter("deltaR2cut")) {} // // -- Analyze @@ -82,14 +79,15 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: const auto& tsoaHandleCPU = iEvent.getHandle(tokenSoATrackCPU_); const auto& tsoaHandleGPU = iEvent.getHandle(tokenSoATrackGPU_); if (!tsoaHandleCPU.isValid() || !tsoaHandleGPU) { - edm::LogWarning("SiPixelPhase1CompareTrackSoA") << "Either GPU or CPU tracks not found! Hence comparison not run!" << std::endl; + edm::LogWarning("SiPixelPhase1CompareTrackSoA") + << "Either GPU or CPU tracks not found! Hence comparison not run!" << std::endl; return; } auto const& tsoaCPU = *((tsoaHandleCPU.product())->get()); auto const& tsoaGPU = *((tsoaHandleGPU.product())->get()); - auto maxTracksCPU = tsoaCPU.stride();//this should be same for both? - auto maxTracksGPU = tsoaGPU.stride();//this should be same for both? + auto maxTracksCPU = tsoaCPU.stride(); //this should be same for both? + auto maxTracksGPU = tsoaGPU.stride(); //this should be same for both? auto const* qualityCPU = tsoaCPU.qualityData(); auto const* qualityGPU = tsoaGPU.qualityData(); int32_t nTracksCPU = 0; @@ -99,10 +97,12 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: int32_t nLooseAndAboveTracksGPU = 0; //Loop over GPU tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? - std::vector looseTrkidxGPU; + std::vector looseTrkidxGPU; for (int32_t jt = 0; jt < maxTracksGPU; ++jt) { - if (tsoaGPU.nHits(jt) == 0) break; // this is a guard - if (!(tsoaGPU.pt(jt) > 0.)) continue; + if (tsoaGPU.nHits(jt) == 0) + break; // this is a guard + if (!(tsoaGPU.pt(jt) > 0.)) + continue; nTracksGPU++; if (useQualityCut_ && qualityGPU[jt] < minQuality_) continue; @@ -112,8 +112,10 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: //Now loop over CPU tracks//nested loop for loose gPU tracks for (int32_t it = 0; it < maxTracksCPU; ++it) { - if (tsoaCPU.nHits(it) == 0) break; // this is a guard - if (!(tsoaCPU.pt(it) > 0.)) continue; + if (tsoaCPU.nHits(it) == 0) + break; // this is a guard + if (!(tsoaCPU.pt(it) > 0.)) + continue; nTracksCPU++; if (useQualityCut_ && qualityCPU[it] < minQuality_) continue; @@ -123,17 +125,19 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: float mindr2 = 99.; float etacpu = tsoaCPU.eta(it); float phicpu = tsoaCPU.phi(it); - for (auto gid : looseTrkidxGPU) { + for (auto gid : looseTrkidxGPU) { float etagpu = tsoaGPU.eta(gid); float phigpu = tsoaGPU.phi(gid); float dr2 = reco::deltaR2(etacpu, phicpu, etagpu, phigpu); - if(dr2 > dr2cut_) continue; // this is arbitrary - if(mindr2 > dr2 ) { - mindr2 = dr2; - closestTkidx = gid; + if (dr2 > dr2cut_) + continue; // this is arbitrary + if (mindr2 > dr2) { + mindr2 = dr2; + closestTkidx = gid; } } - if(closestTkidx == 99999) continue; + if (closestTkidx == 99999) + continue; nLooseAndAboveTracksCPU_matchedGPU++; hchi2->Fill(tsoaCPU.chi2(it), tsoaGPU.chi2(closestTkidx)); diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc index 3680ffc8a9c1c..8181095254cea 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc @@ -1,5 +1,4 @@ // -*- C++ -*- -///bookLayer // Package: SiPixelPhase1CompareVertexSoA // Class: SiPixelPhase1CompareVertexSoA // @@ -53,14 +52,12 @@ class SiPixelPhase1CompareVertexSoA : public DQMEDAnalyzer { // constructors // -SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::ParameterSet& iConfig) : - tokenSoAVertexCPU_(consumes(iConfig.getParameter("pixelVertexSrcCPU"))), - tokenSoAVertexGPU_(consumes(iConfig.getParameter("pixelVertexSrcGPU"))), - tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), - topFolderName_(iConfig.getParameter("TopFolderName")), - dzCut_(iConfig.getParameter("dzCut")) -{ -} +SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::ParameterSet& iConfig) + : tokenSoAVertexCPU_(consumes(iConfig.getParameter("pixelVertexSrcCPU"))), + tokenSoAVertexGPU_(consumes(iConfig.getParameter("pixelVertexSrcGPU"))), + tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), + topFolderName_(iConfig.getParameter("TopFolderName")), + dzCut_(iConfig.getParameter("dzCut")) {} // // -- Analyze @@ -69,7 +66,8 @@ void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm: const auto& vsoaHandleCPU = iEvent.getHandle(tokenSoAVertexCPU_); const auto& vsoaHandleGPU = iEvent.getHandle(tokenSoAVertexGPU_); if (!vsoaHandleCPU.isValid() || !vsoaHandleGPU.isValid()) { - edm::LogWarning("SiPixelPhase1MonitorTrackSoA") << "Either vertex SoA found GPU or CPU not found. Comparison not run!" << std::endl; + edm::LogWarning("SiPixelPhase1MonitorTrackSoA") + << "Either vertex SoA found GPU or CPU not found. Comparison not run!" << std::endl; return; } @@ -90,7 +88,7 @@ void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm: dxdz = bs.dxdz(); dydz = bs.dydz(); } - + for (int ivc = 0; ivc < nVerticesCPU; ivc++) { auto sic = vsoaCPU.sortInd[ivc]; auto zc = vsoaCPU.zv[sic]; @@ -110,16 +108,16 @@ void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm: auto chi2GPU = vsoaGPU.chi2[sig]; //insert some matching condition - if(std::abs(zc - zg) > dzCut_) continue; + if (std::abs(zc - zg) > dzCut_) + continue; hx->Fill(xc, xg); hy->Fill(yc, yg); hz->Fill(zc, zg); hchi2->Fill(chi2CPU, chi2GPU); - hchi2oNdof->Fill(chi2CPU/ndofCPU, chi2GPU/ndofGPU); + hchi2oNdof->Fill(chi2CPU / ndofCPU, chi2GPU / ndofGPU); hptv2->Fill(vsoaCPU.ptv2[sic], vsoaGPU.ptv2[sig]); hntrks->Fill(ndofCPU + 1, ndofGPU + 1); - } } hnVertex->Fill(nVerticesCPU, nVerticesGPU); From 754ac6dd9e8447e309575273605f873cbffbd9d3 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 19 Apr 2022 16:27:24 +0200 Subject: [PATCH 19/57] follow-up to code review --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 110 +++++++++--------- .../plugins/SiPixelPhase1CompareVertexSoA.cc | 103 +++++++++------- .../plugins/SiPixelPhase1MonitorTrackSoA.cc | 4 +- .../plugins/SiPixelPhase1MonitorVertexSoA.cc | 4 +- ...ixelPhase1HeterogenousDQM_FirstStep_cff.py | 8 +- 5 files changed, 125 insertions(+), 104 deletions(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index f00cb05798181..b89d04c395d62 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -9,13 +9,11 @@ // #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Math/interface/deltaR.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/InputTag.h" // DQM Histograming #include "DQMServices/Core/interface/MonitorElement.h" @@ -40,24 +38,24 @@ class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { const bool useQualityCut_; const pixelTrack::Quality minQuality_; const float dr2cut_; - MonitorElement* hnTracks; - MonitorElement* hnLooseAndAboveTracks; - MonitorElement* hnLooseAndAboveTracks_matched; - MonitorElement* hnHits; - MonitorElement* hnHitsVsPhi; - MonitorElement* hnHitsVsEta; - MonitorElement* hnLayers; - MonitorElement* hnLayersVsPhi; - MonitorElement* hnLayersVsEta; - MonitorElement* hchi2; - MonitorElement* hChi2VsPhi; - MonitorElement* hChi2VsEta; - MonitorElement* hpt; - MonitorElement* heta; - MonitorElement* hphi; - MonitorElement* hz; - MonitorElement* htip; - MonitorElement* hquality; + MonitorElement* hnTracks_; + MonitorElement* hnLooseAndAboveTracks_; + MonitorElement* hnLooseAndAboveTracks_matched_; + MonitorElement* hnHits_; + MonitorElement* hnHitsVsPhi_; + MonitorElement* hnHitsVsEta_; + MonitorElement* hnLayers_; + MonitorElement* hnLayersVsPhi_; + MonitorElement* hnLayersVsEta_; + MonitorElement* hchi2_; + MonitorElement* hChi2VsPhi_; + MonitorElement* hChi2VsEta_; + MonitorElement* hpt_; + MonitorElement* heta_; + MonitorElement* hphi_; + MonitorElement* hz_; + MonitorElement* htip_; + MonitorElement* hquality_; }; // @@ -67,7 +65,7 @@ class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterSet& iConfig) : tokenSoATrackCPU_(consumes(iConfig.getParameter("pixelTrackSrcCPU"))), tokenSoATrackGPU_(consumes(iConfig.getParameter("pixelTrackSrcGPU"))), - topFolderName_(iConfig.getParameter("TopFolderName")), + topFolderName_(iConfig.getParameter("topFolderName")), useQualityCut_(iConfig.getParameter("useQualityCut")), minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), dr2cut_(iConfig.getParameter("deltaR2cut")) {} @@ -78,14 +76,20 @@ SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterS void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { const auto& tsoaHandleCPU = iEvent.getHandle(tokenSoATrackCPU_); const auto& tsoaHandleGPU = iEvent.getHandle(tokenSoATrackGPU_); - if (!tsoaHandleCPU.isValid() || !tsoaHandleGPU) { - edm::LogWarning("SiPixelPhase1CompareTrackSoA") - << "Either GPU or CPU tracks not found! Hence comparison not run!" << std::endl; + if (not tsoaHandleCPU or not tsoaHandleGPU) { + edm::LogWarning out("SiPixelPhase1CompareTrackSoA"); + if (not tsoaHandleCPU) { + out << "reference (cpu) tracks not found; "; + } + if (not tsoaHandleGPU) { + out << "target (gpu) tracks not found; "; + } + out << "the comparison will not run."; return; } - auto const& tsoaCPU = *((tsoaHandleCPU.product())->get()); - auto const& tsoaGPU = *((tsoaHandleGPU.product())->get()); + auto const& tsoaCPU = *tsoaHandleCPU->get(); + auto const& tsoaGPU = *tsoaHandleGPU->get(); auto maxTracksCPU = tsoaCPU.stride(); //this should be same for both? auto maxTracksGPU = tsoaGPU.stride(); //this should be same for both? auto const* qualityCPU = tsoaCPU.qualityData(); @@ -121,8 +125,9 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: continue; nLooseAndAboveTracksCPU++; //Now loop over loose GPU trk and find the closest in DeltaR//do we need pt cut? - int32_t closestTkidx = 99999; - float mindr2 = 99.; + const int32_t notFound = -1; + int32_t closestTkidx = notFound; + float mindr2 = dr2cut_; float etacpu = tsoaCPU.eta(it); float phicpu = tsoaCPU.phi(it); for (auto gid : looseTrkidxGPU) { @@ -136,22 +141,22 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: closestTkidx = gid; } } - if (closestTkidx == 99999) + if (closestTkidx == notFound) continue; nLooseAndAboveTracksCPU_matchedGPU++; - hchi2->Fill(tsoaCPU.chi2(it), tsoaGPU.chi2(closestTkidx)); - hnHits->Fill(tsoaCPU.nHits(it), tsoaGPU.nHits(closestTkidx)); - hnLayers->Fill(tsoaCPU.nLayers(it), tsoaGPU.nLayers(closestTkidx)); - hpt->Fill(tsoaCPU.pt(it), tsoaGPU.pt(closestTkidx)); - heta->Fill(etacpu, tsoaGPU.eta(closestTkidx)); - hphi->Fill(phicpu, tsoaGPU.phi(closestTkidx)); - hz->Fill(tsoaCPU.zip(it), tsoaGPU.zip(closestTkidx)); - htip->Fill(tsoaCPU.tip(it), tsoaGPU.tip(closestTkidx)); + hchi2_->Fill(tsoaCPU.chi2(it), tsoaGPU.chi2(closestTkidx)); + hnHits_->Fill(tsoaCPU.nHits(it), tsoaGPU.nHits(closestTkidx)); + hnLayers_->Fill(tsoaCPU.nLayers(it), tsoaGPU.nLayers(closestTkidx)); + hpt_->Fill(tsoaCPU.pt(it), tsoaGPU.pt(closestTkidx)); + heta_->Fill(etacpu, tsoaGPU.eta(closestTkidx)); + hphi_->Fill(phicpu, tsoaGPU.phi(closestTkidx)); + hz_->Fill(tsoaCPU.zip(it), tsoaGPU.zip(closestTkidx)); + htip_->Fill(tsoaCPU.tip(it), tsoaGPU.tip(closestTkidx)); } - hnTracks->Fill(nTracksCPU, nTracksGPU); - hnLooseAndAboveTracks->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); - hnLooseAndAboveTracks_matched->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU); + hnTracks_->Fill(nTracksCPU, nTracksGPU); + hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); + hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU); } // @@ -165,25 +170,24 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, // clang-format off std::string toRep = "Number of tracks"; - hnTracks = iBook.book2D("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - hnLooseAndAboveTracks = iBook.book2D("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - hnLooseAndAboveTracks_matched = iBook.book2D("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnTracks_ = iBook.book2D("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnLooseAndAboveTracks_ = iBook.book2D("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnLooseAndAboveTracks_matched_ = iBook.book2D("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); toRep = "Number of all RecHits per track (quality #geq loose)"; - hnHits = iBook.book2D("nRecHits", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); + hnHits_ = iBook.book2D("nRecHits", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); toRep = "Number of all layers per track (quality #geq loose)"; - hnLayers = iBook.book2D("nLayers", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); + hnLayers_ = iBook.book2D("nLayers", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); toRep = "Track (quality #geq loose) #chi^{2}/ndof"; - hchi2 = iBook.book2D("nChi2ndof", fmt::sprintf("%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.); - + hchi2_ = iBook.book2D("nChi2ndof", fmt::sprintf("%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.); - hpt = iBook.book2D("pt", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.); - heta = iBook.book2D("eta", "Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.); - hphi = iBook.book2D("phi", "Track (quality #geq loose) #phi;CPU;GPU", 30, -M_PI, M_PI, 30, -M_PI, M_PI); - hz = iBook.book2D("z", "Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.); - htip = iBook.book2D("tip", "Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5); + hpt_ = iBook.book2D("pt", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.); + heta_ = iBook.book2D("eta", "Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.); + hphi_ = iBook.book2D("phi", "Track (quality #geq loose) #phi;CPU;GPU", 30, -M_PI, M_PI, 30, -M_PI, M_PI); + hz_ = iBook.book2D("z", "Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.); + htip_ = iBook.book2D("tip", "Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5); } void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { @@ -191,7 +195,7 @@ void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptio edm::ParameterSetDescription desc; desc.add("pixelTrackSrcCPU", edm::InputTag("pixelTracksSoA@cpu")); desc.add("pixelTrackSrcGPU", edm::InputTag("pixelTracksSoA@cuda")); - desc.add("TopFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU/"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU/"); desc.add("useQualityCut", true); desc.add("minQuality", "loose"); desc.add("deltaR2cut", 0.04); diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc index 8181095254cea..3648a4860144b 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc @@ -9,11 +9,9 @@ // #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/Common/interface/Handle.h" // DQM Histograming @@ -38,14 +36,14 @@ class SiPixelPhase1CompareVertexSoA : public DQMEDAnalyzer { const edm::EDGetTokenT tokenBeamSpot_; const std::string topFolderName_; const float dzCut_; - MonitorElement* hnVertex; - MonitorElement* hx; - MonitorElement* hy; - MonitorElement* hz; - MonitorElement* hchi2; - MonitorElement* hchi2oNdof; - MonitorElement* hptv2; - MonitorElement* hntrks; + MonitorElement* hnVertex_; + MonitorElement* hx_; + MonitorElement* hy_; + MonitorElement* hz_; + MonitorElement* hchi2_; + MonitorElement* hchi2oNdof_; + MonitorElement* hptv2_; + MonitorElement* hntrks_; }; // @@ -56,7 +54,7 @@ SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::Paramete : tokenSoAVertexCPU_(consumes(iConfig.getParameter("pixelVertexSrcCPU"))), tokenSoAVertexGPU_(consumes(iConfig.getParameter("pixelVertexSrcGPU"))), tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), - topFolderName_(iConfig.getParameter("TopFolderName")), + topFolderName_(iConfig.getParameter("topFolderName")), dzCut_(iConfig.getParameter("dzCut")) {} // @@ -65,15 +63,21 @@ SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::Paramete void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { const auto& vsoaHandleCPU = iEvent.getHandle(tokenSoAVertexCPU_); const auto& vsoaHandleGPU = iEvent.getHandle(tokenSoAVertexGPU_); - if (!vsoaHandleCPU.isValid() || !vsoaHandleGPU.isValid()) { - edm::LogWarning("SiPixelPhase1MonitorTrackSoA") - << "Either vertex SoA found GPU or CPU not found. Comparison not run!" << std::endl; + if (not vsoaHandleCPU or not vsoaHandleGPU) { + edm::LogWarning out("SiPixelPhase1CompareTrackSoA"); + if (not vsoaHandleCPU) { + out << "reference (cpu) tracks not found; "; + } + if (not vsoaHandleGPU) { + out << "target (gpu) tracks not found; "; + } + out << "the comparison will not run."; return; } - auto const& vsoaCPU = *((vsoaHandleCPU.product())->get()); + auto const& vsoaCPU = *vsoaHandleCPU->get(); int nVerticesCPU = vsoaCPU.nvFinal; - auto const& vsoaGPU = *((vsoaHandleGPU.product())->get()); + auto const& vsoaGPU = *vsoaHandleGPU->get(); int nVerticesGPU = vsoaGPU.nvFinal; auto bsHandle = iEvent.getHandle(tokenBeamSpot_); @@ -98,29 +102,42 @@ void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm: auto ndofCPU = vsoaCPU.ndof[sic]; auto chi2CPU = vsoaCPU.chi2[sic]; + + const int32_t notFound = -1; + int32_t closestVtxidx = notFound; + float mindz = dzCut_; + for (int ivg = 0; ivg < nVerticesGPU; ivg++) { auto sig = vsoaGPU.sortInd[ivg]; - auto zg = vsoaGPU.zv[sig]; - auto xg = x0 + dxdz * zg; - auto yg = y0 + dydz * zg; - zg += z0; - auto ndofGPU = vsoaGPU.ndof[sig]; - auto chi2GPU = vsoaGPU.chi2[sig]; - + auto zgc = vsoaGPU.zv[sig] + z0; + auto zDist = std::abs(zc - zgc); //insert some matching condition - if (std::abs(zc - zg) > dzCut_) + if (zDist > dzCut_) continue; - - hx->Fill(xc, xg); - hy->Fill(yc, yg); - hz->Fill(zc, zg); - hchi2->Fill(chi2CPU, chi2GPU); - hchi2oNdof->Fill(chi2CPU / ndofCPU, chi2GPU / ndofGPU); - hptv2->Fill(vsoaCPU.ptv2[sic], vsoaGPU.ptv2[sig]); - hntrks->Fill(ndofCPU + 1, ndofGPU + 1); + if (mindz > zDist) { + mindz = zDist; + closestVtxidx = sig; + } } + if (closestVtxidx == notFound) + continue; + + auto zg = vsoaGPU.zv[closestVtxidx]; + auto xg = x0 + dxdz * zg; + auto yg = y0 + dydz * zg; + zg += z0; + auto ndofGPU = vsoaGPU.ndof[closestVtxidx]; + auto chi2GPU = vsoaGPU.chi2[closestVtxidx]; + + hx_->Fill(xc, xg); + hy_->Fill(yc, yg); + hz_->Fill(zc, zg); + hchi2_->Fill(chi2CPU, chi2GPU); + hchi2oNdof_->Fill(chi2CPU / ndofCPU, chi2GPU / ndofGPU); + hptv2_->Fill(vsoaCPU.ptv2[sic], vsoaGPU.ptv2[closestVtxidx]); + hntrks_->Fill(ndofCPU + 1, ndofGPU + 1); } - hnVertex->Fill(nVerticesCPU, nVerticesGPU); + hnVertex_->Fill(nVerticesCPU, nVerticesGPU); } // @@ -132,15 +149,15 @@ void SiPixelPhase1CompareVertexSoA::bookHistograms(DQMStore::IBooker& ibooker, //std::string top_folder = ""// ibooker.cd(); ibooker.setCurrentFolder(topFolderName_); - hnVertex = ibooker.book2D("nVertex", "# of Vertex;CPU;GPU", 101, -0.5, 100.5, 101, -0.5, 100.5); - hx = ibooker.book2D("vx", "Vertez x;CPU;GPU", 10, -5., 5., 10, -5., 5.); - hy = ibooker.book2D("vy", "Vertez y;CPU;GPU", 10, -5., 5., 10, -5., 5.); - hz = ibooker.book2D("vz", "Vertez z;CPU;GPU", 30, -30., 30., 30, -30., 30.); - hchi2 = ibooker.book2D("chi2", "Vertex chi-squared;CPU;GPU", 40, 0., 20., 40, 0., 20.); - hchi2oNdof = ibooker.book2D("chi2oNdof", "Vertex chi-squared/Ndof;CPU;GPU", 40, 0., 20., 40, 0., 20.); - hptv2 = ibooker.book2D("ptsq", "Vertex p_T squared;CPU;GPU", 200, 0., 200., 200, 0., 200.); - hntrks = ibooker.book2D("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); - hntrks = ibooker.book2D("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); + hnVertex_ = ibooker.book2D("nVertex", "# of Vertex;CPU;GPU", 101, -0.5, 100.5, 101, -0.5, 100.5); + hx_ = ibooker.book2D("vx", "Vertez x;CPU;GPU", 20, -0.1, 0.1, 20, -0.1, 0.1); + hy_ = ibooker.book2D("vy", "Vertez y;CPU;GPU", 20, -0.1, 0.1, 20, -0.1, 0.1); + hz_ = ibooker.book2D("vz", "Vertez z;CPU;GPU", 30, -30., 30., 30, -30., 30.); + hchi2_ = ibooker.book2D("chi2", "Vertex chi-squared;CPU;GPU", 40, 0., 20., 40, 0., 20.); + hchi2oNdof_ = ibooker.book2D("chi2oNdof", "Vertex chi-squared/Ndof;CPU;GPU", 40, 0., 20., 40, 0., 20.); + hptv2_ = ibooker.book2D("ptsq", "Vertex p_T squared;CPU;GPU", 200, 0., 200., 200, 0., 200.); + hntrks_ = ibooker.book2D("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); + hntrks_ = ibooker.book2D("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); } void SiPixelPhase1CompareVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { @@ -149,7 +166,7 @@ void SiPixelPhase1CompareVertexSoA::fillDescriptions(edm::ConfigurationDescripti desc.add("pixelVertexSrcCPU", edm::InputTag("pixelVerticesSoA@cpu")); desc.add("pixelVertexSrcGPU", edm::InputTag("pixelVerticesSoA@cuda")); desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("TopFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoAGPU vs CPU"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoAGPU vs CPU"); desc.add("dzCut", 1.); descriptions.addWithDefaultLabel(desc); } diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorTrackSoA.cc index 63d4935630603..47bde4f171ede 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorTrackSoA.cc @@ -63,7 +63,7 @@ class SiPixelPhase1MonitorTrackSoA : public DQMEDAnalyzer { SiPixelPhase1MonitorTrackSoA::SiPixelPhase1MonitorTrackSoA(const edm::ParameterSet& iConfig) { tokenSoATrack_ = consumes(iConfig.getParameter("pixelTrackSrc")); - topFolderName_ = iConfig.getParameter("TopFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA"; + topFolderName_ = iConfig.getParameter("topFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA"; useQualityCut_ = iConfig.getParameter("useQualityCut"); minQuality_ = pixelTrack::qualityByName(iConfig.getParameter("minQuality")); } @@ -175,7 +175,7 @@ void SiPixelPhase1MonitorTrackSoA::fillDescriptions(edm::ConfigurationDescriptio // monitorpixelTrackSoA edm::ParameterSetDescription desc; desc.add("pixelTrackSrc", edm::InputTag("pixelTracksSoA")); - desc.add("TopFolderName", "SiPixelHeterogeneous/PixelTrackSoA"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackSoA"); desc.add("useQualityCut", true); desc.add("minQuality", "loose"); descriptions.addWithDefaultLabel(desc); diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorVertexSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorVertexSoA.cc index 792b92af8ba84..02f04f0050960 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorVertexSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1MonitorVertexSoA.cc @@ -54,7 +54,7 @@ class SiPixelPhase1MonitorVertexSoA : public DQMEDAnalyzer { SiPixelPhase1MonitorVertexSoA::SiPixelPhase1MonitorVertexSoA(const edm::ParameterSet& iConfig) { tokenSoAVertex_ = consumes(iConfig.getParameter("pixelVertexSrc")); tokenBeamSpot_ = consumes(iConfig.getParameter("beamSpotSrc")); - topFolderName_ = iConfig.getParameter("TopFolderName"); + topFolderName_ = iConfig.getParameter("topFolderName"); } // @@ -123,7 +123,7 @@ void SiPixelPhase1MonitorVertexSoA::fillDescriptions(edm::ConfigurationDescripti edm::ParameterSetDescription desc; desc.add("pixelVertexSrc", edm::InputTag("pixelVerticesSoA")); desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("TopFolderName", "SiPixelHeterogeneous/PixelVertexSoA"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexSoA"); descriptions.addWithDefaultLabel(desc); } DEFINE_FWK_MODULE(SiPixelPhase1MonitorVertexSoA); diff --git a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py index e14cf7f429322..dc19a2318a08d 100644 --- a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQM_FirstStep_cff.py @@ -17,22 +17,22 @@ siPixelPhase1MonitorTrackSoACPU = siPixelPhase1MonitorTrackSoA.clone( pixelTrackSrc = 'pixelTracksSoA@cpu', - TopFolderName = 'SiPixelHeterogeneous/PixelTrackSoACPU', + topFolderName = 'SiPixelHeterogeneous/PixelTrackSoACPU', ) siPixelPhase1MonitorTrackSoAGPU = siPixelPhase1MonitorTrackSoA.clone( pixelTrackSrc = 'pixelTracksSoA@cuda', - TopFolderName = 'SiPixelHeterogeneous/PixelTrackSoAGPU', + topFolderName = 'SiPixelHeterogeneous/PixelTrackSoAGPU', ) siPixelPhase1MonitorVertexSoACPU = siPixelPhase1MonitorVertexSoA.clone( pixelVertexSrc = 'pixelVerticesSoA@cpu', - TopFolderName = 'SiPixelHeterogeneous/PixelVertexSoACPU', + topFolderName = 'SiPixelHeterogeneous/PixelVertexSoACPU', ) siPixelPhase1MonitorVertexSoAGPU = siPixelPhase1MonitorVertexSoA.clone( pixelVertexSrc = 'pixelVerticesSoA@cuda', - TopFolderName = 'SiPixelHeterogeneous/PixelVertexSoAGPU', + topFolderName = 'SiPixelHeterogeneous/PixelVertexSoAGPU', ) From 40fddbbe74512392f38a755dc4c99b737fca0c8a Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 20 Apr 2022 11:24:05 +0200 Subject: [PATCH 20/57] add pT comparison plot in log-log scale --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index b89d04c395d62..6e28561a29454 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -23,6 +23,55 @@ // for string manipulations #include +namespace { + // same logic used for the MTV: + // cf https://github.com/cms-sw/cmssw/blob/master/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc + typedef dqm::reco::DQMStore DQMStore; + + void BinLogX(TH1* h) { + TAxis* axis = h->GetXaxis(); + int bins = axis->GetNbins(); + + float from = axis->GetXmin(); + float to = axis->GetXmax(); + float width = (to - from) / bins; + std::vector new_bins(bins + 1, 0); + + for (int i = 0; i <= bins; i++) { + new_bins[i] = TMath::Power(10, from + i * width); + } + + axis->Set(bins, new_bins.data()); + } + + void BinLogY(TH1* h) { + TAxis* axis = h->GetYaxis(); + int bins = axis->GetNbins(); + + float from = axis->GetXmin(); + float to = axis->GetXmax(); + float width = (to - from) / bins; + std::vector new_bins(bins + 1, 0); + + for (int i = 0; i <= bins; i++) { + new_bins[i] = TMath::Power(10, from + i * width); + } + + axis->Set(bins, new_bins.data()); + } + + template + dqm::reco::MonitorElement* make2DIfLog(DQMStore::IBooker& ibook, bool logx, bool logy, Args&&... args) { + auto h = std::make_unique(std::forward(args)...); + if (logx) + BinLogX(h.get()); + if (logy) + BinLogY(h.get()); + const auto& name = h->GetName(); + return ibook.book2D(name, h.release()); + } +} // namespace + class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { public: explicit SiPixelPhase1CompareTrackSoA(const edm::ParameterSet&); @@ -51,6 +100,7 @@ class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { MonitorElement* hChi2VsPhi_; MonitorElement* hChi2VsEta_; MonitorElement* hpt_; + MonitorElement* hptLogLog_; MonitorElement* heta_; MonitorElement* hphi_; MonitorElement* hz_; @@ -149,6 +199,7 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: hnHits_->Fill(tsoaCPU.nHits(it), tsoaGPU.nHits(closestTkidx)); hnLayers_->Fill(tsoaCPU.nLayers(it), tsoaGPU.nLayers(closestTkidx)); hpt_->Fill(tsoaCPU.pt(it), tsoaGPU.pt(closestTkidx)); + hptLogLog_->Fill(tsoaCPU.pt(it), tsoaGPU.pt(closestTkidx)); heta_->Fill(etacpu, tsoaGPU.eta(closestTkidx)); hphi_->Fill(phicpu, tsoaGPU.phi(closestTkidx)); hz_->Fill(tsoaCPU.zip(it), tsoaGPU.zip(closestTkidx)); @@ -184,6 +235,7 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, hchi2_ = iBook.book2D("nChi2ndof", fmt::sprintf("%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.); hpt_ = iBook.book2D("pt", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.); + hptLogLog_ = make2DIfLog(iBook, true, true, "ptLogLog", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, log10(0.5), log10(200.), 200, log10(0.5), log10(200.)); heta_ = iBook.book2D("eta", "Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.); hphi_ = iBook.book2D("phi", "Track (quality #geq loose) #phi;CPU;GPU", 30, -M_PI, M_PI, 30, -M_PI, M_PI); hz_ = iBook.book2D("z", "Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.); From 8890b12d90af81a442202a14ecc8ddbbc492feb9 Mon Sep 17 00:00:00 2001 From: Suvankar Roy Chowdhury Date: Wed, 20 Apr 2022 16:52:58 +0200 Subject: [PATCH 21/57] add 1D plot and 2D ratio plots --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 32 +++++++++++ .../SiPixelPhase1TrackComparisonHarvester.cc | 57 +++++++++++++++++++ ...ixelPhase1HeterogenousDQMHarvesting_cff.py | 4 +- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index 6e28561a29454..57584401b54e6 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -9,6 +9,7 @@ // #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/Math/interface/deltaPhi.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -106,6 +107,16 @@ class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer { MonitorElement* hz_; MonitorElement* htip_; MonitorElement* hquality_; + //1D differences + MonitorElement* hptdiffMatched_; + MonitorElement* hetadiffMatched_; + MonitorElement* hphidiffMatched_; + MonitorElement* hzdiffMatched_; + //for matching eff vs region:dervie ration at harvesting + MonitorElement* hpt_eta_tkAllCPU_; + MonitorElement* hpt_eta_tkAllCPUMatched_; + MonitorElement* hphi_z_tkAllCPU_; + MonitorElement* hphi_z_tkAllCPUMatched_; }; // @@ -191,6 +202,9 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: closestTkidx = gid; } } + + hpt_eta_tkAllCPU_->Fill(etacpu, tsoaCPU.pt(it)); //all CPU tk + hphi_z_tkAllCPU_->Fill(tsoaCPU.zip(it), phicpu); if (closestTkidx == notFound) continue; nLooseAndAboveTracksCPU_matchedGPU++; @@ -204,6 +218,12 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: hphi_->Fill(phicpu, tsoaGPU.phi(closestTkidx)); hz_->Fill(tsoaCPU.zip(it), tsoaGPU.zip(closestTkidx)); htip_->Fill(tsoaCPU.tip(it), tsoaGPU.tip(closestTkidx)); + hptdiffMatched_->Fill(tsoaCPU.pt(it) - tsoaGPU.pt(closestTkidx)); + hetadiffMatched_->Fill(etacpu - tsoaGPU.eta(closestTkidx)); + hphidiffMatched_->Fill(reco::deltaPhi(phicpu, tsoaGPU.phi(closestTkidx))); + hzdiffMatched_->Fill(tsoaCPU.zip(it) - tsoaGPU.zip(closestTkidx)); + hpt_eta_tkAllCPUMatched_->Fill(etacpu, tsoaCPU.pt(it)); //matched to gpu + hphi_z_tkAllCPUMatched_->Fill(tsoaCPU.zip(it), phicpu); } hnTracks_->Fill(nTracksCPU, nTracksGPU); hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); @@ -240,6 +260,18 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, hphi_ = iBook.book2D("phi", "Track (quality #geq loose) #phi;CPU;GPU", 30, -M_PI, M_PI, 30, -M_PI, M_PI); hz_ = iBook.book2D("z", "Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.); htip_ = iBook.book2D("tip", "Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5); + //1D difference plots + hptdiffMatched_ = iBook.book1D("ptdiffmatched", " p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 60, -30., 30.); + hetadiffMatched_ = iBook.book1D("etadiffmatched", " #eta diff between matched tracks; #Delta #eta", 300, -3., 3); + hphidiffMatched_ = iBook.book1D("phidiffmatched", " #phi diff between matched tracks; #Delta #phi", 300, -M_PI, M_PI); + hzdiffMatched_ = iBook.book1D("zdiffmatched", " z diff between matched tracks; #Delta z [cm]", 60, -30, 30.); + //2D plots for eff + hpt_eta_tkAllCPU_ = iBook.book2D("ptetatrkAllCPU", "Track (quality #geq loose) on CPU; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); + hpt_eta_tkAllCPUMatched_ = iBook.book2D("ptetatrkAllCPUmatched", "Track (quality #geq loose) on CPU matched to GPU track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); + + hphi_z_tkAllCPU_ = iBook.book2D("phiztrkAllCPU", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -30., 30., 30, -M_PI, M_PI); + hphi_z_tkAllCPUMatched_ = iBook.book2D("phiztrkAllCPUmatched", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -30., 30., 30, -M_PI, M_PI); + } void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc new file mode 100644 index 0000000000000..3cd4189fd91e6 --- /dev/null +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc @@ -0,0 +1,57 @@ +#include "DQMServices/Core/interface/DQMEDHarvester.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/MakerMacros.h" +class SiPixelPhase1TrackComparisonHarvester : public DQMEDHarvester { +public: + explicit SiPixelPhase1TrackComparisonHarvester(const edm::ParameterSet&); + ~SiPixelPhase1TrackComparisonHarvester() override; + void dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + + // ----------member data --------------------------- + const std::string topFolder_; +}; + +SiPixelPhase1TrackComparisonHarvester::SiPixelPhase1TrackComparisonHarvester(const edm::ParameterSet& iConfig) + : topFolder_(iConfig.getParameter("topFolderName")) { +} + +SiPixelPhase1TrackComparisonHarvester::~SiPixelPhase1TrackComparisonHarvester() {} + +void SiPixelPhase1TrackComparisonHarvester::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) { + MonitorElement* hpt_eta_tkAllCPU = igetter.get(topFolder_ + "/ptetatrkAllCPU"); + MonitorElement* hpt_eta_tkAllCPUmatched = igetter.get(topFolder_ + "/ptetatrkAllCPUmatched"); + MonitorElement* hphi_z_tkAllCPU_ = igetter.get(topFolder_ + "/phiztrkAllCPU"); + MonitorElement* hphi_z_tkAllCPUmatched_ = igetter.get(topFolder_ + "/phiztrkAllCPUmatched"); + + ibooker.cd(); + ibooker.setCurrentFolder(topFolder_); + MonitorElement* hpt_eta_matchRatio = ibooker.book2D("matchingeff_pt_eta", "Efficiency of track matching; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); + MonitorElement* hphi_z_matchRatio = ibooker.book2D("matchingeff_phi_z", "Efficiency of track matching; #phi; z [cm];", 30, -30., 30., 60, -M_PI, M_PI); + + hpt_eta_matchRatio->divide(hpt_eta_tkAllCPUmatched, hpt_eta_tkAllCPU, 1., 1., "B"); + hphi_z_matchRatio->divide(hphi_z_tkAllCPUmatched_, hphi_z_tkAllCPU_, 1., 1., "B"); +} + + +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +void SiPixelPhase1TrackComparisonHarvester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU/"); + descriptions.add("siPixelPhase1TrackComparisonHarvester", desc); + // or use the following to generate the label from the module's C++ type + //descriptions.addWithDefaultLabel(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(SiPixelPhase1TrackComparisonHarvester); diff --git a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py index 143c1bea945e1..e5bd597650ead 100644 --- a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py +++ b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py @@ -1,2 +1,4 @@ import FWCore.ParameterSet.Config as cms -siPixelPhase1HeterogenousDQMHarvesting = cms.Sequence() +from DQM.SiPixelPhase1Heterogeneous.siPixelPhase1TrackComparisonHarvester_cfi import * + +siPixelPhase1HeterogenousDQMHarvesting = cms.Sequence(siPixelPhase1TrackComparisonHarvester) From 1465cf714595fc4b5f3be8f2996f5afac3f2804e Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 20 Apr 2022 18:29:59 +0200 Subject: [PATCH 22/57] clean-up harvester code --- .../SiPixelPhase1TrackComparisonHarvester.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc index 3cd4189fd91e6..08362bb2e6134 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc @@ -10,22 +10,18 @@ class SiPixelPhase1TrackComparisonHarvester : public DQMEDHarvester { public: explicit SiPixelPhase1TrackComparisonHarvester(const edm::ParameterSet&); - ~SiPixelPhase1TrackComparisonHarvester() override; + ~SiPixelPhase1TrackComparisonHarvester() override = default; void dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - // ----------member data --------------------------- const std::string topFolder_; }; SiPixelPhase1TrackComparisonHarvester::SiPixelPhase1TrackComparisonHarvester(const edm::ParameterSet& iConfig) - : topFolder_(iConfig.getParameter("topFolderName")) { -} - -SiPixelPhase1TrackComparisonHarvester::~SiPixelPhase1TrackComparisonHarvester() {} + : topFolder_(iConfig.getParameter("topFolderName")) {} void SiPixelPhase1TrackComparisonHarvester::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) { MonitorElement* hpt_eta_tkAllCPU = igetter.get(topFolder_ + "/ptetatrkAllCPU"); @@ -35,22 +31,21 @@ void SiPixelPhase1TrackComparisonHarvester::dqmEndJob(DQMStore::IBooker& ibooker ibooker.cd(); ibooker.setCurrentFolder(topFolder_); - MonitorElement* hpt_eta_matchRatio = ibooker.book2D("matchingeff_pt_eta", "Efficiency of track matching; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - MonitorElement* hphi_z_matchRatio = ibooker.book2D("matchingeff_phi_z", "Efficiency of track matching; #phi; z [cm];", 30, -30., 30., 60, -M_PI, M_PI); + MonitorElement* hpt_eta_matchRatio = ibooker.book2D( + "matchingeff_pt_eta", "Efficiency of track matching; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); + MonitorElement* hphi_z_matchRatio = ibooker.book2D( + "matchingeff_phi_z", "Efficiency of track matching; #phi; z [cm];", 30, -30., 30., 60, -M_PI, M_PI); hpt_eta_matchRatio->divide(hpt_eta_tkAllCPUmatched, hpt_eta_tkAllCPU, 1., 1., "B"); hphi_z_matchRatio->divide(hphi_z_tkAllCPUmatched_, hphi_z_tkAllCPU_, 1., 1., "B"); } - #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" void SiPixelPhase1TrackComparisonHarvester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU/"); descriptions.add("siPixelPhase1TrackComparisonHarvester", desc); - // or use the following to generate the label from the module's C++ type - //descriptions.addWithDefaultLabel(desc); } //define this as a plug-in From 893c827a3811079e0450ccc674c7c9c661031478 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 20 Apr 2022 20:17:28 +0200 Subject: [PATCH 23/57] simplify the logarithmic binning code and fix bug in SiPixelPhase1TrackComparisonHarvester --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 37 +++++++------------ .../SiPixelPhase1TrackComparisonHarvester.cc | 2 +- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index 57584401b54e6..dc10f9d31f1e0 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -29,45 +29,34 @@ namespace { // cf https://github.com/cms-sw/cmssw/blob/master/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc typedef dqm::reco::DQMStore DQMStore; - void BinLogX(TH1* h) { - TAxis* axis = h->GetXaxis(); + void setBinLog(TAxis* axis) { int bins = axis->GetNbins(); - float from = axis->GetXmin(); float to = axis->GetXmax(); float width = (to - from) / bins; std::vector new_bins(bins + 1, 0); - for (int i = 0; i <= bins; i++) { new_bins[i] = TMath::Power(10, from + i * width); } - axis->Set(bins, new_bins.data()); } - void BinLogY(TH1* h) { + void setBinLogX(TH1* h) { + TAxis* axis = h->GetXaxis(); + setBinLog(axis); + } + void setBinLogY(TH1* h) { TAxis* axis = h->GetYaxis(); - int bins = axis->GetNbins(); - - float from = axis->GetXmin(); - float to = axis->GetXmax(); - float width = (to - from) / bins; - std::vector new_bins(bins + 1, 0); - - for (int i = 0; i <= bins; i++) { - new_bins[i] = TMath::Power(10, from + i * width); - } - - axis->Set(bins, new_bins.data()); + setBinLog(axis); } template dqm::reco::MonitorElement* make2DIfLog(DQMStore::IBooker& ibook, bool logx, bool logy, Args&&... args) { auto h = std::make_unique(std::forward(args)...); if (logx) - BinLogX(h.get()); + setBinLogX(h.get()); if (logy) - BinLogY(h.get()); + setBinLogY(h.get()); const auto& name = h->GetName(); return ibook.book2D(name, h.release()); } @@ -204,7 +193,7 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: } hpt_eta_tkAllCPU_->Fill(etacpu, tsoaCPU.pt(it)); //all CPU tk - hphi_z_tkAllCPU_->Fill(tsoaCPU.zip(it), phicpu); + hphi_z_tkAllCPU_->Fill(phicpu, tsoaCPU.zip(it)); if (closestTkidx == notFound) continue; nLooseAndAboveTracksCPU_matchedGPU++; @@ -223,7 +212,7 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm:: hphidiffMatched_->Fill(reco::deltaPhi(phicpu, tsoaGPU.phi(closestTkidx))); hzdiffMatched_->Fill(tsoaCPU.zip(it) - tsoaGPU.zip(closestTkidx)); hpt_eta_tkAllCPUMatched_->Fill(etacpu, tsoaCPU.pt(it)); //matched to gpu - hphi_z_tkAllCPUMatched_->Fill(tsoaCPU.zip(it), phicpu); + hphi_z_tkAllCPUMatched_->Fill(phicpu, tsoaCPU.zip(it)); } hnTracks_->Fill(nTracksCPU, nTracksGPU); hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); @@ -269,8 +258,8 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, hpt_eta_tkAllCPU_ = iBook.book2D("ptetatrkAllCPU", "Track (quality #geq loose) on CPU; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); hpt_eta_tkAllCPUMatched_ = iBook.book2D("ptetatrkAllCPUmatched", "Track (quality #geq loose) on CPU matched to GPU track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - hphi_z_tkAllCPU_ = iBook.book2D("phiztrkAllCPU", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -30., 30., 30, -M_PI, M_PI); - hphi_z_tkAllCPUMatched_ = iBook.book2D("phiztrkAllCPUmatched", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -30., 30., 30, -M_PI, M_PI); + hphi_z_tkAllCPU_ = iBook.book2D("phiztrkAllCPU", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); + hphi_z_tkAllCPUMatched_ = iBook.book2D("phiztrkAllCPUmatched", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); } diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc index 08362bb2e6134..75f27654c11c9 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc @@ -34,7 +34,7 @@ void SiPixelPhase1TrackComparisonHarvester::dqmEndJob(DQMStore::IBooker& ibooker MonitorElement* hpt_eta_matchRatio = ibooker.book2D( "matchingeff_pt_eta", "Efficiency of track matching; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); MonitorElement* hphi_z_matchRatio = ibooker.book2D( - "matchingeff_phi_z", "Efficiency of track matching; #phi; z [cm];", 30, -30., 30., 60, -M_PI, M_PI); + "matchingeff_phi_z", "Efficiency of track matching; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); hpt_eta_matchRatio->divide(hpt_eta_tkAllCPUmatched, hpt_eta_tkAllCPU, 1., 1., "B"); hphi_z_matchRatio->divide(hphi_z_tkAllCPUmatched_, hphi_z_tkAllCPU_, 1., 1., "B"); From 53b0e229258ce02a0719032af124065fe5880dab Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 20 Apr 2022 22:19:41 +0200 Subject: [PATCH 24/57] add gpuValidation process modifier in the HARVESTING step for the patatrack pixel-related workflows --- .../PyReleaseValidation/python/upgradeWorkflowComponents.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 09fbd2cf20788..eab4848eeb862 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -611,7 +611,8 @@ def setup_(self, step, stepName, stepDict, k, properties): '--procModifiers': 'pixelNtupletFit,gpuValidation' }, harvest = { - '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM', + '--procModifiers': 'gpuValidation' }, suffix = 'Patatrack_PixelOnlyGPU_Validation', offset = 0.503, @@ -693,7 +694,8 @@ def setup_(self, step, stepName, stepDict, k, properties): '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksForTriplets.customizePixelTracksForTriplets' }, harvest = { - '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM', + '--procModifiers': 'gpuValidation', }, suffix = 'Patatrack_PixelOnlyTripletsGPU_Validation', offset = 0.507, From 3addb167d61c3fd98a3c2293db2ba42c0c77f918 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 20 Apr 2022 16:37:15 +0200 Subject: [PATCH 25/57] get rid of residual deprecation warnings in DataFormats/SiStripCommon --- .../test/plugins/examples_SiStripFecKey.cc | 43 ++++++++++--- .../test/plugins/examples_SiStripFecKey.h | 27 -------- .../SiStripCommon/test/plugins/modules.cc | 28 -------- .../test/plugins/perf_SiStripFecKey.cc | 64 +++++++++++++++++-- .../test/plugins/perf_SiStripFecKey.h | 53 --------------- .../plugins/test_SiStripEnumsAndStrings.cc | 29 +++++++-- .../plugins/test_SiStripEnumsAndStrings.h | 22 ------- .../test/plugins/test_SiStripFecKey.cc | 32 +++++++++- .../test/plugins/test_SiStripFecKey.h | 31 --------- .../test/plugins/test_SiStripFedKey.cc | 33 ++++++++-- .../test/plugins/test_SiStripFedKey.h | 22 ------- .../test/plugins/test_SiStripHistoTitle.cc | 37 ++++++++--- .../test/plugins/test_SiStripHistoTitle.h | 22 ------- .../test/plugins/test_SiStripKey.cc | 44 ++++++++++--- .../test/plugins/test_SiStripKey.h | 29 --------- .../test/plugins/test_SiStripNullKey.cc | 33 ++++++++-- .../test/plugins/test_SiStripNullKey.h | 22 ------- .../test/plugins/test_Template.cc | 29 +++++++-- .../test/plugins/test_Template.h | 24 ------- 19 files changed, 285 insertions(+), 339 deletions(-) delete mode 100644 DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/modules.cc delete mode 100644 DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_SiStripKey.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.h delete mode 100644 DataFormats/SiStripCommon/test/plugins/test_Template.h diff --git a/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.cc b/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.cc index 9a1db31d05c77..8724db100d4fd 100644 --- a/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.cc +++ b/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.cc @@ -1,16 +1,38 @@ - -#include "DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.h" -#include "FWCore/Framework/interface/Event.h" -#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" -#include "DataFormats/SiStripCommon/interface/Constants.h" -#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include +// system includes +#include +#include #include +#include #include #include #include -#include +#include + +// user includes +#include "DataFormats/SiStripCommon/interface/Constants.h" +#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +/** + @class examplesSiStripFecKey + @author R.Bainbridge + @brief Simple class that tests SiStripFecKey. +*/ + +class examplesSiStripFecKey : public edm::one::EDAnalyzer<> { +public: + examplesSiStripFecKey(const edm::ParameterSet&); + ~examplesSiStripFecKey(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: + void buildKeys(std::vector&); +}; using namespace sistrip; @@ -92,3 +114,6 @@ void examplesSiStripFecKey::analyze(const edm::Event& event, const edm::EventSet LogTrace(mlDqmCommon_) << "[SiStripFecKey::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(examplesSiStripFecKey); diff --git a/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.h b/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.h deleted file mode 100644 index 3cd32bfef5fa0..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_examplesSiStripFecKey_H -#define DataFormats_SiStripCommon_examplesSiStripFecKey_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include -#include - -/** - @class examplesSiStripFecKey - @author R.Bainbridge - @brief Simple class that tests SiStripFecKey. -*/ -class examplesSiStripFecKey : public edm::EDAnalyzer { -public: - examplesSiStripFecKey(const edm::ParameterSet&); - ~examplesSiStripFecKey(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } - -private: - void buildKeys(std::vector&); -}; - -#endif // DataFormats_SiStripCommon_examplesSiStripFecKey_H diff --git a/DataFormats/SiStripCommon/test/plugins/modules.cc b/DataFormats/SiStripCommon/test/plugins/modules.cc deleted file mode 100644 index 7198f9847a35c..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/modules.cc +++ /dev/null @@ -1,28 +0,0 @@ -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.h" -DEFINE_FWK_MODULE(testSiStripFecKey); - -#include "DataFormats/SiStripCommon/test/plugins/examples_SiStripFecKey.h" -DEFINE_FWK_MODULE(examplesSiStripFecKey); - -#include "DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.h" -DEFINE_FWK_MODULE(perfSiStripFecKey); - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.h" -DEFINE_FWK_MODULE(testSiStripFedKey); - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.h" -DEFINE_FWK_MODULE(testSiStripNullKey); - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripKey.h" -DEFINE_FWK_MODULE(testSiStripKey); - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.h" -DEFINE_FWK_MODULE(testSiStripEnumsAndStrings); - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.h" -DEFINE_FWK_MODULE(testSiStripHistoTitle); - -#include "DataFormats/SiStripCommon/test/plugins/test_Template.h" -DEFINE_FWK_MODULE(test_Template); diff --git a/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.cc b/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.cc index 89f4542d20bb0..3c67857f2b142 100644 --- a/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.cc +++ b/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.cc @@ -1,10 +1,6 @@ - -#include "DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/SiStripCommon/interface/Constants.h" -#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" +// system includes +#include +#include #include #include #include @@ -12,6 +8,57 @@ #include #include +// user includes +#include "DataFormats/SiStripCommon/interface/Constants.h" +#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" +#include "DataFormats/SiStripCommon/interface/SiStripKey.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +/** + @class perfSiStripFecKey + @author R.Bainbridge + @brief Simple class that tests SiStripFecKey. +*/ +class perfSiStripFecKey : public edm::one::EDAnalyzer<> { +public: + perfSiStripFecKey(const edm::ParameterSet&); + ~perfSiStripFecKey(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: + class Value { + public: + uint16_t crate_, slot_, ring_, ccu_, module_, lld_, i2c_; + Value() : crate_(0), slot_(0), ring_(0), ccu_(0), module_(0), lld_(0), i2c_(0) { ; } + Value(uint16_t crate, uint16_t slot, uint16_t ring, uint16_t ccu, uint16_t module, uint16_t lld, uint16_t i2c) + : crate_(crate), slot_(slot), ring_(ring), ccu_(ccu), module_(module), lld_(lld), i2c_(i2c) { + ; + } + }; + + void build(std::vector&, + std::vector&, + std::vector&, + std::vector&, + std::vector&); + + void build(const std::vector&) const; + void build(const std::vector&) const; + void build(const std::vector&) const; + void build(const std::vector&) const; + void build(const std::vector&) const; + + void test(const std::vector&) const; + + uint32_t loops_; +}; + using namespace sistrip; // ----------------------------------------------------------------------------- @@ -205,3 +252,6 @@ void perfSiStripFecKey::build(std::vector& values, // std::sort( derived.begin(), derived.end() ); // std::sort( base.begin(), base.end() ); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(perfSiStripFecKey); diff --git a/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.h b/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.h deleted file mode 100644 index e75e89dd53511..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/perf_SiStripFecKey.h +++ /dev/null @@ -1,53 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_perfSiStripFecKey_H -#define DataFormats_SiStripCommon_perfSiStripFecKey_H - -#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" -#include "DataFormats/SiStripCommon/interface/SiStripKey.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include -#include - -/** - @class perfSiStripFecKey - @author R.Bainbridge - @brief Simple class that tests SiStripFecKey. -*/ -class perfSiStripFecKey : public edm::EDAnalyzer { -public: - perfSiStripFecKey(const edm::ParameterSet&); - ~perfSiStripFecKey(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } - -private: - class Value { - public: - uint16_t crate_, slot_, ring_, ccu_, module_, lld_, i2c_; - Value() : crate_(0), slot_(0), ring_(0), ccu_(0), module_(0), lld_(0), i2c_(0) { ; } - Value(uint16_t crate, uint16_t slot, uint16_t ring, uint16_t ccu, uint16_t module, uint16_t lld, uint16_t i2c) - : crate_(crate), slot_(slot), ring_(ring), ccu_(ccu), module_(module), lld_(lld), i2c_(i2c) { - ; - } - }; - - void build(std::vector&, - std::vector&, - std::vector&, - std::vector&, - std::vector&); - - void build(const std::vector&) const; - void build(const std::vector&) const; - void build(const std::vector&) const; - void build(const std::vector&) const; - void build(const std::vector&) const; - - void test(const std::vector&) const; - - uint32_t loops_; -}; - -#endif // DataFormats_SiStripCommon_perfSiStripFecKey_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.cc b/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.cc index 4a6897c90463b..b43be846c5833 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.cc @@ -1,15 +1,31 @@ - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.h" -#include "FWCore/Framework/interface/Event.h" -#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" +// user includes #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include + +// system includes #include +#include #include #include #include +/** + @class testSiStripEnumsAndStrings + @author R.Bainbridge + @brief Simple class that tests SiStripEnumsAndStrings. +*/ +class testSiStripEnumsAndStrings : public edm::one::EDAnalyzer<> { +public: + testSiStripEnumsAndStrings(const edm::ParameterSet&); + ~testSiStripEnumsAndStrings(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); +}; + using namespace sistrip; // ----------------------------------------------------------------------------- @@ -216,3 +232,6 @@ void testSiStripEnumsAndStrings::analyze(const edm::Event& event, const edm::Eve LogTrace(mlDqmCommon_) << "[SiStripEnumsAndStrings::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(testSiStripEnumsAndStrings); diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.h b/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.h deleted file mode 100644 index 84a2329a70a63..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripEnumsAndStrings.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_testSiStripEnumsAndStrings_H -#define DataFormats_SiStripCommon_testSiStripEnumsAndStrings_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -/** - @class testSiStripEnumsAndStrings - @author R.Bainbridge - @brief Simple class that tests SiStripEnumsAndStrings. -*/ -class testSiStripEnumsAndStrings : public edm::EDAnalyzer { -public: - testSiStripEnumsAndStrings(const edm::ParameterSet&); - ~testSiStripEnumsAndStrings(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } -}; - -#endif // DataFormats_SiStripCommon_testSiStripEnumsAndStrings_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.cc b/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.cc index 9b751de8acd33..864fec51f6fed 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.cc @@ -1,12 +1,37 @@ +// system includes +#include -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.h" +// user includes +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include + +/** + @class testSiStripFecKey + @author R.Bainbridge + @brief Simple class that tests SiStripFecKey. +*/ +class testSiStripFecKey : public edm::one::EDAnalyzer<> { +public: + testSiStripFecKey(const edm::ParameterSet&); + ~testSiStripFecKey(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: + const uint32_t crate_; + const uint32_t slot_; + const uint32_t ring_; + const uint32_t ccu_; + const uint32_t module_; + const uint32_t lld_; + const uint32_t i2c_; +}; using namespace sistrip; @@ -170,3 +195,6 @@ void testSiStripFecKey::analyze(const edm::Event& event, const edm::EventSetup& LogTrace(mlDqmCommon_) << "[SiStripFecKey::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(testSiStripFecKey); diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.h b/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.h deleted file mode 100644 index 71535eb8d9e8a..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripFecKey.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_testSiStripFecKey_H -#define DataFormats_SiStripCommon_testSiStripFecKey_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -/** - @class testSiStripFecKey - @author R.Bainbridge - @brief Simple class that tests SiStripFecKey. -*/ -class testSiStripFecKey : public edm::EDAnalyzer { -public: - testSiStripFecKey(const edm::ParameterSet&); - ~testSiStripFecKey(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } - -private: - uint32_t crate_; - uint32_t slot_; - uint32_t ring_; - uint32_t ccu_; - uint32_t module_; - uint32_t lld_; - uint32_t i2c_; -}; - -#endif // DataFormats_SiStripCommon_testSiStripFecKey_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.cc b/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.cc index 37853f170e8dc..ba5dfcadf497a 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.cc @@ -1,16 +1,32 @@ - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.h" -#include "FWCore/Framework/interface/Event.h" -#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" -#include "DataFormats/SiStripCommon/interface/Constants.h" -#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" +// system includes #include #include #include #include #include +// user includes +#include "DataFormats/SiStripCommon/interface/Constants.h" +#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +/** + @class testSiStripFedKey + @author R.Bainbridge + @brief Simple class that tests SiStripFedKey. +*/ +class testSiStripFedKey : public edm::one::EDAnalyzer<> { +public: + testSiStripFedKey(const edm::ParameterSet&); + ~testSiStripFedKey(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); +}; + using namespace sistrip; // ----------------------------------------------------------------------------- @@ -165,3 +181,6 @@ void testSiStripFedKey::analyze(const edm::Event& event, const edm::EventSetup& LogTrace(mlDqmCommon_) << "[SiStripFedKey::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(testSiStripFedKey); diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.h b/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.h deleted file mode 100644 index bc6597b5974be..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripFedKey.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_testSiStripFedKey_H -#define DataFormats_SiStripCommon_testSiStripFedKey_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -/** - @class testSiStripFedKey - @author R.Bainbridge - @brief Simple class that tests SiStripFedKey. -*/ -class testSiStripFedKey : public edm::EDAnalyzer { -public: - testSiStripFedKey(const edm::ParameterSet&); - ~testSiStripFedKey(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } -}; - -#endif // DataFormats_SiStripCommon_testSiStripFedKey_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.cc b/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.cc index c00ad7c1bee9f..6d7c2e566a5ff 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.cc @@ -1,18 +1,34 @@ - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.h" -#include "FWCore/Framework/interface/Event.h" -#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" -#include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h" -#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" -#include "DataFormats/SiStripCommon/interface/Constants.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" +// system includes #include #include #include #include #include +// user includes +#include "DataFormats/SiStripCommon/interface/Constants.h" +#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" +#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" +#include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +/** + @class testSiStripHistoTitle + @author R.Bainbridge + @brief Simple class that tests SiStripHistoTitle. +*/ +class testSiStripHistoTitle : public edm::one::EDAnalyzer<> { +public: + testSiStripHistoTitle(const edm::ParameterSet&); + ~testSiStripHistoTitle(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); +}; + using namespace sistrip; // ----------------------------------------------------------------------------- @@ -205,3 +221,6 @@ void testSiStripHistoTitle::analyze(const edm::Event& event, const edm::EventSet LogTrace(mlDqmCommon_) << "[SiStripHistoTitle::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(testSiStripHistoTitle); diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.h b/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.h deleted file mode 100644 index 4378abdc46797..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripHistoTitle.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_testSiStripHistoTitle_H -#define DataFormats_SiStripCommon_testSiStripHistoTitle_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -/** - @class testSiStripHistoTitle - @author R.Bainbridge - @brief Simple class that tests SiStripHistoTitle. -*/ -class testSiStripHistoTitle : public edm::EDAnalyzer { -public: - testSiStripHistoTitle(const edm::ParameterSet&); - ~testSiStripHistoTitle(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } -}; - -#endif // DataFormats_SiStripCommon_testSiStripHistoTitle_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.cc b/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.cc index 58f22bc81cc93..67f291375ffc8 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.cc @@ -1,17 +1,40 @@ - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripKey.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" -#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" -#include "DataFormats/SiStripCommon/interface/SiStripDetKey.h" -#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" +// system includes +#include #include #include #include #include +// user includes +#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripDetKey.h" +#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" +#include "DataFormats/SiStripCommon/interface/SiStripFecKey.h" +#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +/** + @class testSiStripKey + @author R.Bainbridge + @brief Simple class that tests SiStripKey. +*/ +class testSiStripKey : public edm::one::EDAnalyzer<> { +public: + testSiStripKey(const edm::ParameterSet&); + ~testSiStripKey(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: + sistrip::KeyType keyType_; + uint32_t key_; + std::string path_; +}; + using namespace sistrip; // ----------------------------------------------------------------------------- @@ -134,3 +157,6 @@ void testSiStripKey::analyze(const edm::Event& event, const edm::EventSetup& set LogTrace(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(testSiStripKey); diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.h b/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.h deleted file mode 100644 index b032546f82f2c..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripKey.h +++ /dev/null @@ -1,29 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_testSiStripKey_H -#define DataFormats_SiStripCommon_testSiStripKey_H - -#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include - -/** - @class testSiStripKey - @author R.Bainbridge - @brief Simple class that tests SiStripKey. -*/ -class testSiStripKey : public edm::EDAnalyzer { -public: - testSiStripKey(const edm::ParameterSet&); - ~testSiStripKey(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } - -private: - sistrip::KeyType keyType_; - uint32_t key_; - std::string path_; -}; - -#endif // DataFormats_SiStripCommon_testSiStripKey_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.cc b/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.cc index 71701e1a88b6e..a0fb426392103 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.cc @@ -1,15 +1,31 @@ - -#include "DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.h" -#include "FWCore/Framework/interface/Event.h" -#include "DataFormats/SiStripCommon/interface/SiStripNullKey.h" -#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include +// system includes #include +#include #include #include #include +// user includes +#include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "DataFormats/SiStripCommon/interface/SiStripNullKey.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +/** + @class testSiStripNullKey + @author R.Bainbridge + @brief Simple class that tests SiStripNullKey. +*/ +class testSiStripNullKey : public edm::one::EDAnalyzer<> { +public: + testSiStripNullKey(const edm::ParameterSet&); + ~testSiStripNullKey(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); +}; + using namespace sistrip; // ----------------------------------------------------------------------------- @@ -71,3 +87,6 @@ void testSiStripNullKey::analyze(const edm::Event& event, const edm::EventSetup& LogTrace(mlDqmCommon_) << "[SiStripNullKey::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(testSiStripNullKey); diff --git a/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.h b/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.h deleted file mode 100644 index 19c3b28bf10ea..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_SiStripNullKey.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef DataFormats_SiStripCommon_testSiStripNullKey_H -#define DataFormats_SiStripCommon_testSiStripNullKey_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -/** - @class testSiStripNullKey - @author R.Bainbridge - @brief Simple class that tests SiStripNullKey. -*/ -class testSiStripNullKey : public edm::EDAnalyzer { -public: - testSiStripNullKey(const edm::ParameterSet&); - ~testSiStripNullKey(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } -}; - -#endif // DataFormats_SiStripCommon_testSiStripNullKey_H diff --git a/DataFormats/SiStripCommon/test/plugins/test_Template.cc b/DataFormats/SiStripCommon/test/plugins/test_Template.cc index 108262fdaf9b8..6c944196f0fb3 100644 --- a/DataFormats/SiStripCommon/test/plugins/test_Template.cc +++ b/DataFormats/SiStripCommon/test/plugins/test_Template.cc @@ -1,10 +1,28 @@ +// system includes +#include +#include -#include "DataFormats/SiStripCommon/test/plugins/test_Template.h" -#include "FWCore/Framework/interface/Event.h" +// user includes #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include -#include + +/** + @class test_Template + @author R.Bainbridge + @brief Simple class that tests Template. +*/ +class test_Template : public edm::one::EDAnalyzer<> { +public: + test_Template(const edm::ParameterSet&); + ~test_Template(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: +}; using namespace sistrip; @@ -37,3 +55,6 @@ void test_Template::analyze(const edm::Event& event, const edm::EventSetup& setu LogTrace(mlTest_) << "[test_Template::" << __func__ << "]" << " Analyzing run/event " << event.id().run() << "/" << event.id().event(); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(test_Template); diff --git a/DataFormats/SiStripCommon/test/plugins/test_Template.h b/DataFormats/SiStripCommon/test/plugins/test_Template.h deleted file mode 100644 index 7e2c270afbda8..0000000000000 --- a/DataFormats/SiStripCommon/test/plugins/test_Template.h +++ /dev/null @@ -1,24 +0,0 @@ - -#ifndef DQM_SiStripCommissioningClients_test_Template_H -#define DQM_SiStripCommissioningClients_test_Template_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -/** - @class test_Template - @author R.Bainbridge - @brief Simple class that tests Template. -*/ -class test_Template : public edm::EDAnalyzer { -public: - test_Template(const edm::ParameterSet&); - ~test_Template(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob() { ; } - -private: -}; - -#endif // DQM_SiStripCommissioningClients_test_Template_H From 344a6c7b08c57074f2e067f8ed3bc8794e95e3e1 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 21 Apr 2022 10:02:26 +0200 Subject: [PATCH 26/57] get rid of residual deprecation warnings in EventFilter/Phase2TrackerRawToDigi --- .../plugins/Phase2TrackerFEDTestAnalyzer.cc | 103 ++++++++++++------ .../plugins/Phase2TrackerFEDTestAnalyzer.h | 36 ------ .../test/plugins/module.cc | 5 - 3 files changed, 70 insertions(+), 74 deletions(-) delete mode 100644 EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.h delete mode 100644 EventFilter/Phase2TrackerRawToDigi/test/plugins/module.cc diff --git a/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.cc b/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.cc index e48c7db03a977..17cda25154e77 100644 --- a/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.cc +++ b/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.cc @@ -1,26 +1,59 @@ +// system includes +#include +#include + +// user includes #include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDTrailer.h" -#include "EventFilter/Phase2TrackerRawToDigi/interface/utils.h" -#include "EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.h" #include "EventFilter/Phase2TrackerRawToDigi/interface/Phase2TrackerFEDBuffer.h" #include "EventFilter/Phase2TrackerRawToDigi/interface/Phase2TrackerFEDChannel.h" #include "EventFilter/Phase2TrackerRawToDigi/interface/Phase2TrackerFEDHeader.h" #include "EventFilter/Phase2TrackerRawToDigi/interface/Phase2TrackerFEDRawChannelUnpacker.h" #include "EventFilter/Phase2TrackerRawToDigi/interface/Phase2TrackerFEDZSChannelUnpacker.h" +#include "EventFilter/Phase2TrackerRawToDigi/interface/utils.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#define LOGPRINT edm::LogPrint("Phase2TrackerFEDTestAnalyzer") + +/** + @class Phase2TrackerFEDTestAnalyzer + @brief Analyzes contents of FED_test_ collection +*/ + +class Phase2TrackerFEDTestAnalyzer : public edm::one::EDAnalyzer<> { +public: + typedef std::pair Fed; + typedef std::vector Feds; + typedef std::vector Channels; + typedef std::map ChannelsMap; + + Phase2TrackerFEDTestAnalyzer(const edm::ParameterSet&); + ~Phase2TrackerFEDTestAnalyzer(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + void endJob(); + +private: + const edm::EDGetTokenT token_; +}; using namespace Phase2Tracker; using namespace std; // ----------------------------------------------------------------------------- // -Phase2TrackerFEDTestAnalyzer::Phase2TrackerFEDTestAnalyzer(const edm::ParameterSet& pset) { +Phase2TrackerFEDTestAnalyzer::Phase2TrackerFEDTestAnalyzer(const edm::ParameterSet& pset) + : token_(consumes(pset.getParameter("ProductLabel"))) { LogDebug("Phase2TrackerFEDTestAnalyzer") << "[Phase2TrackerFEDTestAnalyzer::" << __func__ << "]" << "Constructing object..."; - token_ = consumes(pset.getParameter("ProductLabel")); } // ----------------------------------------------------------------------------- @@ -58,39 +91,39 @@ void Phase2TrackerFEDTestAnalyzer::analyze(const edm::Event& event, const edm::E Phase2Tracker::Phase2TrackerFEDBuffer* buffer = 0; buffer = new Phase2Tracker::Phase2TrackerFEDBuffer(fed.data(), fed.size()); - cout << " -------------------------------------------- " << endl; - cout << " buffer debug ------------------------------- " << endl; - cout << " -------------------------------------------- " << endl; - cout << " buffer size : " << buffer->bufferSize() << endl; - cout << " fed id : " << fedIndex << endl; - cout << " -------------------------------------------- " << endl; - cout << " tracker header debug ------------------------" << endl; - cout << " -------------------------------------------- " << endl; + LOGPRINT << " -------------------------------------------- "; + LOGPRINT << " buffer debug ------------------------------- "; + LOGPRINT << " -------------------------------------------- "; + LOGPRINT << " buffer size : " << buffer->bufferSize(); + LOGPRINT << " fed id : " << fedIndex; + LOGPRINT << " -------------------------------------------- "; + LOGPRINT << " tracker header debug ------------------------"; + LOGPRINT << " -------------------------------------------- "; Phase2TrackerFEDHeader tr_header = buffer->trackerHeader(); - cout << " Version : " << hex << setw(2) << (int)tr_header.getDataFormatVersion() << endl; - cout << " Mode : " << hex << setw(2) << (int)tr_header.getDebugMode() << endl; - cout << " Type : " << hex << setw(2) << (int)tr_header.getEventType() << endl; - cout << " Readout : " << hex << setw(2) << (int)tr_header.getReadoutMode() << endl; - cout << " Status : " << hex << setw(16) << (int)tr_header.getGlibStatusCode() << endl; - cout << " FE stat : "; + LOGPRINT << " Version : " << hex << setw(2) << (int)tr_header.getDataFormatVersion(); + LOGPRINT << " Mode : " << hex << setw(2) << (int)tr_header.getDebugMode(); + LOGPRINT << " Type : " << hex << setw(2) << (int)tr_header.getEventType(); + LOGPRINT << " Readout : " << hex << setw(2) << (int)tr_header.getReadoutMode(); + LOGPRINT << " Status : " << hex << setw(16) << (int)tr_header.getGlibStatusCode(); + LOGPRINT << " FE stat : "; for (int i = 15; i >= 0; i--) { if ((tr_header.frontendStatus())[i]) { - cout << "1"; + LOGPRINT << "1"; } else { - cout << "0"; + LOGPRINT << "0"; } } - cout << endl; - cout << " Nr CBC : " << hex << setw(16) << (int)tr_header.getNumberOfCBC() << endl; - cout << " CBC stat : "; + LOGPRINT << "\n"; + LOGPRINT << " Nr CBC : " << hex << setw(16) << (int)tr_header.getNumberOfCBC(); + LOGPRINT << " CBC stat : "; for (int i = 0; i < tr_header.getNumberOfCBC(); i++) { - cout << hex << setw(2) << (int)tr_header.CBCStatus()[i] << " "; + LOGPRINT << hex << setw(2) << (int)tr_header.CBCStatus()[i] << " "; } - cout << endl; - cout << " -------------------------------------------- " << endl; - cout << " Payload ----------------------------------- " << endl; - cout << " -------------------------------------------- " << endl; + LOGPRINT << "\n"; + LOGPRINT << " -------------------------------------------- "; + LOGPRINT << " Payload ----------------------------------- "; + LOGPRINT << " -------------------------------------------- "; // loop channels int ichan = 0; @@ -98,14 +131,14 @@ void Phase2TrackerFEDTestAnalyzer::analyze(const edm::Event& event, const edm::E for (int icbc = 0; icbc < 16; icbc++) { const Phase2TrackerFEDChannel& channel = buffer->channel(ichan); if (channel.length() > 0) { - cout << dec << " reading channel : " << icbc << " on FE " << ife; - cout << dec << " with length : " << (int)channel.length() << endl; + LOGPRINT << dec << " reading channel : " << icbc << " on FE " << ife; + LOGPRINT << dec << " with length : " << (int)channel.length(); Phase2TrackerFEDRawChannelUnpacker unpacker = Phase2TrackerFEDRawChannelUnpacker(channel); while (unpacker.hasData()) { - std::cout << (unpacker.stripOn() ? "1" : "_"); + LOGPRINT << (unpacker.stripOn() ? "1" : "_"); unpacker++; } - std::cout << std::endl; + LOGPRINT << "\n"; } ichan++; } @@ -113,3 +146,7 @@ void Phase2TrackerFEDTestAnalyzer::analyze(const edm::Event& event, const edm::E } } } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(Phase2TrackerFEDTestAnalyzer); diff --git a/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.h b/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.h deleted file mode 100644 index 881dd4748e33f..0000000000000 --- a/EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDTestAnalyzer_H -#define EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDTestAnalyzer_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" -#include -#include - -/** - @class Phase2TrackerFEDTestAnalyzer - @brief Analyzes contents of FED_test_ collection -*/ - -class Phase2TrackerFEDTestAnalyzer : public edm::EDAnalyzer { -public: - typedef std::pair Fed; - typedef std::vector Feds; - typedef std::vector Channels; - typedef std::map ChannelsMap; - - Phase2TrackerFEDTestAnalyzer(const edm::ParameterSet&); - ~Phase2TrackerFEDTestAnalyzer(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob(); - -private: - edm::InputTag label_; - edm::EDGetTokenT token_; -}; - -#endif // EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDTestAnalyzer_H diff --git a/EventFilter/Phase2TrackerRawToDigi/test/plugins/module.cc b/EventFilter/Phase2TrackerRawToDigi/test/plugins/module.cc deleted file mode 100644 index 6d64bd1901da4..0000000000000 --- a/EventFilter/Phase2TrackerRawToDigi/test/plugins/module.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include "FWCore/PluginManager/interface/ModuleDef.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "EventFilter/Phase2TrackerRawToDigi/test/plugins/Phase2TrackerFEDTestAnalyzer.h" -DEFINE_FWK_MODULE(Phase2TrackerFEDTestAnalyzer); From b5ab65fcb5b420e7c11dea935bcba39f92cd8cd9 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 21 Apr 2022 16:21:17 +0200 Subject: [PATCH 27/57] get rid of deprection warnings in EventFilter/SiStripChannelChargeFilter --- .../interface/ClusterMTCCFilter.h | 6 +++--- .../interface/MTCCHLTrigger.h | 12 +++--------- .../interface/TECClusterFilter.h | 6 +++--- .../interface/TrackMTCCFilter.h | 4 ++-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/EventFilter/SiStripChannelChargeFilter/interface/ClusterMTCCFilter.h b/EventFilter/SiStripChannelChargeFilter/interface/ClusterMTCCFilter.h index 8757c8ef08739..e93dec7a630aa 100644 --- a/EventFilter/SiStripChannelChargeFilter/interface/ClusterMTCCFilter.h +++ b/EventFilter/SiStripChannelChargeFilter/interface/ClusterMTCCFilter.h @@ -9,7 +9,7 @@ // // Original Author: dkcira -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -19,10 +19,10 @@ class TrackerTopology; namespace cms { - class ClusterMTCCFilter : public edm::EDFilter { + class ClusterMTCCFilter : public edm::stream::EDFilter<> { public: ClusterMTCCFilter(const edm::ParameterSet& ps); - ~ClusterMTCCFilter() override {} + ~ClusterMTCCFilter() override = default; bool filter(edm::Event& e, edm::EventSetup const& c) override; private: diff --git a/EventFilter/SiStripChannelChargeFilter/interface/MTCCHLTrigger.h b/EventFilter/SiStripChannelChargeFilter/interface/MTCCHLTrigger.h index b084c155101fa..d7d1d09f3b345 100644 --- a/EventFilter/SiStripChannelChargeFilter/interface/MTCCHLTrigger.h +++ b/EventFilter/SiStripChannelChargeFilter/interface/MTCCHLTrigger.h @@ -1,28 +1,22 @@ #ifndef MTCCHLTrigger_H #define MTCCHLTrigger_H -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -// #include "SimDataFormats/TrackingHit/interface/PSimHit.h" -// #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" namespace cms { - class MTCCHLTrigger : public edm::EDFilter { + class MTCCHLTrigger : public edm::stream::EDFilter<> { public: MTCCHLTrigger(const edm::ParameterSet& ps); - ~MTCCHLTrigger() override {} + ~MTCCHLTrigger() override = default; bool filter(edm::Event& e, edm::EventSetup const& c) override; private: - // bool selOnClusterCharge; bool selOnDigiCharge; unsigned int ChargeThreshold; - // unsigned int digiChargeThreshold; - // std::string rawtodigiProducer; - // std::string zsdigiProducer; std::string clusterProducer; }; } // namespace cms diff --git a/EventFilter/SiStripChannelChargeFilter/interface/TECClusterFilter.h b/EventFilter/SiStripChannelChargeFilter/interface/TECClusterFilter.h index 15875e8bc8a00..8bcba609f2901 100644 --- a/EventFilter/SiStripChannelChargeFilter/interface/TECClusterFilter.h +++ b/EventFilter/SiStripChannelChargeFilter/interface/TECClusterFilter.h @@ -9,7 +9,7 @@ // // Original Author: sfricke -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -17,10 +17,10 @@ #include "DataFormats/DetId/interface/DetId.h" namespace cms { - class TECClusterFilter : public edm::EDFilter { + class TECClusterFilter : public edm::stream::EDFilter<> { public: TECClusterFilter(const edm::ParameterSet& ps); - ~TECClusterFilter() override {} + ~TECClusterFilter() override = default; bool filter(edm::Event& e, edm::EventSetup const& c) override; private: diff --git a/EventFilter/SiStripChannelChargeFilter/interface/TrackMTCCFilter.h b/EventFilter/SiStripChannelChargeFilter/interface/TrackMTCCFilter.h index 127436b630a51..3b0da079f08be 100644 --- a/EventFilter/SiStripChannelChargeFilter/interface/TrackMTCCFilter.h +++ b/EventFilter/SiStripChannelChargeFilter/interface/TrackMTCCFilter.h @@ -9,13 +9,13 @@ // // Original Author: dkcira -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" namespace cms { - class TrackMTCCFilter : public edm::EDFilter { + class TrackMTCCFilter : public edm::stream::EDFilter<> { public: TrackMTCCFilter(const edm::ParameterSet& ps); ~TrackMTCCFilter() override {} From 6a5c40bbb12c4411a3f42cb5461bcc192046326c Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 21 Apr 2022 16:22:08 +0200 Subject: [PATCH 28/57] get rid of deprection warnings in EventFilter/SiStripRawToDigi --- .../test/plugins/SiStripClusterValidator.cc | 48 +++++++- .../test/plugins/SiStripClusterValidator.h | 41 ------- .../test/plugins/SiStripDigiAnalyzer.cc | 112 ++++++++++++++++-- .../test/plugins/SiStripDigiAnalyzer.h | 92 -------------- .../test/plugins/SiStripDigiValidator.cc | 61 +++++++++- .../test/plugins/SiStripDigiValidator.h | 55 --------- .../test/plugins/SiStripFEDRawDataAnalyzer.cc | 48 +++++++- .../test/plugins/SiStripFEDRawDataAnalyzer.h | 37 ------ .../test/plugins/SiStripModuleTimer.cc | 35 +++++- .../test/plugins/SiStripModuleTimer.h | 27 ----- .../plugins/SiStripTrivialClusterSource.cc | 65 +++++++++- .../plugins/SiStripTrivialClusterSource.h | 60 ---------- .../test/plugins/SiStripTrivialDigiSource.cc | 53 +++++++-- .../test/plugins/SiStripTrivialDigiSource.h | 32 ----- .../SiStripRawToDigi/test/plugins/module.cc | 23 ---- 15 files changed, 378 insertions(+), 411 deletions(-) delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h delete mode 100644 EventFilter/SiStripRawToDigi/test/plugins/module.cc diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc index 7fde5101e85da..0ead12781d1cb 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc @@ -1,6 +1,42 @@ -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" +// system includes +#include + +// user includes +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +class SiStripClusterValidator : public edm::one::EDAnalyzer<> { +public: + SiStripClusterValidator(const edm::ParameterSet& config); + ~SiStripClusterValidator() override = default; + virtual void endJob(); + virtual void analyze(const edm::Event& event, const edm::EventSetup& setup); + void validate(const edm::DetSetVector&, const edm::DetSetVector&); + void validate(const edmNew::DetSetVector&, const edmNew::DetSetVector&); + +private: + inline const std::string& header() { return header_; } + + /// Input collections + const edm::InputTag collection1Tag_; + const edm::InputTag collection2Tag_; + const bool dsvnew_; + /// used to remember if there have been errors for message in endJob + bool errors_; + + std::string header_; +}; + +std::ostream& operator<<(std::ostream&, const edmNew::DetSetVector&); +std::ostream& operator<<(std::ostream&, const edm::DetSetVector&); SiStripClusterValidator::SiStripClusterValidator(const edm::ParameterSet& conf) : collection1Tag_(conf.getUntrackedParameter("Collection1")), @@ -27,10 +63,6 @@ SiStripClusterValidator::SiStripClusterValidator(const edm::ParameterSet& conf) } } -SiStripClusterValidator::~SiStripClusterValidator() {} - -void SiStripClusterValidator::beginJob() {} - void SiStripClusterValidator::endJob() { std::stringstream ss; ss << "[SiStripClusterValidator::" << __func__ << "]" << std::endl << header(); @@ -218,3 +250,7 @@ std::ostream& operator<<(std::ostream& ss, const edm::DetSetVector - -class SiStripClusterValidator : public edm::EDAnalyzer { -public: - SiStripClusterValidator(const edm::ParameterSet& config); - ~SiStripClusterValidator(); - virtual void beginJob(); - virtual void endJob(); - virtual void analyze(const edm::Event& event, const edm::EventSetup& setup); - void validate(const edm::DetSetVector&, const edm::DetSetVector&); - void validate(const edmNew::DetSetVector&, const edmNew::DetSetVector&); - -private: - inline const std::string& header() { return header_; } - - /// Input collections - edm::InputTag collection1Tag_; - edm::InputTag collection2Tag_; - bool dsvnew_; - /// used to remember if there have been errors for message in endJob - bool errors_; - - std::string header_; -}; - -std::ostream& operator<<(std::ostream&, const edmNew::DetSetVector&); -std::ostream& operator<<(std::ostream&, const edm::DetSetVector&); - -#endif /// RecoLocalTracker_SiStripClusterizer_SiStripClusterValidator_H diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.cc index f75f22dd5aa3d..5dbca003803ce 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.cc @@ -1,18 +1,105 @@ -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" +// system includes +#include +#include +#include +#include +#include + +// user includes +#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" +#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" #include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/Handle.h" #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h" +#include "DataFormats/SiStripCommon/interface/SiStripFedKey.h" #include "DataFormats/SiStripDigi/interface/SiStripDigi.h" #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h" -#include -#include +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +/** + @class SiStripDigiAnalyzer + @brief Simple class that analyzes Digis produced by RawToDigi unpacker +*/ + +class SiStripTrivialDigiAnalysis { +public: + /** Default constructor. */ + SiStripTrivialDigiAnalysis() + : events_(0), feds_(0), channels_(0), strips_(0), digis_(0), size_(1024), pos_(size_ + 1, 0), adc_(size_ + 1, 0) {} + + /** Pipes collected statistics to stringstream. */ + void print(std::stringstream&); + + // setters + inline void pos(const uint16_t& pos); + inline void adc(const uint16_t& adc); + + // getters + inline const std::vector& pos(); + inline const std::vector& adc(); + +public: + uint32_t events_; + uint32_t feds_; + uint32_t channels_; + uint32_t strips_; + uint32_t digis_; + + const uint16_t size_; + +private: + std::vector pos_; + std::vector adc_; +}; + +class SiStripDigiAnalyzer : public edm::one::EDAnalyzer<> { +public: + SiStripDigiAnalyzer(const edm::ParameterSet&); + ~SiStripDigiAnalyzer(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + void endJob(); + +private: + const edm::ESGetToken esTokenCabling_; + std::string inputModuleLabel_; + + SiStripTrivialDigiAnalysis anal_; + SiStripTrivialDigiAnalysis vr_p; + SiStripTrivialDigiAnalysis pr_p; + SiStripTrivialDigiAnalysis sm_p; + SiStripTrivialDigiAnalysis zs_p; + SiStripTrivialDigiAnalysis vr_r; + SiStripTrivialDigiAnalysis pr_r; + SiStripTrivialDigiAnalysis sm_r; + SiStripTrivialDigiAnalysis zs_r; +}; + +void SiStripTrivialDigiAnalysis::pos(const uint16_t& pos) { + if (pos < size_) { + pos_[pos]++; + } else { + pos_[size_]++; + } +} + +void SiStripTrivialDigiAnalysis::adc(const uint16_t& adc) { + if (adc < size_) { + adc_[adc]++; + } else { + adc_[size_]++; + } +} + +const std::vector& SiStripTrivialDigiAnalysis::pos() { return pos_; } +const std::vector& SiStripTrivialDigiAnalysis::adc() { return adc_; } using namespace std; @@ -207,7 +294,10 @@ void SiStripDigiAnalyzer::analyze(const edm::Event& event, const edm::EventSetup } } } - } // channel loop } // fed loop } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SiStripDigiAnalyzer); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.h b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.h deleted file mode 100644 index 008ee2fe6aea5..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef EventFilter_SiStripRawToDigi_test_AnalyzeSiStripDigis_H -#define EventFilter_SiStripRawToDigi_test_AnalyzeSiStripDigis_H - -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" -#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" -#include -#include -#include -#include - -/** - @class SiStripDigiAnalyzer - @brief Simple class that analyzes Digis produced by RawToDigi unpacker -*/ - -class SiStripTrivialDigiAnalysis { -public: - /** Default constructor. */ - SiStripTrivialDigiAnalysis() - : events_(0), feds_(0), channels_(0), strips_(0), digis_(0), size_(1024), pos_(size_ + 1, 0), adc_(size_ + 1, 0) {} - - /** Pipes collected statistics to stringstream. */ - void print(std::stringstream&); - - // setters - inline void pos(const uint16_t& pos); - inline void adc(const uint16_t& adc); - - // getters - inline const std::vector& pos(); - inline const std::vector& adc(); - -public: - uint32_t events_; - uint32_t feds_; - uint32_t channels_; - uint32_t strips_; - uint32_t digis_; - - const uint16_t size_; - -private: - std::vector pos_; - std::vector adc_; -}; - -class SiStripDigiAnalyzer : public edm::one::EDAnalyzer<> { -public: - SiStripDigiAnalyzer(const edm::ParameterSet&); - ~SiStripDigiAnalyzer(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob(); - -private: - const edm::ESGetToken esTokenCabling_; - std::string inputModuleLabel_; - - SiStripTrivialDigiAnalysis anal_; - SiStripTrivialDigiAnalysis vr_p; - SiStripTrivialDigiAnalysis pr_p; - SiStripTrivialDigiAnalysis sm_p; - SiStripTrivialDigiAnalysis zs_p; - SiStripTrivialDigiAnalysis vr_r; - SiStripTrivialDigiAnalysis pr_r; - SiStripTrivialDigiAnalysis sm_r; - SiStripTrivialDigiAnalysis zs_r; -}; - -void SiStripTrivialDigiAnalysis::pos(const uint16_t& pos) { - if (pos < size_) { - pos_[pos]++; - } else { - pos_[size_]++; - } -} - -void SiStripTrivialDigiAnalysis::adc(const uint16_t& adc) { - if (adc < size_) { - adc_[adc]++; - } else { - adc_[size_]++; - } -} - -const std::vector& SiStripTrivialDigiAnalysis::pos() { return pos_; } - -const std::vector& SiStripTrivialDigiAnalysis::adc() { return adc_; } - -#endif // EventFilter_SiStripRawToDigi_test_SiStripDigiAnalyzer_H diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc index 074d8c05cb479..7f6f470fa979e 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc @@ -1,6 +1,57 @@ -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h" +// system includes +#include + +// user includes +#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" +#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" +#include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" +#include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +/** + @file EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h + @class SiStripDigiValidator + + @brief Compares two digi collections. Reports an error if the collection + sizes do not match or the first collection conatins any digi which + does not have an identical matching digi in the other collection. + This guarentees that the collections are identical. +*/ + +class SiStripDigiValidator : public edm::EDAnalyzer { +public: + SiStripDigiValidator(const edm::ParameterSet& config); + ~SiStripDigiValidator() override = default; + + virtual void endJob(); + virtual void analyze(const edm::Event& event, const edm::EventSetup& setup); + + void validate(const edm::DetSetVector&, const edm::DetSetVector&); + void validate(const edm::DetSetVector&, const edm::DetSetVector&); + void validate(const edm::DetSetVector&, const edm::DetSetVector&); + void validate(const edm::DetSetVector&, const edm::DetSetVector&); + +private: + inline const std::string& header() { return header_; } + + //Input collections + const edm::InputTag tag1_; + const edm::InputTag tag2_; + const bool raw1_; + const bool raw2_; + //used to remember if there have been errors for message in endJob + bool errors_; + + std::string header_; +}; SiStripDigiValidator::SiStripDigiValidator(const edm::ParameterSet& conf) : tag1_(conf.getUntrackedParameter("TagCollection1")), @@ -24,10 +75,6 @@ SiStripDigiValidator::SiStripDigiValidator(const edm::ParameterSet& conf) mayConsume >(tag2_); } -SiStripDigiValidator::~SiStripDigiValidator() {} - -void SiStripDigiValidator::beginJob() {} - void SiStripDigiValidator::endJob() { std::stringstream ss; ss << "[SiStripDigiValidator::" << __func__ << "]" << std::endl << header(); @@ -222,3 +269,7 @@ void SiStripDigiValidator::validate(const edm::DetSetVector& col } } } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SiStripDigiValidator); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h deleted file mode 100644 index 5c567e6d75d1a..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef EventFilter_SiStripRawToDigi_SiStripDigiValidator_H -#define EventFilter_SiStripRawToDigi_SiStripDigiValidator_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" -#include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h" -#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" -#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" -#include - -/** - @file EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h - @class SiStripDigiValidator - - @brief Compares two digi collections. Reports an error if the collection - sizes do not match or the first collection conatins any digi which - does not have an identical matching digi in the other collection. - This guarentees that the collections are identical. -*/ - -class SiStripDigiValidator : public edm::EDAnalyzer { -public: - SiStripDigiValidator(const edm::ParameterSet& config); - ~SiStripDigiValidator(); - - virtual void beginJob(); - virtual void endJob(); - virtual void analyze(const edm::Event& event, const edm::EventSetup& setup); - - void validate(const edm::DetSetVector&, const edm::DetSetVector&); - void validate(const edm::DetSetVector&, const edm::DetSetVector&); - void validate(const edm::DetSetVector&, const edm::DetSetVector&); - void validate(const edm::DetSetVector&, const edm::DetSetVector&); - -private: - inline const std::string& header() { return header_; } - - //Input collections - edm::InputTag tag1_; - edm::InputTag tag2_; - bool raw1_; - bool raw2_; - //used to remember if there have been errors for message in endJob - bool errors_; - - std::string header_; -}; - -#endif // EventFilter_SiStripRawToDigi_SiStripDigiValidator_H diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.cc index ab781ac0e4a51..e4883c0c56526 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.cc @@ -1,14 +1,48 @@ +// system includes +#include +#include +#include +#include +#include + +// user includes +#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" +#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDTrailer.h" #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.h" #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/ESHandle.h" -#include -#include -#include +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +/** + @class SiStripFEDRawDataAnalyzer + @brief Analyzes contents of FEDRawData collection +*/ + +class SiStripFEDRawDataAnalyzer : public edm::one::EDAnalyzer<> { +public: + typedef std::pair Fed; + typedef std::vector Feds; + typedef std::vector Channels; + typedef std::map ChannelsMap; + + SiStripFEDRawDataAnalyzer(const edm::ParameterSet&); + ~SiStripFEDRawDataAnalyzer(); + + void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + void endJob(); + +private: + const edm::ESGetToken esTokenCabling_; + edm::InputTag label_; +}; using namespace sistrip; using namespace std; @@ -321,3 +355,7 @@ void SiStripFEDRawDataAnalyzer::analyze(const edm::Event& event, const edm::Even LogTrace(mlRawToDigi_) << ss.str(); } } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SiStripFEDRawDataAnalyzer); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.h b/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.h deleted file mode 100644 index 5db35c868b8ef..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef EventFilter_SiStripRawToDigi_SiStripFEDRawDataAnalyzer_H -#define EventFilter_SiStripRawToDigi_SiStripFEDRawDataAnalyzer_H - -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" -#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" -#include -#include - -/** - @class SiStripFEDRawDataAnalyzer - @brief Analyzes contents of FEDRawData collection -*/ - -class SiStripFEDRawDataAnalyzer : public edm::one::EDAnalyzer<> { -public: - typedef std::pair Fed; - typedef std::vector Feds; - typedef std::vector Channels; - typedef std::map ChannelsMap; - - SiStripFEDRawDataAnalyzer(const edm::ParameterSet&); - ~SiStripFEDRawDataAnalyzer(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob(); - -private: - const edm::ESGetToken esTokenCabling_; - edm::InputTag label_; -}; - -#endif // EventFilter_SiStripRawToDigi_SiStripFEDRawDataAnalyzer_H diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.cc index ca376959a2c88..a7c9ae5db9cf5 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.cc @@ -1,13 +1,34 @@ -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.h" +// user includes #include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +//#include "DQM/HLTEvF/interface/PathTimerService.h" + +// ROOT includes +#include "TFile.h" +#include "TTree.h" + +class SiStripModuleTimer : public edm::EDAnalyzer { +public: + SiStripModuleTimer(const edm::ParameterSet&); + ~SiStripModuleTimer(); + + void analyze(const edm::Event&, const edm::EventSetup&); + void endJob(); + +private: + std::vector moduleLabels_; + std::vector times_; + TFile* file_; + TTree* tree_; +}; using namespace std; using namespace edm; SiStripModuleTimer::SiStripModuleTimer(const ParameterSet& pset) - : - - moduleLabels_(pset.getUntrackedParameter >("ModuleLabels")), + : moduleLabels_(pset.getUntrackedParameter >("ModuleLabels")), times_(moduleLabels_.size()), file_(0), tree_(0) { @@ -26,8 +47,6 @@ SiStripModuleTimer::~SiStripModuleTimer() { file_->Close(); } -void SiStripModuleTimer::beginJob() {} - void SiStripModuleTimer::endJob() { file_->cd(); tree_->Write(); @@ -44,3 +63,7 @@ void SiStripModuleTimer::analyze(const Event& iEvent, const EventSetup& iSetup) //} tree_->Fill(); } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SiStripModuleTimer); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.h b/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.h deleted file mode 100644 index aca99a03dcf03..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef EventFilter_SiStripRawToDigi_SiStripModuleTimer_H -#define EventFilter_SiStripRawToDigi_SiStripModuleTimer_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -//#include "DQM/HLTEvF/interface/PathTimerService.h" -#include "TFile.h" -#include "TTree.h" - -class SiStripModuleTimer : public edm::EDAnalyzer { -public: - SiStripModuleTimer(const edm::ParameterSet&); - ~SiStripModuleTimer(); - - void beginJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - void endJob(); - -private: - std::vector moduleLabels_; - std::vector times_; - TFile* file_; - TTree* tree_; -}; - -#endif diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.cc index 1c023a977a5b5..56f1eeac78e12 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.cc @@ -1,4 +1,63 @@ -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h" +// system includes +#include + +// user includes +#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" +#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +// ROOT includes +#include "TRandom.h" + +/** + @file EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.cc + @class SiStripTrivialClusterSource + @brief Creates a DetSetVector of SiStripDigis created using random + number generators and attaches the collection to the Event. Allows + to test the final DigiToRaw and RawToDigi/RawToCluster converters. + */ + +class SiStripTrivialClusterSource : public edm::stream::EDProducer<> { +public: + SiStripTrivialClusterSource(const edm::ParameterSet&); + ~SiStripTrivialClusterSource() override; + + void beginRun(const edm::Run&, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; + +private: + /** Check for space in module */ + bool available(const edm::DetSet&, const uint16_t, const uint32_t); + + /** Add cluster to module */ + void addcluster(edm::DetSet&, const uint16_t, const uint16_t); + + /** token */ + const edm::ESGetToken esTokenCabling_; + + /** Configurables */ + double minocc_; + double maxocc_; + double mincluster_; + double maxcluster_; + uint16_t separation_; + + /** Setup */ + edm::ESHandle cabling_; + std::vector detids_; + uint32_t nstrips_; + + /** Random */ + TRandom random_; +}; SiStripTrivialClusterSource::SiStripTrivialClusterSource(const edm::ParameterSet& pset) : esTokenCabling_(esConsumes()), @@ -82,3 +141,7 @@ void SiStripTrivialClusterSource::addcluster(edm::DetSet& detset, detset.data.push_back(SiStripDigi(firststrip + istrip, 0xFF)); } } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SiStripTrivialClusterSource); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h b/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h deleted file mode 100644 index 3e16ad6c6f894..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef EventFilter_SiStripRawToDigi_SiStripTrivialClusterSource_H -#define EventFilter_SiStripRawToDigi_SiStripTrivialClusterSource_H - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Run.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" -#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" -#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" -#include "TRandom.h" -#include - -/** - @file EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h - @class SiStripTrivialClusterSource - @brief Creates a DetSetVector of SiStripDigis created using random - number generators and attaches the collection to the Event. Allows - to test the final DigiToRaw and RawToDigi/RawToCluster converters. - */ - -class SiStripTrivialClusterSource : public edm::stream::EDProducer<> { -public: - SiStripTrivialClusterSource(const edm::ParameterSet&); - ~SiStripTrivialClusterSource() override; - - void beginRun(const edm::Run&, const edm::EventSetup&) override; - void produce(edm::Event&, const edm::EventSetup&) override; - -private: - /** Check for space in module */ - bool available(const edm::DetSet&, const uint16_t, const uint32_t); - - /** Add cluster to module */ - void addcluster(edm::DetSet&, const uint16_t, const uint16_t); - - /** token */ - const edm::ESGetToken esTokenCabling_; - - /** Configurables */ - double minocc_; - double maxocc_; - double mincluster_; - double maxcluster_; - uint16_t separation_; - - /** Setup */ - edm::ESHandle cabling_; - std::vector detids_; - uint32_t nstrips_; - - /** Random */ - TRandom random_; -}; - -#endif // EventFilter_SiStripRawToDigi_SiStripTrivialClusterSource_H diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.cc index 3c1ca9acf8d6d..1c1804af89ae8 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.cc @@ -1,4 +1,17 @@ -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h" +// system includes +#include +#include +#include +#include +#include +#include +#include + +// user includes +#include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Random/RandGauss.h" +#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" +#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" #include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" #include "DataFormats/SiStripDigi/interface/SiStripDigi.h" @@ -6,17 +19,33 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "CLHEP/Random/RandGauss.h" -#include "CLHEP/Random/RandFlat.h" -#include -#include -#include -#include -#include -#include -#include + +/** + @file EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h + @class SiStripTrivialDigiSource + + @brief Creates a DetSetVector of SiStripDigis created using random + number generators and attaches the collection to the Event. Allows + to test the final DigiToRaw and RawToDigi converters. +*/ +class SiStripTrivialDigiSource : public edm::global::EDProducer<> { +public: + SiStripTrivialDigiSource(const edm::ParameterSet&); + ~SiStripTrivialDigiSource(); + + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + +private: + const edm::ESGetToken esTokenCabling_; + const float meanOcc_; + const float rmsOcc_; + const int ped_; + const bool raw_; + const bool useFedKey_; +}; // ----------------------------------------------------------------------------- // @@ -174,3 +203,7 @@ void SiStripTrivialDigiSource::produce(edm::StreamID, edm::Event& event, const e LogTrace("TrivialDigiSource") << ss.str(); } } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SiStripTrivialDigiSource); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h b/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h deleted file mode 100644 index 2474dd30300ec..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef EventFilter_SiStripRawToDigi_SiStripTrivialDigiSource_H -#define EventFilter_SiStripRawToDigi_SiStripTrivialDigiSource_H - -#include "FWCore/Framework/interface/global/EDProducer.h" -#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" -#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" - -/** - @file EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h - @class SiStripTrivialDigiSource - - @brief Creates a DetSetVector of SiStripDigis created using random - number generators and attaches the collection to the Event. Allows - to test the final DigiToRaw and RawToDigi converters. -*/ -class SiStripTrivialDigiSource : public edm::global::EDProducer<> { -public: - SiStripTrivialDigiSource(const edm::ParameterSet&); - ~SiStripTrivialDigiSource(); - - virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; - -private: - const edm::ESGetToken esTokenCabling_; - const float meanOcc_; - const float rmsOcc_; - const int ped_; - const bool raw_; - const bool useFedKey_; -}; - -#endif // EventFilter_SiStripRawToDigi_SiStripTrivialDigiSource_H diff --git a/EventFilter/SiStripRawToDigi/test/plugins/module.cc b/EventFilter/SiStripRawToDigi/test/plugins/module.cc deleted file mode 100644 index a1cf2ac0d3d7b..0000000000000 --- a/EventFilter/SiStripRawToDigi/test/plugins/module.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include "FWCore/PluginManager/interface/ModuleDef.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripFEDRawDataAnalyzer.h" -DEFINE_FWK_MODULE(SiStripFEDRawDataAnalyzer); - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiAnalyzer.h" -DEFINE_FWK_MODULE(SiStripDigiAnalyzer); - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialClusterSource.h" -DEFINE_FWK_MODULE(SiStripTrivialClusterSource); - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripTrivialDigiSource.h" -DEFINE_FWK_MODULE(SiStripTrivialDigiSource); - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.h" -DEFINE_FWK_MODULE(SiStripDigiValidator); - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.h" -DEFINE_FWK_MODULE(SiStripClusterValidator); - -#include "EventFilter/SiStripRawToDigi/test/plugins/SiStripModuleTimer.h" -DEFINE_FWK_MODULE(SiStripModuleTimer); From caebbae54b6e129e74a87f206972f2664cfd855c Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 22 Apr 2022 10:51:38 +0200 Subject: [PATCH 29/57] get rid of residual deprecation warnings in RecoLocalTracker/SiStripRecHitConverter and RecoTracker/TkMSParametrization --- .../test/ClusterFilter.cc | 47 ++++++++----- .../test/ClusterFilter.h | 24 ------- .../SiStripRecHitConverter/test/ReadRecHit.cc | 66 ++++++++++++------- .../SiStripRecHitConverter/test/ReadRecHit.h | 37 ----------- .../TkMSParametrization/test/TestMS.cc | 22 ++++--- 5 files changed, 85 insertions(+), 111 deletions(-) delete mode 100644 RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.h delete mode 100644 RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.h diff --git a/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc b/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc index f8ce3366c4202..59236b468d3c8 100644 --- a/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc +++ b/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc @@ -1,30 +1,41 @@ -#include "RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.h" +// system include #include -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" + +// user includes #include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +namespace edm { + class ParameterSet; +} + +class ClusterFilter : public edm::stream::EDFilter<> { +public: + ClusterFilter(const edm::ParameterSet&); + ~ClusterFilter() override = default; + +private: + bool filter(edm::Event&, edm::EventSetup const&); + const int nMax_; + const edm::EDGetTokenT> clustersToken_; +}; + using namespace std; using namespace edm; -ClusterFilter::ClusterFilter(const ParameterSet& pset) : nMax_(pset.getParameter("maxClusters")), conf_(pset) {} - -ClusterFilter::~ClusterFilter() {} +ClusterFilter::ClusterFilter(const ParameterSet& pset) + : nMax_(pset.getParameter("maxClusters")), + clustersToken_(consumes>(pset.getParameter("ClusterProducer"))) {} bool ClusterFilter::filter(Event& e, EventSetup const& es) { - std::string clusterProducer = conf_.getParameter("ClusterProducer"); - edm::Handle > clusters; - e.getByLabel(clusterProducer, clusters); - // int size=clusters.product()->size(); + const edm::DetSetVector& clusters = e.get(clustersToken_); int size = 0; - for (edm::DetSetVector::const_iterator DSViter = clusters.product()->begin(); - DSViter != clusters.product()->end(); - ++DSViter) { - size += DSViter->data.size(); + for (const auto& DSViter : clusters) { + size += DSViter.data.size(); } - - if (size > nMax_) - return 0; - else - return 1; + return (size < nMax_); } diff --git a/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.h b/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.h deleted file mode 100644 index a0e9384986345..0000000000000 --- a/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef TkSeedGenerator_ClusterFilter_h -#define TkSeedGenerator_ClusterFilter_h - -#include "FWCore/Framework/interface/EDFilter.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -namespace edm { - class ParameterSet; -} - -class ClusterFilter : public edm::EDFilter { -public: - ClusterFilter(const edm::ParameterSet&); - ~ClusterFilter(); - -private: - bool filter(edm::Event&, edm::EventSetup const&); - const int nMax_; - const edm::ParameterSet conf_; - // int n_; - // const bool verbose_; -}; - -#endif diff --git a/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc b/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc index e2660e1bcb82e..295a9ec58066e 100644 --- a/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc +++ b/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc @@ -1,41 +1,63 @@ -// File: ReadRecHit.cc -// Description: see ReadRecHit.h -// Author: C.Genta -// -//-------------------------------------------- +/** \class ReadRecHit + * + * ReadRecHit is a analyzer which reads rechits + * + * \author C. Genta + * + */ + +// system includes #include #include #include -#include "RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.h" - -#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" +// user includes +#include "DataFormats/Common/interface/Handle.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" - -#include "FWCore/Framework/interface/ESHandle.h" +#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHitAlgorithm.h" + namespace cms { + class ReadRecHit : public edm::one::EDAnalyzer<> { + public: + explicit ReadRecHit(const edm::ParameterSet& conf); + virtual ~ReadRecHit() override = default; - ReadRecHit::ReadRecHit(edm::ParameterSet const& conf) : readRecHitAlgorithm_(conf), conf_(conf) { - // produces(); - } + virtual void analyze(const edm::Event& e, const edm::EventSetup& c); + + private: + ReadRecHitAlgorithm readRecHitAlgorithm_; + const std::string recHitProducer_; + const edm::EDGetTokenT matchedRecHitToken_; + const edm::EDGetTokenT rphiToken_; + const edm::EDGetTokenT stereoToken_; + }; +} // namespace cms + +namespace cms { - // Virtual destructor needed. - ReadRecHit::~ReadRecHit() {} + ReadRecHit::ReadRecHit(edm::ParameterSet const& conf) + : readRecHitAlgorithm_(conf), + recHitProducer_(conf.getParameter("RecHitProducer")), + matchedRecHitToken_( + consumes(edm::InputTag{recHitProducer_, "matchedRecHit"})), + rphiToken_(consumes(edm::InputTag{recHitProducer_, "rphiRecHit"})), + stereoToken_(consumes(edm::InputTag{recHitProducer_, "stereoRecHit"})) {} // Functions that gets called by framework every event void ReadRecHit::analyze(const edm::Event& e, const edm::EventSetup& es) { using namespace edm; - std::string rechitProducer = conf_.getParameter("RecHitProducer"); // Step A: Get Inputs - edm::Handle rechitsmatched; - edm::Handle rechitsrphi; - edm::Handle rechitsstereo; - e.getByLabel(rechitProducer, "matchedRecHit", rechitsmatched); - e.getByLabel(rechitProducer, "rphiRecHit", rechitsrphi); - e.getByLabel(rechitProducer, "stereoRecHit", rechitsstereo); + edm::Handle rechitsmatched = e.getHandle(matchedRecHitToken_); + edm::Handle rechitsrphi = e.getHandle(rphiToken_); + edm::Handle rechitsstereo = e.getHandle(stereoToken_); edm::LogInfo("ReadRecHit") << "Matched hits:"; readRecHitAlgorithm_.run(rechitsmatched.product()); diff --git a/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.h b/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.h deleted file mode 100644 index 18083f70b3103..0000000000000 --- a/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef ReadRecHit_h -#define ReadRecHit_h - -/** \class ReadRecHit - * - * ReadRecHit is a analyzer which reads rechits - * - * \author C. Genta - * - * - ************************************************************/ - -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/EventSetup.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHitAlgorithm.h" - -namespace cms { - class ReadRecHit : public edm::EDAnalyzer { - public: - explicit ReadRecHit(const edm::ParameterSet& conf); - - virtual ~ReadRecHit(); - - virtual void analyze(const edm::Event& e, const edm::EventSetup& c); - - private: - ReadRecHitAlgorithm readRecHitAlgorithm_; - edm::ParameterSet conf_; - }; -} // namespace cms - -#endif diff --git a/RecoTracker/TkMSParametrization/test/TestMS.cc b/RecoTracker/TkMSParametrization/test/TestMS.cc index d001a5759d719..990df14f56cd7 100644 --- a/RecoTracker/TkMSParametrization/test/TestMS.cc +++ b/RecoTracker/TkMSParametrization/test/TestMS.cc @@ -1,6 +1,10 @@ +// system includes +#include + +// user includes #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "DataFormats/Common/interface/Handle.h" @@ -8,10 +12,8 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" - #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisation.h" #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" - #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h" #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h" #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" @@ -20,28 +22,28 @@ #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" -using namespace GeomDetEnumerators; - -#include - -using namespace std; -using namespace edm; +// ROOT includes #include "TFile.h" #include "TH1D.h" #include "TProfile.h" +using namespace GeomDetEnumerators; +using namespace std; +using namespace edm; + template T sqr(T t) { return t * t; } -class TestMS : public edm::EDAnalyzer { +class TestMS : public edm::one::EDAnalyzer { public: explicit TestMS(const edm::ParameterSet& conf); ~TestMS(); virtual void beginRun(edm::Run const& run, const edm::EventSetup& es) override; virtual void analyze(const edm::Event& ev, const edm::EventSetup& es) override; + virtual void endRun(edm::Run const& run, const edm::EventSetup& es){}; private: edm::ESGetToken trackerToken_; From 4d1eb85cd174a8fec462964a77a845a935c54b82 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 20 Apr 2022 22:20:29 +0200 Subject: [PATCH 30/57] protect fetching of input histograms in SiPixelPhase1TrackComparisonHarvester and run it only if the gpuValidationPixel modifier is active --- .../SiPixelPhase1TrackComparisonHarvester.cc | 13 ++++++++++--- .../SiPixelPhase1HeterogenousDQMHarvesting_cff.py | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc index 75f27654c11c9..7e8b773360f7d 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1TrackComparisonHarvester.cc @@ -26,8 +26,15 @@ SiPixelPhase1TrackComparisonHarvester::SiPixelPhase1TrackComparisonHarvester(con void SiPixelPhase1TrackComparisonHarvester::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) { MonitorElement* hpt_eta_tkAllCPU = igetter.get(topFolder_ + "/ptetatrkAllCPU"); MonitorElement* hpt_eta_tkAllCPUmatched = igetter.get(topFolder_ + "/ptetatrkAllCPUmatched"); - MonitorElement* hphi_z_tkAllCPU_ = igetter.get(topFolder_ + "/phiztrkAllCPU"); - MonitorElement* hphi_z_tkAllCPUmatched_ = igetter.get(topFolder_ + "/phiztrkAllCPUmatched"); + MonitorElement* hphi_z_tkAllCPU = igetter.get(topFolder_ + "/phiztrkAllCPU"); + MonitorElement* hphi_z_tkAllCPUmatched = igetter.get(topFolder_ + "/phiztrkAllCPUmatched"); + + if (hpt_eta_tkAllCPU == nullptr or hpt_eta_tkAllCPUmatched == nullptr or hphi_z_tkAllCPU == nullptr or + hphi_z_tkAllCPUmatched == nullptr) { + edm::LogError("SiPixelPhase1TrackComparisonHarvester") + << "MEs needed for this module are not found in the input file. Skipping."; + return; + } ibooker.cd(); ibooker.setCurrentFolder(topFolder_); @@ -37,7 +44,7 @@ void SiPixelPhase1TrackComparisonHarvester::dqmEndJob(DQMStore::IBooker& ibooker "matchingeff_phi_z", "Efficiency of track matching; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); hpt_eta_matchRatio->divide(hpt_eta_tkAllCPUmatched, hpt_eta_tkAllCPU, 1., 1., "B"); - hphi_z_matchRatio->divide(hphi_z_tkAllCPUmatched_, hphi_z_tkAllCPU_, 1., 1., "B"); + hphi_z_matchRatio->divide(hphi_z_tkAllCPUmatched, hphi_z_tkAllCPU, 1., 1., "B"); } #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" diff --git a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py index e5bd597650ead..a68508f296be1 100644 --- a/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py +++ b/DQM/SiPixelPhase1Heterogeneous/python/SiPixelPhase1HeterogenousDQMHarvesting_cff.py @@ -1,4 +1,11 @@ import FWCore.ParameterSet.Config as cms +siPixelPhase1HeterogenousDQMHarvesting = cms.Sequence() # empty sequence if not both CPU and GPU recos are run + from DQM.SiPixelPhase1Heterogeneous.siPixelPhase1TrackComparisonHarvester_cfi import * +siPixelPhase1HeterogenousDQMComparisonHarvesting = cms.Sequence(siPixelPhase1TrackComparisonHarvester) + +# add the harvester in case of the validation modifier is active +from Configuration.ProcessModifiers.gpuValidationPixel_cff import gpuValidationPixel +gpuValidationPixel.toReplaceWith(siPixelPhase1HeterogenousDQMHarvesting,siPixelPhase1HeterogenousDQMComparisonHarvesting) + -siPixelPhase1HeterogenousDQMHarvesting = cms.Sequence(siPixelPhase1TrackComparisonHarvester) From b52348d3f6ed40968459953a29cf6767a2e88c7b Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 22 Apr 2022 14:50:18 +0200 Subject: [PATCH 31/57] follow-up to code review --- .../python/upgradeWorkflowComponents.py | 6 ++++-- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 8 ++++---- .../plugins/SiPixelPhase1CompareVertexSoA.cc | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index eab4848eeb862..6abfec3e0c876 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -930,7 +930,8 @@ def setup_(self, step, stepName, stepDict, k, properties): '--procModifiers': 'pixelNtupletFit,gpuValidation' }, harvest = { - '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM+@ecalOnlyValidation+@ecal+@hcalOnlyValidation+@hcalOnly+@hcal2Only' + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM+@ecalOnlyValidation+@ecal+@hcalOnlyValidation+@hcalOnly+@hcal2Only', + '--procModifiers': 'gpuValidation' }, suffix = 'Patatrack_AllGPU_Validation', offset = 0.583, @@ -996,7 +997,8 @@ def setup_(self, step, stepName, stepDict, k, properties): '--procModifiers': 'pixelNtupletFit,gpuValidation' }, harvest = { - '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM+@ecalOnlyValidation+@ecal+@hcalOnlyValidation+@hcalOnly+@hcal2Only' + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM+@ecalOnlyValidation+@ecal+@hcalOnlyValidation+@hcalOnly+@hcal2Only', + '--procModifiers': 'gpuValidation' }, suffix = 'Patatrack_AllTripletsGPU_Validation', offset = 0.587, diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index dc10f9d31f1e0..8bf8bb5c668ca 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -251,9 +251,9 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, htip_ = iBook.book2D("tip", "Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5); //1D difference plots hptdiffMatched_ = iBook.book1D("ptdiffmatched", " p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 60, -30., 30.); - hetadiffMatched_ = iBook.book1D("etadiffmatched", " #eta diff between matched tracks; #Delta #eta", 300, -3., 3); - hphidiffMatched_ = iBook.book1D("phidiffmatched", " #phi diff between matched tracks; #Delta #phi", 300, -M_PI, M_PI); - hzdiffMatched_ = iBook.book1D("zdiffmatched", " z diff between matched tracks; #Delta z [cm]", 60, -30, 30.); + hetadiffMatched_ = iBook.book1D("etadiffmatched", " #eta diff between matched tracks; #Delta #eta", 160, -0.04 ,0.04); + hphidiffMatched_ = iBook.book1D("phidiffmatched", " #phi diff between matched tracks; #Delta #phi", 160, -0.04 ,0.04); + hzdiffMatched_ = iBook.book1D("zdiffmatched", " z diff between matched tracks; #Delta z [cm]", 300, -1.5, 1.5); //2D plots for eff hpt_eta_tkAllCPU_ = iBook.book2D("ptetatrkAllCPU", "Track (quality #geq loose) on CPU; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); hpt_eta_tkAllCPUMatched_ = iBook.book2D("ptetatrkAllCPUmatched", "Track (quality #geq loose) on CPU matched to GPU track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); @@ -268,7 +268,7 @@ void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptio edm::ParameterSetDescription desc; desc.add("pixelTrackSrcCPU", edm::InputTag("pixelTracksSoA@cpu")); desc.add("pixelTrackSrcGPU", edm::InputTag("pixelTracksSoA@cuda")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU/"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU"); desc.add("useQualityCut", true); desc.add("minQuality", "loose"); desc.add("deltaR2cut", 0.04); diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc index 3648a4860144b..042c15c23a8cf 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc @@ -166,7 +166,7 @@ void SiPixelPhase1CompareVertexSoA::fillDescriptions(edm::ConfigurationDescripti desc.add("pixelVertexSrcCPU", edm::InputTag("pixelVerticesSoA@cpu")); desc.add("pixelVertexSrcGPU", edm::InputTag("pixelVerticesSoA@cuda")); desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoAGPU vs CPU"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoAGPUvsCPU"); desc.add("dzCut", 1.); descriptions.addWithDefaultLabel(desc); } From 66e4a9fa13ef8a9e8dbeaa18f2194c3c72be7246 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 22 Apr 2022 17:14:56 +0200 Subject: [PATCH 32/57] make clang happy --- .../SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc | 4 ++-- .../SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc | 4 ++-- RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc | 2 +- RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc | 2 +- RecoTracker/TkMSParametrization/test/TestMS.cc | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc index 0ead12781d1cb..93d6ae03d43a4 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripClusterValidator.cc @@ -17,8 +17,8 @@ class SiStripClusterValidator : public edm::one::EDAnalyzer<> { public: SiStripClusterValidator(const edm::ParameterSet& config); ~SiStripClusterValidator() override = default; - virtual void endJob(); - virtual void analyze(const edm::Event& event, const edm::EventSetup& setup); + virtual void endJob() override; + virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override; void validate(const edm::DetSetVector&, const edm::DetSetVector&); void validate(const edmNew::DetSetVector&, const edmNew::DetSetVector&); diff --git a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc index 7f6f470fa979e..f0679a1ba1192 100644 --- a/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc +++ b/EventFilter/SiStripRawToDigi/test/plugins/SiStripDigiValidator.cc @@ -31,8 +31,8 @@ class SiStripDigiValidator : public edm::EDAnalyzer { SiStripDigiValidator(const edm::ParameterSet& config); ~SiStripDigiValidator() override = default; - virtual void endJob(); - virtual void analyze(const edm::Event& event, const edm::EventSetup& setup); + virtual void endJob() override; + virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override; void validate(const edm::DetSetVector&, const edm::DetSetVector&); void validate(const edm::DetSetVector&, const edm::DetSetVector&); diff --git a/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc b/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc index 59236b468d3c8..65b82e4f812d9 100644 --- a/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc +++ b/RecoLocalTracker/SiStripRecHitConverter/test/ClusterFilter.cc @@ -19,7 +19,7 @@ class ClusterFilter : public edm::stream::EDFilter<> { ~ClusterFilter() override = default; private: - bool filter(edm::Event&, edm::EventSetup const&); + bool filter(edm::Event&, edm::EventSetup const&) override; const int nMax_; const edm::EDGetTokenT> clustersToken_; }; diff --git a/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc b/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc index 295a9ec58066e..725c1be9d4def 100644 --- a/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc +++ b/RecoLocalTracker/SiStripRecHitConverter/test/ReadRecHit.cc @@ -29,7 +29,7 @@ namespace cms { explicit ReadRecHit(const edm::ParameterSet& conf); virtual ~ReadRecHit() override = default; - virtual void analyze(const edm::Event& e, const edm::EventSetup& c); + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; private: ReadRecHitAlgorithm readRecHitAlgorithm_; diff --git a/RecoTracker/TkMSParametrization/test/TestMS.cc b/RecoTracker/TkMSParametrization/test/TestMS.cc index 990df14f56cd7..4f87eb173b125 100644 --- a/RecoTracker/TkMSParametrization/test/TestMS.cc +++ b/RecoTracker/TkMSParametrization/test/TestMS.cc @@ -43,7 +43,7 @@ class TestMS : public edm::one::EDAnalyzer { ~TestMS(); virtual void beginRun(edm::Run const& run, const edm::EventSetup& es) override; virtual void analyze(const edm::Event& ev, const edm::EventSetup& es) override; - virtual void endRun(edm::Run const& run, const edm::EventSetup& es){}; + virtual void endRun(edm::Run const& run, const edm::EventSetup& es) override; private: edm::ESGetToken trackerToken_; @@ -76,6 +76,7 @@ TestMS::~TestMS() { } void TestMS::analyze(const edm::Event& ev, const edm::EventSetup& es) {} +void TestMS::endRun(edm::Run const& run, const edm::EventSetup& es) {} void TestMS::beginRun(edm::Run const& run, const edm::EventSetup& es) { auto const& tracker = es.getData(trackerToken_); From 946d4adddbdff4011670cae3b0b7a2a2466d32a0 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 23 Apr 2022 04:27:17 +0200 Subject: [PATCH 33/57] Correct cassette positioning in view of modified flat file format for HGCal silicon --- .../HGCalCommonData/interface/HGCalCassette.h | 1 - Geometry/HGCalCommonData/src/HGCalCassette.cc | 20 ++++--------------- .../HGCalCommonData/test/HGCalConvert.cpp | 10 ++++------ 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalCassette.h b/Geometry/HGCalCommonData/interface/HGCalCassette.h index 6342df5fec747..3b8d0d729d16a 100644 --- a/Geometry/HGCalCommonData/interface/HGCalCassette.h +++ b/Geometry/HGCalCommonData/interface/HGCalCassette.h @@ -19,7 +19,6 @@ class HGCalCassette { int cassette_; bool typeHE_; std::vector shifts_; - std::vector cos_, sin_; }; #endif diff --git a/Geometry/HGCalCommonData/src/HGCalCassette.cc b/Geometry/HGCalCommonData/src/HGCalCassette.cc index 9275e70f4f045..a8eca5a969ac2 100644 --- a/Geometry/HGCalCommonData/src/HGCalCassette.cc +++ b/Geometry/HGCalCommonData/src/HGCalCassette.cc @@ -1,39 +1,27 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalCassette.h" -#include "DataFormats/Math/interface/angle_units.h" #include -#define EDM_ML_DEBUG +//#define EDM_ML_DEBUG void HGCalCassette::setParameter(int cassette, const std::vector& shifts) { cassette_ = cassette; typeHE_ = (cassette_ >= 12); shifts_.insert(shifts_.end(), shifts.begin(), shifts.end()); - double dphi = angle_units::piRadians / cassette_; - for (int k = 0; k < cassette_; ++k) { - double angle = (2 * k - 1) * dphi; - cos_.emplace_back(std::cos(angle)); - sin_.emplace_back(std::sin(angle)); - } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "# of cassettes = " << cassette_ << " Type " << typeHE_ << " dPhi " << dphi; + edm::LogVerbatim("HGCalGeom") << "# of cassettes = " << cassette_ << " Type " << typeHE_; std::ostringstream st1; st1 << " Shifts:"; for (const auto& s : shifts_) st1 << ":" << s; edm::LogVerbatim("HGCalGeom") << st1.str(); - std::ostringstream st2; - st2 << " Cos|Sin:"; - for (int k = 0; k < cassette_; ++k) - st2 << " " << cos_[k] << ":" << sin_[k]; - edm::LogVerbatim("HGCalGeom") << st2.str(); #endif } std::pair HGCalCassette::getShift(int layer, int zside, int cassette) { int locc = (zside < 0) ? (cassette - 1) : (typeHE_ ? positHE_[cassette - 1] : positEE_[cassette - 1]); - int loc = cassette_ * (layer - 1) + locc; - std::pair xy = std::make_pair(shifts_[loc] * cos_[locc], shifts_[loc] * sin_[locc]); + int loc = 2 * cassette_ * (layer - 1) + locc; + std::pair xy = std::make_pair(shifts_[loc], shifts_[loc + 1]); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "HGCalCassette::getShift: Layer " << layer << " zside " << zside << " cassette " << cassette << " Loc " << locc << ":" << loc << " shift " << xy.first << ":" diff --git a/Geometry/HGCalCommonData/test/HGCalConvert.cpp b/Geometry/HGCalCommonData/test/HGCalConvert.cpp index e0484a2af48d4..e3c9289a1536b 100644 --- a/Geometry/HGCalCommonData/test/HGCalConvert.cpp +++ b/Geometry/HGCalCommonData/test/HGCalConvert.cpp @@ -605,7 +605,7 @@ void ConvertSiliconV2::convert( HGCalTypes::WaferLDRight, HGCalTypes::WaferLDFive, HGCalTypes::WaferLDThree}; - const unsigned int cassetteEE(6), cassetteHE(12); + const unsigned int cassetteEE(12), cassetteHE(24); std::map module1, module2, module3; unsigned int all(0), comments(0), others(0), bad(0), good(0); unsigned int layers(layMax3_); @@ -814,7 +814,7 @@ void ConvertSiliconV2::writeSilicon(const char* outfile, fOut << std::setw(5) << layerStart[k3] << last; } fOut << "\n" << blank << "\n"; - unsigned int csize = cassettes * layers.size() + 1; + unsigned int csize = cassettes * layers.size(); if (mode) { fOut << blank << ""; @@ -822,16 +822,14 @@ void ConvertSiliconV2::writeSilicon(const char* outfile, fOut << blank << ""; } - std::string last = (layers.size() == 0) ? " " : ","; - fOut << "\n " << blank << std::setw(2) << cassettes << last; for (const auto& l : layers) { ++k3; for (unsigned int k = 0; k < cassettes; ++k) { std::string last = ((k3 == layers.size()) && ((k + 1) == cassettes)) ? " " : ","; if ((k == 0) || (k == 6)) - fOut << "\n " << blank << std::setw(8) << l.deltaR[k] << last; + fOut << "\n " << blank << std::setw(9) << l.deltaR[k] << last; else - fOut << std::setw(8) << l.deltaR[k] << last; + fOut << std::setw(9) << l.deltaR[k] << last; } } fOut << "\n" << blank << "\n"; From 65c8253922afadff29d47890bf36f7abc65435ff Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 23 Apr 2022 13:59:45 +0200 Subject: [PATCH 34/57] add comment to fix TH2 comparison plots as soon as new format is available --- .../plugins/SiPixelPhase1CompareTrackSoA.cc | 2 ++ .../plugins/SiPixelPhase1CompareVertexSoA.cc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc index 8bf8bb5c668ca..223a2bc06b443 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareTrackSoA.cc @@ -230,6 +230,8 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, // clang-format off std::string toRep = "Number of tracks"; + // FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports either TH2I or THnSparse + // these should be moved to a less resource consuming format hnTracks_ = iBook.book2D("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); hnLooseAndAboveTracks_ = iBook.book2D("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); hnLooseAndAboveTracks_matched_ = iBook.book2D("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); diff --git a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc index 042c15c23a8cf..cdfdf441a7983 100644 --- a/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc +++ b/DQM/SiPixelPhase1Heterogeneous/plugins/SiPixelPhase1CompareVertexSoA.cc @@ -149,6 +149,9 @@ void SiPixelPhase1CompareVertexSoA::bookHistograms(DQMStore::IBooker& ibooker, //std::string top_folder = ""// ibooker.cd(); ibooker.setCurrentFolder(topFolderName_); + + // FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports either TH2I or THnSparse + // these should be moved to a less resource consuming format hnVertex_ = ibooker.book2D("nVertex", "# of Vertex;CPU;GPU", 101, -0.5, 100.5, 101, -0.5, 100.5); hx_ = ibooker.book2D("vx", "Vertez x;CPU;GPU", 20, -0.1, 0.1, 20, -0.1, 0.1); hy_ = ibooker.book2D("vy", "Vertez y;CPU;GPU", 20, -0.1, 0.1, 20, -0.1, 0.1); From 6174b8c4696bd31f3b9a0da9630d989b57a1a9c3 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 25 Apr 2022 15:50:02 -0400 Subject: [PATCH 35/57] Can now disable CondorStatusUpdator Added a parameter to allow the service to be disabled. --- FWCore/Services/plugins/CondorStatusUpdater.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/FWCore/Services/plugins/CondorStatusUpdater.cc b/FWCore/Services/plugins/CondorStatusUpdater.cc index d9b6f0e35e5cd..1208c7c7bc845 100644 --- a/FWCore/Services/plugins/CondorStatusUpdater.cc +++ b/FWCore/Services/plugins/CondorStatusUpdater.cc @@ -80,6 +80,7 @@ namespace edm { edm::ParameterSetID m_processParameterSetID; std::uint_least64_t m_lastEventCount = 0; + bool m_disable = false; }; } // namespace service @@ -92,10 +93,15 @@ const unsigned int CondorStatusService::m_defaultUpdateInterval; constexpr float CondorStatusService::m_defaultEmaInterval; CondorStatusService::CondorStatusService(ParameterSet const &pset, edm::ActivityRegistry &ar) - : m_debug(false), m_lastUpdate(0), m_events(0), m_lumis(0), m_runs(0), m_files(0) { + : m_debug(pset.getUntrackedParameter("debug", false)), + m_lastUpdate(0), + m_events(0), + m_lumis(0), + m_runs(0), + m_files(0) { m_shouldUpdate.clear(); - if (pset.exists("debug")) { - m_debug = true; + if (pset.getUntrackedParameter("disable", false)) { + return; } if (!isChirpSupported()) { return; @@ -419,6 +425,7 @@ void CondorStatusService::fillDescriptions(ConfigurationDescriptions &descriptio ->setComment("Interval, in seconds, to calculate event rate over (using EMA)"); desc.addOptionalUntracked("tag")->setComment( "Identifier tag for this process (a value of 'Foo' results in ClassAd attributes of the form 'ChirpCMSSWFoo*')"); + desc.addOptionalUntracked("disable", false)->setComment("Disable this service"); descriptions.add("CondorStatusService", desc); } From f5cc75bfb8661e37c85e28aa40bf00b9cb05a963 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 26 Apr 2022 06:58:30 +0200 Subject: [PATCH 36/57] Put the new 2018 scenarios in the standard places as decided in the SIM meeting --- .../python/GeometryDD4hepExtended2018DD4hepReco_cff.py | 2 +- .../Geometry/python/GeometryDD4hepExtended2018DD4hep_cff.py | 2 +- .../Geometry/python/GeometryExtended2018DDDReco_cff.py | 2 +- .../Geometry/python/GeometryExtended2018DDD_cff.py | 2 +- .../data/dd4hep/cmsExtendedGeometry2018DD4hep.xml} | 0 .../python/cmsExtendedGeometry2018DDDXML_cfi.py} | 0 .../python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.0.py | 4 ++-- .../python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.911.py | 4 ++-- .../test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.0.py | 2 +- .../test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.911.py | 2 +- ...RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.0.py | 2 +- ...W2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.911.py | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) rename Geometry/HcalCommonData/python/GeometryDD4HepExtended2018Reco_cff.py => Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hepReco_cff.py (95%) rename Geometry/HcalCommonData/python/GeometryDD4HepExtended2018_cff.py => Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hep_cff.py (88%) rename Geometry/HcalCommonData/python/GeometryExtended2018Reco_cff.py => Configuration/Geometry/python/GeometryExtended2018DDDReco_cff.py (95%) rename Geometry/HcalCommonData/python/GeometryExtended2018_cff.py => Configuration/Geometry/python/GeometryExtended2018DDD_cff.py (84%) rename Geometry/{HcalCommonData/data/cmsExtendedGeometry2018.xml => CMSCommonData/data/dd4hep/cmsExtendedGeometry2018DD4hep.xml} (100%) rename Geometry/{HcalCommonData/python/cmsExtendedGeometry2018XML_cfi.py => CMSCommonData/python/cmsExtendedGeometry2018DDDXML_cfi.py} (100%) diff --git a/Geometry/HcalCommonData/python/GeometryDD4HepExtended2018Reco_cff.py b/Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hepReco_cff.py similarity index 95% rename from Geometry/HcalCommonData/python/GeometryDD4HepExtended2018Reco_cff.py rename to Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hepReco_cff.py index 5c2d1bcf7a2bd..022d54b8556bc 100644 --- a/Geometry/HcalCommonData/python/GeometryDD4HepExtended2018Reco_cff.py +++ b/Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hepReco_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms -from Geometry.HcalCommonData.GeometryDD4HepExtended2018_cff import * +from Configuration.Geometry.GeometryDD4hepExtended2018DD4hep_cff import * from Geometry.CommonTopologies.globalTrackingGeometry_cfi import * from RecoTracker.GeometryESProducer.TrackerRecoGeometryESProducer_cfi import * diff --git a/Geometry/HcalCommonData/python/GeometryDD4HepExtended2018_cff.py b/Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hep_cff.py similarity index 88% rename from Geometry/HcalCommonData/python/GeometryDD4HepExtended2018_cff.py rename to Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hep_cff.py index b8b5c67e7a1b0..44e73301ae4aa 100644 --- a/Geometry/HcalCommonData/python/GeometryDD4HepExtended2018_cff.py +++ b/Configuration/Geometry/python/GeometryDD4hepExtended2018DD4hep_cff.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms from Configuration.Geometry.GeometryDD4hep_cff import * -DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("Geometry/HcalCommonData/data/cmsExtendedGeometry2018.xml") +DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2018DD4hep.xml") from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff import * from Geometry.EcalCommonData.ecalSimulationParameters_cff import * diff --git a/Geometry/HcalCommonData/python/GeometryExtended2018Reco_cff.py b/Configuration/Geometry/python/GeometryExtended2018DDDReco_cff.py similarity index 95% rename from Geometry/HcalCommonData/python/GeometryExtended2018Reco_cff.py rename to Configuration/Geometry/python/GeometryExtended2018DDDReco_cff.py index 4e265ad746828..4565dfff3ada3 100644 --- a/Geometry/HcalCommonData/python/GeometryExtended2018Reco_cff.py +++ b/Configuration/Geometry/python/GeometryExtended2018DDDReco_cff.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms # Ideal geometry, needed for transient ECAL alignement -from Geometry.HcalCommonData.GeometryExtended2018_cff import * +from Configuration.Geometry.GeometryExtended2018DDD_cff import * # Reconstruction geometry services diff --git a/Geometry/HcalCommonData/python/GeometryExtended2018_cff.py b/Configuration/Geometry/python/GeometryExtended2018DDD_cff.py similarity index 84% rename from Geometry/HcalCommonData/python/GeometryExtended2018_cff.py rename to Configuration/Geometry/python/GeometryExtended2018DDD_cff.py index 19002d5ae3835..95f24d2182ffe 100644 --- a/Geometry/HcalCommonData/python/GeometryExtended2018_cff.py +++ b/Configuration/Geometry/python/GeometryExtended2018DDD_cff.py @@ -4,7 +4,7 @@ # Geometry master configuration # # Ideal geometry, needed for simulation -from Geometry.HcalCommonData.cmsExtendedGeometry2018XML_cfi import * +from Geometry.CMSCommonData.cmsExtendedGeometry2018DDDXML_cfi import * from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import * from Geometry.EcalCommonData.ecalSimulationParameters_cff import * from Geometry.HcalCommonData.hcalDDDSimConstants_cff import * diff --git a/Geometry/HcalCommonData/data/cmsExtendedGeometry2018.xml b/Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2018DD4hep.xml similarity index 100% rename from Geometry/HcalCommonData/data/cmsExtendedGeometry2018.xml rename to Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2018DD4hep.xml diff --git a/Geometry/HcalCommonData/python/cmsExtendedGeometry2018XML_cfi.py b/Geometry/CMSCommonData/python/cmsExtendedGeometry2018DDDXML_cfi.py similarity index 100% rename from Geometry/HcalCommonData/python/cmsExtendedGeometry2018XML_cfi.py rename to Geometry/CMSCommonData/python/cmsExtendedGeometry2018DDDXML_cfi.py diff --git a/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.0.py b/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.0.py index 0e34b158ee22c..b9c7845e01dac 100644 --- a/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.0.py +++ b/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.0.py @@ -15,8 +15,8 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Geometry.HcalCommonData.GeometryExtended2018Reco_cff') -process.load('Geometry.HcalCommonData.GeometryExtended2018_cff') +process.load('Configuration.Geometry.GeometryExtended2018DDDReco_cff') +process.load('Configuration.Geometry.GeometryExtended2018DDD_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.Generator_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic25ns13TeVEarly2018Collision_cfi') diff --git a/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.911.py b/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.911.py index 2b3d22131f167..bf987c7713f26 100644 --- a/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.911.py +++ b/Geometry/HcalCommonData/test/python/TTbar_13TeV_TuneCUETP8M1_cfi_GEN_SIM_10824.911.py @@ -10,8 +10,8 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Geometry.HcalCommonData.GeometryDD4HepExtended2018Reco_cff') -process.load('Geometry.HcalCommonData.GeometryDD4HepExtended2018_cff') +process.load('Configuration.Geometry.GeometryDD4hepExtended2018DD4hep_cff') +process.load('Configuration.Geometry.GeometryDD4hepExtended2018DD4hepReco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.Generator_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic25ns13TeVEarly2018Collision_cfi') diff --git a/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.0.py b/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.0.py index b3b18fba108b5..d1335f53f8c2e 100644 --- a/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.0.py +++ b/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.0.py @@ -15,7 +15,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Geometry.HcalCommonData.GeometryExtended2018Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2018DDDReco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.Digi_cff') process.load('Configuration.StandardSequences.SimL1Emulator_cff') diff --git a/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.911.py b/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.911.py index be6cb133ce7ab..656abe6a10cdb 100644 --- a/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.911.py +++ b/Geometry/HcalCommonData/test/python/step2_DIGI_L1_DIGI2RAW_HLT_10824.911.py @@ -10,7 +10,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Geometry.HcalCommonData.GeometryDD4HepExtended2018Reco_cff') +process.load('Configuration.Geometry.GeometryDD4hepExtended2018DD4hepReco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.Digi_cff') process.load('Configuration.StandardSequences.SimL1Emulator_cff') diff --git a/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.0.py b/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.0.py index 831f7634c6c13..880c2a2d97dd5 100644 --- a/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.0.py +++ b/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.0.py @@ -15,7 +15,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Geometry.HcalCommonData.GeometryExtended2018Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2018DDDReco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1Reco_cff') diff --git a/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.911.py b/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.911.py index 0c8cfb7da9708..fd4a56f0f1e9b 100644 --- a/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.911.py +++ b/Geometry/HcalCommonData/test/python/step3_RAW2DIGI_L1Reco_RECO_RECOSIM_PAT_VALIDATION_DQM_10824.911.py @@ -10,7 +10,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Geometry.HcalCommonData.GeometryDD4HepExtended2018Reco_cff') +process.load('Configuration.Geometry.GeometryDD4hepExtended2018DD4hepReco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1Reco_cff') From cdb2b0e0a4a25c2458d8510d350f16fd7575b3ba Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 27 Apr 2022 04:46:38 +0200 Subject: [PATCH 37/57] Replace getbylabel with get using token --- SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc b/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc index bb7aa7f97e615..301d1548c084f 100644 --- a/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc +++ b/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc @@ -75,6 +75,11 @@ class TreeProducerCalibSimul : public edm::one::EDAnalyzer myTree_; + edm::EDGetTokenT tokEBRecHit_; + edm::EDGetTokenT tokEcalHodo_; + edm::EDGetTokenT tokEcalTDC_; + edm::EDGetTokenT tokEventHeader_; + int xtalInBeam_; int tot_events_; int tot_events_ok_; @@ -112,6 +117,11 @@ TreeProducerCalibSimul::TreeProducerCalibSimul(const edm::ParameterSet& iConfig) << tdcRecInfoProducer_.c_str(); edm::LogVerbatim("GFlash") << "Fetching evHeaCollection: " << eventHeaderCollection_.c_str() << " prod by " << eventHeaderProducer_.c_str() << "\n"; + + tokEBRecHit_ = consumes(edm::InputTag(RecHitProducer_, EBRecHitCollection_)) ; + tokEcalHodo_ = consumes(edm::InputTag(hodoRecInfoProducer_, hodoRecInfoCollection_)); + tokEcalTDC_ = consumes(edm::InputTag(tdcRecInfoProducer_, tdcRecInfoCollection_)); + tokEventHeader_ = consumes(edm::InputTag(eventHeaderProducer_)); } // ------------------------------------------------------ @@ -157,24 +167,16 @@ void TreeProducerCalibSimul::analyze(const edm::Event& iEvent, const edm::EventS // --------------------------------------------------------------------- // taking what I need: hits - edm::Handle pEBRecHits; - iEvent.getByLabel(RecHitProducer_, EBRecHitCollection_, pEBRecHits); - const EBRecHitCollection* EBRecHits = pEBRecHits.product(); + const EBRecHitCollection* EBRecHits = &iEvent.get(tokEBRecHit_); // taking what I need: hodoscopes - edm::Handle pHodo; - iEvent.getByLabel(hodoRecInfoProducer_, hodoRecInfoCollection_, pHodo); - const EcalTBHodoscopeRecInfo* recHodo = pHodo.product(); + const EcalTBHodoscopeRecInfo* recHodo = &iEvent.get(tokEcalHodo_); // taking what I need: tdc - edm::Handle pTDC; - iEvent.getByLabel(tdcRecInfoProducer_, tdcRecInfoCollection_, pTDC); - const EcalTBTDCRecInfo* recTDC = pTDC.product(); + const EcalTBTDCRecInfo* recTDC = &iEvent.get(tokEcalTDC_); // taking what I need: event header - edm::Handle pEventHeader; - iEvent.getByLabel(eventHeaderProducer_, pEventHeader); - const EcalTBEventHeader* evtHeader = pEventHeader.product(); + const EcalTBEventHeader* evtHeader = &iEvent.get(tokEventHeader_); // checking everything is there and fine if ((!EBRecHits) || (EBRecHits->size() == 0)) { From b2edf4e182a1cb6b43817bc6d1b5d4a86ac36477 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 27 Apr 2022 05:42:13 +0200 Subject: [PATCH 38/57] Code check --- SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc b/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc index 301d1548c084f..a99c6c71a22da 100644 --- a/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc +++ b/SimG4Core/GFlash/TB/TreeProducerCalibSimul.cc @@ -118,7 +118,7 @@ TreeProducerCalibSimul::TreeProducerCalibSimul(const edm::ParameterSet& iConfig) edm::LogVerbatim("GFlash") << "Fetching evHeaCollection: " << eventHeaderCollection_.c_str() << " prod by " << eventHeaderProducer_.c_str() << "\n"; - tokEBRecHit_ = consumes(edm::InputTag(RecHitProducer_, EBRecHitCollection_)) ; + tokEBRecHit_ = consumes(edm::InputTag(RecHitProducer_, EBRecHitCollection_)); tokEcalHodo_ = consumes(edm::InputTag(hodoRecInfoProducer_, hodoRecInfoCollection_)); tokEcalTDC_ = consumes(edm::InputTag(tdcRecInfoProducer_, tdcRecInfoCollection_)); tokEventHeader_ = consumes(edm::InputTag(eventHeaderProducer_)); From f26e0cddd10fee05fa4cfa06dc0608b63a6d09a3 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 27 Apr 2022 10:38:18 +0200 Subject: [PATCH 39/57] Safer limits for Geant4 tracking and explicit dependene on geant4core --- SimG4CMS/Calo/plugins/BuildFile.xml | 1 + SimG4Core/Application/python/g4SimHits_cfi.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SimG4CMS/Calo/plugins/BuildFile.xml b/SimG4CMS/Calo/plugins/BuildFile.xml index 041a8a5ec0472..449edbe1206c8 100644 --- a/SimG4CMS/Calo/plugins/BuildFile.xml +++ b/SimG4CMS/Calo/plugins/BuildFile.xml @@ -21,6 +21,7 @@ + diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index b236b517bd376..aa068c8156fbc 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -85,7 +85,7 @@ StorePhysicsTables = cms.untracked.bool(False), RestorePhysicsTables = cms.untracked.bool(False), UseParametrisedEMPhysics = cms.untracked.bool(True), - ThresholdForGeometryExceptions = cms.double(0.01), ## in GeV + ThresholdForGeometryExceptions = cms.double(0.1), ## in GeV TraceExceptions = cms.bool(False), CheckGeometry = cms.untracked.bool(False), OnlySDs = cms.vstring('ZdcSensitiveDetector', 'TotemT2ScintSensitiveDetector', 'TotemSensitiveDetector', 'RomanPotSensitiveDetector', 'PLTSensitiveDetector', 'MuonSensitiveDetector', 'MtdSensitiveDetector', 'BCM1FSensitiveDetector', 'EcalSensitiveDetector', 'CTPPSSensitiveDetector', 'BSCSensitiveDetector', 'CTPPSDiamondSensitiveDetector', 'FP420SensitiveDetector', 'BHMSensitiveDetector', 'CastorSensitiveDetector', 'CaloTrkProcessing', 'HcalSensitiveDetector', 'TkAccumulatingSensitiveDetector'), @@ -312,7 +312,7 @@ ), SteppingAction = cms.PSet( common_maximum_time, - MaxNumberOfSteps = cms.int32(50000), + MaxNumberOfSteps = cms.int32(20000), EkinNames = cms.vstring(), EkinThresholds = cms.vdouble(), EkinParticles = cms.vstring() From 49e9e1f3ac423e8647e5ab91292ff346db3a1c89 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 27 Apr 2022 12:07:00 +0200 Subject: [PATCH 40/57] Replace getByLabel with getHandle in SimG4Core/CustomPhysics --- .../CustomPhysics/interface/RHStopDump.h | 12 +++++-- SimG4Core/CustomPhysics/plugins/RHStopDump.cc | 34 +++++++++---------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/SimG4Core/CustomPhysics/interface/RHStopDump.h b/SimG4Core/CustomPhysics/interface/RHStopDump.h index 9c11f8a77ae42..9703b478ff4e9 100644 --- a/SimG4Core/CustomPhysics/interface/RHStopDump.h +++ b/SimG4Core/CustomPhysics/interface/RHStopDump.h @@ -12,12 +12,20 @@ class RHStopDump : public edm::one::EDAnalyzer { public: explicit RHStopDump(const edm::ParameterSet&); - ~RHStopDump() override{}; + ~RHStopDump() override = default; void analyze(const edm::Event&, const edm::EventSetup&) override; private: std::ofstream mStream; - std::string mProducer; + const std::string mProducer; + const edm::EDGetTokenT > tokNames_; + const edm::EDGetTokenT > tokenXs_; + const edm::EDGetTokenT > tokenYs_; + const edm::EDGetTokenT > tokenZs_; + const edm::EDGetTokenT > tokenTs_; + const edm::EDGetTokenT > tokenIds_; + const edm::EDGetTokenT > tokenMasses_; + const edm::EDGetTokenT > tokenCharges_; }; #endif diff --git a/SimG4Core/CustomPhysics/plugins/RHStopDump.cc b/SimG4Core/CustomPhysics/plugins/RHStopDump.cc index f711bd9a73066..046934deac71b 100644 --- a/SimG4Core/CustomPhysics/plugins/RHStopDump.cc +++ b/SimG4Core/CustomPhysics/plugins/RHStopDump.cc @@ -6,25 +6,25 @@ RHStopDump::RHStopDump(edm::ParameterSet const& parameters) : mStream(parameters.getParameter("stoppedFile").c_str()), - mProducer(parameters.getUntrackedParameter("producer", "g4SimHits")) {} + mProducer(parameters.getUntrackedParameter("producer", "g4SimHits")), + tokNames_ (consumes >(edm::InputTag(mProducer, "StoppedParticlesName"))), + tokenXs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesX"))), + tokenYs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesY"))), + tokenZs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesZ"))), + tokenTs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesTime"))), + tokenIds_(consumes >(edm::InputTag(mProducer, "StoppedParticlesPdgId"))), + tokenMasses_(consumes >(edm::InputTag(mProducer, "StoppedParticlesMass"))), + tokenCharges_(consumes >(edm::InputTag(mProducer, "StoppedParticlesCharge"))){} void RHStopDump::analyze(const edm::Event& fEvent, const edm::EventSetup&) { - edm::Handle > names; - fEvent.getByLabel(mProducer, "StoppedParticlesName", names); - edm::Handle > xs; - fEvent.getByLabel(mProducer, "StoppedParticlesX", xs); - edm::Handle > ys; - fEvent.getByLabel(mProducer, "StoppedParticlesY", ys); - edm::Handle > zs; - fEvent.getByLabel(mProducer, "StoppedParticlesZ", zs); - edm::Handle > ts; - fEvent.getByLabel(mProducer, "StoppedParticlesTime", ts); - edm::Handle > ids; - fEvent.getByLabel(mProducer, "StoppedParticlesPdgId", ids); - edm::Handle > masses; - fEvent.getByLabel(mProducer, "StoppedParticlesMass", masses); - edm::Handle > charges; - fEvent.getByLabel(mProducer, "StoppedParticlesCharge", charges); + const edm::Handle > & names = fEvent.getHandle(tokNames_); + const edm::Handle > & xs = fEvent.getHandle(tokenXs_); + const edm::Handle > & ys = fEvent.getHandle(tokenYs_); + const edm::Handle > & zs = fEvent.getHandle(tokenZs_); + const edm::Handle > & ts = fEvent.getHandle(tokenTs_); + const edm::Handle > & ids = fEvent.getHandle(tokenIds_); + const edm::Handle > & masses = fEvent.getHandle(tokenMasses_); + const edm::Handle > & charges = fEvent.getHandle(tokenCharges_); if (names->size() != xs->size() || xs->size() != ys->size() || ys->size() != zs->size()) { edm::LogError("RHStopDump") << "mismatch array sizes name/x/y/z:" << names->size() << '/' << xs->size() << '/' From 904e9c70baa8d25bf98b8989da466c4a68f16a47 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 27 Apr 2022 12:19:03 +0200 Subject: [PATCH 41/57] Code check --- SimG4Core/CustomPhysics/plugins/RHStopDump.cc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/SimG4Core/CustomPhysics/plugins/RHStopDump.cc b/SimG4Core/CustomPhysics/plugins/RHStopDump.cc index 046934deac71b..39c3ddbe39c5d 100644 --- a/SimG4Core/CustomPhysics/plugins/RHStopDump.cc +++ b/SimG4Core/CustomPhysics/plugins/RHStopDump.cc @@ -7,24 +7,24 @@ RHStopDump::RHStopDump(edm::ParameterSet const& parameters) : mStream(parameters.getParameter("stoppedFile").c_str()), mProducer(parameters.getUntrackedParameter("producer", "g4SimHits")), - tokNames_ (consumes >(edm::InputTag(mProducer, "StoppedParticlesName"))), + tokNames_(consumes >(edm::InputTag(mProducer, "StoppedParticlesName"))), tokenXs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesX"))), tokenYs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesY"))), tokenZs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesZ"))), tokenTs_(consumes >(edm::InputTag(mProducer, "StoppedParticlesTime"))), tokenIds_(consumes >(edm::InputTag(mProducer, "StoppedParticlesPdgId"))), tokenMasses_(consumes >(edm::InputTag(mProducer, "StoppedParticlesMass"))), - tokenCharges_(consumes >(edm::InputTag(mProducer, "StoppedParticlesCharge"))){} + tokenCharges_(consumes >(edm::InputTag(mProducer, "StoppedParticlesCharge"))) {} void RHStopDump::analyze(const edm::Event& fEvent, const edm::EventSetup&) { - const edm::Handle > & names = fEvent.getHandle(tokNames_); - const edm::Handle > & xs = fEvent.getHandle(tokenXs_); - const edm::Handle > & ys = fEvent.getHandle(tokenYs_); - const edm::Handle > & zs = fEvent.getHandle(tokenZs_); - const edm::Handle > & ts = fEvent.getHandle(tokenTs_); - const edm::Handle > & ids = fEvent.getHandle(tokenIds_); - const edm::Handle > & masses = fEvent.getHandle(tokenMasses_); - const edm::Handle > & charges = fEvent.getHandle(tokenCharges_); + const edm::Handle >& names = fEvent.getHandle(tokNames_); + const edm::Handle >& xs = fEvent.getHandle(tokenXs_); + const edm::Handle >& ys = fEvent.getHandle(tokenYs_); + const edm::Handle >& zs = fEvent.getHandle(tokenZs_); + const edm::Handle >& ts = fEvent.getHandle(tokenTs_); + const edm::Handle >& ids = fEvent.getHandle(tokenIds_); + const edm::Handle >& masses = fEvent.getHandle(tokenMasses_); + const edm::Handle >& charges = fEvent.getHandle(tokenCharges_); if (names->size() != xs->size() || xs->size() != ys->size() || ys->size() != zs->size()) { edm::LogError("RHStopDump") << "mismatch array sizes name/x/y/z:" << names->size() << '/' << xs->size() << '/' From 5ffbfea596e9b0227ee24885141516d5d444e918 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 27 Apr 2022 12:38:34 +0200 Subject: [PATCH 42/57] improved comments --- SimG4Core/Application/python/g4SimHits_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index aa068c8156fbc..10bb7e3f30afe 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -85,12 +85,12 @@ StorePhysicsTables = cms.untracked.bool(False), RestorePhysicsTables = cms.untracked.bool(False), UseParametrisedEMPhysics = cms.untracked.bool(True), - ThresholdForGeometryExceptions = cms.double(0.1), ## in GeV + ThresholdForGeometryExceptions = cms.double(0.1), ## in GeV TraceExceptions = cms.bool(False), CheckGeometry = cms.untracked.bool(False), OnlySDs = cms.vstring('ZdcSensitiveDetector', 'TotemT2ScintSensitiveDetector', 'TotemSensitiveDetector', 'RomanPotSensitiveDetector', 'PLTSensitiveDetector', 'MuonSensitiveDetector', 'MtdSensitiveDetector', 'BCM1FSensitiveDetector', 'EcalSensitiveDetector', 'CTPPSSensitiveDetector', 'BSCSensitiveDetector', 'CTPPSDiamondSensitiveDetector', 'FP420SensitiveDetector', 'BHMSensitiveDetector', 'CastorSensitiveDetector', 'CaloTrkProcessing', 'HcalSensitiveDetector', 'TkAccumulatingSensitiveDetector'), G4CheckOverlap = cms.untracked.PSet( - OutputBaseName = cms.string('2017'), + OutputBaseName = cms.string('2021'), MaterialFlag = cms.bool(True), GeomFlag = cms.bool(True), OverlapFlag = cms.bool(False), From b030515246cf35074b66b960f67dd9e43f9e9921 Mon Sep 17 00:00:00 2001 From: ccaillol Date: Wed, 27 Apr 2022 12:46:12 +0200 Subject: [PATCH 43/57] fix improper casting --- .../plugins/implementations_stage2/EtSumUnpacker.h | 2 +- .../plugins/implementations_stage2/EtSumUnpacker_0x10010057.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h index 2d2dae5ddd9f5..7468b417f8156 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h @@ -12,7 +12,7 @@ namespace l1t { bool unpack(const Block& block, UnpackerCollections* coll) override; - inline void setEtSumCopy(const unsigned int copy) { EtSumCopy_ = copy; }; + virtual inline void setEtSumCopy(const unsigned int copy) { EtSumCopy_ = copy; }; private: unsigned int EtSumCopy_; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h index 29e62e7170d47..31de9b15ef29c 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h @@ -1,11 +1,11 @@ #ifndef L1T_PACKER_STAGE2_ETSUMUNPACKER_0X10010057_H #define L1T_PACKER_STAGE2_ETSUMUNPACKER_0X10010057_H -#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" +#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h" namespace l1t { namespace stage2 { - class EtSumUnpacker_0x10010057 : public Unpacker { + class EtSumUnpacker_0x10010057 : public EtSumUnpacker { public: EtSumUnpacker_0x10010057(); ~EtSumUnpacker_0x10010057() override{}; From 638f9c6b04dcf3d28661fd8a8e5e1a331e318890 Mon Sep 17 00:00:00 2001 From: ccaillol Date: Wed, 27 Apr 2022 14:55:57 +0200 Subject: [PATCH 44/57] fix clang warning --- .../plugins/implementations_stage2/EtSumUnpacker_0x10010057.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h index 31de9b15ef29c..963b7bf60d1d6 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker_0x10010057.h @@ -12,7 +12,7 @@ namespace l1t { bool unpack(const Block& block, UnpackerCollections* coll) override; - inline void setEtSumCopy(const unsigned int copy) { EtSumCopy_ = copy; }; + inline void setEtSumCopy(const unsigned int copy) override { EtSumCopy_ = copy; }; private: unsigned int EtSumCopy_; From 0f53d79f47b13a7ab5a1e709c5369e660e46ebba Mon Sep 17 00:00:00 2001 From: ccaillol Date: Wed, 27 Apr 2022 15:32:19 +0200 Subject: [PATCH 45/57] fix array bounds --- EventFilter/CSCTFRawToDigi/plugins/CSCTFUnpacker.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EventFilter/CSCTFRawToDigi/plugins/CSCTFUnpacker.cc b/EventFilter/CSCTFRawToDigi/plugins/CSCTFUnpacker.cc index 3d4b1a427643f..8bfff33e07542 100644 --- a/EventFilter/CSCTFRawToDigi/plugins/CSCTFUnpacker.cc +++ b/EventFilter/CSCTFRawToDigi/plugins/CSCTFUnpacker.cc @@ -183,9 +183,9 @@ void CSCTFUnpacker::produce(edm::Event& e, const edm::EventSetup& c) { if (lct.empty()) continue; - status.link_status[lct[0].spInput()] |= (1 << lct[0].receiver_status_frame1()) | - (1 << lct[0].receiver_status_frame2()) | - ((lct[0].aligment_fifo() ? 1 : 0) << 4); + status.link_status[lct[0].spInput() - 1] |= (1 << lct[0].receiver_status_frame1()) | + (1 << lct[0].receiver_status_frame2()) | + ((lct[0].aligment_fifo() ? 1 : 0) << 4); status.mpc_link_id |= (lct[0].link() << 2) | lct[0].mpc(); int station = (FPGA ? FPGA : 1); From c0367060a5039c73a9707740c4100e7a1aece459 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Tue, 26 Apr 2022 19:30:01 -0500 Subject: [PATCH 46/57] Remove unnecessary include of legacy EDAnalyzer header --- HLTrigger/Egamma/plugins/HLTGenericFilter.h | 1 - 1 file changed, 1 deletion(-) diff --git a/HLTrigger/Egamma/plugins/HLTGenericFilter.h b/HLTrigger/Egamma/plugins/HLTGenericFilter.h index 4e74fb5b3e33a..603162b8498af 100644 --- a/HLTrigger/Egamma/plugins/HLTGenericFilter.h +++ b/HLTrigger/Egamma/plugins/HLTGenericFilter.h @@ -10,7 +10,6 @@ #include "HLTrigger/HLTcore/interface/HLTFilter.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" From 1217394a96ae460c4652193a11aebdb75807556b Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Tue, 26 Apr 2022 19:30:48 -0500 Subject: [PATCH 47/57] Remove (some) unnecessary framework includes --- .../GlobalTriggerAnalyzer/src/L1GtTrigReport.cc | 2 -- .../L1GctAnalyzer/interface/compareBitCounts.h | 10 +--------- L1Trigger/L1GctAnalyzer/interface/compareRingSums.h | 11 +---------- L1Trigger/L1GctAnalyzer/src/compareBitCounts.cc | 13 ------------- L1Trigger/L1GctAnalyzer/src/compareRingSums.cc | 13 ------------- .../interface/Omtf/OMTFReconstruction.h | 1 - .../plugins/L1TMuonOverlapPhase1TrackProducer.cc | 5 +---- L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.cc | 2 +- L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.h | 1 - L1Trigger/TrackFindingTMTT/interface/InputData.h | 3 +-- L1Trigger/TrackFindingTMTT/src/InputData.cc | 3 --- L1Trigger/TrackTrigger/interface/L1TrackQuality.h | 2 -- L1Trigger/VertexFinder/interface/InputData.h | 3 --- L1Trigger/VertexFinder/src/InputData.cc | 1 - 14 files changed, 5 insertions(+), 65 deletions(-) diff --git a/L1Trigger/GlobalTriggerAnalyzer/src/L1GtTrigReport.cc b/L1Trigger/GlobalTriggerAnalyzer/src/L1GtTrigReport.cc index 6ed0feba5f46b..6b7c38d574c3b 100644 --- a/L1Trigger/GlobalTriggerAnalyzer/src/L1GtTrigReport.cc +++ b/L1Trigger/GlobalTriggerAnalyzer/src/L1GtTrigReport.cc @@ -30,7 +30,6 @@ #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -41,7 +40,6 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "CondFormats/L1TObjects/interface/L1GtStableParameters.h" #include "CondFormats/DataRecord/interface/L1GtStableParametersRcd.h" diff --git a/L1Trigger/L1GctAnalyzer/interface/compareBitCounts.h b/L1Trigger/L1GctAnalyzer/interface/compareBitCounts.h index f378d3863c53f..388e1dfeeb118 100644 --- a/L1Trigger/L1GctAnalyzer/interface/compareBitCounts.h +++ b/L1Trigger/L1GctAnalyzer/interface/compareBitCounts.h @@ -1,19 +1,11 @@ #ifndef compareBitCounts_h #define compareBitCounts_h -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/Common/interface/Handle.h" #include "TH2.h" #include "TH1.h" diff --git a/L1Trigger/L1GctAnalyzer/interface/compareRingSums.h b/L1Trigger/L1GctAnalyzer/interface/compareRingSums.h index 1d405fe45e760..174fb27afc7db 100644 --- a/L1Trigger/L1GctAnalyzer/interface/compareRingSums.h +++ b/L1Trigger/L1GctAnalyzer/interface/compareRingSums.h @@ -1,19 +1,10 @@ #ifndef compareRingSums_h #define compareRingSums_h -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/Common/interface/Handle.h" #include "TH2.h" #include "TH1.h" diff --git a/L1Trigger/L1GctAnalyzer/src/compareBitCounts.cc b/L1Trigger/L1GctAnalyzer/src/compareBitCounts.cc index 607195a673970..870c3c4508adc 100644 --- a/L1Trigger/L1GctAnalyzer/src/compareBitCounts.cc +++ b/L1Trigger/L1GctAnalyzer/src/compareBitCounts.cc @@ -2,19 +2,6 @@ #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Utilities/interface/InputTag.h" - -#include "FWCore/ServiceRegistry/interface/Service.h" // Framework services -#include "CommonTools/UtilAlgos/interface/TFileService.h" // Framework service for histograms - compareBitCounts::compareBitCounts(const edm::Handle &data, const edm::Handle &emu, const GctErrorAnalyzerMBxInfo &mbxparams) diff --git a/L1Trigger/L1GctAnalyzer/src/compareRingSums.cc b/L1Trigger/L1GctAnalyzer/src/compareRingSums.cc index 407806d8436ab..3e8572bf10bb2 100644 --- a/L1Trigger/L1GctAnalyzer/src/compareRingSums.cc +++ b/L1Trigger/L1GctAnalyzer/src/compareRingSums.cc @@ -2,19 +2,6 @@ #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Utilities/interface/InputTag.h" - -#include "FWCore/ServiceRegistry/interface/Service.h" // Framework services -#include "CommonTools/UtilAlgos/interface/TFileService.h" // Framework service for histograms - compareRingSums::compareRingSums(const edm::Handle &data, const edm::Handle &emu, const GctErrorAnalyzerMBxInfo &mbxparams) diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h index df6e6c91f12d7..b4a1ffa0f0e87 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h @@ -16,7 +16,6 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Utilities/interface/ESGetToken.h" #include "FWCore/Framework/interface/ESWatcher.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.cc b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.cc index a6e2b172b50c0..b06fc19a9e5fb 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.cc @@ -1,7 +1,4 @@ -#include "L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.h" -#include "FWCore/Framework/interface/EDConsumerBase.h" -#include "FWCore/Framework/interface/ProductRegistryHelper.h" -#include "FWCore/PluginManager/interface/PluginFactory.h" +#include "L1TMuonOverlapPhase1TrackProducer.h" #include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/Utilities/interface/InputTag.h" diff --git a/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.cc b/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.cc index 97eee29c83d85..aaecd61bef1ff 100644 --- a/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.cc +++ b/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.h" +#include "HPSPFTauProducer.h" #include "FWCore/Utilities/interface/InputTag.h" #include // std::fabs diff --git a/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.h b/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.h index c75d41d6b6552..572d07ac0fa9b 100644 --- a/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.h +++ b/L1Trigger/Phase2L1Taus/plugins/HPSPFTauProducer.h @@ -1,7 +1,6 @@ #ifndef L1Trigger_Phase2L1Taus_HPSPFTauProducer_h #define L1Trigger_Phase2L1Taus_HPSPFTauProducer_h -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" diff --git a/L1Trigger/TrackFindingTMTT/interface/InputData.h b/L1Trigger/TrackFindingTMTT/interface/InputData.h index 789c059796171..56e06f8fe2e3b 100644 --- a/L1Trigger/TrackFindingTMTT/interface/InputData.h +++ b/L1Trigger/TrackFindingTMTT/interface/InputData.h @@ -1,12 +1,11 @@ #ifndef L1Trigger_TrackFindingTMTT_InputData_h #define L1Trigger_TrackFindingTMTT_InputData_h -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Utilities/interface/EDGetToken.h" #include "L1Trigger/TrackFindingTMTT/interface/TP.h" #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h" #include "L1Trigger/TrackFindingTMTT/interface/Stub.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Utilities/interface/InputTag.h" #include namespace tmtt { diff --git a/L1Trigger/TrackFindingTMTT/src/InputData.cc b/L1Trigger/TrackFindingTMTT/src/InputData.cc index 4d16a2651cfe5..88adc18a3b5dc 100644 --- a/L1Trigger/TrackFindingTMTT/src/InputData.cc +++ b/L1Trigger/TrackFindingTMTT/src/InputData.cc @@ -1,8 +1,5 @@ -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" #include "SimDataFormats/Track/interface/SimTrack.h" #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h" #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" diff --git a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h index 6f96010b30411..c55aeb93cc0dd 100644 --- a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h +++ b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h @@ -16,10 +16,8 @@ C.Brown 28/07/20 #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" diff --git a/L1Trigger/VertexFinder/interface/InputData.h b/L1Trigger/VertexFinder/interface/InputData.h index 8c1ac9d0c6de8..727650fc93e55 100644 --- a/L1Trigger/VertexFinder/interface/InputData.h +++ b/L1Trigger/VertexFinder/interface/InputData.h @@ -1,15 +1,12 @@ #ifndef __L1Trigger_VertexFinder_InputData_h__ #define __L1Trigger_VertexFinder_InputData_h__ -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/ESGetToken.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/InputTag.h" #include "L1Trigger/VertexFinder/interface/Stub.h" #include "L1Trigger/VertexFinder/interface/TP.h" #include "L1Trigger/VertexFinder/interface/Vertex.h" diff --git a/L1Trigger/VertexFinder/src/InputData.cc b/L1Trigger/VertexFinder/src/InputData.cc index a0413b72b4908..9b3de240ebc8c 100644 --- a/L1Trigger/VertexFinder/src/InputData.cc +++ b/L1Trigger/VertexFinder/src/InputData.cc @@ -1,7 +1,6 @@ #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Utilities/interface/InputTag.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" From 067f72da8e381e4691f637af8b83947f486180af Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 27 Apr 2022 18:50:03 +0200 Subject: [PATCH 48/57] do not fetch PixelClusterCountsInEvent when the handle is not valid --- .../plugins/AlcaPCCIntegrator.cc | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCIntegrator.cc b/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCIntegrator.cc index 4e92d9fa4f5db..587aa65069ead 100644 --- a/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCIntegrator.cc +++ b/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCIntegrator.cc @@ -10,28 +10,24 @@ ________________________________________________________________**/ // C++ standard #include // CMS -#include "DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h" #include "DataFormats/Luminosity/interface/PixelClusterCounts.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/MakerMacros.h" +#include "DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/one/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/EDGetToken.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/LuminosityBlock.h" -#include "TMath.h" //The class class AlcaPCCIntegrator : public edm::one::EDProducer { public: explicit AlcaPCCIntegrator(const edm::ParameterSet&); - ~AlcaPCCIntegrator() override; + ~AlcaPCCIntegrator() override = default; private: void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) override; @@ -67,9 +63,6 @@ AlcaPCCIntegrator::AlcaPCCIntegrator(const edm::ParameterSet& iConfig) { pccToken_ = consumes(PCCInputTag_); } -//-------------------------------------------------------------------------------------------------- -AlcaPCCIntegrator::~AlcaPCCIntegrator() {} - //-------------------------------------------------------------------------------------------------- void AlcaPCCIntegrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { countEvt_++; @@ -83,7 +76,12 @@ void AlcaPCCIntegrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetu edm::Handle pccHandle; iEvent.getByToken(pccToken_, pccHandle); - const reco::PixelClusterCountsInEvent inputPcc = *(pccHandle.product()); + if (!pccHandle.isValid()) { + // do not resolve a not existing product! + return; + } + + const reco::PixelClusterCountsInEvent inputPcc = *pccHandle; thePCCob->add(inputPcc); } From fe1c16d56d14715a8bca4817c09887e8dfe2b2cd Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 27 Apr 2022 19:29:47 +0200 Subject: [PATCH 49/57] Remove (some) unnecessary framework includes --- PhysicsTools/UtilAlgos/interface/StringBasedNTupler.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/PhysicsTools/UtilAlgos/interface/StringBasedNTupler.h b/PhysicsTools/UtilAlgos/interface/StringBasedNTupler.h index b2addeb54c8e8..c2d2703cb6f03 100644 --- a/PhysicsTools/UtilAlgos/interface/StringBasedNTupler.h +++ b/PhysicsTools/UtilAlgos/interface/StringBasedNTupler.h @@ -3,8 +3,6 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/ProducesCollector.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" @@ -31,7 +29,6 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" From 5b59b0b469ce3fab0227dfcb596207c6898cdf1e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 27 Apr 2022 13:32:18 -0400 Subject: [PATCH 50/57] Switch parameter to enable --- FWCore/Services/plugins/CondorStatusUpdater.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/FWCore/Services/plugins/CondorStatusUpdater.cc b/FWCore/Services/plugins/CondorStatusUpdater.cc index 1208c7c7bc845..a08af45d781fe 100644 --- a/FWCore/Services/plugins/CondorStatusUpdater.cc +++ b/FWCore/Services/plugins/CondorStatusUpdater.cc @@ -80,7 +80,6 @@ namespace edm { edm::ParameterSetID m_processParameterSetID; std::uint_least64_t m_lastEventCount = 0; - bool m_disable = false; }; } // namespace service @@ -100,7 +99,7 @@ CondorStatusService::CondorStatusService(ParameterSet const &pset, edm::Activity m_runs(0), m_files(0) { m_shouldUpdate.clear(); - if (pset.getUntrackedParameter("disable", false)) { + if (not pset.getUntrackedParameter("enable", true)) { return; } if (!isChirpSupported()) { @@ -425,7 +424,7 @@ void CondorStatusService::fillDescriptions(ConfigurationDescriptions &descriptio ->setComment("Interval, in seconds, to calculate event rate over (using EMA)"); desc.addOptionalUntracked("tag")->setComment( "Identifier tag for this process (a value of 'Foo' results in ClassAd attributes of the form 'ChirpCMSSWFoo*')"); - desc.addOptionalUntracked("disable", false)->setComment("Disable this service"); + desc.addOptionalUntracked("enable", true)->setComment("Enable this service"); descriptions.add("CondorStatusService", desc); } From 1da5e8be27b71a9cbef2dcd3e9968afc610b8f90 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Apr 2022 05:41:34 +0200 Subject: [PATCH 51/57] Replace some of the getByLabel with getHandle in SimCalorimetry/HcalSimProducers --- .../interface/HcalDigitizer.h | 23 ++++++++---- .../plugins/HcalDigiAnalyzer.cc | 37 +++++++++++-------- .../plugins/HcalHitAnalyzer.cc | 37 +++++++++++-------- .../HcalSimProducers/src/HcalDigitizer.cc | 13 ++----- 4 files changed, 63 insertions(+), 47 deletions(-) diff --git a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h index a381942a1d30a..5762b3ca1e29a 100644 --- a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h +++ b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h @@ -10,6 +10,7 @@ #include "CalibCalorimetry/HcalAlgos/interface/HFRecalibration.h" #include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Utilities/interface/EDGetToken.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h" #include "Geometry/HcalCommonData/interface/HcalHitRelabeller.h" @@ -73,6 +74,16 @@ class HcalDigitizer { /// make sure the digitizer has the correct list of all cells that /// exist in the geometry void checkGeometry(const edm::EventSetup &eventSetup); + + void updateGeometry(const edm::EventSetup &eventSetup); + + void buildHOSiPMCells(const std::vector &allCells, const edm::EventSetup &eventSetup); + void buildHFQIECells(const std::vector &allCells, const edm::EventSetup &eventSetup); + void buildHBHEQIECells(const std::vector &allCells, const edm::EventSetup &eventSetup); + + // function to evaluate aging at the digi level + void darkening(std::vector &hcalHits); + const edm::ESGetToken conditionsToken_; const edm::ESGetToken topoToken_; edm::ESGetToken m_HBDarkeningToken; @@ -84,16 +95,9 @@ class HcalDigitizer { edm::ESGetToken mcParamsToken_; edm::ESWatcher theGeometryWatcher_; edm::ESWatcher theRecNumberWatcher_; + const CaloGeometry *theGeometry; const HcalDDDRecConstants *theRecNumber; - void updateGeometry(const edm::EventSetup &eventSetup); - - void buildHOSiPMCells(const std::vector &allCells, const edm::EventSetup &eventSetup); - void buildHFQIECells(const std::vector &allCells, const edm::EventSetup &eventSetup); - void buildHBHEQIECells(const std::vector &allCells, const edm::EventSetup &eventSetup); - - // function to evaluate aging at the digi level - void darkening(std::vector &hcalHits); /** Reconstruction algorithm*/ typedef CaloTDigitizer HBHEDigitizer; @@ -174,6 +178,9 @@ class HcalDigitizer { double deliveredLumi; bool agingFlagHB, agingFlagHE; + + edm::EDGetTokenT> zdcToken_; + edm::EDGetTokenT> hcalToken_; const HBHEDarkening *m_HBDarkening; const HBHEDarkening *m_HEDarkening; std::unique_ptr m_HFRecalibration; diff --git a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc index 271950d8eb0f7..f18bea291339f 100644 --- a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc @@ -91,9 +91,14 @@ class HcalDigiAnalyzer : public edm::one::EDAnalyzer<> { HcalDigiStatistics hfDigiStatistics_; HcalDigiStatistics zdcDigiStatistics_; - edm::InputTag hbheDigiCollectionTag_; - edm::InputTag hoDigiCollectionTag_; - edm::InputTag hfDigiCollectionTag_; + const edm::InputTag hbheDigiCollectionTag_; + const edm::InputTag hoDigiCollectionTag_; + const edm::InputTag hfDigiCollectionTag_; + const edm::EDGetTokenT hbheDigiCollectionToken_; + const edm::EDGetTokenT hoDigiCollectionToken_; + const edm::EDGetTokenT hfDigiCollectionToken_; + const edm::EDGetTokenT> cfToken_; + const edm::EDGetTokenT> zdccfToken_; }; HcalDigiAnalyzer::HcalDigiAnalyzer(edm::ParameterSet const &conf) @@ -112,13 +117,17 @@ HcalDigiAnalyzer::HcalDigiAnalyzer(edm::ParameterSet const &conf) zdcDigiStatistics_("ZDCDigi", 3, 10., 6., 0.1, 0.5, zdcHitAnalyzer_), hbheDigiCollectionTag_(conf.getParameter("hbheDigiCollectionTag")), hoDigiCollectionTag_(conf.getParameter("hoDigiCollectionTag")), - hfDigiCollectionTag_(conf.getParameter("hfDigiCollectionTag")) {} + hfDigiCollectionTag_(conf.getParameter("hfDigiCollectionTag")), + hbheDigiCollectionToken_(consumes(hbheDigiCollectionTag_)), + hoDigiCollectionToken_(consumes(hoDigiCollectionTag_)), + hfDigiCollectionToken_(consumes(hfDigiCollectionTag_)), + cfToken_(consumes(edm::InputTag("mix", "HcalHits"))), + zdccfToken_(consumes(edm::InputTag("mix", "ZDCHits"))) {} namespace HcalDigiAnalyzerImpl { template - void analyze(edm::Event const &e, HcalDigiStatistics &statistics, edm::InputTag &tag) { - edm::Handle digis; - e.getByLabel(tag, digis); + void analyze(edm::Event const &e, HcalDigiStatistics &statistics, const edm::EDGetTokenT &token) { + const edm::Handle& digis = e.getHandle(token); for (unsigned i = 0; i < digis->size(); ++i) { std::cout << (*digis)[i] << std::endl; statistics.analyze((*digis)[i]); @@ -128,21 +137,19 @@ namespace HcalDigiAnalyzerImpl { void HcalDigiAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { // Step A: Get Inputs - edm::Handle> cf, zdccf; - e.getByLabel("mix", "HcalHits", cf); - // e.getByLabel("mix", "ZDCHits", zdccf); + const edm::Handle>& cf = e.getHandle(cfToken_); + //const edm::Handle>& zdccf = e.getHandle(zdccfToken_); // test access to SimHits for HcalHits and ZDC hits std::unique_ptr> hits(new MixCollection(cf.product())); - // std::unique_ptr > zdcHits(new - // MixCollection(zdccf.product())); + // std::unique_ptr > zdcHits(new MixCollection(zdccf.product())); hbheHitAnalyzer_.fillHits(*hits); hoHitAnalyzer_.fillHits(*hits); hfHitAnalyzer_.fillHits(*hits); // zdcHitAnalyzer_.fillHits(*zdcHits); - HcalDigiAnalyzerImpl::analyze(e, hbheDigiStatistics_, hbheDigiCollectionTag_); - HcalDigiAnalyzerImpl::analyze(e, hoDigiStatistics_, hoDigiCollectionTag_); - HcalDigiAnalyzerImpl::analyze(e, hfDigiStatistics_, hfDigiCollectionTag_); + HcalDigiAnalyzerImpl::analyze(e, hbheDigiStatistics_, hbheDigiCollectionToken_); + HcalDigiAnalyzerImpl::analyze(e, hoDigiStatistics_, hoDigiCollectionToken_); + HcalDigiAnalyzerImpl::analyze(e, hfDigiStatistics_, hfDigiCollectionToken_); // HcalDigiAnalyzerImpl::analyze(e, zdcDigiStatistics_); } diff --git a/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc index f632dc8ff3f9a..85b7a24ca5838 100644 --- a/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc @@ -34,9 +34,14 @@ class HcalHitAnalyzer : public edm::one::EDAnalyzer<> { CaloHitAnalyzer hfAnalyzer_; CaloHitAnalyzer zdcAnalyzer_; - edm::InputTag hbheRecHitCollectionTag_; - edm::InputTag hoRecHitCollectionTag_; - edm::InputTag hfRecHitCollectionTag_; + const edm::InputTag hbheRecHitCollectionTag_; + const edm::InputTag hoRecHitCollectionTag_; + const edm::InputTag hfRecHitCollectionTag_; + const edm::EDGetTokenT hbheRecHitCollectionToken_; + const edm::EDGetTokenT hoRecHitCollectionToken_; + const edm::EDGetTokenT hfRecHitCollectionToken_; + const edm::EDGetTokenT> cfToken_; + const edm::EDGetTokenT> zdccfToken_; }; HcalHitAnalyzer::HcalHitAnalyzer(edm::ParameterSet const &conf) @@ -51,13 +56,17 @@ HcalHitAnalyzer::HcalHitAnalyzer(edm::ParameterSet const &conf) zdcAnalyzer_("ZDC", 1., &simParameterMap_, &zdcFilter_), hbheRecHitCollectionTag_(conf.getParameter("hbheRecHitCollectionTag")), hoRecHitCollectionTag_(conf.getParameter("hoRecHitCollectionTag")), - hfRecHitCollectionTag_(conf.getParameter("hfRecHitCollectionTag")) {} + hfRecHitCollectionTag_(conf.getParameter("hfRecHitCollectionTag")), + hbheRecHitCollectionToken_(consumes(hbheRecHitCollectionTag_)), + hoRecHitCollectionToken_(consumes(hoRecHitCollectionTag_)), + hfRecHitCollectionToken_(consumes(hfRecHitCollectionTag_)), + cfToken_(consumes(edm::InputTag("mix", "HcalHits"))), + zdccfToken_(consumes(edm::InputTag("mix", "ZDCHits"))) {} namespace HcalHitAnalyzerImpl { template - void analyze(edm::Event const &e, CaloHitAnalyzer &analyzer, edm::InputTag &tag) { - edm::Handle recHits; - e.getByLabel(tag, recHits); + void analyze(edm::Event const &e, CaloHitAnalyzer &analyzer, edm::EDGetTokenT const &token) { + const edm::Handle& recHits = e.getHandle(token); for (unsigned i = 0; i < recHits->size(); ++i) { analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy()); } @@ -66,21 +75,19 @@ namespace HcalHitAnalyzerImpl { void HcalHitAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { // Step A: Get Inputs - edm::Handle> cf, zdccf; - e.getByLabel("mix", "g4SimHitsHcalHits", cf); - // e.getByLabel("mix", "ZDCHits", zdccf); + const edm::Handle>& cf = e.getHandle(cfToken_); + //const edm::Handle>& zdccf = e.getHandle(zdccfToken_); // test access to SimHits for HcalHits and ZDC hits std::unique_ptr> hits(new MixCollection(cf.product())); - // std::unique_ptr > zdcHits(new - // MixCollection(zdccf.product())); + // std::unique_ptr > zdcHits(new MixCollection(zdccf.product())); hbheAnalyzer_.fillHits(*hits); // hoAnalyzer_.fillHits(*hits); // hfAnalyzer_.fillHits(*hits); // zdcAnalyzer_.fillHits(*hits); - HcalHitAnalyzerImpl::analyze(e, hbheAnalyzer_, hbheRecHitCollectionTag_); - HcalHitAnalyzerImpl::analyze(e, hoAnalyzer_, hoRecHitCollectionTag_); - HcalHitAnalyzerImpl::analyze(e, hfAnalyzer_, hfRecHitCollectionTag_); + HcalHitAnalyzerImpl::analyze(e, hbheAnalyzer_, hbheRecHitCollectionToken_); + HcalHitAnalyzerImpl::analyze(e, hoAnalyzer_, hoRecHitCollectionToken_); + HcalHitAnalyzerImpl::analyze(e, hfAnalyzer_, hfRecHitCollectionToken_); // HcalHitAnalyzerImpl::analyze(e, zdcAnalyzer_); } diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 35a0421419121..e68f7c0e22138 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -98,15 +98,14 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector deliveredLumi(0.), agingFlagHB(ps.getParameter("HBDarkening")), agingFlagHE(ps.getParameter("HEDarkening")), + zdcToken_(iC.consumes(edm::InputTag(hitsProducer_, "ZDCHITS"))), + hcalToken_(iC.consumes(edm::InputTag(hitsProducer_, "HcalHits"))), m_HBDarkening(nullptr), m_HEDarkening(nullptr), m_HFRecalibration(nullptr), injectedHitsEnergy_(ps.getParameter>("injectTestHitsEnergy")), injectedHitsTime_(ps.getParameter>("injectTestHitsTime")), injectedHitsCells_(ps.getParameter>("injectTestHitsCells")) { - iC.consumes>(edm::InputTag(hitsProducer_, "ZDCHITS")); - iC.consumes>(edm::InputTag(hitsProducer_, "HcalHits")); - if (agingFlagHB) { m_HBDarkeningToken = iC.esConsumes(edm::ESInputTag("", "HB")); } @@ -427,14 +426,10 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const void HcalDigitizer::accumulate(edm::Event const &e, edm::EventSetup const &eventSetup, CLHEP::HepRandomEngine *engine) { // Step A: Get Inputs - edm::InputTag zdcTag(hitsProducer_, "ZDCHITS"); - edm::Handle> zdcHandle; - e.getByLabel(zdcTag, zdcHandle); + const edm::Handle>& zdcHandle = e.getHandle(zdcToken_); isZDC = zdcHandle.isValid(); - edm::InputTag hcalTag(hitsProducer_, "HcalHits"); - edm::Handle> hcalHandle; - e.getByLabel(hcalTag, hcalHandle); + const edm::Handle>& hcalHandle = e.getHandle(hcalToken_); isHCAL = hcalHandle.isValid() or injectTestHits_; const HcalTopology *htopoP = &eventSetup.getData(topoToken_); From 9f1e2bd1f34d835a41f9fddd196caa49e1cf108f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Apr 2022 05:51:11 +0200 Subject: [PATCH 52/57] Code check --- SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc | 4 ++-- SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc | 4 ++-- SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc index f18bea291339f..2a2e566440bde 100644 --- a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc @@ -127,7 +127,7 @@ HcalDigiAnalyzer::HcalDigiAnalyzer(edm::ParameterSet const &conf) namespace HcalDigiAnalyzerImpl { template void analyze(edm::Event const &e, HcalDigiStatistics &statistics, const edm::EDGetTokenT &token) { - const edm::Handle& digis = e.getHandle(token); + const edm::Handle &digis = e.getHandle(token); for (unsigned i = 0; i < digis->size(); ++i) { std::cout << (*digis)[i] << std::endl; statistics.analyze((*digis)[i]); @@ -137,7 +137,7 @@ namespace HcalDigiAnalyzerImpl { void HcalDigiAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { // Step A: Get Inputs - const edm::Handle>& cf = e.getHandle(cfToken_); + const edm::Handle> &cf = e.getHandle(cfToken_); //const edm::Handle>& zdccf = e.getHandle(zdccfToken_); // test access to SimHits for HcalHits and ZDC hits diff --git a/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc index 85b7a24ca5838..69ec6c17d7084 100644 --- a/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc @@ -66,7 +66,7 @@ HcalHitAnalyzer::HcalHitAnalyzer(edm::ParameterSet const &conf) namespace HcalHitAnalyzerImpl { template void analyze(edm::Event const &e, CaloHitAnalyzer &analyzer, edm::EDGetTokenT const &token) { - const edm::Handle& recHits = e.getHandle(token); + const edm::Handle &recHits = e.getHandle(token); for (unsigned i = 0; i < recHits->size(); ++i) { analyzer.analyze((*recHits)[i].id().rawId(), (*recHits)[i].energy()); } @@ -75,7 +75,7 @@ namespace HcalHitAnalyzerImpl { void HcalHitAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { // Step A: Get Inputs - const edm::Handle>& cf = e.getHandle(cfToken_); + const edm::Handle> &cf = e.getHandle(cfToken_); //const edm::Handle>& zdccf = e.getHandle(zdccfToken_); // test access to SimHits for HcalHits and ZDC hits diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index e68f7c0e22138..a0e1350a9cb15 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -426,10 +426,10 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const void HcalDigitizer::accumulate(edm::Event const &e, edm::EventSetup const &eventSetup, CLHEP::HepRandomEngine *engine) { // Step A: Get Inputs - const edm::Handle>& zdcHandle = e.getHandle(zdcToken_); + const edm::Handle> &zdcHandle = e.getHandle(zdcToken_); isZDC = zdcHandle.isValid(); - const edm::Handle>& hcalHandle = e.getHandle(hcalToken_); + const edm::Handle> &hcalHandle = e.getHandle(hcalToken_); isHCAL = hcalHandle.isValid() or injectTestHits_; const HcalTopology *htopoP = &eventSetup.getData(topoToken_); From 501070118bbc75dc97df1cf7021ac31419b32181 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Apr 2022 10:36:56 +0200 Subject: [PATCH 53/57] replace cout with messagelogger --- .../plugins/HcalDigiAnalyzer.cc | 2 +- .../HcalSimProducers/src/HcalDigitizer.cc | 38 +++++++++---------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc index 2a2e566440bde..adda7e872add3 100644 --- a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc @@ -129,7 +129,7 @@ namespace HcalDigiAnalyzerImpl { void analyze(edm::Event const &e, HcalDigiStatistics &statistics, const edm::EDGetTokenT &token) { const edm::Handle &digis = e.getHandle(token); for (unsigned i = 0; i < digis->size(); ++i) { - std::cout << (*digis)[i] << std::endl; + edm::LogVerbatim("HcalSim") << (*digis)[i]; statistics.analyze((*digis)[i]); } } diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index a0e1350a9cb15..e578dac7a97c0 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -29,7 +29,7 @@ #include #include -//#define DebugLog +//#define EDM_ML_DEBUG HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC) : conditionsToken_(iC.esConsumes()), @@ -207,8 +207,7 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector theZDCDigitizer = std::make_unique(theZDCResponse.get(), theZDCElectronicsSim.get(), doEmpty); testNumbering_ = ps.getParameter("TestNumbering"); - // std::cout << "Flag to see if Hit Relabeller to be initiated " << - // testNumbering_ << std::endl; + // edm::LogVerbatim("HcalSim") << "Flag to see if Hit Relabeller to be initiated " << testNumbering_; if (testNumbering_) theRelabeller = std::make_unique(ps.getParameter("doNeutralDensityFilter")); @@ -368,8 +367,7 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const DetId id(hcalHitsOrig[i].id()); HcalDetId hid(id); if (!htopoP->validHcal(hid)) { - edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << " " << hid - << std::endl; + edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << " " << hid; continue; } else if (hid.subdet() == HcalForward && !doHFWindow_ && hcalHitsOrig[i].depth() != 0) { // skip HF window hits unless desired @@ -378,12 +376,12 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const // remove HE hits if asked for (phase 2) continue; } else { -#ifdef DebugLog - std::cout << "HcalDigitizer format " << hid.oldFormat() << " for " << hid << std::endl; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "HcalDigitizer format " << hid.oldFormat() << " for " << hid; #endif DetId newid = DetId(hid.newForm()); -#ifdef DebugLog - std::cout << "Hit " << i << " out of " << hcalHits.size() << " " << std::hex << id.rawId() << " --> " +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << hcalHits.size() << " " << std::hex << id.rawId() << " --> " << newid.rawId() << std::dec << " " << HcalDetId(newid.rawId()) << '\n'; #endif hcalHitsOrig[i].setID(newid.rawId()); @@ -501,14 +499,13 @@ void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSet edm::LogInfo("HcalDigitizer") << "HCAL HF QIE10 digis : " << hfQIE10Result->size(); edm::LogInfo("HcalDigitizer") << "HCAL HBHE QIE11 digis : " << hbheQIE11Result->size(); -#ifdef DebugLog - std::cout << std::endl; - std::cout << "HCAL HBHE digis : " << hbheResult->size() << std::endl; - std::cout << "HCAL HO digis : " << hoResult->size() << std::endl; - std::cout << "HCAL HF digis : " << hfResult->size() << std::endl; - std::cout << "HCAL ZDC digis : " << zdcResult->size() << std::endl; - std::cout << "HCAL HF QIE10 digis : " << hfQIE10Result->size() << std::endl; - std::cout << "HCAL HBHE QIE11 digis : " << hbheQIE11Result->size() << std::endl; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "\nHCAL HBHE digis : " << hbheResult->size(); + edm::LogVerbatim("HcalSim") << "HCAL HO digis : " << hoResult->size(); + edm::LogVerbatim("HcalSim") << "HCAL HF digis : " << hfResult->size(); + edm::LogVerbatim("HcalSim") << "HCAL ZDC digis : " << zdcResult->size(); + edm::LogVerbatim("HcalSim") << "HCAL HF QIE10 digis : " << hfQIE10Result->size(); + edm::LogVerbatim("HcalSim") << "HCAL HBHE QIE11 digis : " << hbheQIE11Result->size(); #endif // Step D: Put outputs into event @@ -552,8 +549,8 @@ void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSet e.put(std::move(pcResult), "HcalHits"); } -#ifdef DebugLog - std::cout << std::endl << "========> HcalDigitizer e.put " << std::endl << std::endl; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "\n========> HcalDigitizer e.put\n"; #endif } @@ -611,8 +608,7 @@ void HcalDigitizer::updateGeometry(const edm::EventSetup &eventSetup) { // geometry->getValidDetIds(DetId::Hcal, HcalTriggerTower); const // std::vector& hcalCalib = geometry->getValidDetIds(DetId::Calo, // HcalCastorDetId::SubdetectorId); - // std::cout<<"HcalDigitizer::CheckGeometry number of cells: - // "< Date: Thu, 28 Apr 2022 11:06:34 +0200 Subject: [PATCH 54/57] Code check --- SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index e578dac7a97c0..2858830c551ef 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -381,8 +381,8 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const #endif DetId newid = DetId(hid.newForm()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << hcalHits.size() << " " << std::hex << id.rawId() << " --> " - << newid.rawId() << std::dec << " " << HcalDetId(newid.rawId()) << '\n'; + edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << hcalHits.size() << " " << std::hex << id.rawId() + << " --> " << newid.rawId() << std::dec << " " << HcalDetId(newid.rawId()) << '\n'; #endif hcalHitsOrig[i].setID(newid.rawId()); hcalHits.push_back(hcalHitsOrig[i]); From c2022654dde7fcb757933514e86a322102ff19c3 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Apr 2022 11:37:33 +0200 Subject: [PATCH 55/57] Replace getByLabel with getHandle in SimCalorimetry/HcalTestBeam --- .../interface/HcalTBDigiProducer.h | 18 +++++--- .../HcalTestBeam/src/HcalTBDigiProducer.cc | 44 ++++++++----------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h b/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h index ace8ad1c5bf86..92bcc1119bfe8 100644 --- a/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h +++ b/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h @@ -23,6 +23,7 @@ #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h" #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h" +#include #include #include @@ -61,6 +62,9 @@ class HcalTBDigiProducer : public DigiAccumulatorMixMod { typedef CaloTDigitizer HBHEDigitizer; typedef CaloTDigitizer HODigitizer; + const double tunePhaseShift; + const std::string ecalTBInfoLabel; + HcalTBSimParameterMap *theParameterMap; HcalSimParameterMap *paraMap; CaloVShape *theHcalShape; @@ -78,24 +82,24 @@ class HcalTBDigiProducer : public DigiAccumulatorMixMod { HcalTimeSlewSim *theTimeSlewSim; - HBHEDigitizer *theHBHEDigitizer; - HODigitizer *theHODigitizer; + std::unique_ptr theHBHEDigitizer; + std::unique_ptr theHODigitizer; - edm::ESGetToken conditionsToken_; - edm::ESGetToken hcalTimeSlew_delay_token_; - edm::ESGetToken geometryToken_; + const edm::ESGetToken geometryToken_; + const edm::ESGetToken conditionsToken_; + const edm::ESGetToken hcalTimeSlew_delay_token_; edm::ESWatcher geometryWatcher_; + const edm::EDGetTokenT> hcalToken_; + edm::EDGetTokenT theEcalTBToken_; const CaloGeometry *theGeometry; std::vector hbheCells; std::vector hoCells; std::vector theHBHEHits, theHOHits; - std::string ecalTBInfoLabel; double thisPhaseShift; bool doPhaseShift; - double tunePhaseShift; CLHEP::HepRandomEngine *randomEngine_ = nullptr; }; diff --git a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc index b7339a855d9d4..e1ecf46213c8b 100644 --- a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc +++ b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc @@ -19,7 +19,9 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, edm::ProducesCollector producesCollector, edm::ConsumesCollector &iC) - : theParameterMap(new HcalTBSimParameterMap(ps)), + : tunePhaseShift(ps.getUntrackedParameter("tunePhaseShiftTB", 1.)), + ecalTBInfoLabel(ps.getUntrackedParameter("EcalTBInfoLabel", "SimEcalTBG4Object")), + theParameterMap(new HcalTBSimParameterMap(ps)), paraMap(new HcalSimParameterMap(ps)), theHcalShape(new HcalShape()), theHcalIntegratedShape(new CaloShapeIntegrator(theHcalShape)), @@ -29,17 +31,16 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, theCoderFactory(nullptr), theElectronicsSim(nullptr), theTimeSlewSim(nullptr), - theHBHEDigitizer(nullptr), - theHODigitizer(nullptr), + geometryToken_(iC.esConsumes()), conditionsToken_(iC.esConsumes()), hcalTimeSlew_delay_token_(iC.esConsumes(edm::ESInputTag("", "HBHE"))), + hcalToken_(iC.consumes>(edm::InputTag("g4SimHits", "HcalHits"))), theHBHEHits(), theHOHits(), thisPhaseShift(0) { std::string const instance("simHcalDigis"); producesCollector.produces(instance); producesCollector.produces(instance); - iC.consumes>(edm::InputTag("g4SimHits", "HcalHits")); DetId detId(DetId::Hcal, 1); bool syncPhase = (theParameterMap->simParameters(detId)).syncPhase(); @@ -65,28 +66,23 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, theAmplifier->setTimeSlewSim(theTimeSlewSim); } - theHBHEDigitizer = new HBHEDigitizer(theHBHEResponse, theElectronicsSim, doNoise); - theHODigitizer = new HODigitizer(theHOResponse, theElectronicsSim, doNoise); + theHBHEDigitizer.reset(new HBHEDigitizer(theHBHEResponse, theElectronicsSim, doNoise)); + theHODigitizer.reset(new HODigitizer(theHOResponse, theElectronicsSim, doNoise)); - tunePhaseShift = ps.getUntrackedParameter("tunePhaseShiftTB", 1.); - ecalTBInfoLabel = ps.getUntrackedParameter("EcalTBInfoLabel", "SimEcalTBG4Object"); - edm::LogInfo("HcalSim") << "HcalTBDigiProducer initialized with doNoise = " << doNoise + edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer initialized with doNoise = " << doNoise << ", doTimeSlew = " << doTimeSlew << " and doPhaseShift = " << doPhaseShift << " tunePhasShift = " << tunePhaseShift; - if (doPhaseShift) { - iC.consumes(edm::InputTag(ecalTBInfoLabel, "")); - } + if (doPhaseShift) + theEcalTBToken_ = iC.consumes(edm::InputTag(ecalTBInfoLabel, "")); } HcalTBDigiProducer::~HcalTBDigiProducer() { - if (theHBHEDigitizer) - delete theHBHEDigitizer; - if (theHODigitizer) - delete theHODigitizer; if (theParameterMap) delete theParameterMap; - if (theHcalShape) + if (paraMap) + delete paraMap; + if (theHcalShape) delete theHcalShape; if (theHcalIntegratedShape) delete theHcalIntegratedShape; @@ -120,8 +116,7 @@ void HcalTBDigiProducer::initializeEvent(edm::Event const &e, edm::EventSetup co theHBHEHits.clear(); theHOHits.clear(); if (doPhaseShift) { - edm::Handle theEcalTBInfo; - e.getByLabel(ecalTBInfoLabel, theEcalTBInfo); + const edm::Handle& theEcalTBInfo = e.getHandle(theEcalTBToken_); thisPhaseShift = theEcalTBInfo->phaseShift(); DetId detIdHB(DetId::Hcal, 1); @@ -153,8 +148,7 @@ void HcalTBDigiProducer::accumulate(edm::Event const &e, edm::EventSetup const & // Step A: Get Inputs, and accumulate digis edm::InputTag hcalTag("g4SimHits", "HcalHits"); - edm::Handle> hcalHandle; - e.getByLabel(hcalTag, hcalHandle); + const edm::Handle>& hcalHandle = e.getHandle(hcalToken_); accumulateCaloHits(hcalHandle, 0); } @@ -178,9 +172,9 @@ void HcalTBDigiProducer::finalizeEvent(edm::Event &e, const edm::EventSetup &eve LogDebug("HcalSim") << "HcalTBDigiProducer::produce Empty collection created"; // Step C: Invoke the algorithm, getting back outputs. theHBHEDigitizer->run(*hbheResult, randomEngine_); - edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HBHE digis : " << hbheResult->size(); + edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer: HBHE digis : " << hbheResult->size(); theHODigitizer->run(*hoResult, randomEngine_); - edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HO digis : " << hoResult->size(); + edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer: HO digis : " << hoResult->size(); // Step D: Put outputs into event std::string const instance("simHcalDigis"); @@ -226,8 +220,8 @@ void HcalTBDigiProducer::updateGeometry() { hoCells.clear(); hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter); - edm::LogInfo("HcalSim") << "HcalTBDigiProducer update Geometry with " << hbheCells.size() << " cells in HB/HE and " - << hoCells.size() << " cells in HO"; + edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer update Geometry with " << hbheCells.size() << " cells in HB/HE and " + << hoCells.size() << " cells in HO"; theHBHEDigitizer->setDetIds(hbheCells); LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HB/HE"; From 2fff12758ce0287850ccc341f054d18e2f3cbdbd Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Apr 2022 11:49:09 +0200 Subject: [PATCH 56/57] Code check --- .../HcalTestBeam/src/HcalTBDigiProducer.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc index e1ecf46213c8b..6c6412a83e561 100644 --- a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc +++ b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc @@ -70,8 +70,8 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, theHODigitizer.reset(new HODigitizer(theHOResponse, theElectronicsSim, doNoise)); edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer initialized with doNoise = " << doNoise - << ", doTimeSlew = " << doTimeSlew << " and doPhaseShift = " << doPhaseShift - << " tunePhasShift = " << tunePhaseShift; + << ", doTimeSlew = " << doTimeSlew << " and doPhaseShift = " << doPhaseShift + << " tunePhasShift = " << tunePhaseShift; if (doPhaseShift) theEcalTBToken_ = iC.consumes(edm::InputTag(ecalTBInfoLabel, "")); @@ -82,7 +82,7 @@ HcalTBDigiProducer::~HcalTBDigiProducer() { delete theParameterMap; if (paraMap) delete paraMap; - if (theHcalShape) + if (theHcalShape) delete theHcalShape; if (theHcalIntegratedShape) delete theHcalIntegratedShape; @@ -116,7 +116,7 @@ void HcalTBDigiProducer::initializeEvent(edm::Event const &e, edm::EventSetup co theHBHEHits.clear(); theHOHits.clear(); if (doPhaseShift) { - const edm::Handle& theEcalTBInfo = e.getHandle(theEcalTBToken_); + const edm::Handle &theEcalTBInfo = e.getHandle(theEcalTBToken_); thisPhaseShift = theEcalTBInfo->phaseShift(); DetId detIdHB(DetId::Hcal, 1); @@ -148,7 +148,7 @@ void HcalTBDigiProducer::accumulate(edm::Event const &e, edm::EventSetup const & // Step A: Get Inputs, and accumulate digis edm::InputTag hcalTag("g4SimHits", "HcalHits"); - const edm::Handle>& hcalHandle = e.getHandle(hcalToken_); + const edm::Handle> &hcalHandle = e.getHandle(hcalToken_); accumulateCaloHits(hcalHandle, 0); } @@ -220,8 +220,8 @@ void HcalTBDigiProducer::updateGeometry() { hoCells.clear(); hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter); - edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer update Geometry with " << hbheCells.size() << " cells in HB/HE and " - << hoCells.size() << " cells in HO"; + edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer update Geometry with " << hbheCells.size() + << " cells in HB/HE and " << hoCells.size() << " cells in HO"; theHBHEDigitizer->setDetIds(hbheCells); LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HB/HE"; From 162a7ed9b2f3265d46bba649c6632f2e722881d3 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Apr 2022 12:14:24 +0200 Subject: [PATCH 57/57] Code check --- SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc index 6c6412a83e561..32edfa3445876 100644 --- a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc +++ b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc @@ -1,3 +1,5 @@ +#include + #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -66,8 +68,8 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, theAmplifier->setTimeSlewSim(theTimeSlewSim); } - theHBHEDigitizer.reset(new HBHEDigitizer(theHBHEResponse, theElectronicsSim, doNoise)); - theHODigitizer.reset(new HODigitizer(theHOResponse, theElectronicsSim, doNoise)); + theHBHEDigitizer = std::make_unique(theHBHEResponse, theElectronicsSim, doNoise); + theHODigitizer = std::make_unique(theHOResponse, theElectronicsSim, doNoise); edm::LogVerbatim("HcalSim") << "HcalTBDigiProducer initialized with doNoise = " << doNoise << ", doTimeSlew = " << doTimeSlew << " and doPhaseShift = " << doPhaseShift