diff --git a/DQM/SiPixelHeterogeneous/plugins/BuildFile.xml b/DQM/SiPixelHeterogeneous/plugins/BuildFile.xml index 79925fdcb6cf8..7606931353d8d 100644 --- a/DQM/SiPixelHeterogeneous/plugins/BuildFile.xml +++ b/DQM/SiPixelHeterogeneous/plugins/BuildFile.xml @@ -9,7 +9,4 @@ - - - diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc deleted file mode 100644 index 7e7efbc764edb..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoA.cc +++ /dev/null @@ -1,254 +0,0 @@ -// -*- C++ -*- -// Package: SiPixelCompareRecHitsSoA -// Class: SiPixelCompareRecHitsSoA -// -/**\class SiPixelCompareRecHitsSoA SiPixelCompareRecHitsSoA.cc -*/ -// -// Author: Suvankar Roy Chowdhury, Alessandro Rossi -// -#include "DataFormats/Math/interface/approx_atan2.h" -#include "DataFormats/Common/interface/Handle.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" -// DQM Histograming -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHitSoAHost.h" -#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHitsUtilities.h" -// Geometry -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -#include "Geometry/CommonTopologies/interface/PixelTopology.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" - -template -class SiPixelCompareRecHitsSoA : public DQMEDAnalyzer { -public: - using HitSoA = TrackingRecHitSoAView; - using HitsOnHost = TrackingRecHitSoAHost; - - explicit SiPixelCompareRecHitsSoA(const edm::ParameterSet&); - ~SiPixelCompareRecHitsSoA() 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 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(); - 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 -SiPixelCompareRecHitsSoA::SiPixelCompareRecHitsSoA(const edm::ParameterSet& iConfig) - : geomToken_(esConsumes()), - topoToken_(esConsumes()), - tokenSoAHitsCPU_(consumes(iConfig.getParameter("pixelHitsSrcCPU"))), - tokenSoAHitsGPU_(consumes(iConfig.getParameter("pixelHitsSrcGPU"))), - topFolderName_(iConfig.getParameter("topFolderName")), - mind2cut_(iConfig.getParameter("minD2cut")) {} -// -// Begin Run -// -template -void SiPixelCompareRecHitsSoA::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { - tkGeom_ = &iSetup.getData(geomToken_); - tTopo_ = &iSetup.getData(topoToken_); -} - -// -// -- Analyze -// -template -void SiPixelCompareRecHitsSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& rhsoaHandleCPU = iEvent.getHandle(tokenSoAHitsCPU_); - const auto& rhsoaHandleGPU = iEvent.getHandle(tokenSoAHitsGPU_); - if (not rhsoaHandleCPU or not rhsoaHandleGPU) { - edm::LogWarning out("SiPixelCompareRecHitSoA"); - if (not rhsoaHandleCPU) { - out << "reference (CPU) rechits not found; "; - } - if (not rhsoaHandleGPU) { - out << "target (GPU) rechits not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& rhsoaCPU = *rhsoaHandleCPU; - auto const& rhsoaGPU = *rhsoaHandleGPU; - - auto const& soa2dCPU = rhsoaCPU.const_view(); - auto const& soa2dGPU = rhsoaGPU.const_view(); - - uint32_t nHitsCPU = soa2dCPU.nHits(); - uint32_t nHitsGPU = soa2dGPU.nHits(); - - hnHits_->Fill(nHitsCPU, nHitsGPU); - auto detIds = tkGeom_->detUnitIds(); - for (uint32_t i = 0; i < nHitsCPU; i++) { - float minD = mind2cut_; - uint32_t matchedHit = invalidHit_; - 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; - matchedHit = j; - } - } - } - 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_) { - 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(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(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; - } - } -} - -// -// -- Book Histograms -// -template -void SiPixelCompareRecHitsSoA::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", "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("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("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 difference of rechits in BPix; rechit charge difference (CPU - GPU)", 101, -50.5, 50.5); - hFchargeDiff_ = iBook.book1D("rechitChargeDiffFpix","Charge difference 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 -void SiPixelCompareRecHitsSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelRecHitsSoA - edm::ParameterSetDescription desc; - desc.add("pixelHitsSrcCPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu")); - desc.add("pixelHitsSrcGPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cuda")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU"); - desc.add("minD2cut", 0.0001); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1CompareRecHitsSoA = SiPixelCompareRecHitsSoA; -using SiPixelPhase2CompareRecHitsSoA = SiPixelCompareRecHitsSoA; -using SiPixelHIonPhase1CompareRecHitsSoA = SiPixelCompareRecHitsSoA; - -DEFINE_FWK_MODULE(SiPixelPhase1CompareRecHitsSoA); -DEFINE_FWK_MODULE(SiPixelPhase2CompareRecHitsSoA); -DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareRecHitsSoA); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoA.cc deleted file mode 100644 index 3dc60de8416c6..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoA.cc +++ /dev/null @@ -1,368 +0,0 @@ -// -*- C++ -*- -// Package: SiPixelCompareTrackSoA -// Class: SiPixelCompareTrackSoA -// -/**\class SiPixelCompareTrackSoA SiPixelCompareTrackSoA.cc -*/ -// -// Author: Suvankar Roy Chowdhury -// -#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" -#include "CUDADataFormats/Track/interface/TrackSoAHeterogeneousHost.h" -#include "CUDADataFormats/Track/interface/TrackSoAHeterogeneousDevice.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()); - } -} // namespace - -template -class SiPixelCompareTrackSoA : public DQMEDAnalyzer { -public: - using PixelTrackSoA = TrackSoAHeterogeneousHost; - - explicit SiPixelCompareTrackSoA(const edm::ParameterSet&); - ~SiPixelCompareTrackSoA() override = default; - void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; - void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - const edm::EDGetTokenT tokenSoATrackCPU_; - const edm::EDGetTokenT tokenSoATrackGPU_; - const std::string topFolderName_; - const bool useQualityCut_; - const pixelTrack::Quality minQuality_; - const float dr2cut_; - MonitorElement* hnTracks_; - MonitorElement* hnLooseAndAboveTracks_; - MonitorElement* hnLooseAndAboveTracks_matched_; - MonitorElement* hDeltaNTracks_; - MonitorElement* hDeltaNLooseAndAboveTracks_; - MonitorElement* hDeltaNLooseAndAboveTracks_matched_; - MonitorElement* hnHits_; - MonitorElement* hnHitsVsPhi_; - MonitorElement* hnHitsVsEta_; - MonitorElement* hnLayers_; - MonitorElement* hnLayersVsPhi_; - MonitorElement* hnLayersVsEta_; - MonitorElement* hCharge_; - MonitorElement* hchi2_; - MonitorElement* hChi2VsPhi_; - MonitorElement* hChi2VsEta_; - MonitorElement* hpt_; - MonitorElement* hCurvature_; - 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 -SiPixelCompareTrackSoA::SiPixelCompareTrackSoA(const edm::ParameterSet& iConfig) - : tokenSoATrackCPU_(consumes(iConfig.getParameter("pixelTrackSrcCPU"))), - tokenSoATrackGPU_(consumes(iConfig.getParameter("pixelTrackSrcGPU"))), - topFolderName_(iConfig.getParameter("topFolderName")), - useQualityCut_(iConfig.getParameter("useQualityCut")), - minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), - dr2cut_(iConfig.getParameter("deltaR2cut")) {} - -// -// -- Analyze -// -template -void SiPixelCompareTrackSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using helper = TracksUtilities; - const auto& tsoaHandleCPU = iEvent.getHandle(tokenSoATrackCPU_); - const auto& tsoaHandleGPU = iEvent.getHandle(tokenSoATrackGPU_); - if (not tsoaHandleCPU or not tsoaHandleGPU) { - edm::LogWarning out("SiPixelCompareTrackSoA"); - if (not tsoaHandleCPU) { - out << "reference (cpu) tracks not found; "; - } - if (not tsoaHandleGPU) { - out << "target (gpu) tracks not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& tsoaCPU = *tsoaHandleCPU; - auto const& tsoaGPU = *tsoaHandleGPU; - auto maxTracksCPU = tsoaCPU.view().metadata().size(); //this should be same for both? - auto maxTracksGPU = tsoaGPU.view().metadata().size(); //this should be same for both? - auto const qualityCPU = tsoaCPU.view().quality(); - auto const qualityGPU = tsoaGPU.view().quality(); - int32_t nTracksCPU = 0; - int32_t nTracksGPU = 0; - int32_t nLooseAndAboveTracksCPU = 0; - int32_t nLooseAndAboveTracksCPU_matchedGPU = 0; - int32_t nLooseAndAboveTracksGPU = 0; - - //Loop over GPU tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? - std::vector looseTrkidxGPU; - for (int32_t jt = 0; jt < maxTracksGPU; ++jt) { - if (helper::nHits(tsoaGPU.view(), jt) == 0) - break; // this is a guard - if (!(tsoaGPU.view()[jt].pt() > 0.)) - continue; - nTracksGPU++; - if (useQualityCut_ && qualityGPU[jt] < minQuality_) - continue; - nLooseAndAboveTracksGPU++; - looseTrkidxGPU.emplace_back(jt); - } - - //Now loop over CPU tracks//nested loop for loose gPU tracks - for (int32_t it = 0; it < maxTracksCPU; ++it) { - int nHitsCPU = helper::nHits(tsoaCPU.view(), it); - - if (nHitsCPU == 0) - break; // this is a guard - - float ptCPU = tsoaCPU.view()[it].pt(); - float etaCPU = tsoaCPU.view()[it].eta(); - float phiCPU = helper::phi(tsoaCPU.view(), it); - float zipCPU = helper::zip(tsoaCPU.view(), it); - float tipCPU = helper::tip(tsoaCPU.view(), it); - auto qCPU = helper::charge(tsoaCPU.view(), it); - - if (!(ptCPU > 0.)) - continue; - nTracksCPU++; - if (useQualityCut_ && qualityCPU[it] < minQuality_) - continue; - nLooseAndAboveTracksCPU++; - //Now loop over loose GPU trk and find the closest in DeltaR//do we need pt cut? - const int32_t notFound = -1; - int32_t closestTkidx = notFound; - float mindr2 = dr2cut_; - - for (auto gid : looseTrkidxGPU) { - float etaGPU = tsoaGPU.view()[gid].eta(); - float phiGPU = helper::phi(tsoaGPU.view(), gid); - float dr2 = reco::deltaR2(etaCPU, phiCPU, etaGPU, phiGPU); - if (dr2 > dr2cut_) - continue; // this is arbitrary - if (mindr2 > dr2) { - mindr2 = dr2; - closestTkidx = gid; - } - } - - hpt_eta_tkAllRef_->Fill(etaCPU, ptCPU); //all CPU tk - hphi_z_tkAllRef_->Fill(phiCPU, zipCPU); - if (closestTkidx == notFound) - continue; - nLooseAndAboveTracksCPU_matchedGPU++; - - hchi2_->Fill(tsoaCPU.view()[it].chi2(), tsoaGPU.view()[closestTkidx].chi2()); - hCharge_->Fill(qCPU, helper::charge(tsoaGPU.view(), closestTkidx)); - hnHits_->Fill(helper::nHits(tsoaCPU.view(), it), helper::nHits(tsoaGPU.view(), closestTkidx)); - hnLayers_->Fill(tsoaCPU.view()[it].nLayers(), tsoaGPU.view()[closestTkidx].nLayers()); - hpt_->Fill(ptCPU, tsoaGPU.view()[closestTkidx].pt()); - hCurvature_->Fill(qCPU / ptCPU, helper::charge(tsoaGPU.view(), closestTkidx) / tsoaGPU.view()[closestTkidx].pt()); - hptLogLog_->Fill(ptCPU, tsoaGPU.view()[closestTkidx].pt()); - heta_->Fill(etaCPU, tsoaGPU.view()[closestTkidx].eta()); - hphi_->Fill(phiCPU, helper::phi(tsoaGPU.view(), closestTkidx)); - hz_->Fill(zipCPU, helper::zip(tsoaGPU.view(), closestTkidx)); - htip_->Fill(tipCPU, helper::tip(tsoaGPU.view(), closestTkidx)); - hptdiffMatched_->Fill(ptCPU - tsoaGPU.view()[closestTkidx].pt()); - hCurvdiffMatched_->Fill((helper::charge(tsoaCPU.view(), it) / tsoaCPU.view()[it].pt()) - - (helper::charge(tsoaGPU.view(), closestTkidx) / tsoaGPU.view()[closestTkidx].pt())); - hetadiffMatched_->Fill(etaCPU - tsoaGPU.view()[closestTkidx].eta()); - hphidiffMatched_->Fill(reco::deltaPhi(phiCPU, helper::phi(tsoaGPU.view(), closestTkidx))); - hzdiffMatched_->Fill(zipCPU - helper::zip(tsoaGPU.view(), closestTkidx)); - htipdiffMatched_->Fill(tipCPU - helper::tip(tsoaGPU.view(), closestTkidx)); - hpt_eta_tkAllRefMatched_->Fill(etaCPU, tsoaCPU.view()[it].pt()); //matched to gpu - hphi_z_tkAllRefMatched_->Fill(etaCPU, zipCPU); - } - - // Define a lambda function for filling the histograms - auto fillHistogram = [](auto& histogram, auto xValue, auto yValue) { histogram->Fill(xValue, yValue); }; - - // Define a lambda for filling delta histograms - auto fillDeltaHistogram = [](auto& histogram, int cpuValue, int gpuValue) { - histogram->Fill(std::min(cpuValue, 1000), std::clamp(gpuValue - cpuValue, -100, 100)); - }; - - // Fill the histograms - fillHistogram(hnTracks_, nTracksCPU, nTracksGPU); - fillHistogram(hnLooseAndAboveTracks_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); - fillHistogram(hnLooseAndAboveTracks_matched_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU); - - fillDeltaHistogram(hDeltaNTracks_, nTracksCPU, nTracksGPU); - fillDeltaHistogram(hDeltaNLooseAndAboveTracks_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU); - fillDeltaHistogram(hDeltaNLooseAndAboveTracks_matched_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU); -} - -// -// -- Book Histograms -// -template -void SiPixelCompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - iBook.cd(); - iBook.setCurrentFolder(topFolderName_); - - // Define a helper function for booking histograms - std::string toRep = "Number of tracks"; - auto bookTracksTH2I = [&](const std::string& name, - const std::string& title, - int xBins, - double xMin, - double xMax, - int yBins, - double yMin, - double yMax) { - return iBook.book2I(name, fmt::sprintf(title, toRep), xBins, xMin, xMax, yBins, yMin, yMax); - }; - - // Define common parameters for different histogram types - constexpr int xBins = 501; - constexpr double xMin = -0.5; - constexpr double xMax = 1001.5; - - constexpr int dXBins = 1001; - constexpr double dXMin = -0.5; - constexpr double dXMax = 1000.5; - - constexpr int dYBins = 201; - constexpr double dYMin = -100.5; - constexpr double dYMax = 100.5; - - // 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 - - // Book histograms using the helper function - // clang-format off - hnTracks_ = bookTracksTH2I("nTracks", "%s per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax); - hnLooseAndAboveTracks_ = bookTracksTH2I("nLooseAndAboveTracks", "%s (quality #geq loose) per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax); - hnLooseAndAboveTracks_matched_ = bookTracksTH2I("nLooseAndAboveTracks_matched", "%s (quality #geq loose) per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax); - - hDeltaNTracks_ = bookTracksTH2I("deltaNTracks", "%s per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax); - hDeltaNLooseAndAboveTracks_ = bookTracksTH2I("deltaNLooseAndAboveTracks", "%s (quality #geq loose) per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax); - hDeltaNLooseAndAboveTracks_matched_ = bookTracksTH2I("deltaNLooseAndAboveTracks_matched", "%s (quality #geq loose) per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax); - - toRep = "Number of all RecHits per track (quality #geq loose)"; - hnHits_ = iBook.book2I("nRecHits", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); - - toRep = "Number of all layers per track (quality #geq loose)"; - hnLayers_ = iBook.book2I("nLayers", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); - - toRep = "Track (quality #geq loose) #chi^{2}/ndof"; - hchi2_ = iBook.book2I("nChi2ndof", fmt::sprintf("%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.); - - toRep = "Track (quality #geq loose) charge"; - hCharge_ = iBook.book2I("charge",fmt::sprintf("%s;CPU;GPU",toRep),3, -1.5, 1.5, 3, -1.5, 1.5); - - hpt_ = iBook.book2I("pt", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.); - hCurvature_ = iBook.book2I("curvature", "Track (quality #geq loose) q/p_{T} [GeV^{-1}];CPU;GPU", 60,- 3., 3., 60, -3., 3. ); - hptLogLog_ = make2DIfLog(iBook, true, true, "ptLogLog", "Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, log10(0.5), log10(200.), 200, log10(0.5), log10(200.)); - heta_ = iBook.book2I("eta", "Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.); - hphi_ = iBook.book2I("phi", "Track (quality #geq loose) #phi;CPU;GPU", 30, -M_PI, M_PI, 30, -M_PI, M_PI); - hz_ = iBook.book2I("z", "Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.); - htip_ = iBook.book2I("tip", "Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5); - //1D difference plots - hptdiffMatched_ = iBook.book1D("ptdiffmatched", " p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 61, -30.5, 30.5); - hCurvdiffMatched_ = iBook.book1D("curvdiffmatched", "q/p_{T} diff [GeV^{-1}] between matched tracks; #Delta q/p_{T} [GeV^{-1}]", 61, -3.05, 3.05); - hetadiffMatched_ = iBook.book1D("etadiffmatched", " #eta diff between matched tracks; #Delta #eta", 161, -0.045 ,0.045); - hphidiffMatched_ = iBook.book1D("phidiffmatched", " #phi diff between matched tracks; #Delta #phi", 161, -0.045 ,0.045); - hzdiffMatched_ = iBook.book1D("zdiffmatched", " z diff between matched tracks; #Delta z [cm]", 301, -1.55, 1.55); - htipdiffMatched_ = iBook.book1D("tipdiffmatched", " TIP diff between matched tracks; #Delta TIP [cm]", 301, -1.55, 1.55); - //2D plots for eff - hpt_eta_tkAllRef_ = iBook.book2I("ptetatrkAllReference", "Track (quality #geq loose) on CPU; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - hpt_eta_tkAllRefMatched_ = iBook.book2I("ptetatrkAllReferencematched", "Track (quality #geq loose) on CPU matched to GPU track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - - hphi_z_tkAllRef_ = iBook.book2I("phiztrkAllReference", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); - hphi_z_tkAllRefMatched_ = iBook.book2I("phiztrkAllReferencematched", "Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); - -} - -template -void SiPixelCompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelTrackSoA - edm::ParameterSetDescription desc; - desc.add("pixelTrackSrcCPU", edm::InputTag("pixelTracksSoA@cpu")); - desc.add("pixelTrackSrcGPU", edm::InputTag("pixelTracksSoA@cuda")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU"); - desc.add("useQualityCut", true); - desc.add("minQuality", "loose"); - desc.add("deltaR2cut", 0.02 * 0.02)->setComment("deltaR2 cut between track on CPU and GPU"); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1CompareTrackSoA = SiPixelCompareTrackSoA; -using SiPixelPhase2CompareTrackSoA = SiPixelCompareTrackSoA; -using SiPixelHIonPhase1CompareTrackSoA = SiPixelCompareTrackSoA; - -DEFINE_FWK_MODULE(SiPixelPhase1CompareTrackSoA); -DEFINE_FWK_MODULE(SiPixelPhase2CompareTrackSoA); -DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareTrackSoA); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoA.cc deleted file mode 100644 index 7961a17817d98..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoA.cc +++ /dev/null @@ -1,186 +0,0 @@ -// -*- C++ -*- -// Package: SiPixelCompareVertexSoA -// Class: SiPixelCompareVertexSoA -// -/**\class SiPixelCompareVertexSoA SiPixelCompareVertexSoA.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 "CUDADataFormats/Vertex/interface/ZVertexSoAHeterogeneousHost.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" - -class SiPixelCompareVertexSoA : public DQMEDAnalyzer { -public: - using IndToEdm = std::vector; - explicit SiPixelCompareVertexSoA(const edm::ParameterSet&); - ~SiPixelCompareVertexSoA() override = default; - void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; - void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - const edm::EDGetTokenT tokenSoAVertexCPU_; - const edm::EDGetTokenT tokenSoAVertexGPU_; - const edm::EDGetTokenT tokenBeamSpot_; - const std::string topFolderName_; - const float dzCut_; - MonitorElement* hnVertex_; - MonitorElement* hx_; - MonitorElement* hy_; - MonitorElement* hz_; - MonitorElement* hchi2_; - MonitorElement* hchi2oNdof_; - MonitorElement* hptv2_; - MonitorElement* hntrks_; - MonitorElement* hxdiff_; - MonitorElement* hydiff_; - MonitorElement* hzdiff_; -}; - -// -// constructors -// - -// Note tokenSoAVertexGPU_ contains data copied from device to host, hence is a HostCollection -SiPixelCompareVertexSoA::SiPixelCompareVertexSoA(const edm::ParameterSet& iConfig) - : tokenSoAVertexCPU_(consumes(iConfig.getParameter("pixelVertexSrcCPU"))), - tokenSoAVertexGPU_(consumes(iConfig.getParameter("pixelVertexSrcGPU"))), - tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), - topFolderName_(iConfig.getParameter("topFolderName")), - dzCut_(iConfig.getParameter("dzCut")) {} - -// -// -- Analyze -// -void SiPixelCompareVertexSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& vsoaHandleCPU = iEvent.getHandle(tokenSoAVertexCPU_); - const auto& vsoaHandleGPU = iEvent.getHandle(tokenSoAVertexGPU_); - if (not vsoaHandleCPU or not vsoaHandleGPU) { - edm::LogWarning out("SiPixelCompareVertexSoA"); - if (not vsoaHandleCPU) { - out << "reference (cpu) tracks not found; "; - } - if (not vsoaHandleGPU) { - out << "target (gpu) tracks not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& vsoaCPU = *vsoaHandleCPU; - int nVerticesCPU = vsoaCPU.view().nvFinal(); - auto const& vsoaGPU = *vsoaHandleGPU; - int nVerticesGPU = vsoaGPU.view().nvFinal(); - - auto bsHandle = iEvent.getHandle(tokenBeamSpot_); - float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.; - if (!bsHandle.isValid()) { - edm::LogWarning("SiPixelCompareVertexSoA") << "No beamspot found. returning vertexes with (0,0,Z) "; - } else { - const reco::BeamSpot& bs = *bsHandle; - x0 = bs.x0(); - y0 = bs.y0(); - z0 = bs.z0(); - dxdz = bs.dxdz(); - dydz = bs.dydz(); - } - - for (int ivc = 0; ivc < nVerticesCPU; ivc++) { - auto sic = vsoaCPU.view()[ivc].sortInd(); - auto zc = vsoaCPU.view()[sic].zv(); - auto xc = x0 + dxdz * zc; - auto yc = y0 + dydz * zc; - zc += z0; - - auto ndofCPU = vsoaCPU.view()[sic].ndof(); - auto chi2CPU = vsoaCPU.view()[sic].chi2(); - - const int32_t notFound = -1; - int32_t closestVtxidx = notFound; - float mindz = dzCut_; - - for (int ivg = 0; ivg < nVerticesGPU; ivg++) { - auto sig = vsoaGPU.view()[ivg].sortInd(); - auto zgc = vsoaGPU.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 = vsoaGPU.view()[closestVtxidx].zv(); - auto xg = x0 + dxdz * zg; - auto yg = y0 + dydz * zg; - zg += z0; - auto ndofGPU = vsoaGPU.view()[closestVtxidx].ndof(); - auto chi2GPU = vsoaGPU.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(chi2CPU, chi2GPU); - hchi2oNdof_->Fill(chi2CPU / ndofCPU, chi2GPU / ndofGPU); - hptv2_->Fill(vsoaCPU.view()[sic].ptv2(), vsoaGPU.view()[closestVtxidx].ptv2()); - hntrks_->Fill(ndofCPU + 1, ndofGPU + 1); - } - hnVertex_->Fill(nVerticesCPU, nVerticesGPU); -} - -// -// -- Book Histograms -// -void SiPixelCompareVertexSoA::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;CPU;GPU", 101, -0.5, 100.5, 101, -0.5, 100.5); - hx_ = ibooker.book2I("vx", "Vertez x - Beamspot x;CPU;GPU", 50, -0.1, 0.1, 50, -0.1, 0.1); - hy_ = ibooker.book2I("vy", "Vertez y - Beamspot y;CPU;GPU", 50, -0.1, 0.1, 50, -0.1, 0.1); - hz_ = ibooker.book2I("vz", "Vertez z;CPU;GPU", 30, -30., 30., 30, -30., 30.); - hchi2_ = ibooker.book2I("chi2", "Vertex chi-squared;CPU;GPU", 40, 0., 20., 40, 0., 20.); - hchi2oNdof_ = ibooker.book2I("chi2oNdof", "Vertex chi-squared/Ndof;CPU;GPU", 40, 0., 20., 40, 0., 20.); - hptv2_ = ibooker.book2I("ptsq", "Vertex #sum (p_{T})^{2};CPU;GPU", 200, 0., 200., 200, 0., 200.); - hntrks_ = ibooker.book2I("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); - hntrks_ = ibooker.book2I("ntrk", "#tracks associated;CPU;GPU", 100, -0.5, 99.5, 100, -0.5, 99.5); - hxdiff_ = ibooker.book1D("vxdiff", ";Vertex x difference (CPU - GPU);#entries", 100, -0.001, 0.001); - hydiff_ = ibooker.book1D("vydiff", ";Vertex y difference (CPU - GPU);#entries", 100, -0.001, 0.001); - hzdiff_ = ibooker.book1D("vzdiff", ";Vertex z difference (CPU - GPU);#entries", 100, -2.5, 2.5); -} - -void SiPixelCompareVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelVertexSoA - edm::ParameterSetDescription desc; - desc.add("pixelVertexSrcCPU", edm::InputTag("pixelVerticesSoA@cpu")); - desc.add("pixelVertexSrcGPU", edm::InputTag("pixelVerticesSoA@cuda")); - desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoAGPUvsCPU"); - desc.add("dzCut", 1.); - descriptions.addWithDefaultLabel(desc); -} - -DEFINE_FWK_MODULE(SiPixelCompareVertexSoA); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorRecHitsSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorRecHitsSoA.cc deleted file mode 100644 index a1feefe53ba58..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorRecHitsSoA.cc +++ /dev/null @@ -1,211 +0,0 @@ -// -*- C++ -*- -///bookLayer -// Package: SiPixelMonitorRecHitsSoA -// Class: SiPixelMonitorRecHitsSoA -// -/**\class SiPixelMonitorRecHitsSoA SiPixelMonitorRecHitsSoA.cc -*/ -// -// Author: Suvankar Roy Chowdhury, Alessandro Rossi -// -#include "DataFormats/Math/interface/approx_atan2.h" -#include "DataFormats/Common/interface/Handle.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" -// DQM Histograming -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHitSoAHost.h" -#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHitsUtilities.h" -// Geometry -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -#include "Geometry/CommonTopologies/interface/PixelTopology.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" - -template -class SiPixelMonitorRecHitsSoA : public DQMEDAnalyzer { -public: - using HitSoA = TrackingRecHitSoAView; - using HitsOnHost = TrackingRecHitSoAHost; - - explicit SiPixelMonitorRecHitsSoA(const edm::ParameterSet&); - ~SiPixelMonitorRecHitsSoA() 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 tokenSoAHitsCPU_; - const std::string topFolderName_; - const TrackerGeometry* tkGeom_ = nullptr; - const TrackerTopology* tTopo_ = nullptr; - MonitorElement* hnHits; - MonitorElement* hBFposZP; - MonitorElement* hBFposZR; - MonitorElement* hBposXY; - MonitorElement* hBposZP; - MonitorElement* hBcharge; - MonitorElement* hBsizex; - MonitorElement* hBsizey; - MonitorElement* hBposZPL[4]; // max 4 barrel hits - MonitorElement* hBchargeL[4]; - MonitorElement* hBsizexL[4]; - MonitorElement* hBsizeyL[4]; - MonitorElement* hFposXY; - MonitorElement* hFposZP; - MonitorElement* hFcharge; - MonitorElement* hFsizex; - MonitorElement* hFsizey; - MonitorElement* hFposXYD[2][12]; // max 12 endcap disks - MonitorElement* hFchargeD[2][12]; - MonitorElement* hFsizexD[2][12]; - MonitorElement* hFsizeyD[2][12]; -}; - -// -// constructors -// - -template -SiPixelMonitorRecHitsSoA::SiPixelMonitorRecHitsSoA(const edm::ParameterSet& iConfig) - : geomToken_(esConsumes()), - topoToken_(esConsumes()), - tokenSoAHitsCPU_(consumes(iConfig.getParameter("pixelHitsSrc"))), - topFolderName_(iConfig.getParameter("TopFolderName")) {} -// -// Begin Run -// -template -void SiPixelMonitorRecHitsSoA::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { - tkGeom_ = &iSetup.getData(geomToken_); - tTopo_ = &iSetup.getData(topoToken_); -} - -// -// -- Analyze -// -template -void SiPixelMonitorRecHitsSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& rhsoaHandle = iEvent.getHandle(tokenSoAHitsCPU_); - if (!rhsoaHandle.isValid()) { - edm::LogWarning("SiPixelMonitorRecHitsSoA") << "No RecHits SoA found \n returning!" << std::endl; - return; - } - auto const& rhsoa = *rhsoaHandle; - auto const& soa2d = rhsoa.const_view(); - - uint32_t nHits_ = soa2d.nHits(); - hnHits->Fill(nHits_); - auto detIds = tkGeom_->detUnitIds(); - for (uint32_t i = 0; i < nHits_; i++) { - DetId id = detIds[soa2d[i].detectorIndex()]; - float xG = soa2d[i].xGlobal(); - float yG = soa2d[i].yGlobal(); - float zG = soa2d[i].zGlobal(); - float rG = soa2d[i].rGlobal(); - float fphi = short2phi(soa2d[i].iphi()); - uint32_t charge = soa2d[i].chargeAndStatus().charge; - int16_t sizeX = std::ceil(float(std::abs(soa2d[i].clusterSizeX()) / 8.)); - int16_t sizeY = std::ceil(float(std::abs(soa2d[i].clusterSizeY()) / 8.)); - hBFposZP->Fill(zG, fphi); - int16_t ysign = yG >= 0 ? 1 : -1; - hBFposZR->Fill(zG, rG * ysign); - switch (id.subdetId()) { - case PixelSubdetector::PixelBarrel: - hBposXY->Fill(xG, yG); - hBposZP->Fill(zG, fphi); - hBcharge->Fill(charge); - hBsizex->Fill(sizeX); - hBsizey->Fill(sizeY); - hBposZPL[tTopo_->pxbLayer(id) - 1]->Fill(zG, fphi); - hBchargeL[tTopo_->pxbLayer(id) - 1]->Fill(charge); - hBsizexL[tTopo_->pxbLayer(id) - 1]->Fill(sizeX); - hBsizeyL[tTopo_->pxbLayer(id) - 1]->Fill(sizeY); - break; - case PixelSubdetector::PixelEndcap: - hFposXY->Fill(xG, yG); - hFposZP->Fill(zG, fphi); - hFcharge->Fill(charge); - hFsizex->Fill(sizeX); - hFsizey->Fill(sizeY); - hFposXYD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xG, yG); - hFchargeD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(charge); - hFsizexD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeX); - hFsizeyD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeY); - break; - } - } -} - -// -// -- Book Histograms -// -template -void SiPixelMonitorRecHitsSoA::bookHistograms(DQMStore::IBooker& iBook, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - iBook.cd(); - iBook.setCurrentFolder(topFolderName_); - - // clang-format off - //Global - hnHits = iBook.book1D("nHits", "RecHits per event;RecHits;#events", 200, 0, 5000); - hBFposZP = iBook.book2D("recHitsGlobalPosZP", "RecHits position Global;Z;#phi", 1000, -60, 60, 200,-3.2,3.2); - hBFposZR = iBook.book2D("recHitsGlobalPosZR", "RecHits position Global;Z;R", 1000, -60, 60, 200,-20,20); - //Barrel - hBposXY = iBook.book2D("recHitsBarrelPosXY", "RecHits position Barrel;X;Y", 200, -20, 20, 200,-20,20); - hBposZP = iBook.book2D("recHitsBarrelPosZP", "RecHits position Barrel;Z;#phi", 300, -30, 30, 200,-3.2,3.2); - hBcharge = iBook.book1D("recHitsBarrelCharge", "RecHits Charge Barrel;Charge;#events", 250, 0, 100000); - hBsizex = iBook.book1D("recHitsBarrelSizex", "RecHits SizeX Barrel;SizeX;#events", 50, 0, 50); - hBsizey = iBook.book1D("recHitsBarrelSizey", "RecHits SizeY Barrel;SizeY;#events", 50, 0, 50); - //Barrel Layer - for(unsigned int il=0;ilnumberOfLayers(PixelSubdetector::PixelBarrel);il++){ - hBposZPL[il] = iBook.book2D(Form("recHitsBLay%dPosZP",il+1), Form("RecHits position Barrel Layer%d;Z;#phi",il+1), 300, -30, 30, 200,-3.2,3.2); - hBchargeL[il] = iBook.book1D(Form("recHitsBLay%dCharge",il+1), Form("RecHits Charge Barrel Layer%d;Charge;#events",il+1), 250, 0, 100000); - hBsizexL[il] = iBook.book1D(Form("recHitsBLay%dSizex",il+1), Form("RecHits SizeX Barrel Layer%d;SizeX;#events",il+1), 50, 0, 50); - hBsizeyL[il] = iBook.book1D(Form("recHitsBLay%dSizey",il+1), Form("RecHits SizeY Barrel Layer%d;SizeY;#events",il+1), 50, 0, 50); - } - //Endcaps - hFposXY = iBook.book2D("recHitsEndcapsPosXY", "RecHits position Endcaps;X;Y", 200, -20, 20, 200,-20, 20); - hFposZP = iBook.book2D("recHitsEndcapsPosZP", "RecHits position Endcaps;Z;#phi", 600, -60, 60, 200,-3.2,3.2); - hFcharge = iBook.book1D("recHitsEndcapsCharge", "RecHits Charge Endcaps;Charge;#events", 250, 0, 100000); - hFsizex = iBook.book1D("recHitsEndcapsSizex", "RecHits SizeX Endcaps;SizeX;#events", 50, 0, 50); - hFsizey = iBook.book1D("recHitsEndcapsSizey", "RecHits SizeY Endcaps;SizeY;#events", 50, 0, 50); - //Endcaps Disk - for(int is=0;is<2;is++){ - int sign=is==0? -1:1; - for(unsigned int id=0;idnumberOfLayers(PixelSubdetector::PixelEndcap);id++){ - hFposXYD[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosXY",id*sign+sign), Form("RecHits position Endcaps Disk%+d;X;Y",id*sign+sign), 200, -20, 20, 200,-20,20); - hFchargeD[is][id] = iBook.book1D(Form("recHitsFDisk%+dCharge",id*sign+sign), Form("RecHits Charge Endcaps Disk%+d;Charge;#events",id*sign+sign), 250, 0, 100000); - hFsizexD[is][id] = iBook.book1D(Form("recHitsFDisk%+dSizex",id*sign+sign), Form("RecHits SizeX Endcaps Disk%+d;SizeX;#events",id*sign+sign), 50, 0, 50); - hFsizeyD[is][id] = iBook.book1D(Form("recHitsFDisk%+dSizey",id*sign+sign), Form("RecHits SizeY Endcaps Disk%+d;SizeY;#events",id*sign+sign), 50, 0, 50); - } - } -} - -template -void SiPixelMonitorRecHitsSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelRecHitsSoA - edm::ParameterSetDescription desc; - desc.add("pixelHitsSrc", edm::InputTag("siPixelRecHitsPreSplittingSoA")); - desc.add("TopFolderName", "SiPixelHeterogeneous/PixelRecHitsSoA"); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1MonitorRecHitsSoA = SiPixelMonitorRecHitsSoA; -using SiPixelPhase2MonitorRecHitsSoA = SiPixelMonitorRecHitsSoA; -using SiPixelHIonPhase1MonitorRecHitsSoA = SiPixelMonitorRecHitsSoA; - -DEFINE_FWK_MODULE(SiPixelPhase1MonitorRecHitsSoA); -DEFINE_FWK_MODULE(SiPixelPhase2MonitorRecHitsSoA); -DEFINE_FWK_MODULE(SiPixelHIonPhase1MonitorRecHitsSoA); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoA.cc deleted file mode 100644 index 59565f4932ecc..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoA.cc +++ /dev/null @@ -1,201 +0,0 @@ -// -*- C++ -*- -// Package: SiPixelMonitorTrackSoA -// Class: SiPixelMonitorTrackSoA -// -/**\class SiPixelMonitorTrackSoA SiPixelMonitorTrackSoA.cc -*/ -// -// Author: Suvankar Roy Chowdhury -// -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "FWCore/Utilities/interface/InputTag.h" -// DQM Histograming -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "CUDADataFormats/Track/interface/PixelTrackUtilities.h" -#include "CUDADataFormats/Track/interface/TrackSoAHeterogeneousHost.h" -// for string manipulations -#include - -template -class SiPixelMonitorTrackSoA : public DQMEDAnalyzer { -public: - using PixelTrackHeterogeneous = TrackSoAHeterogeneousHost; - explicit SiPixelMonitorTrackSoA(const edm::ParameterSet&); - ~SiPixelMonitorTrackSoA() 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: - edm::EDGetTokenT tokenSoATrack_; - std::string topFolderName_; - bool useQualityCut_; - pixelTrack::Quality minQuality_; - MonitorElement* hnTracks; - MonitorElement* hnLooseAndAboveTracks; - MonitorElement* hnHits; - MonitorElement* hnHitsVsPhi; - MonitorElement* hnHitsVsEta; - MonitorElement* hnLayers; - MonitorElement* hnLayersVsPhi; - MonitorElement* hnLayersVsEta; - MonitorElement* hchi2; - MonitorElement* hChi2VsPhi; - MonitorElement* hChi2VsEta; - MonitorElement* hpt; - MonitorElement* hCurvature; - MonitorElement* heta; - MonitorElement* hphi; - MonitorElement* hz; - MonitorElement* htip; - MonitorElement* hquality; -}; - -// -// constructors -// - -template -SiPixelMonitorTrackSoA::SiPixelMonitorTrackSoA(const edm::ParameterSet& iConfig) { - tokenSoATrack_ = consumes(iConfig.getParameter("pixelTrackSrc")); - topFolderName_ = iConfig.getParameter("topFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA"; - useQualityCut_ = iConfig.getParameter("useQualityCut"); - minQuality_ = pixelTrack::qualityByName(iConfig.getParameter("minQuality")); -} - -// -// -- Analyze -// -template -void SiPixelMonitorTrackSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& tsoaHandle = iEvent.getHandle(tokenSoATrack_); - if (!tsoaHandle.isValid()) { - edm::LogWarning("SiPixelMonitorTrackSoA") << "No Track SoA found \n returning!" << std::endl; - return; - } - - using helper = TracksUtilities; - auto const& tsoa = *tsoaHandle.product(); - auto maxTracks = tsoa.view().metadata().size(); - auto const quality = tsoa.view().quality(); - int32_t nTracks = 0; - int32_t nLooseAndAboveTracks = 0; - - for (int32_t it = 0; it < maxTracks; ++it) { - auto nHits = helper::nHits(tsoa.const_view(), it); - auto nLayers = tsoa.view()[it].nLayers(); - if (nHits == 0) - break; // this is a guard - float pt = tsoa.view()[it].pt(); - if (!(pt > 0.)) - continue; - - // fill the quality for all tracks - pixelTrack::Quality qual = quality[it]; - hquality->Fill(int(qual)); - nTracks++; - - if (useQualityCut_ && quality[it] < minQuality_) - continue; - - // fill parameters only for quality >= loose - float chi2 = tsoa.view()[it].chi2(); - float phi = helper::phi(tsoa.const_view(), it); - float zip = helper::zip(tsoa.const_view(), it); - float eta = tsoa.view()[it].eta(); - float tip = helper::tip(tsoa.const_view(), it); - auto charge = helper::charge(tsoa.const_view(), it); - - hchi2->Fill(chi2); - hChi2VsPhi->Fill(phi, chi2); - hChi2VsEta->Fill(eta, chi2); - hnHits->Fill(nHits); - hnLayers->Fill(nLayers); - hnHitsVsPhi->Fill(phi, nHits); - hnHitsVsEta->Fill(eta, nHits); - hnLayersVsPhi->Fill(phi, nLayers); - hnLayersVsEta->Fill(eta, nLayers); - hpt->Fill(pt); - hCurvature->Fill(charge / pt); - heta->Fill(eta); - hphi->Fill(phi); - hz->Fill(zip); - htip->Fill(tip); - nLooseAndAboveTracks++; - } - hnTracks->Fill(nTracks); - hnLooseAndAboveTracks->Fill(nLooseAndAboveTracks); -} - -// -// -- Book Histograms -// -template -void SiPixelMonitorTrackSoA::bookHistograms(DQMStore::IBooker& iBook, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - iBook.cd(); - iBook.setCurrentFolder(topFolderName_); - - // clang-format off - std::string toRep = "Number of tracks"; - hnTracks = iBook.book1D("nTracks", fmt::sprintf(";%s per event;#events",toRep), 1001, -0.5, 2001.5); - hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::sprintf(";%s (quality #geq loose) per event;#events",toRep), 1001, -0.5, 2001.5); - - toRep = "Number of all RecHits per track (quality #geq loose)"; - hnHits = iBook.book1D("nRecHits", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5); - hnHitsVsPhi = iBook.bookProfile("nHitsPerTrackVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI,0., 15.); - hnHitsVsEta = iBook.bookProfile("nHitsPerTrackVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 15.); - - toRep = "Number of all layers per track (quality #geq loose)"; - hnLayers = iBook.book1D("nLayers", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5); - hnLayersVsPhi = iBook.bookProfile("nLayersPerTrackVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI,0., 15.); - hnLayersVsEta = iBook.bookProfile("nLayersPerTrackVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 15.); - - toRep = "Track (quality #geq loose) #chi^{2}/ndof"; - hchi2 = iBook.book1D("nChi2ndof", fmt::sprintf(";%s;#tracks",toRep), 40, 0., 20.); - hChi2VsPhi = iBook.bookProfile("nChi2ndofVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI, 0., 20.); - hChi2VsEta = iBook.bookProfile("nChi2ndofVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 20.); - // clang-format on - - hpt = iBook.book1D("pt", ";Track (quality #geq loose) p_{T} [GeV];#tracks", 200, 0., 200.); - hCurvature = iBook.book1D("curvature", ";Track (quality #geq loose) q/p_{T} [GeV^{-1}];#tracks", 100, -3., 3.); - heta = iBook.book1D("eta", ";Track (quality #geq loose) #eta;#tracks", 30, -3., 3.); - hphi = iBook.book1D("phi", ";Track (quality #geq loose) #phi;#tracks", 30, -M_PI, M_PI); - hz = iBook.book1D("z", ";Track (quality #geq loose) z [cm];#tracks", 30, -30., 30.); - 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) { - hquality->setBinLabel(i, q, 1); - i++; - } -} - -template -void SiPixelMonitorTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelTrackSoA - edm::ParameterSetDescription desc; - desc.add("pixelTrackSrc", edm::InputTag("pixelTracksSoA")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackSoA"); - desc.add("useQualityCut", true); - desc.add("minQuality", "loose"); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1MonitorTrackSoA = SiPixelMonitorTrackSoA; -using SiPixelPhase2MonitorTrackSoA = SiPixelMonitorTrackSoA; -using SiPixelHIonPhase1MonitorTrackSoA = SiPixelMonitorTrackSoA; - -DEFINE_FWK_MODULE(SiPixelPhase1MonitorTrackSoA); -DEFINE_FWK_MODULE(SiPixelPhase2MonitorTrackSoA); -DEFINE_FWK_MODULE(SiPixelHIonPhase1MonitorTrackSoA); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorVertexSoA.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorVertexSoA.cc deleted file mode 100644 index 3d90da5c01c5a..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorVertexSoA.cc +++ /dev/null @@ -1,132 +0,0 @@ -// -*- C++ -*- -///bookLayer -// Package: SiPixelMonitorVertexSoA -// Class: SiPixelMonitorVertexSoA -// -/**\class SiPixelMonitorVertexSoA SiPixelMonitorVertexSoA.cc -*/ -// -// Author: Suvankar Roy Chowdhury -// -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/Common/interface/Handle.h" -// DQM Histograming -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "CUDADataFormats/Vertex/interface/ZVertexSoAHeterogeneousHost.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" - -class SiPixelMonitorVertexSoA : public DQMEDAnalyzer { -public: - using IndToEdm = std::vector; - explicit SiPixelMonitorVertexSoA(const edm::ParameterSet&); - ~SiPixelMonitorVertexSoA() 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: - edm::EDGetTokenT tokenSoAVertex_; - edm::EDGetTokenT tokenBeamSpot_; - std::string topFolderName_; - MonitorElement* hnVertex; - MonitorElement* hx; - MonitorElement* hy; - MonitorElement* hz; - MonitorElement* hchi2; - MonitorElement* hchi2oNdof; - MonitorElement* hptv2; - MonitorElement* hntrks; -}; - -// -// constructors -// - -SiPixelMonitorVertexSoA::SiPixelMonitorVertexSoA(const edm::ParameterSet& iConfig) { - tokenSoAVertex_ = consumes(iConfig.getParameter("pixelVertexSrc")); - tokenBeamSpot_ = consumes(iConfig.getParameter("beamSpotSrc")); - topFolderName_ = iConfig.getParameter("topFolderName"); -} - -// -// -- Analyze -// -void SiPixelMonitorVertexSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& vsoaHandle = iEvent.getHandle(tokenSoAVertex_); - if (!vsoaHandle.isValid()) { - edm::LogWarning("SiPixelMonitorVertexSoA") << "No Vertex SoA found \n returning!" << std::endl; - return; - } - - auto const& vsoa = *vsoaHandle; - int nVertices = vsoa.view().nvFinal(); - auto bsHandle = iEvent.getHandle(tokenBeamSpot_); - float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.; - if (!bsHandle.isValid()) { - edm::LogWarning("SiPixelMonitorVertexSoA") << "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 iv = 0; iv < nVertices; iv++) { - auto si = vsoa.view()[iv].sortInd(); - auto z = vsoa.view()[si].zv(); - auto x = x0 + dxdz * z; - auto y = y0 + dydz * z; - - z += z0; - hx->Fill(x); - hy->Fill(y); - hz->Fill(z); - auto ndof = vsoa.view()[si].ndof(); - hchi2->Fill(vsoa.view()[si].chi2()); - hchi2oNdof->Fill(vsoa.view()[si].chi2() / ndof); - hptv2->Fill(vsoa.view()[si].ptv2()); - hntrks->Fill(ndof + 1); - } - hnVertex->Fill(nVertices); -} - -// -// -- Book Histograms -// -void SiPixelMonitorVertexSoA::bookHistograms(DQMStore::IBooker& ibooker, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - //std::string top_folder = ""// - ibooker.cd(); - ibooker.setCurrentFolder(topFolderName_); - hnVertex = ibooker.book1D("nVertex", ";# of Vertices;#entries", 101, -0.5, 100.5); - hx = ibooker.book1D("vx", ";Vertex x;#entries", 10, -5., 5.); - hy = ibooker.book1D("vy", ";Vertex y;#entries", 10, -5., 5.); - hz = ibooker.book1D("vz", ";Vertex z;#entries", 30, -30., 30); - hchi2 = ibooker.book1D("chi2", ";Vertex chi-squared;#entries", 40, 0., 20.); - hchi2oNdof = ibooker.book1D("chi2oNdof", ";Vertex chi-squared/Ndof;#entries", 40, 0., 20.); - hptv2 = ibooker.book1D("ptsq", ";Vertex #sum (p_{T})^{2};#entries", 200, 0., 200.); - hntrks = ibooker.book1D("ntrk", ";#tracks associated;#entries", 100, -0.5, 99.5); -} - -void SiPixelMonitorVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelVertexSoA - edm::ParameterSetDescription desc; - desc.add("pixelVertexSrc", edm::InputTag("pixelVerticesSoA")); - desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexSoA"); - descriptions.addWithDefaultLabel(desc); -} - -DEFINE_FWK_MODULE(SiPixelMonitorVertexSoA); diff --git a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py index a08b3df2eea33..0a946d86ade71 100644 --- a/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py +++ b/DQM/SiPixelHeterogeneous/python/SiPixelHeterogenousDQM_FirstStep_cff.py @@ -1,12 +1,5 @@ import copy import FWCore.ParameterSet.Config as cms -from DQM.SiPixelHeterogeneous.siPixelPhase1MonitorRecHitsSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase2MonitorRecHitsSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelHIonPhase1MonitorRecHitsSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase1MonitorTrackSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelPhase2MonitorTrackSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelHIonPhase1MonitorTrackSoA_cfi import * -from DQM.SiPixelHeterogeneous.siPixelMonitorVertexSoA_cfi import * # Alpaka Modules from Configuration.ProcessModifiers.alpaka_cff import alpaka from DQM.SiPixelHeterogeneous.siPixelPhase1MonitorRecHitsSoAAlpaka_cfi import * @@ -18,13 +11,13 @@ from DQM.SiPixelHeterogeneous.siPixelMonitorVertexSoAAlpaka_cfi import * # Run-3 sequence -monitorpixelSoASource = cms.Sequence(siPixelPhase1MonitorRecHitsSoA * siPixelPhase1MonitorTrackSoA * siPixelMonitorVertexSoA) +monitorpixelSoASource = cms.Sequence() # Run-3 Alpaka sequence monitorpixelSoASourceAlpaka = cms.Sequence(siPixelPhase1MonitorRecHitsSoAAlpaka * siPixelPhase1MonitorTrackSoAAlpaka * siPixelMonitorVertexSoAAlpaka) alpaka.toReplaceWith(monitorpixelSoASource, monitorpixelSoASourceAlpaka) # Phase-2 sequence from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker -_monitorpixelSoARecHitsSource = cms.Sequence(siPixelPhase2MonitorRecHitsSoA * siPixelPhase2MonitorTrackSoA * siPixelMonitorVertexSoA) +_monitorpixelSoARecHitsSource = cms.Sequence() (phase2_tracker & ~alpaka).toReplaceWith(monitorpixelSoASource, _monitorpixelSoARecHitsSource) _monitorpixelSoARecHitsSourceAlpaka = cms.Sequence(siPixelPhase2MonitorRecHitsSoAAlpaka * siPixelPhase2MonitorTrackSoAAlpaka * siPixelMonitorVertexSoAAlpaka) (phase2_tracker & alpaka).toReplaceWith(monitorpixelSoASource, _monitorpixelSoARecHitsSourceAlpaka) @@ -32,20 +25,13 @@ # HIon Phase 1 sequence from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA -_monitorpixelSoARecHitsSourceHIon = cms.Sequence(siPixelHIonPhase1MonitorRecHitsSoA * siPixelHIonPhase1MonitorTrackSoA * siPixelMonitorVertexSoA) +_monitorpixelSoARecHitsSourceHIon = cms.Sequence() (pp_on_AA & ~phase2_tracker).toReplaceWith(monitorpixelSoASource, _monitorpixelSoARecHitsSourceHIon) _monitorpixelSoARecHitsSourceHIonAlpaka = cms.Sequence(siPixelHIonPhase1MonitorRecHitsSoAAlpaka * siPixelHIonPhase1MonitorTrackSoAAlpaka * siPixelMonitorVertexSoAAlpaka) (pp_on_AA & ~phase2_tracker & alpaka).toReplaceWith(monitorpixelSoASource, _monitorpixelSoARecHitsSourceHIonAlpaka) #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.siPixelPhase1RawDataErrorComparator_cfi import * from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import * #Alpaka @@ -76,79 +62,6 @@ histograms =SiPixelPhase1RawDataConfForGPU ) -## rechits -siPixelPhase1MonitorRecHitsSoACPU = siPixelPhase1MonitorRecHitsSoA.clone( - pixelHitsSrc = "siPixelRecHitsPreSplittingSoA@cpu", - TopFolderName = "SiPixelHeterogeneous/PixelRecHitsSoACPU" -) - -siPixelPhase1MonitorRecHitsSoAGPU = siPixelPhase1MonitorRecHitsSoA.clone( - pixelHitsSrc = "siPixelRecHitsPreSplittingSoA@cuda", - TopFolderName = "SiPixelHeterogeneous/PixelRecHitsSoAGPU" -) - -siPixelPhase2MonitorRecHitsSoACPU = siPixelPhase2MonitorRecHitsSoA.clone( - pixelHitsSrc = "siPixelRecHitsPreSplittingSoA@cpu", - TopFolderName = "SiPixelHeterogeneous/PixelRecHitsSoACPU" -) - -siPixelPhase2MonitorRecHitsSoAGPU = siPixelPhase2MonitorRecHitsSoA.clone( - pixelHitsSrc = "siPixelRecHitsPreSplittingSoA@cuda", - TopFolderName = "SiPixelHeterogeneous/PixelRecHitsSoAGPU" -) - -siPixelHIonPhase1MonitorRecHitsSoACPU = siPixelHIonPhase1MonitorRecHitsSoA.clone( - pixelHitsSrc = "siPixelRecHitsPreSplittingSoA@cpu", - TopFolderName = "SiPixelHeterogeneous/PixelRecHitsSoACPU" -) - -siPixelHIonPhase1MonitorRecHitsSoAGPU = siPixelHIonPhase1MonitorRecHitsSoA.clone( - pixelHitsSrc = "siPixelRecHitsPreSplittingSoA@cuda", - TopFolderName = "SiPixelHeterogeneous/PixelRecHitsSoAGPU" -) - -## tracks -siPixelPhase1MonitorTrackSoACPU = siPixelPhase1MonitorTrackSoA.clone( - pixelTrackSrc = 'pixelTracksSoA@cpu', - topFolderName = 'SiPixelHeterogeneous/PixelTrackSoACPU', -) - -siPixelPhase1MonitorTrackSoAGPU = siPixelPhase1MonitorTrackSoA.clone( - pixelTrackSrc = 'pixelTracksSoA@cuda', - topFolderName = 'SiPixelHeterogeneous/PixelTrackSoAGPU', -) - -siPixelPhase2MonitorTrackSoACPU = siPixelPhase2MonitorTrackSoA.clone( - pixelTrackSrc = 'pixelTracksSoA@cpu', - topFolderName = 'SiPixelHeterogeneous/PixelTrackSoACPU', -) - -siPixelPhase2MonitorTrackSoAGPU = siPixelPhase2MonitorTrackSoA.clone( - pixelTrackSrc = 'pixelTracksSoA@cuda', - topFolderName = 'SiPixelHeterogeneous/PixelTrackSoAGPU', -) - -siPixelHIonPhase1MonitorTrackSoACPU = siPixelHIonPhase1MonitorTrackSoA.clone( - pixelTrackSrc = 'pixelTracksSoA@cpu', - topFolderName = 'SiPixelHeterogeneous/PixelTrackSoACPU', -) - -siPixelHIonPhase1MonitorTrackSoAGPU = siPixelHIonPhase1MonitorTrackSoA.clone( - pixelTrackSrc = 'pixelTracksSoA@cuda', - topFolderName = 'SiPixelHeterogeneous/PixelTrackSoAGPU', -) - -## vertices -siPixelMonitorVertexSoACPU = siPixelMonitorVertexSoA.clone( - pixelVertexSrc = 'pixelVerticesSoA@cpu', - topFolderName = 'SiPixelHeterogeneous/PixelVertexSoACPU', -) - -siPixelMonitorVertexSoAGPU = siPixelMonitorVertexSoA.clone( - pixelVertexSrc = 'pixelVerticesSoA@cuda', - topFolderName = 'SiPixelHeterogeneous/PixelVertexSoAGPU', -) - ### Alpaka # digi errors @@ -214,15 +127,6 @@ # Run-3 sequence monitorpixelSoACompareSource = cms.Sequence(siPixelPhase1MonitorRawDataACPU * siPixelPhase1MonitorRawDataAGPU * - siPixelPhase1MonitorRecHitsSoACPU * - siPixelPhase1MonitorRecHitsSoAGPU * - siPixelPhase1CompareRecHitsSoA * - siPixelPhase1MonitorTrackSoAGPU * - siPixelPhase1MonitorTrackSoACPU * - siPixelPhase1CompareTrackSoA * - siPixelMonitorVertexSoACPU * - siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA * siPixelPhase1RawDataErrorComparator) # and the Alpaka version monitorpixelSoACompareSourceAlpaka = cms.Sequence( @@ -240,15 +144,7 @@ siPixelCompareVertices ) # Phase-2 sequence ... -_monitorpixelSoACompareSource = cms.Sequence(siPixelPhase2MonitorRecHitsSoACPU * - siPixelPhase2MonitorRecHitsSoAGPU * - siPixelPhase2CompareRecHitsSoA * - siPixelPhase2MonitorTrackSoAGPU * - siPixelPhase2MonitorTrackSoACPU * - siPixelPhase2CompareTrackSoA * - siPixelMonitorVertexSoACPU * - siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA) +_monitorpixelSoACompareSource = cms.Sequence() # ...and the Alpaka version _monitorpixelSoACompareSourceAlpakaPhase2 = cms.Sequence( @@ -262,17 +158,6 @@ siPixelVertexSoAMonitorDevice * siPixelCompareVertices ) -# HIon sequence -_monitorpixelSoACompareSourceHIonPhase1 = cms.Sequence(siPixelHIonPhase1MonitorRecHitsSoACPU * - siPixelHIonPhase1MonitorRecHitsSoAGPU * - siPixelHIonPhase1CompareRecHitsSoA * - siPixelHIonPhase1MonitorTrackSoAGPU * - siPixelHIonPhase1MonitorTrackSoACPU * - siPixelHIonPhase1CompareTrackSoA * - siPixelMonitorVertexSoACPU * - siPixelMonitorVertexSoAGPU * - siPixelCompareVertexSoA) - phase2_tracker.toReplaceWith(monitorpixelSoACompareSource,_monitorpixelSoACompareSource) phase2_tracker.toReplaceWith(monitorpixelSoACompareSourceAlpaka,_monitorpixelSoACompareSourceAlpakaPhase2)