Skip to content

Commit

Permalink
feat: Write truth matching in VertexPerformanceWriter (#2969)
Browse files Browse the repository at this point in the history
Writes primary and secondary vertex number after matching to truth.

I also reorganized the branches and the order of writing them to follow reco -> truth.

blocked by
- #2970
  • Loading branch information
andiwand committed Mar 8, 2024
1 parent 22c4d40 commit afebfab
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 269 deletions.
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_gridseeder_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_truth_estimated_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_truth_smeared_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_truth_estimated_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_truth_smeared_hist.root
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ActsExamples/Framework/ProcessCode.hpp"
#include "ActsExamples/Framework/WriterT.hpp"

#include <cstdint>
#include <mutex>
#include <string>
#include <vector>
Expand Down Expand Up @@ -107,25 +108,41 @@ class VertexPerformanceWriter final
/// The event number
std::uint32_t m_eventNr{0};

// True 4D vertex position
std::vector<double> m_truthX;
std::vector<double> m_truthY;
std::vector<double> m_truthZ;
std::vector<double> m_truthT;
// Truth vertex ID
std::vector<int> m_vertexPrimary;
std::vector<int> m_vertexSecondary;

// Reconstructed 4D vertex position
std::vector<double> m_recoX;
std::vector<double> m_recoY;
std::vector<double> m_recoZ;
std::vector<double> m_recoT;

// Vertex covariance
std::vector<double> m_covXX;
std::vector<double> m_covYY;
std::vector<double> m_covZZ;
std::vector<double> m_covTT;
std::vector<double> m_covXY;
std::vector<double> m_covXZ;
std::vector<double> m_covXT;
std::vector<double> m_covYZ;
std::vector<double> m_covYT;
std::vector<double> m_covZT;

// 4D position of the vertex seed. x and y coordinate are 0 in current
// implementations, we save them here as a check.
std::vector<double> m_seedX;
std::vector<double> m_seedY;
std::vector<double> m_seedZ;
std::vector<double> m_seedT;

// True 4D vertex position
std::vector<double> m_truthX;
std::vector<double> m_truthY;
std::vector<double> m_truthZ;
std::vector<double> m_truthT;

// Difference of reconstructed and true vertex 4D position
std::vector<double> m_resX;
std::vector<double> m_resY;
Expand All @@ -142,21 +159,25 @@ class VertexPerformanceWriter final
std::vector<double> m_pullZ;
std::vector<double> m_pullT;

// Vertex covariance
std::vector<double> m_covXX;
std::vector<double> m_covYY;
std::vector<double> m_covZZ;
std::vector<double> m_covTT;
std::vector<double> m_covXY;
std::vector<double> m_covXZ;
std::vector<double> m_covXT;
std::vector<double> m_covYZ;
std::vector<double> m_covYT;
std::vector<double> m_covZT;

// Sum pT^2 of all tracks associated with the vertex
std::vector<double> m_sumPt2;

// Number of tracks associated with truth/reconstructed vertex
std::vector<int> m_nTracksOnTruthVertex;
std::vector<int> m_nTracksOnRecoVertex;

std::vector<double> m_trackVtxMatchFraction;

/// Number of reconstructed vertices
int m_nRecoVtx = -1;
/// Number of true vertices
int m_nTrueVtx = -1;
/// Number of vertices in detector acceptance
int m_nVtxDetAcceptance = -1;
/// Max. number of reconstructable vertices (detector acceptance + tracking
/// efficiency)
int m_nVtxReconstructable = -1;

//--------------------------------------------------------------
// Track-related variables are contained in a vector of vectors: The inner
// vectors contain the values of all tracks corresponding to one vertex. The
Expand All @@ -167,74 +188,54 @@ class VertexPerformanceWriter final
// (truthPhi of 1st trk belonging to vtx 2,
// truthPhi of 2nd trk belonging to vtx 2, ...),
// ...)
//
// True track momenta at the vertex
std::vector<std::vector<double>> m_truthPhi;
std::vector<std::vector<double>> m_truthTheta;
std::vector<std::vector<double>> m_truthQOverP;

// Track weights from vertex fit, will be set to 1 if we do unweighted vertex
// fitting
std::vector<std::vector<double>> m_trkWeight;

// Reconstructed track momenta at the vertex before and after the vertex fit
std::vector<std::vector<double>> m_recoPhi;
std::vector<std::vector<double>> m_recoPhiFitted;
std::vector<std::vector<double>> m_recoTheta;
std::vector<std::vector<double>> m_recoThetaFitted;
std::vector<std::vector<double>> m_recoQOverP;

std::vector<std::vector<double>> m_recoPhiFitted;
std::vector<std::vector<double>> m_recoThetaFitted;
std::vector<std::vector<double>> m_recoQOverPFitted;

std::vector<std::vector<std::uint64_t>> m_trkParticleId;

// True track momenta at the vertex
std::vector<std::vector<double>> m_truthPhi;
std::vector<std::vector<double>> m_truthTheta;
std::vector<std::vector<double>> m_truthQOverP;

// Difference between reconstructed momenta and true momenta
std::vector<std::vector<double>> m_resPhi;
std::vector<std::vector<double>> m_resPhiFitted;
std::vector<std::vector<double>> m_resTheta;
std::vector<std::vector<double>> m_resThetaFitted;
std::vector<std::vector<double>> m_resQOverP;
std::vector<std::vector<double>> m_resQOverPFitted;
std::vector<std::vector<double>> m_momOverlap;

std::vector<std::vector<double>> m_resPhiFitted;
std::vector<std::vector<double>> m_resThetaFitted;
std::vector<std::vector<double>> m_resQOverPFitted;
std::vector<std::vector<double>> m_momOverlapFitted;

// Pulls
std::vector<std::vector<double>> m_pullPhi;
std::vector<std::vector<double>> m_pullPhiFitted;
std::vector<std::vector<double>> m_pullTheta;
std::vector<std::vector<double>> m_pullThetaFitted;
std::vector<std::vector<double>> m_pullQOverP;
std::vector<std::vector<double>> m_pullQOverPFitted;

// Track weights from vertex fit, will be set to 1 if we do unweighted vertex
// fitting
std::vector<std::vector<double>> m_trkWeight;

// Number of tracks associated with truth/reconstructed vertex
std::vector<int> m_nTracksOnTruthVertex;
std::vector<int> m_nTracksOnRecoVertex;

std::vector<double> m_trackVtxMatchFraction;

/// Number of reconstructed vertices
int m_nRecoVtx = -1;
/// Number of true vertices
int m_nTrueVtx = -1;
/// Number of vertices in detector acceptance
int m_nVtxDetAcceptance = -1;
/// Max. number of reconstructable vertices (detector acceptance + tracking
/// efficiency)
int m_nVtxReconstructable = -1;

int getNumberOfReconstructableVertices(
const SimParticleContainer& collection) const;

int getNumberOfTruePriVertices(const SimParticleContainer& collection) const;
std::vector<std::vector<double>> m_pullPhiFitted;
std::vector<std::vector<double>> m_pullThetaFitted;
std::vector<std::vector<double>> m_pullQOverPFitted;

ReadDataHandle<SimParticleContainer> m_inputAllTruthParticles{
this, "InputAllTruthParticles"};

ReadDataHandle<SimParticleContainer> m_inputSelectedTruthParticles{
this, "InputSelectedTruthParticles"};

ReadDataHandle<ConstTrackContainer> m_inputTracks{this, "InputTracks"};

ReadDataHandle<SimParticleContainer> m_inputAssociatedTruthParticles{
this, "InputAssociatedTruthParticles"};

ReadDataHandle<HitParticlesMap> m_inputMeasurementParticlesMap{
this, "InputMeasurementParticlesMap"};
};
Expand Down

0 comments on commit afebfab

Please sign in to comment.