From f8ea5ed622b9dc84c13d924fc99074dd7a94f3c8 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Thu, 5 Nov 2026 21:19:17 -0600 Subject: [PATCH 1/4] Validation histograms for new track/CRV association objects. --- Validation/CMakeLists.txt | 3 + Validation/inc/ValTrkCrvMatch.hh | 57 ++++++++++++++ Validation/inc/ValTrkCrvMatchMC.hh | 43 +++++++++++ Validation/src/SConscript | 2 + Validation/src/ValTrkCrvMatch.cc | 115 ++++++++++++++++++++++++++++ Validation/src/ValTrkCrvMatchMC.cc | 69 +++++++++++++++++ Validation/src/Validation_module.cc | 6 ++ 7 files changed, 295 insertions(+) create mode 100644 Validation/inc/ValTrkCrvMatch.hh create mode 100644 Validation/inc/ValTrkCrvMatchMC.hh create mode 100644 Validation/src/ValTrkCrvMatch.cc create mode 100644 Validation/src/ValTrkCrvMatchMC.cc diff --git a/Validation/CMakeLists.txt b/Validation/CMakeLists.txt index d53ed0fd1d..54f0e7cc1d 100644 --- a/Validation/CMakeLists.txt +++ b/Validation/CMakeLists.txt @@ -34,8 +34,11 @@ cet_make_library( src/ValTimeCluster.cc src/ValTriggerInfo.cc src/ValTriggerResults.cc + src/ValTrkCrvMatch.cc + src/ValTrkCrvMatchMC.cc LIBRARIES PUBLIC + Offline::CosmicRayShieldGeom Offline::DataProducts Offline::GeometryService Offline::KinKalGeom diff --git a/Validation/inc/ValTrkCrvMatch.hh b/Validation/inc/ValTrkCrvMatch.hh new file mode 100644 index 0000000000..26e03d4c09 --- /dev/null +++ b/Validation/inc/ValTrkCrvMatch.hh @@ -0,0 +1,57 @@ +#ifndef ValTrkCrvMatch_HH_ +#define ValTrkCrvMatch_HH_ + +#include "Offline/RecoDataProducts/inc/TrkCrvMatch.hh" +#include "KinKal/General/Vectors.hh" +#include "art/Framework/Principal/Event.h" +#include "art_root_io/TFileDirectory.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include +#include + +namespace mu2e { + +// track-CRV association: candidate counts, residuals and chi2 per CRV shield, dv against slope (alignment monitor), +// predicted vs matched shield, layer probe +class ValTrkCrvMatch { + public: + ValTrkCrvMatch(std::string name) : _name(name) {} + int declare(const art::TFileDirectory& tfs); + int fill(const TrkCrvMatchCollection& coll, art::Event const& event); + std::string& name() { return _name; } + + private: + std::string _name; + std::vector _v, _w; // per shield: across-bar direction and normal, detector frame + + TH1D* _hVer; + TH1D* _hNTrk; + TH1D* _hNCand; + TH1D* _hNGeom; + TH1D* _hNXing; + TH1D* _hDtRef; + TH1D* _hDtRefBest; + TH1D* _hDtRefToF; + TH1D* _hChi2; + TH1D* _hNShare; + TH1D* _hFlags; + TH1D* _hXingShield; + TH1D* _hXingGeomShield; + TH2D* _hDtXing; + TH2D* _hDu; + TH2D* _hDv; + TH2D* _hPredMatched; + std::vector _pDvSlope; + TH1D* _hProbePred; + TH1D* _hProbeHit; + TH1D* _hProbeInCluster; + TH1D* _hProbeDBar; + TH1D* _hProbeDt; + TH1D* _hProbePE; + TH1D* _hProbeDu; +}; +} // namespace mu2e + +#endif diff --git a/Validation/inc/ValTrkCrvMatchMC.hh b/Validation/inc/ValTrkCrvMatchMC.hh new file mode 100644 index 0000000000..88869b9726 --- /dev/null +++ b/Validation/inc/ValTrkCrvMatchMC.hh @@ -0,0 +1,43 @@ +#ifndef ValTrkCrvMatchMC_HH_ +#define ValTrkCrvMatchMC_HH_ + +#include "Offline/MCDataProducts/inc/TrkCrvMatchMC.hh" +#include "art/Framework/Principal/Event.h" +#include "art_root_io/TFileDirectory.h" +#include "TH1D.h" +#include "TH2D.h" +#include + +namespace mu2e { + +// track-CRV association truth: relation of the best candidates, own-cluster association and crossing truth per +// CRV shield, reco crossings against the true crossings +class ValTrkCrvMatchMC { + public: + ValTrkCrvMatchMC(std::string name) : _name(name) {} + int declare(const art::TFileDirectory& tfs); + int fill(const TrkCrvMatchMCCollection& coll, art::Event const& event); + std::string& name() { return _name; } + + private: + std::string _name; + int _ns = 0; + + TH1D* _hVer; + TH1D* _hBestGeomRel; + TH1D* _hBestTimeRel; + TH1D* _hGeomCandRel; + TH1D* _hTimeCandRel; + TH1D* _hTrueClu; + TH1D* _hTrueCluGeom; + TH1D* _hTrueCluBest; + TH1D* _hRecoXing; + TH1D* _hRecoXingTrue; + TH1D* _hTrueXing; + TH1D* _hTrueXingFound; + TH2D* _hXingDist; + TH2D* _hXingDt; +}; +} // namespace mu2e + +#endif diff --git a/Validation/src/SConscript b/Validation/src/SConscript index d54dac2617..bd3deb3995 100644 --- a/Validation/src/SConscript +++ b/Validation/src/SConscript @@ -22,6 +22,7 @@ mainlib = helper.make_mainlib ( [ 'mu2e_Validation_root', 'mu2e_GlobalConstantsService', 'mu2e_GeneralUtilities', 'mu2e_KinKalGeom', + 'mu2e_CosmicRayShieldGeom', 'art_Framework_Core', 'art_Framework_Principal', 'art_Framework_Services_Registry', @@ -48,6 +49,7 @@ helper.make_plugins( [ mainlib,'mu2e_Validation_root', 'mu2e_RecoDataProducts', 'mu2e_DataProducts', 'mu2e_KinKalGeom', + 'mu2e_CosmicRayShieldGeom', 'art_Framework_Core', 'art_Framework_Principal', 'art_Framework_Services_Registry', diff --git a/Validation/src/ValTrkCrvMatch.cc b/Validation/src/ValTrkCrvMatch.cc new file mode 100644 index 0000000000..cd658d71e4 --- /dev/null +++ b/Validation/src/ValTrkCrvMatch.cc @@ -0,0 +1,115 @@ +#include "Offline/Validation/inc/ValTrkCrvMatch.hh" +#include "Offline/CosmicRayShieldGeom/inc/CosmicRayShield.hh" +#include "Offline/GeometryService/inc/GeomHandle.hh" +#include "Offline/KinKalGeom/inc/KinKalGeom.hh" +#include +#include + +int mu2e::ValTrkCrvMatch::declare(const art::TFileDirectory& tfs) { + GeomHandle crs; + GeomHandle kkg; + auto const& shields = crs->getCRSScintillatorShields(); + int ns = static_cast(shields.size()); + _v.assign(ns, KinKal::VEC3()); + _w.assign(ns, KinKal::VEC3()); + std::map nameToShield; + for (int i = 0; i < ns; ++i) nameToShield[shields[i].getName()] = i; + for (auto const& sec : kkg->CRV()->sectors()) { + auto it = nameToShield.find(sec.sname_); + if (it == nameToShield.end()) continue; + _v[it->second] = sec.sector_->vDirection(); + _w[it->second] = sec.sector_->normal(); + } + + _hVer = tfs.make("Ver", "Version Number", 101, -0.5, 100.0); + _hNTrk = tfs.make("NTrk", "N tracks", 21, -0.5, 20.5); + _hNCand = tfs.make("NCand", "N candidates per track", 51, -0.5, 50.5); + _hNGeom = tfs.make("NGeom", "N geometric candidates per track", 21, -0.5, 20.5); + _hNXing = tfs.make("NXing", "N CRV crossings per track", 11, -0.5, 10.5); + _hDtRef = tfs.make("dtRef", "t_{trk}(ref) - t_{cluster}, all candidates;ns", 200, -1000., 1000.); + _hDtRefBest = tfs.make("dtRefBest", "t_{trk}(ref) - t_{cluster}, best candidate;ns", 200, -400., 400.); + _hDtRefToF = tfs.make("dtRefToF", "dtRef - flight time, best candidate;ns", 200, -400., 400.); + _hChi2 = tfs.make("chi2ndof", "#chi^{2}/ndof, best in sector", 100, 0., 20.); + _hNShare = tfs.make("NShare", "tracks sharing the cluster", 11, -0.5, 10.5); + _hFlags = tfs.make("Flags", "candidate flag bits", 16, -0.5, 15.5); + _hXingShield = tfs.make("XingShield", "CRV crossings per shield", ns, -0.5, ns - 0.5); + _hXingGeomShield = tfs.make("XingGeomShield", "crossings with a geometric candidate in their shield", ns, -0.5, ns - 0.5); + _hDtXing = tfs.make("dtXing", "t_{cluster} - t_{trk} at the plane, best in sector;shield;ns", ns, -0.5, ns - 0.5, 100, -100., 100.); + _hDu = tfs.make("du", "cluster - track along the bars, best in sector;shield;mm", ns, -0.5, ns - 0.5, 100, -3000., 3000.); + _hDv = tfs.make("dv", "cluster - track across the bars, best in sector;shield;mm", ns, -0.5, ns - 0.5, 100, -500., 500.); + _hPredMatched = tfs.make("PredMatched", "best geometric candidate;reference crossing shield;cluster shield", ns, -0.5, ns - 0.5, ns, -0.5, ns - 0.5); + _pDvSlope.clear(); + for (int i = 0; i < ns; ++i) { + std::string n = shields[i].getName(); + _pDvSlope.push_back(tfs.make(("dvVsSlope_" + n).c_str(), ("dv vs across-bar slope, " + n + ";slope;dv [mm]").c_str(), 40, -2., 2.)); + } + _hProbePred = tfs.make("ProbePred", "layer probe: predicted bar per layer", 6, -0.5, 5.5); + _hProbeHit = tfs.make("ProbeHit", "layer probe: pulse found per layer", 6, -0.5, 5.5); + _hProbeInCluster = tfs.make("ProbeInCluster", "layer probe: pulse in a cluster per layer", 6, -0.5, 5.5); + _hProbeDBar = tfs.make("ProbeDBar", "layer probe: selected - predicted bar", 21, -10.5, 10.5); + _hProbeDt = tfs.make("ProbeDt", "layer probe: pulse - predicted time;ns", 100, -60., 60.); + _hProbePE = tfs.make("ProbePE", "layer probe: PEs", 100, 0., 200.); + _hProbeDu = tfs.make("ProbeDu", "layer probe: two-end position - predicted;mm", 100, -1500., 1500.); + return 0; +} + +int mu2e::ValTrkCrvMatch::fill(const mu2e::TrkCrvMatchCollection& coll, art::Event const& event) { + // increment this by 1 any time the definitions of the histograms or the + // histogram contents change, and will not match previous versions + _hVer->Fill(1.0); + + int ns = static_cast(_v.size()); + auto okShield = [&](int s) { return s >= 0 && s < ns; }; + _hNTrk->Fill(coll.size()); + for (auto const& m : coll) { + _hNCand->Fill(m.cands_.size()); + _hNXing->Fill(m.xings_.size()); + int ngeom = 0; + for (auto const& c : m.cands_) { + _hDtRef->Fill(c.dtRef_); + _hNShare->Fill(c.nShare_); + for (int b = 0; b < 16; ++b) + if (c.flags_ & (1u << b)) _hFlags->Fill(b); + if (!c.hasFlag(TrkCrvCandidate::geomCand)) continue; + ++ngeom; + if (!c.hasFlag(TrkCrvCandidate::bestInSector) || !okShield(c.sector_)) continue; + if (c.ndof_ > 0) _hChi2->Fill(c.chi2_ / c.ndof_); + _hDtXing->Fill(c.sector_, c.dtXing_); + if (!c.hasFlag(TrkCrvCandidate::singleEnded)) _hDu->Fill(c.sector_, c.du_); + _hDv->Fill(c.sector_, c.dv_); + if (c.xing_ >= 0 && static_cast(c.xing_) < m.xings_.size()) { + auto const& d = m.xings_[c.xing_].dir_; + KinKal::VEC3 dir(d.X(), d.Y(), d.Z()); + double dw = dir.Dot(_w[c.sector_]); + if (std::fabs(dw) > 1e-3) _pDvSlope[c.sector_]->Fill(dir.Dot(_v[c.sector_]) / dw, c.dv_); + } + } + _hNGeom->Fill(ngeom); + int best = m.bestGeom_ >= 0 ? m.bestGeom_ : m.bestTime_; + if (best >= 0) { + _hDtRefBest->Fill(m.cands_[best].dtRef_); + _hDtRefToF->Fill(m.cands_[best].dtRefToF_); + } + if (m.bestGeom_ >= 0) { + auto const& c = m.cands_[m.bestGeom_]; + if (c.xing_ >= 0 && static_cast(c.xing_) < m.xings_.size()) _hPredMatched->Fill(m.xings_[c.xing_].sector_, c.sector_); + } + for (auto const& x : m.xings_) { + _hXingShield->Fill(x.sector_); + if (x.best_ >= 0) _hXingGeomShield->Fill(x.sector_); + for (size_t L = 0; L < x.layers_.size(); ++L) { + auto const& p = x.layers_[L]; + if (p.bar_ < 0) continue; + _hProbePred->Fill(L); + if (p.dBar_ == INT8_MAX) continue; + _hProbeHit->Fill(L); + if (p.inCluster_) _hProbeInCluster->Fill(L); + _hProbeDBar->Fill(p.dBar_); + _hProbeDt->Fill(p.dt_); + _hProbePE->Fill(p.pe_); + if (!std::isnan(p.uTdiv_)) _hProbeDu->Fill(p.uTdiv_ - p.uPred_); + } + } + } + return 0; +} diff --git a/Validation/src/ValTrkCrvMatchMC.cc b/Validation/src/ValTrkCrvMatchMC.cc new file mode 100644 index 0000000000..5832125c7c --- /dev/null +++ b/Validation/src/ValTrkCrvMatchMC.cc @@ -0,0 +1,69 @@ +#include "Offline/Validation/inc/ValTrkCrvMatchMC.hh" +#include "Offline/CosmicRayShieldGeom/inc/CosmicRayShield.hh" +#include "Offline/GeometryService/inc/GeomHandle.hh" +#include + +int mu2e::ValTrkCrvMatchMC::declare(const art::TFileDirectory& tfs) { + GeomHandle crs; + _ns = static_cast(crs->getCRSScintillatorShields().size()); + double lo = -0.5, hi = _ns - 0.5; + _hVer = tfs.make("Ver", "Version Number", 101, -0.5, 100.0); + _hBestGeomRel = tfs.make("BestGeomRel", "best geometric candidate: 0 same particle, 1 family, 2 primary, 3 unrelated, 4 bkg, 5 no MC", 6, -0.5, 5.5); + _hBestTimeRel = tfs.make("BestTimeRel", "best time candidate: relation to the track's particle", 6, -0.5, 5.5); + _hGeomCandRel = tfs.make("GeomCandRel", "all geometric candidates: relation", 6, -0.5, 5.5); + _hTimeCandRel = tfs.make("TimeCandRel", "time-only candidates: relation", 6, -0.5, 5.5); + _hTrueClu = tfs.make("TrueClu", "own cluster of the track's particle per shield", _ns, lo, hi); + _hTrueCluGeom = tfs.make("TrueCluGeom", "own cluster is a geometric candidate", _ns, lo, hi); + _hTrueCluBest = tfs.make("TrueCluBest", "own cluster is the best in its sector", _ns, lo, hi); + _hRecoXing = tfs.make("RecoXing", "reco crossings per shield", _ns, lo, hi); + _hRecoXingTrue = tfs.make("RecoXingTrue", "reco crossings with a true crossing of the same shield", _ns, lo, hi); + _hTrueXing = tfs.make("TrueXing", "true crossings of the track's particle per shield", _ns, lo, hi); + _hTrueXingFound = tfs.make("TrueXingFound", "true crossings with a reco crossing", _ns, lo, hi); + _hXingDist = tfs.make("XingDist", "|reco - true crossing|;shield;mm", _ns, lo, hi, 100, 0., 500.); + _hXingDt = tfs.make("XingDt", "reco - true crossing time;shield;ns", _ns, lo, hi, 100, -20., 20.); + return 0; +} + +int mu2e::ValTrkCrvMatchMC::fill(const mu2e::TrkCrvMatchMCCollection& coll, art::Event const& event) { + // increment this by 1 any time the definitions of the histograms or the + // histogram contents change, and will not match previous versions + _hVer->Fill(1.0); + + auto ok = [&](int s) { return s >= 0 && s < _ns; }; + for (auto const& mc : coll) { + if (mc.match_.isNull() || !mc.match_.isAvailable()) continue; + auto const& m = *mc.match_; + if (mc.cands_.size() != m.cands_.size()) continue; + if (m.bestGeom_ >= 0) _hBestGeomRel->Fill(mc.cands_[m.bestGeom_].rel_); + if (m.bestTime_ >= 0) _hBestTimeRel->Fill(mc.cands_[m.bestTime_].rel_); + for (size_t j = 0; j < m.cands_.size(); ++j) + (m.cands_[j].hasFlag(TrkCrvCandidate::geomCand) ? _hGeomCandRel : _hTimeCandRel)->Fill(mc.cands_[j].rel_); + for (auto const& xm : mc.xings_) { + if (xm.generation_ != 0 || !ok(xm.sector_)) continue; + if (xm.geom_) { + _hTrueXing->Fill(xm.sector_); + if (xm.recoXing_ >= 0) _hTrueXingFound->Fill(xm.sector_); + } + if (xm.trueCluster_ < 0) continue; + _hTrueClu->Fill(xm.sector_); + if (xm.trueCand_ < 0 || static_cast(xm.trueCand_) >= m.cands_.size()) continue; + auto const& c = m.cands_[xm.trueCand_]; + if (!c.hasFlag(TrkCrvCandidate::geomCand)) continue; + _hTrueCluGeom->Fill(xm.sector_); + if (c.hasFlag(TrkCrvCandidate::bestInSector)) _hTrueCluBest->Fill(xm.sector_); + } + for (size_t ir = 0; ir < m.xings_.size() && ir < mc.recoXingTruth_.size(); ++ir) { + auto const& rx = m.xings_[ir]; + if (!ok(rx.sector_)) continue; + _hRecoXing->Fill(rx.sector_); + int t = mc.recoXingTruth_[ir]; + if (t < 0 || static_cast(t) >= mc.xings_.size()) continue; + _hRecoXingTrue->Fill(rx.sector_); + auto const& xm = mc.xings_[t]; + if (!xm.geom_ || xm.generation_ != 0) continue; + _hXingDist->Fill(rx.sector_, std::sqrt((rx.pos_ - xm.pos_).Mag2())); + _hXingDt->Fill(rx.sector_, rx.time_ - xm.time_); + } + } + return 0; +} diff --git a/Validation/src/Validation_module.cc b/Validation/src/Validation_module.cc index 45f678791a..d8365aaa29 100644 --- a/Validation/src/Validation_module.cc +++ b/Validation/src/Validation_module.cc @@ -39,6 +39,8 @@ #include "Offline/Validation/inc/ValTimeCluster.hh" #include "Offline/Validation/inc/ValTriggerInfo.hh" #include "Offline/Validation/inc/ValTriggerResults.hh" +#include "Offline/Validation/inc/ValTrkCrvMatch.hh" +#include "Offline/Validation/inc/ValTrkCrvMatchMC.hh" #include "art/Framework/Core/EDAnalyzer.h" #include "art_root_io/TFileService.h" #include "fhiclcpp/types/Atom.h" @@ -103,6 +105,8 @@ class Validation : public art::EDAnalyzer { std::vector> _stht; std::vector> _trrs; std::vector> _tris; + std::vector> _tcrv; + std::vector> _tcmc; // Loop over the products of type T and // call fill() on validation histogram class V to make histograms. @@ -155,6 +159,8 @@ void mu2e::Validation::analyze(art::Event const& event) { analyzeProduct(_tmcl, event); analyzeProduct(_hxsd, event); analyzeProduct(_klsd, event); + analyzeProduct(_tcrv, event); + analyzeProduct(_tcmc, event); analyzeProduct(_stmw, event); analyzeProduct(_stmw, event); analyzeProduct(_trrs, event); From 133bf6207be31575078ab51840431993d8fa74fc Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Fri, 6 Nov 2026 14:43:40 -0600 Subject: [PATCH 2/4] Update val histogram for upstream Offline fixes. --- Validation/src/ValTrkCrvMatchMC.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Validation/src/ValTrkCrvMatchMC.cc b/Validation/src/ValTrkCrvMatchMC.cc index 5832125c7c..d8c737a948 100644 --- a/Validation/src/ValTrkCrvMatchMC.cc +++ b/Validation/src/ValTrkCrvMatchMC.cc @@ -8,10 +8,10 @@ int mu2e::ValTrkCrvMatchMC::declare(const art::TFileDirectory& tfs) { _ns = static_cast(crs->getCRSScintillatorShields().size()); double lo = -0.5, hi = _ns - 0.5; _hVer = tfs.make("Ver", "Version Number", 101, -0.5, 100.0); - _hBestGeomRel = tfs.make("BestGeomRel", "best geometric candidate: 0 same particle, 1 family, 2 primary, 3 unrelated, 4 bkg, 5 no MC", 6, -0.5, 5.5); - _hBestTimeRel = tfs.make("BestTimeRel", "best time candidate: relation to the track's particle", 6, -0.5, 5.5); - _hGeomCandRel = tfs.make("GeomCandRel", "all geometric candidates: relation", 6, -0.5, 5.5); - _hTimeCandRel = tfs.make("TimeCandRel", "time-only candidates: relation", 6, -0.5, 5.5); + _hBestGeomRel = tfs.make("BestGeomRel", "best geometric candidate, MCRelationship to the track's particle: 0 no MC, 1 unrelated, 2 same, 3 daughter, 4 mother, 5 sibling, 6 udaughter, 7 umother, 8 usibling", 9, -0.5, 8.5); + _hBestTimeRel = tfs.make("BestTimeRel", "best time candidate, MCRelationship to the track's particle", 9, -0.5, 8.5); + _hGeomCandRel = tfs.make("GeomCandRel", "all geometric candidates, MCRelationship", 9, -0.5, 8.5); + _hTimeCandRel = tfs.make("TimeCandRel", "time-only candidates, MCRelationship", 9, -0.5, 8.5); _hTrueClu = tfs.make("TrueClu", "own cluster of the track's particle per shield", _ns, lo, hi); _hTrueCluGeom = tfs.make("TrueCluGeom", "own cluster is a geometric candidate", _ns, lo, hi); _hTrueCluBest = tfs.make("TrueCluBest", "own cluster is the best in its sector", _ns, lo, hi); @@ -34,10 +34,11 @@ int mu2e::ValTrkCrvMatchMC::fill(const mu2e::TrkCrvMatchMCCollection& coll, art: if (mc.match_.isNull() || !mc.match_.isAvailable()) continue; auto const& m = *mc.match_; if (mc.cands_.size() != m.cands_.size()) continue; - if (m.bestGeom_ >= 0) _hBestGeomRel->Fill(mc.cands_[m.bestGeom_].rel_); - if (m.bestTime_ >= 0) _hBestTimeRel->Fill(mc.cands_[m.bestTime_].rel_); + auto relBin = [](TrkCrvCandidateMC const& cm) { return cm.hasMC_ ? cm.rel_.relationship() + 2 : 0; }; // 0 no MC, 1 none, 2 same, ... + if (m.bestGeom_ >= 0) _hBestGeomRel->Fill(relBin(mc.cands_[m.bestGeom_])); + if (m.bestTime_ >= 0) _hBestTimeRel->Fill(relBin(mc.cands_[m.bestTime_])); for (size_t j = 0; j < m.cands_.size(); ++j) - (m.cands_[j].hasFlag(TrkCrvCandidate::geomCand) ? _hGeomCandRel : _hTimeCandRel)->Fill(mc.cands_[j].rel_); + (m.cands_[j].hasFlag(TrkCrvCandidate::geomCand) ? _hGeomCandRel : _hTimeCandRel)->Fill(relBin(mc.cands_[j])); for (auto const& xm : mc.xings_) { if (xm.generation_ != 0 || !ok(xm.sector_)) continue; if (xm.geom_) { From 6b0bc14062d6405ead716bcfc453f07fb16ed3e0 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Fri, 6 Nov 2026 15:40:29 -0600 Subject: [PATCH 3/4] Validation: true crossings use MCRelationship instead of generation. --- Validation/src/ValTrkCrvMatchMC.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/src/ValTrkCrvMatchMC.cc b/Validation/src/ValTrkCrvMatchMC.cc index d8c737a948..2d1e73e41d 100644 --- a/Validation/src/ValTrkCrvMatchMC.cc +++ b/Validation/src/ValTrkCrvMatchMC.cc @@ -40,7 +40,7 @@ int mu2e::ValTrkCrvMatchMC::fill(const mu2e::TrkCrvMatchMCCollection& coll, art: for (size_t j = 0; j < m.cands_.size(); ++j) (m.cands_[j].hasFlag(TrkCrvCandidate::geomCand) ? _hGeomCandRel : _hTimeCandRel)->Fill(relBin(mc.cands_[j])); for (auto const& xm : mc.xings_) { - if (xm.generation_ != 0 || !ok(xm.sector_)) continue; + if (xm.rel_ != MCRelationship::same || !ok(xm.sector_)) continue; if (xm.geom_) { _hTrueXing->Fill(xm.sector_); if (xm.recoXing_ >= 0) _hTrueXingFound->Fill(xm.sector_); @@ -61,7 +61,7 @@ int mu2e::ValTrkCrvMatchMC::fill(const mu2e::TrkCrvMatchMCCollection& coll, art: if (t < 0 || static_cast(t) >= mc.xings_.size()) continue; _hRecoXingTrue->Fill(rx.sector_); auto const& xm = mc.xings_[t]; - if (!xm.geom_ || xm.generation_ != 0) continue; + if (!xm.geom_ || xm.rel_ != MCRelationship::same) continue; _hXingDist->Fill(rx.sector_, std::sqrt((rx.pos_ - xm.pos_).Mag2())); _hXingDt->Fill(rx.sector_, rx.time_ - xm.time_); } From 1886f04beedaa5e4bf8b719687f8ed00ff9aa204 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Tue, 10 Nov 2026 14:46:56 -0600 Subject: [PATCH 4/4] Address review comments. --- Validation/CMakeLists.txt | 1 - Validation/inc/ValTrkCrvMatch.hh | 19 ++++-- Validation/inc/ValTrkCrvMatchMC.hh | 5 +- Validation/inc/ValTrkCrvSectorAxis.hh | 47 ++++++++++++++ Validation/src/SConscript | 2 - Validation/src/ValTrkCrvMatch.cc | 92 +++++++++++++++------------ Validation/src/ValTrkCrvMatchMC.cc | 53 +++++++-------- 7 files changed, 142 insertions(+), 77 deletions(-) create mode 100644 Validation/inc/ValTrkCrvSectorAxis.hh diff --git a/Validation/CMakeLists.txt b/Validation/CMakeLists.txt index 54f0e7cc1d..5b3f5415b0 100644 --- a/Validation/CMakeLists.txt +++ b/Validation/CMakeLists.txt @@ -38,7 +38,6 @@ cet_make_library( src/ValTrkCrvMatchMC.cc LIBRARIES PUBLIC - Offline::CosmicRayShieldGeom Offline::DataProducts Offline::GeometryService Offline::KinKalGeom diff --git a/Validation/inc/ValTrkCrvMatch.hh b/Validation/inc/ValTrkCrvMatch.hh index 26e03d4c09..e48fa0ba0a 100644 --- a/Validation/inc/ValTrkCrvMatch.hh +++ b/Validation/inc/ValTrkCrvMatch.hh @@ -2,19 +2,21 @@ #define ValTrkCrvMatch_HH_ #include "Offline/RecoDataProducts/inc/TrkCrvMatch.hh" +#include "Offline/Validation/inc/ValTrkCrvSectorAxis.hh" #include "KinKal/General/Vectors.hh" #include "art/Framework/Principal/Event.h" #include "art_root_io/TFileDirectory.h" #include "TH1D.h" #include "TH2D.h" #include "TProfile.h" +#include +#include #include -#include namespace mu2e { -// track-CRV association: candidate counts, residuals and chi2 per CRV shield, dv against slope (alignment monitor), -// predicted vs matched shield, layer probe +// track-CRV association: candidate counts, residuals and chi2 per CRV sector, dv against slope (alignment monitor), +// predicted vs matched sector, layer probe class ValTrkCrvMatch { public: ValTrkCrvMatch(std::string name) : _name(name) {} @@ -24,7 +26,14 @@ class ValTrkCrvMatch { private: std::string _name; - std::vector _v, _w; // per shield: across-bar direction and normal, detector frame + struct Plane { // a sector of this job's geometry: centre, across-bar direction, normal, dv vs slope + KinKal::VEC3 c, v, w; + TProfile* p = nullptr; + }; + ValTrkCrvSectorAxis _axis; + std::map _plane; // by axis bin + std::map _shieldBin; // product shield index (sector_) -> axis bin, from the crossings + static constexpr double _planeTol = 1.0; // max distance of a crossing from the job's sector mid-plane [mm] TH1D* _hVer; TH1D* _hNTrk; @@ -43,7 +52,7 @@ class ValTrkCrvMatch { TH2D* _hDu; TH2D* _hDv; TH2D* _hPredMatched; - std::vector _pDvSlope; + TH1D* _hSlopeNoGeom; TH1D* _hProbePred; TH1D* _hProbeHit; TH1D* _hProbeInCluster; diff --git a/Validation/inc/ValTrkCrvMatchMC.hh b/Validation/inc/ValTrkCrvMatchMC.hh index 88869b9726..3c27027f3a 100644 --- a/Validation/inc/ValTrkCrvMatchMC.hh +++ b/Validation/inc/ValTrkCrvMatchMC.hh @@ -2,6 +2,7 @@ #define ValTrkCrvMatchMC_HH_ #include "Offline/MCDataProducts/inc/TrkCrvMatchMC.hh" +#include "Offline/Validation/inc/ValTrkCrvSectorAxis.hh" #include "art/Framework/Principal/Event.h" #include "art_root_io/TFileDirectory.h" #include "TH1D.h" @@ -11,7 +12,7 @@ namespace mu2e { // track-CRV association truth: relation of the best candidates, own-cluster association and crossing truth per -// CRV shield, reco crossings against the true crossings +// CRV sector, reco crossings against the true crossings class ValTrkCrvMatchMC { public: ValTrkCrvMatchMC(std::string name) : _name(name) {} @@ -21,7 +22,7 @@ class ValTrkCrvMatchMC { private: std::string _name; - int _ns = 0; + ValTrkCrvSectorAxis _axis; TH1D* _hVer; TH1D* _hBestGeomRel; diff --git a/Validation/inc/ValTrkCrvSectorAxis.hh b/Validation/inc/ValTrkCrvSectorAxis.hh new file mode 100644 index 0000000000..567d929743 --- /dev/null +++ b/Validation/inc/ValTrkCrvSectorAxis.hh @@ -0,0 +1,47 @@ +#ifndef ValTrkCrvSectorAxis_HH_ +#define ValTrkCrvSectorAxis_HH_ + +#include "Offline/DataProducts/inc/SurfaceId.hh" +#include "TAxis.h" +#include +#include +#include + +namespace mu2e { + +// fixed, labelled histogram axis of the CRV sector SurfaceIds, so the per-sector histograms do not depend on the job +// geometry; the last bin collects sectors without a SurfaceId +class ValTrkCrvSectorAxis { + public: + ValTrkCrvSectorAxis() { + for (auto const& [id, name] : SurfaceIdDetail::names()) { + if (name.rfind("CRV_", 0) != 0 || id == SurfaceIdDetail::CRV_StrongBack) continue; + _byName[name] = _bin[id] = static_cast(_names.size()); + _names.push_back(name); + } + _names.push_back("unknown"); + } + int n() const { return static_cast(_names.size()); } + int unknown() const { return n() - 1; } + double lo() const { return -0.5; } + double hi() const { return n() - 0.5; } + int bin(SurfaceId const& sid) const { + auto it = _bin.find(sid.id().id()); + return it == _bin.end() ? unknown() : it->second; + } + int bin(std::string const& name) const { + auto it = _byName.find(name); + return it == _byName.end() ? unknown() : it->second; + } + void label(TAxis* ax) const { + for (int i = 0; i < n(); ++i) ax->SetBinLabel(i + 1, _names[i].c_str()); + } + + private: + std::map _bin; + std::map _byName; + std::vector _names; +}; +} // namespace mu2e + +#endif diff --git a/Validation/src/SConscript b/Validation/src/SConscript index bd3deb3995..d54dac2617 100644 --- a/Validation/src/SConscript +++ b/Validation/src/SConscript @@ -22,7 +22,6 @@ mainlib = helper.make_mainlib ( [ 'mu2e_Validation_root', 'mu2e_GlobalConstantsService', 'mu2e_GeneralUtilities', 'mu2e_KinKalGeom', - 'mu2e_CosmicRayShieldGeom', 'art_Framework_Core', 'art_Framework_Principal', 'art_Framework_Services_Registry', @@ -49,7 +48,6 @@ helper.make_plugins( [ mainlib,'mu2e_Validation_root', 'mu2e_RecoDataProducts', 'mu2e_DataProducts', 'mu2e_KinKalGeom', - 'mu2e_CosmicRayShieldGeom', 'art_Framework_Core', 'art_Framework_Principal', 'art_Framework_Services_Registry', diff --git a/Validation/src/ValTrkCrvMatch.cc b/Validation/src/ValTrkCrvMatch.cc index cd658d71e4..d39bbd6912 100644 --- a/Validation/src/ValTrkCrvMatch.cc +++ b/Validation/src/ValTrkCrvMatch.cc @@ -1,26 +1,11 @@ #include "Offline/Validation/inc/ValTrkCrvMatch.hh" -#include "Offline/CosmicRayShieldGeom/inc/CosmicRayShield.hh" #include "Offline/GeometryService/inc/GeomHandle.hh" #include "Offline/KinKalGeom/inc/KinKalGeom.hh" #include -#include int mu2e::ValTrkCrvMatch::declare(const art::TFileDirectory& tfs) { - GeomHandle crs; - GeomHandle kkg; - auto const& shields = crs->getCRSScintillatorShields(); - int ns = static_cast(shields.size()); - _v.assign(ns, KinKal::VEC3()); - _w.assign(ns, KinKal::VEC3()); - std::map nameToShield; - for (int i = 0; i < ns; ++i) nameToShield[shields[i].getName()] = i; - for (auto const& sec : kkg->CRV()->sectors()) { - auto it = nameToShield.find(sec.sname_); - if (it == nameToShield.end()) continue; - _v[it->second] = sec.sector_->vDirection(); - _w[it->second] = sec.sector_->normal(); - } - + int ns = _axis.n(); + double lo = _axis.lo(), hi = _axis.hi(); _hVer = tfs.make("Ver", "Version Number", 101, -0.5, 100.0); _hNTrk = tfs.make("NTrk", "N tracks", 21, -0.5, 20.5); _hNCand = tfs.make("NCand", "N candidates per track", 51, -0.5, 50.5); @@ -32,16 +17,28 @@ int mu2e::ValTrkCrvMatch::declare(const art::TFileDirectory& tfs) { _hChi2 = tfs.make("chi2ndof", "#chi^{2}/ndof, best in sector", 100, 0., 20.); _hNShare = tfs.make("NShare", "tracks sharing the cluster", 11, -0.5, 10.5); _hFlags = tfs.make("Flags", "candidate flag bits", 16, -0.5, 15.5); - _hXingShield = tfs.make("XingShield", "CRV crossings per shield", ns, -0.5, ns - 0.5); - _hXingGeomShield = tfs.make("XingGeomShield", "crossings with a geometric candidate in their shield", ns, -0.5, ns - 0.5); - _hDtXing = tfs.make("dtXing", "t_{cluster} - t_{trk} at the plane, best in sector;shield;ns", ns, -0.5, ns - 0.5, 100, -100., 100.); - _hDu = tfs.make("du", "cluster - track along the bars, best in sector;shield;mm", ns, -0.5, ns - 0.5, 100, -3000., 3000.); - _hDv = tfs.make("dv", "cluster - track across the bars, best in sector;shield;mm", ns, -0.5, ns - 0.5, 100, -500., 500.); - _hPredMatched = tfs.make("PredMatched", "best geometric candidate;reference crossing shield;cluster shield", ns, -0.5, ns - 0.5, ns, -0.5, ns - 0.5); - _pDvSlope.clear(); - for (int i = 0; i < ns; ++i) { - std::string n = shields[i].getName(); - _pDvSlope.push_back(tfs.make(("dvVsSlope_" + n).c_str(), ("dv vs across-bar slope, " + n + ";slope;dv [mm]").c_str(), 40, -2., 2.)); + _hXingShield = tfs.make("XingShield", "CRV crossings per sector", ns, lo, hi); + _hXingGeomShield = tfs.make("XingGeomShield", "crossings with a geometric candidate in their sector", ns, lo, hi); + _hDtXing = tfs.make("dtXing", "t_{cluster} - t_{trk} at the plane, best in sector;cluster sector;ns", ns, lo, hi, 100, -100., 100.); + _hDu = tfs.make("du", "cluster - track along the bars, best in sector;cluster sector;mm", ns, lo, hi, 100, -3000., 3000.); + _hDv = tfs.make("dv", "cluster - track across the bars, best in sector;cluster sector;mm", ns, lo, hi, 100, -500., 500.); + _hPredMatched = tfs.make("PredMatched", "best geometric candidate;reference crossing sector;cluster sector", ns, lo, hi, ns, lo, hi); + _hSlopeNoGeom = tfs.make("SlopeNoGeom", "best in sector, not in dvVsSlope: sector not in this job's geometry;cluster sector", ns, lo, hi); + for (TH1* h : {static_cast(_hXingShield), static_cast(_hXingGeomShield), static_cast(_hDtXing), + static_cast(_hDu), static_cast(_hDv), static_cast(_hPredMatched), static_cast(_hSlopeNoGeom)}) + _axis.label(h->GetXaxis()); + _axis.label(_hPredMatched->GetYaxis()); + + // dv vs slope needs the sector directions, from this job's geometry: one profile per sector it has + GeomHandle kkg; + for (auto const& sec : kkg->CRV()->sectors()) { + int b = _axis.bin(sec.sname_); + if (b == _axis.unknown() || _plane.count(b)) continue; + auto& pl = _plane[b]; + pl.c = sec.sector_->center(); + pl.v = sec.sector_->vDirection(); + pl.w = sec.sector_->normal(); + pl.p = tfs.make(("dvVsSlope_" + sec.sname_).c_str(), ("dv vs across-bar slope, " + sec.sname_ + ";slope;dv [mm]").c_str(), 40, -2., 2.); } _hProbePred = tfs.make("ProbePred", "layer probe: predicted bar per layer", 6, -0.5, 5.5); _hProbeHit = tfs.make("ProbeHit", "layer probe: pulse found per layer", 6, -0.5, 5.5); @@ -58,10 +55,14 @@ int mu2e::ValTrkCrvMatch::fill(const mu2e::TrkCrvMatchCollection& coll, art::Eve // histogram contents change, and will not match previous versions _hVer->Fill(1.0); - int ns = static_cast(_v.size()); - auto okShield = [&](int s) { return s >= 0 && s < ns; }; + // a cluster's sector: the SurfaceId of a crossing with the same shield index in the product's geometry + auto clusterBin = [&](int16_t shield) { + auto it = _shieldBin.find(shield); + return it == _shieldBin.end() ? _axis.unknown() : it->second; + }; _hNTrk->Fill(coll.size()); for (auto const& m : coll) { + for (auto const& x : m.xings_) _shieldBin[x.sector_] = _axis.bin(x.sid_); _hNCand->Fill(m.cands_.size()); _hNXing->Fill(m.xings_.size()); int ngeom = 0; @@ -72,17 +73,25 @@ int mu2e::ValTrkCrvMatch::fill(const mu2e::TrkCrvMatchCollection& coll, art::Eve if (c.flags_ & (1u << b)) _hFlags->Fill(b); if (!c.hasFlag(TrkCrvCandidate::geomCand)) continue; ++ngeom; - if (!c.hasFlag(TrkCrvCandidate::bestInSector) || !okShield(c.sector_)) continue; + if (!c.hasFlag(TrkCrvCandidate::bestInSector)) continue; + int b = clusterBin(c.sector_); if (c.ndof_ > 0) _hChi2->Fill(c.chi2_ / c.ndof_); - _hDtXing->Fill(c.sector_, c.dtXing_); - if (!c.hasFlag(TrkCrvCandidate::singleEnded)) _hDu->Fill(c.sector_, c.du_); - _hDv->Fill(c.sector_, c.dv_); - if (c.xing_ >= 0 && static_cast(c.xing_) < m.xings_.size()) { - auto const& d = m.xings_[c.xing_].dir_; - KinKal::VEC3 dir(d.X(), d.Y(), d.Z()); - double dw = dir.Dot(_w[c.sector_]); - if (std::fabs(dw) > 1e-3) _pDvSlope[c.sector_]->Fill(dir.Dot(_v[c.sector_]) / dw, c.dv_); + _hDtXing->Fill(b, c.dtXing_); + if (!c.hasFlag(TrkCrvCandidate::singleEnded)) _hDu->Fill(b, c.du_); + _hDv->Fill(b, c.dv_); + if (c.xing_ < 0 || static_cast(c.xing_) >= m.xings_.size()) continue; + // the job's directions apply only if its plane of the reference crossing's sector holds that crossing + auto const& x = m.xings_[c.xing_]; + auto ix = _plane.find(_axis.bin(x.sid_)); + auto ic = _plane.find(b); + KinKal::VEC3 pos(x.pos_.X(), x.pos_.Y(), x.pos_.Z()); + if (ix == _plane.end() || ic == _plane.end() || std::fabs((pos - ix->second.c).Dot(ix->second.w)) > _planeTol) { + _hSlopeNoGeom->Fill(b); + continue; } + KinKal::VEC3 dir(x.dir_.X(), x.dir_.Y(), x.dir_.Z()); + double dw = dir.Dot(ic->second.w); + if (std::fabs(dw) > 1e-3) ic->second.p->Fill(dir.Dot(ic->second.v) / dw, c.dv_); } _hNGeom->Fill(ngeom); int best = m.bestGeom_ >= 0 ? m.bestGeom_ : m.bestTime_; @@ -92,11 +101,12 @@ int mu2e::ValTrkCrvMatch::fill(const mu2e::TrkCrvMatchCollection& coll, art::Eve } if (m.bestGeom_ >= 0) { auto const& c = m.cands_[m.bestGeom_]; - if (c.xing_ >= 0 && static_cast(c.xing_) < m.xings_.size()) _hPredMatched->Fill(m.xings_[c.xing_].sector_, c.sector_); + if (c.xing_ >= 0 && static_cast(c.xing_) < m.xings_.size()) + _hPredMatched->Fill(_axis.bin(m.xings_[c.xing_].sid_), clusterBin(c.sector_)); } for (auto const& x : m.xings_) { - _hXingShield->Fill(x.sector_); - if (x.best_ >= 0) _hXingGeomShield->Fill(x.sector_); + _hXingShield->Fill(_axis.bin(x.sid_)); + if (x.best_ >= 0) _hXingGeomShield->Fill(_axis.bin(x.sid_)); for (size_t L = 0; L < x.layers_.size(); ++L) { auto const& p = x.layers_[L]; if (p.bar_ < 0) continue; diff --git a/Validation/src/ValTrkCrvMatchMC.cc b/Validation/src/ValTrkCrvMatchMC.cc index 2d1e73e41d..8fa26f738a 100644 --- a/Validation/src/ValTrkCrvMatchMC.cc +++ b/Validation/src/ValTrkCrvMatchMC.cc @@ -1,26 +1,27 @@ #include "Offline/Validation/inc/ValTrkCrvMatchMC.hh" -#include "Offline/CosmicRayShieldGeom/inc/CosmicRayShield.hh" -#include "Offline/GeometryService/inc/GeomHandle.hh" #include int mu2e::ValTrkCrvMatchMC::declare(const art::TFileDirectory& tfs) { - GeomHandle crs; - _ns = static_cast(crs->getCRSScintillatorShields().size()); - double lo = -0.5, hi = _ns - 0.5; + int ns = _axis.n(); + double lo = _axis.lo(), hi = _axis.hi(); _hVer = tfs.make("Ver", "Version Number", 101, -0.5, 100.0); _hBestGeomRel = tfs.make("BestGeomRel", "best geometric candidate, MCRelationship to the track's particle: 0 no MC, 1 unrelated, 2 same, 3 daughter, 4 mother, 5 sibling, 6 udaughter, 7 umother, 8 usibling", 9, -0.5, 8.5); _hBestTimeRel = tfs.make("BestTimeRel", "best time candidate, MCRelationship to the track's particle", 9, -0.5, 8.5); _hGeomCandRel = tfs.make("GeomCandRel", "all geometric candidates, MCRelationship", 9, -0.5, 8.5); _hTimeCandRel = tfs.make("TimeCandRel", "time-only candidates, MCRelationship", 9, -0.5, 8.5); - _hTrueClu = tfs.make("TrueClu", "own cluster of the track's particle per shield", _ns, lo, hi); - _hTrueCluGeom = tfs.make("TrueCluGeom", "own cluster is a geometric candidate", _ns, lo, hi); - _hTrueCluBest = tfs.make("TrueCluBest", "own cluster is the best in its sector", _ns, lo, hi); - _hRecoXing = tfs.make("RecoXing", "reco crossings per shield", _ns, lo, hi); - _hRecoXingTrue = tfs.make("RecoXingTrue", "reco crossings with a true crossing of the same shield", _ns, lo, hi); - _hTrueXing = tfs.make("TrueXing", "true crossings of the track's particle per shield", _ns, lo, hi); - _hTrueXingFound = tfs.make("TrueXingFound", "true crossings with a reco crossing", _ns, lo, hi); - _hXingDist = tfs.make("XingDist", "|reco - true crossing|;shield;mm", _ns, lo, hi, 100, 0., 500.); - _hXingDt = tfs.make("XingDt", "reco - true crossing time;shield;ns", _ns, lo, hi, 100, -20., 20.); + _hTrueClu = tfs.make("TrueClu", "own cluster of the track's particle per sector", ns, lo, hi); + _hTrueCluGeom = tfs.make("TrueCluGeom", "own cluster is a geometric candidate", ns, lo, hi); + _hTrueCluBest = tfs.make("TrueCluBest", "own cluster is the best in its sector", ns, lo, hi); + _hRecoXing = tfs.make("RecoXing", "reco crossings per sector", ns, lo, hi); + _hRecoXingTrue = tfs.make("RecoXingTrue", "reco crossings with a true crossing of the same sector", ns, lo, hi); + _hTrueXing = tfs.make("TrueXing", "true crossings of the track's particle per sector", ns, lo, hi); + _hTrueXingFound = tfs.make("TrueXingFound", "true crossings with a reco crossing", ns, lo, hi); + _hXingDist = tfs.make("XingDist", "|reco - true crossing|;sector;mm", ns, lo, hi, 100, 0., 500.); + _hXingDt = tfs.make("XingDt", "reco - true crossing time;sector;ns", ns, lo, hi, 100, -20., 20.); + for (TH1* h : {static_cast(_hTrueClu), static_cast(_hTrueCluGeom), static_cast(_hTrueCluBest), + static_cast(_hRecoXing), static_cast(_hRecoXingTrue), static_cast(_hTrueXing), + static_cast(_hTrueXingFound), static_cast(_hXingDist), static_cast(_hXingDt)}) + _axis.label(h->GetXaxis()); return 0; } @@ -29,7 +30,6 @@ int mu2e::ValTrkCrvMatchMC::fill(const mu2e::TrkCrvMatchMCCollection& coll, art: // histogram contents change, and will not match previous versions _hVer->Fill(1.0); - auto ok = [&](int s) { return s >= 0 && s < _ns; }; for (auto const& mc : coll) { if (mc.match_.isNull() || !mc.match_.isAvailable()) continue; auto const& m = *mc.match_; @@ -40,30 +40,31 @@ int mu2e::ValTrkCrvMatchMC::fill(const mu2e::TrkCrvMatchMCCollection& coll, art: for (size_t j = 0; j < m.cands_.size(); ++j) (m.cands_[j].hasFlag(TrkCrvCandidate::geomCand) ? _hGeomCandRel : _hTimeCandRel)->Fill(relBin(mc.cands_[j])); for (auto const& xm : mc.xings_) { - if (xm.rel_ != MCRelationship::same || !ok(xm.sector_)) continue; + if (xm.rel_ != MCRelationship::same) continue; + int b = _axis.bin(xm.sid_); if (xm.geom_) { - _hTrueXing->Fill(xm.sector_); - if (xm.recoXing_ >= 0) _hTrueXingFound->Fill(xm.sector_); + _hTrueXing->Fill(b); + if (xm.recoXing_ >= 0) _hTrueXingFound->Fill(b); } if (xm.trueCluster_ < 0) continue; - _hTrueClu->Fill(xm.sector_); + _hTrueClu->Fill(b); if (xm.trueCand_ < 0 || static_cast(xm.trueCand_) >= m.cands_.size()) continue; auto const& c = m.cands_[xm.trueCand_]; if (!c.hasFlag(TrkCrvCandidate::geomCand)) continue; - _hTrueCluGeom->Fill(xm.sector_); - if (c.hasFlag(TrkCrvCandidate::bestInSector)) _hTrueCluBest->Fill(xm.sector_); + _hTrueCluGeom->Fill(b); + if (c.hasFlag(TrkCrvCandidate::bestInSector)) _hTrueCluBest->Fill(b); } for (size_t ir = 0; ir < m.xings_.size() && ir < mc.recoXingTruth_.size(); ++ir) { auto const& rx = m.xings_[ir]; - if (!ok(rx.sector_)) continue; - _hRecoXing->Fill(rx.sector_); + int b = _axis.bin(rx.sid_); + _hRecoXing->Fill(b); int t = mc.recoXingTruth_[ir]; if (t < 0 || static_cast(t) >= mc.xings_.size()) continue; - _hRecoXingTrue->Fill(rx.sector_); + _hRecoXingTrue->Fill(b); auto const& xm = mc.xings_[t]; if (!xm.geom_ || xm.rel_ != MCRelationship::same) continue; - _hXingDist->Fill(rx.sector_, std::sqrt((rx.pos_ - xm.pos_).Mag2())); - _hXingDt->Fill(rx.sector_, rx.time_ - xm.time_); + _hXingDist->Fill(b, std::sqrt((rx.pos_ - xm.pos_).Mag2())); + _hXingDt->Fill(b, rx.time_ - xm.time_); } } return 0;