Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template DQM/SiPixelPhase1Heterogenous class to be able to handle the Phase-2 SoA objects #40264

Merged
merged 5 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// -*- C++ -*-
// Package: SiPixelPhase1CompareRecHitsSoA
// Class: SiPixelPhase1CompareRecHitsSoA
// Package: SiPixelCompareRecHitsSoA
// Class: SiPixelCompareRecHitsSoA
//
/**\class SiPixelPhase1CompareRecHitsSoA SiPixelPhase1CompareRecHitsSoA.cc
/**\class SiPixelCompareRecHitsSoA SiPixelCompareRecHitsSoA.cc
*/
//
// Author: Suvankar Roy Chowdhury, Alessandro Rossi
Expand All @@ -27,13 +27,14 @@
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"

class SiPixelPhase1CompareRecHitsSoA : public DQMEDAnalyzer {
template <typename T>
class SiPixelCompareRecHitsSoA : public DQMEDAnalyzer {
public:
using HitSoA = TrackingRecHit2DSOAViewT<pixelTopology::Phase1>;
using HitsOnCPU = TrackingRecHit2DCPUT<pixelTopology::Phase1>;
using HitSoA = TrackingRecHit2DSOAViewT<T>;
using HitsOnCPU = TrackingRecHit2DCPUT<T>;

explicit SiPixelPhase1CompareRecHitsSoA(const edm::ParameterSet&);
~SiPixelPhase1CompareRecHitsSoA() override = default;
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;
Expand All @@ -51,16 +52,16 @@ class SiPixelPhase1CompareRecHitsSoA : public DQMEDAnalyzer {
const TrackerGeometry* tkGeom_ = nullptr;
const TrackerTopology* tTopo_ = nullptr;
MonitorElement* hnHits_;
MonitorElement* hBchargeL_[4];
MonitorElement* hBchargeL_[4]; // max 4 barrel hits
MonitorElement* hBsizexL_[4];
MonitorElement* hBsizeyL_[4];
MonitorElement* hBposxL_[4];
MonitorElement* hBposyL_[4];
MonitorElement* hFchargeD_[2][3];
MonitorElement* hFsizexD_[2][3];
MonitorElement* hFsizeyD_[2][3];
MonitorElement* hFposxD_[2][3];
MonitorElement* hFposyD_[2][3];
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_;
Expand All @@ -77,7 +78,8 @@ class SiPixelPhase1CompareRecHitsSoA : public DQMEDAnalyzer {
// constructors
//

SiPixelPhase1CompareRecHitsSoA::SiPixelPhase1CompareRecHitsSoA(const edm::ParameterSet& iConfig)
template <typename T>
SiPixelCompareRecHitsSoA<T>::SiPixelCompareRecHitsSoA(const edm::ParameterSet& iConfig)
: geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()),
tokenSoAHitsCPU_(consumes(iConfig.getParameter<edm::InputTag>("pixelHitsSrcCPU"))),
Expand All @@ -87,19 +89,21 @@ SiPixelPhase1CompareRecHitsSoA::SiPixelPhase1CompareRecHitsSoA(const edm::Parame
//
// Begin Run
//
void SiPixelPhase1CompareRecHitsSoA::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
template <typename T>
void SiPixelCompareRecHitsSoA<T>::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
tkGeom_ = &iSetup.getData(geomToken_);
tTopo_ = &iSetup.getData(topoToken_);
}

//
// -- Analyze
//
void SiPixelPhase1CompareRecHitsSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
template <typename T>
void SiPixelCompareRecHitsSoA<T>::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("SiPixelPhase1CompareRecHitSoA");
edm::LogWarning out("SiPixelCompareRecHitSoA");
if (not rhsoaHandleCPU) {
out << "reference (cpu) rechits not found; ";
}
Expand Down Expand Up @@ -184,9 +188,10 @@ void SiPixelPhase1CompareRecHitsSoA::analyze(const edm::Event& iEvent, const edm
//
// -- Book Histograms
//
void SiPixelPhase1CompareRecHitsSoA::bookHistograms(DQMStore::IBooker& iBook,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
template <typename T>
void SiPixelCompareRecHitsSoA<T>::bookHistograms(DQMStore::IBooker& iBook,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
iBook.cd();
iBook.setCurrentFolder(topFolderName_);

Expand Down Expand Up @@ -226,7 +231,8 @@ void SiPixelPhase1CompareRecHitsSoA::bookHistograms(DQMStore::IBooker& iBook,
hFposYDiff_ = iBook.book1D("rechitsposYDiffFpix","y-position difference of rechits in FPix; rechit y-pos difference (CPU - GPU)", 1000, -10, 10);
}

void SiPixelPhase1CompareRecHitsSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
template<typename T>
void SiPixelCompareRecHitsSoA<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
// monitorpixelRecHitsSoA
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("pixelHitsSrcCPU", edm::InputTag("siPixelRecHitsPreSplittingSoA@cpu"));
Expand All @@ -235,4 +241,9 @@ void SiPixelPhase1CompareRecHitsSoA::fillDescriptions(edm::ConfigurationDescript
desc.add<double>("minD2cut", 0.0001);
descriptions.addWithDefaultLabel(desc);
}

using SiPixelPhase1CompareRecHitsSoA = SiPixelCompareRecHitsSoA<pixelTopology::Phase1>;
using SiPixelPhase2CompareRecHitsSoA = SiPixelCompareRecHitsSoA<pixelTopology::Phase2>;

DEFINE_FWK_MODULE(SiPixelPhase1CompareRecHitsSoA);
DEFINE_FWK_MODULE(SiPixelPhase2CompareRecHitsSoA);
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// -*- C++ -*-
// Package: SiPixelPhase1CompareTrackSoA
// Class: SiPixelPhase1CompareTrackSoA
// Package: SiPixelCompareTrackSoA
// Class: SiPixelCompareTrackSoA
//
/**\class SiPixelPhase1CompareTrackSoA SiPixelPhase1CompareTrackSoA.cc
/**\class SiPixelCompareTrackSoA SiPixelCompareTrackSoA.cc
*/
//
// Author: Suvankar Roy Chowdhury
Expand Down Expand Up @@ -62,19 +62,20 @@ namespace {
}
} // namespace

class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer {
template <typename T>
class SiPixelCompareTrackSoA : public DQMEDAnalyzer {
public:
using PixelTrackSoAPhase1 = PixelTrackHeterogeneousT<pixelTopology::Phase1>;
using PixelTrackSoA = PixelTrackHeterogeneousT<T>;

explicit SiPixelPhase1CompareTrackSoA(const edm::ParameterSet&);
~SiPixelPhase1CompareTrackSoA() override = default;
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<PixelTrackSoAPhase1> tokenSoATrackCPU_;
const edm::EDGetTokenT<PixelTrackSoAPhase1> tokenSoATrackGPU_;
const edm::EDGetTokenT<PixelTrackSoA> tokenSoATrackCPU_;
const edm::EDGetTokenT<PixelTrackSoA> tokenSoATrackGPU_;
const std::string topFolderName_;
const bool useQualityCut_;
const pixelTrack::Quality minQuality_;
Expand Down Expand Up @@ -114,9 +115,10 @@ class SiPixelPhase1CompareTrackSoA : public DQMEDAnalyzer {
// constructors
//

SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterSet& iConfig)
: tokenSoATrackCPU_(consumes<PixelTrackSoAPhase1>(iConfig.getParameter<edm::InputTag>("pixelTrackSrcCPU"))),
tokenSoATrackGPU_(consumes<PixelTrackSoAPhase1>(iConfig.getParameter<edm::InputTag>("pixelTrackSrcGPU"))),
template <typename T>
SiPixelCompareTrackSoA<T>::SiPixelCompareTrackSoA(const edm::ParameterSet& iConfig)
: tokenSoATrackCPU_(consumes<PixelTrackSoA>(iConfig.getParameter<edm::InputTag>("pixelTrackSrcCPU"))),
tokenSoATrackGPU_(consumes<PixelTrackSoA>(iConfig.getParameter<edm::InputTag>("pixelTrackSrcGPU"))),
topFolderName_(iConfig.getParameter<std::string>("topFolderName")),
useQualityCut_(iConfig.getParameter<bool>("useQualityCut")),
minQuality_(pixelTrack::qualityByName(iConfig.getParameter<std::string>("minQuality"))),
Expand All @@ -125,11 +127,12 @@ SiPixelPhase1CompareTrackSoA::SiPixelPhase1CompareTrackSoA(const edm::ParameterS
//
// -- Analyze
//
void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
template <typename T>
void SiPixelCompareTrackSoA<T>::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
const auto& tsoaHandleCPU = iEvent.getHandle(tokenSoATrackCPU_);
const auto& tsoaHandleGPU = iEvent.getHandle(tokenSoATrackGPU_);
if (not tsoaHandleCPU or not tsoaHandleGPU) {
edm::LogWarning out("SiPixelPhase1CompareTrackSoA");
edm::LogWarning out("SiPixelCompareTrackSoA");
if (not tsoaHandleCPU) {
out << "reference (cpu) tracks not found; ";
}
Expand Down Expand Up @@ -224,9 +227,10 @@ void SiPixelPhase1CompareTrackSoA::analyze(const edm::Event& iEvent, const edm::
//
// -- Book Histograms
//
void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
template <typename T>
void SiPixelCompareTrackSoA<T>::bookHistograms(DQMStore::IBooker& iBook,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
iBook.cd();
iBook.setCurrentFolder(topFolderName_);

Expand Down Expand Up @@ -267,7 +271,8 @@ void SiPixelPhase1CompareTrackSoA::bookHistograms(DQMStore::IBooker& iBook,

}

void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
template<typename T>
void SiPixelCompareTrackSoA<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
// monitorpixelTrackSoA
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("pixelTrackSrcCPU", edm::InputTag("pixelTracksSoA@cpu"));
Expand All @@ -278,4 +283,9 @@ void SiPixelPhase1CompareTrackSoA::fillDescriptions(edm::ConfigurationDescriptio
desc.add<double>("deltaR2cut", 0.04);
descriptions.addWithDefaultLabel(desc);
}

using SiPixelPhase1CompareTrackSoA = SiPixelCompareTrackSoA<pixelTopology::Phase1>;
using SiPixelPhase2CompareTrackSoA = SiPixelCompareTrackSoA<pixelTopology::Phase2>;

DEFINE_FWK_MODULE(SiPixelPhase1CompareTrackSoA);
DEFINE_FWK_MODULE(SiPixelPhase2CompareTrackSoA);
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// -*- C++ -*-
// Package: SiPixelPhase1CompareVertexSoA
// Class: SiPixelPhase1CompareVertexSoA
// Package: SiPixelCompareVertexSoA
// Class: SiPixelCompareVertexSoA
//
/**\class SiPixelPhase1CompareVertexSoA SiPixelPhase1CompareVertexSoA.cc
/**\class SiPixelCompareVertexSoA SiPixelCompareVertexSoA.cc
*/
//
// Author: Suvankar Roy Chowdhury
Expand All @@ -21,11 +21,11 @@
#include "CUDADataFormats/Vertex/interface/ZVertexHeterogeneous.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"

class SiPixelPhase1CompareVertexSoA : public DQMEDAnalyzer {
class SiPixelCompareVertexSoA : public DQMEDAnalyzer {
public:
using IndToEdm = std::vector<uint16_t>;
explicit SiPixelPhase1CompareVertexSoA(const edm::ParameterSet&);
~SiPixelPhase1CompareVertexSoA() override = default;
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);
Expand Down Expand Up @@ -53,7 +53,7 @@ class SiPixelPhase1CompareVertexSoA : public DQMEDAnalyzer {
// constructors
//

SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::ParameterSet& iConfig)
SiPixelCompareVertexSoA::SiPixelCompareVertexSoA(const edm::ParameterSet& iConfig)
: tokenSoAVertexCPU_(consumes<ZVertexHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelVertexSrcCPU"))),
tokenSoAVertexGPU_(consumes<ZVertexHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelVertexSrcGPU"))),
tokenBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotSrc"))),
Expand All @@ -63,11 +63,11 @@ SiPixelPhase1CompareVertexSoA::SiPixelPhase1CompareVertexSoA(const edm::Paramete
//
// -- Analyze
//
void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
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("SiPixelPhase1CompareTrackSoA");
edm::LogWarning out("SiPixelCompareVertexSoA");
if (not vsoaHandleCPU) {
out << "reference (cpu) tracks not found; ";
}
Expand All @@ -86,7 +86,7 @@ void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm:
auto bsHandle = iEvent.getHandle(tokenBeamSpot_);
float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.;
if (!bsHandle.isValid()) {
edm::LogWarning("PixelVertexProducer") << "No beamspot found. returning vertexes with (0,0,Z) ";
edm::LogWarning("SiPixelCompareVertexSoA") << "No beamspot found. returning vertexes with (0,0,Z) ";
} else {
const reco::BeamSpot& bs = *bsHandle;
x0 = bs.x0();
Expand Down Expand Up @@ -149,29 +149,29 @@ void SiPixelPhase1CompareVertexSoA::analyze(const edm::Event& iEvent, const edm:
//
// -- Book Histograms
//
void SiPixelPhase1CompareVertexSoA::bookHistograms(DQMStore::IBooker& ibooker,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
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 Vertex;CPU;GPU", 101, -0.5, 100.5, 101, -0.5, 100.5);
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 p_T squared;CPU;GPU", 200, 0., 200., 200, 0., 200.);
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 SiPixelPhase1CompareVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void SiPixelCompareVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
// monitorpixelVertexSoA
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("pixelVertexSrcCPU", edm::InputTag("pixelVerticesSoA@cpu"));
Expand All @@ -181,4 +181,7 @@ void SiPixelPhase1CompareVertexSoA::fillDescriptions(edm::ConfigurationDescripti
desc.add<double>("dzCut", 1.);
descriptions.addWithDefaultLabel(desc);
}
DEFINE_FWK_MODULE(SiPixelCompareVertexSoA);

using SiPixelPhase1CompareVertexSoA = SiPixelCompareVertexSoA;
DEFINE_FWK_MODULE(SiPixelPhase1CompareVertexSoA);
Loading