26 #include <fmt/printf.h> 33 void setBinLog(TAxis* axis) {
34 int bins = axis->GetNbins();
35 float from = axis->GetXmin();
36 float to = axis->GetXmax();
38 std::vector<float> new_bins(
bins + 1, 0);
39 for (
int i = 0;
i <=
bins;
i++) {
40 new_bins[
i] = TMath::Power(10, from +
i *
width);
42 axis->Set(
bins, new_bins.data());
45 void setBinLogX(TH1*
h) {
46 TAxis* axis =
h->GetXaxis();
49 void setBinLogY(TH1*
h) {
50 TAxis* axis =
h->GetYaxis();
54 template <
typename...
Args>
56 auto h = std::make_unique<TH2I>(std::forward<Args>(
args)...);
61 const auto&
name =
h->GetName();
62 return ibook.book2I(
name,
h.release());
127 template <
typename T>
131 topFolderName_(iConfig.getParameter<
std::
string>(
"topFolderName")),
132 useQualityCut_(iConfig.getParameter<
bool>(
"useQualityCut")),
134 dr2cut_(iConfig.getParameter<double>(
"deltaR2cut")) {}
139 template <
typename T>
142 const auto& tsoaHandleCPU =
iEvent.getHandle(tokenSoATrackCPU_);
143 const auto& tsoaHandleGPU =
iEvent.getHandle(tokenSoATrackGPU_);
144 if (not tsoaHandleCPU
or not tsoaHandleGPU) {
146 if (not tsoaHandleCPU) {
147 out <<
"reference (cpu) tracks not found; ";
149 if (not tsoaHandleGPU) {
150 out <<
"target (gpu) tracks not found; ";
152 out <<
"the comparison will not run.";
156 auto const& tsoaCPU = *tsoaHandleCPU;
157 auto const& tsoaGPU = *tsoaHandleGPU;
158 auto maxTracksCPU = tsoaCPU.view().metadata().size();
159 auto maxTracksGPU = tsoaGPU.view().metadata().size();
160 auto const* qualityCPU = tsoaCPU.view().quality();
161 auto const* qualityGPU = tsoaGPU.view().quality();
162 int32_t nTracksCPU = 0;
163 int32_t nTracksGPU = 0;
164 int32_t nLooseAndAboveTracksCPU = 0;
165 int32_t nLooseAndAboveTracksCPU_matchedGPU = 0;
166 int32_t nLooseAndAboveTracksGPU = 0;
169 std::vector<int32_t> looseTrkidxGPU;
170 for (int32_t jt = 0; jt < maxTracksGPU; ++jt) {
173 if (!(tsoaGPU.view()[jt].pt() > 0.))
176 if (useQualityCut_ && qualityGPU[jt] < minQuality_)
178 nLooseAndAboveTracksGPU++;
179 looseTrkidxGPU.emplace_back(jt);
183 for (int32_t
it = 0;
it < maxTracksCPU; ++
it) {
189 float ptCPU = tsoaCPU.view()[
it].pt();
190 float etaCPU = tsoaCPU.view()[
it].eta();
191 float phiCPU = helper::phi(tsoaCPU.view(),
it);
199 if (useQualityCut_ && qualityCPU[
it] < minQuality_)
201 nLooseAndAboveTracksCPU++;
205 float mindr2 = dr2cut_;
207 for (
auto gid : looseTrkidxGPU) {
208 float etaGPU = tsoaGPU.view()[gid].
eta();
209 float phiGPU = helper::phi(tsoaGPU.view(), gid);
219 hpt_eta_tkAllRef_->Fill(etaCPU, ptCPU);
220 hphi_z_tkAllRef_->Fill(phiCPU, zipCPU);
223 nLooseAndAboveTracksCPU_matchedGPU++;
225 hchi2_->Fill(tsoaCPU.view()[
it].chi2(), tsoaGPU.view()[closestTkidx].chi2());
226 hCharge_->Fill(qCPU,
helper::charge(tsoaGPU.view(), closestTkidx));
228 hnLayers_->Fill(tsoaCPU.view()[
it].nLayers(), tsoaGPU.view()[closestTkidx].nLayers());
229 hpt_->Fill(ptCPU, tsoaGPU.view()[closestTkidx].pt());
230 hCurvature_->Fill(qCPU / ptCPU,
helper::charge(tsoaGPU.view(), closestTkidx) / tsoaGPU.view()[closestTkidx].pt());
231 hptLogLog_->Fill(ptCPU, tsoaGPU.view()[closestTkidx].pt());
232 heta_->Fill(etaCPU, tsoaGPU.view()[closestTkidx].eta());
233 hphi_->Fill(phiCPU, helper::phi(tsoaGPU.view(), closestTkidx));
234 hz_->Fill(zipCPU,
helper::zip(tsoaGPU.view(), closestTkidx));
235 htip_->Fill(tipCPU,
helper::tip(tsoaGPU.view(), closestTkidx));
236 hptdiffMatched_->Fill(ptCPU - tsoaGPU.view()[closestTkidx].pt());
237 hCurvdiffMatched_->Fill((
helper::charge(tsoaCPU.view(),
it) / tsoaCPU.view()[
it].pt()) -
238 (
helper::charge(tsoaGPU.view(), closestTkidx) / tsoaGPU.view()[closestTkidx].pt()));
239 hetadiffMatched_->Fill(etaCPU - tsoaGPU.view()[closestTkidx].eta());
240 hphidiffMatched_->Fill(
reco::deltaPhi(phiCPU, helper::phi(tsoaGPU.view(), closestTkidx)));
241 hzdiffMatched_->Fill(zipCPU -
helper::zip(tsoaGPU.view(), closestTkidx));
242 htipdiffMatched_->Fill(tipCPU -
helper::tip(tsoaGPU.view(), closestTkidx));
243 hpt_eta_tkAllRefMatched_->Fill(etaCPU, tsoaCPU.view()[
it].pt());
244 hphi_z_tkAllRefMatched_->Fill(etaCPU, zipCPU);
248 auto fillHistogram = [](
auto& histogram,
auto xValue,
auto yValue) { histogram->Fill(xValue, yValue); };
251 auto fillDeltaHistogram = [](
auto& histogram,
int cpuValue,
int gpuValue) {
252 histogram->Fill(
std::min(cpuValue, 1000), std::clamp(gpuValue - cpuValue, -100, 100));
256 fillHistogram(hnTracks_, nTracksCPU, nTracksGPU);
257 fillHistogram(hnLooseAndAboveTracks_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU);
258 fillHistogram(hnLooseAndAboveTracks_matched_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU);
260 fillDeltaHistogram(hDeltaNTracks_, nTracksCPU, nTracksGPU);
261 fillDeltaHistogram(hDeltaNLooseAndAboveTracks_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU);
262 fillDeltaHistogram(hDeltaNLooseAndAboveTracks_matched_, nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU);
268 template <
typename T>
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);
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);
314 toRep =
"Number of all RecHits per track (quality #geq loose)";
315 hnHits_ = iBook.
book2I(
"nRecHits", fmt::sprintf(
"%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
317 toRep =
"Number of all layers per track (quality #geq loose)";
318 hnLayers_ = iBook.
book2I(
"nLayers", fmt::sprintf(
"%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
320 toRep =
"Track (quality #geq loose) #chi^{2}/ndof";
321 hchi2_ = iBook.
book2I(
"nChi2ndof", fmt::sprintf(
"%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.);
323 toRep =
"Track (quality #geq loose) charge";
324 hCharge_ = iBook.
book2I(
"charge",fmt::sprintf(
"%s;CPU;GPU",toRep),3, -1.5, 1.5, 3, -1.5, 1.5);
326 hpt_ = iBook.
book2I(
"pt",
"Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.);
327 hCurvature_ = iBook.
book2I(
"curvature",
"Track (quality #geq loose) q/p_{T} [GeV^{-1}];CPU;GPU", 60,- 3., 3., 60, -3., 3. );
328 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.));
329 heta_ = iBook.
book2I(
"eta",
"Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.);
331 hz_ = iBook.
book2I(
"z",
"Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.);
332 htip_ = iBook.
book2I(
"tip",
"Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5);
334 hptdiffMatched_ = iBook.
book1D(
"ptdiffmatched",
" p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 61, -30.5, 30.5);
335 hCurvdiffMatched_ = iBook.
book1D(
"curvdiffmatched",
"q/p_{T} diff [GeV^{-1}] between matched tracks; #Delta q/p_{T} [GeV^{-1}]", 61, -3.05, 3.05);
336 hetadiffMatched_ = iBook.
book1D(
"etadiffmatched",
" #eta diff between matched tracks; #Delta #eta", 161, -0.045 ,0.045);
337 hphidiffMatched_ = iBook.
book1D(
"phidiffmatched",
" #phi diff between matched tracks; #Delta #phi", 161, -0.045 ,0.045);
338 hzdiffMatched_ = iBook.
book1D(
"zdiffmatched",
" z diff between matched tracks; #Delta z [cm]", 301, -1.55, 1.55);
339 htipdiffMatched_ = iBook.
book1D(
"tipdiffmatched",
" TIP diff between matched tracks; #Delta TIP [cm]", 301, -1.55, 1.55);
341 hpt_eta_tkAllRef_ = iBook.
book2I(
"ptetatrkAllReference",
"Track (quality #geq loose) on CPU; #eta; p_{T} [GeV];", 30, -
M_PI,
M_PI, 200, 0., 200.);
342 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.);
344 hphi_z_tkAllRef_ = iBook.
book2I(
"phiztrkAllReference",
"Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
345 hphi_z_tkAllRefMatched_ = iBook.
book2I(
"phiztrkAllReferencematched",
"Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
355 desc.add<
std::string>(
"topFolderName",
"SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU");
356 desc.add<
bool>(
"useQualityCut",
true);
358 desc.add<
double>(
"deltaR2cut", 0.02 * 0.02)->setComment(
"deltaR2 cut between track on CPU and GPU");
constexpr double deltaPhi(double phi1, double phi2)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
MonitorElement * hetadiffMatched_
const bool useQualityCut_
SiPixelCompareTrackSoA(const edm::ParameterSet &)
virtual void setCurrentFolder(std::string const &fullpath)
Quality qualityByName(std::string const &name)
MonitorElement * hnLayersVsPhi_
const edm::EDGetTokenT< PixelTrackSoA > tokenSoATrackGPU_
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
MonitorElement * hDeltaNTracks_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
MonitorElement * hphi_z_tkAllRef_
MonitorElement * hptdiffMatched_
const std::string topFolderName_
MonitorElement * hnLayersVsEta_
MonitorElement * hDeltaNLooseAndAboveTracks_matched_
MonitorElement * hptLogLog_
MonitorElement * hnLooseAndAboveTracks_matched_
MonitorElement * hpt_eta_tkAllRef_
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
dqm::reco::DQMStore DQMStore
MonitorElement * hpt_eta_tkAllRefMatched_
MonitorElement * hphi_z_tkAllRefMatched_
MonitorElement * hChi2VsPhi_
MonitorElement * hDeltaNLooseAndAboveTracks_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
#define DEFINE_FWK_MODULE(type)
MonitorElement * htipdiffMatched_
MonitorElement * hzdiffMatched_
MonitorElement * hnHitsVsPhi_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
MonitorElement * hnTracks_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static const GlobalPoint notFound(0, 0, 0)
MonitorElement * hnHitsVsEta_
const pixelTrack::Quality minQuality_
MonitorElement * hnLooseAndAboveTracks_
MonitorElement * hChi2VsEta_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
MonitorElement * hCharge_
MonitorElement * hCurvdiffMatched_
MonitorElement * hCurvature_
MonitorElement * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
~SiPixelCompareTrackSoA() override=default
const edm::EDGetTokenT< PixelTrackSoA > tokenSoATrackCPU_
MonitorElement * hnLayers_
MonitorElement * hphidiffMatched_
MonitorElement * hquality_