23 #include <unordered_map>
84 throw std::invalid_argument(
"Missing particles input collection");
87 throw std::invalid_argument(
"Missing hit-particles map input collection");
90 throw std::invalid_argument(
"Missing proto tracks input collection");
93 throw std::invalid_argument(
"Missing output filename");
100 file = TFile::Open(path.c_str(),
"RECREATE");
102 throw std::invalid_argument(
"Could not open '" + path +
"'");
106 trkTree =
new TTree(
"track_finder_tracks",
"");
115 prtTree =
new TTree(
"track_finder_particles",
"");
137 const HitParticlesMap& hitParticlesMap,
142 std::unordered_map<ActsFatras::Barcode, std::size_t> reconCount;
143 reconCount.reserve(particles.size());
145 std::unordered_map<ActsFatras::Barcode, std::size_t> majorityCount;
146 majorityCount.reserve(particles.size());
148 std::vector<ParticleHitCount> particleHitCounts;
152 std::lock_guard<std::mutex> guardTrk(
trkMutex);
153 for (
size_t itrack = 0; itrack < tracks.size(); ++itrack) {
154 const auto& track = tracks[itrack];
162 if (not particleHitCounts.empty()) {
163 auto it = majorityCount
164 .try_emplace(particleHitCounts.front().particleId, 0
u)
168 for (
const auto& hc : particleHitCounts) {
169 auto it = reconCount.try_emplace(hc.particleId, 0
u).first;
180 for (
const auto& phc : particleHitCounts) {
183 auto trueParticleHits =
184 makeRange(particleHitsMap.equal_range(phc.particleId.value()));
195 std::lock_guard<std::mutex> guardPrt(
trkMutex);
196 for (
const auto&
particle : particles) {
218 auto nt = reconCount.find(
particle.particleId());
220 auto nm = majorityCount.find(
particle.particleId());
241 :
WriterT(cfg.inputProtoTracks,
"TrackFinderPerformanceWriter", lvl),
242 m_impl(std::make_unique<
Impl>(std::move(cfg), logger())) {}
251 const auto& particles =
253 const auto& hitParticlesMap =
254 ctx.
eventStore.
get<HitParticlesMap>(m_impl->cfg.inputHitParticlesMap);
255 m_impl->write(ctx.
eventNumber, particles, hitParticlesMap, tracks);