diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc deleted file mode 100644 index 474194ad72616..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHitsSoAAlpaka.cc +++ /dev/null @@ -1,244 +0,0 @@ -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "DataFormats/Math/interface/approx_atan2.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h" -#include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -#include "Geometry/CommonTopologies/interface/PixelTopology.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" - -template -class SiPixelCompareRecHitsSoAAlpaka : public DQMEDAnalyzer { -public: - using HitsOnHost = TrackingRecHitHost; - - explicit SiPixelCompareRecHitsSoAAlpaka(const edm::ParameterSet&); - ~SiPixelCompareRecHitsSoAAlpaka() override = default; - void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override; - void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; - void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - const edm::ESGetToken geomToken_; - const edm::ESGetToken topoToken_; - const edm::EDGetTokenT tokenSoAHitsHost_; //these two are both on Host but originally they have been - const edm::EDGetTokenT tokenSoAHitsDevice_; //produced on Host or on Device - const std::string topFolderName_; - const float mind2cut_; - static constexpr uint32_t invalidHit_ = std::numeric_limits::max(); - static constexpr float micron_ = 10000.; - const TrackerGeometry* tkGeom_ = nullptr; - const TrackerTopology* tTopo_ = nullptr; - MonitorElement* hnHits_; - MonitorElement* hBchargeL_[4]; // max 4 barrel hits - MonitorElement* hBsizexL_[4]; - MonitorElement* hBsizeyL_[4]; - MonitorElement* hBposxL_[4]; - MonitorElement* hBposyL_[4]; - MonitorElement* hFchargeD_[2][12]; // max 12 endcap disks - MonitorElement* hFsizexD_[2][12]; - MonitorElement* hFsizeyD_[2][12]; - MonitorElement* hFposxD_[2][12]; - MonitorElement* hFposyD_[2][12]; - //differences - MonitorElement* hBchargeDiff_; - MonitorElement* hFchargeDiff_; - MonitorElement* hBsizeXDiff_; - MonitorElement* hFsizeXDiff_; - MonitorElement* hBsizeYDiff_; - MonitorElement* hFsizeYDiff_; - MonitorElement* hBposXDiff_; - MonitorElement* hFposXDiff_; - MonitorElement* hBposYDiff_; - MonitorElement* hFposYDiff_; -}; - -// -// constructors -// -template -SiPixelCompareRecHitsSoAAlpaka::SiPixelCompareRecHitsSoAAlpaka(const edm::ParameterSet& iConfig) - : geomToken_(esConsumes()), - topoToken_(esConsumes()), - tokenSoAHitsHost_(consumes(iConfig.getParameter("pixelHitsSrcHost"))), - tokenSoAHitsDevice_(consumes(iConfig.getParameter("pixelHitsSrcDevice"))), - topFolderName_(iConfig.getParameter("topFolderName")), - mind2cut_(iConfig.getParameter("minD2cut")) {} - -// -// Begin Run -// -template -void SiPixelCompareRecHitsSoAAlpaka::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { - tkGeom_ = &iSetup.getData(geomToken_); - tTopo_ = &iSetup.getData(topoToken_); -} - -// -// -- Analyze -// -template -void SiPixelCompareRecHitsSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& rhsoaHandleHost = iEvent.getHandle(tokenSoAHitsHost_); - const auto& rhsoaHandleDevice = iEvent.getHandle(tokenSoAHitsDevice_); - if (not rhsoaHandleHost or not rhsoaHandleDevice) { - edm::LogWarning out("SiPixelCompareRecHitsSoAAlpaka"); - if (not rhsoaHandleHost) { - out << "reference (Host) rechits not found; "; - } - if (not rhsoaHandleDevice) { - out << "target (Device) rechits not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& rhsoaHost = *rhsoaHandleHost; - auto const& rhsoaDevice = *rhsoaHandleDevice; - - auto const& soa2dHost = rhsoaHost.const_view(); - auto const& soa2dDevice = rhsoaDevice.const_view(); - - uint32_t nHitsHost = soa2dHost.metadata().size(); - uint32_t nHitsDevice = soa2dDevice.metadata().size(); - - hnHits_->Fill(nHitsHost, nHitsDevice); - auto detIds = tkGeom_->detUnitIds(); - for (uint32_t i = 0; i < nHitsHost; i++) { - float minD = mind2cut_; - uint32_t matchedHit = invalidHit_; - uint16_t indHost = soa2dHost[i].detectorIndex(); - float xLocalHost = soa2dHost[i].xLocal(); - float yLocalHost = soa2dHost[i].yLocal(); - for (uint32_t j = 0; j < nHitsDevice; j++) { - if (soa2dDevice.detectorIndex(j) == indHost) { - float dx = xLocalHost - soa2dDevice[j].xLocal(); - float dy = yLocalHost - soa2dDevice[j].yLocal(); - float distance = dx * dx + dy * dy; - if (distance < minD) { - minD = distance; - matchedHit = j; - } - } - } - DetId id = detIds[indHost]; - uint32_t chargeHost = soa2dHost[i].chargeAndStatus().charge; - int16_t sizeXHost = std::ceil(float(std::abs(soa2dHost[i].clusterSizeX()) / 8.)); - int16_t sizeYHost = std::ceil(float(std::abs(soa2dHost[i].clusterSizeY()) / 8.)); - uint32_t chargeDevice = 0; - int16_t sizeXDevice = -99; - int16_t sizeYDevice = -99; - float xLocalDevice = -999.; - float yLocalDevice = -999.; - if (matchedHit != invalidHit_) { - chargeDevice = soa2dDevice[matchedHit].chargeAndStatus().charge; - sizeXDevice = std::ceil(float(std::abs(soa2dDevice[matchedHit].clusterSizeX()) / 8.)); - sizeYDevice = std::ceil(float(std::abs(soa2dDevice[matchedHit].clusterSizeY()) / 8.)); - xLocalDevice = soa2dDevice[matchedHit].xLocal(); - yLocalDevice = soa2dDevice[matchedHit].yLocal(); - } - switch (id.subdetId()) { - case PixelSubdetector::PixelBarrel: - hBchargeL_[tTopo_->pxbLayer(id) - 1]->Fill(chargeHost, chargeDevice); - hBsizexL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeXHost, sizeXDevice); - hBsizeyL_[tTopo_->pxbLayer(id) - 1]->Fill(sizeYHost, sizeYDevice); - hBposxL_[tTopo_->pxbLayer(id) - 1]->Fill(xLocalHost, xLocalDevice); - hBposyL_[tTopo_->pxbLayer(id) - 1]->Fill(yLocalHost, yLocalDevice); - hBchargeDiff_->Fill(chargeHost - chargeDevice); - hBsizeXDiff_->Fill(sizeXHost - sizeXDevice); - hBsizeYDiff_->Fill(sizeYHost - sizeYDevice); - hBposXDiff_->Fill(micron_ * (xLocalHost - xLocalDevice)); - hBposYDiff_->Fill(micron_ * (yLocalHost - yLocalDevice)); - break; - case PixelSubdetector::PixelEndcap: - hFchargeD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(chargeHost, chargeDevice); - hFsizexD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeXHost, sizeXDevice); - hFsizeyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeYHost, sizeYDevice); - hFposxD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xLocalHost, xLocalDevice); - hFposyD_[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(yLocalHost, yLocalDevice); - hFchargeDiff_->Fill(chargeHost - chargeDevice); - hFsizeXDiff_->Fill(sizeXHost - sizeXDevice); - hFsizeYDiff_->Fill(sizeYHost - sizeYDevice); - hFposXDiff_->Fill(micron_ * (xLocalHost - xLocalDevice)); - hFposYDiff_->Fill(micron_ * (yLocalHost - yLocalDevice)); - break; - } - } -} - -// -// -- Book Histograms -// -template -void SiPixelCompareRecHitsSoAAlpaka::bookHistograms(DQMStore::IBooker& iBook, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - iBook.cd(); - iBook.setCurrentFolder(topFolderName_); - - // clang-format off - //Global - hnHits_ = iBook.book2I("nHits", "HostvsDevice RecHits per event;#Host RecHits;#Device RecHits", 200, 0, 5000,200, 0, 5000); - //Barrel Layer - for(unsigned int il=0;ilnumberOfLayers(PixelSubdetector::PixelBarrel);il++){ - hBchargeL_[il] = iBook.book2I(Form("recHitsBLay%dCharge",il+1), Form("HostvsDevice RecHits Charge Barrel Layer%d;Host Charge;Device Charge",il+1), 250, 0, 100000, 250, 0, 100000); - hBsizexL_[il] = iBook.book2I(Form("recHitsBLay%dSizex",il+1), Form("HostvsDevice RecHits SizeX Barrel Layer%d;Host SizeX;Device SizeX",il+1), 30, 0, 30, 30, 0, 30); - hBsizeyL_[il] = iBook.book2I(Form("recHitsBLay%dSizey",il+1), Form("HostvsDevice RecHits SizeY Barrel Layer%d;Host SizeY;Device SizeY",il+1), 30, 0, 30, 30, 0, 30); - hBposxL_[il] = iBook.book2D(Form("recHitsBLay%dPosx",il+1), Form("HostvsDevice RecHits x-pos in Barrel Layer%d;Host pos x;Device pos x",il+1), 200, -5, 5, 200,-5,5); - hBposyL_[il] = iBook.book2D(Form("recHitsBLay%dPosy",il+1), Form("HostvsDevice RecHits y-pos in Barrel Layer%d;Host pos y;Device pos y",il+1), 200, -5, 5, 200,-5,5); - } - //Endcaps - //Endcaps Disk - for(int is=0;is<2;is++){ - int sign=is==0? -1:1; - for(unsigned int id=0;idnumberOfLayers(PixelSubdetector::PixelEndcap);id++){ - hFchargeD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dCharge",id*sign+sign), Form("HostvsDevice RecHits Charge Endcaps Disk%+d;Host Charge;Device Charge",id*sign+sign), 250, 0, 100000, 250, 0, 100000); - hFsizexD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizex",id*sign+sign), Form("HostvsDevice RecHits SizeX Endcaps Disk%+d;Host SizeX;Device SizeX",id*sign+sign), 30, 0, 30, 30, 0, 30); - hFsizeyD_[is][id] = iBook.book2I(Form("recHitsFDisk%+dSizey",id*sign+sign), Form("HostvsDevice RecHits SizeY Endcaps Disk%+d;Host SizeY;Device SizeY",id*sign+sign), 30, 0, 30, 30, 0, 30); - hFposxD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosx",id*sign+sign), Form("HostvsDevice RecHits x-pos Endcaps Disk%+d;Host pos x;Device pos x",id*sign+sign), 200, -5, 5, 200, -5, 5); - hFposyD_[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosy",id*sign+sign), Form("HostvsDevice RecHits y-pos Endcaps Disk%+d;Host pos y;Device pos y",id*sign+sign), 200, -5, 5, 200, -5, 5); - } - } - //1D differences - hBchargeDiff_ = iBook.book1D("rechitChargeDiffBpix","Charge differnce of rechits in BPix; rechit charge difference (Host - Device)", 101, -50.5, 50.5); - hFchargeDiff_ = iBook.book1D("rechitChargeDiffFpix","Charge differnce of rechits in FPix; rechit charge difference (Host - Device)", 101, -50.5, 50.5); - hBsizeXDiff_ = iBook.book1D("rechitsizeXDiffBpix","SizeX difference of rechits in BPix; rechit sizex difference (Host - Device)", 21, -10.5, 10.5); - hFsizeXDiff_ = iBook.book1D("rechitsizeXDiffFpix","SizeX difference of rechits in FPix; rechit sizex difference (Host - Device)", 21, -10.5, 10.5); - hBsizeYDiff_ = iBook.book1D("rechitsizeYDiffBpix","SizeY difference of rechits in BPix; rechit sizey difference (Host - Device)", 21, -10.5, 10.5); - hFsizeYDiff_ = iBook.book1D("rechitsizeYDiffFpix","SizeY difference of rechits in FPix; rechit sizey difference (Host - Device)", 21, -10.5, 10.5); - hBposXDiff_ = iBook.book1D("rechitsposXDiffBpix","x-position difference of rechits in BPix; rechit x-pos difference (Host - Device)", 1000, -10, 10); - hFposXDiff_ = iBook.book1D("rechitsposXDiffFpix","x-position difference of rechits in FPix; rechit x-pos difference (Host - Device)", 1000, -10, 10); - hBposYDiff_ = iBook.book1D("rechitsposYDiffBpix","y-position difference of rechits in BPix; rechit y-pos difference (Host - Device)", 1000, -10, 10); - hFposYDiff_ = iBook.book1D("rechitsposYDiffFpix","y-position difference of rechits in FPix; rechit y-pos difference (Host - Device)", 1000, -10, 10); -} - -template -void SiPixelCompareRecHitsSoAAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelRecHitsSoAAlpaka - edm::ParameterSetDescription desc; - desc.add("pixelHitsSrcHost", edm::InputTag("siPixelRecHitsPreSplittingAlpakaSerial")); - desc.add("pixelHitsSrcDevice", edm::InputTag("siPixelRecHitsPreSplittingAlpaka")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelRecHitsCompareDeviceVSHost"); - desc.add("minD2cut", 0.0001); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1CompareRecHitsSoAAlpaka = SiPixelCompareRecHitsSoAAlpaka; -using SiPixelPhase2CompareRecHitsSoAAlpaka = SiPixelCompareRecHitsSoAAlpaka; -using SiPixelHIonPhase1CompareRecHitsSoAAlpaka = SiPixelCompareRecHitsSoAAlpaka; - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(SiPixelPhase1CompareRecHitsSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelPhase2CompareRecHitsSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareRecHitsSoAAlpaka); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc deleted file mode 100644 index 025bdfd988ea6..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoAAlpaka.cc +++ /dev/null @@ -1,308 +0,0 @@ -// for string manipulations -#include -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/Math/interface/deltaR.h" -#include "DataFormats/Math/interface/deltaPhi.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -// DQM Histograming -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -// DataFormats -#include "DataFormats/TrackSoA/interface/TracksHost.h" -#include "DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h" - -namespace { - // same logic used for the MTV: - // cf https://github.com/cms-sw/cmssw/blob/master/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc - typedef dqm::reco::DQMStore DQMStore; - - void setBinLog(TAxis* axis) { - int bins = axis->GetNbins(); - float from = axis->GetXmin(); - float to = axis->GetXmax(); - float width = (to - from) / bins; - std::vector new_bins(bins + 1, 0); - for (int i = 0; i <= bins; i++) { - new_bins[i] = TMath::Power(10, from + i * width); - } - axis->Set(bins, new_bins.data()); - } - - void setBinLogX(TH1* h) { - TAxis* axis = h->GetXaxis(); - setBinLog(axis); - } - void setBinLogY(TH1* h) { - TAxis* axis = h->GetYaxis(); - setBinLog(axis); - } - - template - dqm::reco::MonitorElement* make2DIfLog(DQMStore::IBooker& ibook, bool logx, bool logy, Args&&... args) { - auto h = std::make_unique(std::forward(args)...); - if (logx) - setBinLogX(h.get()); - if (logy) - setBinLogY(h.get()); - const auto& name = h->GetName(); - return ibook.book2I(name, h.release()); - } -} // namespace - -template -class SiPixelCompareTrackSoAAlpaka : public DQMEDAnalyzer { -public: - using PixelTrackSoA = TracksHost; - - explicit SiPixelCompareTrackSoAAlpaka(const edm::ParameterSet&); - ~SiPixelCompareTrackSoAAlpaka() override = default; - void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; - void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - const edm::EDGetTokenT tokenSoATrackHost_; - const edm::EDGetTokenT tokenSoATrackDevice_; - const std::string topFolderName_; - const bool useQualityCut_; - const pixelTrack::Quality minQuality_; - const float dr2cut_; - MonitorElement* hnTracks_; - MonitorElement* hnLooseAndAboveTracks_; - MonitorElement* hnLooseAndAboveTracks_matched_; - MonitorElement* hnHits_; - MonitorElement* hnHitsVsPhi_; - MonitorElement* hnHitsVsEta_; - MonitorElement* hnLayers_; - MonitorElement* hnLayersVsPhi_; - MonitorElement* hnLayersVsEta_; - MonitorElement* hCharge_; - MonitorElement* hchi2_; - MonitorElement* hChi2VsPhi_; - MonitorElement* hChi2VsEta_; - MonitorElement* hpt_; - MonitorElement* hptLogLog_; - MonitorElement* heta_; - MonitorElement* hphi_; - MonitorElement* hz_; - MonitorElement* htip_; - MonitorElement* hquality_; - //1D differences - MonitorElement* hptdiffMatched_; - MonitorElement* hCurvdiffMatched_; - MonitorElement* hetadiffMatched_; - MonitorElement* hphidiffMatched_; - MonitorElement* hzdiffMatched_; - MonitorElement* htipdiffMatched_; - - //for matching eff vs region: derive the ratio at harvesting - MonitorElement* hpt_eta_tkAllHost_; - MonitorElement* hpt_eta_tkAllHostMatched_; - MonitorElement* hphi_z_tkAllHost_; - MonitorElement* hphi_z_tkAllHostMatched_; -}; - -// -// constructors -// - -template -SiPixelCompareTrackSoAAlpaka::SiPixelCompareTrackSoAAlpaka(const edm::ParameterSet& iConfig) - : tokenSoATrackHost_(consumes(iConfig.getParameter("pixelTrackSrcHost"))), - tokenSoATrackDevice_(consumes(iConfig.getParameter("pixelTrackSrcDevice"))), - topFolderName_(iConfig.getParameter("topFolderName")), - useQualityCut_(iConfig.getParameter("useQualityCut")), - minQuality_(pixelTrack::qualityByName(iConfig.getParameter("minQuality"))), - dr2cut_(iConfig.getParameter("deltaR2cut")) {} - -// -// -- Analyze -// -template -void SiPixelCompareTrackSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using helper = TracksUtilities; - const auto& tsoaHandleHost = iEvent.getHandle(tokenSoATrackHost_); - const auto& tsoaHandleDevice = iEvent.getHandle(tokenSoATrackDevice_); - if (not tsoaHandleHost or not tsoaHandleDevice) { - edm::LogWarning out("SiPixelCompareTrackSoAAlpaka"); - if (not tsoaHandleHost) { - out << "reference (cpu) tracks not found; "; - } - if (not tsoaHandleDevice) { - out << "target (gpu) tracks not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& tsoaHost = *tsoaHandleHost; - auto const& tsoaDevice = *tsoaHandleDevice; - auto maxTracksHost = tsoaHost.view().metadata().size(); //this should be same for both? - auto maxTracksDevice = tsoaDevice.view().metadata().size(); //this should be same for both? - auto const* qualityHost = tsoaHost.view().quality(); - auto const* qualityDevice = tsoaDevice.view().quality(); - int32_t nTracksHost = 0; - int32_t nTracksDevice = 0; - int32_t nLooseAndAboveTracksHost = 0; - int32_t nLooseAndAboveTracksHost_matchedDevice = 0; - int32_t nLooseAndAboveTracksDevice = 0; - - //Loop over Device tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false? - std::vector looseTrkidxDevice; - for (int32_t jt = 0; jt < maxTracksDevice; ++jt) { - if (helper::nHits(tsoaDevice.view(), jt) == 0) - break; // this is a guard - if (!(tsoaDevice.view()[jt].pt() > 0.)) - continue; - nTracksDevice++; - if (useQualityCut_ && qualityDevice[jt] < minQuality_) - continue; - nLooseAndAboveTracksDevice++; - looseTrkidxDevice.emplace_back(jt); - } - - //Now loop over Host tracks//nested loop for loose gPU tracks - for (int32_t it = 0; it < maxTracksHost; ++it) { - int nHitsHost = helper::nHits(tsoaHost.view(), it); - - if (nHitsHost == 0) - break; // this is a guard - - float ptHost = tsoaHost.view()[it].pt(); - float etaHost = tsoaHost.view()[it].eta(); - float phiHost = reco::phi(tsoaHost.view(), it); - float zipHost = reco::zip(tsoaHost.view(), it); - float tipHost = reco::tip(tsoaHost.view(), it); - - if (!(ptHost > 0.)) - continue; - nTracksHost++; - if (useQualityCut_ && qualityHost[it] < minQuality_) - continue; - nLooseAndAboveTracksHost++; - //Now loop over loose Device trk and find the closest in DeltaR//do we need pt cut? - const int32_t notFound = -1; - int32_t closestTkidx = notFound; - float mindr2 = dr2cut_; - - for (auto gid : looseTrkidxDevice) { - float etaDevice = tsoaDevice.view()[gid].eta(); - float phiDevice = reco::phi(tsoaDevice.view(), gid); - float dr2 = reco::deltaR2(etaHost, phiHost, etaDevice, phiDevice); - if (dr2 > dr2cut_) - continue; // this is arbitrary - if (mindr2 > dr2) { - mindr2 = dr2; - closestTkidx = gid; - } - } - - hpt_eta_tkAllHost_->Fill(etaHost, ptHost); //all Host tk - hphi_z_tkAllHost_->Fill(phiHost, zipHost); - if (closestTkidx == notFound) - continue; - nLooseAndAboveTracksHost_matchedDevice++; - - hchi2_->Fill(tsoaHost.view()[it].chi2(), tsoaDevice.view()[closestTkidx].chi2()); - hCharge_->Fill(reco::charge(tsoaHost.view(), it), reco::charge(tsoaDevice.view(), closestTkidx)); - hnHits_->Fill(helper::nHits(tsoaHost.view(), it), helper::nHits(tsoaDevice.view(), closestTkidx)); - hnLayers_->Fill(tsoaHost.view()[it].nLayers(), tsoaDevice.view()[closestTkidx].nLayers()); - hpt_->Fill(tsoaHost.view()[it].pt(), tsoaDevice.view()[closestTkidx].pt()); - hptLogLog_->Fill(tsoaHost.view()[it].pt(), tsoaDevice.view()[closestTkidx].pt()); - heta_->Fill(etaHost, tsoaDevice.view()[closestTkidx].eta()); - hphi_->Fill(phiHost, reco::phi(tsoaDevice.view(), closestTkidx)); - hz_->Fill(zipHost, reco::zip(tsoaDevice.view(), closestTkidx)); - htip_->Fill(tipHost, reco::tip(tsoaDevice.view(), closestTkidx)); - hptdiffMatched_->Fill(ptHost - tsoaDevice.view()[closestTkidx].pt()); - hCurvdiffMatched_->Fill((reco::charge(tsoaHost.view(), it) / tsoaHost.view()[it].pt()) - - (reco::charge(tsoaDevice.view(), closestTkidx) / tsoaDevice.view()[closestTkidx].pt())); - hetadiffMatched_->Fill(etaHost - tsoaDevice.view()[closestTkidx].eta()); - hphidiffMatched_->Fill(reco::deltaPhi(phiHost, reco::phi(tsoaDevice.view(), closestTkidx))); - hzdiffMatched_->Fill(zipHost - reco::zip(tsoaDevice.view(), closestTkidx)); - htipdiffMatched_->Fill(tipHost - reco::tip(tsoaDevice.view(), closestTkidx)); - hpt_eta_tkAllHostMatched_->Fill(etaHost, tsoaHost.view()[it].pt()); //matched to gpu - hphi_z_tkAllHostMatched_->Fill(etaHost, zipHost); - } - hnTracks_->Fill(nTracksHost, nTracksDevice); - hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksHost, nLooseAndAboveTracksDevice); - hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksHost, nLooseAndAboveTracksHost_matchedDevice); -} - -// -// -- Book Histograms -// -template -void SiPixelCompareTrackSoAAlpaka::bookHistograms(DQMStore::IBooker& iBook, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - iBook.cd(); - iBook.setCurrentFolder(topFolderName_); - - // clang-format off - std::string toRep = "Number of tracks"; - // FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports THnSparse - // these should be moved to a less resource consuming format - hnTracks_ = iBook.book2I("nTracks", fmt::format("{} per event; Host; Device",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - hnLooseAndAboveTracks_ = iBook.book2I("nLooseAndAboveTracks", fmt::format("{} (quality #geq loose) per event; Host; Device",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - hnLooseAndAboveTracks_matched_ = iBook.book2I("nLooseAndAboveTracks_matched", fmt::format("{} (quality #geq loose) per event; Host; Device",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5); - - toRep = "Number of all RecHits per track (quality #geq loose)"; - hnHits_ = iBook.book2I("nRecHits", fmt::format("{};Host;Device",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); - - toRep = "Number of all layers per track (quality #geq loose)"; - hnLayers_ = iBook.book2I("nLayers", fmt::format("{};Host;Device",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5); - - toRep = "Track (quality #geq loose) #chi^{2}/ndof"; - hchi2_ = iBook.book2I("nChi2ndof", fmt::format("{};Host;Device",toRep), 40, 0., 20., 40, 0., 20.); - - toRep = "Track (quality #geq loose) charge"; - hCharge_ = iBook.book2I("charge",fmt::format("{};Host;Device",toRep),3, -1.5, 1.5, 3, -1.5, 1.5); - - hpt_ = iBook.book2I("pt", "Track (quality #geq loose) p_{T} [GeV];Host;Device", 200, 0., 200., 200, 0., 200.); - hptLogLog_ = make2DIfLog(iBook, true, true, "ptLogLog", "Track (quality #geq loose) p_{T} [GeV];Host;Device", 200, log10(0.5), log10(200.), 200, log10(0.5), log10(200.)); - heta_ = iBook.book2I("eta", "Track (quality #geq loose) #eta;Host;Device", 30, -3., 3., 30, -3., 3.); - hphi_ = iBook.book2I("phi", "Track (quality #geq loose) #phi;Host;Device", 30, -M_PI, M_PI, 30, -M_PI, M_PI); - hz_ = iBook.book2I("z", "Track (quality #geq loose) z [cm];Host;Device", 30, -30., 30., 30, -30., 30.); - htip_ = iBook.book2I("tip", "Track (quality #geq loose) TIP [cm];Host;Device", 100, -0.5, 0.5, 100, -0.5, 0.5); - //1D difference plots - hptdiffMatched_ = iBook.book1D("ptdiffmatched", " p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 60, -30., 30.); - hCurvdiffMatched_ = iBook.book1D("curvdiffmatched", "q/p_{T} diff [GeV] between matched tracks; #Delta q/p_{T} [GeV]", 60, -30., 30.); - hetadiffMatched_ = iBook.book1D("etadiffmatched", " #eta diff between matched tracks; #Delta #eta", 160, -0.04 ,0.04); - hphidiffMatched_ = iBook.book1D("phidiffmatched", " #phi diff between matched tracks; #Delta #phi", 160, -0.04 ,0.04); - hzdiffMatched_ = iBook.book1D("zdiffmatched", " z diff between matched tracks; #Delta z [cm]", 300, -1.5, 1.5); - htipdiffMatched_ = iBook.book1D("tipdiffmatched", " TIP diff between matched tracks; #Delta TIP [cm]", 300, -1.5, 1.5); - //2D plots for eff - hpt_eta_tkAllHost_ = iBook.book2I("ptetatrkAllHost", "Track (quality #geq loose) on Host; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - hpt_eta_tkAllHostMatched_ = iBook.book2I("ptetatrkAllHostmatched", "Track (quality #geq loose) on Host matched to Device track; #eta; p_{T} [GeV];", 30, -M_PI, M_PI, 200, 0., 200.); - - hphi_z_tkAllHost_ = iBook.book2I("phiztrkAllHost", "Track (quality #geq loose) on Host; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); - hphi_z_tkAllHostMatched_ = iBook.book2I("phiztrkAllHostmatched", "Track (quality #geq loose) on Host; #phi; z [cm];", 30, -M_PI, M_PI, 30, -30., 30.); - -} - -template -void SiPixelCompareTrackSoAAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelTrackSoA - edm::ParameterSetDescription desc; - desc.add("pixelTrackSrcHost", edm::InputTag("pixelTracksAlpakaSerial")); - desc.add("pixelTrackSrcDevice", edm::InputTag("pixelTracksAlpaka")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelTrackCompareDeviceVSHost"); - desc.add("useQualityCut", true); - desc.add("minQuality", "loose"); - desc.add("deltaR2cut", 0.04); - descriptions.addWithDefaultLabel(desc); -} - -using SiPixelPhase1CompareTrackSoAAlpaka = SiPixelCompareTrackSoAAlpaka; -using SiPixelPhase2CompareTrackSoAAlpaka = SiPixelCompareTrackSoAAlpaka; -using SiPixelHIonPhase1CompareTrackSoAAlpaka = SiPixelCompareTrackSoAAlpaka; - -DEFINE_FWK_MODULE(SiPixelPhase1CompareTrackSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelPhase2CompareTrackSoAAlpaka); -DEFINE_FWK_MODULE(SiPixelHIonPhase1CompareTrackSoAAlpaka); diff --git a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc b/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc deleted file mode 100644 index 2eea6a980d9c5..0000000000000 --- a/DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertexSoAAlpaka.cc +++ /dev/null @@ -1,186 +0,0 @@ -// -*- C++ -*- -// Package: SiPixelCompareVertexSoAAlpaka -// Class: SiPixelCompareVertexSoAAlpaka -// -/**\class SiPixelCompareVertexSoAAlpaka SiPixelCompareVertexSoAAlpaka.cc -*/ -// -// Author: Suvankar Roy Chowdhury -// -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/Common/interface/Handle.h" -// DQM Histograming -#include "DQMServices/Core/interface/MonitorElement.h" -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "DataFormats/VertexSoA/interface/ZVertexHost.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" - -class SiPixelCompareVertexSoAAlpaka : public DQMEDAnalyzer { -public: - using IndToEdm = std::vector; - explicit SiPixelCompareVertexSoAAlpaka(const edm::ParameterSet&); - ~SiPixelCompareVertexSoAAlpaka() override = default; - void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; - void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - const edm::EDGetTokenT tokenSoAVertexHost_; - const edm::EDGetTokenT tokenSoAVertexDevice_; - const edm::EDGetTokenT tokenBeamSpot_; - const std::string topFolderName_; - const float dzCut_; - MonitorElement* hnVertex_; - MonitorElement* hx_; - MonitorElement* hy_; - MonitorElement* hz_; - MonitorElement* hchi2_; - MonitorElement* hchi2oNdof_; - MonitorElement* hptv2_; - MonitorElement* hntrks_; - MonitorElement* hxdiff_; - MonitorElement* hydiff_; - MonitorElement* hzdiff_; -}; - -// -// constructors -// - -// Note tokenSoAVertexDevice_ contains data copied from device to host, hence is a HostCollection -SiPixelCompareVertexSoAAlpaka::SiPixelCompareVertexSoAAlpaka(const edm::ParameterSet& iConfig) - : tokenSoAVertexHost_(consumes(iConfig.getParameter("pixelVertexSrcHost"))), - tokenSoAVertexDevice_(consumes(iConfig.getParameter("pixelVertexSrcDevice"))), - tokenBeamSpot_(consumes(iConfig.getParameter("beamSpotSrc"))), - topFolderName_(iConfig.getParameter("topFolderName")), - dzCut_(iConfig.getParameter("dzCut")) {} - -// -// -- Analyze -// -void SiPixelCompareVertexSoAAlpaka::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - const auto& vsoaHandleHost = iEvent.getHandle(tokenSoAVertexHost_); - const auto& vsoaHandleDevice = iEvent.getHandle(tokenSoAVertexDevice_); - if (not vsoaHandleHost or not vsoaHandleDevice) { - edm::LogWarning out("SiPixelCompareVertexSoAAlpaka"); - if (not vsoaHandleHost) { - out << "reference (cpu) tracks not found; "; - } - if (not vsoaHandleDevice) { - out << "target (gpu) tracks not found; "; - } - out << "the comparison will not run."; - return; - } - - auto const& vsoaHost = *vsoaHandleHost; - int nVerticesHost = vsoaHost.view().nvFinal(); - auto const& vsoaDevice = *vsoaHandleDevice; - int nVerticesDevice = vsoaDevice.view().nvFinal(); - - auto bsHandle = iEvent.getHandle(tokenBeamSpot_); - float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.; - if (!bsHandle.isValid()) { - edm::LogWarning("SiPixelCompareVertexSoAAlpaka") << "No beamspot found. returning vertexes with (0,0,Z) "; - } else { - const reco::BeamSpot& bs = *bsHandle; - x0 = bs.x0(); - y0 = bs.y0(); - z0 = bs.z0(); - dxdz = bs.dxdz(); - dydz = bs.dydz(); - } - - for (int ivc = 0; ivc < nVerticesHost; ivc++) { - auto sic = vsoaHost.view()[ivc].sortInd(); - auto zc = vsoaHost.view()[sic].zv(); - auto xc = x0 + dxdz * zc; - auto yc = y0 + dydz * zc; - zc += z0; - - auto ndofHost = vsoaHost.view()[sic].ndof(); - auto chi2Host = vsoaHost.view()[sic].chi2(); - - const int32_t notFound = -1; - int32_t closestVtxidx = notFound; - float mindz = dzCut_; - - for (int ivg = 0; ivg < nVerticesDevice; ivg++) { - auto sig = vsoaDevice.view()[ivg].sortInd(); - auto zgc = vsoaDevice.view()[sig].zv() + z0; - auto zDist = std::abs(zc - zgc); - //insert some matching condition - if (zDist > dzCut_) - continue; - if (mindz > zDist) { - mindz = zDist; - closestVtxidx = sig; - } - } - if (closestVtxidx == notFound) - continue; - - auto zg = vsoaDevice.view()[closestVtxidx].zv(); - auto xg = x0 + dxdz * zg; - auto yg = y0 + dydz * zg; - zg += z0; - auto ndofDevice = vsoaDevice.view()[closestVtxidx].ndof(); - auto chi2Device = vsoaDevice.view()[closestVtxidx].chi2(); - - hx_->Fill(xc - x0, xg - x0); - hy_->Fill(yc - y0, yg - y0); - hz_->Fill(zc, zg); - hxdiff_->Fill(xc - xg); - hydiff_->Fill(yc - yg); - hzdiff_->Fill(zc - zg); - hchi2_->Fill(chi2Host, chi2Device); - hchi2oNdof_->Fill(chi2Host / ndofHost, chi2Device / ndofDevice); - hptv2_->Fill(vsoaHost.view()[sic].ptv2(), vsoaDevice.view()[closestVtxidx].ptv2()); - hntrks_->Fill(ndofHost + 1, ndofDevice + 1); - } - hnVertex_->Fill(nVerticesHost, nVerticesDevice); -} - -// -// -- Book Histograms -// -void SiPixelCompareVertexSoAAlpaka::bookHistograms(DQMStore::IBooker& ibooker, - edm::Run const& iRun, - edm::EventSetup const& iSetup) { - ibooker.cd(); - ibooker.setCurrentFolder(topFolderName_); - - // FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports either TH2I or THnSparse - // these should be moved to a less resource consuming format - hnVertex_ = ibooker.book2I("nVertex", "# of Vertices;Host;Device", 101, -0.5, 100.5, 101, -0.5, 100.5); - hx_ = ibooker.book2I("vx", "Vertez x - Beamspot x;Host;Device", 50, -0.1, 0.1, 50, -0.1, 0.1); - hy_ = ibooker.book2I("vy", "Vertez y - Beamspot y;Host;Device", 50, -0.1, 0.1, 50, -0.1, 0.1); - hz_ = ibooker.book2I("vz", "Vertez z;Host;Device", 30, -30., 30., 30, -30., 30.); - hchi2_ = ibooker.book2I("chi2", "Vertex chi-squared;Host;Device", 40, 0., 20., 40, 0., 20.); - hchi2oNdof_ = ibooker.book2I("chi2oNdof", "Vertex chi-squared/Ndof;Host;Device", 40, 0., 20., 40, 0., 20.); - hptv2_ = ibooker.book2I("ptsq", "Vertex #sum (p_{T})^{2};Host;Device", 200, 0., 200., 200, 0., 200.); - hntrks_ = ibooker.book2I("ntrk", "#tracks associated;Host;Device", 100, -0.5, 99.5, 100, -0.5, 99.5); - hntrks_ = ibooker.book2I("ntrk", "#tracks associated;Host;Device", 100, -0.5, 99.5, 100, -0.5, 99.5); - hxdiff_ = ibooker.book1D("vxdiff", ";Vertex x difference (Host - Device);#entries", 100, -0.001, 0.001); - hydiff_ = ibooker.book1D("vydiff", ";Vertex y difference (Host - Device);#entries", 100, -0.001, 0.001); - hzdiff_ = ibooker.book1D("vzdiff", ";Vertex z difference (Host - Device);#entries", 100, -2.5, 2.5); -} - -void SiPixelCompareVertexSoAAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // monitorpixelVertexSoA - edm::ParameterSetDescription desc; - desc.add("pixelVertexSrcHost", edm::InputTag("pixelVerticesAlpakaSerial")); - desc.add("pixelVertexSrcDevice", edm::InputTag("pixelVerticesAlpaka")); - desc.add("beamSpotSrc", edm::InputTag("offlineBeamSpot")); - desc.add("topFolderName", "SiPixelHeterogeneous/PixelVertexCompareSoADeviceVSHost"); - desc.add("dzCut", 1.); - descriptions.addWithDefaultLabel(desc); -} - -DEFINE_FWK_MODULE(SiPixelCompareVertexSoAAlpaka); diff --git a/HLTrigger/Configuration/python/customizeHLTforAlpaka.py b/HLTrigger/Configuration/python/customizeHLTforAlpaka.py index 619f38cf27ebd..c0ea39bd9db41 100644 --- a/HLTrigger/Configuration/python/customizeHLTforAlpaka.py +++ b/HLTrigger/Configuration/python/customizeHLTforAlpaka.py @@ -332,9 +332,9 @@ def customizeHLTforDQMGPUvsCPUPixel(process): ) # PixelRecHits: 'GPUvsCPU' comparisons - process.hltPixelRecHitsSoACompareGPUvsCPU = cms.EDProducer('SiPixelPhase1CompareRecHitsSoAAlpaka', - pixelHitsSrcHost = cms.InputTag('hltSiPixelRecHitsSoASerialSync'), - pixelHitsSrcDevice = cms.InputTag('hltSiPixelRecHitsSoA'), + process.hltPixelRecHitsSoACompareGPUvsCPU = cms.EDProducer('SiPixelPhase1CompareRecHits', + pixelHitsReferenceSoA = cms.InputTag('hltSiPixelRecHitsSoASerialSync'), + pixelHitsTargetSoA = cms.InputTag('hltSiPixelRecHitsSoA'), topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU'), minD2cut = cms.double(1.0e-4) ) @@ -353,11 +353,11 @@ def customizeHLTforDQMGPUvsCPUPixel(process): useQualityCut = cms.bool(True) ) - process.hltPixelTracksSoACompareGPUvsCPU = cms.EDProducer("SiPixelPhase1CompareTrackSoAAlpaka", + process.hltPixelTracksSoACompareGPUvsCPU = cms.EDProducer("SiPixelPhase1CompareTracks", deltaR2cut = cms.double(0.04), minQuality = cms.string('loose'), - pixelTrackSrcHost = cms.InputTag("hltPixelTracksSoASerialSync"), - pixelTrackSrcDevice = cms.InputTag("hltPixelTracksSoA"), + pixelTrackReferenceSoA = cms.InputTag("hltPixelTracksSoASerialSync"), + pixelTrackTargetSoA = cms.InputTag("hltPixelTracksSoA"), topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU'), useQualityCut = cms.bool(True) ) @@ -374,11 +374,11 @@ def customizeHLTforDQMGPUvsCPUPixel(process): topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexGPU') ) - process.hltPixelVertexSoACompareGPUvsCPU = cms.EDProducer("SiPixelCompareVertexSoAAlpaka", + process.hltPixelVertexSoACompareGPUvsCPU = cms.EDProducer("SiPixelCompareVertices", beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"), dzCut = cms.double(1), - pixelVertexSrcHost = cms.InputTag("hltPixelVerticesSoASerialSync"), - pixelVertexSrcDevice = cms.InputTag("hltPixelVerticesSoA"), + pixelVertexReferenceSoA = cms.InputTag("hltPixelVerticesSoASerialSync"), + pixelVertexTargetSoA = cms.InputTag("hltPixelVerticesSoA"), topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareGPUvsCPU') )