14 #include <fmt/printf.h> 37 void setBinLog(TAxis* axis) {
38 int bins = axis->GetNbins();
39 float from = axis->GetXmin();
40 float to = axis->GetXmax();
42 std::vector<float> new_bins(
bins + 1, 0);
43 for (
int i = 0;
i <=
bins;
i++) {
44 new_bins[
i] = TMath::Power(10, from +
i *
width);
46 axis->Set(
bins, new_bins.data());
49 void setBinLogX(TH1*
h) {
50 TAxis* axis =
h->GetXaxis();
53 void setBinLogY(TH1*
h) {
54 TAxis* axis =
h->GetYaxis();
58 template <
typename... Args>
60 auto h = std::make_unique<TH2I>(std::forward<Args>(
args)...);
65 const auto&
name =
h->GetName();
66 return ibook.book2I(
name,
h.release());
82 template <
typename U,
typename V>
133 template <
typename T>
137 topFolderName_(iConfig.getParameter<
std::
string>(
"topFolderName")),
138 useQualityCut_(iConfig.getParameter<
bool>(
"useQualityCut")),
140 dr2cut_(iConfig.getParameter<double>(
"deltaR2cut")) {}
142 template <
typename T>
143 template <
typename U,
typename V>
147 const auto& tsoaHandleRef =
iEvent.getHandle(tokenRef);
148 const auto& tsoaHandleTar =
iEvent.getHandle(tokenTar);
150 if (not tsoaHandleRef
or not tsoaHandleTar) {
152 if (not tsoaHandleRef) {
153 out <<
"reference tracks not found; ";
155 if (not tsoaHandleTar) {
156 out <<
"target tracks not found; ";
158 out <<
"the comparison will not run.";
162 auto const& tsoaRef = *tsoaHandleRef;
163 auto const& tsoaTar = *tsoaHandleTar;
165 auto maxTracksRef = tsoaRef.view().metadata().size();
166 auto maxTracksTar = tsoaTar.view().metadata().size();
168 auto const* qualityRef = tsoaRef.view().quality();
169 auto const* qualityTar = tsoaTar.view().quality();
171 int32_t nTracksRef = 0;
172 int32_t nTracksTar = 0;
173 int32_t nLooseAndAboveTracksRef = 0;
174 int32_t nLooseAndAboveTracksRef_matchedTar = 0;
175 int32_t nLooseAndAboveTracksTar = 0;
178 std::vector<int32_t> looseTrkidxTar;
179 for (int32_t jt = 0; jt < maxTracksTar; ++jt) {
182 if (!(tsoaTar.view()[jt].pt() > 0.))
185 if (useQualityCut_ && qualityTar[jt] < minQuality_)
187 nLooseAndAboveTracksTar++;
188 looseTrkidxTar.emplace_back(jt);
192 for (int32_t
it = 0;
it < maxTracksRef; ++
it) {
198 float ptRef = tsoaRef.view()[
it].pt();
199 float etaRef = tsoaRef.view()[
it].eta();
207 if (useQualityCut_ && qualityRef[
it] < minQuality_)
209 nLooseAndAboveTracksRef++;
213 float mindr2 = dr2cut_;
215 for (
auto gid : looseTrkidxTar) {
216 float etaTar = tsoaTar.view()[gid].
eta();
217 float phiTar =
reco::phi(tsoaTar.view(), gid);
227 hpt_eta_tkAllRef_->Fill(etaRef, ptRef);
228 hphi_z_tkAllRef_->Fill(phiRef, zipRef);
231 nLooseAndAboveTracksRef_matchedTar++;
233 hchi2_->Fill(tsoaRef.view()[
it].chi2(), tsoaTar.view()[closestTkidx].chi2());
236 hnLayers_->Fill(tsoaRef.view()[
it].nLayers(), tsoaTar.view()[closestTkidx].nLayers());
237 hpt_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt());
238 hptLogLog_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt());
239 heta_->Fill(etaRef, tsoaTar.view()[closestTkidx].eta());
240 hphi_->Fill(phiRef,
reco::phi(tsoaTar.view(), closestTkidx));
241 hz_->Fill(zipRef,
reco::zip(tsoaTar.view(), closestTkidx));
242 htip_->Fill(tipRef,
reco::tip(tsoaTar.view(), closestTkidx));
243 hptdiffMatched_->Fill(ptRef - tsoaTar.view()[closestTkidx].pt());
244 hCurvdiffMatched_->Fill((
reco::charge(tsoaRef.view(),
it) / tsoaRef.view()[
it].pt()) -
245 (
reco::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt()));
246 hetadiffMatched_->Fill(etaRef - tsoaTar.view()[closestTkidx].eta());
248 hzdiffMatched_->Fill(zipRef -
reco::zip(tsoaTar.view(), closestTkidx));
249 htipdiffMatched_->Fill(tipRef -
reco::tip(tsoaTar.view(), closestTkidx));
250 hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[
it].pt());
251 hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef);
253 hnTracks_->Fill(nTracksRef, nTracksTar);
254 hnLooseAndAboveTracks_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksTar);
255 hnLooseAndAboveTracks_matched_->Fill(nLooseAndAboveTracksRef, nLooseAndAboveTracksRef_matchedTar);
261 template <
typename T>
265 analyzeSeparate(tokenSoATrackReference_, tokenSoATrackTarget_,
iEvent);
271 template <
typename T>
282 hnTracks_ = iBook.
book2I(
"nTracks", fmt::sprintf(
"%s per event; Reference; Target",toRep), 501, -0.5, 500.5, 501, -0.5, 500.5);
283 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);
284 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);
286 toRep =
"Number of all RecHits per track (quality #geq loose)";
287 hnHits_ = iBook.
book2I(
"nRecHits", fmt::sprintf(
"%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
289 toRep =
"Number of all layers per track (quality #geq loose)";
290 hnLayers_ = iBook.
book2I(
"nLayers", fmt::sprintf(
"%s;Reference;Target",toRep), 15, -0.5, 14.5, 15, -0.5, 14.5);
292 toRep =
"Track (quality #geq loose) #chi^{2}/ndof";
293 hchi2_ = iBook.
book2I(
"nChi2ndof", fmt::sprintf(
"%s;Reference;Target",toRep), 40, 0., 20., 40, 0., 20.);
295 toRep =
"Track (quality #geq loose) charge";
296 hCharge_ = iBook.
book2I(
"charge",fmt::sprintf(
"%s;Reference;Target",toRep),3, -1.5, 1.5, 3, -1.5, 1.5);
298 hpt_ = iBook.
book2I(
"pt",
"Track (quality #geq loose) p_{T} [GeV];Reference;Target", 200, 0., 200., 200, 0., 200.);
299 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.));
300 heta_ = iBook.
book2I(
"eta",
"Track (quality #geq loose) #eta;Reference;Target", 30, -3., 3., 30, -3., 3.);
301 hphi_ = iBook.
book2I(
"phi",
"Track (quality #geq loose) #phi;Reference;Target", 30, -
M_PI,
M_PI, 30, -
M_PI,
M_PI);
302 hz_ = iBook.
book2I(
"z",
"Track (quality #geq loose) z [cm];Reference;Target", 30, -30., 30., 30, -30., 30.);
303 htip_ = iBook.
book2I(
"tip",
"Track (quality #geq loose) TIP [cm];Reference;Target", 100, -0.5, 0.5, 100, -0.5, 0.5);
305 hptdiffMatched_ = iBook.
book1D(
"ptdiffmatched",
" p_{T} diff [GeV] between matched tracks; #Delta p_{T} [GeV]", 60, -30., 30.);
306 hCurvdiffMatched_ = iBook.
book1D(
"curvdiffmatched",
"q/p_{T} diff [GeV] between matched tracks; #Delta q/p_{T} [GeV]", 60, -30., 30.);
307 hetadiffMatched_ = iBook.
book1D(
"etadiffmatched",
" #eta diff between matched tracks; #Delta #eta", 160, -0.04 ,0.04);
308 hphidiffMatched_ = iBook.
book1D(
"phidiffmatched",
" #phi diff between matched tracks; #Delta #phi", 160, -0.04 ,0.04);
309 hzdiffMatched_ = iBook.
book1D(
"zdiffmatched",
" z diff between matched tracks; #Delta z [cm]", 300, -1.5, 1.5);
310 htipdiffMatched_ = iBook.
book1D(
"tipdiffmatched",
" TIP diff between matched tracks; #Delta TIP [cm]", 300, -1.5, 1.5);
312 hpt_eta_tkAllRef_ = iBook.
book2I(
"ptetatrkAllReference",
"Track (quality #geq loose) on Reference; #eta; p_{T} [GeV];", 30, -
M_PI,
M_PI, 200, 0., 200.);
313 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.);
315 hphi_z_tkAllRef_ = iBook.
book2I(
"phiztrkAllReference",
"Track (quality #geq loose) on Reference; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
316 hphi_z_tkAllRefMatched_ = iBook.
book2I(
"phiztrkAllReferencematched",
"Track (quality #geq loose) on Reference; #phi; z [cm];", 30, -
M_PI,
M_PI, 30, -30., 30.);
326 desc.add<
std::string>(
"topFolderName",
"SiPixelHeterogeneous/PixelTrackCompareDeviceVSHost");
327 desc.add<
bool>(
"useQualityCut",
true);
329 desc.add<
double>(
"deltaR2cut", 0.04);
constexpr double deltaPhi(double phi1, double phi2)
MonitorElement * hquality_
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_
#define DEFINE_FWK_MODULE(type)
MonitorElement * hzdiffMatched_
~SiPixelCompareTracks() override=default
MonitorElement * hChi2VsPhi_
MonitorElement * hetadiffMatched_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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_