From 57fe6a07eb3f6c56459179524c83fb59a3538baa Mon Sep 17 00:00:00 2001 From: Breno Orzari Date: Thu, 29 Feb 2024 16:24:26 +0100 Subject: [PATCH 1/2] Adding TrackingRecHitSoA to reco namespace --- .../plugins/SiPixelCompareTrackSoAAlpaka.cc | 6 +- .../plugins/SiPixelMonitorTrackSoAAlpaka.cc | 8 +- .../TrackSoA/interface/TrackDefinitions.h | 48 +-- .../interface/alpaka/TrackUtilities.h | 298 +++++++++--------- DataFormats/TrackSoA/src/classes.cc | 6 +- DataFormats/TrackSoA/src/classes_def.xml | 12 +- .../alpaka/TrackSoAHeterogeneous_test.dev.cc | 2 +- .../interface/SiPixelHitStatus.h | 28 +- .../interface/TrackingRecHitsDevice.h | 16 +- .../interface/TrackingRecHitsHost.h | 18 +- .../interface/TrackingRecHitsSoA.h | 90 +++--- .../src/alpaka/classes_cuda_def.xml | 6 +- .../src/alpaka/classes_rocm_def.xml | 6 +- DataFormats/TrackingRecHitSoA/src/classes.cc | 6 +- .../TrackingRecHitSoA/src/classes_def.xml | 42 ++- .../test/alpaka/Hits_test.dev.cc | 10 +- .../TrackingRecHitSoA/test/alpaka/Hits_test.h | 2 +- .../interface/pixelCPEforDevice.h | 2 +- .../plugins/SiPixelRecHitFromSoAAlpaka.cc | 2 +- .../plugins/alpaka/PixelRecHitKernels.dev.cc | 2 +- .../plugins/alpaka/PixelRecHits.h | 2 +- .../src/L2TauTagNNProducerAlpaka.cc | 8 +- .../plugins/alpaka/BrokenLineFit.dev.cc | 6 +- .../PixelSeeding/plugins/alpaka/CACell.h | 6 +- .../plugins/alpaka/CAHitNtuplet.cc | 2 +- .../plugins/alpaka/CAHitNtupletGenerator.cc | 8 +- .../plugins/alpaka/CAHitNtupletGenerator.h | 10 +- .../alpaka/CAHitNtupletGeneratorKernels.h | 14 +- .../alpaka/CAHitNtupletGeneratorKernelsImpl.h | 8 +- .../plugins/alpaka/CAPixelDoubletsAlgos.h | 2 +- .../PixelSeeding/plugins/alpaka/HelixFit.h | 6 +- .../plugins/alpaka/RiemannFit.dev.cc | 6 +- .../PixelTrackProducerFromSoAAlpaka.cc | 14 +- .../plugins/alpaka/vertexFinder.dev.cc | 4 +- 34 files changed, 354 insertions(+), 352 deletions(-) diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc index 025bdfd988ea6..e49d89f2b50a8 100644 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc @@ -71,7 +71,7 @@ class SiPixelCompareTrackSoAAlpaka : public DQMEDAnalyzer { const edm::EDGetTokenT tokenSoATrackDevice_; const std::string topFolderName_; const bool useQualityCut_; - const pixelTrack::Quality minQuality_; + const reco::pixelTrack::Quality minQuality_; const float dr2cut_; MonitorElement* hnTracks_; MonitorElement* hnLooseAndAboveTracks_; @@ -118,7 +118,7 @@ SiPixelCompareTrackSoAAlpaka::SiPixelCompareTrackSoAAlpaka(const edm::Paramet tokenSoATrackDevice_(consumes(iConfig.getParameter("pixelTrackSrcDevice"))), topFolderName_(iConfig.getParameter("topFolderName")), useQualityCut_(iConfig.getParameter("useQualityCut")), - minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), + minQuality_(reco::pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), dr2cut_(iConfig.getParameter("deltaR2cut")) {} // @@ -126,7 +126,7 @@ SiPixelCompareTrackSoAAlpaka::SiPixelCompareTrackSoAAlpaka(const edm::Paramet // template void SiPixelCompareTrackSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using helper = TracksUtilities; + using helper = reco::TracksUtilities; const auto& tsoaHandleHost = iEvent.getHandle(tokenSoATrackHost_); const auto& tsoaHandleDevice = iEvent.getHandle(tokenSoATrackDevice_); if (not tsoaHandleHost or not tsoaHandleDevice) { diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoAAlpaka.cc index fd98957ee8492..e60e48267a5ba 100644 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoAAlpaka.cc +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoAAlpaka.cc @@ -39,7 +39,7 @@ class SiPixelMonitorTrackSoAAlpaka : public DQMEDAnalyzer { edm::EDGetTokenT tokenSoATrack_; std::string topFolderName_; bool useQualityCut_; - pixelTrack::Quality minQuality_; + reco::pixelTrack::Quality minQuality_; MonitorElement* hnTracks; MonitorElement* hnLooseAndAboveTracks; MonitorElement* hnHits; @@ -68,7 +68,7 @@ SiPixelMonitorTrackSoAAlpaka::SiPixelMonitorTrackSoAAlpaka(const edm::Paramet tokenSoATrack_ = consumes(iConfig.getParameter("pixelTrackSrc")); topFolderName_ = iConfig.getParameter("topFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA"; useQualityCut_ = iConfig.getParameter("useQualityCut"); - minQuality_ = pixelTrack::qualityByName(iConfig.getParameter("minQuality")); + minQuality_ = reco::pixelTrack::qualityByName(iConfig.getParameter("minQuality")); } // @@ -98,7 +98,7 @@ void SiPixelMonitorTrackSoAAlpaka::analyze(const edm::Event& iEvent, const ed continue; // fill the quality for all tracks - pixelTrack::Quality qual = quality[it]; + reco::pixelTrack::Quality qual = quality[it]; hquality->Fill(int(qual)); nTracks++; @@ -171,7 +171,7 @@ hChi2VsEta = iBook.bookProfile("nChi2ndofVsEta", fmt::format("{} vs track #eta;T htip = iBook.book1D("tip", ";Track (quality #geq loose) TIP [cm];#tracks", 100, -0.5, 0.5); hquality = iBook.book1D("quality", ";Track Quality;#tracks", 7, -0.5, 6.5); uint i = 1; - for (const auto& q : pixelTrack::qualityName) { + for (const auto& q : reco::pixelTrack::qualityName) { hquality->setBinLabel(i, q.data(), 1); i++; } diff --git a/DataFormats/TrackSoA/interface/TrackDefinitions.h b/DataFormats/TrackSoA/interface/TrackDefinitions.h index 6bd36b5bd3cd1..682f1ec72bfb8 100644 --- a/DataFormats/TrackSoA/interface/TrackDefinitions.h +++ b/DataFormats/TrackSoA/interface/TrackDefinitions.h @@ -4,29 +4,33 @@ #include #include -namespace pixelTrack { +namespace reco { - enum class Quality : uint8_t { bad = 0, edup, dup, loose, strict, tight, highPurity, notQuality }; - constexpr uint32_t qualitySize{uint8_t(Quality::notQuality)}; - constexpr std::string_view qualityName[qualitySize]{"bad", "edup", "dup", "loose", "strict", "tight", "highPurity"}; - inline Quality qualityByName(std::string_view name) { - auto qp = std::find(qualityName, qualityName + qualitySize, name) - qualityName; - auto ret = static_cast(qp); + namespace pixelTrack { + + enum class Quality : uint8_t { bad = 0, edup, dup, loose, strict, tight, highPurity, notQuality }; + constexpr uint32_t qualitySize{uint8_t(Quality::notQuality)}; + constexpr std::string_view qualityName[qualitySize]{"bad", "edup", "dup", "loose", "strict", "tight", "highPurity"}; + inline Quality qualityByName(std::string_view name) { + auto qp = std::find(qualityName, qualityName + qualitySize, name) - qualityName; + auto ret = static_cast(qp); + + if (ret == pixelTrack::Quality::notQuality) + throw std::invalid_argument(std::string(name) + " is not a pixelTrack::Quality!"); + + return ret; + } + + #ifdef GPU_SMALL_EVENTS + // kept for testing and debugging + constexpr uint32_t maxNumber() { return 2 * 1024; } + #else + // tested on MC events with 55-75 pileup events + constexpr uint32_t maxNumber() { return 32 * 1024; } + #endif + + } // namespace pixelTrack - if (ret == pixelTrack::Quality::notQuality) - throw std::invalid_argument(std::string(name) + " is not a pixelTrack::Quality!"); - - return ret; - } - -#ifdef GPU_SMALL_EVENTS - // kept for testing and debugging - constexpr uint32_t maxNumber() { return 2 * 1024; } -#else - // tested on MC events with 55-75 pileup events - constexpr uint32_t maxNumber() { return 32 * 1024; } -#endif - -} // namespace pixelTrack +} #endif diff --git a/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h b/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h index f50756f3ddbca..918a8036c852f 100644 --- a/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h +++ b/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h @@ -10,169 +10,173 @@ #include "DataFormats/TrackSoA/interface/TracksSoA.h" #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h" -// Methods that operate on View and ConstView of the TrackSoA, and cannot be class methods. -template -struct TracksUtilities { - using TrackSoAView = typename reco::TrackSoA::template Layout<>::View; - using TrackSoAConstView = typename reco::TrackSoA::template Layout<>::ConstView; - using hindex_type = typename reco::TrackSoA::hindex_type; - - // state at the beam spot: { phi, tip, 1/pt, cotan(theta), zip } - - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr void copyFromCircle( - TrackSoAView &tracks, V3 const &cp, M3 const &ccov, V2 const &lp, M2 const &lcov, float b, int32_t i) { - tracks[i].state() << cp.template cast(), lp.template cast(); - - tracks[i].state()(2) = tracks[i].state()(2) * b; - auto cov = tracks[i].covariance(); - cov(0) = ccov(0, 0); - cov(1) = ccov(0, 1); - cov(2) = b * float(ccov(0, 2)); - cov(4) = cov(3) = 0; - cov(5) = ccov(1, 1); - cov(6) = b * float(ccov(1, 2)); - cov(8) = cov(7) = 0; - cov(9) = b * b * float(ccov(2, 2)); - cov(11) = cov(10) = 0; - cov(12) = lcov(0, 0); - cov(13) = lcov(0, 1); - cov(14) = lcov(1, 1); - } - - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr void copyFromDense(TrackSoAView &tracks, - V5 const &v, - M5 const &cov, +namespace reco { + + // Methods that operate on View and ConstView of the TrackSoA, and cannot be class methods. + template + struct TracksUtilities { + using TrackSoAView = typename reco::TrackSoA::template Layout<>::View; + using TrackSoAConstView = typename reco::TrackSoA::template Layout<>::ConstView; + using hindex_type = typename reco::TrackSoA::hindex_type; + + // state at the beam spot: { phi, tip, 1/pt, cotan(theta), zip } + + template + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr void copyFromCircle( + TrackSoAView &tracks, V3 const &cp, M3 const &ccov, V2 const &lp, M2 const &lcov, float b, int32_t i) { + tracks[i].state() << cp.template cast(), lp.template cast(); + + tracks[i].state()(2) = tracks[i].state()(2) * b; + auto cov = tracks[i].covariance(); + cov(0) = ccov(0, 0); + cov(1) = ccov(0, 1); + cov(2) = b * float(ccov(0, 2)); + cov(4) = cov(3) = 0; + cov(5) = ccov(1, 1); + cov(6) = b * float(ccov(1, 2)); + cov(8) = cov(7) = 0; + cov(9) = b * b * float(ccov(2, 2)); + cov(11) = cov(10) = 0; + cov(12) = lcov(0, 0); + cov(13) = lcov(0, 1); + cov(14) = lcov(1, 1); + } + + template + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr void copyFromDense(TrackSoAView &tracks, + V5 const &v, + M5 const &cov, + int32_t i) { + tracks[i].state() = v.template cast(); + for (int j = 0, ind = 0; j < 5; ++j) + for (auto k = j; k < 5; ++k) + tracks[i].covariance()(ind++) = cov(j, k); + } + + template + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr void copyToDense(const TrackSoAConstView &tracks, + V5 &v, + M5 &cov, int32_t i) { - tracks[i].state() = v.template cast(); - for (int j = 0, ind = 0; j < 5; ++j) - for (auto k = j; k < 5; ++k) - tracks[i].covariance()(ind++) = cov(j, k); - } - - template - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr void copyToDense(const TrackSoAConstView &tracks, - V5 &v, - M5 &cov, - int32_t i) { - v = tracks[i].state().template cast(); - for (int j = 0, ind = 0; j < 5; ++j) { - cov(j, j) = tracks[i].covariance()(ind++); - for (auto k = j + 1; k < 5; ++k) - cov(k, j) = cov(j, k) = tracks[i].covariance()(ind++); + v = tracks[i].state().template cast(); + for (int j = 0, ind = 0; j < 5; ++j) { + cov(j, j) = tracks[i].covariance()(ind++); + for (auto k = j + 1; k < 5; ++k) + cov(k, j) = cov(j, k) = tracks[i].covariance()(ind++); + } } - } - - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr int computeNumberOfLayers(const TrackSoAConstView &tracks, - int32_t i) { - auto pdet = tracks.detIndices().begin(i); - int nl = 1; - auto ol = pixelTopology::getLayer(*pdet); - for (; pdet < tracks.detIndices().end(i); ++pdet) { - auto il = pixelTopology::getLayer(*pdet); - if (il != ol) - ++nl; - ol = il; + + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr int computeNumberOfLayers(const TrackSoAConstView &tracks, + int32_t i) { + auto pdet = tracks.detIndices().begin(i); + int nl = 1; + auto ol = pixelTopology::getLayer(*pdet); + for (; pdet < tracks.detIndices().end(i); ++pdet) { + auto il = pixelTopology::getLayer(*pdet); + if (il != ol) + ++nl; + ol = il; + } + return nl; } - return nl; - } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr int nHits(const TrackSoAConstView &tracks, int i) { - return tracks.detIndices().size(i); - } -}; + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr int nHits(const TrackSoAConstView &tracks, int i) { + return tracks.detIndices().size(i); + } + }; -namespace pixelTrack { + namespace pixelTrack { - template - struct QualityCutsT {}; + template + struct QualityCutsT {}; - template - struct QualityCutsT> { - using TrackSoAView = typename reco::TrackSoA::template Layout<>::View; - using TrackSoAConstView = typename reco::TrackSoA::template Layout<>::ConstView; - float chi2Coeff[4]; - float chi2MaxPt; // GeV - float chi2Scale; - - struct Region { - float maxTip; // cm - float minPt; // GeV - float maxZip; // cm - }; + template + struct QualityCutsT> { + using TrackSoAView = typename reco::TrackSoA::template Layout<>::View; + using TrackSoAConstView = typename reco::TrackSoA::template Layout<>::ConstView; + float chi2Coeff[4]; + float chi2MaxPt; // GeV + float chi2Scale; - Region triplet; - Region quadruplet; - - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isHP(const TrackSoAConstView &tracks, int nHits, int it) const { - // impose "region cuts" based on the fit results (phi, Tip, pt, cotan(theta)), Zip) - // default cuts: - // - for triplets: |Tip| < 0.3 cm, pT > 0.5 GeV, |Zip| < 12.0 cm - // - for quadruplets: |Tip| < 0.5 cm, pT > 0.3 GeV, |Zip| < 12.0 cm - // (see CAHitNtupletGeneratorGPU.cc) - auto const ®ion = (nHits > 3) ? quadruplet : triplet; - return (std::abs(reco::tip(tracks, it)) < region.maxTip) and (tracks.pt(it) > region.minPt) and - (std::abs(reco::zip(tracks, it)) < region.maxZip); - } + struct Region { + float maxTip; // cm + float minPt; // GeV + float maxZip; // cm + }; + + Region triplet; + Region quadruplet; + + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isHP(const TrackSoAConstView &tracks, int nHits, int it) const { + // impose "region cuts" based on the fit results (phi, Tip, pt, cotan(theta)), Zip) + // default cuts: + // - for triplets: |Tip| < 0.3 cm, pT > 0.5 GeV, |Zip| < 12.0 cm + // - for quadruplets: |Tip| < 0.5 cm, pT > 0.3 GeV, |Zip| < 12.0 cm + // (see CAHitNtupletGeneratorGPU.cc) + auto const ®ion = (nHits > 3) ? quadruplet : triplet; + return (std::abs(reco::tip(tracks, it)) < region.maxTip) and (tracks.pt(it) > region.minPt) and + (std::abs(reco::zip(tracks, it)) < region.maxZip); + } - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool strictCut(const TrackSoAConstView &tracks, int it) const { - auto roughLog = [](float x) { - // max diff [0.5,12] at 1.25 0.16143 - // average diff 0.0662998 - union IF { - uint32_t i; - float f; + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool strictCut(const TrackSoAConstView &tracks, int it) const { + auto roughLog = [](float x) { + // max diff [0.5,12] at 1.25 0.16143 + // average diff 0.0662998 + union IF { + uint32_t i; + float f; + }; + IF z; + z.f = x; + uint32_t lsb = 1 < 21; + z.i += lsb; + z.i >>= 21; + auto f = z.i & 3; + int ex = int(z.i >> 2) - 127; + + // log2(1+0.25*f) + // averaged over bins + const float frac[4] = {0.160497f, 0.452172f, 0.694562f, 0.901964f}; + return float(ex) + frac[f]; }; - IF z; - z.f = x; - uint32_t lsb = 1 < 21; - z.i += lsb; - z.i >>= 21; - auto f = z.i & 3; - int ex = int(z.i >> 2) - 127; - - // log2(1+0.25*f) - // averaged over bins - const float frac[4] = {0.160497f, 0.452172f, 0.694562f, 0.901964f}; - return float(ex) + frac[f]; - }; - float pt = std::min(tracks.pt(it), chi2MaxPt); - float chi2Cut = chi2Scale * (chi2Coeff[0] + roughLog(pt) * chi2Coeff[1]); - if (tracks.chi2(it) >= chi2Cut) { -#ifdef NTUPLE_FIT_DEBUG - printf("Bad chi2 %d pt %f eta %f chi2 %f\n", it, tracks.pt(it), tracks.eta(it), tracks.chi2(it)); -#endif - return true; + float pt = std::min(tracks.pt(it), chi2MaxPt); + float chi2Cut = chi2Scale * (chi2Coeff[0] + roughLog(pt) * chi2Coeff[1]); + if (tracks.chi2(it) >= chi2Cut) { + #ifdef NTUPLE_FIT_DEBUG + printf("Bad chi2 %d pt %f eta %f chi2 %f\n", it, tracks.pt(it), tracks.eta(it), tracks.chi2(it)); + #endif + return true; + } + return false; } - return false; - } - }; + }; - template - struct QualityCutsT> { - using TrackSoAView = typename reco::TrackSoA::template Layout<>::View; - using TrackSoAConstView = typename reco::TrackSoA::template Layout<>::ConstView; + template + struct QualityCutsT> { + using TrackSoAView = typename reco::TrackSoA::template Layout<>::View; + using TrackSoAConstView = typename reco::TrackSoA::template Layout<>::ConstView; - float maxChi2; - float minPt; - float maxTip; - float maxZip; + float maxChi2; + float minPt; + float maxTip; + float maxZip; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isHP(const TrackSoAConstView &tracks, int nHits, int it) const { - return (std::abs(reco::tip(tracks, it)) < maxTip) and (tracks.pt(it) > minPt) and - (std::abs(reco::zip(tracks, it)) < maxZip); - } - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool strictCut(const TrackSoAConstView &tracks, int it) const { - return tracks.chi2(it) >= maxChi2; - } - }; + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool isHP(const TrackSoAConstView &tracks, int nHits, int it) const { + return (std::abs(reco::tip(tracks, it)) < maxTip) and (tracks.pt(it) > minPt) and + (std::abs(reco::zip(tracks, it)) < maxZip); + } + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool strictCut(const TrackSoAConstView &tracks, int it) const { + return tracks.chi2(it) >= maxChi2; + } + }; + + } // namespace pixelTrack -} // namespace pixelTrack + // TODO: Should those be placed in the ALPAKA_ACCELERATOR_NAMESPACE + template struct TracksUtilities; + template struct TracksUtilities; -// TODO: Should those be placed in the ALPAKA_ACCELERATOR_NAMESPACE -template struct TracksUtilities; -template struct TracksUtilities; +} #endif // DataFormats_TrackSoA_interface_alpaka_TrackUtilities_h diff --git a/DataFormats/TrackSoA/src/classes.cc b/DataFormats/TrackSoA/src/classes.cc index 97e00cc5b5638..9e572b5fa44a6 100644 --- a/DataFormats/TrackSoA/src/classes.cc +++ b/DataFormats/TrackSoA/src/classes.cc @@ -2,8 +2,6 @@ #include "DataFormats/TrackSoA/interface/TracksSoA.h" #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h" -using namespace reco; - -SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); -SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); +SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); +SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); // SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); //TODO: For the moment we live without HIons diff --git a/DataFormats/TrackSoA/src/classes_def.xml b/DataFormats/TrackSoA/src/classes_def.xml index 5ae5fbf55cd8f..dcbe554334b93 100644 --- a/DataFormats/TrackSoA/src/classes_def.xml +++ b/DataFormats/TrackSoA/src/classes_def.xml @@ -5,9 +5,7 @@ - - - + @@ -16,9 +14,7 @@ - - - + @@ -27,8 +23,6 @@ - - - + diff --git a/DataFormats/TrackSoA/test/alpaka/TrackSoAHeterogeneous_test.dev.cc b/DataFormats/TrackSoA/test/alpaka/TrackSoAHeterogeneous_test.dev.cc index 4d443e93cab4e..e3bc78c35f29b 100644 --- a/DataFormats/TrackSoA/test/alpaka/TrackSoAHeterogeneous_test.dev.cc +++ b/DataFormats/TrackSoA/test/alpaka/TrackSoAHeterogeneous_test.dev.cc @@ -13,7 +13,7 @@ using namespace reco; -using Quality = pixelTrack::Quality; +using Quality = reco::pixelTrack::Quality; namespace ALPAKA_ACCELERATOR_NAMESPACE { using namespace cms::alpakatools; namespace testTrackSoA { diff --git a/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h b/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h index 06205906d8d2f..ea1ec138a36a3 100644 --- a/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h +++ b/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h @@ -3,18 +3,22 @@ #include -// more information on bit fields : https://en.cppreference.com/w/cpp/language/bit_field -struct SiPixelHitStatus { - bool isBigX : 1; // ∈[0,1] - bool isOneX : 1; // ∈[0,1] - bool isBigY : 1; // ∈[0,1] - bool isOneY : 1; // ∈[0,1] - uint8_t qBin : 3; // ∈[0,1,...,7] -}; +namespace reco{ -struct SiPixelHitStatusAndCharge { - SiPixelHitStatus status; - uint32_t charge : 24; -}; + // more information on bit fields : https://en.cppreference.com/w/cpp/language/bit_field + struct SiPixelHitStatus { + bool isBigX : 1; // ∈[0,1] + bool isOneX : 1; // ∈[0,1] + bool isBigY : 1; // ∈[0,1] + bool isOneY : 1; // ∈[0,1] + uint8_t qBin : 3; // ∈[0,1,...,7] + }; + + struct SiPixelHitStatusAndCharge { + SiPixelHitStatus status; + uint32_t charge : 24; + }; + +} #endif diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h index 7a0104dc899cb..4b6fdb72b17df 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h @@ -10,21 +10,21 @@ #include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" template -class TrackingRecHitDevice : public PortableDeviceCollection, TDev> { +class TrackingRecHitDevice : public PortableDeviceCollection, TDev> { public: - using hitSoA = TrackingRecHitSoA; - - // Need to decorate the class with the inherited portable accessors being now a template - using PortableDeviceCollection, TDev>::view; - using PortableDeviceCollection, TDev>::const_view; - using PortableDeviceCollection, TDev>::buffer; + using hitSoA = reco::TrackingRecHitSoA; + + //Need to decorate the class with the inherited portable accessors being now a template + using PortableDeviceCollection, TDev>::view; + using PortableDeviceCollection, TDev>::const_view; + using PortableDeviceCollection, TDev>::buffer; TrackingRecHitDevice() = default; // Constructor which specifies the SoA size, number of BPIX1 hits, and the modules entry points template explicit TrackingRecHitDevice(TQueue queue, uint32_t nHits, int32_t offsetBPIX2, uint32_t const* hitsModuleStart) - : PortableDeviceCollection, TDev>(nHits, queue), offsetBPIX2_{offsetBPIX2} { + : PortableDeviceCollection, TDev>(nHits, queue), offsetBPIX2_{offsetBPIX2} { const auto device = alpaka::getDev(queue); auto start_h = cms::alpakatools::make_host_view(hitsModuleStart, TrackerTraits::numberOfModules + 1); diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h index e7212ce9a6252..43ab79ec72c3f 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h @@ -10,26 +10,26 @@ #include "HeterogeneousCore/AlpakaInterface/interface/config.h" template -class TrackingRecHitHost : public PortableHostCollection> { +class TrackingRecHitHost : public PortableHostCollection> { public: - using hitSoA = TrackingRecHitSoA; - - // Need to decorate the class with the inherited portable accessors being now a template - using PortableHostCollection>::view; - using PortableHostCollection>::const_view; - using PortableHostCollection>::buffer; + using hitSoA = reco::TrackingRecHitSoA; + + //Need to decorate the class with the inherited portable accessors being now a template + using PortableHostCollection>::view; + using PortableHostCollection>::const_view; + using PortableHostCollection>::buffer; TrackingRecHitHost() = default; // Constructor which specifies only the SoA size, to be used when copying the results from the device to the host template explicit TrackingRecHitHost(TQueue queue, uint32_t nHits) - : PortableHostCollection>(nHits, queue) {} + : PortableHostCollection>(nHits, queue) {} // Constructor which specifies the SoA size, number of BPIX1 hits, and the modules entry points template explicit TrackingRecHitHost(TQueue queue, uint32_t nHits, int32_t offsetBPIX2, uint32_t const* hitsModuleStart) - : PortableHostCollection>(nHits, queue) { + : PortableHostCollection>(nHits, queue) { std::copy(hitsModuleStart, hitsModuleStart + TrackerTraits::numberOfModules + 1, view().hitsModuleStart().data()); view().offsetBPIX2() = offsetBPIX2; } diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h index 7e45a75043951..2b0e6154d43cb 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h @@ -8,48 +8,52 @@ #include "HeterogeneousCore/AlpakaInterface/interface/HistoContainer.h" #include "RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h" -template -struct TrackingRecHitSoA { - using hindex_type = typename TrackerTraits::hindex_type; - using PhiBinner = cms::alpakatools::HistoContainer; //28 for phase2 geometry - using PhiBinnerView = typename PhiBinner::View; - using PhiBinnerStorageType = typename PhiBinner::index_type; - using AverageGeometry = pixelTopology::AverageGeometryT; - using HitLayerStartArray = std::array; - using HitModuleStartArray = std::array; - - GENERATE_SOA_LAYOUT(Layout, - SOA_COLUMN(float, xLocal), - SOA_COLUMN(float, yLocal), - SOA_COLUMN(float, xerrLocal), - SOA_COLUMN(float, yerrLocal), - SOA_COLUMN(float, xGlobal), - SOA_COLUMN(float, yGlobal), - SOA_COLUMN(float, zGlobal), - SOA_COLUMN(float, rGlobal), - SOA_COLUMN(int16_t, iphi), - SOA_COLUMN(SiPixelHitStatusAndCharge, chargeAndStatus), - SOA_COLUMN(int16_t, clusterSizeX), - SOA_COLUMN(int16_t, clusterSizeY), - SOA_COLUMN(uint16_t, detectorIndex), - SOA_SCALAR(int32_t, offsetBPIX2), - SOA_COLUMN(PhiBinnerStorageType, phiBinnerStorage), - SOA_SCALAR(HitModuleStartArray, hitsModuleStart), - SOA_SCALAR(HitLayerStartArray, hitsLayerStart), - SOA_SCALAR(AverageGeometry, averageGeometry), - SOA_SCALAR(PhiBinner, phiBinner)); -}; - -template -using TrackingRecHitLayout = typename TrackingRecHitSoA::template Layout<>; -template -using TrackingRecHitSoAView = typename TrackingRecHitSoA::template Layout<>::View; -template -using TrackingRecHitSoAConstView = typename TrackingRecHitSoA::template Layout<>::ConstView; +namespace reco { + + template + struct TrackingRecHitSoA { + using hindex_type = typename TrackerTraits::hindex_type; + using PhiBinner = cms::alpakatools::HistoContainer; //28 for phase2 geometry + using PhiBinnerView = typename PhiBinner::View; + using PhiBinnerStorageType = typename PhiBinner::index_type; + using AverageGeometry = pixelTopology::AverageGeometryT; + using HitLayerStartArray = std::array; + using HitModuleStartArray = std::array; + + GENERATE_SOA_LAYOUT(Layout, + SOA_COLUMN(float, xLocal), + SOA_COLUMN(float, yLocal), + SOA_COLUMN(float, xerrLocal), + SOA_COLUMN(float, yerrLocal), + SOA_COLUMN(float, xGlobal), + SOA_COLUMN(float, yGlobal), + SOA_COLUMN(float, zGlobal), + SOA_COLUMN(float, rGlobal), + SOA_COLUMN(int16_t, iphi), + SOA_COLUMN(reco::SiPixelHitStatusAndCharge, chargeAndStatus), + SOA_COLUMN(int16_t, clusterSizeX), + SOA_COLUMN(int16_t, clusterSizeY), + SOA_COLUMN(uint16_t, detectorIndex), + SOA_SCALAR(int32_t, offsetBPIX2), + SOA_COLUMN(PhiBinnerStorageType, phiBinnerStorage), + SOA_SCALAR(HitModuleStartArray, hitsModuleStart), + SOA_SCALAR(HitLayerStartArray, hitsLayerStart), + SOA_SCALAR(AverageGeometry, averageGeometry), + SOA_SCALAR(PhiBinner, phiBinner)); + }; + + template + using TrackingRecHitLayout = typename TrackingRecHitSoA::template Layout<>; + template + using TrackingRecHitSoAView = typename TrackingRecHitSoA::template Layout<>::View; + template + using TrackingRecHitSoAConstView = typename TrackingRecHitSoA::template Layout<>::ConstView; + +} #endif diff --git a/DataFormats/TrackingRecHitSoA/src/alpaka/classes_cuda_def.xml b/DataFormats/TrackingRecHitSoA/src/alpaka/classes_cuda_def.xml index 80c267b57d585..d3279d635526e 100644 --- a/DataFormats/TrackingRecHitSoA/src/alpaka/classes_cuda_def.xml +++ b/DataFormats/TrackingRecHitSoA/src/alpaka/classes_cuda_def.xml @@ -1,15 +1,15 @@ - + - + - + diff --git a/DataFormats/TrackingRecHitSoA/src/alpaka/classes_rocm_def.xml b/DataFormats/TrackingRecHitSoA/src/alpaka/classes_rocm_def.xml index bc4c969137121..636b977b18670 100644 --- a/DataFormats/TrackingRecHitSoA/src/alpaka/classes_rocm_def.xml +++ b/DataFormats/TrackingRecHitSoA/src/alpaka/classes_rocm_def.xml @@ -1,15 +1,15 @@ - + - + - + diff --git a/DataFormats/TrackingRecHitSoA/src/classes.cc b/DataFormats/TrackingRecHitSoA/src/classes.cc index bbcc923b04373..375dfbf2d1b4f 100644 --- a/DataFormats/TrackingRecHitSoA/src/classes.cc +++ b/DataFormats/TrackingRecHitSoA/src/classes.cc @@ -2,6 +2,6 @@ #include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h" -SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); -SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); -SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); +SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); +SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); +SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection>); diff --git a/DataFormats/TrackingRecHitSoA/src/classes_def.xml b/DataFormats/TrackingRecHitSoA/src/classes_def.xml index f3107e8587327..6b9243626476f 100644 --- a/DataFormats/TrackingRecHitSoA/src/classes_def.xml +++ b/DataFormats/TrackingRecHitSoA/src/classes_def.xml @@ -1,34 +1,28 @@ - - - - + + + + - - - - + + - - - - + + + + - - - - + + - - - - + + + + - - - - + + diff --git a/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc b/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc index 2123c7968f664..b0032dfc97e1f 100644 --- a/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc +++ b/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc @@ -21,7 +21,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template struct TestFillKernel { template >> - ALPAKA_FN_ACC void operator()(TAcc const& acc, TrackingRecHitSoAView soa) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, reco::TrackingRecHitSoAView soa) const { const uint32_t i(alpaka::getIdx(acc)[0u]); const uint32_t j(alpaka::getIdx(acc)[0u]); @@ -38,7 +38,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template struct ShowKernel { template >> - ALPAKA_FN_ACC void operator()(TAcc const& acc, TrackingRecHitSoAConstView soa) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, reco::TrackingRecHitSoAConstView soa) const { if (cms::alpakatools::once_per_grid(acc)) { printf("nbins = %d\n", soa.phiBinner().nbins()); printf("offsetBPIX = %d\n", soa.offsetBPIX2()); @@ -54,7 +54,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { }; template - void runKernels(TrackingRecHitSoAView& view, Queue& queue) { + void runKernels(reco::TrackingRecHitSoAView& view, Queue& queue) { uint32_t items = 64; uint32_t groups = divide_up_by(view.metadata().size(), items); auto workDiv = make_workdiv(groups, items); @@ -62,8 +62,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { alpaka::exec(queue, workDiv, ShowKernel{}, view); } - template void runKernels(TrackingRecHitSoAView& view, Queue& queue); - template void runKernels(TrackingRecHitSoAView& view, Queue& queue); + template void runKernels(reco::TrackingRecHitSoAView& view, Queue& queue); + template void runKernels(reco::TrackingRecHitSoAView& view, Queue& queue); } // namespace testTrackingRecHitSoA } // namespace ALPAKA_ACCELERATOR_NAMESPACE diff --git a/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.h b/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.h index fcc0d8e80d589..485c284575a42 100644 --- a/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.h +++ b/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.h @@ -7,7 +7,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::testTrackingRecHitSoA { template - void runKernels(TrackingRecHitSoAView& hits, Queue& queue); + void runKernels(reco::TrackingRecHitSoAView& hits, Queue& queue); } // namespace ALPAKA_ACCELERATOR_NAMESPACE::testTrackingRecHitSoA diff --git a/RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h b/RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h index ac99af3146904..94856ebf7a199 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h @@ -25,7 +25,7 @@ namespace pixelCPEforDevice { constexpr float micronsToCm = 1.0e-4f; - using Status = SiPixelHitStatus; + using Status = reco::SiPixelHitStatus; using Frame = SOAFrame; using Rotation = SOARotation; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelRecHitFromSoAAlpaka.cc b/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelRecHitFromSoAAlpaka.cc index a76ff6af49ac9..9c6fd869a2347 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelRecHitFromSoAAlpaka.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelRecHitFromSoAAlpaka.cc @@ -23,7 +23,7 @@ template class SiPixelRecHitFromSoAAlpaka : public edm::global::EDProducer<> { - using HitModuleStartArray = typename TrackingRecHitSoA::HitModuleStartArray; + using HitModuleStartArray = typename reco::TrackingRecHitSoA::HitModuleStartArray; using hindex_type = typename TrackerTraits::hindex_type; using HMSstorage = typename std::vector; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc index 5b6d1133a77bb..915fc6fa59b44 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHitKernels.dev.cc @@ -106,7 +106,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { // Use a view since it's runtime sized and can't use the implicit definition // see HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h:100 - typename TrackingRecHitSoA::PhiBinnerView hrv_d; + typename reco::TrackingRecHitSoA::PhiBinnerView hrv_d; hrv_d.assoc = &(hits_d.view().phiBinner()); hrv_d.offSize = -1; hrv_d.offStorage = nullptr; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h index aacdeb79a2749..6fb1786e1bb4b 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h +++ b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/PixelRecHits.h @@ -37,7 +37,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { uint32_t numElements, uint32_t nonEmptyModules, SiPixelClustersSoAConstView clusters, - TrackingRecHitSoAView hits) const { + reco::TrackingRecHitSoAView hits) const { ALPAKA_ASSERT_ACC(cpeParams); // outer loop: one block per module diff --git a/RecoTauTag/HLTProducers/src/L2TauTagNNProducerAlpaka.cc b/RecoTauTag/HLTProducers/src/L2TauTagNNProducerAlpaka.cc index 9772366c6b22e..fe1386c4d1b22 100644 --- a/RecoTauTag/HLTProducers/src/L2TauTagNNProducerAlpaka.cc +++ b/RecoTauTag/HLTProducers/src/L2TauTagNNProducerAlpaka.cc @@ -577,7 +577,7 @@ void L2TauNNProducerAlpaka::selectGoodTracksAndVertices(const ZVertexHost& patav const TracksHost& patatracks_tsoa, std::vector& trkGood, std::vector& vtxGood) { - using patatrackHelpers = TracksUtilities; + using patatrackHelpers = reco::TracksUtilities; const auto maxTracks = patatracks_tsoa.view().metadata().size(); const int nv = patavtx_soa.view().nvFinal(); trkGood.clear(); @@ -604,7 +604,7 @@ void L2TauNNProducerAlpaka::selectGoodTracksAndVertices(const ZVertexHost& patav pTSquaredSum[vtx_ass_to_track] += patatrackPt * patatrackPt; } } - if (nHits > 0 and quality[trk_idx] >= pixelTrack::Quality::loose) { + if (nHits > 0 and quality[trk_idx] >= reco::pixelTrack::Quality::loose) { trkGood.push_back(trk_idx); } } @@ -629,7 +629,7 @@ std::pair L2TauNNProducerAlpaka::impactParameter(int it, /* dxy and dz */ riemannFit::Vector5d ipar, opar; riemannFit::Matrix5d icov, ocov; - TracksUtilities::copyToDense(patatracks_tsoa.view(), ipar, icov, it); + reco::TracksUtilities::copyToDense(patatracks_tsoa.view(), ipar, icov, it); riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov); LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.); float sp = std::sin(patatrackPhi); @@ -659,7 +659,7 @@ void L2TauNNProducerAlpaka::fillPatatracks(tensorflow::Tensor& cellGridMatrix, const reco::BeamSpot& beamspot, const MagneticField* magfi) { using NNInputs = L2TauTagNNv1::NNInputs; - using patatrackHelpers = TracksUtilities; + using patatrackHelpers = reco::TracksUtilities; float deta, dphi; int eta_idx = 0; int phi_idx = 0; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/BrokenLineFit.dev.cc b/RecoTracker/PixelSeeding/plugins/alpaka/BrokenLineFit.dev.cc index aaf83bbc2e097..33f8f08e47417 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/BrokenLineFit.dev.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/BrokenLineFit.dev.cc @@ -30,7 +30,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { ALPAKA_FN_ACC void operator()(TAcc const &acc, Tuples const *__restrict__ foundNtuplets, TupleMultiplicity const *__restrict__ tupleMultiplicity, - TrackingRecHitSoAConstView hh, + reco::TrackingRecHitSoAConstView hh, pixelCPEforDevice::ParamsOnDeviceT const *__restrict__ cpeParams, typename TrackerTraits::tindex_type *__restrict__ ptkids, double *__restrict__ phits, @@ -210,7 +210,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { brokenline::lineFit(acc, hits_ge, fast_fit, bField, data, line); brokenline::circleFit(acc, hits, hits_ge, fast_fit, bField, data, circle); - TracksUtilities::copyFromCircle( + reco::TracksUtilities::copyFromCircle( results_view, circle.par, circle.cov, line.par, line.cov, 1.f / float(bField), tkid); results_view[tkid].pt() = float(bField) / float(std::abs(circle.par(2))); results_view[tkid].eta() = alpaka::math::asinh(acc, line.par(0)); @@ -242,7 +242,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template void HelixFit::launchBrokenLineKernels( - const TrackingRecHitSoAConstView &hv, + const reco::TrackingRecHitSoAConstView &hv, pixelCPEforDevice::ParamsOnDeviceT const *cpeParams, uint32_t hitsInFit, uint32_t maxNumberOfTuples, diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h b/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h index d8af548109d29..49814cd0e65e4 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CACell.h @@ -33,7 +33,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { using CellNeighborsVector = caStructures::CellNeighborsVectorT; using CellTracksVector = caStructures::CellTracksVectorT; - using HitsConstView = TrackingRecHitSoAConstView; + using HitsConstView = reco::TrackingRecHitSoAConstView; using hindex_type = typename TrackerTraits::hindex_type; using tindex_type = typename TrackerTraits::tindex_type; static constexpr auto invalidHitId = std::numeric_limits::max(); @@ -41,8 +41,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { using TmpTuple = cms::alpakatools::VecArray; using HitContainer = typename reco::TrackSoA::HitContainer; - using Quality = ::pixelTrack::Quality; - static constexpr auto bad = ::pixelTrack::Quality::bad; + using Quality = ::reco::pixelTrack::Quality; + static constexpr auto bad = ::reco::pixelTrack::Quality::bad; enum class StatusBit : uint16_t { kUsed = 1, kInTrack = 2, kKilled = 1 << 15 }; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc index c16aed2e0b1e8..73a4b6d8b94ca 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc @@ -28,7 +28,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template class CAHitNtupletAlpaka : public stream::EDProducer<> { - using HitsConstView = TrackingRecHitSoAConstView; + using HitsConstView = reco::TrackingRecHitSoAConstView; using HitsOnDevice = TrackingRecHitsSoACollection; using HitsOnHost = TrackingRecHitHost; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc index c6615c08d73bf..44708f4558428 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc @@ -93,12 +93,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { (float)cfg.getParameter("dcaCutOuterTriplet")}}; }; - static constexpr ::pixelTrack::QualityCutsT makeQualityCuts(edm::ParameterSet const& pset) { + static constexpr ::reco::pixelTrack::QualityCutsT makeQualityCuts(edm::ParameterSet const& pset) { auto coeff = pset.getParameter>("chi2Coeff"); auto ptMax = pset.getParameter("chi2MaxPt"); coeff[1] = (coeff[1] - coeff[0]) / log2(ptMax); - return ::pixelTrack::QualityCutsT{// polynomial coefficients for the pT-dependent chi2 cut + return ::reco::pixelTrack::QualityCutsT{// polynomial coefficients for the pT-dependent chi2 cut {(float)coeff[0], (float)coeff[1], 0.f, 0.f}, // max pT used to determine the chi2 cut (float)ptMax, @@ -129,8 +129,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { {(bool)cfg.getParameter("includeFarForwards")}}; } - static constexpr ::pixelTrack::QualityCutsT makeQualityCuts(edm::ParameterSet const& pset) { - return ::pixelTrack::QualityCutsT{ + static constexpr ::reco::pixelTrack::QualityCutsT makeQualityCuts(edm::ParameterSet const& pset) { + return ::reco::pixelTrack::QualityCutsT{ static_cast(pset.getParameter("maxChi2")), static_cast(pset.getParameter("minPt")), static_cast(pset.getParameter("maxTip")), diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.h b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.h index ec3273a89dee6..60e9b9d8aeecc 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.h @@ -27,11 +27,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template class CAHitNtupletGenerator { public: - using HitsView = TrackingRecHitSoAView; - using HitsConstView = TrackingRecHitSoAConstView; + using HitsView = reco::TrackingRecHitSoAView; + using HitsConstView = reco::TrackingRecHitSoAConstView; using HitsOnDevice = TrackingRecHitsSoACollection; using HitsOnHost = TrackingRecHitHost; - using hindex_type = typename TrackingRecHitSoA::hindex_type; + using hindex_type = typename reco::TrackingRecHitSoA::hindex_type; using HitToTuple = caStructures::HitToTupleT; using TupleMultiplicity = caStructures::TupleMultiplicityT; @@ -46,9 +46,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { using CellNeighborsVector = caStructures::CellNeighborsVectorT; using CellTracksVector = caStructures::CellTracksVectorT; - using Quality = ::pixelTrack::Quality; + using Quality = ::reco::pixelTrack::Quality; - using QualityCuts = ::pixelTrack::QualityCutsT; + using QualityCuts = ::reco::pixelTrack::QualityCutsT; using Params = caHitNtupletGenerator::ParamsT; using Counters = caHitNtupletGenerator::Counters; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h index ecf8e00c454ab..b3532795936c8 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h @@ -98,7 +98,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template struct ParamsT> : public AlgoParams { using TT = TrackerTraits; - using QualityCuts = ::pixelTrack::QualityCutsT; //track quality cuts + using QualityCuts = ::reco::pixelTrack::QualityCutsT; //track quality cuts using CellCuts = caPixelDoublets::CellCutsT; //cell building cuts using CAParams = CAParamsT; //params to be used on device @@ -149,7 +149,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template struct ParamsT> : public AlgoParams { using TT = TrackerTraits; - using QualityCuts = ::pixelTrack::QualityCutsT; + using QualityCuts = ::reco::pixelTrack::QualityCutsT; using CellCuts = caPixelDoublets::CellCutsT; using CAParams = CAParamsT; @@ -198,7 +198,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { unsigned long long nZeroTrackCells; }; - using Quality = ::pixelTrack::Quality; + using Quality = ::reco::pixelTrack::Quality; } // namespace caHitNtupletGenerator @@ -206,14 +206,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { class CAHitNtupletGeneratorKernels { public: using TrackerTraits = TTTraits; - using QualityCuts = ::pixelTrack::QualityCutsT; + using QualityCuts = ::reco::pixelTrack::QualityCutsT; using CellCuts = caPixelDoublets::CellCutsT; using Params = caHitNtupletGenerator::ParamsT; using CAParams = caHitNtupletGenerator::CAParamsT; using Counters = caHitNtupletGenerator::Counters; - using HitsView = TrackingRecHitSoAView; - using HitsConstView = TrackingRecHitSoAConstView; + using HitsView = reco::TrackingRecHitSoAView; + using HitsConstView = reco::TrackingRecHitSoAConstView; using TkSoAView = reco::TrackSoAView; using HitToTuple = caStructures::template HitToTupleT; @@ -230,7 +230,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { using CACell = CACellT; - using Quality = ::pixelTrack::Quality; + using Quality = ::reco::pixelTrack::Quality; using HitContainer = typename reco::TrackSoA::HitContainer; CAHitNtupletGeneratorKernels(Params const& params, uint32_t nhits, uint32_t offsetBPIX2, Queue& queue); diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h index e7ff7a2c5a01a..84fb571070813 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h @@ -50,7 +50,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels { template using OuterHitOfCell = caStructures::OuterHitOfCellT; - using Quality = ::pixelTrack::Quality; + using Quality = ::reco::pixelTrack::Quality; template using TkSoAView = reco::TrackSoAView; @@ -62,7 +62,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels { using HitsConstView = typename CACellT::HitsConstView; template - using QualityCuts = ::pixelTrack::QualityCutsT; + using QualityCuts = ::reco::pixelTrack::QualityCutsT; template using CAParams = caHitNtupletGenerator::CAParamsT; @@ -626,8 +626,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels { if (cms::alpakatools::once_per_grid(acc)) tracks_view.nTracks() = ntracks; for (auto idx : cms::alpakatools::uniform_elements(acc, ntracks)) { - ALPAKA_ASSERT_ACC(TracksUtilities::nHits(tracks_view, idx) >= 3); - tracks_view[idx].nLayers() = TracksUtilities::computeNumberOfLayers(tracks_view, idx); + ALPAKA_ASSERT_ACC(reco::TracksUtilities::nHits(tracks_view, idx) >= 3); + tracks_view[idx].nLayers() = reco::TracksUtilities::computeNumberOfLayers(tracks_view, idx); } } }; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAPixelDoubletsAlgos.h b/RecoTracker/PixelSeeding/plugins/alpaka/CAPixelDoubletsAlgos.h index 97d9acdd8739a..4c531b9446eef 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAPixelDoubletsAlgos.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAPixelDoubletsAlgos.h @@ -151,7 +151,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets { const float minRadius = hardPtCut * 87.78f; const float minRadius2T4 = 4.f * minRadius * minRadius; - using PhiBinner = typename TrackingRecHitSoA::PhiBinner; + using PhiBinner = typename reco::TrackingRecHitSoA::PhiBinner; auto const& __restrict__ phiBinner = hh.phiBinner(); uint32_t const* __restrict__ offsets = hh.hitsLayerStart().data(); diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/HelixFit.h b/RecoTracker/PixelSeeding/plugins/alpaka/HelixFit.h index f3e75e83106a7..089dcbc866339 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/HelixFit.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/HelixFit.h @@ -53,10 +53,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { template class HelixFit { public: - using TrackingRecHitSoAs = TrackingRecHitSoA; + using TrackingRecHitSoAs = reco::TrackingRecHitSoA; - using HitView = TrackingRecHitSoAView; - using HitConstView = TrackingRecHitSoAConstView; + using HitView = reco::TrackingRecHitSoAView; + using HitConstView = reco::TrackingRecHitSoAConstView; using Tuples = typename reco::TrackSoA::HitContainer; using OutputSoAView = reco::TrackSoAView; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc b/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc index a822bbd8a8252..0c3e02a28cff4 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc @@ -32,7 +32,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { Tuples const *__restrict__ foundNtuplets, TupleMultiplicity const *__restrict__ tupleMultiplicity, uint32_t nHits, - TrackingRecHitSoAConstView hh, + reco::TrackingRecHitSoAConstView hh, pixelCPEforDevice::ParamsOnDeviceT const *__restrict__ cpeParams, double *__restrict__ phits, float *__restrict__ phits_ge, @@ -174,7 +174,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { riemannFit::fromCircleToPerigee(acc, circle_fit[local_idx]); - TracksUtilities::copyFromCircle(results_view, + reco::TracksUtilities::copyFromCircle(results_view, circle_fit[local_idx].par, circle_fit[local_idx].cov, line_fit.par, @@ -208,7 +208,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { }; template - void HelixFit::launchRiemannKernels(const TrackingRecHitSoAConstView &hv, + void HelixFit::launchRiemannKernels(const reco::TrackingRecHitSoAConstView &hv, pixelCPEforDevice::ParamsOnDeviceT const *cpeParams, uint32_t nhits, uint32_t maxNumberOfTuples, diff --git a/RecoTracker/PixelTrackFitting/plugins/PixelTrackProducerFromSoAAlpaka.cc b/RecoTracker/PixelTrackFitting/plugins/PixelTrackProducerFromSoAAlpaka.cc index 5769c8c53976c..89f246c09a507 100644 --- a/RecoTracker/PixelTrackFitting/plugins/PixelTrackProducerFromSoAAlpaka.cc +++ b/RecoTracker/PixelTrackFitting/plugins/PixelTrackProducerFromSoAAlpaka.cc @@ -47,7 +47,7 @@ template class PixelTrackProducerFromSoAAlpaka : public edm::global::EDProducer<> { using TrackSoAHost = TracksHost; - using TracksHelpers = TracksUtilities; + using TracksHelpers = reco::TracksUtilities; using HMSstorage = std::vector; using IndToEdm = std::vector; @@ -70,7 +70,7 @@ class PixelTrackProducerFromSoAAlpaka : public edm::global::EDProducer<> { const edm::ESGetToken ttTopoToken_; int32_t const minNumberOfHits_; - pixelTrack::Quality const minQuality_; + reco::pixelTrack::Quality const minQuality_; }; template @@ -82,12 +82,12 @@ PixelTrackProducerFromSoAAlpaka::PixelTrackProducerFromSoAAlpaka( idealMagneticFieldToken_(esConsumes()), ttTopoToken_(esConsumes()), minNumberOfHits_(iConfig.getParameter("minNumberOfHits")), - minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))) { - if (minQuality_ == pixelTrack::Quality::notQuality) { + minQuality_(reco::pixelTrack::qualityByName(iConfig.getParameter("minQuality"))) { + if (minQuality_ == reco::pixelTrack::Quality::notQuality) { throw cms::Exception("PixelTrackConfiguration") - << iConfig.getParameter("minQuality") + " is not a pixelTrack::Quality"; + << iConfig.getParameter("minQuality") + " is not a reco::pixelTrack::Quality"; } - if (minQuality_ < pixelTrack::Quality::dup) { + if (minQuality_ < reco::pixelTrack::Quality::dup) { throw cms::Exception("PixelTrackConfiguration") << iConfig.getParameter("minQuality") + " not supported"; } @@ -123,7 +123,7 @@ void PixelTrackProducerFromSoAAlpaka::produce(edm::StreamID strea reco::TrackBase::tight, reco::TrackBase::tight, reco::TrackBase::highPurity}; - assert(reco::TrackBase::highPurity == recoQuality[int(pixelTrack::Quality::highPurity)]); + assert(reco::TrackBase::highPurity == recoQuality[int(reco::pixelTrack::Quality::highPurity)]); #ifdef GPU_DEBUG std::cout << "Converting soa helix in reco tracks" << std::endl; diff --git a/RecoTracker/PixelVertexFinding/plugins/alpaka/vertexFinder.dev.cc b/RecoTracker/PixelVertexFinding/plugins/alpaka/vertexFinder.dev.cc index b41e07aff56d5..04a7a1f6e4e98 100644 --- a/RecoTracker/PixelVertexFinding/plugins/alpaka/vertexFinder.dev.cc +++ b/RecoTracker/PixelVertexFinding/plugins/alpaka/vertexFinder.dev.cc @@ -37,7 +37,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { float ptMin, float ptMax) const { auto const* quality = tracks_view.quality(); - using helper = TracksUtilities; + using helper = reco::TracksUtilities; for (auto idx : cms::alpakatools::uniform_elements(acc, tracks_view.nTracks())) { [[maybe_unused]] auto nHits = helper::nHits(tracks_view, idx); @@ -48,7 +48,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { if (reco::isTriplet(tracks_view, idx)) continue; // no triplets - if (quality[idx] < ::pixelTrack::Quality::highPurity) + if (quality[idx] < ::reco::pixelTrack::Quality::highPurity) continue; auto pt = tracks_view[idx].pt(); From 86bfd1251ad7e41cfa70ec7fbab30edd571446d6 Mon Sep 17 00:00:00 2001 From: Breno Orzari Date: Thu, 29 Feb 2024 16:25:09 +0100 Subject: [PATCH 2/2] Adding pixel tracks DQM modules for Alpaka vs CUDA --- .../python/alpakaCUDAValidationPixel_cff.py | 6 + .../python/alpakaCUDAValidation_cff.py | 15 + .../python/upgradeWorkflowComponents.py | 20 + .../plugins/SiPixelCompareRecHits.cc | 287 +++++ .../plugins/SiPixelCompareRecHitsSoAAlpaka.cc | 244 ----- .../plugins/SiPixelCompareTrackSoAAlpaka.cc | 308 ------ .../plugins/SiPixelCompareTracks.cc | 615 +++++++++++ .../plugins/SiPixelCompareVertexSoAAlpaka.cc | 186 ---- .../plugins/SiPixelCompareVertices.cc | 228 ++++ .../SiPixelHeterogenousDQM_FirstStep_cff.py | 186 +++- .../TrackSoA/interface/TrackDefinitions.h | 18 +- .../interface/alpaka/TrackUtilities.h | 6 +- .../interface/SiPixelHitStatus.h | 6 +- .../interface/TrackingRecHitsDevice.h | 5 +- .../interface/TrackingRecHitsHost.h | 2 +- .../interface/TrackingRecHitsSoA.h | 2 +- .../test/alpaka/Hits_test.dev.cc | 6 +- .../python/siPixelDigis_cff.py | 18 +- .../python/customizeHLTforAlpaka.py | 64 +- .../python/customizeHLTforCMSSW.py | 2 +- .../python/customizeHLTforAlpakavsCUDA.py | 999 ++++++++++++++++++ .../python/siPixelClustersPreSplitting_cff.py | 65 ++ .../python/SiPixelRecHits_cfi.py | 15 + .../python/RecoPixelVertexing_cff.py | 20 + .../plugins/alpaka/CAHitNtupletGenerator.cc | 29 +- .../alpaka/CAHitNtupletGeneratorKernels.h | 4 +- .../plugins/alpaka/RiemannFit.dev.cc | 12 +- .../python/PixelTracks_cff.py | 16 + .../BeamSpotProducer/python/BeamSpot_cff.py | 6 + 29 files changed, 2564 insertions(+), 826 deletions(-) create mode 100644 Configuration/ProcessModifiers/python/alpakaCUDAValidationPixel_cff.py create mode 100644 Configuration/ProcessModifiers/python/alpakaCUDAValidation_cff.py create mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHits.cc delete mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc delete mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc create mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTracks.cc delete mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc create mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertices.cc create mode 100644 HLTriggerOffline/Common/python/customizeHLTforAlpakavsCUDA.py diff --git a/Configuration/ProcessModifiers/python/alpakaCUDAValidationPixel_cff.py b/Configuration/ProcessModifiers/python/alpakaCUDAValidationPixel_cff.py new file mode 100644 index 0000000000000..8a73f028e6026 --- /dev/null +++ b/Configuration/ProcessModifiers/python/alpakaCUDAValidationPixel_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier chain is for turning on DQM modules used for alpaka vs CUDA device/host validation for pixels + +alpakaCUDAValidationPixel = cms.Modifier() + diff --git a/Configuration/ProcessModifiers/python/alpakaCUDAValidation_cff.py b/Configuration/ProcessModifiers/python/alpakaCUDAValidation_cff.py new file mode 100644 index 0000000000000..139a94c3e3406 --- /dev/null +++ b/Configuration/ProcessModifiers/python/alpakaCUDAValidation_cff.py @@ -0,0 +1,15 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.ProcessModifiers.alpaka_cff import * +from Configuration.ProcessModifiers.alpakaValidationPixel_cff import * +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import * +from Configuration.ProcessModifiers.gpu_cff import * + +# This modifier chain is for turning on DQM modules used for alpaka device/host validation + +alpakaCUDAValidation = cms.ModifierChain( + alpaka, + alpakaValidationPixel, + alpakaCUDAValidationPixel +) + diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index f48044c0a3c9b..234e68a7749a5 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -966,6 +966,26 @@ def setup_(self, step, stepName, stepDict, k, properties): offset = 0.504, ) +# Pixel-only quadruplets workflow running on CPU and GPU for both CUDA and Alpaka +# This should be removed together with the rest of the CUDA code +# - HLT on GPU (required) +# - Pixel-only reconstruction on both CPU and GPU, with DQM and validation for GPU-vs-CPU/Alpaka-vs-CUDA comparisons +# - harvesting +upgradeWFs['PatatrackPixelOnlyAlpakaCUDAValidation'] = PatatrackWorkflow( + digi = { + '--customise': 'HLTriggerOffline/Common/customizeHLTforAlpakavsCUDA.customizeHLTforAlpakavsCUDA', + }, + reco = { + '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', + '--procModifiers': 'alpakaCUDAValidation' + }, + harvest = { + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + }, + suffix = 'Patatrack_PixelOnlyAlpakaCUDAValidation', + offset = 0.5041, +) + # Pixel-only triplets workflow running on CPU # - HLT on CPU # - Pixel-only reconstruction on CPU, with DQM and validation diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHits.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHits.cc new file mode 100644 index 0000000000000..7b45213d137b9 --- /dev/null +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHits.cc @@ -0,0 +1,287 @@ +// TODO: change file name to SiPixelCompareRecHitsSoA.cc when CUDA code is removed + +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "DataFormats/Math/interface/approx_atan2.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h" +#include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" +#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHitSoAHost.h" +#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHitsUtilities.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" + +// TODO: change class name to SiPixelCompareRecHitsSoA when CUDA code is removed +template +class SiPixelCompareRecHits : public DQMEDAnalyzer { +public: + using HitsSoA = TrackingRecHitHost; + using HitsCUDA = TrackingRecHitSoAHost; + + explicit SiPixelCompareRecHits(const edm::ParameterSet&); + ~SiPixelCompareRecHits() override = default; + void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override; + 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; + // TODO: remove analyzeSeparate function below once the CUDA code is removed from CMSSW; it was implemented + // to make the DQM compare modules work for every case: CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; + // the content of analyzeSeparate can be copied to analyze once the CUDA code is removed + template + void analyzeSeparate(U tokenRef, V tokenTar, const edm::Event& iEvent); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + const edm::ESGetToken geomToken_; + const edm::ESGetToken topoToken_; + // CUDA and Alpaka tokens are implemented to make the DQM compare modules work for every case: + // CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; CUDA tokens must be removed together with rest of CUDA code + const edm::EDGetTokenT tokenSoAHitsReferenceCUDA_; //these two are both on CPU but originally they have been + const edm::EDGetTokenT tokenSoAHitsTargetCUDA_; //produced on CPU or on GPU + const edm::EDGetTokenT tokenSoAHitsReference_; //these two are both on Host but originally they have been + const edm::EDGetTokenT tokenSoAHitsTarget_; //produced on Host or on Device + const std::string topFolderName_; + const float mind2cut_; + // String case_ is used to differentiate between different comparisons; must be removed together with rest of CUDA code + const std::string case_; + static constexpr uint32_t invalidHit_ = std::numeric_limits::max(); + static constexpr float micron_ = 10000.; + const TrackerGeometry* tkGeom_ = nullptr; + const TrackerTopology* tTopo_ = nullptr; + MonitorElement* hnHits_; + MonitorElement* hBchargeL_[4]; // max 4 barrel hits + MonitorElement* hBsizexL_[4]; + MonitorElement* hBsizeyL_[4]; + MonitorElement* hBposxL_[4]; + MonitorElement* hBposyL_[4]; + MonitorElement* hFchargeD_[2][12]; // max 12 endcap disks + MonitorElement* hFsizexD_[2][12]; + MonitorElement* hFsizeyD_[2][12]; + MonitorElement* hFposxD_[2][12]; + MonitorElement* hFposyD_[2][12]; + //differences + MonitorElement* hBchargeDiff_; + MonitorElement* hFchargeDiff_; + MonitorElement* hBsizeXDiff_; + MonitorElement* hFsizeXDiff_; + MonitorElement* hBsizeYDiff_; + MonitorElement* hFsizeYDiff_; + MonitorElement* hBposXDiff_; + MonitorElement* hFposXDiff_; + MonitorElement* hBposYDiff_; + MonitorElement* hFposYDiff_; +}; + +// +// constructors +// +template +SiPixelCompareRecHits::SiPixelCompareRecHits(const edm::ParameterSet& iConfig) + : geomToken_(esConsumes()), + topoToken_(esConsumes()), + tokenSoAHitsReferenceCUDA_(consumes(iConfig.getParameter("pixelHitsReferenceCUDA"))), + tokenSoAHitsTargetCUDA_(consumes(iConfig.getParameter("pixelHitsTargetCUDA"))), + tokenSoAHitsReference_(consumes(iConfig.getParameter("pixelHitsReferenceSoA"))), + tokenSoAHitsTarget_(consumes(iConfig.getParameter("pixelHitsTargetSoA"))), + topFolderName_(iConfig.getParameter("topFolderName")), + mind2cut_(iConfig.getParameter("minD2cut")), + case_(iConfig.getParameter("case")) {} + +// +// Begin Run +// +template +void SiPixelCompareRecHits::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { + tkGeom_ = &iSetup.getData(geomToken_); + tTopo_ = &iSetup.getData(topoToken_); +} + +template +template +void SiPixelCompareRecHits::analyzeSeparate(U tokenRef, V tokenTar, const edm::Event& iEvent) { + const auto& rhsoaHandleRef = iEvent.getHandle(tokenRef); + const auto& rhsoaHandleTar = iEvent.getHandle(tokenTar); + + if (not rhsoaHandleRef or not rhsoaHandleTar) { + edm::LogWarning out("SiPixelCompareRecHits"); + if (not rhsoaHandleRef) { + out << "reference rechits not found; "; + } + if (not rhsoaHandleTar) { + out << "target rechits not found; "; + } + out << "the comparison will not run."; + return; + } + + auto const& rhsoaRef = *rhsoaHandleRef; + auto const& rhsoaTar = *rhsoaHandleTar; + + auto const& soa2dRef = rhsoaRef.const_view(); + auto const& soa2dTar = rhsoaTar.const_view(); + + uint32_t nHitsRef = soa2dRef.metadata().size(); + uint32_t nHitsTar = soa2dTar.metadata().size(); + + hnHits_->Fill(nHitsRef, nHitsTar); + auto detIds = tkGeom_->detUnitIds(); + for (uint32_t i = 0; i < nHitsRef; i++) { + float minD = mind2cut_; + uint32_t matchedHit = invalidHit_; + uint16_t indRef = soa2dRef[i].detectorIndex(); + float xLocalRef = soa2dRef[i].xLocal(); + float yLocalRef = soa2dRef[i].yLocal(); + for (uint32_t j = 0; j < nHitsTar; j++) { + if (soa2dTar.detectorIndex(j) == indRef) { + float dx = xLocalRef - soa2dTar[j].xLocal(); + float dy = yLocalRef - soa2dTar[j].yLocal(); + float distance = dx * dx + dy * dy; + if (distance < minD) { + minD = distance; + matchedHit = j; + } + } + } + DetId id = detIds[indRef]; + uint32_t chargeRef = soa2dRef[i].chargeAndStatus().charge; + int16_t sizeXRef = std::ceil(float(std::abs(soa2dRef[i].clusterSizeX()) / 8.)); + int16_t sizeYRef = std::ceil(float(std::abs(soa2dRef[i].clusterSizeY()) / 8.)); + uint32_t chargeTar = 0; + int16_t sizeXTar = -99; + int16_t sizeYTar = -99; + float xLocalTar = -999.; + float yLocalTar = -999.; + if (matchedHit != invalidHit_) { + chargeTar = soa2dTar[matchedHit].chargeAndStatus().charge; + sizeXTar = std::ceil(float(std::abs(soa2dTar[matchedHit].clusterSizeX()) / 8.)); + sizeYTar = std::ceil(float(std::abs(soa2dTar[matchedHit].clusterSizeY()) / 8.)); + xLocalTar = soa2dTar[matchedHit].xLocal(); + yLocalTar = soa2dTar[matchedHit].yLocal(); + } + switch (id.subdetId()) { + case PixelSubdetector::PixelBarrel: + hBchargeL_[tTopo_->pxbLayer(id) - 1]->Fill(chargeRef, chargeTar); + hBsizexL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeXRef, sizeXTar); + hBsizeyL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeYRef, sizeYTar); + hBposxL_[tTopo_->pxbLayer(id) - 1]->Fill(xLocalRef, xLocalTar); + hBposyL_[tTopo_->pxbLayer(id) - 1]->Fill(yLocalRef, yLocalTar); + hBchargeDiff_->Fill(chargeRef - chargeTar); + hBsizeXDiff_->Fill(sizeXRef - sizeXTar); + hBsizeYDiff_->Fill(sizeYRef - sizeYTar); + hBposXDiff_->Fill(micron_ * (xLocalRef - xLocalTar)); + hBposYDiff_->Fill(micron_ * (yLocalRef - yLocalTar)); + break; + case PixelSubdetector::PixelEndcap: + hFchargeD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(chargeRef, chargeTar); + hFsizexD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeXRef, sizeXTar); + hFsizeyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeYRef, sizeYTar); + hFposxD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xLocalRef, xLocalTar); + hFposyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(yLocalRef, yLocalTar); + hFchargeDiff_->Fill(chargeRef - chargeTar); + hFsizeXDiff_->Fill(sizeXRef - sizeXTar); + hFsizeYDiff_->Fill(sizeYRef - sizeYTar); + hFposXDiff_->Fill(micron_ * (xLocalRef - xLocalTar)); + hFposYDiff_->Fill(micron_ * (yLocalRef - yLocalTar)); + break; + } + } +} + +// +// -- Analyze +// +template +void SiPixelCompareRecHits::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + // TODO: remove analyzeSeparate function below once the CUDA code is removed from CMSSW; it was implemented + // to make the DQM compare modules work for every case: CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; + // the content of analyzeSeparate can be copied to analyze once the CUDA code is removed + if (case_ == "CUDA") + analyzeSeparate(tokenSoAHitsReferenceCUDA_, tokenSoAHitsTargetCUDA_, iEvent); + if (case_ == "Alpaka") + analyzeSeparate(tokenSoAHitsReference_, tokenSoAHitsTarget_, iEvent); + if (case_ == "AlpakavsCUDA") + analyzeSeparate(tokenSoAHitsReference_, tokenSoAHitsTargetCUDA_, iEvent); +} + +// +// -- Book Histograms +// +template +void SiPixelCompareRecHits::bookHistograms(DQMStore::IBooker& iBook, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + iBook.cd(); + iBook.setCurrentFolder(topFolderName_); + + // clang-format off + //Global + hnHits_ = iBook.book2I("nHits", "ReferencevsTarget RecHits per event;#Reference RecHits;#Target RecHits", 200, 0, 5000,200, 0, 5000); + //Barrel Layer + for(unsigned int il=0;ilnumberOfLayers(PixelSubdetector::PixelBarrel);il++){ + hBchargeL_[il] = iBook.book2I(Form("recHitsBLay%dCharge",il+1), Form("ReferencevsTarget RecHits Charge Barrel Layer%d;Reference Charge;Target Charge",il+1), 250, 0, 100000, 250, 0, 100000); + hBsizexL_[il] = iBook.book2I(Form("recHitsBLay%dSizex",il+1), Form("ReferencevsTarget RecHits SizeX Barrel Layer%d;Reference SizeX;Target SizeX",il+1), 30, 0, 30, 30, 0, 30); + hBsizeyL_[il] = iBook.book2I(Form("recHitsBLay%dSizey",il+1), Form("ReferencevsTarget RecHits SizeY Barrel Layer%d;Reference SizeY;Target SizeY",il+1), 30, 0, 30, 30, 0, 30); + hBposxL_[il] = iBook.book2D(Form("recHitsBLay%dPosx",il+1), Form("ReferencevsTarget RecHits x-pos in Barrel Layer%d;Reference pos x;Target pos x",il+1), 200, -5, 5, 200,-5,5); + hBposyL_[il] = iBook.book2D(Form("recHitsBLay%dPosy",il+1), Form("ReferencevsTarget RecHits y-pos in Barrel Layer%d;Reference pos y;Target pos y",il+1), 200, -5, 5, 200,-5,5); + } + //Endcaps + //Endcaps Disk + for(int is=0;is<2;is++){ + int sign=is==0? -1:1; + for(unsigned int id=0;idnumberOfLayers(PixelSubdetector::PixelEndcap);id++){ + hFchargeD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dCharge",id*sign+sign), Form("ReferencevsTarget RecHits Charge Endcaps Disk%+d;Reference Charge;Target Charge",id*sign+sign), 250, 0, 100000, 250, 0, 100000); + hFsizexD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizex",id*sign+sign), Form("ReferencevsTarget RecHits SizeX Endcaps Disk%+d;Reference SizeX;Target SizeX",id*sign+sign), 30, 0, 30, 30, 0, 30); + hFsizeyD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizey",id*sign+sign), Form("ReferencevsTarget RecHits SizeY Endcaps Disk%+d;Reference SizeY;Target SizeY",id*sign+sign), 30, 0, 30, 30, 0, 30); + hFposxD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosx",id*sign+sign), Form("ReferencevsTarget RecHits x-pos Endcaps Disk%+d;Reference pos x;Target pos x",id*sign+sign), 200, -5, 5, 200, -5, 5); + hFposyD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosy",id*sign+sign), Form("ReferencevsTarget RecHits y-pos Endcaps Disk%+d;Reference pos y;Target pos y",id*sign+sign), 200, -5, 5, 200, -5, 5); + } + } + //1D differences + hBchargeDiff_ = iBook.book1D("rechitChargeDiffBpix","Charge differnce of rechits in BPix; rechit charge difference (Reference - Target)", 101, -50.5, 50.5); + hFchargeDiff_ = iBook.book1D("rechitChargeDiffFpix","Charge differnce of rechits in FPix; rechit charge difference (Reference - Target)", 101, -50.5, 50.5); + hBsizeXDiff_ = iBook.book1D("rechitsizeXDiffBpix","SizeX difference of rechits in BPix; rechit sizex difference (Reference - Target)", 21, -10.5, 10.5); + hFsizeXDiff_ = iBook.book1D("rechitsizeXDiffFpix","SizeX difference of rechits in FPix; rechit sizex difference (Reference - Target)", 21, -10.5, 10.5); + hBsizeYDiff_ = iBook.book1D("rechitsizeYDiffBpix","SizeY difference of rechits in BPix; rechit sizey difference (Reference - Target)", 21, -10.5, 10.5); + hFsizeYDiff_ = iBook.book1D("rechitsizeYDiffFpix","SizeY difference of rechits in FPix; rechit sizey difference (Reference - Target)", 21, -10.5, 10.5); + hBposXDiff_ = iBook.book1D("rechitsposXDiffBpix","x-position difference of rechits in BPix; rechit x-pos difference (Reference - Target)", 1000, -10, 10); + hFposXDiff_ = iBook.book1D("rechitsposXDiffFpix","x-position difference of rechits in FPix; rechit x-pos difference (Reference - Target)", 1000, -10, 10); + hBposYDiff_ = iBook.book1D("rechitsposYDiffBpix","y-position difference of rechits in BPix; rechit y-pos difference (Reference - Target)", 1000, -10, 10); + hFposYDiff_ = iBook.book1D("rechitsposYDiffFpix","y-position difference of rechits in FPix; rechit y-pos difference (Reference - Target)", 1000, -10, 10); +} + +template +void SiPixelCompareRecHits::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // monitorpixelRecHitsSoAAlpaka + edm::ParameterSetDescription desc; + // The default case for the comparison is still CUDA vs CUDA; the {Reference|Target}Alpaka + // input tags are set with "placeholders"; the specific tags for the other comparisons are defined + // in DQM/SiPixelHeterogeneous/python/SiPixelHeterogeneousDQM_FirstStep_cff.py + desc.add("pixelHitsReferenceCUDA", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu")); + desc.add("pixelHitsTargetCUDA", edm::InputTag("siPixelRecHitsPreSplittingSoA@cuda")); + desc.add("pixelHitsReferenceSoA", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu")); + desc.add("pixelHitsTargetSoA", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu")); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU"); + desc.add("minD2cut", 0.0001); + desc.add("case", "CUDA"); + descriptions.addWithDefaultLabel(desc); +} + +using SiPixelPhase1CompareRecHits = SiPixelCompareRecHits; +using SiPixelPhase2CompareRecHits = SiPixelCompareRecHits; +using SiPixelHIonPhase1CompareRecHits = SiPixelCompareRecHits; + +#include "FWCore/Framework/interface/MakerMacros.h" +// TODO: change module names to SiPixel*CompareRecHitsSoA when CUDA code is removed +DEFINE_FWK_MODULE(SiPixelPhase1CompareRecHits); +DEFINE_FWK_MODULE(SiPixelPhase2CompareRecHits); +DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareRecHits); + diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc deleted file mode 100644 index 474194ad72616..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc +++ /dev/null @@ -1,244 +0,0 @@ -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "DataFormats/Math/interface/approx_atan2.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h" -#include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -#include "Geometry/CommonTopologies/interface/PixelTopology.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" - -template -class SiPixelCompareRecHitsSoAAlpaka : public DQMEDAnalyzer { -public: - using HitsOnHost = TrackingRecHitHost; - - explicit SiPixelCompareRecHitsSoAAlpaka(const edm::ParameterSet&); - ~SiPixelCompareRecHitsSoAAlpaka() override = default; - void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override; - 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::ESGetToken geomToken_; - const edm::ESGetToken topoToken_; - const edm::EDGetTokenT tokenSoAHitsHost_; //these two are both on Host but originally they have been - const edm::EDGetTokenT tokenSoAHitsDevice_; //produced on Host or on Device - const std::string topFolderName_; - const float mind2cut_; - static constexpr uint32_t invalidHit_ = std::numeric_limits::max(); - static constexpr float micron_ = 10000.; - const TrackerGeometry* tkGeom_ = nullptr; - const TrackerTopology* tTopo_ = nullptr; - MonitorElement* hnHits_; - MonitorElement* hBchargeL_[4]; // max 4 barrel hits - MonitorElement* hBsizexL_[4]; - MonitorElement* hBsizeyL_[4]; - MonitorElement* hBposxL_[4]; - MonitorElement* hBposyL_[4]; - MonitorElement* hFchargeD_[2][12]; // max 12 endcap disks - MonitorElement* hFsizexD_[2][12]; - MonitorElement* hFsizeyD_[2][12]; - MonitorElement* hFposxD_[2][12]; - MonitorElement* hFposyD_[2][12]; - //differences - MonitorElement* hBchargeDiff_; - MonitorElement* hFchargeDiff_; - MonitorElement* hBsizeXDiff_; - MonitorElement* hFsizeXDiff_; - MonitorElement* hBsizeYDiff_; - MonitorElement* hFsizeYDiff_; - MonitorElement* hBposXDiff_; - MonitorElement* hFposXDiff_; - MonitorElement* hBposYDiff_; - MonitorElement* hFposYDiff_; -}; - -// -// constructors -// -template -SiPixelCompareRecHitsSoAAlpaka::SiPixelCompareRecHitsSoAAlpaka(const edm::ParameterSet& iConfig) - : geomToken_(esConsumes()), - topoToken_(esConsumes()), - tokenSoAHitsHost_(consumes(iConfig.getParameter("pixelHitsSrcHost"))), - tokenSoAHitsDevice_(consumes(iConfig.getParameter("pixelHitsSrcDevice"))), - topFolderName_(iConfig.getParameter("topFolderName")), - mind2cut_(iConfig.getParameter("minD2cut")) {} - -// -// Begin Run -// -template -void SiPixelCompareRecHitsSoAAlpaka::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { - tkGeom_ = &iSetup.getData(geomToken_); - tTopo_ = &iSetup.getData(topoToken_); -} - -// -// -- Analyze -// -template -void SiPixelCompareRecHitsSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& rhsoaHandleHost = iEvent.getHandle(tokenSoAHitsHost_); - const auto& rhsoaHandleDevice = iEvent.getHandle(tokenSoAHitsDevice_); - if (not rhsoaHandleHost or not rhsoaHandleDevice) { - edm::LogWarning out("SiPixelCompareRecHitsSoAAlpaka"); - if (not rhsoaHandleHost) { - out << "reference (Host) rechits not found; "; - } - if (not rhsoaHandleDevice) { - out << "target (Device) rechits not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& rhsoaHost = *rhsoaHandleHost; - auto const& rhsoaDevice = *rhsoaHandleDevice; - - auto const& soa2dHost = rhsoaHost.const_view(); - auto const& soa2dDevice = rhsoaDevice.const_view(); - - uint32_t nHitsHost = soa2dHost.metadata().size(); - uint32_t nHitsDevice = soa2dDevice.metadata().size(); - - hnHits_->Fill(nHitsHost, nHitsDevice); - auto detIds = tkGeom_->detUnitIds(); - for (uint32_t i = 0; i < nHitsHost; i++) { - float minD = mind2cut_; - uint32_t matchedHit = invalidHit_; - uint16_t indHost = soa2dHost[i].detectorIndex(); - float xLocalHost = soa2dHost[i].xLocal(); - float yLocalHost = soa2dHost[i].yLocal(); - for (uint32_t j = 0; j < nHitsDevice; j++) { - if (soa2dDevice.detectorIndex(j) == indHost) { - float dx = xLocalHost - soa2dDevice[j].xLocal(); - float dy = yLocalHost - soa2dDevice[j].yLocal(); - float distance = dx * dx + dy * dy; - if (distance < minD) { - minD = distance; - matchedHit = j; - } - } - } - DetId id = detIds[indHost]; - uint32_t chargeHost = soa2dHost[i].chargeAndStatus().charge; - int16_t sizeXHost = std::ceil(float(std::abs(soa2dHost[i].clusterSizeX()) / 8.)); - int16_t sizeYHost = std::ceil(float(std::abs(soa2dHost[i].clusterSizeY()) / 8.)); - uint32_t chargeDevice = 0; - int16_t sizeXDevice = -99; - int16_t sizeYDevice = -99; - float xLocalDevice = -999.; - float yLocalDevice = -999.; - if (matchedHit != invalidHit_) { - chargeDevice = soa2dDevice[matchedHit].chargeAndStatus().charge; - sizeXDevice = std::ceil(float(std::abs(soa2dDevice[matchedHit].clusterSizeX()) / 8.)); - sizeYDevice = std::ceil(float(std::abs(soa2dDevice[matchedHit].clusterSizeY()) / 8.)); - xLocalDevice = soa2dDevice[matchedHit].xLocal(); - yLocalDevice = soa2dDevice[matchedHit].yLocal(); - } - switch (id.subdetId()) { - case PixelSubdetector::PixelBarrel: - hBchargeL_[tTopo_->pxbLayer(id) - 1]->Fill(chargeHost, chargeDevice); - hBsizexL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeXHost, sizeXDevice); - hBsizeyL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeYHost, sizeYDevice); - hBposxL_[tTopo_->pxbLayer(id) - 1]->Fill(xLocalHost, xLocalDevice); - hBposyL_[tTopo_->pxbLayer(id) - 1]->Fill(yLocalHost, yLocalDevice); - hBchargeDiff_->Fill(chargeHost - chargeDevice); - hBsizeXDiff_->Fill(sizeXHost - sizeXDevice); - hBsizeYDiff_->Fill(sizeYHost - sizeYDevice); - hBposXDiff_->Fill(micron_ * (xLocalHost - xLocalDevice)); - hBposYDiff_->Fill(micron_ * (yLocalHost - yLocalDevice)); - break; - case PixelSubdetector::PixelEndcap: - hFchargeD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(chargeHost, chargeDevice); - hFsizexD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeXHost, sizeXDevice); - hFsizeyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeYHost, sizeYDevice); - hFposxD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xLocalHost, xLocalDevice); - hFposyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(yLocalHost, yLocalDevice); - hFchargeDiff_->Fill(chargeHost - chargeDevice); - hFsizeXDiff_->Fill(sizeXHost - sizeXDevice); - hFsizeYDiff_->Fill(sizeYHost - sizeYDevice); - hFposXDiff_->Fill(micron_ * (xLocalHost - xLocalDevice)); - hFposYDiff_->Fill(micron_ * (yLocalHost - yLocalDevice)); - break; - } - } -} - -// -// -- Book Histograms -// -template -void SiPixelCompareRecHitsSoAAlpaka::bookHistograms(DQMStore::IBooker& iBook, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - iBook.cd(); - iBook.setCurrentFolder(topFolderName_); - - // clang-format off - //Global - hnHits_ = iBook.book2I("nHits", "HostvsDevice RecHits per event;#Host RecHits;#Device RecHits", 200, 0, 5000,200, 0, 5000); - //Barrel Layer - for(unsigned int il=0;ilnumberOfLayers(PixelSubdetector::PixelBarrel);il++){ - hBchargeL_[il] = iBook.book2I(Form("recHitsBLay%dCharge",il+1), Form("HostvsDevice RecHits Charge Barrel Layer%d;Host Charge;Device Charge",il+1), 250, 0, 100000, 250, 0, 100000); - hBsizexL_[il] = iBook.book2I(Form("recHitsBLay%dSizex",il+1), Form("HostvsDevice RecHits SizeX Barrel Layer%d;Host SizeX;Device SizeX",il+1), 30, 0, 30, 30, 0, 30); - hBsizeyL_[il] = iBook.book2I(Form("recHitsBLay%dSizey",il+1), Form("HostvsDevice RecHits SizeY Barrel Layer%d;Host SizeY;Device SizeY",il+1), 30, 0, 30, 30, 0, 30); - hBposxL_[il] = iBook.book2D(Form("recHitsBLay%dPosx",il+1), Form("HostvsDevice RecHits x-pos in Barrel Layer%d;Host pos x;Device pos x",il+1), 200, -5, 5, 200,-5,5); - hBposyL_[il] = iBook.book2D(Form("recHitsBLay%dPosy",il+1), Form("HostvsDevice RecHits y-pos in Barrel Layer%d;Host pos y;Device pos y",il+1), 200, -5, 5, 200,-5,5); - } - //Endcaps - //Endcaps Disk - for(int is=0;is<2;is++){ - int sign=is==0? -1:1; - for(unsigned int id=0;idnumberOfLayers(PixelSubdetector::PixelEndcap);id++){ - hFchargeD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dCharge",id*sign+sign), Form("HostvsDevice RecHits Charge Endcaps Disk%+d;Host Charge;Device Charge",id*sign+sign), 250, 0, 100000, 250, 0, 100000); - hFsizexD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizex",id*sign+sign), Form("HostvsDevice RecHits SizeX Endcaps Disk%+d;Host SizeX;Device SizeX",id*sign+sign), 30, 0, 30, 30, 0, 30); - hFsizeyD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizey",id*sign+sign), Form("HostvsDevice RecHits SizeY Endcaps Disk%+d;Host SizeY;Device SizeY",id*sign+sign), 30, 0, 30, 30, 0, 30); - hFposxD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosx",id*sign+sign), Form("HostvsDevice RecHits x-pos Endcaps Disk%+d;Host pos x;Device pos x",id*sign+sign), 200, -5, 5, 200, -5, 5); - hFposyD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosy",id*sign+sign), Form("HostvsDevice RecHits y-pos Endcaps Disk%+d;Host pos y;Device pos y",id*sign+sign), 200, -5, 5, 200, -5, 5); - } - } - //1D differences - hBchargeDiff_ = iBook.book1D("rechitChargeDiffBpix","Charge differnce of rechits in BPix; rechit charge difference (Host - Device)", 101, -50.5, 50.5); - hFchargeDiff_ = iBook.book1D("rechitChargeDiffFpix","Charge differnce of rechits in FPix; rechit charge difference (Host - Device)", 101, -50.5, 50.5); - hBsizeXDiff_ = iBook.book1D("rechitsizeXDiffBpix","SizeX difference of rechits in BPix; rechit sizex difference (Host - Device)", 21, -10.5, 10.5); - hFsizeXDiff_ = iBook.book1D("rechitsizeXDiffFpix","SizeX difference of rechits in FPix; rechit sizex difference (Host - Device)", 21, -10.5, 10.5); - hBsizeYDiff_ = iBook.book1D("rechitsizeYDiffBpix","SizeY difference of rechits in BPix; rechit sizey difference (Host - Device)", 21, -10.5, 10.5); - hFsizeYDiff_ = iBook.book1D("rechitsizeYDiffFpix","SizeY difference of rechits in FPix; rechit sizey difference (Host - Device)", 21, -10.5, 10.5); - hBposXDiff_ = iBook.book1D("rechitsposXDiffBpix","x-position difference of rechits in BPix; rechit x-pos difference (Host - Device)", 1000, -10, 10); - hFposXDiff_ = iBook.book1D("rechitsposXDiffFpix","x-position difference of rechits in FPix; rechit x-pos difference (Host - Device)", 1000, -10, 10); - hBposYDiff_ = iBook.book1D("rechitsposYDiffBpix","y-position difference of rechits in BPix; rechit y-pos difference (Host - Device)", 1000, -10, 10); - hFposYDiff_ = iBook.book1D("rechitsposYDiffFpix","y-position difference of rechits in FPix; rechit y-pos difference (Host - Device)", 1000, -10, 10); -} - -template -void SiPixelCompareRecHitsSoAAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelRecHitsSoAAlpaka - edm::ParameterSetDescription desc; - desc.add("pixelHitsSrcHost", edm::InputTag("siPixelRecHitsPreSplittingAlpakaSerial")); - desc.add("pixelHitsSrcDevice", edm::InputTag("siPixelRecHitsPreSplittingAlpaka")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareDeviceVSHost"); - desc.add("minD2cut", 0.0001); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1CompareRecHitsSoAAlpaka = SiPixelCompareRecHitsSoAAlpaka; -using SiPixelPhase2CompareRecHitsSoAAlpaka = SiPixelCompareRecHitsSoAAlpaka; -using SiPixelHIonPhase1CompareRecHitsSoAAlpaka = SiPixelCompareRecHitsSoAAlpaka; - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(SiPixelPhase1CompareRecHitsSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelPhase2CompareRecHitsSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareRecHitsSoAAlpaka); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc deleted file mode 100644 index e49d89f2b50a8..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc +++ /dev/null @@ -1,308 +0,0 @@ -// for string manipulations -#include -#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" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.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" -// DataFormats -#include "DataFormats/TrackSoA/interface/TracksHost.h" -#include "DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h" - -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 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 setBinLogX(TH1* h) { - TAxis* axis = h->GetXaxis(); - setBinLog(axis); - } - void setBinLogY(TH1* h) { - TAxis* axis = h->GetYaxis(); - 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) - setBinLogX(h.get()); - if (logy) - setBinLogY(h.get()); - const auto& name = h->GetName(); - return ibook.book2I(name, h.release()); - } -} // namespace - -template -class SiPixelCompareTrackSoAAlpaka : public DQMEDAnalyzer { -public: - using PixelTrackSoA = TracksHost; - - explicit SiPixelCompareTrackSoAAlpaka(const edm::ParameterSet&); - ~SiPixelCompareTrackSoAAlpaka() 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 tokenSoATrackHost_; - const edm::EDGetTokenT tokenSoATrackDevice_; - const std::string topFolderName_; - const bool useQualityCut_; - const reco::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* hCharge_; - MonitorElement* hchi2_; - MonitorElement* hChi2VsPhi_; - MonitorElement* hChi2VsEta_; - MonitorElement* hpt_; - MonitorElement* hptLogLog_; - MonitorElement* heta_; - MonitorElement* hphi_; - MonitorElement* hz_; - MonitorElement* htip_; - MonitorElement* hquality_; - //1D differences - MonitorElement* hptdiffMatched_; - MonitorElement* hCurvdiffMatched_; - MonitorElement* hetadiffMatched_; - MonitorElement* hphidiffMatched_; - MonitorElement* hzdiffMatched_; - MonitorElement* htipdiffMatched_; - - //for matching eff vs region: derive the ratio at harvesting - MonitorElement* hpt_eta_tkAllHost_; - MonitorElement* hpt_eta_tkAllHostMatched_; - MonitorElement* hphi_z_tkAllHost_; - MonitorElement* hphi_z_tkAllHostMatched_; -}; - -// -// constructors -// - -template -SiPixelCompareTrackSoAAlpaka::SiPixelCompareTrackSoAAlpaka(const edm::ParameterSet& iConfig) - : tokenSoATrackHost_(consumes(iConfig.getParameter("pixelTrackSrcHost"))), - tokenSoATrackDevice_(consumes(iConfig.getParameter("pixelTrackSrcDevice"))), - topFolderName_(iConfig.getParameter("topFolderName")), - useQualityCut_(iConfig.getParameter("useQualityCut")), - minQuality_(reco::pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), - dr2cut_(iConfig.getParameter("deltaR2cut")) {} - -// -// -- Analyze -// -template -void SiPixelCompareTrackSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using helper = reco::TracksUtilities; - const auto& tsoaHandleHost = iEvent.getHandle(tokenSoATrackHost_); - const auto& tsoaHandleDevice = iEvent.getHandle(tokenSoATrackDevice_); - if (not tsoaHandleHost or not tsoaHandleDevice) { - edm::LogWarning out("SiPixelCompareTrackSoAAlpaka"); - if (not tsoaHandleHost) { - out << "reference (cpu) tracks not found; "; - } - if (not tsoaHandleDevice) { - out << "target (gpu) tracks not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& tsoaHost = *tsoaHandleHost; - auto const& tsoaDevice = *tsoaHandleDevice; - auto maxTracksHost = tsoaHost.view().metadata().size(); //this should be same for both? - auto maxTracksDevice = tsoaDevice.view().metadata().size(); //this should be same for both? - auto const* qualityHost = tsoaHost.view().quality(); - auto const* qualityDevice = tsoaDevice.view().quality(); - int32_t nTracksHost = 0; - int32_t nTracksDevice = 0; - int32_t nLooseAndAboveTracksHost = 0; - int32_t nLooseAndAboveTracksHost_matchedDevice = 0; - int32_t nLooseAndAboveTracksDevice = 0; - - //Loop over Device tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? - std::vector looseTrkidxDevice; - for (int32_t jt = 0; jt < maxTracksDevice; ++jt) { - if (helper::nHits(tsoaDevice.view(), jt) == 0) - break; // this is a guard - if (!(tsoaDevice.view()[jt].pt() > 0.)) - continue; - nTracksDevice++; - if (useQualityCut_ && qualityDevice[jt] < minQuality_) - continue; - nLooseAndAboveTracksDevice++; - looseTrkidxDevice.emplace_back(jt); - } - - //Now loop over Host tracks//nested loop for loose gPU tracks - for (int32_t it = 0; it < maxTracksHost; ++it) { - int nHitsHost = helper::nHits(tsoaHost.view(), it); - - if (nHitsHost == 0) - break; // this is a guard - - float ptHost = tsoaHost.view()[it].pt(); - float etaHost = tsoaHost.view()[it].eta(); - float phiHost = reco::phi(tsoaHost.view(), it); - float zipHost = reco::zip(tsoaHost.view(), it); - float tipHost = reco::tip(tsoaHost.view(), it); - - if (!(ptHost > 0.)) - continue; - nTracksHost++; - if (useQualityCut_ && qualityHost[it] < minQuality_) - continue; - nLooseAndAboveTracksHost++; - //Now loop over loose Device trk and find the closest in DeltaR//do we need pt cut? - const int32_t notFound = -1; - int32_t closestTkidx = notFound; - float mindr2 = dr2cut_; - - for (auto gid : looseTrkidxDevice) { - float etaDevice = tsoaDevice.view()[gid].eta(); - float phiDevice = reco::phi(tsoaDevice.view(), gid); - float dr2 = reco::deltaR2(etaHost, phiHost, etaDevice, phiDevice); - if (dr2 > dr2cut_) - continue; // this is arbitrary - if (mindr2 > dr2) { - mindr2 = dr2; - closestTkidx = gid; - } - } - - hpt_eta_tkAllHost_->Fill(etaHost, ptHost); //all Host tk - hphi_z_tkAllHost_->Fill(phiHost, zipHost); - if (closestTkidx == notFound) - continue; - nLooseAndAboveTracksHost_matchedDevice++; - - hchi2_->Fill(tsoaHost.view()[it].chi2(), tsoaDevice.view()[closestTkidx].chi2()); - hCharge_->Fill(reco::charge(tsoaHost.view(), it), reco::charge(tsoaDevice.view(), closestTkidx)); - hnHits_->Fill(helper::nHits(tsoaHost.view(), it), helper::nHits(tsoaDevice.view(), closestTkidx)); - hnLayers_->Fill(tsoaHost.view()[it].nLayers(), tsoaDevice.view()[closestTkidx].nLayers()); - hpt_->Fill(tsoaHost.view()[it].pt(), tsoaDevice.view()[closestTkidx].pt()); - hptLogLog_->Fill(tsoaHost.view()[it].pt(), tsoaDevice.view()[closestTkidx].pt()); - heta_->Fill(etaHost, tsoaDevice.view()[closestTkidx].eta()); - hphi_->Fill(phiHost, reco::phi(tsoaDevice.view(), closestTkidx)); - hz_->Fill(zipHost, reco::zip(tsoaDevice.view(), closestTkidx)); - htip_->Fill(tipHost, reco::tip(tsoaDevice.view(), closestTkidx)); - hptdiffMatched_->Fill(ptHost - tsoaDevice.view()[closestTkidx].pt()); - hCurvdiffMatched_->Fill((reco::charge(tsoaHost.view(), it) / tsoaHost.view()[it].pt()) - - (reco::charge(tsoaDevice.view(), closestTkidx) / tsoaDevice.view()[closestTkidx].pt())); - hetadiffMatched_->Fill(etaHost - tsoaDevice.view()[closestTkidx].eta()); - hphidiffMatched_->Fill(reco::deltaPhi(phiHost, reco::phi(tsoaDevice.view(), closestTkidx))); - hzdiffMatched_->Fill(zipHost - reco::zip(tsoaDevice.view(), closestTkidx)); - htipdiffMatched_->Fill(tipHost - reco::tip(tsoaDevice.view(), closestTkidx)); - hpt_eta_tkAllHostMatched_->Fill(etaHost, tsoaHost.view()[it].pt()); //matched to gpu - hphi_z_tkAllHostMatched_->Fill(etaHost, zipHost); - } - hnTracks_->Fill(nTracksHost, nTracksDevice); - hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksHost, nLooseAndAboveTracksDevice); - hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksHost, nLooseAndAboveTracksHost_matchedDevice); -} - -// -// -- Book Histograms -// -template -void SiPixelCompareTrackSoAAlpaka::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"; - // FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports THnSparse - // these should be moved to a less resource consuming format - hnTracks_ = iBook.book2I("nTracks", fmt::format("{} per event; Host; Device",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - hnLooseAndAboveTracks_ = iBook.book2I("nLooseAndAboveTracks", fmt::format("{} (quality #geq loose) per event; Host; Device",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - hnLooseAndAboveTracks_matched_ = iBook.book2I("nLooseAndAboveTracks_matched", fmt::format("{} (quality #geq loose) per event; Host; Device",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - - toRep = "Number of all RecHits per track (quality #geq loose)"; - hnHits_ = iBook.book2I("nRecHits", fmt::format("{};Host;Device",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); - - toRep = "Number of all layers per track (quality #geq loose)"; - hnLayers_ = iBook.book2I("nLayers", fmt::format("{};Host;Device",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); - - toRep = "Track (quality #geq loose) #chi^{2}/ndof"; - hchi2_ = iBook.book2I("nChi2ndof", fmt::format("{};Host;Device",toRep), 40, 0., 20., 40, 0., 20.); - - toRep = "Track (quality #geq loose) charge"; - hCharge_ = iBook.book2I("charge",fmt::format("{};Host;Device",toRep),3, -1.5, 1.5, 3, -1.5, 1.5); - - hpt_ = iBook.book2I("pt", "Track (quality #geq loose) p_{T} [GeV];Host;Device", 200, 0., 200., 200, 0., 200.); - hptLogLog_ = make2DIfLog(iBook, true, true, "ptLogLog", "Track (quality #geq loose) p_{T} [GeV];Host;Device", 200, log10(0.5), log10(200.), 200, log10(0.5), log10(200.)); - heta_ = iBook.book2I("eta", "Track (quality #geq loose) #eta;Host;Device", 30, -3., 3., 30, -3., 3.); - hphi_ = iBook.book2I("phi", "Track (quality #geq loose) #phi;Host;Device", 30, -M_PI, M_PI, 30, -M_PI, M_PI); - hz_ = iBook.book2I("z", "Track (quality #geq loose) z [cm];Host;Device", 30, -30., 30., 30, -30., 30.); - htip_ = iBook.book2I("tip", "Track (quality #geq loose) TIP [cm];Host;Device", 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.); - hCurvdiffMatched_ = iBook.book1D("curvdiffmatched", "q/p_{T} diff [GeV] between matched tracks; #Delta q/p_{T} [GeV]", 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); - htipdiffMatched_ = iBook.book1D("tipdiffmatched", " TIP diff between matched tracks; #Delta TIP [cm]", 300, -1.5, 1.5); - //2D plots for eff - hpt_eta_tkAllHost_ = iBook.book2I("ptetatrkAllHost", "Track (quality #geq loose) on Host; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - hpt_eta_tkAllHostMatched_ = iBook.book2I("ptetatrkAllHostmatched", "Track (quality #geq loose) on Host matched to Device track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - - hphi_z_tkAllHost_ = iBook.book2I("phiztrkAllHost", "Track (quality #geq loose) on Host; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); - hphi_z_tkAllHostMatched_ = iBook.book2I("phiztrkAllHostmatched", "Track (quality #geq loose) on Host; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); - -} - -template -void SiPixelCompareTrackSoAAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelTrackSoA - edm::ParameterSetDescription desc; - desc.add("pixelTrackSrcHost", edm::InputTag("pixelTracksAlpakaSerial")); - desc.add("pixelTrackSrcDevice", edm::InputTag("pixelTracksAlpaka")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareDeviceVSHost"); - desc.add("useQualityCut", true); - desc.add("minQuality", "loose"); - desc.add("deltaR2cut", 0.04); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1CompareTrackSoAAlpaka = SiPixelCompareTrackSoAAlpaka; -using SiPixelPhase2CompareTrackSoAAlpaka = SiPixelCompareTrackSoAAlpaka; -using SiPixelHIonPhase1CompareTrackSoAAlpaka = SiPixelCompareTrackSoAAlpaka; - -DEFINE_FWK_MODULE(SiPixelPhase1CompareTrackSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelPhase2CompareTrackSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareTrackSoAAlpaka); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTracks.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTracks.cc new file mode 100644 index 0000000000000..9ffcc0d82d953 --- /dev/null +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTracks.cc @@ -0,0 +1,615 @@ +// TODO: change file name to SiPixelCompareTracksSoA.cc when CUDA code is removed + +// -*- C++ -*- +// Package: SiPixelCompareTracks +// Class: SiPixelCompareTracks +// +/**\class SiPixelCompareTracks SiPixelCompareTracks.cc +*/ +// +// Author: Suvankar Roy Chowdhury +// + +// for string manipulations +#include +#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" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.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" +// DataFormats +#include "DataFormats/TrackSoA/interface/TracksHost.h" +#include "DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h" +#include "CUDADataFormats/Track/interface/TrackSoAHeterogeneousHost.h" +#include "CUDADataFormats/Track/interface/TrackSoAHeterogeneousDevice.h" + +struct None {}; + +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 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 setBinLogX(TH1* h) { + TAxis* axis = h->GetXaxis(); + setBinLog(axis); + } + void setBinLogY(TH1* h) { + TAxis* axis = h->GetYaxis(); + 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) + setBinLogX(h.get()); + if (logy) + setBinLogY(h.get()); + const auto& name = h->GetName(); + return ibook.book2I(name, h.release()); + } +} // namespace + +// TODO: change class name to SiPixelCompareTracksSoA when CUDA code is removed +template +class SiPixelCompareTracks : public DQMEDAnalyzer { +public: + using PixelTrackSoA = TracksHost; + using PixelTrackSoACUDA = TrackSoAHeterogeneousHost; + + explicit SiPixelCompareTracks(const edm::ParameterSet&); + ~SiPixelCompareTracks() 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; + // TODO: remove analyze* functions below once the CUDA code is removed from CMSSW; they were implemented + // to make the DQM compare modules work for every case: CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; + // the content of analyzeAlpaka can be copied to analyze once the CUDA code is removed + void analyzeCUDA(const edm::EDGetTokenT tokenRef, + const edm::EDGetTokenT tokenTar, + const edm::Event& iEvent); + void analyzeAlpaka(const edm::EDGetTokenT tokenRef, + const edm::EDGetTokenT tokenTar, + const edm::Event& iEvent); + void analyzeAlpakavsCUDA(const edm::EDGetTokenT tokenRef, + const edm::EDGetTokenT tokenTar, + const edm::Event& iEvent); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + // CUDA and Alpaka tokens are implemented to make the DQM compare modules work for every case: + // CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; CUDA tokens must be removed together with rest of CUDA code + const edm::EDGetTokenT + tokenSoATrackReferenceCUDA_; //these two are both on CPU but originally they have been + const edm::EDGetTokenT tokenSoATrackTargetCUDA_; //produced on CPU or on GPU + const edm::EDGetTokenT + tokenSoATrackReference_; //these two are both on Host but originally they have been + const edm::EDGetTokenT tokenSoATrackTarget_; //produced on Host or on Device + const std::string topFolderName_; + const bool useQualityCut_; + const reco::pixelTrack::Quality minQuality_; + const float dr2cut_; + // String case_ is used to differentiate between different comparisons; must be removed together with rest of CUDA code + const std::string case_; + MonitorElement* hnTracks_; + MonitorElement* hnLooseAndAboveTracks_; + MonitorElement* hnLooseAndAboveTracks_matched_; + MonitorElement* hnHits_; + MonitorElement* hnHitsVsPhi_; + MonitorElement* hnHitsVsEta_; + MonitorElement* hnLayers_; + MonitorElement* hnLayersVsPhi_; + MonitorElement* hnLayersVsEta_; + MonitorElement* hCharge_; + MonitorElement* hchi2_; + MonitorElement* hChi2VsPhi_; + MonitorElement* hChi2VsEta_; + MonitorElement* hpt_; + MonitorElement* hptLogLog_; + MonitorElement* heta_; + MonitorElement* hphi_; + MonitorElement* hz_; + MonitorElement* htip_; + MonitorElement* hquality_; + //1D differences + MonitorElement* hptdiffMatched_; + MonitorElement* hCurvdiffMatched_; + MonitorElement* hetadiffMatched_; + MonitorElement* hphidiffMatched_; + MonitorElement* hzdiffMatched_; + MonitorElement* htipdiffMatched_; + + //for matching eff vs region: derive the ratio at harvesting + MonitorElement* hpt_eta_tkAllRef_; + MonitorElement* hpt_eta_tkAllRefMatched_; + MonitorElement* hphi_z_tkAllRef_; + MonitorElement* hphi_z_tkAllRefMatched_; +}; + +// +// constructors +// + +template +SiPixelCompareTracks::SiPixelCompareTracks(const edm::ParameterSet& iConfig) + : tokenSoATrackReferenceCUDA_( + consumes(iConfig.getParameter("pixelTrackReferenceCUDA"))), + tokenSoATrackTargetCUDA_( + consumes(iConfig.getParameter("pixelTrackTargetCUDA"))), + tokenSoATrackReference_(consumes(iConfig.getParameter("pixelTrackReferenceSoA"))), + tokenSoATrackTarget_(consumes(iConfig.getParameter("pixelTrackTargetSoA"))), + topFolderName_(iConfig.getParameter("topFolderName")), + useQualityCut_(iConfig.getParameter("useQualityCut")), + minQuality_(reco::pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), + dr2cut_(iConfig.getParameter("deltaR2cut")), + case_(iConfig.getParameter("case")) {} + +template +void SiPixelCompareTracks::analyzeCUDA(const edm::EDGetTokenT tokenRef, + const edm::EDGetTokenT tokenTar, + const edm::Event& iEvent) { + using helper = TracksUtilities; + + const auto& tsoaHandleRef = iEvent.getHandle(tokenRef); + const auto& tsoaHandleTar = iEvent.getHandle(tokenTar); + + if (not tsoaHandleRef or not tsoaHandleTar) { + edm::LogWarning out("SiPixelCompareTracks"); + if (not tsoaHandleRef) { + out << "reference tracks not found; "; + } + if (not tsoaHandleTar) { + out << "target tracks not found; "; + } + out << "the comparison will not run."; + return; + } + + auto const& tsoaRef = *tsoaHandleRef; + auto const& tsoaTar = *tsoaHandleTar; + + auto maxTracksRef = tsoaRef.view().metadata().size(); //this should be same for both? + auto maxTracksTar = tsoaTar.view().metadata().size(); //this should be same for both? + + auto const* qualityRef = tsoaRef.view().quality(); + auto const* qualityTar = tsoaTar.view().quality(); + + int32_t nTracksRef = 0; + int32_t nTracksTar = 0; + int32_t nLooseAndAboveTracksRef = 0; + int32_t nLooseAndAboveTracksRef_matchedTar = 0; + int32_t nLooseAndAboveTracksTar = 0; + + //Loop over Tar tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? + std::vector looseTrkidxTar; + for (int32_t jt = 0; jt < maxTracksTar; ++jt) { + if (helper::nHits(tsoaTar.view(), jt) == 0) + break; // this is a guard + if (!(tsoaTar.view()[jt].pt() > 0.)) + continue; + nTracksTar++; + if (useQualityCut_ && (reco::pixelTrack::Quality)qualityTar[jt] < minQuality_) + continue; + nLooseAndAboveTracksTar++; + looseTrkidxTar.emplace_back(jt); + } + + //Now loop over Ref tracks//nested loop for loose gPU tracks + for (int32_t it = 0; it < maxTracksRef; ++it) { + int nHitsRef = helper::nHits(tsoaRef.view(), it); + + if (nHitsRef == 0) + break; // this is a guard + + float ptRef = tsoaRef.view()[it].pt(); + float etaRef = tsoaRef.view()[it].eta(); + float phiRef = helper::phi(tsoaRef.view(), it); + float zipRef = helper::zip(tsoaRef.view(), it); + float tipRef = helper::tip(tsoaRef.view(), it); + + if (!(ptRef > 0.)) + continue; + nTracksRef++; + if (useQualityCut_ && (reco::pixelTrack::Quality)qualityRef[it] < minQuality_) + continue; + nLooseAndAboveTracksRef++; + //Now loop over loose Tar trk and find the closest in DeltaR//do we need pt cut? + const int32_t notFound = -1; + int32_t closestTkidx = notFound; + float mindr2 = dr2cut_; + + for (auto gid : looseTrkidxTar) { + float etaTar = tsoaTar.view()[gid].eta(); + float phiTar = helper::phi(tsoaTar.view(), gid); + float dr2 = reco::deltaR2(etaRef, phiRef, etaTar, phiTar); + if (dr2 > dr2cut_) + continue; // this is arbitrary + if (mindr2 > dr2) { + mindr2 = dr2; + closestTkidx = gid; + } + } + + hpt_eta_tkAllRef_->Fill(etaRef, ptRef); //all Ref tk + hphi_z_tkAllRef_->Fill(phiRef, zipRef); + if (closestTkidx == notFound) + continue; + nLooseAndAboveTracksRef_matchedTar++; + + hchi2_->Fill(tsoaRef.view()[it].chi2(), tsoaTar.view()[closestTkidx].chi2()); + hCharge_->Fill(helper::charge(tsoaRef.view(), it), helper::charge(tsoaTar.view(), closestTkidx)); + hnHits_->Fill(helper::nHits(tsoaRef.view(), it), helper::nHits(tsoaTar.view(), closestTkidx)); + hnLayers_->Fill(tsoaRef.view()[it].nLayers(), tsoaTar.view()[closestTkidx].nLayers()); + hpt_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt()); + hptLogLog_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt()); + heta_->Fill(etaRef, tsoaTar.view()[closestTkidx].eta()); + hphi_->Fill(phiRef, helper::phi(tsoaTar.view(), closestTkidx)); + hz_->Fill(zipRef, helper::zip(tsoaTar.view(), closestTkidx)); + htip_->Fill(tipRef, helper::tip(tsoaTar.view(), closestTkidx)); + hptdiffMatched_->Fill(ptRef - tsoaTar.view()[closestTkidx].pt()); + hCurvdiffMatched_->Fill((helper::charge(tsoaRef.view(), it) / tsoaRef.view()[it].pt()) - + (helper::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt())); + hetadiffMatched_->Fill(etaRef - tsoaTar.view()[closestTkidx].eta()); + hphidiffMatched_->Fill(reco::deltaPhi(phiRef, helper::phi(tsoaTar.view(), closestTkidx))); + hzdiffMatched_->Fill(zipRef - helper::zip(tsoaTar.view(), closestTkidx)); + htipdiffMatched_->Fill(tipRef - helper::tip(tsoaTar.view(), closestTkidx)); + hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[it].pt()); //matched to gpu + hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef); + } + hnTracks_->Fill(nTracksRef, nTracksTar); + hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksTar); + hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar); +} + +template +void SiPixelCompareTracks::analyzeAlpaka(const edm::EDGetTokenT tokenRef, + const edm::EDGetTokenT tokenTar, + const edm::Event& iEvent) { + using helper = reco::TracksUtilities; + + const auto& tsoaHandleRef = iEvent.getHandle(tokenRef); + const auto& tsoaHandleTar = iEvent.getHandle(tokenTar); + + if (not tsoaHandleRef or not tsoaHandleTar) { + edm::LogWarning out("SiPixelCompareTracks"); + if (not tsoaHandleRef) { + out << "reference tracks not found; "; + } + if (not tsoaHandleTar) { + out << "target tracks not found; "; + } + out << "the comparison will not run."; + return; + } + + auto const& tsoaRef = *tsoaHandleRef; + auto const& tsoaTar = *tsoaHandleTar; + + auto maxTracksRef = tsoaRef.view().metadata().size(); //this should be same for both? + auto maxTracksTar = tsoaTar.view().metadata().size(); //this should be same for both? + + auto const* qualityRef = tsoaRef.view().quality(); + auto const* qualityTar = tsoaTar.view().quality(); + + int32_t nTracksRef = 0; + int32_t nTracksTar = 0; + int32_t nLooseAndAboveTracksRef = 0; + int32_t nLooseAndAboveTracksRef_matchedTar = 0; + int32_t nLooseAndAboveTracksTar = 0; + + //Loop over Tar tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? + std::vector looseTrkidxTar; + for (int32_t jt = 0; jt < maxTracksTar; ++jt) { + if (helper::nHits(tsoaTar.view(), jt) == 0) + break; // this is a guard + if (!(tsoaTar.view()[jt].pt() > 0.)) + continue; + nTracksTar++; + if (useQualityCut_ && qualityTar[jt] < minQuality_) + continue; + nLooseAndAboveTracksTar++; + looseTrkidxTar.emplace_back(jt); + } + + //Now loop over Ref tracks//nested loop for loose gPU tracks + for (int32_t it = 0; it < maxTracksRef; ++it) { + int nHitsRef = helper::nHits(tsoaRef.view(), it); + + if (nHitsRef == 0) + break; // this is a guard + + float ptRef = tsoaRef.view()[it].pt(); + float etaRef = tsoaRef.view()[it].eta(); + float phiRef = reco::phi(tsoaRef.view(), it); + float zipRef = reco::zip(tsoaRef.view(), it); + float tipRef = reco::tip(tsoaRef.view(), it); + + if (!(ptRef > 0.)) + continue; + nTracksRef++; + if (useQualityCut_ && qualityRef[it] < minQuality_) + continue; + nLooseAndAboveTracksRef++; + //Now loop over loose Tar trk and find the closest in DeltaR//do we need pt cut? + const int32_t notFound = -1; + int32_t closestTkidx = notFound; + float mindr2 = dr2cut_; + + for (auto gid : looseTrkidxTar) { + float etaTar = tsoaTar.view()[gid].eta(); + float phiTar = reco::phi(tsoaTar.view(), gid); + float dr2 = reco::deltaR2(etaRef, phiRef, etaTar, phiTar); + if (dr2 > dr2cut_) + continue; // this is arbitrary + if (mindr2 > dr2) { + mindr2 = dr2; + closestTkidx = gid; + } + } + + hpt_eta_tkAllRef_->Fill(etaRef, ptRef); //all Ref tk + hphi_z_tkAllRef_->Fill(phiRef, zipRef); + if (closestTkidx == notFound) + continue; + nLooseAndAboveTracksRef_matchedTar++; + + hchi2_->Fill(tsoaRef.view()[it].chi2(), tsoaTar.view()[closestTkidx].chi2()); + hCharge_->Fill(reco::charge(tsoaRef.view(), it), reco::charge(tsoaTar.view(), closestTkidx)); + hnHits_->Fill(helper::nHits(tsoaRef.view(), it), helper::nHits(tsoaTar.view(), closestTkidx)); + hnLayers_->Fill(tsoaRef.view()[it].nLayers(), tsoaTar.view()[closestTkidx].nLayers()); + hpt_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt()); + hptLogLog_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt()); + heta_->Fill(etaRef, tsoaTar.view()[closestTkidx].eta()); + hphi_->Fill(phiRef, reco::phi(tsoaTar.view(), closestTkidx)); + hz_->Fill(zipRef, reco::zip(tsoaTar.view(), closestTkidx)); + htip_->Fill(tipRef, reco::tip(tsoaTar.view(), closestTkidx)); + hptdiffMatched_->Fill(ptRef - tsoaTar.view()[closestTkidx].pt()); + hCurvdiffMatched_->Fill((reco::charge(tsoaRef.view(), it) / tsoaRef.view()[it].pt()) - + (reco::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt())); + hetadiffMatched_->Fill(etaRef - tsoaTar.view()[closestTkidx].eta()); + hphidiffMatched_->Fill(reco::deltaPhi(phiRef, reco::phi(tsoaTar.view(), closestTkidx))); + hzdiffMatched_->Fill(zipRef - reco::zip(tsoaTar.view(), closestTkidx)); + htipdiffMatched_->Fill(tipRef - reco::tip(tsoaTar.view(), closestTkidx)); + hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[it].pt()); //matched to gpu + hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef); + } + hnTracks_->Fill(nTracksRef, nTracksTar); + hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksTar); + hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar); +} + +template +void SiPixelCompareTracks::analyzeAlpakavsCUDA(const edm::EDGetTokenT tokenRef, + const edm::EDGetTokenT tokenTar, + const edm::Event& iEvent) { + using helperAlpaka = reco::TracksUtilities; + using helperCUDA = TracksUtilities; + + const auto& tsoaHandleRef = iEvent.getHandle(tokenRef); + const auto& tsoaHandleTar = iEvent.getHandle(tokenTar); + + if (not tsoaHandleRef or not tsoaHandleTar) { + edm::LogWarning out("SiPixelCompareTracks"); + if (not tsoaHandleRef) { + out << "reference tracks not found; "; + } + if (not tsoaHandleTar) { + out << "target tracks not found; "; + } + out << "the comparison will not run."; + return; + } + + auto const& tsoaRef = *tsoaHandleRef; + auto const& tsoaTar = *tsoaHandleTar; + + auto maxTracksRef = tsoaRef.view().metadata().size(); //this should be same for both? + auto maxTracksTar = tsoaTar.view().metadata().size(); //this should be same for both? + + auto const* qualityRef = tsoaRef.view().quality(); + auto const* qualityTar = tsoaTar.view().quality(); + + int32_t nTracksRef = 0; + int32_t nTracksTar = 0; + int32_t nLooseAndAboveTracksRef = 0; + int32_t nLooseAndAboveTracksRef_matchedTar = 0; + int32_t nLooseAndAboveTracksTar = 0; + + //Loop over Tar tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? + std::vector looseTrkidxTar; + for (int32_t jt = 0; jt < maxTracksTar; ++jt) { + if (helperCUDA::nHits(tsoaTar.view(), jt) == 0) + break; // this is a guard + if (!(tsoaTar.view()[jt].pt() > 0.)) + continue; + nTracksTar++; + if (useQualityCut_ && (reco::pixelTrack::Quality)qualityTar[jt] < minQuality_) + continue; + nLooseAndAboveTracksTar++; + looseTrkidxTar.emplace_back(jt); + } + + //Now loop over Ref tracks//nested loop for loose gPU tracks + for (int32_t it = 0; it < maxTracksRef; ++it) { + int nHitsRef = helperAlpaka::nHits(tsoaRef.view(), it); + + if (nHitsRef == 0) + break; // this is a guard + + float ptRef = tsoaRef.view()[it].pt(); + float etaRef = tsoaRef.view()[it].eta(); + float phiRef = reco::phi(tsoaRef.view(), it); + float zipRef = reco::zip(tsoaRef.view(), it); + float tipRef = reco::tip(tsoaRef.view(), it); + + if (!(ptRef > 0.)) + continue; + nTracksRef++; + if (useQualityCut_ && qualityRef[it] < minQuality_) + continue; + nLooseAndAboveTracksRef++; + //Now loop over loose Tar trk and find the closest in DeltaR//do we need pt cut? + const int32_t notFound = -1; + int32_t closestTkidx = notFound; + float mindr2 = dr2cut_; + + for (auto gid : looseTrkidxTar) { + float etaTar = tsoaTar.view()[gid].eta(); + float phiTar = helperCUDA::phi(tsoaTar.view(), gid); + float dr2 = reco::deltaR2(etaRef, phiRef, etaTar, phiTar); + if (dr2 > dr2cut_) + continue; // this is arbitrary + if (mindr2 > dr2) { + mindr2 = dr2; + closestTkidx = gid; + } + } + + hpt_eta_tkAllRef_->Fill(etaRef, ptRef); //all Ref tk + hphi_z_tkAllRef_->Fill(phiRef, zipRef); + if (closestTkidx == notFound) + continue; + nLooseAndAboveTracksRef_matchedTar++; + + hchi2_->Fill(tsoaRef.view()[it].chi2(), tsoaTar.view()[closestTkidx].chi2()); + hCharge_->Fill(reco::charge(tsoaRef.view(), it), helperCUDA::charge(tsoaTar.view(), closestTkidx)); + hnHits_->Fill(helperAlpaka::nHits(tsoaRef.view(), it), helperCUDA::nHits(tsoaTar.view(), closestTkidx)); + hnLayers_->Fill(tsoaRef.view()[it].nLayers(), tsoaTar.view()[closestTkidx].nLayers()); + hpt_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt()); + hptLogLog_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt()); + heta_->Fill(etaRef, tsoaTar.view()[closestTkidx].eta()); + hphi_->Fill(phiRef, helperCUDA::phi(tsoaTar.view(), closestTkidx)); + hz_->Fill(zipRef, helperCUDA::zip(tsoaTar.view(), closestTkidx)); + htip_->Fill(tipRef, helperCUDA::tip(tsoaTar.view(), closestTkidx)); + hptdiffMatched_->Fill(ptRef - tsoaTar.view()[closestTkidx].pt()); + hCurvdiffMatched_->Fill((reco::charge(tsoaRef.view(), it) / tsoaRef.view()[it].pt()) - + (helperCUDA::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt())); + hetadiffMatched_->Fill(etaRef - tsoaTar.view()[closestTkidx].eta()); + hphidiffMatched_->Fill(reco::deltaPhi(phiRef, helperCUDA::phi(tsoaTar.view(), closestTkidx))); + hzdiffMatched_->Fill(zipRef - helperCUDA::zip(tsoaTar.view(), closestTkidx)); + htipdiffMatched_->Fill(tipRef - helperCUDA::tip(tsoaTar.view(), closestTkidx)); + hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[it].pt()); //matched to gpu + hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef); + } + hnTracks_->Fill(nTracksRef, nTracksTar); + hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksTar); + hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar); +} + +// +// -- Analyze +// +template +void SiPixelCompareTracks::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + // TODO: remove analyze* functions below once the CUDA code is removed from CMSSW; they were implemented + // to make the DQM compare modules work for every case: CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; + // the content of analyzeAlpaka can be copied to analyze once the CUDA code is removed + if (case_ == "CUDA") + analyzeCUDA(tokenSoATrackReferenceCUDA_, tokenSoATrackTargetCUDA_, iEvent); + if (case_ == "Alpaka") + analyzeAlpaka(tokenSoATrackReference_, tokenSoATrackTarget_, iEvent); + if (case_ == "AlpakavsCUDA") + analyzeAlpakavsCUDA(tokenSoATrackReference_, tokenSoATrackTargetCUDA_, iEvent); +} + +// +// -- Book Histograms +// +template +void SiPixelCompareTracks::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"; + // FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports THnSparse + // these should be moved to a less resource consuming format + hnTracks_ = iBook.book2I("nTracks", fmt::sprintf("%s per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnLooseAndAboveTracks_ = iBook.book2I("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + hnLooseAndAboveTracks_matched_ = iBook.book2I("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); + + toRep = "Number of all RecHits per track (quality #geq loose)"; + hnHits_ = iBook.book2I("nRecHits", fmt::sprintf("%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); + + toRep = "Number of all layers per track (quality #geq loose)"; + hnLayers_ = iBook.book2I("nLayers", fmt::sprintf("%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); + + toRep = "Track (quality #geq loose) #chi^{2}/ndof"; + hchi2_ = iBook.book2I("nChi2ndof", fmt::sprintf("%s;Reference;Target",toRep), 40, 0., 20., 40, 0., 20.); + + toRep = "Track (quality #geq loose) charge"; + hCharge_ = iBook.book2I("charge",fmt::sprintf("%s;Reference;Target",toRep),3, -1.5, 1.5, 3, -1.5, 1.5); + + hpt_ = iBook.book2I("pt", "Track (quality #geq loose) p_{T} [GeV];Reference;Target", 200, 0., 200., 200, 0., 200.); + hptLogLog_ = make2DIfLog(iBook, true, true, "ptLogLog", "Track (quality #geq loose) p_{T} [GeV];Reference;Target", 200, log10(0.5), log10(200.), 200, log10(0.5), log10(200.)); + heta_ = iBook.book2I("eta", "Track (quality #geq loose) #eta;Reference;Target", 30, -3., 3., 30, -3., 3.); + hphi_ = iBook.book2I("phi", "Track (quality #geq loose) #phi;Reference;Target", 30, -M_PI, M_PI, 30, -M_PI, M_PI); + hz_ = iBook.book2I("z", "Track (quality #geq loose) z [cm];Reference;Target", 30, -30., 30., 30, -30., 30.); + htip_ = iBook.book2I("tip", "Track (quality #geq loose) TIP [cm];Reference;Target", 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.); + hCurvdiffMatched_ = iBook.book1D("curvdiffmatched", "q/p_{T} diff [GeV] between matched tracks; #Delta q/p_{T} [GeV]", 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); + htipdiffMatched_ = iBook.book1D("tipdiffmatched", " TIP diff between matched tracks; #Delta TIP [cm]", 300, -1.5, 1.5); + //2D plots for eff + hpt_eta_tkAllRef_ = iBook.book2I("ptetatrkAllReference", "Track (quality #geq loose) on Reference; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); + hpt_eta_tkAllRefMatched_ = iBook.book2I("ptetatrkAllReferencematched", "Track (quality #geq loose) on Reference matched to Target track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); + + hphi_z_tkAllRef_ = iBook.book2I("phiztrkAllReference", "Track (quality #geq loose) on Reference; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); + hphi_z_tkAllRefMatched_ = iBook.book2I("phiztrkAllReferencematched", "Track (quality #geq loose) on Reference; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); + +} + +template +void SiPixelCompareTracks::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // monitorpixelTrackSoA + edm::ParameterSetDescription desc; + // The default case for the comparison is still CUDA vs CUDA; the {Reference|Target}Alpaka + // input tags are set with "placeholders"; the specific tags for the other comparisons are defined + // in DQM/SiPixelHeterogeneous/python/SiPixelHeterogeneousDQM_FirstStep_cff.py + desc.add("pixelTrackReferenceCUDA", edm::InputTag("pixelTracksSoA@cpu")); + desc.add("pixelTrackTargetCUDA", edm::InputTag("pixelTracksSoA@cuda")); + desc.add("pixelTrackReferenceSoA", edm::InputTag("pixelTracksSoA@cpu")); + desc.add("pixelTrackTargetSoA", edm::InputTag("pixelTracksSoA@cpu")); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU"); + desc.add("useQualityCut", true); + desc.add("minQuality", "loose"); + desc.add("deltaR2cut", 0.04); + desc.add("case", "CUDA"); + descriptions.addWithDefaultLabel(desc); +} + +// TODO: change module names to SiPixel*CompareTracksSoA when CUDA code is removed + +using SiPixelPhase1CompareTracks = SiPixelCompareTracks; +using SiPixelPhase2CompareTracks = SiPixelCompareTracks; +using SiPixelHIonPhase1CompareTracks = SiPixelCompareTracks; + +DEFINE_FWK_MODULE(SiPixelPhase1CompareTracks); +DEFINE_FWK_MODULE(SiPixelPhase2CompareTracks); +DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareTracks); + diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc deleted file mode 100644 index 2eea6a980d9c5..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc +++ /dev/null @@ -1,186 +0,0 @@ -// -*- C++ -*- -// Package: SiPixelCompareVertexSoAAlpaka -// Class: SiPixelCompareVertexSoAAlpaka -// -/**\class SiPixelCompareVertexSoAAlpaka SiPixelCompareVertexSoAAlpaka.cc -*/ -// -// Author: Suvankar Roy Chowdhury -// -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.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 "DataFormats/VertexSoA/interface/ZVertexHost.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" - -class SiPixelCompareVertexSoAAlpaka : public DQMEDAnalyzer { -public: - using IndToEdm = std::vector; - explicit SiPixelCompareVertexSoAAlpaka(const edm::ParameterSet&); - ~SiPixelCompareVertexSoAAlpaka() 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 tokenSoAVertexHost_; - const edm::EDGetTokenT tokenSoAVertexDevice_; - 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* hxdiff_; - MonitorElement* hydiff_; - MonitorElement* hzdiff_; -}; - -// -// constructors -// - -// Note tokenSoAVertexDevice_ contains data copied from device to host, hence is a HostCollection -SiPixelCompareVertexSoAAlpaka::SiPixelCompareVertexSoAAlpaka(const edm::ParameterSet& iConfig) - : tokenSoAVertexHost_(consumes(iConfig.getParameter("pixelVertexSrcHost"))), - tokenSoAVertexDevice_(consumes(iConfig.getParameter("pixelVertexSrcDevice"))), - tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), - topFolderName_(iConfig.getParameter("topFolderName")), - dzCut_(iConfig.getParameter("dzCut")) {} - -// -// -- Analyze -// -void SiPixelCompareVertexSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& vsoaHandleHost = iEvent.getHandle(tokenSoAVertexHost_); - const auto& vsoaHandleDevice = iEvent.getHandle(tokenSoAVertexDevice_); - if (not vsoaHandleHost or not vsoaHandleDevice) { - edm::LogWarning out("SiPixelCompareVertexSoAAlpaka"); - if (not vsoaHandleHost) { - out << "reference (cpu) tracks not found; "; - } - if (not vsoaHandleDevice) { - out << "target (gpu) tracks not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& vsoaHost = *vsoaHandleHost; - int nVerticesHost = vsoaHost.view().nvFinal(); - auto const& vsoaDevice = *vsoaHandleDevice; - int nVerticesDevice = vsoaDevice.view().nvFinal(); - - auto bsHandle = iEvent.getHandle(tokenBeamSpot_); - float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.; - if (!bsHandle.isValid()) { - edm::LogWarning("SiPixelCompareVertexSoAAlpaka") << "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 < nVerticesHost; ivc++) { - auto sic = vsoaHost.view()[ivc].sortInd(); - auto zc = vsoaHost.view()[sic].zv(); - auto xc = x0 + dxdz * zc; - auto yc = y0 + dydz * zc; - zc += z0; - - auto ndofHost = vsoaHost.view()[sic].ndof(); - auto chi2Host = vsoaHost.view()[sic].chi2(); - - const int32_t notFound = -1; - int32_t closestVtxidx = notFound; - float mindz = dzCut_; - - for (int ivg = 0; ivg < nVerticesDevice; ivg++) { - auto sig = vsoaDevice.view()[ivg].sortInd(); - auto zgc = vsoaDevice.view()[sig].zv() + z0; - auto zDist = std::abs(zc - zgc); - //insert some matching condition - if (zDist > dzCut_) - continue; - if (mindz > zDist) { - mindz = zDist; - closestVtxidx = sig; - } - } - if (closestVtxidx == notFound) - continue; - - auto zg = vsoaDevice.view()[closestVtxidx].zv(); - auto xg = x0 + dxdz * zg; - auto yg = y0 + dydz * zg; - zg += z0; - auto ndofDevice = vsoaDevice.view()[closestVtxidx].ndof(); - auto chi2Device = vsoaDevice.view()[closestVtxidx].chi2(); - - hx_->Fill(xc - x0, xg - x0); - hy_->Fill(yc - y0, yg - y0); - hz_->Fill(zc, zg); - hxdiff_->Fill(xc - xg); - hydiff_->Fill(yc - yg); - hzdiff_->Fill(zc - zg); - hchi2_->Fill(chi2Host, chi2Device); - hchi2oNdof_->Fill(chi2Host / ndofHost, chi2Device / ndofDevice); - hptv2_->Fill(vsoaHost.view()[sic].ptv2(), vsoaDevice.view()[closestVtxidx].ptv2()); - hntrks_->Fill(ndofHost + 1, ndofDevice + 1); - } - hnVertex_->Fill(nVerticesHost, nVerticesDevice); -} - -// -// -- Book Histograms -// -void SiPixelCompareVertexSoAAlpaka::bookHistograms(DQMStore::IBooker& ibooker, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - 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.book2I("nVertex", "# of Vertices;Host;Device", 101, -0.5, 100.5, 101, -0.5, 100.5); - hx_ = ibooker.book2I("vx", "Vertez x - Beamspot x;Host;Device", 50, -0.1, 0.1, 50, -0.1, 0.1); - hy_ = ibooker.book2I("vy", "Vertez y - Beamspot y;Host;Device", 50, -0.1, 0.1, 50, -0.1, 0.1); - hz_ = ibooker.book2I("vz", "Vertez z;Host;Device", 30, -30., 30., 30, -30., 30.); - hchi2_ = ibooker.book2I("chi2", "Vertex chi-squared;Host;Device", 40, 0., 20., 40, 0., 20.); - hchi2oNdof_ = ibooker.book2I("chi2oNdof", "Vertex chi-squared/Ndof;Host;Device", 40, 0., 20., 40, 0., 20.); - hptv2_ = ibooker.book2I("ptsq", "Vertex #sum (p_{T})^{2};Host;Device", 200, 0., 200., 200, 0., 200.); - hntrks_ = ibooker.book2I("ntrk", "#tracks associated;Host;Device", 100, -0.5, 99.5, 100, -0.5, 99.5); - hntrks_ = ibooker.book2I("ntrk", "#tracks associated;Host;Device", 100, -0.5, 99.5, 100, -0.5, 99.5); - hxdiff_ = ibooker.book1D("vxdiff", ";Vertex x difference (Host - Device);#entries", 100, -0.001, 0.001); - hydiff_ = ibooker.book1D("vydiff", ";Vertex y difference (Host - Device);#entries", 100, -0.001, 0.001); - hzdiff_ = ibooker.book1D("vzdiff", ";Vertex z difference (Host - Device);#entries", 100, -2.5, 2.5); -} - -void SiPixelCompareVertexSoAAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelVertexSoA - edm::ParameterSetDescription desc; - desc.add("pixelVertexSrcHost", edm::InputTag("pixelVerticesAlpakaSerial")); - desc.add("pixelVertexSrcDevice", edm::InputTag("pixelVerticesAlpaka")); - desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoADeviceVSHost"); - desc.add("dzCut", 1.); - descriptions.addWithDefaultLabel(desc); -} - -DEFINE_FWK_MODULE(SiPixelCompareVertexSoAAlpaka); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertices.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertices.cc new file mode 100644 index 0000000000000..6b3f80f447db5 --- /dev/null +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertices.cc @@ -0,0 +1,228 @@ +// TODO: change file name to SiPixelCompareVerticesSoA.cc when CUDA code is removed + +// -*- C++ -*- +// Package: SiPixelCompareVertices +// Class: SiPixelCompareVertices +// +/**\class SiPixelCompareVertices SiPixelCompareVertices.cc +*/ +// +// Author: Suvankar Roy Chowdhury +// +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.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 "DataFormats/VertexSoA/interface/ZVertexHost.h" +#include "CUDADataFormats/Vertex/interface/ZVertexSoAHeterogeneousHost.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" + +// TODO: change class name to SiPixelCompareVerticesSoA when CUDA code is removed +class SiPixelCompareVertices : public DQMEDAnalyzer { +public: + using IndToEdm = std::vector; + explicit SiPixelCompareVertices(const edm::ParameterSet&); + ~SiPixelCompareVertices() 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; + // TODO: remove analyzeSeparate function below once the CUDA code is removed from CMSSW; it was implemented + // to make the DQM compare modules work for every case: CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; + // the content of analyzeSeparate can be copied to analyze once the CUDA code is removed + template + void analyzeSeparate(U tokenRef, V tokenTar, const edm::Event& iEvent); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + // CUDA and Alpaka tokens are implemented to make the DQM compare modules work for every case: + // CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; CUDA tokens must be removed together with rest of CUDA code + const edm::EDGetTokenT + tokenSoAVertexReferenceCUDA_; //these two are both on CPU but originally they have been + const edm::EDGetTokenT tokenSoAVertexTargetCUDA_; //produced on CPU or on GPU + const edm::EDGetTokenT + tokenSoAVertexReferenceSoA_; //these two are both on Host but originally they have been + const edm::EDGetTokenT tokenSoAVertexTargetSoA_; //produced on Host or on Device + const edm::EDGetTokenT tokenBeamSpot_; + const std::string topFolderName_; + const float dzCut_; + // String case_ is used to differentiate between different comparisons; must be removed together with rest of CUDA code + const std::string case_; + MonitorElement* hnVertex_; + MonitorElement* hx_; + MonitorElement* hy_; + MonitorElement* hz_; + MonitorElement* hchi2_; + MonitorElement* hchi2oNdof_; + MonitorElement* hptv2_; + MonitorElement* hntrks_; + MonitorElement* hxdiff_; + MonitorElement* hydiff_; + MonitorElement* hzdiff_; +}; + +// +// constructors +// + +SiPixelCompareVertices::SiPixelCompareVertices(const edm::ParameterSet& iConfig) + : tokenSoAVertexReferenceCUDA_( + consumes(iConfig.getParameter("pixelVertexReferenceCUDA"))), + tokenSoAVertexTargetCUDA_(consumes(iConfig.getParameter("pixelVertexTargetCUDA"))), + tokenSoAVertexReferenceSoA_( + consumes(iConfig.getParameter("pixelVertexReferenceSoA"))), + tokenSoAVertexTargetSoA_(consumes(iConfig.getParameter("pixelVertexTargetSoA"))), + tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), + topFolderName_(iConfig.getParameter("topFolderName")), + dzCut_(iConfig.getParameter("dzCut")), + case_(iConfig.getParameter("case")) {} + +template +void SiPixelCompareVertices::analyzeSeparate(U tokenRef, V tokenTar, const edm::Event& iEvent) { + const auto& vsoaHandleRef = iEvent.getHandle(tokenRef); + const auto& vsoaHandleTar = iEvent.getHandle(tokenTar); + + if (not vsoaHandleRef or not vsoaHandleTar) { + edm::LogWarning out("SiPixelCompareVertices"); + if (not vsoaHandleRef) { + out << "reference vertices not found; "; + } + if (not vsoaHandleTar) { + out << "Refget vertices not found; "; + } + out << "the comparison will not run."; + return; + } + + auto const& vsoaRef = *vsoaHandleRef; + int nVerticesRef = vsoaRef.view().nvFinal(); + auto const& vsoaTar = *vsoaHandleTar; + int nVerticesTar = vsoaTar.view().nvFinal(); + + auto bsHandle = iEvent.getHandle(tokenBeamSpot_); + float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.; + if (!bsHandle.isValid()) { + edm::LogWarning("SiPixelCompareVertices") << "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 < nVerticesRef; ivc++) { + auto sic = vsoaRef.view()[ivc].sortInd(); + auto zc = vsoaRef.view()[sic].zv(); + auto xc = x0 + dxdz * zc; + auto yc = y0 + dydz * zc; + zc += z0; + + auto ndofRef = vsoaRef.view()[sic].ndof(); + auto chi2Ref = vsoaRef.view()[sic].chi2(); + + const int32_t notFound = -1; + int32_t closestVtxidx = notFound; + float mindz = dzCut_; + + for (int ivg = 0; ivg < nVerticesTar; ivg++) { + auto sig = vsoaTar.view()[ivg].sortInd(); + auto zgc = vsoaTar.view()[sig].zv() + z0; + auto zDist = std::abs(zc - zgc); + //insert some matching condition + if (zDist > dzCut_) + continue; + if (mindz > zDist) { + mindz = zDist; + closestVtxidx = sig; + } + } + if (closestVtxidx == notFound) + continue; + + auto zg = vsoaTar.view()[closestVtxidx].zv(); + auto xg = x0 + dxdz * zg; + auto yg = y0 + dydz * zg; + zg += z0; + auto ndofTar = vsoaTar.view()[closestVtxidx].ndof(); + auto chi2Tar = vsoaTar.view()[closestVtxidx].chi2(); + + hx_->Fill(xc - x0, xg - x0); + hy_->Fill(yc - y0, yg - y0); + hz_->Fill(zc, zg); + hxdiff_->Fill(xc - xg); + hydiff_->Fill(yc - yg); + hzdiff_->Fill(zc - zg); + hchi2_->Fill(chi2Ref, chi2Tar); + hchi2oNdof_->Fill(chi2Ref / ndofRef, chi2Tar / ndofTar); + hptv2_->Fill(vsoaRef.view()[sic].ptv2(), vsoaTar.view()[closestVtxidx].ptv2()); + hntrks_->Fill(ndofRef + 1, ndofTar + 1); + } + hnVertex_->Fill(nVerticesRef, nVerticesTar); +} + +// +// -- Analyze +// +void SiPixelCompareVertices::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + // TODO: remove analyzeSeparate function below once the CUDA code is removed from CMSSW; it was implemented + // to make the DQM compare modules work for every case: CUDA vs CUDA, Alpaka vs Alpaka and Alpaka vs CUDA; + // the content of analyzeSeparate can be copied to analyze once the CUDA code is removed + if (case_ == "CUDA") + analyzeSeparate(tokenSoAVertexReferenceCUDA_, tokenSoAVertexTargetCUDA_, iEvent); + if (case_ == "Alpaka") + analyzeSeparate(tokenSoAVertexReferenceSoA_, tokenSoAVertexTargetSoA_, iEvent); + if (case_ == "AlpakavsCUDA") + analyzeSeparate(tokenSoAVertexReferenceSoA_, tokenSoAVertexTargetCUDA_, iEvent); +} + +// +// -- Book Histograms +// +void SiPixelCompareVertices::bookHistograms(DQMStore::IBooker& ibooker, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + 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.book2I("nVertex", "# of Vertices;Reference;Target", 101, -0.5, 100.5, 101, -0.5, 100.5); + hx_ = ibooker.book2I("vx", "Vertez x - Beamspot x;Reference;Target", 50, -0.1, 0.1, 50, -0.1, 0.1); + hy_ = ibooker.book2I("vy", "Vertez y - Beamspot y;Reference;Target", 50, -0.1, 0.1, 50, -0.1, 0.1); + hz_ = ibooker.book2I("vz", "Vertez z;Reference;Target", 30, -30., 30., 30, -30., 30.); + hchi2_ = ibooker.book2I("chi2", "Vertex chi-squared;Reference;Target", 40, 0., 20., 40, 0., 20.); + hchi2oNdof_ = ibooker.book2I("chi2oNdof", "Vertex chi-squared/Ndof;Reference;Target", 40, 0., 20., 40, 0., 20.); + hptv2_ = ibooker.book2I("ptsq", "Vertex #sum (p_{T})^{2};Reference;Target", 200, 0., 200., 200, 0., 200.); + hntrks_ = ibooker.book2I("ntrk", "#tracks associated;Reference;Target", 100, -0.5, 99.5, 100, -0.5, 99.5); + hntrks_ = ibooker.book2I("ntrk", "#tracks associated;Reference;Target", 100, -0.5, 99.5, 100, -0.5, 99.5); + hxdiff_ = ibooker.book1D("vxdiff", ";Vertex x difference (Reference - Target);#entries", 100, -0.001, 0.001); + hydiff_ = ibooker.book1D("vydiff", ";Vertex y difference (Reference - Target);#entries", 100, -0.001, 0.001); + hzdiff_ = ibooker.book1D("vzdiff", ";Vertex z difference (Reference - Target);#entries", 100, -2.5, 2.5); +} + +void SiPixelCompareVertices::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // monitorpixelVertexSoA + edm::ParameterSetDescription desc; + // The default case for the comparison is still CUDA vs CUDA; the {Reference|Target}Alpaka + // input tags are set with "placeholders"; the specific tags for the other comparisons are defined + // in DQM/SiPixelHeterogeneous/python/SiPixelHeterogeneousDQM_FirstStep_cff.py + desc.add("pixelVertexReferenceSoA", edm::InputTag("pixelVerticesSoA@cpu")); + desc.add("pixelVertexReferenceCUDA", edm::InputTag("pixelVerticesSoA@cpu")); + desc.add("pixelVertexTargetSoA", edm::InputTag("pixelVerticesSoA@cpu")); + desc.add("pixelVertexTargetCUDA", edm::InputTag("pixelVerticesSoA@cuda")); + desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareGPUvsCPU"); + desc.add("dzCut", 1.); + desc.add("case", "CUDA"); + descriptions.addWithDefaultLabel(desc); +} + +// TODO: change module name to SiPixelCompareVerticesSoA when CUDA code is removed +DEFINE_FWK_MODULE(SiPixelCompareVertices); diff --git a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py index 95245a3fea968..c53b3ffeabc44 100644 --- a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py @@ -39,23 +39,15 @@ #Define the sequence for GPU vs CPU validation #This should run:- individual monitor for the 2 collections + comparison module -from DQM.SiPixelHeterogeneous.siPixelPhase1CompareRecHitsSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase2CompareRecHitsSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelHIonPhase1CompareRecHitsSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase1CompareTrackSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase2CompareTrackSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelHIonPhase1CompareTrackSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelCompareVertexSoA_cfi import * +from DQM.SiPixelHeterogeneous.siPixelPhase1CompareRecHits_cfi import* +from DQM.SiPixelHeterogeneous.siPixelPhase2CompareRecHits_cfi import* +from DQM.SiPixelHeterogeneous.siPixelHIonPhase1CompareRecHits_cfi import* +from DQM.SiPixelHeterogeneous.siPixelPhase1CompareTracks_cfi import * +from DQM.SiPixelHeterogeneous.siPixelPhase2CompareTracks_cfi import * +from DQM.SiPixelHeterogeneous.siPixelHIonPhase1CompareTracks_cfi import * +from DQM.SiPixelHeterogeneous.siPixelCompareVertices_cfi import * from DQM.SiPixelHeterogeneous.siPixelPhase1RawDataErrorComparator_cfi import * from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import * -#Alpaka -from DQM.SiPixelHeterogeneous.siPixelPhase1CompareRecHitsSoAAlpaka_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase2CompareRecHitsSoAAlpaka_cfi import * -from DQM.SiPixelHeterogeneous.siPixelHIonPhase1CompareRecHitsSoAAlpaka_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase1CompareTrackSoAAlpaka_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase2CompareTrackSoAAlpaka_cfi import * -from DQM.SiPixelHeterogeneous.siPixelHIonPhase1CompareTrackSoAAlpaka_cfi import * -from DQM.SiPixelHeterogeneous.siPixelCompareVertexSoAAlpaka_cfi import * # digi errors SiPixelPhase1RawDataConfForCPU = copy.deepcopy(SiPixelPhase1RawDataConf) @@ -151,6 +143,25 @@ ### Alpaka +# digi errors +SiPixelPhase1RawDataConfForSerial = copy.deepcopy(SiPixelPhase1RawDataConf) +for pset in SiPixelPhase1RawDataConfForSerial: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsSerial" + +siPixelPhase1MonitorRawDataASerial = SiPixelPhase1RawDataAnalyzer.clone( + src = "siPixelDigiErrorsAlpakaSerial", + histograms = SiPixelPhase1RawDataConfForSerial +) + +SiPixelPhase1RawDataConfForDevice = copy.deepcopy(SiPixelPhase1RawDataConf) +for pset in SiPixelPhase1RawDataConfForDevice: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsDevice" + +siPixelPhase1MonitorRawDataADevice = SiPixelPhase1RawDataAnalyzer.clone( + src = "siPixelDigiErrorsAlpaka", + histograms = SiPixelPhase1RawDataConfForDevice +) + # PixelRecHits: monitor of CPUSerial product (Alpaka backend: 'serial_sync') siPixelRecHitsSoAMonitorSerial = siPixelPhase1MonitorRecHitsSoAAlpaka.clone( pixelHitsSrc = cms.InputTag( 'siPixelRecHitsPreSplittingAlpakaSerial' ), @@ -186,21 +197,107 @@ topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexDevice') ) +siPixelPhase1CompareDigiErrorsSoAAlpaka = siPixelPhase1RawDataErrorComparator.clone( + pixelErrorSrcGPU = cms.InputTag("siPixelDigiErrorsAlpaka"), + pixelErrorSrcCPU = cms.InputTag("siPixelDigiErrorsAlpakaSerial"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelErrorCompareDeviceVSHost') +) + +siPixelPhase1CompareRecHitsSoAAlpaka = siPixelPhase1CompareRecHits.clone( + topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareDeviceVSHost'), + pixelHitsReferenceSoA = cms.InputTag("siPixelRecHitsPreSplittingAlpakaSerial"), + pixelHitsTargetSoA = cms.InputTag("siPixelRecHitsPreSplittingAlpaka"), + case = cms.string("Alpaka"), +) + +siPixelPhase1CompareTrackSoAAlpaka = siPixelPhase1CompareTracks.clone( + pixelTrackReferenceSoA = cms.InputTag("pixelTracksAlpakaSerial"), + pixelTrackTargetSoA = cms.InputTag("pixelTracksAlpaka"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareDeviceVSHost'), + case = cms.string("Alpaka"), +) + +siPixelCompareVertexSoAAlpaka = siPixelCompareVertices.clone( + pixelVertexReferenceSoA = cms.InputTag("pixelVerticesAlpakaSerial"), + pixelVertexTargetSoA = cms.InputTag("pixelVerticesAlpaka"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareSoADeviceVSHost'), + case = cms.string("Alpaka") +) + +### Alpaka vs CUDA + +siPixelPhase1CompareDigiErrorsSoAAlpakavsCUDACPU = siPixelPhase1RawDataErrorComparator.clone( + pixelErrorSrcGPU = cms.InputTag("siPixelDigis@cpu"), + pixelErrorSrcCPU = cms.InputTag("siPixelDigiErrorsAlpakaSerial"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelErrorCompareAlpakavsCUDASerial') +) + +siPixelPhase1CompareDigiErrorsSoAAlpakavsCUDAGPU = siPixelPhase1RawDataErrorComparator.clone( + pixelErrorSrcGPU = cms.InputTag("siPixelDigis@cuda"), + pixelErrorSrcCPU = cms.InputTag("siPixelDigiErrorsAlpaka"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelErrorCompareAlpakavsCUDADevice') +) + +siPixelPhase1CompareRecHitsSoAAlpakavsCUDACPU = siPixelPhase1CompareRecHits.clone( + topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareAlpakavsCUDASerial'), + pixelHitsReferenceSoA = cms.InputTag("siPixelRecHitsPreSplittingAlpakaSerial"), + pixelHitsTargetCUDA = cms.InputTag("siPixelRecHitsPreSplittingSoA@cpu"), + case = cms.string("AlpakavsCUDA"), +) + +siPixelPhase1CompareRecHitsSoAAlpakavsCUDAGPU = siPixelPhase1CompareRecHits.clone( + topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareAlpakavsCUDADevice'), + pixelHitsReferenceSoA = cms.InputTag("siPixelRecHitsPreSplittingAlpaka"), + pixelHitsTargetCUDA = cms.InputTag("siPixelRecHitsPreSplittingSoA@cuda"), + case = cms.string("AlpakavsCUDA"), +) + +siPixelPhase1CompareTrackSoAAlpakavsCUDACPU = siPixelPhase1CompareTracks.clone( + pixelTrackReferenceSoA = cms.InputTag("pixelTracksAlpakaSerial"), + pixelTrackTargetCUDA = cms.InputTag("pixelTracksSoA@cpu"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareAlpakavsCUDASerial'), + case = cms.string("AlpakavsCUDA"), +) + +siPixelPhase1CompareTrackSoAAlpakavsCUDAGPU = siPixelPhase1CompareTracks.clone( + pixelTrackReferenceSoA = cms.InputTag("pixelTracksAlpaka"), + pixelTrackTargetCUDA = cms.InputTag("pixelTracksSoA@cuda"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareAlpakavsCUDADevice'), + case = cms.string("AlpakavsCUDA"), +) + +siPixelCompareVertexSoAAlpakavsCUDACPU = siPixelCompareVertices.clone( + pixelVertexReferenceSoA = cms.InputTag("pixelVerticesAlpakaSerial"), + pixelVertexTargetCUDA = cms.InputTag("pixelVerticesSoA@cpu"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareAlpakavsCUDASerial'), + case = cms.string("AlpakavsCUDA") +) + +siPixelCompareVertexSoAAlpakavsCUDAGPU = siPixelCompareVertices.clone( + pixelVertexReferenceSoA = cms.InputTag("pixelVerticesAlpaka"), + pixelVertexTargetCUDA = cms.InputTag("pixelVerticesSoA@cuda"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareAlpakavsCUDADevice'), + case = cms.string("AlpakavsCUDA") +) + # Run-3 sequence monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorRawDataACPU * siPixelPhase1MonitorRawDataAGPU * siPixelPhase1MonitorRecHitsSoACPU * siPixelPhase1MonitorRecHitsSoAGPU * - siPixelPhase1CompareRecHitsSoA * + siPixelPhase1CompareRecHits * siPixelPhase1MonitorTrackSoAGPU * siPixelPhase1MonitorTrackSoACPU * - siPixelPhase1CompareTrackSoA * + siPixelPhase1CompareTracks * siPixelMonitorVertexSoACPU * siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA * + siPixelCompareVertices * siPixelPhase1RawDataErrorComparator) # and the Alpaka version monitorpixelSoACompareSourceAlpaka = cms.Sequence( + siPixelPhase1MonitorRawDataASerial * + siPixelPhase1MonitorRawDataADevice * + siPixelPhase1CompareDigiErrorsSoAAlpaka * siPixelRecHitsSoAMonitorSerial * siPixelRecHitsSoAMonitorDevice * siPixelPhase1CompareRecHitsSoAAlpaka * @@ -214,24 +311,62 @@ # Phase-2 sequence _monitorpixelSoACompareSource = cms.Sequence(siPixelPhase2MonitorRecHitsSoACPU * siPixelPhase2MonitorRecHitsSoAGPU * - siPixelPhase2CompareRecHitsSoA * + siPixelPhase2CompareRecHits * siPixelPhase2MonitorTrackSoAGPU * siPixelPhase2MonitorTrackSoACPU * - siPixelPhase2CompareTrackSoA * + siPixelPhase2CompareTracks * siPixelMonitorVertexSoACPU * siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA) + siPixelCompareVertices) # HIon sequence _monitorpixelSoACompareSourceHIonPhase1 = cms.Sequence(siPixelHIonPhase1MonitorRecHitsSoACPU * siPixelHIonPhase1MonitorRecHitsSoAGPU * - siPixelHIonPhase1CompareRecHitsSoA * + siPixelHIonPhase1CompareRecHits * siPixelHIonPhase1MonitorTrackSoAGPU * siPixelHIonPhase1MonitorTrackSoACPU * - siPixelHIonPhase1CompareTrackSoA * + siPixelHIonPhase1CompareTracks * siPixelMonitorVertexSoACPU * siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA) + siPixelCompareVertices) + +# Alpaka vs CUDA +monitorpixelSoACompareSourceAlpakaCUDA = cms.Sequence( + # CUDA objects + siPixelPhase1MonitorRawDataACPU * + siPixelPhase1MonitorRawDataAGPU * + siPixelPhase1RawDataErrorComparator * + siPixelPhase1MonitorRecHitsSoACPU * + siPixelPhase1MonitorRecHitsSoAGPU * + siPixelPhase1CompareRecHits * + siPixelPhase1MonitorTrackSoAGPU * + siPixelPhase1MonitorTrackSoACPU * + siPixelPhase1CompareTracks * + siPixelMonitorVertexSoACPU * + siPixelMonitorVertexSoAGPU * + siPixelCompareVertices * + # Alpaka objects + siPixelPhase1MonitorRawDataASerial * + siPixelPhase1MonitorRawDataADevice * + siPixelPhase1CompareDigiErrorsSoAAlpaka * + siPixelRecHitsSoAMonitorSerial * + siPixelRecHitsSoAMonitorDevice * + siPixelPhase1CompareRecHitsSoAAlpaka * + siPixelTrackSoAMonitorSerial * + siPixelTrackSoAMonitorDevice * + siPixelPhase1CompareTrackSoAAlpaka * + siPixelVertexSoAMonitorSerial * + siPixelVertexSoAMonitorDevice * + siPixelCompareVertexSoAAlpaka * + # Alpaka vs CUDA + siPixelPhase1CompareDigiErrorsSoAAlpakavsCUDACPU * + siPixelPhase1CompareDigiErrorsSoAAlpakavsCUDAGPU * + siPixelPhase1CompareRecHitsSoAAlpakavsCUDACPU * + siPixelPhase1CompareRecHitsSoAAlpakavsCUDAGPU * + siPixelPhase1CompareTrackSoAAlpakavsCUDACPU * + siPixelPhase1CompareTrackSoAAlpakavsCUDAGPU * + siPixelCompareVertexSoAAlpakavsCUDACPU * + siPixelCompareVertexSoAAlpakavsCUDAGPU) phase2_tracker.toReplaceWith(monitorpixelSoACompareSource,_monitorpixelSoACompareSource) @@ -240,3 +375,6 @@ from Configuration.ProcessModifiers.alpakaValidationPixel_cff import alpakaValidationPixel (alpakaValidationPixel & ~gpuValidationPixel).toReplaceWith(monitorpixelSoASource, monitorpixelSoACompareSourceAlpaka) + +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel +(alpakaCUDAValidationPixel & ~gpuValidationPixel).toReplaceWith(monitorpixelSoASource, monitorpixelSoACompareSourceAlpakaCUDA) diff --git a/DataFormats/TrackSoA/interface/TrackDefinitions.h b/DataFormats/TrackSoA/interface/TrackDefinitions.h index 682f1ec72bfb8..031a25ca80834 100644 --- a/DataFormats/TrackSoA/interface/TrackDefinitions.h +++ b/DataFormats/TrackSoA/interface/TrackDefinitions.h @@ -7,30 +7,30 @@ namespace reco { namespace pixelTrack { - + enum class Quality : uint8_t { bad = 0, edup, dup, loose, strict, tight, highPurity, notQuality }; constexpr uint32_t qualitySize{uint8_t(Quality::notQuality)}; constexpr std::string_view qualityName[qualitySize]{"bad", "edup", "dup", "loose", "strict", "tight", "highPurity"}; inline Quality qualityByName(std::string_view name) { auto qp = std::find(qualityName, qualityName + qualitySize, name) - qualityName; auto ret = static_cast(qp); - + if (ret == pixelTrack::Quality::notQuality) throw std::invalid_argument(std::string(name) + " is not a pixelTrack::Quality!"); - + return ret; } - - #ifdef GPU_SMALL_EVENTS + +#ifdef GPU_SMALL_EVENTS // kept for testing and debugging constexpr uint32_t maxNumber() { return 2 * 1024; } - #else +#else // tested on MC events with 55-75 pileup events constexpr uint32_t maxNumber() { return 32 * 1024; } - #endif - +#endif + } // namespace pixelTrack -} +} // namespace reco #endif diff --git a/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h b/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h index 918a8036c852f..c6d0684d9692b 100644 --- a/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h +++ b/DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h @@ -143,9 +143,9 @@ namespace reco { float pt = std::min(tracks.pt(it), chi2MaxPt); float chi2Cut = chi2Scale * (chi2Coeff[0] + roughLog(pt) * chi2Coeff[1]); if (tracks.chi2(it) >= chi2Cut) { - #ifdef NTUPLE_FIT_DEBUG +#ifdef NTUPLE_FIT_DEBUG printf("Bad chi2 %d pt %f eta %f chi2 %f\n", it, tracks.pt(it), tracks.eta(it), tracks.chi2(it)); - #endif +#endif return true; } return false; @@ -177,6 +177,6 @@ namespace reco { template struct TracksUtilities; template struct TracksUtilities; -} +} // namespace reco #endif // DataFormats_TrackSoA_interface_alpaka_TrackUtilities_h diff --git a/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h b/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h index ea1ec138a36a3..c14648af9cd4d 100644 --- a/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h +++ b/DataFormats/TrackingRecHitSoA/interface/SiPixelHitStatus.h @@ -3,7 +3,7 @@ #include -namespace reco{ +namespace reco { // more information on bit fields : https://en.cppreference.com/w/cpp/language/bit_field struct SiPixelHitStatus { @@ -13,12 +13,12 @@ namespace reco{ bool isOneY : 1; // ∈[0,1] uint8_t qBin : 3; // ∈[0,1,...,7] }; - + struct SiPixelHitStatusAndCharge { SiPixelHitStatus status; uint32_t charge : 24; }; -} +} // namespace reco #endif diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h index 4b6fdb72b17df..340f3c78c079f 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h @@ -13,7 +13,7 @@ template class TrackingRecHitDevice : public PortableDeviceCollection, TDev> { public: using hitSoA = reco::TrackingRecHitSoA; - + //Need to decorate the class with the inherited portable accessors being now a template using PortableDeviceCollection, TDev>::view; using PortableDeviceCollection, TDev>::const_view; @@ -24,7 +24,8 @@ class TrackingRecHitDevice : public PortableDeviceCollection explicit TrackingRecHitDevice(TQueue queue, uint32_t nHits, int32_t offsetBPIX2, uint32_t const* hitsModuleStart) - : PortableDeviceCollection, TDev>(nHits, queue), offsetBPIX2_{offsetBPIX2} { + : PortableDeviceCollection, TDev>(nHits, queue), + offsetBPIX2_{offsetBPIX2} { const auto device = alpaka::getDev(queue); auto start_h = cms::alpakatools::make_host_view(hitsModuleStart, TrackerTraits::numberOfModules + 1); diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h index 43ab79ec72c3f..95f6a54b7a1ea 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h @@ -13,7 +13,7 @@ template class TrackingRecHitHost : public PortableHostCollection> { public: using hitSoA = reco::TrackingRecHitSoA; - + //Need to decorate the class with the inherited portable accessors being now a template using PortableHostCollection>::view; using PortableHostCollection>::const_view; diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h index 2b0e6154d43cb..7f2823f37e9ea 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h @@ -54,6 +54,6 @@ namespace reco { template using TrackingRecHitSoAConstView = typename TrackingRecHitSoA::template Layout<>::ConstView; -} +} // namespace reco #endif diff --git a/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc b/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc index b0032dfc97e1f..aba2178c05384 100644 --- a/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc +++ b/DataFormats/TrackingRecHitSoA/test/alpaka/Hits_test.dev.cc @@ -62,8 +62,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { alpaka::exec(queue, workDiv, ShowKernel{}, view); } - template void runKernels(reco::TrackingRecHitSoAView& view, Queue& queue); - template void runKernels(reco::TrackingRecHitSoAView& view, Queue& queue); + template void runKernels(reco::TrackingRecHitSoAView& view, + Queue& queue); + template void runKernels(reco::TrackingRecHitSoAView& view, + Queue& queue); } // namespace testTrackingRecHitSoA } // namespace ALPAKA_ACCELERATOR_NAMESPACE diff --git a/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py b/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py index f5139f1cb418b..683d07cae031d 100644 --- a/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py +++ b/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py @@ -23,12 +23,6 @@ from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA siPixelDigiErrors = _siPixelDigiErrorsFromSoA.clone() -# Alpaka modifier -from Configuration.ProcessModifiers.alpaka_cff import alpaka -from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoAAlpaka_cfi import siPixelDigiErrorsFromSoAAlpaka as _siPixelDigiErrorsFromSoAAlpaka - -alpaka.toReplaceWith(siPixelDigiErrors, _siPixelDigiErrorsFromSoAAlpaka.clone()) - # use the Phase 1 settings from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(siPixelDigiErrors, @@ -48,5 +42,17 @@ siPixelDigisTask.copy() )) +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel +alpakaCUDAValidationPixel.toReplaceWith(siPixelDigisTask, cms.Task( + # copy the pixel digis (except errors) and clusters to the host + siPixelDigisSoA, + # copy the pixel digis errors to the host + siPixelDigiErrorsSoA, + # convert the pixel digis errors to the legacy format + siPixelDigiErrors, + # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA + siPixelDigisTask.copy() +)) + # Remove siPixelDigis until we have phase2 pixel digis phase2_tracker.toReplaceWith(siPixelDigisTask, cms.Task()) #FIXME diff --git a/HLTrigger/Configuration/python/customizeHLTforAlpaka.py b/HLTrigger/Configuration/python/customizeHLTforAlpaka.py index d2e393568c4bd..22cf3025ac01a 100644 --- a/HLTrigger/Configuration/python/customizeHLTforAlpaka.py +++ b/HLTrigger/Configuration/python/customizeHLTforAlpaka.py @@ -2,6 +2,7 @@ from HeterogeneousCore.AlpakaCore.functions import * from HLTrigger.Configuration.common import * +import copy ## PF HLT in Alpaka def customizeHLTforAlpakaParticleFlowClustering(process): @@ -306,6 +307,35 @@ def customizeHLTforDQMGPUvsCPUPixel(process): except: pass + from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import SiPixelPhase1RawDataConf,SiPixelPhase1RawDataAnalyzer + + # PixelDigiErrors: monitor of CPUSerial product + SiPixelPhase1RawDataConfForSerial = copy.deepcopy(SiPixelPhase1RawDataConf) + for pset in SiPixelPhase1RawDataConfForSerial: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsSerial" + + process.hltPixelPhase1MonitorRawDataASerial = SiPixelPhase1RawDataAnalyzer.clone( + src = "hltSiPixelDigiErrorsLegacyFormatCPUSerial", + histograms = SiPixelPhase1RawDataConfForSerial + ) + + # PixelDigiErrors: monitor of GPU product + SiPixelPhase1RawDataConfForDevice = copy.deepcopy(SiPixelPhase1RawDataConf) + for pset in SiPixelPhase1RawDataConfForDevice: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsDevice" + + process.hltPixelPhase1MonitorRawDataADevice = SiPixelPhase1RawDataAnalyzer.clone( + src = "hltSiPixelDigis", + histograms = SiPixelPhase1RawDataConfForDevice + ) + + # PixelDigiErrors: 'GPUvsCPU' comparison + process.hltPixelDigiErrorsCompareGPUvsCPU = cms.EDProducer('SiPixelPhase1RawDataErrorComparator', + pixelErrorSrcCPU = cms.InputTag( 'hltSiPixelDigiErrorsLegacyFormatCPUSerial' ), + pixelErrorSrcGPU = cms.InputTag( 'hltSiPixelDigis' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelDigiErrorsCompareGPUvsCPU' ) + ) + # PixelRecHits: monitor of CPUSerial product (Alpaka backend: 'serial_sync') process.hltPixelRecHitsSoAMonitorCPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka', pixelHitsSrc = cms.InputTag('hltSiPixelRecHitsSoACPUSerial'), @@ -319,11 +349,12 @@ def customizeHLTforDQMGPUvsCPUPixel(process): ) # PixelRecHits: 'GPUvsCPU' comparisons - process.hltPixelRecHitsSoACompareGPUvsCPU = cms.EDProducer('SiPixelPhase1CompareRecHitsSoAAlpaka', - pixelHitsSrcHost = cms.InputTag('hltSiPixelRecHitsSoACPUSerial'), - pixelHitsSrcDevice = cms.InputTag('hltSiPixelRecHitsSoA'), - topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU'), - minD2cut = cms.double(1.0e-4) + process.hltPixelRecHitsSoACompareGPUvsCPU = cms.EDProducer('SiPixelPhase1CompareRecHits', + pixelHitsReferenceSoA = cms.InputTag( 'hltSiPixelRecHitsCPUSerial' ), + pixelHitsTargetSoA = cms.InputTag( 'hltSiPixelRecHitsSoA' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU' ), + minD2cut = cms.double( 1.0E-4 ), + case = cms.string('Alpaka') ) process.hltPixelTracksSoAMonitorCPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka", @@ -340,13 +371,14 @@ def customizeHLTforDQMGPUvsCPUPixel(process): useQualityCut = cms.bool(True) ) - process.hltPixelTracksSoACompareGPUvsCPU = cms.EDProducer("SiPixelPhase1CompareTrackSoAAlpaka", + process.hltPixelTracksSoACompareGPUvsCPU = cms.EDProducer("SiPixelPhase1CompareTracks", deltaR2cut = cms.double(0.04), minQuality = cms.string('loose'), - pixelTrackSrcHost = cms.InputTag("hltPixelTracksSoACPUSerial"), - pixelTrackSrcDevice = cms.InputTag("hltPixelTracksSoA"), + pixelTrackReferenceSoA = cms.InputTag("hltPixelTracksCPUSerial"), + pixelTrackTargetSoA = cms.InputTag("hltPixelTracksSoA"), topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU'), - useQualityCut = cms.bool(True) + useQualityCut = cms.bool(True), + case = cms.string('Alpaka') ) process.hltPixelVertexSoAMonitorCPU = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka", @@ -361,16 +393,20 @@ def customizeHLTforDQMGPUvsCPUPixel(process): topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexGPU') ) - process.hltPixelVertexSoACompareGPUvsCPU = cms.EDProducer("SiPixelCompareVertexSoAAlpaka", + process.hltPixelVertexSoACompareGPUvsCPU = cms.EDProducer("SiPixelCompareVertices", beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), dzCut = cms.double(1), - pixelVertexSrcHost = cms.InputTag("hltPixelVerticesSoACPUSerial"), - pixelVertexSrcDevice = cms.InputTag("hltPixelVerticesSoA"), - topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareGPUvsCPU') + pixelVertexReferenceSoA = cms.InputTag("hltPixelVerticesCPUSerial"), + pixelVertexTargetSoA = cms.InputTag("hltPixelVerticesSoA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareGPUvsCPU'), + case = cms.string('Alpaka') ) process.HLTDQMPixelReconstruction = cms.Sequence( - process.hltPixelRecHitsSoAMonitorCPU + process.hltPixelPhase1MonitorRawDataASerial + + process.hltPixelPhase1MonitorRawDataADevice + + process.hltPixelDigiErrorsCompareGPUvsCPU + + process.hltPixelRecHitsSoAMonitorCPU + process.hltPixelRecHitsSoAMonitorGPU + process.hltPixelRecHitsSoACompareGPUvsCPU + process.hltPixelTracksSoAMonitorCPU diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 4c4132fa6d0a9..8001609c342d8 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -259,7 +259,7 @@ def customizeHLTforCMSSW(process, menuType="GRun"): process = customiseForOffline(process) # Alpaka HLT - from Configuration.ProcessModifiers.alpaka_cff import alpaka + from Configuration.ProcessModifiers.alpaka_cff import alpaka from Configuration.Eras.Modifier_run3_common_cff import run3_common from HLTrigger.Configuration.customizeHLTforAlpaka import customizeHLTforAlpaka (alpaka & run3_common).makeProcessModifier(customizeHLTforAlpaka).apply(process) diff --git a/HLTriggerOffline/Common/python/customizeHLTforAlpakavsCUDA.py b/HLTriggerOffline/Common/python/customizeHLTforAlpakavsCUDA.py new file mode 100644 index 0000000000000..bc6cf7e37c24c --- /dev/null +++ b/HLTriggerOffline/Common/python/customizeHLTforAlpakavsCUDA.py @@ -0,0 +1,999 @@ +import FWCore.ParameterSet.Config as cms +import copy + +## Pixel HLT in Alpaka +def customizeHLTforDQMAlpakavsCUDAPixel(process): + '''Ad-hoc changes to test HLT config containing only DQM_PixelReconstruction_v and DQMGPUvsCPU stream + only up to the Pixel Local Reconstruction + ''' + dqmPixelRecoPathName = None + for pathName in process.paths_(): + if pathName.startswith('DQM_PixelReconstruction_v'): + dqmPixelRecoPathName = pathName + break + + if dqmPixelRecoPathName == None: + return process + + process.hltPixelConsumerGPU.eventProducts = [ + 'hltSiPixelClusters', + 'hltSiPixelClustersSoA', + 'hltSiPixelDigis', + 'hltSiPixelRecHits', + 'hltSiPixelRecHitsSoA', + 'hltPixelTracks', + 'hltPixelTracksSoA', + 'hltPixelVertices', + 'hltPixelVerticesSoA', + 'hltSiPixelClustersCUDA', + 'hltSiPixelClustersSoACUDA', + 'hltSiPixelDigisCUDA', + 'hltSiPixelDigisSoACUDA', + 'hltSiPixelRecHitsCUDA', + 'hltSiPixelRecHitsSoACUDA', + 'hltPixelTracksCUDA', + 'hltPixelTracksSoACUDA', + 'hltPixelVerticesCUDA', + 'hltPixelVerticesSoACUDA', + ] + + process.hltPixelConsumerCPU.eventProducts = [] + for foo in process.hltPixelConsumerGPU.eventProducts: + process.hltPixelConsumerCPU.eventProducts += [foo+'CPUSerial'] + # Left over legacy format collections + process.hltPixelConsumerCPU.eventProducts += ['hltPixelTracksLegacyFormatCPUSerial', + 'hltPixelTracksLegacyFormatCUDACPUSerial', + 'hltPixelVerticesLegacyFormatCPUSerial', + 'hltPixelVerticesLegacyFormatCUDACPUSerial', + 'hltSiPixelClustersLegacyFormatCPUSerial', + 'hltSiPixelDigiErrorsLegacyFormatCPUSerial', + 'hltSiPixelRecHitsLegacyFormatCPUSerial', + 'hltSiPixelRecHitsLegacyFormatCUDACPUSerial', + 'hltSiPixelDigisLegacyFormatCUDACPUSerial'] + + # modify EventContent of DQMGPUvsCPU stream + if hasattr(process, 'hltOutputDQMGPUvsCPU'): + process.hltOutputDQMGPUvsCPU.outputCommands = [ + 'drop *', + 'keep *Cluster*_hltSiPixelClusters_*_*', + 'keep *Cluster*_hltSiPixelClustersLegacyFormatCPUSerial_*_*', + 'keep *_hltSiPixelDigis_*_*', + 'keep *_hltSiPixelDigiErrorsLegacyFormatCPUSerial_*_*', + 'keep *RecHit*_hltSiPixelRecHits_*_*', + 'keep *RecHit*_hltSiPixelRecHitsLegacyFormatCPUSerial_*_*', + 'keep *_hltPixelTracks_*_*', + 'keep *_hltPixelTracksLegacyFormatCPUSerial_*_*', + 'keep *_hltPixelVertices_*_*', + 'keep *_hltPixelVerticesLegacyFormatCPUSerial_*_*', + 'keep *Cluster*_hltSiPixelClustersCUDA_*_*', + 'keep *Cluster*_hltSiPixelClustersLegacyFormatCUDACPUSerial_*_*', + 'keep *_hltSiPixelDigisCUDA_*_*', + 'keep *_hltSiPixelDigisLegacyFormatCUDACPUSerial_*_*', + 'keep *RecHit*_hltSiPixelRecHitsCUDA_*_*', + 'keep *RecHit*_hltSiPixelRecHitsLegacyFormatCUDACPUSerial_*_*', + 'keep *_hltPixelTracksCUDA_*_*', + 'keep *_hltPixelTracksLegacyFormatCUDACPUSerial_*_*', + 'keep *_hltPixelVerticesCUDA_*_*', + 'keep *_hltPixelVerticesLegacyFormatCUDACPUSerial_*_*', + ] + + from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import SiPixelPhase1RawDataConf,SiPixelPhase1RawDataAnalyzer + + # PixelDigiErrors: monitor of CPUSerial product + SiPixelPhase1RawDataConfForSerial = copy.deepcopy(SiPixelPhase1RawDataConf) + for pset in SiPixelPhase1RawDataConfForSerial: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsSerial" + + process.hltPixelPhase1MonitorRawDataASerial = SiPixelPhase1RawDataAnalyzer.clone( + src = "hltSiPixelDigiErrorsLegacyFormatCPUSerial", + histograms = SiPixelPhase1RawDataConfForSerial + ) + + # PixelDigiErrors: monitor of GPU product + SiPixelPhase1RawDataConfForDevice = copy.deepcopy(SiPixelPhase1RawDataConf) + for pset in SiPixelPhase1RawDataConfForDevice: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsDevice" + + process.hltPixelPhase1MonitorRawDataADevice = SiPixelPhase1RawDataAnalyzer.clone( + src = "hltSiPixelDigis", + histograms = SiPixelPhase1RawDataConfForDevice + ) + + # PixelDigiErrors: monitor of CPUSerial product with CUDA + SiPixelPhase1RawDataConfForCPU = copy.deepcopy(SiPixelPhase1RawDataConf) + for pset in SiPixelPhase1RawDataConfForCPU: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsCPU" + + process.hltPixelPhase1MonitorRawDataACPU = SiPixelPhase1RawDataAnalyzer.clone( + src = "hltSiPixelDigisLegacyFormatCUDACPUSerial", + histograms = SiPixelPhase1RawDataConfForCPU + ) + + # PixelDigiErrors: monitor of GPU product with CUDA + SiPixelPhase1RawDataConfForGPU = copy.deepcopy(SiPixelPhase1RawDataConf) + for pset in SiPixelPhase1RawDataConfForGPU: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsGPU" + + process.hltPixelPhase1MonitorRawDataAGPU = SiPixelPhase1RawDataAnalyzer.clone( + src = "hltSiPixelDigisCUDA", + histograms = SiPixelPhase1RawDataConfForGPU + ) + + # PixelDigiErrors: 'Alpaka' comparison + process.hltPixelDigiErrorsCompareAlpaka = cms.EDProducer('SiPixelPhase1RawDataErrorComparator', + pixelErrorSrcCPU = cms.InputTag( 'hltSiPixelDigiErrorsLegacyFormatCPUSerial' ), + pixelErrorSrcGPU = cms.InputTag( 'hltSiPixelDigis' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelErrorsCompareAlpaka' ) + ) + + # PixelDigiErrors: 'CUDA' comparison + process.hltPixelDigiErrorsCompareCUDA = cms.EDProducer('SiPixelPhase1RawDataErrorComparator', + pixelErrorSrcCPU = cms.InputTag( 'hltSiPixelDigisLegacyFormatCUDACPUSerial' ), + pixelErrorSrcGPU = cms.InputTag( 'hltSiPixelDigisCUDA' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelErrorsCompareCUDA' ) + ) + + # PixelDigiErrors: 'AlpakavsCUDA' comparisons + process.hltPixelDigiErrorsCompareAlpakavsCUDACPU = cms.EDProducer('SiPixelPhase1RawDataErrorComparator', + pixelErrorSrcCPU = cms.InputTag( 'hltSiPixelDigiErrorsLegacyFormatCPUSerial' ), # Alpaka Serial + pixelErrorSrcGPU = cms.InputTag( 'hltSiPixelDigisLegacyFormatCUDACPUSerial' ), # CUDA CPU + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelErrorsCompareAlpakavsCUDACPU' ) + ) + + process.hltPixelDigiErrorsCompareAlpakavsCUDAGPU = cms.EDProducer('SiPixelPhase1RawDataErrorComparator', + pixelErrorSrcCPU = cms.InputTag( 'hltSiPixelDigis' ), # Alpaka Device + pixelErrorSrcGPU = cms.InputTag( 'hltSiPixelDigisCUDA' ), # CUDA GPU + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelErrorsCompareAlpakavsCUDAGPU' ) + ) + + # PixelRecHits: monitor of CPUSerial product (Alpaka backend: 'serial_sync') + process.hltPixelRecHitsSoAMonitorSerial = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka', + pixelHitsSrc = cms.InputTag( 'hltSiPixelRecHitsCPUSerial' ), + TopFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsSerial' ) + ) + + # PixelRecHits: monitor of GPU product (Alpaka backend: '') + process.hltPixelRecHitsSoAMonitorDevice = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka', + pixelHitsSrc = cms.InputTag( 'hltSiPixelRecHitsSoA' ), + TopFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsDevice' ) + ) + + # PixelRecHits: monitor of CPUSerial product with CUDA + process.hltPixelRecHitsSoAMonitorCPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoA', + pixelHitsSrc = cms.InputTag( 'hltSiPixelRecHitsSoACUDACPUSerial' ), + TopFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsCPU' ) + ) + + # PixelRecHits: monitor of GPU product with CUDA + process.hltPixelRecHitsSoAMonitorGPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoA', + pixelHitsSrc = cms.InputTag( 'hltSiPixelRecHitsSoAFromCUDA' ), + TopFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsGPU' ) + ) + + # PixelRecHits: 'Alpaka' comparison + process.hltPixelRecHitsSoACompareAlpaka = cms.EDProducer('SiPixelPhase1CompareRecHits', + pixelHitsReferenceSoA = cms.InputTag( 'hltSiPixelRecHitsCPUSerial' ), + pixelHitsTargetSoA = cms.InputTag( 'hltSiPixelRecHitsSoA' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsCompareAlpaka' ), + minD2cut = cms.double( 1.0E-4 ), + case = cms.string('Alpaka') + ) + + # PixelRecHits: 'CUDA' comparison + process.hltPixelRecHitsSoACompareCUDA = cms.EDProducer('SiPixelPhase1CompareRecHits', + pixelHitsReferenceCUDA = cms.InputTag( 'hltSiPixelRecHitsSoACUDACPUSerial' ), + pixelHitsTargetCUDA = cms.InputTag( 'hltSiPixelRecHitsSoAFromCUDA' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsCompareCUDA' ), + minD2cut = cms.double( 1.0E-4 ), + case = cms.string('CUDA') + ) + + # PixelRecHits: 'AlpakavsCUDA' comparisons + process.hltPixelRecHitsSoACompareAlpakavsCUDACPU = cms.EDProducer('SiPixelPhase1CompareRecHits', + pixelHitsReferenceSoA = cms.InputTag( 'hltSiPixelRecHitsCPUSerial' ), + pixelHitsTargetCUDA = cms.InputTag( 'hltSiPixelRecHitsSoACUDACPUSerial' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsCompareAlpakavsCUDACPU' ), + minD2cut = cms.double( 1.0E-4 ), + case = cms.string('AlpakavsCUDA') + ) + + process.hltPixelRecHitsSoACompareAlpakavsCUDAGPU = cms.EDProducer('SiPixelPhase1CompareRecHits', + pixelHitsReferenceSoA = cms.InputTag( 'hltSiPixelRecHitsSoA' ), + pixelHitsTargetCUDA = cms.InputTag( 'hltSiPixelRecHitsSoAFromCUDA' ), + topFolderName = cms.string( 'SiPixelHeterogeneous/PixelRecHitsCompareAlpakavsCUDAGPU' ), + minD2cut = cms.double( 1.0E-4 ), + case = cms.string('AlpakavsCUDA') + ) + + # PixelTracks: monitor of CPUSerial product (Alpaka backend: 'serial_sync') + process.hltPixelTracksSoAMonitorSerial = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka", + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackSrc = cms.InputTag('hltPixelTracksCPUSerial'), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackSerial'), + useQualityCut = cms.bool(True) + ) + + # PixelTracks: monitor of GPU product (Alpaka backend: '') + process.hltPixelTracksSoAMonitorDevice = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka", + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackSrc = cms.InputTag('hltPixelTracksSoA'), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackDevice'), + useQualityCut = cms.bool(True) + ) + + # PixelTracks: monitor of CPUSerial product with CUDA + process.hltPixelTracksSoAMonitorCPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoA", + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackSrc = cms.InputTag('hltPixelTracksSoACUDACPUSerial'), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCPU'), + useQualityCut = cms.bool(True) + ) + + # PixelTracks: monitor of GPU product with CUDA + process.hltPixelTracksSoAMonitorGPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoA", + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackSrc = cms.InputTag('hltPixelTracksSoAFromCUDA'), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackGPU'), + useQualityCut = cms.bool(True) + ) + + # PixelTracks: 'Alpaka' comparison + process.hltPixelTracksSoACompareAlpaka = cms.EDProducer("SiPixelPhase1CompareTracks", + deltaR2cut = cms.double(0.04), + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackReferenceSoA = cms.InputTag("hltPixelTracksCPUSerial"), + pixelTrackTargetSoA = cms.InputTag("hltPixelTracksSoA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareAlpaka'), + useQualityCut = cms.bool(True), + case = cms.string('Alpaka') + ) + + # PixelTracks: 'CUDA' comparison + process.hltPixelTracksSoACompareCUDA = cms.EDProducer("SiPixelPhase1CompareTracks", + deltaR2cut = cms.double(0.04), + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackReferenceCUDA = cms.InputTag("hltPixelTracksSoACUDACPUSerial"), + pixelTrackTargetCUDA = cms.InputTag("hltPixelTracksSoAFromCUDA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareCUDA'), + useQualityCut = cms.bool(True), + case = cms.string('CUDA') + ) + + # PixelTracks: 'AlpakavsCUDA' comparisons + process.hltPixelTracksSoACompareAlpakavsCUDACPU = cms.EDProducer("SiPixelPhase1CompareTracks", + deltaR2cut = cms.double(0.04), + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackReferenceSoA = cms.InputTag("hltPixelTracksCPUSerial"), + pixelTrackTargetCUDA = cms.InputTag("hltPixelTracksSoACUDACPUSerial"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareAlpakavsCUDACPU'), + useQualityCut = cms.bool(True), + case = cms.string('AlpakavsCUDA') + ) + + process.hltPixelTracksSoACompareAlpakavsCUDAGPU = cms.EDProducer("SiPixelPhase1CompareTracks", + deltaR2cut = cms.double(0.04), + mightGet = cms.optional.untracked.vstring, + minQuality = cms.string('loose'), + pixelTrackReferenceSoA = cms.InputTag("hltPixelTracksSoA"), + pixelTrackTargetCUDA = cms.InputTag("hltPixelTracksSoAFromCUDA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareAlpakavsCUDAGPU'), + useQualityCut = cms.bool(True), + case = cms.string('AlpakavsCUDA') + ) + + # PixelVertices: monitor of CPUSerial product (Alpaka backend: 'serial_sync') + process.hltPixelVertexSoAMonitorSerial = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + mightGet = cms.optional.untracked.vstring, + pixelVertexSrc = cms.InputTag("hltPixelVerticesCPUSerial"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexSerial') + ) + + # PixelVertices: monitor of GPU product (Alpaka backend: '') + process.hltPixelVertexSoAMonitorDevice = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + mightGet = cms.optional.untracked.vstring, + pixelVertexSrc = cms.InputTag("hltPixelVerticesSoA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexDevice') + ) + + # PixelTracks: monitor of CPUSerial product with CUDA + process.hltPixelVertexSoAMonitorCPU = cms.EDProducer("SiPixelMonitorVertexSoA", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + mightGet = cms.optional.untracked.vstring, + pixelVertexSrc = cms.InputTag("hltPixelVerticesSoACUDACPUSerial"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCPU') + ) + + # PixelTracks: monitor of GPU product with CUDA + process.hltPixelVertexSoAMonitorGPU = cms.EDProducer("SiPixelMonitorVertexSoA", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + mightGet = cms.optional.untracked.vstring, + pixelVertexSrc = cms.InputTag("hltPixelVerticesSoAFromCUDA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexGPU') + ) + + # PixelTracks: 'Alpaka' comparison + process.hltPixelVertexSoACompareAlpaka = cms.EDProducer("SiPixelCompareVertices", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + dzCut = cms.double(1), + mightGet = cms.optional.untracked.vstring, + pixelVertexReferenceSoA = cms.InputTag("hltPixelVerticesCPUSerial"), + pixelVertexTargetSoA = cms.InputTag("hltPixelVerticesSoA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareAlpaka'), + case = cms.string('Alpaka') + ) + + # PixelTracks: 'CUDA' comparison + process.hltPixelVertexSoACompareCUDA = cms.EDProducer("SiPixelCompareVertices", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + dzCut = cms.double(1), + mightGet = cms.optional.untracked.vstring, + pixelVertexReferenceCUDA = cms.InputTag("hltPixelVerticesSoACUDACPUSerial"), + pixelVertexTargetCUDA = cms.InputTag("hltPixelVerticesSoAFromCUDA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareCUDA'), + case = cms.string('CUDA') + ) + + # PixelTracks: 'AlpakavsCUDA' comparisons + process.hltPixelVertexSoACompareAlpakavsCUDACPU = cms.EDProducer("SiPixelCompareVertices", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + dzCut = cms.double(1), + mightGet = cms.optional.untracked.vstring, + pixelVertexReferenceSoA = cms.InputTag("hltPixelVerticesCPUSerial"), + pixelVertexTargetCUDA = cms.InputTag("hltPixelVerticesSoACUDACPUSerial"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareAlpakavsCUDACPU'), + case = cms.string('AlpakavsCUDA') + ) + + process.hltPixelVertexSoACompareAlpakavsCUDAGPU = cms.EDProducer("SiPixelCompareVertices", + beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), + dzCut = cms.double(1), + mightGet = cms.optional.untracked.vstring, + pixelVertexReferenceSoA = cms.InputTag("hltPixelVerticesSoA"), + pixelVertexTargetCUDA = cms.InputTag("hltPixelVerticesSoAFromCUDA"), + topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareAlpakavsCUDAGPU'), + case = cms.string('AlpakavsCUDA') + ) + + process.HLTDQMPixelReconstruction = cms.Sequence( + process.hltPixelPhase1MonitorRawDataASerial + + process.hltPixelPhase1MonitorRawDataADevice + + process.hltPixelPhase1MonitorRawDataACPU + + process.hltPixelPhase1MonitorRawDataAGPU + + process.hltPixelDigiErrorsCompareAlpaka + + process.hltPixelDigiErrorsCompareCUDA + + process.hltPixelDigiErrorsCompareAlpakavsCUDACPU + + process.hltPixelDigiErrorsCompareAlpakavsCUDAGPU + + process.hltPixelRecHitsSoAMonitorSerial + + process.hltPixelRecHitsSoAMonitorDevice + + process.hltPixelRecHitsSoAMonitorCPU + + process.hltPixelRecHitsSoAMonitorGPU + + process.hltPixelRecHitsSoACompareAlpaka + + process.hltPixelRecHitsSoACompareCUDA + + process.hltPixelRecHitsSoACompareAlpakavsCUDACPU + + process.hltPixelRecHitsSoACompareAlpakavsCUDAGPU + + process.hltPixelTracksSoAMonitorSerial + + process.hltPixelTracksSoAMonitorDevice + + process.hltPixelTracksSoAMonitorCPU + + process.hltPixelTracksSoAMonitorGPU + + process.hltPixelTracksSoACompareAlpaka + + process.hltPixelTracksSoACompareCUDA + + process.hltPixelTracksSoACompareAlpakavsCUDACPU + + process.hltPixelTracksSoACompareAlpakavsCUDAGPU + + process.hltPixelVertexSoAMonitorSerial + + process.hltPixelVertexSoAMonitorDevice + + process.hltPixelVertexSoAMonitorCPU + + process.hltPixelVertexSoAMonitorGPU + + process.hltPixelVertexSoACompareAlpaka + + process.hltPixelVertexSoACompareCUDA + + process.hltPixelVertexSoACompareAlpakavsCUDACPU + + process.hltPixelVertexSoACompareAlpakavsCUDAGPU + ) + + # Add CPUSerial sequences to DQM_PixelReconstruction_v Path + dqmPixelRecoPath = getattr(process, dqmPixelRecoPathName) + try: + dqmPixelRecoPathIndex = dqmPixelRecoPath.index(process.HLTRecopixelvertexingSequence) + 1 + for cpuSeqName in [ + 'HLTDoLocalPixelCPUSerialSequence', + 'HLTRecopixelvertexingCPUSerialSequence', + ]: + dqmPixelRecoPath.insert(dqmPixelRecoPathIndex, getattr(process, cpuSeqName)) + dqmPixelRecoPathIndex += 1 + for cudaSeqName in [ + 'HLTDoLocalPixelCUDASequence', + 'HLTRecopixelvertexingCUDASequence', + 'HLTDoLocalPixelCUDACPUSerialSequence', + 'HLTRecopixelvertexingCUDACPUSerialSequence', + ]: + dqmPixelRecoPath.insert(dqmPixelRecoPathIndex, getattr(process, cudaSeqName)) + dqmPixelRecoPathIndex += 1 + except: + dqmPixelRecoPathIndex = None + + return process + +def customizeHLTforCUDAPixelRecoLocal(process): + '''Customisation to introduce the Local Pixel Reconstruction in CUDA + ''' + + # Producing records for CUDA + process.siPixelGainCalibrationForHLTGPU = cms.ESProducer( "SiPixelGainCalibrationForHLTGPUESProducer", + appendToDataLabel = cms.string( "" ) + ) + + process.siPixelROCsStatusAndMappingWrapperESProducer = cms.ESProducer( "SiPixelROCsStatusAndMappingWrapperESProducer", + ComponentName = cms.string( "" ), + CablingMapLabel = cms.string( "" ), + UseQualityInfo = cms.bool( False ), + appendToDataLabel = cms.string( "" ) + ) + + process.pixelCPEFastESProducerPhase1 = cms.ESProducer("PixelCPEFastESProducerPhase1", + appendToDataLabel = cms.string(''), + ) + + ### + + # CUDA EDProducer + # consumes + # - reco::BeamSpot + # produces + # - BeamSpotCUDA + process.hltOnlineBeamSpotGPU = cms.EDProducer("BeamSpotToCUDA", + src = cms.InputTag("hltOnlineBeamSpot") + ) + + # CUDA EDProducer + # consumes + # - FEDRawDataCollection + # produces (* optional) + # - SiPixelDigisCUDA + # - SiPixelDigiErrorsCUDA + # - SiPixelClustersCUDA + process.hltSiPixelClustersSoACUDA = cms.EDProducer("SiPixelRawToClusterCUDAPhase1", + CablingMapLabel = cms.string(''), + IncludeErrors = cms.bool(True), + InputLabel = cms.InputTag("rawDataCollector"), + Regions = cms.PSet( + beamSpot = cms.optional.InputTag, + deltaPhi = cms.optional.vdouble, + inputs = cms.optional.VInputTag, + maxZ = cms.optional.vdouble + ), + UseQualityInfo = cms.bool(False), + VCaltoElectronGain = cms.double(1), + VCaltoElectronGain_L1 = cms.double(1), + VCaltoElectronOffset = cms.double(0), + VCaltoElectronOffset_L1 = cms.double(0), + clusterThreshold_layer1 = cms.int32(4000), + clusterThreshold_otherLayers = cms.int32(4000), + mightGet = cms.optional.untracked.vstring + ) + + # CUDA EDProducer + # consumes + # - SiPixelClustersCUDA + # produces + # - legacy::SiPixelDigisSoA + process.hltSiPixelDigisSoACUDA = cms.EDProducer("SiPixelDigisSoAFromCUDA", + src = cms.InputTag("hltSiPixelClustersSoACUDA") + ) + + # Not sure if digi errors are needed for this comparison + # CUDA EDProducer + # consumes + # - SiPixelDigiErrorsCUDA + # produces + # - SiPixelErrorsSoA + process.hltSiPixelDigisErrorsSoACUDA = cms.EDProducer("SiPixelDigiErrorsSoAFromCUDA", + src = cms.InputTag("hltSiPixelClustersSoACUDA") + ) + + # legacy EDProducer + # consumes + # - legacy::SiPixelDigisSoA + # produces + # - edm::DetSetVector + # - SiPixelClusterCollectionNew + process.hltSiPixelClustersCUDA = cms.EDProducer('SiPixelDigisClustersFromSoAPhase1', + src = cms.InputTag('hltSiPixelDigisSoACUDA'), + clusterThreshold_layer1 = cms.int32(4000), + clusterThreshold_otherLayers = cms.int32(4000), + produceDigis = cms.bool(False), + storeDigis = cms.bool(False) + ) + + # legacy EDProducer + # consumes + # - SiPixelDigiErrorsHost + # - SiPixelFormatterErrors + # produces + # - edm::DetSetVector + # - DetIdCollection + # - DetIdCollection, 'UserErrorModules' + # - edmNew::DetSetVector + process.hltSiPixelDigisCUDA = cms.EDProducer('SiPixelDigiErrorsFromSoA', + digiErrorSoASrc = cms.InputTag('hltSiPixelDigisErrorsSoACUDA'), + CablingMapLabel = cms.string(''), + UsePhase1 = cms.bool(True), + ErrorList = cms.vint32(29), + UserErrorList = cms.vint32(40) + ) + + # CUDA EDProducer + # consumes + # - BeamSpotCUDA + # - SiPixelClustersCUDA + # - SiPixelDigisCUDA + # produces + # - TrackingRecHitSoADevice + process.hltSiPixelRecHitsSoACUDA = cms.EDProducer("SiPixelRecHitCUDAPhase1", + CPE = cms.string('PixelCPEFast'), + beamSpot = cms.InputTag("hltOnlineBeamSpotGPU"), + mightGet = cms.optional.untracked.vstring, + src = cms.InputTag("hltSiPixelClustersSoACUDA") + ) + + # legacy EDProducer + # consumes + # - TrackingRecHitSoADevice + # - SiPixelClusterCollectionNew + # produces + # - SiPixelRecHitCollection + # - HMSstorage + process.hltSiPixelRecHitsCUDA = cms.EDProducer('SiPixelRecHitFromCUDAPhase1', + pixelRecHitSrc = cms.InputTag('hltSiPixelRecHitsSoACUDA'), + src = cms.InputTag('hltSiPixelClustersCUDA'), + ) + + # Needed to convert hits on device to hits on host for monitoring/comparisons + # CUDA EDProducer + # consumes + # - TrackingRecHitSoADevice + # produces + # - TrackingRecHitSoAHost + # - HMSstorage + process.hltSiPixelRecHitsSoAFromCUDA = cms.EDProducer('SiPixelRecHitSoAFromCUDAPhase1', + pixelRecHitSrc = cms.InputTag('hltSiPixelRecHitsSoACUDA'), + ) + + ### + ### Task: Pixel Local Reconstruction + ### + process.HLTDoLocalPixelCUDATask = cms.ConditionalTask( + process.hltOnlineBeamSpotGPU, + process.hltSiPixelClustersSoACUDA, + process.hltSiPixelDigisSoACUDA, + process.hltSiPixelDigisErrorsSoACUDA, + process.hltSiPixelClustersCUDA, # was: hltSiPixelClusters + process.hltSiPixelDigisCUDA, # was: hltSiPixelDigis + process.hltSiPixelRecHitsSoACUDA, + process.hltSiPixelRecHitsSoAFromCUDA, + process.hltSiPixelRecHitsCUDA, # was: hltSiPixelRecHits + ) + + process.HLTDoLocalPixelCUDASequence = cms.Sequence( process.HLTDoLocalPixelCUDATask ) + + ### + ### CPUSerial version of Pixel Local Reconstruction + ### + + # Probably not needed; can keep using hltOnlineBeamSpot + # CUDA EDProducer + # consumes + # - reco::BeamSpot + # produces + # - BeamSpotCUDA + process.hltOnlineBeamSpotCPUSerial = process.hltOnlineBeamSpot.clone() + + # legacy EDProducer + # consumes + # - FEDRawDataCollection + # produces + # - edm::DetSetVector + # - edm::DetSetVector + # - DetIdCollection + # - DetIdCollection + # - edmNew::DetSetVector + process.hltSiPixelDigisLegacyFormatCUDACPUSerial = cms.EDProducer("SiPixelRawToDigi", + IncludeErrors = cms.bool( True ), + UseQualityInfo = cms.bool( False ), + ErrorList = cms.vint32( 29 ), + UserErrorList = cms.vint32( ), + InputLabel = cms.InputTag( "rawDataCollector" ), + Regions = cms.PSet( ), + UsePilotBlade = cms.bool( False ), + UsePhase1 = cms.bool( True ), + CablingMapLabel = cms.string( "" ), + SiPixelQualityLabel = cms.string( "" ) + ) + + # legacy EDProducer + # consumes + # - edm::DetSetVector + # produces + # - SiPixelClusterCollectionNew + process.hltSiPixelClustersLegacyFormatCUDACPUSerial = cms.EDProducer("SiPixelClusterProducer", + ChannelThreshold = cms.int32(10), + ClusterMode = cms.string('PixelThresholdClusterizer'), + ClusterThreshold = cms.int32(4000), + ClusterThreshold_L1 = cms.int32(4000), + DropDuplicates = cms.bool(True), + ElectronPerADCGain = cms.double(135), + MissCalibrate = cms.bool(True), + Phase2Calibration = cms.bool(False), + Phase2DigiBaseline = cms.double(1200), + Phase2KinkADC = cms.int32(8), + Phase2ReadoutMode = cms.int32(-1), + SeedThreshold = cms.int32(1000), + SplitClusters = cms.bool(False), + VCaltoElectronGain = cms.int32(1), + VCaltoElectronGain_L1 = cms.int32(1), + VCaltoElectronOffset = cms.int32(0), + VCaltoElectronOffset_L1 = cms.int32(0), + maxNumberOfClusters = cms.int32(-1), + mightGet = cms.optional.untracked.vstring, + payloadType = cms.string('HLT'), + src = cms.InputTag("hltSiPixelDigisLegacyFormatCUDACPUSerial") + ) + + # CUDA EDProducer + # consumes + # - reco::BeamSpot + # - SiPixelClusterCollectionNew + # produces + # - TrackingRecHitSoAHost + # - HMSstorage + process.hltSiPixelRecHitsSoACUDACPUSerial = cms.EDProducer("SiPixelRecHitSoAFromLegacyPhase1", + CPE = cms.string('PixelCPEFast'), + beamSpot = cms.InputTag("hltOnlineBeamSpotCPUSerial"), + convertToLegacy = cms.bool(False), + mightGet = cms.optional.untracked.vstring, + src = cms.InputTag("hltSiPixelClustersLegacyFormatCUDACPUSerial") + ) + + # legacy EDProducer + # consumes + # - TrackingRecHitSoADevice + # - SiPixelClusterCollectionNew + # produces + # - SiPixelRecHitCollection + # - HMSstorage + process.hltSiPixelRecHitsLegacyFormatCUDACPUSerial = process.hltSiPixelRecHitsCUDA.clone( + pixelRecHitSrc = 'hltSiPixelRecHitsSoACUDA', + src = 'hltSiPixelClustersLegacyFormatCUDACPUSerial', + ) + + process.HLTDoLocalPixelCUDACPUSerialTask = cms.ConditionalTask( + process.hltOnlineBeamSpotCPUSerial, + process.hltSiPixelDigisLegacyFormatCUDACPUSerial, + process.hltSiPixelClustersLegacyFormatCUDACPUSerial, + process.hltSiPixelRecHitsSoACUDACPUSerial, + process.hltSiPixelRecHitsLegacyFormatCUDACPUSerial, + ) + + process.HLTDoLocalPixelCUDACPUSerialSequence = cms.Sequence( process.HLTDoLocalPixelCUDACPUSerialTask ) + + return process + +def customizeHLTforCUDAPixelRecoTracking(process): + '''Customisation to introduce the Pixel-Track Reconstruction in CUDA + ''' + + # CUDA EDProducer + # consumes + # - TrackingRecHitSoADevice + # produces + # - TrackSoAHeterogeneousDevice + process.hltPixelTracksSoACUDA = cms.EDProducer("CAHitNtupletCUDAPhase1", + CAThetaCutBarrel = cms.double(0.002), + CAThetaCutForward = cms.double(0.003), + dcaCutInnerTriplet = cms.double(0.15), + dcaCutOuterTriplet = cms.double(0.25), + doClusterCut = cms.bool(True), + doPtCut = cms.bool(True), + doSharedHitCut = cms.bool(True), + doZ0Cut = cms.bool(True), + dupPassThrough = cms.bool(False), + earlyFishbone = cms.bool(True), + fillStatistics = cms.bool(False), + fitNas4 = cms.bool(False), + hardCurvCut = cms.double(0.0328407225), + idealConditions = cms.bool(False), + includeJumpingForwardDoublets = cms.bool(True), + lateFishbone = cms.bool(False), + maxNumberOfDoublets = cms.uint32(524288), + minHitsForSharingCut = cms.uint32(10), + minHitsPerNtuplet = cms.uint32(3), + onGPU = cms.bool(True), + phiCuts = cms.vint32( + 522, 730, 730, 522, 626, + 626, 522, 522, 626, 626, + 626, 522, 522, 522, 522, + 522, 522, 522, 522 + ), + pixelRecHitSrc = cms.InputTag("hltSiPixelRecHitsSoACUDA"), + ptmin = cms.double(0.9), + trackQualityCuts = cms.PSet( + chi2MaxPt = cms.double(10), + chi2Coeff = cms.vdouble(0.9, 1.8), + chi2Scale = cms.double(8), + tripletMinPt = cms.double(0.5), + tripletMaxTip = cms.double(0.3), + tripletMaxZip = cms.double(12), + quadrupletMinPt = cms.double(0.3), + quadrupletMaxTip = cms.double(0.5), + quadrupletMaxZip = cms.double(12) + ), + useRiemannFit = cms.bool(False), + useSimpleTripletCleaner = cms.bool(True), + ) + + # CUDA EDProducer + # consumes + # - TrackingRecHitSoAHost + # produces + # - TrackSoAHeterogeneousHost + process.hltPixelTracksSoACUDACPUSerial = process.hltPixelTracksSoACUDA.clone( + pixelRecHitSrc = 'hltSiPixelRecHitsSoACUDACPUSerial', + onGPU = cms.bool(False) + ) + + # Needed to convert tracks on device to tracks on host for monitoring/comparisons + # CUDA EDProducer + # consumes + # - TrackSoAHeterogeneousDevice + # produces + # - TrackSoAHeterogeneousHost + process.hltPixelTracksSoAFromCUDA = cms.EDProducer( "PixelTrackSoAFromCUDAPhase1", + src = cms.InputTag( "hltPixelTracksSoACUDA" ) + ) + + # legacy EDProducer + # consumes + # - reco::BeamSpot + # - TrackSoAHeterogeneousHost + # - SiPixelRecHitCollectionNew + # - HMSstorage + # produces + # - TrackingRecHitCollection + # - reco::TrackExtraCollection + # - reco::TrackCollection + # - IndToEdm + process.hltPixelTracksCUDA = cms.EDProducer("PixelTrackProducerFromSoAPhase1", + beamSpot = cms.InputTag("hltOnlineBeamSpot"), + minNumberOfHits = cms.int32(0), + minQuality = cms.string('loose'), + pixelRecHitLegacySrc = cms.InputTag("hltSiPixelRecHitsCUDA"), + trackSrc = cms.InputTag("hltPixelTracksSoAFromCUDA") + ) + + # legacy EDProducer + # consumes + # - reco::BeamSpot + # - TrackSoAHeterogeneousHost + # - SiPixelRecHitCollectionNew + # - HMSstorage + # produces + # - TrackingRecHitCollection + # - reco::TrackExtraCollection + # - reco::TrackCollection + # - IndToEdm + process.hltPixelTracksLegacyFormatCUDACPUSerial = process.hltPixelTracksCUDA.clone( + pixelRecHitLegacySrc = cms.InputTag("hltSiPixelRecHitsLegacyFormatCUDACPUSerial"), + trackSrc = cms.InputTag("hltPixelTracksSoACUDACPUSerial") + ) + + process.HLTRecoPixelTracksCUDATask = cms.ConditionalTask( + process.hltPixelTracksSoACUDA, + process.hltPixelTracksSoAFromCUDA, + process.hltPixelTracksCUDA, + ) + + process.HLTRecoPixelTracksCUDACPUSerialTask = cms.ConditionalTask( + process.hltPixelTracksSoACUDACPUSerial, + process.hltPixelTracksLegacyFormatCUDACPUSerial, + ) + + process.HLTRecoPixelTracksCUDASequence = cms.Sequence( process.HLTRecoPixelTracksCUDATask ) + + process.HLTRecoPixelTracksCUDACPUSerialSequence = cms.Sequence( process.HLTRecoPixelTracksCUDACPUSerialTask ) + + return process + +def customizeHLTforCUDAPixelRecoVertexing(process): + '''Customisation to introduce the Pixel-Vertex Reconstruction in CUDA + ''' + + # CUDA EDProducer + # consumes + # - TrackSoAHeterogeneousDevice + # produces + # - ZVertexSoADevice + process.hltPixelVerticesSoACUDA = cms.EDProducer("PixelVertexProducerCUDAPhase1", + PtMax = cms.double(75), + PtMin = cms.double(0.5), + chi2max = cms.double(9), + eps = cms.double(0.07), + errmax = cms.double(0.01), + minT = cms.int32(2), + onGPU = cms.bool(True), + oneKernel = cms.bool(True), + pixelTrackSrc = cms.InputTag("hltPixelTracksSoACUDA"), + useDBSCAN = cms.bool(False), + useDensity = cms.bool(True), + useIterative = cms.bool(False) + ) + + # CUDA EDProducer + # consumes + # - TrackSoAHeterogeneousHost + # produces + # - ZVertexSoAHost + process.hltPixelVerticesSoACUDACPUSerial = process.hltPixelVerticesSoACUDA.clone( + onGPU = cms.bool(False), + pixelTrackSrc = cms.InputTag("hltPixelTracksSoACUDACPUSerial"), + ) + + # Needed to convert vertices on device to vertices on host for monitoring/comparisons + # CUDA EDProducer + # consumes + # - ZVertexSoADevice + # produces + # - ZVertexSoAHost + process.hltPixelVerticesSoAFromCUDA = cms.EDProducer( "PixelVertexSoAFromCUDA", + src = cms.InputTag( "hltPixelVerticesSoACUDA" ) + ) + + # legacy EDProducer + # consumes + # - reco::BeamSpot + # - ZVertexSoAHost + # - reco::TrackCollection + # - IndToEdm + # produces + # - reco::VertexCollection + process.hltPixelVerticesCUDA = cms.EDProducer("PixelVertexProducerFromSoA", + TrackCollection = cms.InputTag("hltPixelTracksCUDA"), + beamSpot = cms.InputTag("hltOnlineBeamSpot"), + src = cms.InputTag("hltPixelVerticesSoAFromCUDA") + ) + + # legacy EDProducer + # consumes + # - reco::BeamSpot + # - ZVertexSoAHost + # - reco::TrackCollection + # - IndToEdm + # produces + # - reco::VertexCollection + process.hltPixelVerticesLegacyFormatCUDACPUSerial = process.hltPixelVerticesCUDA.clone( + TrackCollection = cms.InputTag("hltPixelTracksLegacyFormatCUDACPUSerial"), + src = cms.InputTag("hltPixelVerticesSoACUDACPUSerial") + ) + + ## failsafe for fake menus + if(not hasattr(process,'hltTrimmedPixelVertices')): + return process + + process.HLTRecopixelvertexingCUDATask = cms.ConditionalTask( + process.HLTRecoPixelTracksCUDATask, + process.hltPixelVerticesSoACUDA, + process.hltPixelVerticesSoAFromCUDA, + process.hltPixelVerticesCUDA, + process.hltTrimmedPixelVertices + ) + + process.HLTRecopixelvertexingCUDACPUSerialTask = cms.ConditionalTask( + process.HLTRecoPixelTracksCUDACPUSerialTask, + process.hltPixelVerticesSoACUDACPUSerial, + process.hltPixelVerticesLegacyFormatCUDACPUSerial, + ) + + process.HLTRecopixelvertexingCUDASequence = cms.Sequence( process.HLTRecopixelvertexingCUDATask ) + + process.HLTRecopixelvertexingCUDACPUSerialSequence = cms.Sequence( process.HLTRecopixelvertexingCUDACPUSerialTask ) + + return process + +# Not sure if this is needed for Alpaka vs CUDA DQM +def customizeHLTforCUDAPixelRecoTheRest(process): + '''Customize HLT path depending on old SoA tracks + ''' + process.hltL2TauTagNNProducerCUDA = cms.EDProducer("L2TauNNProducer", + BeamSpot = cms.InputTag("hltOnlineBeamSpot"), + L1Taus = cms.VPSet( + cms.PSet( + L1CollectionName = cms.string('DoubleTau'), + L1TauTrigger = cms.InputTag("hltL1sDoubleTauBigOR") + ), + cms.PSet( + L1CollectionName = cms.string('SingleTau'), + L1TauTrigger = cms.InputTag("hltL1sSingleTau") + ), + cms.PSet( + L1CollectionName = cms.string('MuXXTauYY'), + L1TauTrigger = cms.InputTag("hltL1sBigOrMuXXerIsoTauYYer") + ), + cms.PSet( + L1CollectionName = cms.string('Mu22Tau40'), + L1TauTrigger = cms.InputTag("hltL1sMu22erIsoTau40er") + ), + cms.PSet( + L1CollectionName = cms.string('DoubleTauJet'), + L1TauTrigger = cms.InputTag("hltL1sBigORDoubleTauJet") + ), + cms.PSet( + L1CollectionName = cms.string('VBFIsoTau'), + L1TauTrigger = cms.InputTag("hltL1VBFDiJetIsoTau") + ), + cms.PSet( + L1CollectionName = cms.string('Mu18TauXX'), + L1TauTrigger = cms.InputTag("hltL1sVeryBigORMu18erTauXXer2p1") + ), + cms.PSet( + L1CollectionName = cms.string('DoubleTauLowMass'), + L1TauTrigger = cms.InputTag("hltL1sDoubleTauBigORWithLowMass") + ) + ), + debugLevel = cms.int32(0), + ebInput = cms.InputTag("hltEcalRecHit","EcalRecHitsEB"), + eeInput = cms.InputTag("hltEcalRecHit","EcalRecHitsEE"), + fractionSumPt2 = cms.double(0.3), + graphPath = cms.string('RecoTauTag/TrainingFiles/data/L2TauNNTag/L2TauTag_Run3v1.pb'), + hbheInput = cms.InputTag("hltHbhereco"), + hoInput = cms.InputTag("hltHoreco"), + maxVtx = cms.uint32(100), + minSumPt2 = cms.double(0.0), + normalizationDict = cms.string('RecoTauTag/TrainingFiles/data/L2TauNNTag/NormalizationDict.json'), + pataTracks = cms.InputTag("hltPixelTracksSoAFromCUDA"), + pataVertices = cms.InputTag("hltPixelVerticesSoAFromCUDA"), + track_chi2_max = cms.double(99999.0), + track_pt_max = cms.double(10.0), + track_pt_min = cms.double(1.0) + ) + + return process + +from HLTrigger.Configuration.customizeHLTforAlpaka import customizeHLTforAlpakaPixelRecoLocal +from HLTrigger.Configuration.customizeHLTforAlpaka import customizeHLTforAlpakaPixelRecoTracking +from HLTrigger.Configuration.customizeHLTforAlpaka import customizeHLTforAlpakaPixelRecoVertexing + +def customizeHLTforAlpakavsCUDAPixelReco(process): + '''Customisation to introduce the Pixel Local+Track+Vertex Reconstruction in Alpaka and CUDA + ''' + + process = customizeHLTforAlpakaPixelRecoLocal(process) + process = customizeHLTforAlpakaPixelRecoTracking(process) + process = customizeHLTforAlpakaPixelRecoVertexing(process) + process = customizeHLTforCUDAPixelRecoLocal(process) + process = customizeHLTforCUDAPixelRecoTracking(process) + process = customizeHLTforCUDAPixelRecoVertexing(process) + process = customizeHLTforDQMAlpakavsCUDAPixel(process) + process = customizeHLTforCUDAPixelRecoTheRest(process) + + return process + +from HLTrigger.Configuration.customizeHLTforAlpaka import customizeHLTforAlpakaEcalLocalReco +from HLTrigger.Configuration.customizeHLTforAlpaka import customizeHLTforAlpakaParticleFlowClustering + +def customizeHLTforAlpakavsCUDA(process): + + process.load("HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi") + process.load('Configuration.StandardSequences.Accelerators_cff') + + process = customizeHLTforAlpakaEcalLocalReco(process) + process = customizeHLTforAlpakavsCUDAPixelReco(process) + process = customizeHLTforAlpakaParticleFlowClustering(process) + + return process + diff --git a/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py b/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py index a6dd2bea80e2a..65cc02564a709 100644 --- a/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py +++ b/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py @@ -159,12 +159,29 @@ def _addProcessCalibTrackerAlpakaES(process): ) ) +# These produce pixelDigiErrors in Alpaka; they are constructed here because they need +# siPixelClustersPreSplittingAlpaka* as input +from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoAAlpaka_cfi import siPixelDigiErrorsFromSoAAlpaka as _siPixelDigiErrorsFromSoAAlpaka +siPixelDigiErrorsAlpaka = _siPixelDigiErrorsFromSoAAlpaka.clone( + digiErrorSoASrc = cms.InputTag('siPixelClustersPreSplittingAlpaka'), + fmtErrorsSoASrc = cms.InputTag('siPixelClustersPreSplittingAlpaka'), + UsePhase1 = cms.bool(True) +) + +siPixelDigiErrorsAlpakaSerial = siPixelDigiErrorsAlpaka.clone( + digiErrorSoASrc = cms.InputTag('siPixelClustersPreSplittingAlpakaSerial'), + fmtErrorsSoASrc = cms.InputTag('siPixelClustersPreSplittingAlpakaSerial') +) + # Run 3 alpaka.toReplaceWith(siPixelClustersPreSplittingTask, cms.Task( # reconstruct the pixel clusters with alpaka siPixelClustersPreSplittingAlpaka, # reconstruct the pixel clusters with alpaka on the cpu (if requested by the validation) siPixelClustersPreSplittingAlpakaSerial, + # reconstruct pixel digis errors legacy with alpaka on serial and device + siPixelDigiErrorsAlpaka, + siPixelDigiErrorsAlpakaSerial, # convert from host SoA to legacy formats (digis and clusters) siPixelDigisClustersPreSplitting, # EDAlias for the clusters @@ -177,8 +194,56 @@ def _addProcessCalibTrackerAlpakaES(process): siPixelClustersPreSplittingAlpaka, # reconstruct the pixel clusters with alpaka from copied digis on the cpu (if requested by the validation) siPixelClustersPreSplittingAlpakaSerial, + # reconstruct pixel digis legacy with alpaka on the serial and device + siPixelDigiErrorsAlpaka, + siPixelDigiErrorsAlpakaSerial, # convert the pixel digis (except errors) and clusters to the legacy format siPixelDigisClustersPreSplitting, # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA siPixelClustersPreSplitting) ) + +### Alpaka vs CUDA validation + +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel +from RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizer_cfi import siPixelClusters as _siPixelClusters + +siPixelClustersPreSplittingCPU = _siPixelClusters.clone( + payloadType = cms.string('HLT'), + src = cms.InputTag('siPixelDigis@cpu') +) + +siPixelDigisClustersPreSplittingCUDA = _siPixelDigisClustersFromSoAPhase1.clone() + +run3_common.toModify(siPixelDigisClustersPreSplittingCUDA, + clusterThreshold_layer1 = 4000) + +from EventFilter.SiPixelRawToDigi.SiPixelRawToDigi_cfi import siPixelDigis + +# SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA +alpakaCUDAValidationPixel.toModify(siPixelDigis, + cuda = cms.EDAlias( + siPixelDigiErrors = cms.VPSet( + cms.PSet(type = cms.string("DetIdedmEDCollection")), + cms.PSet(type = cms.string("SiPixelRawDataErroredmDetSetVector")), + cms.PSet(type = cms.string("PixelFEDChanneledmNewDetSetVector")) + ), + siPixelDigisClustersPreSplittingCUDA = cms.VPSet( + cms.PSet(type = cms.string("PixelDigiedmDetSetVector")) + ) + ) +) + +alpakaCUDAValidationPixel.toReplaceWith(siPixelClustersPreSplittingTask, cms.Task( + # Reconstruct and convert the pixel clusters with alpaka on host and device + siPixelClustersPreSplittingTask.copy(), + # conditions used *only* by the modules running on GPU + siPixelGainCalibrationForHLTGPU, + siPixelROCsStatusAndMappingWrapperESProducer, + # reconstruct pixel digis and clusters in legacy format for CUDA + siPixelDigisClustersPreSplittingCUDA, + # reconstruct the pixel clusters on the cpu + siPixelClustersPreSplittingCPU, + # reconstruct the pixel digis and clusters on the gpu + siPixelClustersPreSplittingCUDA + )) diff --git a/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py b/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py index 7e8910a8e0918..a31f927535178 100644 --- a/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py +++ b/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py @@ -167,3 +167,18 @@ siPixelRecHitsPreSplittingAlpakaSerial, # Convert hit soa on host to legacy formats siPixelRecHitsPreSplitting)) + +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel + +alpakaCUDAValidationPixel.toModify(siPixelRecHitsPreSplittingSoA, cuda = _siPixelRecHitSoAFromCUDA.clone()) +alpakaCUDAValidationPixel.toModify(siPixelRecHitsPreSplittingCPU, src = cms.InputTag("siPixelClustersPreSplittingCPU")) + +alpakaCUDAValidationPixel.toReplaceWith(siPixelRecHitsPreSplittingTask, cms.Task( + # Reconstruct and convert the pixel hit with alpaka on host and device + siPixelRecHitsPreSplittingTask.copy(), + # reconstruct the pixel rechits on the cpu + siPixelRecHitsPreSplittingCPU, + # reconstruct the pixel rechits on the gpu + siPixelRecHitsPreSplittingCUDA, + # this is an alias for the SoA on GPU or CPU to be used for DQM + siPixelRecHitsPreSplittingSoA)) diff --git a/RecoTracker/Configuration/python/RecoPixelVertexing_cff.py b/RecoTracker/Configuration/python/RecoPixelVertexing_cff.py index f5ba3ad7df1da..a3637af2340b9 100644 --- a/RecoTracker/Configuration/python/RecoPixelVertexing_cff.py +++ b/RecoTracker/Configuration/python/RecoPixelVertexing_cff.py @@ -124,6 +124,26 @@ pixelVertices )) +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel + +alpakaCUDAValidationPixel.toModify(pixelVerticesSoA, + cuda = _pixelVerticesSoA.clone( + src = cms.InputTag("pixelVerticesCUDA") + ) +) + +alpakaCUDAValidationPixel.toModify(pixelVerticesSoA.cpu, + pixelTrackSrc = "pixelTracksSoA@cpu" +) + +alpakaCUDAValidationPixel.toReplaceWith(pixelVerticesTask, cms.Task( + # Reconstruct and convert the pixel tracks with alpaka on host and device + pixelVerticesTask.copy(), + # build pixel vertices in SoA format on the GPU + pixelVerticesCUDA, + # this is an alias for the SoA on GPU or CPU to be used for DQM + pixelVerticesSoA)) + # Tasks and Sequences recopixelvertexingTask = cms.Task( pixelTracksTask, diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc index 44708f4558428..a074999497fbd 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc @@ -98,20 +98,21 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { auto ptMax = pset.getParameter("chi2MaxPt"); coeff[1] = (coeff[1] - coeff[0]) / log2(ptMax); - return ::reco::pixelTrack::QualityCutsT{// polynomial coefficients for the pT-dependent chi2 cut - {(float)coeff[0], (float)coeff[1], 0.f, 0.f}, - // max pT used to determine the chi2 cut - (float)ptMax, - // chi2 scale factor: 8 for broken line fit, ?? for Riemann fit - (float)pset.getParameter("chi2Scale"), - // regional cuts for triplets - {(float)pset.getParameter("tripletMaxTip"), - (float)pset.getParameter("tripletMinPt"), - (float)pset.getParameter("tripletMaxZip")}, - // regional cuts for quadruplets - {(float)pset.getParameter("quadrupletMaxTip"), - (float)pset.getParameter("quadrupletMinPt"), - (float)pset.getParameter("quadrupletMaxZip")}}; + return ::reco::pixelTrack::QualityCutsT{ + // polynomial coefficients for the pT-dependent chi2 cut + {(float)coeff[0], (float)coeff[1], 0.f, 0.f}, + // max pT used to determine the chi2 cut + (float)ptMax, + // chi2 scale factor: 8 for broken line fit, ?? for Riemann fit + (float)pset.getParameter("chi2Scale"), + // regional cuts for triplets + {(float)pset.getParameter("tripletMaxTip"), + (float)pset.getParameter("tripletMinPt"), + (float)pset.getParameter("tripletMaxZip")}, + // regional cuts for quadruplets + {(float)pset.getParameter("quadrupletMaxTip"), + (float)pset.getParameter("quadrupletMinPt"), + (float)pset.getParameter("quadrupletMaxZip")}}; } }; diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h index b3532795936c8..ab4692c16a799 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernels.h @@ -99,8 +99,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { struct ParamsT> : public AlgoParams { using TT = TrackerTraits; using QualityCuts = ::reco::pixelTrack::QualityCutsT; //track quality cuts - using CellCuts = caPixelDoublets::CellCutsT; //cell building cuts - using CAParams = CAParamsT; //params to be used on device + using CellCuts = caPixelDoublets::CellCutsT; //cell building cuts + using CAParams = CAParamsT; //params to be used on device ParamsT(AlgoParams const& commonCuts, CellCuts const& cellCuts, diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc b/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc index 0c3e02a28cff4..25ff2c7dd7b92 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/RiemannFit.dev.cc @@ -175,12 +175,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { riemannFit::fromCircleToPerigee(acc, circle_fit[local_idx]); reco::TracksUtilities::copyFromCircle(results_view, - circle_fit[local_idx].par, - circle_fit[local_idx].cov, - line_fit.par, - line_fit.cov, - 1.f / float(bField), - tkid); + circle_fit[local_idx].par, + circle_fit[local_idx].cov, + line_fit.par, + line_fit.cov, + 1.f / float(bField), + tkid); results_view[tkid].pt() = bField / std::abs(circle_fit[local_idx].par(2)); results_view[tkid].eta() = asinhf(line_fit.par(0)); results_view[tkid].chi2() = (circle_fit[local_idx].chi2 + line_fit.chi2) / (2 * N - 5); diff --git a/RecoTracker/PixelTrackFitting/python/PixelTracks_cff.py b/RecoTracker/PixelTrackFitting/python/PixelTracks_cff.py index 046caa0b033f3..c90a29321209b 100644 --- a/RecoTracker/PixelTrackFitting/python/PixelTracks_cff.py +++ b/RecoTracker/PixelTrackFitting/python/PixelTracks_cff.py @@ -243,3 +243,19 @@ # Convert the pixel tracks from SoA to legacy format pixelTracks) ) + +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel + +alpakaCUDAValidationPixel.toModify(pixelTracksSoA, + # transfer the pixel tracks in SoA format to the host + cuda = _pixelTracksSoA.clone() +) +alpakaCUDAValidationPixel.toModify(pixelTracksSoA.cpu, pixelRecHitSrc = "siPixelRecHitsPreSplittingSoA@cpu") + +alpakaCUDAValidationPixel.toReplaceWith(pixelTracksTask, cms.Task( + # Reconstruct and convert the pixel tracks with alpaka on host and device + pixelTracksTask.copy(), + # build the pixel ntuplets and pixel tracks in SoA format on the GPU + pixelTracksCUDA, + # this is an alias for the SoA on GPU or CPU to be used for DQM + pixelTracksSoA)) diff --git a/RecoVertex/BeamSpotProducer/python/BeamSpot_cff.py b/RecoVertex/BeamSpotProducer/python/BeamSpot_cff.py index 5c17275c17274..32ddf81cbb790 100644 --- a/RecoVertex/BeamSpotProducer/python/BeamSpot_cff.py +++ b/RecoVertex/BeamSpotProducer/python/BeamSpot_cff.py @@ -16,3 +16,9 @@ offlineBeamSpotDevice = _beamSpotDeviceProducer.clone(src = cms.InputTag('offlineBeamSpot')) _offlineBeamSpotTask_alpaka.add(offlineBeamSpotDevice) alpaka.toReplaceWith(offlineBeamSpotTask, _offlineBeamSpotTask_alpaka) + +from Configuration.ProcessModifiers.alpakaCUDAValidationPixel_cff import alpakaCUDAValidationPixel +_offlineBeamSpotTask_alpakaCUDA = offlineBeamSpotTask.copy() +_offlineBeamSpotTask_alpakaCUDA.add(offlineBeamSpotToCUDA) +_offlineBeamSpotTask_alpakaCUDA.add(offlineBeamSpotDevice) +alpakaCUDAValidationPixel.toReplaceWith(offlineBeamSpotTask, _offlineBeamSpotTask_alpakaCUDA)