Skip to content

Commit

Permalink
first shot
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger committed Jan 21, 2025
1 parent 2b8572b commit 9f4cafb
Show file tree
Hide file tree
Showing 10 changed files with 765 additions and 579 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ if(ACTS_BUILD_PLUGIN_TGEO)
${_acts_root_version}
REQUIRED
CONFIG
COMPONENTS Geom Graf
COMPONENTS Geom Graf RIO ROOTDataFrame
)
check_root_compatibility()
endif()
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";
/// name of the output tree
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,11 @@

class TFile;
class TTree;

namespace ROOT::Experimental {
class RNTupleWriter;
} // namespace ROOT::Experimental

namespace ActsExamples {
struct AlgorithmContext;
} // namespace ActsExamples
Expand Down Expand Up @@ -51,7 +57,7 @@ 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";
/// path of the output file
Expand All @@ -60,18 +66,8 @@ class RootMaterialTrackWriter
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;
/// Write as RNTuple
bool rnTuple = false;
};

/// Constructor with
Expand Down Expand Up @@ -109,93 +105,10 @@ 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;
/// Experimental RNTuple writer
std::unique_ptr<ROOT::Experimental::RNTupleWriter> m_rntWriter = nullptr;
/// The root material track object
Acts::RootMaterialTrack m_rootMaterialTrack;
};

} // namespace ActsExamples
Loading

0 comments on commit 9f4cafb

Please sign in to comment.