6#include "GaudiKernel/IInterface.h"
29 return StatusCode::FAILURE;
33 m_inputChain = std::make_unique<TChain>(
m_treeName.value().c_str());
38 m_inputChain->Add(inputFile.c_str());
46 std::size_t nentries = m_inputChain->GetEntries();
47 m_events =
static_cast<std::size_t
>(m_inputChain->GetMaximum(
"event_id") + 1);
51 <<
" events this corresponds to a batch size of: " <<
m_batchSize);
53 return StatusCode::SUCCESS;
59 if (m_inputChain ==
nullptr) {
61 return StatusCode::SUCCESS;
65 ATH_MSG_INFO(
"Maximum number of events in file reached, nothing to be done...");
66 return StatusCode::SUCCESS;
74 auto coll = std::make_unique<ActsTrk::RecordedMaterialTrackCollection>();
79 auto* coll = materialTracks.
ptr();
81 ATH_MSG_ERROR(
"RecordedMaterialTrackCollection ptr() is null for key "
83 return StatusCode::FAILURE;
92 ATH_MSG_DEBUG(
"Reading event / entry (in batch) : " << ctx.evt() <<
" / " << entry <<
"(" <<
index <<
")");
95 m_inputChain->GetEntry(entry);
96 Acts::RecordedMaterialTrack rmTrack =
m_accessor.read();
102 coll->push_back(std::move(rmTrack));
105 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual StatusCode execute(const EventContext &ctx) const override
ActsPlugins::RootMaterialTrackIo m_accessor
The read - write payload.
virtual StatusCode initialize() override
MaterialTrackReader(const std::string &name, ISvcLocator *pSvcLocator)
std::mutex m_readMutex
mutex used to protect multi-threaded reads
Gaudi::Property< std::vector< std::string > > m_fileNames
The list of input filenames.
Gaudi::Property< std::string > m_treeName
The name of the input tree.
std::size_t m_events
The number of events.
virtual ~MaterialTrackReader()
std::size_t m_batchSize
The batch size (number of track per events)
SG::WriteHandleKey< RecordedMaterialTrackCollection > m_materialTrackCollectionKey
The RecordedMaterialTrackCollection to write.
Gaudi::Property< bool > m_readCachedSurfaceInformation
Read surface information for the root file.
An algorithm that can be simultaneously executed in multiple threads.
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.