Skip to content

Commit

Permalink
Merge branch 'main' into feature/hit-selector
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 27, 2023
2 parents 947fd03 + 243850f commit 7f1e7d3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
8 changes: 3 additions & 5 deletions Core/include/Acts/Propagator/MaterialInteractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct MaterialInteractor {
bool energyLoss = true;
/// Whether to record all material interactions.
bool recordInteractions = false;
/// Whether to add or remove noise.
NoiseUpdateMode noiseUpdateMode = NoiseUpdateMode::addNoise;

using result_type = RecordedMaterial;

Expand Down Expand Up @@ -100,12 +102,8 @@ struct MaterialInteractor {
if (interaction.performCovarianceTransport) {
stepper.transportCovarianceToCurvilinear(state.stepping);
}
// Change the noise updater depending on the navigation direction
NoiseUpdateMode mode = (state.options.direction == Direction::Forward)
? addNoise
: removeNoise;
// Apply the material interactions
interaction.updateState(state, stepper, mode);
interaction.updateState(state, stepper, noiseUpdateMode);

// Record the result
recordResult(interaction, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <utility>

#include <TFile.h>
#include <TTree.h>
#include <TVectorFfwd.h>
#include <TVectorT.h>

Expand Down Expand Up @@ -67,6 +68,14 @@ ActsExamples::CKFPerformanceWriter::CKFPerformanceWriter(
throw std::invalid_argument("Could not open '" + m_cfg.filePath + "'");
}

if (m_cfg.writeMatchingDetails) {
m_matchingTree = new TTree("matchingdetails", "matchingdetails");

m_matchingTree->Branch("event_nr", &m_treeEventNr);
m_matchingTree->Branch("particle_id", &m_treeParticleId);
m_matchingTree->Branch("matched", &m_treeIsMatched);
}

// initialize the plot tools
m_effPlotTool.book(m_effPlotCache);
m_fakeRatePlotTool.book(m_fakeRatePlotCache);
Expand Down Expand Up @@ -132,6 +141,11 @@ ActsExamples::ProcessCode ActsExamples::CKFPerformanceWriter::finalize() {
write_float(eff_particle, "eff_particles");
write_float(fakeRate_particle, "fakerate_particles");
write_float(duplicationRate_particle, "duplicaterate_particles");

if (m_matchingTree != nullptr) {
m_matchingTree->Write();
}

ACTS_INFO("Wrote performance plots to '" << m_outputFile->GetPath() << "'");
}
return ProcessCode::SUCCESS;
Expand Down Expand Up @@ -324,5 +338,16 @@ ActsExamples::ProcessCode ActsExamples::CKFPerformanceWriter::writeT(
m_nTotalParticles += 1;
} // end all truth particles

// Write additional stuff to TTree
if (m_cfg.writeMatchingDetails && m_matchingTree != nullptr) {
for (const auto& p : particles) {
m_treeEventNr = ctx.eventNumber;
m_treeParticleId = p.particleId().value();
m_treeIsMatched = (matched.find(p.particleId()) != matched.end());

m_matchingTree->Fill();
}
}

return ProcessCode::SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ class CKFPerformanceWriter final : public WriterT<ConstTrackContainer> {
/// Min reco-truth matching probability
double truthMatchProbMin = 0.5;

/// function to check if neural network predicted track label is duplicate
/// Write additional matching details to a TTree
bool writeMatchingDetails = false;

/// function to check if neural network predicted track label is
/// duplicate
std::function<bool(std::vector<float>&)> duplicatedPredictor = nullptr;
};

Expand Down Expand Up @@ -108,6 +112,14 @@ class CKFPerformanceWriter final : public WriterT<ConstTrackContainer> {
TrackSummaryPlotTool m_trackSummaryPlotTool;
TrackSummaryPlotTool::TrackSummaryPlotCache m_trackSummaryPlotCache{};

/// For optional output of the matching details
TTree* m_matchingTree{nullptr};

/// Variables to fill in the TTree
uint32_t m_treeEventNr{};
uint64_t m_treeParticleId{};
bool m_treeIsMatched{};

// Adding numbers for efficiency, fake, duplicate calculations
std::size_t m_nTotalTracks = 0;
std::size_t m_nTotalMatchedTracks = 0;
Expand Down
13 changes: 7 additions & 6 deletions Examples/Python/src/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,13 @@ void addOutput(Context& ctx) {
trackingGeometry, outputDir, outputPrecision, writeSensitive,
writeBoundary, writeSurfaceGrid, writeLayerVolume, writePerEvent);

ACTS_PYTHON_DECLARE_WRITER(ActsExamples::CKFPerformanceWriter, mex,
"CKFPerformanceWriter", inputTracks,
inputParticles, inputMeasurementParticlesMap,
filePath, fileMode, effPlotToolConfig,
fakeRatePlotToolConfig, duplicationPlotToolConfig,
trackSummaryPlotToolConfig, duplicatedPredictor);
ACTS_PYTHON_DECLARE_WRITER(
ActsExamples::CKFPerformanceWriter, mex, "CKFPerformanceWriter",
inputTracks, inputParticles, inputMeasurementParticlesMap, filePath,
fileMode, effPlotToolConfig, fakeRatePlotToolConfig,
duplicationPlotToolConfig, trackSummaryPlotToolConfig,
duplicatedPredictor, truthMatchProbMin, doubleMatching,
writeMatchingDetails);

ACTS_PYTHON_DECLARE_WRITER(
ActsExamples::RootNuclearInteractionParametersWriter, mex,
Expand Down

0 comments on commit 7f1e7d3

Please sign in to comment.