15 #include <fmt/printf.h> 38 void setBinLog(TAxis* axis) {
39 int bins = axis->GetNbins();
40 float from = axis->GetXmin();
41 float to = axis->GetXmax();
43 std::vector<float> new_bins(
bins + 1, 0);
44 for (
int i = 0;
i <=
bins;
i++) {
45 new_bins[
i] = TMath::Power(10, from +
i *
width);
47 axis->Set(
bins, new_bins.data());
50 void setBinLogX(TH1*
h) {
51 TAxis* axis =
h->GetXaxis();
54 void setBinLogY(TH1*
h) {
55 TAxis* axis =
h->GetYaxis();
59 template <
typename... Args>
61 auto h = std::make_unique<TH2I>(std::forward<Args>(
args)...);
66 const auto&
name =
h->GetName();
67 return ibook.book2I(
name,
h.release());
83 template <
typename U,
typename V>
138 template <
typename T>
142 topFolderName_(iConfig.getParameter<
std::
string>(
"topFolderName")),
143 useQualityCut_(iConfig.getParameter<
bool>(
"useQualityCut")),
145 dr2cut_(iConfig.getParameter<double>(
"deltaR2cut")) {}
147 template <
typename T>
148 template <
typename U,
typename V>
152 const auto& tsoaHandleRef =
iEvent.getHandle(tokenRef);
153 const auto& tsoaHandleTar =
iEvent.getHandle(tokenTar);
155 if (not tsoaHandleRef
or not tsoaHandleTar) {
157 if (not tsoaHandleRef) {
158 out <<
"reference tracks not found; ";
160 if (not tsoaHandleTar) {
161 out <<
"target tracks not found; ";
163 out <<
"the comparison will not run.";
167 auto const& tsoaRef = *tsoaHandleRef;
168 auto const& tsoaTar = *tsoaHandleTar;
170 auto maxTracksRef = tsoaRef.view().metadata().size();
171 auto maxTracksTar = tsoaTar.view().metadata().size();
173 auto const* qualityRef = tsoaRef.view().quality();
174 auto const* qualityTar = tsoaTar.view().quality();
176 int32_t nTracksRef = 0;
177 int32_t nTracksTar = 0;
178 int32_t nLooseAndAboveTracksRef = 0;
179 int32_t nLooseAndAboveTracksRef_matchedTar = 0;
180 int32_t nLooseAndAboveTracksTar = 0;
183 std::vector<int32_t> looseTrkidxTar;
184 for (int32_t jt = 0; jt < maxTracksTar; ++jt) {
187 if (!(tsoaTar.view()[jt].pt() > 0.))
190 if (useQualityCut_ && qualityTar[jt] < minQuality_)
192 nLooseAndAboveTracksTar++;
193 looseTrkidxTar.emplace_back(jt);
197 for (int32_t
it = 0;
it < maxTracksRef; ++
it) {
203 float ptRef = tsoaRef.view()[
it].pt();
204 float etaRef = tsoaRef.view()[
it].eta();
213 if (useQualityCut_ && qualityRef[
it] < minQuality_)
215 nLooseAndAboveTracksRef++;
219 float mindr2 = dr2cut_;
221 for (
auto gid : looseTrkidxTar) {
222 float etaTar = tsoaTar.view()[gid].
eta();
223 float phiTar =
reco::phi(tsoaTar.view(), gid);
233 hpt_eta_tkAllRef_->Fill(etaRef, ptRef);
234 hphi_z_tkAllRef_->Fill(phiRef, zipRef);
237 nLooseAndAboveTracksRef_matchedTar++;
239 hchi2_->Fill(tsoaRef.view()[
it].chi2(), tsoaTar.view()[closestTkidx].chi2());
240 hCharge_->Fill(qRef,
reco::charge(tsoaTar.view(), closestTkidx));
242 hnLayers_->Fill(tsoaRef.view()[
it].nLayers(), tsoaTar.view()[closestTkidx].nLayers());
243 hpt_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt());
244 hCurvature_->Fill(qRef / ptRef,
reco::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt());
245 hptLogLog_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt());
246 heta_->Fill(etaRef, tsoaTar.view()[closestTkidx].eta());
247 hphi_->Fill(phiRef,
reco::phi(tsoaTar.view(), closestTkidx));
248 hz_->Fill(zipRef,
reco::zip(tsoaTar.view(), closestTkidx));
249 htip_->Fill(tipRef,
reco::tip(tsoaTar.view(), closestTkidx));
250 hptdiffMatched_->Fill(ptRef - tsoaTar.view()[closestTkidx].pt());
251 hCurvdiffMatched_->Fill(qRef / ptRef -
252 (
reco::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt()));
253 hetadiffMatched_->Fill(etaRef - tsoaTar.view()[closestTkidx].eta());
255 hzdiffMatched_->Fill(zipRef -
reco::zip(tsoaTar.view(), closestTkidx));
256 htipdiffMatched_->Fill(tipRef -
reco::tip(tsoaTar.view(), closestTkidx));
257 hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[
it].pt());
258 hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef);
262 auto fillHistogram = [](
auto& histogram,
auto xValue,
auto yValue) { histogram->Fill(xValue, yValue); };
265 auto fillDeltaHistogram = [](
auto& histogram,
int cpuValue,
int gpuValue) {
266 histogram->Fill(
std::min(cpuValue, 1000), std::clamp(gpuValue - cpuValue, -100, 100));
270 fillHistogram(hnTracks_, nTracksRef, nTracksTar);
271 fillHistogram(hnLooseAndAboveTracks_, nLooseAndAboveTracksRef, nLooseAndAboveTracksTar);
272 fillHistogram(hnLooseAndAboveTracks_matched_, nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar);
274 fillDeltaHistogram(hDeltaNTracks_, nTracksRef, nTracksTar);
275 fillDeltaHistogram(hDeltaNLooseAndAboveTracks_, nLooseAndAboveTracksRef, nLooseAndAboveTracksTar);
276 fillDeltaHistogram(hDeltaNLooseAndAboveTracks_matched_, nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar);
282 template <
typename T>
286 analyzeSeparate(tokenSoATrackReference_, tokenSoATrackTarget_,
iEvent);
292 template <
typename T>
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);
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);
338 toRep =
"Number of all RecHits per track (quality #geq loose)";
339 hnHits_ = iBook.
book2I(
"nRecHits", fmt::sprintf(
"%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
341 toRep =
"Number of all layers per track (quality #geq loose)";
342 hnLayers_ = iBook.
book2I(
"nLayers", fmt::sprintf(
"%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
344 toRep =
"Track (quality #geq loose) #chi^{2}/ndof";
345 hchi2_ = iBook.
book2I(
"nChi2ndof", fmt::sprintf(
"%s;Reference;Target",toRep), 40, 0., 20., 40, 0., 20.);
347 toRep =
"Track (quality #geq loose) charge";
348 hCharge_ = iBook.
book2I(
"charge",fmt::sprintf(
"%s;Reference;Target",toRep),3, -1.5, 1.5, 3, -1.5, 1.5);
350 hpt_ = iBook.
book2I(
"pt",
"Track (quality #geq loose) p_{T} [GeV];Reference;Target", 200, 0., 200., 200, 0., 200.);
351 hCurvature_ = iBook.
book2I(
"curvature",
"Track (quality #geq loose) q/p_{T} [GeV^{-1}];Reference;Target", 60,- 3., 3., 60, -3., 3. );
352 hptLogLog_ = make2DIfLog(iBook,
true,
true,
"ptLogLog",
"Track (quality #geq loose) p_{T} [GeV];Reference;Target", 200, log10(0.5), log10(200.), 200, log10(0.5), log10(200.));
353 heta_ = iBook.
book2I(
"eta",
"Track (quality #geq loose) #eta;Reference;Target", 30, -3., 3., 30, -3., 3.);
354 hphi_ = iBook.
book2I(
"phi",
"Track (quality #geq loose) #phi;Reference;Target", 30, -
M_PI,
M_PI, 30, -
M_PI,
M_PI);
355 hz_ = iBook.
book2I(
"z",
"Track (quality #geq loose) z [cm];Reference;Target", 30, -30., 30., 30, -30., 30.);
356 htip_ = iBook.
book2I(
"tip",
"Track (quality #geq loose) TIP [cm];Reference;Target", 100, -0.5, 0.5, 100, -0.5, 0.5);
359 hptdiffMatched_ = iBook.
book1D(
"ptdiffmatched",
" p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 61, -30.5, 30.5);
360 hCurvdiffMatched_ = iBook.
book1D(
"curvdiffmatched",
"q/p_{T} diff [GeV^{-1}] between matched tracks; #Delta q/p_{T} [GeV^{-1}]", 61, -3.05, 3.05);
361 hetadiffMatched_ = iBook.
book1D(
"etadiffmatched",
" #eta diff between matched tracks; #Delta #eta", 161, -0.045 ,0.045);
362 hphidiffMatched_ = iBook.
book1D(
"phidiffmatched",
" #phi diff between matched tracks; #Delta #phi", 161, -0.045 ,0.045);
363 hzdiffMatched_ = iBook.
book1D(
"zdiffmatched",
" z diff between matched tracks; #Delta z [cm]", 301, -1.55, 1.55);
364 htipdiffMatched_ = iBook.
book1D(
"tipdiffmatched",
" TIP diff between matched tracks; #Delta TIP [cm]", 301, -1.55, 1.55);
366 hpt_eta_tkAllRef_ = iBook.
book2I(
"ptetatrkAllReference",
"Track (quality #geq loose) on Reference; #eta; p_{T} [GeV];", 30, -
M_PI,
M_PI, 200, 0., 200.);
367 hpt_eta_tkAllRefMatched_ = iBook.
book2I(
"ptetatrkAllReferencematched",
"Track (quality #geq loose) on Reference matched to Target track; #eta; p_{T} [GeV];", 30, -
M_PI,
M_PI, 200, 0., 200.);
369 hphi_z_tkAllRef_ = iBook.
book2I(
"phiztrkAllReference",
"Track (quality #geq loose) on Reference; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
370 hphi_z_tkAllRefMatched_ = iBook.
book2I(
"phiztrkAllReferencematched",
"Track (quality #geq loose) on Reference; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
380 desc.add<
std::string>(
"topFolderName",
"SiPixelHeterogeneous/PixelTrackCompareDeviceVSHost");
381 desc.add<
bool>(
"useQualityCut",
true);
383 desc.add<
double>(
"deltaR2cut", 0.02 * 0.02)->setComment(
"deltaR2 cut between track on device and host");
constexpr double deltaPhi(double phi1, double phi2)
MonitorElement * hquality_
MonitorElement * hDeltaNTracks_
const bool useQualityCut_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
MonitorElement * hnLooseAndAboveTracks_
MonitorElement * hnLayersVsPhi_
MonitorElement * hptdiffMatched_
MonitorElement * hphi_z_tkAllRef_
MonitorElement * hptLogLog_
virtual void setCurrentFolder(std::string const &fullpath)
Quality qualityByName(std::string const &name)
SiPixelCompareTracks(const edm::ParameterSet &)
const edm::EDGetTokenT< PixelTrackSoA > tokenSoATrackReference_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
MonitorElement * hphi_z_tkAllRefMatched_
void analyzeSeparate(U tokenRef, V tokenTar, const edm::Event &iEvent)
MonitorElement * hnLayersVsEta_
MonitorElement * hCurvdiffMatched_
MonitorElement * hnTracks_
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float charge(ConstView const &tracks, int32_t i)
MonitorElement * hpt_eta_tkAllRefMatched_
MonitorElement * hnLooseAndAboveTracks_matched_
MonitorElement * hphidiffMatched_
dqm::reco::DQMStore DQMStore
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float tip(ConstView const &tracks, int32_t i)
MonitorElement * hpt_eta_tkAllRef_
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
MonitorElement * hnLayers_
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
MonitorElement * hCharge_
MonitorElement * hChi2VsEta_
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float phi(ConstView const &tracks, int32_t i)
MonitorElement * hnHitsVsEta_
MonitorElement * hDeltaNLooseAndAboveTracks_
#define DEFINE_FWK_MODULE(type)
MonitorElement * hDeltaNLooseAndAboveTracks_matched_
MonitorElement * hzdiffMatched_
~SiPixelCompareTracks() override=default
MonitorElement * hChi2VsPhi_
MonitorElement * hetadiffMatched_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
MonitorElement * hCurvature_
static const GlobalPoint notFound(0, 0, 0)
const pixelTrack::Quality minQuality_
MonitorElement * htipdiffMatched_
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
const std::string topFolderName_
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 * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
MonitorElement * hnHitsVsPhi_
const edm::EDGetTokenT< PixelTrackSoA > tokenSoATrackTarget_