From 805899459f2fc86676f264111c2780dc37ea5b53 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 8 Jun 2023 17:05:11 +0200 Subject: [PATCH 1/4] Add comparator for SiPixel Errors - add comparison histograms - add warning messages, add total FED errors hisogram, add comments on input parametets - add 2D map of GPU/CPU error unbalance vs FEDid / FEDerror type --- .../SiPixelPhase1RawDataErrorComparator.cc | 308 ++++++++++++++++++ .../SiPixelHeterogenousDQM_FirstStep_cff.py | 4 +- 2 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 DQM/SiPixelHeterogeneous/plugins/SiPixelPhase1RawDataErrorComparator.cc diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelPhase1RawDataErrorComparator.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelPhase1RawDataErrorComparator.cc new file mode 100644 index 0000000000000..6b38167563270 --- /dev/null +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelPhase1RawDataErrorComparator.cc @@ -0,0 +1,308 @@ +// -*- C++ -*- +// Package: SiPixelPhase1RawDataErrorComparator +// Class: SiPixelPhase1RawDataErrorComparator +// +/**\class SiPixelPhase1RawDataErrorComparator SiPixelPhase1RawDataErrorComparator.cc +*/ +// +// Author: Marco Musich +// +#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 "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/DetId/interface/DetIdCollection.h" +#include "DataFormats/FEDRawData/interface/FEDNumbering.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" +#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" +#include "DataFormats/SiPixelRawData/interface/SiPixelErrorsSoA.h" +#include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" +#include "Geometry/CommonTopologies/interface/SimplePixelTopology.h" + +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +// for string manipulations +#include + +namespace { + // same logic used for the MTV: + // cf https://github.com/cms-sw/cmssw/blob/master/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc + typedef dqm::reco::DQMStore DQMStore; + + void 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()); + } + + //errorType - a number (25-38) indicating the type of error recorded. + enum SiPixelFEDErrorCodes { + k_FED25 = 25, // 25 indicates an invalid ROC of 25 + k_FED26 = 26, // 26 indicates a gap word + k_FED27 = 27, // 27 indicates a dummy word + k_FED28 = 28, // 28 indicates a FIFO full error + k_FED29 = 29, // 29 indicates a timeout error + k_FED30 = 30, // 30 indicates a TBM error trailer + k_FED31 = 31, // 31 indicates an event number error (TBM and FED event number mismatch) + k_FED32 = 32, // 32 indicates an incorrectly formatted Slink Header + k_FED33 = 33, // 33 indicates an incorrectly formatted Slink Trailer + k_FED34 = + 34, // 34 indicates the event size encoded in the Slink Trailer is different than size found at raw2digi conversion + k_FED35 = 35, // 35 indicates an invalid FED channel number + k_FED36 = 36, // 36 indicates an invalid ROC value + k_FED37 = 37, // 37 indicates an invalid dcol or pixel value + k_FED38 = 38 // 38 indicates the pixels on a ROC weren't read out from lowest to highest row and dcol value + }; + + std::map errorCodeToStringMap = {{k_FED25, "FED25 error"}, + {k_FED26, "FED26 error"}, + {k_FED27, "FED27 error"}, + {k_FED28, "FED28 error"}, + {k_FED29, "FED29 error"}, + {k_FED30, "FED30 error"}, + {k_FED31, "FED31 error"}}; + + std::map errorCodeToTypeMap = {{k_FED25, "ROC of 25"}, + {k_FED26, "Gap word"}, + {k_FED27, "Dummy word"}, + {k_FED28, "FIFO full"}, + {k_FED29, "Timeout"}, + {k_FED30, "TBM error trailer"}, + {k_FED31, "Event number"}, + {k_FED32, "Slink header"}, + {k_FED33, "Slink trailer"}, + {k_FED34, "Event size"}, + {k_FED35, "Invalid channel#"}, + {k_FED36, "ROC value"}, + {k_FED37, "Dcol or pixel value"}, + {k_FED38, "Readout order"}}; +} // namespace + +class SiPixelPhase1RawDataErrorComparator : public DQMEDAnalyzer { +public: + explicit SiPixelPhase1RawDataErrorComparator(const edm::ParameterSet&); + ~SiPixelPhase1RawDataErrorComparator() 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> tokenErrorsGPU_; + const edm::EDGetTokenT> tokenErrorsCPU_; + const std::string topFolderName_; + + MonitorElement* h_totFEDErrors_; + MonitorElement* h_FEDerrorVsFEDIdUnbalance_; + std::unordered_map h_nFEDErrors_; + + // Define the dimensions of the 2D array + static constexpr int nFEDs = FEDNumbering::MAXSiPixeluTCAFEDID - FEDNumbering::MINSiPixeluTCAFEDID; + static constexpr int nErrors = k_FED38 - k_FED25; +}; + +// +// constructors +// +SiPixelPhase1RawDataErrorComparator::SiPixelPhase1RawDataErrorComparator(const edm::ParameterSet& iConfig) + : tokenErrorsGPU_( + consumes>(iConfig.getParameter("pixelErrorSrcGPU"))), + tokenErrorsCPU_( + consumes>(iConfig.getParameter("pixelErrorSrcCPU"))), + topFolderName_(iConfig.getParameter("topFolderName")) {} + +// +// -- Analyze +// +void SiPixelPhase1RawDataErrorComparator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + std::map countsOnCPU; + std::map countsOnGPU; + + std::array, nFEDs> countsMatrixOnCPU; + std::array, nFEDs> countsMatrixOnGPU; + + // initialize the counts for FED/error matrix + for (int i = 0; i < nFEDs; i++) { + for (int j = 0; j < nErrors; j++) { + countsMatrixOnCPU[i][j] = 0; + countsMatrixOnGPU[i][j] = 0; + } + } + + // initialize the counts for errors per type scatter plots + for (unsigned int j = k_FED25; j <= k_FED31; j++) { + countsOnCPU[j] = 0.; + countsOnGPU[j] = 0.; + } + + edm::Handle> inputFromCPU; + iEvent.getByToken(tokenErrorsCPU_, inputFromCPU); + if (!inputFromCPU.isValid()) { + edm::LogWarning("SiPixelCompareTrackSoA") << "reference (cpu) SiPixelRawDataErrors not found; \n" + << "the comparison will not run."; + return; + } + + uint errorsOnCPU{0}; + for (auto it = inputFromCPU->begin(); it != inputFromCPU->end(); ++it) { + for (auto& siPixelRawDataError : *it) { + int fed = siPixelRawDataError.getFedId(); + int type = siPixelRawDataError.getType(); + DetId id = it->detId(); + + // fill the error matrices for CPU + countsOnCPU[type] += 1; + countsMatrixOnCPU[fed - FEDNumbering::MINSiPixeluTCAFEDID][type - k_FED25] += 1; + + edm::LogInfo("SiPixelPhase1RawDataErrorComparator") + << __PRETTY_FUNCTION__ << " on cpu: FED: " << fed << " detid: " << id.rawId() << " type:" << type; + errorsOnCPU++; + } + } + + edm::Handle> inputFromGPU; + iEvent.getByToken(tokenErrorsGPU_, inputFromGPU); + if (!inputFromGPU.isValid()) { + edm::LogWarning("SiPixelCompareTrackSoA") << "target (gpu) SiPixelRawDataErrors not found; \n" + << "the comparison will not run."; + return; + } + + uint errorsOnGPU{0}; + for (auto it = inputFromGPU->begin(); it != inputFromGPU->end(); ++it) { + for (auto& siPixelRawDataError : *it) { + int fed = siPixelRawDataError.getFedId(); + int type = siPixelRawDataError.getType(); + DetId id = it->detId(); + + // fill the error matrices for GPU + countsOnGPU[type] += 1; + countsMatrixOnGPU[fed - FEDNumbering::MINSiPixeluTCAFEDID][type - k_FED25] += 1; + + edm::LogInfo("SiPixelPhase1RawDataErrorComparator") + << __PRETTY_FUNCTION__ << " on gpu: FED: " << fed << " detid: " << id.rawId() << " type:" << type; + errorsOnGPU++; + } + } + + edm::LogInfo("SiPixelPhase1RawDataErrorComparator") + << __PRETTY_FUNCTION__ << " on gpu found: " << errorsOnGPU << " on cpu found: " << errorsOnCPU << std::endl; + + h_totFEDErrors_->Fill(errorsOnCPU, errorsOnGPU); + + // fill the correlations per error type + for (unsigned int j = k_FED25; j <= k_FED31; j++) { + SiPixelFEDErrorCodes code = static_cast(j); + h_nFEDErrors_[code]->Fill(countsOnCPU[j], countsOnGPU[j]); + } + + // fill the error unbalance per FEDid per error type + for (int i = 0; i < nFEDs; i++) { + for (int j = 0; j < nErrors; j++) { + if (countsMatrixOnGPU[i][j] != 0 || countsMatrixOnCPU[i][j] != 0) { + edm::LogInfo("SiPixelPhase1RawDataErrorComparator") + << "FED: " << i + FEDNumbering::MINSiPixeluTCAFEDID << " error: " << j + k_FED25 + << " | GPU counts: " << countsMatrixOnGPU[i][j] << " CPU counts:" << countsMatrixOnCPU[i][j] << std::endl; + h_FEDerrorVsFEDIdUnbalance_->Fill( + j, i + FEDNumbering::MINSiPixeluTCAFEDID, countsMatrixOnGPU[i][j] - countsMatrixOnCPU[i][j]); + } + } + } +} + +// +// -- Book Histograms +// +void SiPixelPhase1RawDataErrorComparator::bookHistograms(DQMStore::IBooker& iBook, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + iBook.cd(); + iBook.setCurrentFolder(topFolderName_); + + h_FEDerrorVsFEDIdUnbalance_ = + iBook.book2I("FEErrorVsFEDIdUnbalance", + "difference (GPU-CPE) of FED errors per FEDid per error type;;FED Id number;GPU counts - CPU counts", + nErrors, + -0.5, + nErrors - 0.5, + nFEDs, + FEDNumbering::MINSiPixeluTCAFEDID - 0.5, + FEDNumbering::MAXSiPixeluTCAFEDID - 0.5); + for (int j = 0; j < nErrors; j++) { + const auto& errorCode = static_cast(j + k_FED25); + h_FEDerrorVsFEDIdUnbalance_->setBinLabel(j + 1, errorCodeToTypeMap[errorCode]); + } + + h_totFEDErrors_ = make2DIfLog(iBook, + true, + true, + "nTotalFEDError", + "n. of total Pixel FEDError per event; CPU; GPU", + 500, + log10(0.5), + log10(500.5), + 500, + log10(0.5), + log10(500.5)); + + for (const auto& element : errorCodeToStringMap) { + h_nFEDErrors_[element.first] = iBook.book2I(fmt::sprintf("nFED%i_Errors", element.first), + fmt::sprintf("n. of %ss per event; CPU; GPU", element.second), + 501, + -0.5, + 500.5, + 501, + -0.5, + 500.5); + } +} + +void SiPixelPhase1RawDataErrorComparator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + //desc.add("pixelErrorSrcGPU", edm::InputTag("siPixelDigiErrors")); + desc.add("pixelErrorSrcGPU", edm::InputTag("siPixelDigis@cuda")) + ->setComment("input GPU SiPixel FED errors"); + desc.add("pixelErrorSrcCPU", edm::InputTag("siPixelDigis@cpu")) + ->setComment("input CPU SiPixel FED errors"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelErrorCompareGPUvsCPU"); + descriptions.addWithDefaultLabel(desc); +} + +DEFINE_FWK_MODULE(SiPixelPhase1RawDataErrorComparator); diff --git a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py index 1385e7425c49b..b44c64dff8a3d 100644 --- a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py @@ -20,6 +20,7 @@ from DQM.SiPixelHeterogeneous.siPixelPhase1CompareTrackSoA_cfi import * from DQM.SiPixelHeterogeneous.siPixelPhase2CompareTrackSoA_cfi import * from DQM.SiPixelHeterogeneous.siPixelCompareVertexSoA_cfi import * +from DQM.SiPixelHeterogeneous.siPixelPhase1RawDataErrorComparator_cfi import * ## rechits siPixelPhase1MonitorRecHitsSoACPU = siPixelPhase1MonitorRecHitsSoA.clone( @@ -83,7 +84,8 @@ siPixelPhase1CompareTrackSoA * siPixelMonitorVertexSoACPU * siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA) + siPixelCompareVertexSoA * + siPixelPhase1RawDataErrorComparator) # Phase-2 sequence _monitorpixelSoACompareSource = cms.Sequence(siPixelPhase2MonitorRecHitsSoACPU * From 628d6a850663bd94d7e1904c92f8ac1c9862312b Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 8 Jun 2023 21:31:43 +0200 Subject: [PATCH 2/4] fix mistake on pixelHitsSrcCPU --- DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc index c13aa5eb47b42..5d2b2a2f28216 100644 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc @@ -238,7 +238,7 @@ template void SiPixelCompareRecHitsSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { // monitorpixelRecHitsSoA edm::ParameterSetDescription desc; - desc.add("pixelHitsSrcCPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@Host")); + desc.add("pixelHitsSrcCPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu")); desc.add("pixelHitsSrcGPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cuda")); desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareDevicevsHost"); desc.add("minD2cut", 0.0001); From c70eefaf93139fb9762e8c853b77614067dd7955 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 11 Jun 2023 11:59:17 +0200 Subject: [PATCH 3/4] rename Host -> CPU and Device -> GPU to comply with the rest of the conventions in this package --- .../plugins/SiPixelCompareRecHitsSoA.cc | 164 +++++++++--------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc index 5d2b2a2f28216..a6a26f3fc58fc 100644 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc +++ b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc @@ -44,8 +44,8 @@ class SiPixelCompareRecHitsSoA : public DQMEDAnalyzer { 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 edm::EDGetTokenT tokenSoAHitsCPU_; //these two are both on CPU but originally they have been + const edm::EDGetTokenT tokenSoAHitsGPU_; //produced on CPU or on GPU const std::string topFolderName_; const float mind2cut_; static constexpr uint32_t invalidHit_ = std::numeric_limits::max(); @@ -83,8 +83,8 @@ template SiPixelCompareRecHitsSoA::SiPixelCompareRecHitsSoA(const edm::ParameterSet& iConfig) : geomToken_(esConsumes()), topoToken_(esConsumes()), - tokenSoAHitsHost_(consumes(iConfig.getParameter("pixelHitsSrcCPU"))), - tokenSoAHitsDevice_(consumes(iConfig.getParameter("pixelHitsSrcGPU"))), + tokenSoAHitsCPU_(consumes(iConfig.getParameter("pixelHitsSrcCPU"))), + tokenSoAHitsGPU_(consumes(iConfig.getParameter("pixelHitsSrcGPU"))), topFolderName_(iConfig.getParameter("topFolderName")), mind2cut_(iConfig.getParameter("minD2cut")) {} // @@ -101,41 +101,41 @@ void SiPixelCompareRecHitsSoA::dqmBeginRun(const edm::Run& iRun, const edm::E // template void SiPixelCompareRecHitsSoA::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) { + const auto& rhsoaHandleCPU = iEvent.getHandle(tokenSoAHitsCPU_); + const auto& rhsoaHandleGPU = iEvent.getHandle(tokenSoAHitsGPU_); + if (not rhsoaHandleCPU or not rhsoaHandleGPU) { edm::LogWarning out("SiPixelCompareRecHitSoA"); - if (not rhsoaHandleHost) { - out << "reference (Host) rechits not found; "; + if (not rhsoaHandleCPU) { + out << "reference (CPU) rechits not found; "; } - if (not rhsoaHandleDevice) { - out << "target (Device) rechits not found; "; + if (not rhsoaHandleGPU) { + out << "target (GPU) rechits not found; "; } out << "the comparison will not run."; return; } - auto const& rhsoaHost = *rhsoaHandleHost; - auto const& rhsoaDevice = *rhsoaHandleDevice; + auto const& rhsoaCPU = *rhsoaHandleCPU; + auto const& rhsoaGPU = *rhsoaHandleGPU; - auto const& soa2dHost = rhsoaHost.const_view(); - auto const& soa2dDevice = rhsoaDevice.const_view(); + auto const& soa2dCPU = rhsoaCPU.const_view(); + auto const& soa2dGPU = rhsoaGPU.const_view(); - uint32_t nHitsHost = soa2dHost.nHits(); - uint32_t nHitsDevice = soa2dDevice.nHits(); + uint32_t nHitsCPU = soa2dCPU.nHits(); + uint32_t nHitsGPU = soa2dGPU.nHits(); - hnHits_->Fill(nHitsHost, nHitsDevice); + hnHits_->Fill(nHitsCPU, nHitsGPU); auto detIds = tkGeom_->detUnitIds(); - for (uint32_t i = 0; i < nHitsHost; i++) { + for (uint32_t i = 0; i < nHitsCPU; 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(); + uint16_t indCPU = soa2dCPU[i].detectorIndex(); + float xLocalCPU = soa2dCPU[i].xLocal(); + float yLocalCPU = soa2dCPU[i].yLocal(); + for (uint32_t j = 0; j < nHitsGPU; j++) { + if (soa2dGPU.detectorIndex(j) == indCPU) { + float dx = xLocalCPU - soa2dGPU[j].xLocal(); + float dy = yLocalCPU - soa2dGPU[j].yLocal(); float distance = dx * dx + dy * dy; if (distance < minD) { minD = distance; @@ -143,46 +143,46 @@ void SiPixelCompareRecHitsSoA::analyze(const edm::Event& iEvent, const edm::E } } } - 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.; + DetId id = detIds[indCPU]; + uint32_t chargeCPU = soa2dCPU[i].chargeAndStatus().charge; + int16_t sizeXCPU = std::ceil(float(std::abs(soa2dCPU[i].clusterSizeX()) / 8.)); + int16_t sizeYCPU = std::ceil(float(std::abs(soa2dCPU[i].clusterSizeY()) / 8.)); + uint32_t chargeGPU = 0; + int16_t sizeXGPU = -99; + int16_t sizeYGPU = -99; + float xLocalGPU = -999.; + float yLocalGPU = -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(); + chargeGPU = soa2dGPU[matchedHit].chargeAndStatus().charge; + sizeXGPU = std::ceil(float(std::abs(soa2dGPU[matchedHit].clusterSizeX()) / 8.)); + sizeYGPU = std::ceil(float(std::abs(soa2dGPU[matchedHit].clusterSizeY()) / 8.)); + xLocalGPU = soa2dGPU[matchedHit].xLocal(); + yLocalGPU = soa2dGPU[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)); + hBchargeL_[tTopo_->pxbLayer(id) - 1]->Fill(chargeCPU, chargeGPU); + hBsizexL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeXCPU, sizeXGPU); + hBsizeyL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeYCPU, sizeYGPU); + hBposxL_[tTopo_->pxbLayer(id) - 1]->Fill(xLocalCPU, xLocalGPU); + hBposyL_[tTopo_->pxbLayer(id) - 1]->Fill(yLocalCPU, yLocalGPU); + hBchargeDiff_->Fill(chargeCPU - chargeGPU); + hBsizeXDiff_->Fill(sizeXCPU - sizeXGPU); + hBsizeYDiff_->Fill(sizeYCPU - sizeYGPU); + hBposXDiff_->Fill(micron_ * (xLocalCPU - xLocalGPU)); + hBposYDiff_->Fill(micron_ * (yLocalCPU - yLocalGPU)); 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)); + hFchargeD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(chargeCPU, chargeGPU); + hFsizexD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeXCPU, sizeXGPU); + hFsizeyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeYCPU, sizeYGPU); + hFposxD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xLocalCPU, xLocalGPU); + hFposyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(yLocalCPU, yLocalGPU); + hFchargeDiff_->Fill(chargeCPU - chargeGPU); + hFsizeXDiff_->Fill(sizeXCPU - sizeXGPU); + hFsizeYDiff_->Fill(sizeYCPU - sizeYGPU); + hFposXDiff_->Fill(micron_ * (xLocalCPU - xLocalGPU)); + hFposYDiff_->Fill(micron_ * (yLocalCPU - yLocalGPU)); break; } } @@ -200,38 +200,38 @@ void SiPixelCompareRecHitsSoA::bookHistograms(DQMStore::IBooker& iBook, // clang-format off //Global - hnHits_ = iBook.book2I("nHits", "HostvsDevice RecHits per event;#Host RecHits;#Device RecHits", 200, 0, 5000,200, 0, 5000); + hnHits_ = iBook.book2I("nHits", "CPUvsGPU RecHits per event;#CPU RecHits;#GPU 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); + hBchargeL_[il] = iBook.book2I(Form("recHitsBLay%dCharge",il+1), Form("CPUvsGPU RecHits Charge Barrel Layer%d;CPU Charge;GPU Charge",il+1), 250, 0, 100000, 250, 0, 100000); + hBsizexL_[il] = iBook.book2I(Form("recHitsBLay%dSizex",il+1), Form("CPUvsGPU RecHits SizeX Barrel Layer%d;CPU SizeX;GPU SizeX",il+1), 30, 0, 30, 30, 0, 30); + hBsizeyL_[il] = iBook.book2I(Form("recHitsBLay%dSizey",il+1), Form("CPUvsGPU RecHits SizeY Barrel Layer%d;CPU SizeY;GPU SizeY",il+1), 30, 0, 30, 30, 0, 30); + hBposxL_[il] = iBook.book2D(Form("recHitsBLay%dPosx",il+1), Form("CPUvsGPU RecHits x-pos in Barrel Layer%d;CPU pos x;GPU pos x",il+1), 200, -5, 5, 200,-5,5); + hBposyL_[il] = iBook.book2D(Form("recHitsBLay%dPosy",il+1), Form("CPUvsGPU RecHits y-pos in Barrel Layer%d;CPU pos y;GPU 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); + hFchargeD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dCharge",id*sign+sign), Form("CPUvsGPU RecHits Charge Endcaps Disk%+d;CPU Charge;GPU Charge",id*sign+sign), 250, 0, 100000, 250, 0, 100000); + hFsizexD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizex",id*sign+sign), Form("CPUvsGPU RecHits SizeX Endcaps Disk%+d;CPU SizeX;GPU SizeX",id*sign+sign), 30, 0, 30, 30, 0, 30); + hFsizeyD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizey",id*sign+sign), Form("CPUvsGPU RecHits SizeY Endcaps Disk%+d;CPU SizeY;GPU SizeY",id*sign+sign), 30, 0, 30, 30, 0, 30); + hFposxD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosx",id*sign+sign), Form("CPUvsGPU RecHits x-pos Endcaps Disk%+d;CPU pos x;GPU pos x",id*sign+sign), 200, -5, 5, 200, -5, 5); + hFposyD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosy",id*sign+sign), Form("CPUvsGPU RecHits y-pos Endcaps Disk%+d;CPU pos y;GPU 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); + hBchargeDiff_ = iBook.book1D("rechitChargeDiffBpix","Charge differnce of rechits in BPix; rechit charge difference (CPU - GPU)", 101, -50.5, 50.5); + hFchargeDiff_ = iBook.book1D("rechitChargeDiffFpix","Charge differnce of rechits in FPix; rechit charge difference (CPU - GPU)", 101, -50.5, 50.5); + hBsizeXDiff_ = iBook.book1D("rechitsizeXDiffBpix","SizeX difference of rechits in BPix; rechit sizex difference (CPU - GPU)", 21, -10.5, 10.5); + hFsizeXDiff_ = iBook.book1D("rechitsizeXDiffFpix","SizeX difference of rechits in FPix; rechit sizex difference (CPU - GPU)", 21, -10.5, 10.5); + hBsizeYDiff_ = iBook.book1D("rechitsizeYDiffBpix","SizeY difference of rechits in BPix; rechit sizey difference (CPU - GPU)", 21, -10.5, 10.5); + hFsizeYDiff_ = iBook.book1D("rechitsizeYDiffFpix","SizeY difference of rechits in FPix; rechit sizey difference (CPU - GPU)", 21, -10.5, 10.5); + hBposXDiff_ = iBook.book1D("rechitsposXDiffBpix","x-position difference of rechits in BPix; rechit x-pos difference (CPU - GPU)", 1000, -10, 10); + hFposXDiff_ = iBook.book1D("rechitsposXDiffFpix","x-position difference of rechits in FPix; rechit x-pos difference (CPU - GPU)", 1000, -10, 10); + hBposYDiff_ = iBook.book1D("rechitsposYDiffBpix","y-position difference of rechits in BPix; rechit y-pos difference (CPU - GPU)", 1000, -10, 10); + hFposYDiff_ = iBook.book1D("rechitsposYDiffFpix","y-position difference of rechits in FPix; rechit y-pos difference (CPU - GPU)", 1000, -10, 10); } template @@ -240,7 +240,7 @@ void SiPixelCompareRecHitsSoA::fillDescriptions(edm::ConfigurationDescription edm::ParameterSetDescription desc; desc.add("pixelHitsSrcCPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu")); desc.add("pixelHitsSrcGPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cuda")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareDevicevsHost"); + desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU"); desc.add("minD2cut", 0.0001); descriptions.addWithDefaultLabel(desc); } From b94af65c22a60ef78d03575b6b8cb3fe1849d779 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 11 Jun 2023 12:00:13 +0200 Subject: [PATCH 4/4] add SiPixelPhase1RawDataAnalyzer to the CPU and GPU branches in case the gpuValidation modifier is run --- .../SiPixelHeterogenousDQMHarvesting_cff.py | 11 +++++++- .../SiPixelHeterogenousDQM_FirstStep_cff.py | 25 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQMHarvesting_cff.py b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQMHarvesting_cff.py index 24c26e9d99c0b..d39b9e277bec7 100644 --- a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQMHarvesting_cff.py +++ b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQMHarvesting_cff.py @@ -1,8 +1,17 @@ import FWCore.ParameterSet.Config as cms siPixelHeterogeneousDQMHarvesting = cms.Sequence() # empty sequence if not both CPU and GPU recos are run +from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import * +from DQM.SiPixelHeterogeneous.SiPixelHeterogenousDQM_FirstStep_cff import SiPixelPhase1RawDataConfForCPU,SiPixelPhase1RawDataConfForGPU + +siPixelPhase1RawDataHarvesterCPU = SiPixelPhase1RawDataHarvester.clone(histograms = SiPixelPhase1RawDataConfForCPU) +siPixelPhase1RawDataHarvesterGPU = SiPixelPhase1RawDataHarvester.clone(histograms = SiPixelPhase1RawDataConfForGPU) + from DQM.SiPixelHeterogeneous.siPixelTrackComparisonHarvester_cfi import * -siPixelHeterogeneousDQMComparisonHarvesting = cms.Sequence(siPixelTrackComparisonHarvester) + +siPixelHeterogeneousDQMComparisonHarvesting = cms.Sequence(siPixelPhase1RawDataHarvesterCPU * + siPixelPhase1RawDataHarvesterGPU * + siPixelTrackComparisonHarvester ) # add the harvester in case of the validation modifier is active from Configuration.ProcessModifiers.gpuValidationPixel_cff import gpuValidationPixel diff --git a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py index b44c64dff8a3d..6a263beee2e22 100644 --- a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py @@ -1,3 +1,4 @@ +import copy import FWCore.ParameterSet.Config as cms from DQM.SiPixelHeterogeneous.siPixelPhase1MonitorRecHitsSoA_cfi import * from DQM.SiPixelHeterogeneous.siPixelPhase2MonitorRecHitsSoA_cfi import * @@ -21,6 +22,26 @@ from DQM.SiPixelHeterogeneous.siPixelPhase2CompareTrackSoA_cfi import * from DQM.SiPixelHeterogeneous.siPixelCompareVertexSoA_cfi import * from DQM.SiPixelHeterogeneous.siPixelPhase1RawDataErrorComparator_cfi import * +from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import * + +# digi errors +SiPixelPhase1RawDataConfForCPU = copy.deepcopy(SiPixelPhase1RawDataConf) +for pset in SiPixelPhase1RawDataConfForCPU: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsCPU" + +siPixelPhase1MonitorRawDataACPU = SiPixelPhase1RawDataAnalyzer.clone( + src = "siPixelDigis@cpu", + histograms = SiPixelPhase1RawDataConfForCPU +) + +SiPixelPhase1RawDataConfForGPU = copy.deepcopy(SiPixelPhase1RawDataConf) +for pset in SiPixelPhase1RawDataConfForGPU: + pset.topFolderName = "SiPixelHeterogeneous/PixelErrorsGPU" + +siPixelPhase1MonitorRawDataAGPU = SiPixelPhase1RawDataAnalyzer.clone( + src = "siPixelDigis@cuda", + histograms =SiPixelPhase1RawDataConfForGPU +) ## rechits siPixelPhase1MonitorRecHitsSoACPU = siPixelPhase1MonitorRecHitsSoA.clone( @@ -76,7 +97,9 @@ ) # Run-3 sequence -monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorRecHitsSoACPU * +monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorRawDataACPU * + siPixelPhase1MonitorRawDataAGPU * + siPixelPhase1MonitorRecHitsSoACPU * siPixelPhase1MonitorRecHitsSoAGPU * siPixelPhase1CompareRecHitsSoA * siPixelPhase1MonitorTrackSoAGPU *