Skip to content

Commit dd76748

Browse files
committed
refine number of tracks monitoring
1 parent 41de219 commit dd76748

File tree

4 files changed

+115
-18
lines changed

4 files changed

+115
-18
lines changed

DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTrackSoA.cc

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class SiPixelCompareTrackSoA : public DQMEDAnalyzer {
8484
MonitorElement* hnTracks_;
8585
MonitorElement* hnLooseAndAboveTracks_;
8686
MonitorElement* hnLooseAndAboveTracks_matched_;
87+
MonitorElement* hDeltaNTracks_;
88+
MonitorElement* hDeltaNLooseAndAboveTracks_;
89+
MonitorElement* hDeltaNLooseAndAboveTracks_matched_;
8790
MonitorElement* hnHits_;
8891
MonitorElement* hnHitsVsPhi_;
8992
MonitorElement* hnHitsVsEta_;
@@ -240,9 +243,23 @@ void SiPixelCompareTrackSoA<T>::analyze(const edm::Event& iEvent, const edm::Eve
240243
hpt_eta_tkAllRefMatched_->Fill(etaCPU, tsoaCPU.view()[it].pt()); //matched to gpu
241244
hphi_z_tkAllRefMatched_->Fill(etaCPU, zipCPU);
242245
}
243-
hnTracks_->Fill(nTracksCPU, nTracksGPU);
244-
hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU);
245-
hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU);
246+
247+
// Define a lambda function for filling the histograms
248+
auto fillHistogram = [](auto& histogram, auto xValue, auto yValue) { histogram->Fill(xValue, yValue); };
249+
250+
// Define a lambda for filling delta histograms
251+
auto fillDeltaHistogram = [](auto& histogram, int cpuValue, int gpuValue) {
252+
histogram->Fill(std::min(cpuValue, 1000), std::clamp(gpuValue - cpuValue, -100, 100));
253+
};
254+
255+
// Fill the histograms
256+
fillHistogram(hnTracks_, nTracksCPU, nTracksGPU);
257+
fillHistogram(hnLooseAndAboveTracks_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU);
258+
fillHistogram(hnLooseAndAboveTracks_matched_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU);
259+
260+
fillDeltaHistogram(hDeltaNTracks_, nTracksCPU, nTracksGPU);
261+
fillDeltaHistogram(hDeltaNLooseAndAboveTracks_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU);
262+
fillDeltaHistogram(hDeltaNLooseAndAboveTracks_matched_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU);
246263
}
247264

248265
//
@@ -255,13 +272,44 @@ void SiPixelCompareTrackSoA<T>::bookHistograms(DQMStore::IBooker& iBook,
255272
iBook.cd();
256273
iBook.setCurrentFolder(topFolderName_);
257274

258-
// clang-format off
275+
// Define a helper function for booking histograms
259276
std::string toRep = "Number of tracks";
277+
auto bookTracksTH2I = [&](const std::string& name,
278+
const std::string& title,
279+
int xBins,
280+
double xMin,
281+
double xMax,
282+
int yBins,
283+
double yMin,
284+
double yMax) {
285+
return iBook.book2I(name, fmt::sprintf(title, toRep), xBins, xMin, xMax, yBins, yMin, yMax);
286+
};
287+
288+
// Define common parameters for different histogram types
289+
constexpr int xBins = 501;
290+
constexpr double xMin = -0.5;
291+
constexpr double xMax = 1001.5;
292+
293+
constexpr int dXBins = 1001;
294+
constexpr double dXMin = -0.5;
295+
constexpr double dXMax = 1000.5;
296+
297+
constexpr int dYBins = 201;
298+
constexpr double dYMin = -100.5;
299+
constexpr double dYMax = 100.5;
300+
260301
// FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports THnSparse
261302
// these should be moved to a less resource consuming format
262-
hnTracks_ = iBook.book2I("nTracks", fmt::sprintf("%s per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
263-
hnLooseAndAboveTracks_ = iBook.book2I("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
264-
hnLooseAndAboveTracks_matched_ = iBook.book2I("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
303+
304+
// Book histograms using the helper function
305+
// clang-format off
306+
hnTracks_ = bookTracksTH2I("nTracks", "%s per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax);
307+
hnLooseAndAboveTracks_ = bookTracksTH2I("nLooseAndAboveTracks", "%s (quality #geq loose) per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax);
308+
hnLooseAndAboveTracks_matched_ = bookTracksTH2I("nLooseAndAboveTracks_matched", "%s (quality #geq loose) per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax);
309+
310+
hDeltaNTracks_ = bookTracksTH2I("deltaNTracks", "%s per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax);
311+
hDeltaNLooseAndAboveTracks_ = bookTracksTH2I("deltaNLooseAndAboveTracks", "%s (quality #geq loose) per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax);
312+
hDeltaNLooseAndAboveTracks_matched_ = bookTracksTH2I("deltaNLooseAndAboveTracks_matched", "%s (quality #geq loose) per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax);
265313

266314
toRep = "Number of all RecHits per track (quality #geq loose)";
267315
hnHits_ = iBook.book2I("nRecHits", fmt::sprintf("%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);

DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTracks.cc

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212

1313
// for string manipulations
14+
#include <algorithm>
1415
#include <fmt/printf.h>
1516
#include "DataFormats/Common/interface/Handle.h"
1617
#include "DataFormats/Math/interface/deltaR.h"
@@ -94,6 +95,9 @@ class SiPixelCompareTracks : public DQMEDAnalyzer {
9495
MonitorElement* hnTracks_;
9596
MonitorElement* hnLooseAndAboveTracks_;
9697
MonitorElement* hnLooseAndAboveTracks_matched_;
98+
MonitorElement* hDeltaNTracks_;
99+
MonitorElement* hDeltaNLooseAndAboveTracks_;
100+
MonitorElement* hDeltaNLooseAndAboveTracks_matched_;
97101
MonitorElement* hnHits_;
98102
MonitorElement* hnHitsVsPhi_;
99103
MonitorElement* hnHitsVsEta_;
@@ -253,9 +257,23 @@ void SiPixelCompareTracks<T>::analyzeSeparate(U tokenRef, V tokenTar, const edm:
253257
hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[it].pt()); //matched to gpu
254258
hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef);
255259
}
256-
hnTracks_->Fill(nTracksRef, nTracksTar);
257-
hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksTar);
258-
hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar);
260+
261+
// Define a lambda function for filling the histograms
262+
auto fillHistogram = [](auto& histogram, auto xValue, auto yValue) { histogram->Fill(xValue, yValue); };
263+
264+
// Define a lambda for filling delta histograms
265+
auto fillDeltaHistogram = [](auto& histogram, int cpuValue, int gpuValue) {
266+
histogram->Fill(std::min(cpuValue, 1000), std::clamp(gpuValue - cpuValue, -100, 100));
267+
};
268+
269+
// Fill the histograms
270+
fillHistogram(hnTracks_, nTracksRef, nTracksTar);
271+
fillHistogram(hnLooseAndAboveTracks_, nLooseAndAboveTracksRef, nLooseAndAboveTracksTar);
272+
fillHistogram(hnLooseAndAboveTracks_matched_, nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar);
273+
274+
fillDeltaHistogram(hDeltaNTracks_, nTracksRef, nTracksTar);
275+
fillDeltaHistogram(hDeltaNLooseAndAboveTracks_, nLooseAndAboveTracksRef, nLooseAndAboveTracksTar);
276+
fillDeltaHistogram(hDeltaNLooseAndAboveTracks_matched_, nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar);
259277
}
260278

261279
//
@@ -278,13 +296,44 @@ void SiPixelCompareTracks<T>::bookHistograms(DQMStore::IBooker& iBook,
278296
iBook.cd();
279297
iBook.setCurrentFolder(topFolderName_);
280298

281-
// clang-format off
299+
// Define a helper function for booking histograms
282300
std::string toRep = "Number of tracks";
301+
auto bookTracksTH2I = [&](const std::string& name,
302+
const std::string& title,
303+
int xBins,
304+
double xMin,
305+
double xMax,
306+
int yBins,
307+
double yMin,
308+
double yMax) {
309+
return iBook.book2I(name, fmt::sprintf(title, toRep), xBins, xMin, xMax, yBins, yMin, yMax);
310+
};
311+
312+
// Define common parameters for different histogram types
313+
constexpr int xBins = 501;
314+
constexpr double xMin = -0.5;
315+
constexpr double xMax = 1001.5;
316+
317+
constexpr int dXBins = 1001;
318+
constexpr double dXMin = -0.5;
319+
constexpr double dXMax = 1000.5;
320+
321+
constexpr int dYBins = 201;
322+
constexpr double dYMin = -100.5;
323+
constexpr double dYMax = 100.5;
324+
283325
// FIXME: all the 2D correlation plots are quite heavy in terms of memory consumption, so a as soon as DQM supports THnSparse
284326
// these should be moved to a less resource consuming format
285-
hnTracks_ = iBook.book2I("nTracks", fmt::sprintf("%s per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
286-
hnLooseAndAboveTracks_ = iBook.book2I("nLooseAndAboveTracks", fmt::sprintf("%s (quality #geq loose) per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
287-
hnLooseAndAboveTracks_matched_ = iBook.book2I("nLooseAndAboveTracks_matched", fmt::sprintf("%s (quality #geq loose) per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
327+
328+
// Book histograms using the helper function
329+
// clang-format off
330+
hnTracks_ = bookTracksTH2I("nTracks", "%s per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax);
331+
hnLooseAndAboveTracks_ = bookTracksTH2I("nLooseAndAboveTracks", "%s (quality #geq loose) per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax);
332+
hnLooseAndAboveTracks_matched_ = bookTracksTH2I("nLooseAndAboveTracks_matched", "%s (quality #geq loose) per event; Reference; Target", xBins, xMin, xMax, xBins, xMin, xMax);
333+
334+
hDeltaNTracks_ = bookTracksTH2I("deltaNTracks", "%s per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax);
335+
hDeltaNLooseAndAboveTracks_ = bookTracksTH2I("deltaNLooseAndAboveTracks", "%s (quality #geq loose) per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax);
336+
hDeltaNLooseAndAboveTracks_matched_ = bookTracksTH2I("deltaNLooseAndAboveTracks_matched", "%s (quality #geq loose) per event; Reference; Target - Reference", dXBins, dXMin, dXMax, dYBins, dYMin, dYMax);
288337

289338
toRep = "Number of all RecHits per track (quality #geq loose)";
290339
hnHits_ = iBook.book2I("nRecHits", fmt::sprintf("%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);

DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoA.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void SiPixelMonitorTrackSoA<T>::bookHistograms(DQMStore::IBooker& iBook,
148148

149149
// clang-format off
150150
std::string toRep = "Number of tracks";
151-
hnTracks = iBook.book1D("nTracks", fmt::sprintf(";%s per event;#events",toRep), 1001, -0.5, 1000.5);
152-
hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::sprintf(";%s (quality #geq loose) per event;#events",toRep), 1001, -0.5, 1000.5);
151+
hnTracks = iBook.book1D("nTracks", fmt::sprintf(";%s per event;#events",toRep), 1001, -0.5, 2001.5);
152+
hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::sprintf(";%s (quality #geq loose) per event;#events",toRep), 1001, -0.5, 2001.5);
153153

154154
toRep = "Number of all RecHits per track (quality #geq loose)";
155155
hnHits = iBook.book1D("nRecHits", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5);

DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoAAlpaka.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void SiPixelMonitorTrackSoAAlpaka<T>::bookHistograms(DQMStore::IBooker& iBook,
148148

149149
// clang-format off
150150
std::string toRep = "Number of tracks";
151-
hnTracks = iBook.book1D("nTracks", fmt::format(";{} per event;#events",toRep), 1001, -0.5, 1000.5);
152-
hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::format(";{} (quality #geq loose) per event;#events",toRep), 1001, -0.5, 1000.5);
151+
hnTracks = iBook.book1D("nTracks", fmt::format(";{} per event;#events",toRep), 1001, -0.5, 2001.5);
152+
hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::format(";{} (quality #geq loose) per event;#events",toRep), 1001, -0.5, 2001.5);
153153

154154
toRep = "Number of all RecHits per track (quality #geq loose)";
155155
hnHits = iBook.book1D("nRecHits", fmt::format(";{};#tracks",toRep), 15, -0.5, 14.5);

0 commit comments

Comments
 (0)