Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move MaterialTrackWriting infrastructure to Core + first use of RNTuple #4043

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CI/codespell_ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ strack
te
vart
writet
mata
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ option(ACTS_EXATRKX_ENABLE_CUDA "Enable CUDA for the exatrkx plugin" OFF)
option(ACTS_BUILD_PLUGIN_JSON "Build json plugin" OFF)
option(ACTS_BUILD_PLUGIN_LEGACY "Build legacy plugin" OFF)
option(ACTS_BUILD_PLUGIN_ONNX "Build ONNX plugin" OFF)
option(ACTS_BUILD_PLUGIN_ROOT "Build ROOT plugin" OFF)
option(ACTS_BUILD_PLUGIN_TGEO "Build TGeo plugin" OFF)
option(ACTS_SETUP_ANNOY "Explicitly set up Annoy for the project" OFF)
option(ACTS_BUILD_PLUGIN_HASHING "Build Hashing plugin" OFF)
Expand Down Expand Up @@ -170,6 +171,14 @@ set_option_if(
ACTS_BUILD_PLUGIN_DD4HEP OR
ACTS_BUILD_EXAMPLES
)
set_option_if(
ACTS_BUILD_PLUGIN_ROOT
ACTS_BUILD_PLUGIN_TGEO
)
set_option_if(
ACTS_BUILD_PLUGIN_ROOT
ACTS_BUILD_ANALYSIS_APPS
)
set_option_if(
ACTS_BUILD_PLUGIN_IDENTIFICATION
ACTS_BUILD_PLUGIN_TGEO OR
Expand Down Expand Up @@ -405,17 +414,17 @@ if(ACTS_BUILD_PLUGIN_GEOMODEL)
# find other GeoModel components of EXACT same version
find_package(GeoModelIO ${GeoModelCore_VERSION} REQUIRED EXACT CONFIG)
endif()
if(ACTS_BUILD_PLUGIN_TGEO)
if(ACTS_BUILD_PLUGIN_ROOT)
find_package(
ROOT
${_acts_root_version}
REQUIRED
CONFIG
COMPONENTS Geom Graf
COMPONENTS RIO ROOTDataFrame
)
check_root_compatibility()
endif()
if(ACTS_BUILD_ANALYSIS_APPS)
if(ACTS_BUILD_PLUGIN_TGEO)
find_package(
ROOT
${_acts_root_version}
Expand Down
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"ACTS_BUILD_PLUGIN_EXATRKX": "OFF",
"ACTS_BUILD_PLUGIN_JSON": "ON",
"ACTS_BUILD_PLUGIN_ONNX": "OFF",
"ACTS_BUILD_PLUGIN_ROOT": "ON",
"ACTS_BUILD_PLUGIN_TGEO": "ON",
"ACTS_BUILD_EXAMPLES_EDM4HEP": "ON",
"ACTS_BUILD_EXAMPLES_EXATRKX": "OFF",
Expand Down
1 change: 1 addition & 0 deletions Examples/Io/Root/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ target_link_libraries(
ActsExamplesIoRoot
PUBLIC
ActsCore
ActsPluginRoot
ActsExamplesDigitization
ActsExamplesFramework
ActsExamplesPropagation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Material/MaterialInteraction.hpp"
#include "Acts/Plugins/Root/RootMaterialTrack.hpp"
#include "Acts/Propagator/MaterialInteractor.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
Expand Down Expand Up @@ -37,16 +38,13 @@ namespace ActsExamples {
class RootMaterialTrackReader : public IReader {
public:
/// @brief The nested configuration struct
struct Config {
struct Config : public Acts::RootMaterialTrack::Config {
/// material collection to read
std::string outputMaterialTracks = "material-tracks";
std::string outputMaterialTracks = "material_tracks";
/// name of the output tree
std::string treeName = "material-tracks";
std::string treeName = "material_tracks";
/// List of input files
std::vector<std::string> fileList;

// Read surface information for the root file
bool readCachedSurfaceInformation = false;
};

/// Constructor
Expand Down Expand Up @@ -96,69 +94,12 @@ class RootMaterialTrackReader : public IReader {
/// The input tree name
std::unique_ptr<TChain> m_inputChain;

/// Event identifier.
std::uint32_t m_eventId = 0;

/// The entry numbers for accessing events in increased order (there could be
/// multiple entries corresponding to one event number)
std::vector<long long> m_entryNumbers = {};

/// start global x
float m_v_x = 0;
/// start global y
float m_v_y = 0;
/// start global z
float m_v_z = 0;
/// start global momentum x
float m_v_px = 0;
/// start global momentum y
float m_v_py = 0;
/// start global momentum z
float m_v_pz = 0;
/// start phi direction
float m_v_phi = 0;
/// start eta direction
float m_v_eta = 0;
/// thickness in X0/L0
float m_tX0 = 0;
/// thickness in X0/L0
float m_tL0 = 0;

/// step x position
std::vector<float>* m_step_x = new std::vector<float>;
/// step y position
std::vector<float>* m_step_y = new std::vector<float>;
/// step z position
std::vector<float>* m_step_z = new std::vector<float>;
/// step x direction
std::vector<float>* m_step_dx = new std::vector<float>;
/// step y direction
std::vector<float>* m_step_dy = new std::vector<float>;
/// step z direction
std::vector<float>* m_step_dz = new std::vector<float>;
/// step length
std::vector<float>* m_step_length = new std::vector<float>;
/// step material x0
std::vector<float>* m_step_X0 = new std::vector<float>;
/// step material l0
std::vector<float>* m_step_L0 = new std::vector<float>;
/// step material A
std::vector<float>* m_step_A = new std::vector<float>;
/// step material Z
std::vector<float>* m_step_Z = new std::vector<float>;
/// step material rho
std::vector<float>* m_step_rho = new std::vector<float>;

/// ID of the surface associated with the step
std::vector<std::uint64_t>* m_sur_id = new std::vector<std::uint64_t>;
/// x position of the center of the surface associated with the step
std::vector<float>* m_sur_x = new std::vector<float>;
/// y position of the center of the surface associated with the step
std::vector<float>* m_sur_y = new std::vector<float>;
/// z position of the center of the surface associated with the step
std::vector<float>* m_sur_z = new std::vector<float>;
/// path correction when associating material to the given surface
std::vector<float>* m_sur_pathCorrection = new std::vector<float>;
/// The ROOT material track representation
Acts::RootMaterialTrack m_rootMaterialTrack;
};

} // namespace ActsExamples
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "ActsExamples/Framework/ProcessCode.hpp"
#include "ActsExamples/Framework/WriterT.hpp"
#include <Acts/Definitions/Algebra.hpp>
#include <Acts/Plugins/Root/RootMaterialTrack.hpp>
#include <Acts/Propagator/MaterialInteractor.hpp>
#include <Acts/Utilities/Logger.hpp>
#include <ActsExamples/Framework/ProcessCode.hpp>
#include <ActsExamples/Framework/WriterT.hpp>

#include <cstddef>
#include <cstdint>
Expand All @@ -24,6 +25,7 @@

class TFile;
class TTree;

namespace ActsExamples {
struct AlgorithmContext;
} // namespace ActsExamples
Expand Down Expand Up @@ -51,27 +53,15 @@ class RootMaterialTrackWriter
: public WriterT<
std::unordered_map<std::size_t, Acts::RecordedMaterialTrack>> {
public:
struct Config {
struct Config : public Acts::RootMaterialTrack::Config {
/// material collection to write
std::string inputMaterialTracks = "material-tracks";
std::string inputMaterialTracks = "material_tracks";
/// path of the output file
std::string filePath = "";
/// file access mode
std::string fileMode = "RECREATE";
/// name of the output tree
std::string treeName = "material-tracks";

/// Re-calculate total values from individual steps (for cross-checks)
bool recalculateTotals = false;
/// Write aut pre and post step (for G4), otherwise central step position
bool prePostStep = false;
/// Write the surface to which the material step correpond
bool storeSurface = false;
/// Write the volume to which the material step correpond
bool storeVolume = false;
/// Collapse consecutive interactions of a single surface into a single
/// interaction
bool collapseInteractions = false;
std::string treeName = "material_tracks";
};

/// Constructor with
Expand Down Expand Up @@ -109,93 +99,8 @@ class RootMaterialTrackWriter
TFile* m_outputFile = nullptr;
/// The output tree name
TTree* m_outputTree = nullptr;

/// Event identifier.
std::uint32_t m_eventId = 0;

/// start global x
float m_v_x = 0;
/// start global y
float m_v_y = 0;
/// start global z
float m_v_z = 0;
/// start global momentum x
float m_v_px = 0;
/// start global momentum y
float m_v_py = 0;
/// start global momentum z
float m_v_pz = 0;
/// start phi direction
float m_v_phi = 0;
/// start eta direction
float m_v_eta = 0;
/// thickness in X0/L0
float m_tX0 = 0;
/// thickness in X0/L0
float m_tL0 = 0;

/// step x (start) position (optional)
std::vector<float> m_step_sx;
/// step y (start) position (optional)
std::vector<float> m_step_sy;
/// step z (start) position (optional)
std::vector<float> m_step_sz;
/// step x position
std::vector<float> m_step_x;
/// step y position
std::vector<float> m_step_y;
/// step z position
std::vector<float> m_step_z;
/// step r position
std::vector<float> m_step_r;
/// step x (end) position (optional)
std::vector<float> m_step_ex;
/// step y (end) position (optional)
std::vector<float> m_step_ey;
/// step z (end) position (optional)
std::vector<float> m_step_ez;
/// step x direction
std::vector<float> m_step_dx;
/// step y direction
std::vector<float> m_step_dy;
/// step z direction
std::vector<float> m_step_dz;
/// step length
std::vector<float> m_step_length;
/// step material x0
std::vector<float> m_step_X0;
/// step material l0
std::vector<float> m_step_L0;
/// step material A
std::vector<float> m_step_A;
/// step material Z
std::vector<float> m_step_Z;
/// step material rho
std::vector<float> m_step_rho;

/// ID of the surface associated with the step
std::vector<std::uint64_t> m_sur_id;
/// Type of the surface associated with the step
std::vector<std::int32_t> m_sur_type;
/// x position of the surface intersection associated with the step
std::vector<float> m_sur_x;
/// y position of the surface intersection associated with the step
std::vector<float> m_sur_y;
/// z position of the surface intersection associated with the step
std::vector<float> m_sur_z;
/// r of the position of the surface intersection associated with the step
std::vector<float> m_sur_r;
/// the distance to the surface associated with the step
std::vector<float> m_sur_distance;
/// path correction when associating material to the given surface
std::vector<float> m_sur_pathCorrection;
/// Min range of the surface associated with the step
std::vector<float> m_sur_range_min;
/// Max range of the surface associated with the step
std::vector<float> m_sur_range_max;

/// ID of the volume associated with the step
std::vector<std::uint64_t> m_vol_id;
/// The root material track object
Acts::RootMaterialTrack m_rootMaterialTrack;
};

} // namespace ActsExamples
Loading
Loading