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());
123 template <
typename T>
127 topFolderName_(iConfig.getParameter<
std::
string>(
"topFolderName")),
128 useQualityCut_(iConfig.getParameter<
bool>(
"useQualityCut")),
130 dr2cut_(iConfig.getParameter<double>(
"deltaR2cut")) {}
135 template <
typename T>
138 const auto& tsoaHandleCPU =
iEvent.getHandle(tokenSoATrackCPU_);
139 const auto& tsoaHandleGPU =
iEvent.getHandle(tokenSoATrackGPU_);
140 if (not tsoaHandleCPU
or not tsoaHandleGPU) {
142 if (not tsoaHandleCPU) {
143 out <<
"reference (cpu) tracks not found; ";
145 if (not tsoaHandleGPU) {
146 out <<
"target (gpu) tracks not found; ";
148 out <<
"the comparison will not run.";
152 auto const& tsoaCPU = *tsoaHandleCPU;
153 auto const& tsoaGPU = *tsoaHandleGPU;
154 auto maxTracksCPU = tsoaCPU.view().metadata().size();
155 auto maxTracksGPU = tsoaGPU.view().metadata().size();
156 auto const* qualityCPU = tsoaCPU.view().quality();
157 auto const* qualityGPU = tsoaGPU.view().quality();
158 int32_t nTracksCPU = 0;
159 int32_t nTracksGPU = 0;
160 int32_t nLooseAndAboveTracksCPU = 0;
161 int32_t nLooseAndAboveTracksCPU_matchedGPU = 0;
162 int32_t nLooseAndAboveTracksGPU = 0;
165 std::vector<int32_t> looseTrkidxGPU;
166 for (int32_t jt = 0; jt < maxTracksGPU; ++jt) {
169 if (!(tsoaGPU.view()[jt].pt() > 0.))
172 if (useQualityCut_ && qualityGPU[jt] < minQuality_)
174 nLooseAndAboveTracksGPU++;
175 looseTrkidxGPU.emplace_back(jt);
179 for (int32_t it = 0; it < maxTracksCPU; ++it) {
185 float ptCPU = tsoaCPU.view()[it].pt();
186 float etaCPU = tsoaCPU.view()[it].eta();
187 float phiCPU = helper::phi(tsoaCPU.view(), it);
194 if (useQualityCut_ && qualityCPU[it] < minQuality_)
196 nLooseAndAboveTracksCPU++;
200 float mindr2 = dr2cut_;
202 for (
auto gid : looseTrkidxGPU) {
203 float etaGPU = tsoaGPU.view()[gid].
eta();
204 float phiGPU = helper::phi(tsoaGPU.view(), gid);
214 hpt_eta_tkAllCPU_->Fill(etaCPU, ptCPU);
215 hphi_z_tkAllCPU_->Fill(phiCPU, zipCPU);
218 nLooseAndAboveTracksCPU_matchedGPU++;
220 hchi2_->Fill(tsoaCPU.view()[it].chi2(), tsoaGPU.view()[closestTkidx].chi2());
223 hnLayers_->Fill(tsoaCPU.view()[it].nLayers(), tsoaGPU.view()[closestTkidx].nLayers());
224 hpt_->Fill(ptCPU, tsoaGPU.view()[closestTkidx].pt());
225 hptLogLog_->Fill(ptCPU, tsoaGPU.view()[closestTkidx].pt());
226 heta_->Fill(etaCPU, tsoaGPU.view()[closestTkidx].eta());
227 hphi_->Fill(phiCPU, helper::phi(tsoaGPU.view(), closestTkidx));
228 hz_->Fill(zipCPU,
helper::zip(tsoaGPU.view(), closestTkidx));
229 htip_->Fill(tipCPU,
helper::tip(tsoaGPU.view(), closestTkidx));
230 hptdiffMatched_->Fill(ptCPU - tsoaGPU.view()[closestTkidx].pt());
231 hCurvdiffMatched_->Fill((
helper::charge(tsoaCPU.view(), it) / tsoaCPU.view()[it].pt()) -
232 (
helper::charge(tsoaGPU.view(), closestTkidx) / tsoaGPU.view()[closestTkidx].pt()));
233 hetadiffMatched_->Fill(etaCPU - tsoaGPU.view()[closestTkidx].eta());
234 hphidiffMatched_->Fill(
reco::deltaPhi(phiCPU, helper::phi(tsoaGPU.view(), closestTkidx)));
235 hzdiffMatched_->Fill(zipCPU -
helper::zip(tsoaGPU.view(), closestTkidx));
236 htipdiffMatched_->Fill(tipCPU -
helper::tip(tsoaGPU.view(), closestTkidx));
237 hpt_eta_tkAllCPUMatched_->Fill(etaCPU, tsoaCPU.view()[it].pt());
238 hphi_z_tkAllCPUMatched_->Fill(etaCPU, zipCPU);
240 hnTracks_->Fill(nTracksCPU, nTracksGPU);
241 hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksGPU);
242 hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksCPU, nLooseAndAboveTracksCPU_matchedGPU);
248 template <
typename T>
259 hnTracks_ = iBook.
book2I(
"nTracks", fmt::sprintf(
"%s per event; CPU; GPU",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
260 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);
261 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);
263 toRep =
"Number of all RecHits per track (quality #geq loose)";
264 hnHits_ = iBook.
book2I(
"nRecHits", fmt::sprintf(
"%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
266 toRep =
"Number of all layers per track (quality #geq loose)";
267 hnLayers_ = iBook.
book2I(
"nLayers", fmt::sprintf(
"%s;CPU;GPU",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
269 toRep =
"Track (quality #geq loose) #chi^{2}/ndof";
270 hchi2_ = iBook.
book2I(
"nChi2ndof", fmt::sprintf(
"%s;CPU;GPU",toRep), 40, 0., 20., 40, 0., 20.);
272 toRep =
"Track (quality #geq loose) charge";
273 hCharge_ = iBook.
book2I(
"charge",fmt::sprintf(
"%s;CPU;GPU",toRep),3, -1.5, 1.5, 3, -1.5, 1.5);
275 hpt_ = iBook.
book2I(
"pt",
"Track (quality #geq loose) p_{T} [GeV];CPU;GPU", 200, 0., 200., 200, 0., 200.);
276 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.));
277 heta_ = iBook.
book2I(
"eta",
"Track (quality #geq loose) #eta;CPU;GPU", 30, -3., 3., 30, -3., 3.);
279 hz_ = iBook.
book2I(
"z",
"Track (quality #geq loose) z [cm];CPU;GPU", 30, -30., 30., 30, -30., 30.);
280 htip_ = iBook.
book2I(
"tip",
"Track (quality #geq loose) TIP [cm];CPU;GPU", 100, -0.5, 0.5, 100, -0.5, 0.5);
282 hptdiffMatched_ = iBook.
book1D(
"ptdiffmatched",
" p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 60, -30., 30.);
283 hCurvdiffMatched_ = iBook.
book1D(
"curvdiffmatched",
"q/p_{T} diff [GeV] between matched tracks; #Delta q/p_{T} [GeV]", 60, -30., 30.);
284 hetadiffMatched_ = iBook.
book1D(
"etadiffmatched",
" #eta diff between matched tracks; #Delta #eta", 160, -0.04 ,0.04);
285 hphidiffMatched_ = iBook.
book1D(
"phidiffmatched",
" #phi diff between matched tracks; #Delta #phi", 160, -0.04 ,0.04);
286 hzdiffMatched_ = iBook.
book1D(
"zdiffmatched",
" z diff between matched tracks; #Delta z [cm]", 300, -1.5, 1.5);
287 htipdiffMatched_ = iBook.
book1D(
"tipdiffmatched",
" TIP diff between matched tracks; #Delta TIP [cm]", 300, -1.5, 1.5);
289 hpt_eta_tkAllCPU_ = iBook.
book2I(
"ptetatrkAllCPU",
"Track (quality #geq loose) on CPU; #eta; p_{T} [GeV];", 30, -
M_PI,
M_PI, 200, 0., 200.);
290 hpt_eta_tkAllCPUMatched_ = iBook.
book2I(
"ptetatrkAllCPUmatched",
"Track (quality #geq loose) on CPU matched to GPU track; #eta; p_{T} [GeV];", 30, -
M_PI,
M_PI, 200, 0., 200.);
292 hphi_z_tkAllCPU_ = iBook.
book2I(
"phiztrkAllCPU",
"Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
293 hphi_z_tkAllCPUMatched_ = iBook.
book2I(
"phiztrkAllCPUmatched",
"Track (quality #geq loose) on CPU; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
303 desc.add<
std::string>(
"topFolderName",
"SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU");
304 desc.add<
bool>(
"useQualityCut",
true);
306 desc.add<
double>(
"deltaR2cut", 0.04);
constexpr double deltaPhi(double phi1, double phi2)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
MonitorElement * hetadiffMatched_
const bool useQualityCut_
MonitorElement * hphi_z_tkAllCPUMatched_
SiPixelCompareTrackSoA(const edm::ParameterSet &)
virtual void setCurrentFolder(std::string const &fullpath)
Quality qualityByName(std::string const &name)
MonitorElement * hnLayersVsPhi_
const edm::EDGetTokenT< PixelTrackSoA > tokenSoATrackGPU_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
MonitorElement * hptdiffMatched_
const std::string topFolderName_
MonitorElement * hnLayersVsEta_
MonitorElement * hptLogLog_
MonitorElement * hnLooseAndAboveTracks_matched_
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
dqm::reco::DQMStore DQMStore
MonitorElement * hpt_eta_tkAllCPU_
MonitorElement * hChi2VsPhi_
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
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 * hphi_z_tkAllCPU_
MonitorElement * hzdiffMatched_
MonitorElement * hnHitsVsPhi_
MonitorElement * hpt_eta_tkAllCPUMatched_
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 * 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_