ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::MaterialTrackReader Class Reference

Writes out RecordedMaterialTrackCollection to a root file. More...

#include <MaterialTrackReader.h>

Inheritance diagram for ActsTrk::MaterialTrackReader:
Collaboration diagram for ActsTrk::MaterialTrackReader:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode execute () override
virtual StatusCode finalize () override
virtual unsigned cardinality () const override
virtual ~MaterialTrackReader ()
 AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< std::size_t > m_maxEvents {this, "maxEvents", std::numeric_limits<std::size_t>::max()}
 The number of events in the processed.
Gaudi::Property< std::size_t > m_skipEvents {this, "skipEvents", 0ul}
 The number of events in the file to skip.
Gaudi::Property< std::size_t > m_batchSize {this, "batchSize", 1000ul}
 The batch size (number of track per events).
std::size_t m_nTreeEntries {0ul}
 The number of entries in the tree to read.
std::size_t m_currEntry {0ul}
 The current processed tree entry.
std::size_t m_procEvents {0ul}
 The number of processed tree events.
Gaudi::Property< std::vector< std::string > > m_fileNames {this, "FileNames", {}, "The list of input file names"}
 The list of input filenames.
Gaudi::Property< std::string > m_treeName {this, "TreeName", "material-tracks", "The input tree name"}
 The name of the input tree.
Gaudi::Property< bool > m_readCachedSurfaceInformation {this, "ReadCachedSurface", false, "Read surface information for the root file"}
 Read surface information for the root file.
ActsPlugins::RootMaterialTrackIo m_accessor {{false, m_readCachedSurfaceInformation}}
 The read - write payload.
std::unique_ptr< TChain > m_inputChain {}
 The input chain of entries.
SG::WriteHandleKey< RecordedMaterialTrackCollectionm_materialTrackCollectionKey {this, "MaterialTrackCollectionKey", "InputMaterialTracks", "Name of the RecordedMaterialTrackCollection"}
 The RecordedMaterialTrackCollection to write.
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Writes out RecordedMaterialTrackCollection to a root file.

It writes out a MaterialTrack which is usually generated from MaterialTrackRecorder G4UA

Definition at line 31 of file MaterialTrackReader.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ~MaterialTrackReader()

ActsTrk::MaterialTrackReader::~MaterialTrackReader ( )
virtualdefault

Member Function Documentation

◆ AthAlgorithm()

AthAlgorithm::AthAlgorithm ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 51 of file AthAlgorithm.cxx.

25 :
27{
28 // Set up to run AthAlgorithmDHUpdate in sysInitialize before
29 // merging dependency lists. This extends the output dependency
30 // list with any symlinks implied by inheritance relations.
31 m_updateDataHandles =
32 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
34 std::move (m_updateDataHandles));
35}
DataObjIDColl m_extendedExtraObjects
AthCommonDataStore(const std::string &name, T... args)

◆ cardinality()

virtual unsigned ActsTrk::MaterialTrackReader::cardinality ( ) const
inlineoverridevirtual

Definition at line 38 of file MaterialTrackReader.h.

38{ return 1; }

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode ActsTrk::MaterialTrackReader::execute ( )
overridevirtual

Definition at line 82 of file MaterialTrackReader.cxx.

82 {
83 const EventContext& ctx{Gaudi::Hive::currentContext()};
84 // Write to the collection to the EventStore
85 SG::WriteHandle materialTracks{m_materialTrackCollectionKey, ctx};
86
87 // Record the collection once per event if not already there
88 if (!materialTracks.isPresent()) {
89 ATH_CHECK(materialTracks.record(std::make_unique<ActsTrk::RecordedMaterialTrackCollection>()));
90 }
91
93 m_inputChain.reset();
94 return StatusCode::SUCCESS;
95 }
96
97 std::size_t nProcEvents{0ul};
98 std::size_t nCurrentEvt{m_accessor.eventId()};
99
101 ATH_MSG_VERBOSE("Fetched entry "<<m_currEntry<<", eventId: "<<m_accessor.eventId());
102 // get the correspoing entry and read it
103 m_inputChain->GetEntry(m_currEntry);
104 Acts::RecordedMaterialTrack rmTrack = m_accessor.read();
105 m_accessor.eventId();
106
107 ATH_MSG_VERBOSE("Track vertex: " << Amg::toString(rmTrack.first.first)
108 <<", momentum:" << Amg::toString(rmTrack.first.second));
109
110 // filling the collection
111 materialTracks->push_back(std::move(rmTrack));
112 if (nCurrentEvt != m_accessor.eventId()) {
113 ++nProcEvents;
114 ++m_procEvents;
115 nCurrentEvt = m_accessor.eventId();
116 }
117
118 if (m_procEvents >= m_maxEvents) {
119 ATH_MSG_INFO("All "<<m_maxEvents<<" events have been processed");
121 return StatusCode::SUCCESS;
122 }
123
124 if (nProcEvents >=m_batchSize) {
125 ATH_MSG_DEBUG("Batch processing "<<nProcEvents<<" completed. ");
126 break;
127 }
128
129 }
130 return StatusCode::SUCCESS;
131}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
std::unique_ptr< TChain > m_inputChain
The input chain of entries.
Gaudi::Property< std::size_t > m_batchSize
The batch size (number of track per events).
ActsPlugins::RootMaterialTrackIo m_accessor
The read - write payload.
Gaudi::Property< std::size_t > m_maxEvents
The number of events in the processed.
std::size_t m_nTreeEntries
The number of entries in the tree to read.
SG::WriteHandleKey< RecordedMaterialTrackCollection > m_materialTrackCollectionKey
The RecordedMaterialTrackCollection to write.
std::size_t m_currEntry
The current processed tree entry.
std::size_t m_procEvents
The number of processed tree events.
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
unsigned long ul

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}

◆ finalize()

StatusCode ActsTrk::MaterialTrackReader::finalize ( )
overridevirtual

Definition at line 72 of file MaterialTrackReader.cxx.

72 {
73 if (m_inputChain) {
74 ATH_MSG_ERROR("Not all entries / events have been processed. Processed entries: "
75 <<(m_currEntry+ 1)<<"/"<<m_nTreeEntries<<", processed events: "
76 <<m_procEvents<<"/"<<m_maxEvents.value());
77 }
78 return StatusCode::SUCCESS;
79}
#define ATH_MSG_ERROR(x)

◆ initialize()

StatusCode ActsTrk::MaterialTrackReader::initialize ( )
overridevirtual

Definition at line 16 of file MaterialTrackReader.cxx.

17{
19
20 if (m_fileNames.empty()) {
21 ATH_MSG_ERROR("No input files given... Please check!!");
22 return StatusCode::FAILURE;
23 }
24
25 // set up the input chain
26 m_inputChain = std::make_unique<TChain>(m_treeName.value().c_str());
27
28 // loop over the input files
29 for (const auto& inputFile : m_fileNames) {
30 // add file to the input chain
31 ATH_MSG_DEBUG("Adding File " << inputFile << " to tree '" << m_treeName << "'.");
32 if (!m_inputChain->Add(inputFile.c_str())) {
33 ATH_MSG_ERROR("Failed to load file "<<inputFile);
34 return StatusCode::FAILURE;
35 }
36 }
37
38 // Connect the branches
39 m_accessor.connectForRead(*m_inputChain);
40 // get the number of events, which also loads the tree
41 m_nTreeEntries = m_inputChain->GetEntries();
42
43 if (m_skipEvents >0ul) {
44 std::optional<std::uint32_t> evt{0ul};
45 std::size_t procEvts{0ul};
46 ATH_MSG_DEBUG("Skip "<<m_skipEvents<<" events. ");
48 m_inputChain->GetEntry(m_currEntry);
49 if (!evt) {
50 evt = m_accessor.eventId();
51 } else if ((*evt) != m_accessor.eventId()) {
52 ++procEvts;
53 evt = m_accessor.eventId();
54 }
55 if (procEvts == m_skipEvents) {
56 break;
57 }
58 }
59 ATH_MSG_INFO("Skipped "<<procEvts<<" events. Corresponding to "
60 <<m_currEntry<<" tree entries");
61 }
62 if (!m_nTreeEntries) {
63 ATH_MSG_ERROR("Input does not contain any recorded track");
64 return StatusCode::FAILURE;
65 }
66 ATH_MSG_INFO("Material files contain " << m_nTreeEntries << " entries. Process "
67 <<m_batchSize.value()<<" material events per athena event. Until "
68 <<m_maxEvents.value()<<" events are processed or the tree is finished");
69 return StatusCode::SUCCESS;
70}
Gaudi::Property< std::size_t > m_skipEvents
The number of events in the file to skip.
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.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_WARNING(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_accessor

ActsPlugins::RootMaterialTrackIo ActsTrk::MaterialTrackReader::m_accessor {{false, m_readCachedSurfaceInformation}}
private

The read - write payload.

Definition at line 61 of file MaterialTrackReader.h.

Gaudi::Property< bool > m_readCachedSurfaceInformation
Read surface information for the root file.

◆ m_batchSize

Gaudi::Property<std::size_t> ActsTrk::MaterialTrackReader::m_batchSize {this, "batchSize", 1000ul}
private

The batch size (number of track per events).

Definition at line 47 of file MaterialTrackReader.h.

47{this, "batchSize", 1000ul};

◆ m_currEntry

std::size_t ActsTrk::MaterialTrackReader::m_currEntry {0ul}
private

The current processed tree entry.

Definition at line 51 of file MaterialTrackReader.h.

51{0ul};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_fileNames

Gaudi::Property<std::vector<std::string> > ActsTrk::MaterialTrackReader::m_fileNames {this, "FileNames", {}, "The list of input file names"}
private

The list of input filenames.

Definition at line 55 of file MaterialTrackReader.h.

55{this, "FileNames", {}, "The list of input file names"};

◆ m_inputChain

std::unique_ptr<TChain> ActsTrk::MaterialTrackReader::m_inputChain {}
private

The input chain of entries.

Definition at line 63 of file MaterialTrackReader.h.

63{};

◆ m_materialTrackCollectionKey

SG::WriteHandleKey<RecordedMaterialTrackCollection> ActsTrk::MaterialTrackReader::m_materialTrackCollectionKey {this, "MaterialTrackCollectionKey", "InputMaterialTracks", "Name of the RecordedMaterialTrackCollection"}
private

The RecordedMaterialTrackCollection to write.

Definition at line 65 of file MaterialTrackReader.h.

65{this, "MaterialTrackCollectionKey", "InputMaterialTracks", "Name of the RecordedMaterialTrackCollection"};

◆ m_maxEvents

Gaudi::Property<std::size_t> ActsTrk::MaterialTrackReader::m_maxEvents {this, "maxEvents", std::numeric_limits<std::size_t>::max()}
private

The number of events in the processed.

Definition at line 43 of file MaterialTrackReader.h.

43{this, "maxEvents", std::numeric_limits<std::size_t>::max()};

◆ m_nTreeEntries

std::size_t ActsTrk::MaterialTrackReader::m_nTreeEntries {0ul}
private

The number of entries in the tree to read.

Definition at line 49 of file MaterialTrackReader.h.

49{0ul};

◆ m_procEvents

std::size_t ActsTrk::MaterialTrackReader::m_procEvents {0ul}
private

The number of processed tree events.

Definition at line 53 of file MaterialTrackReader.h.

53{0ul};

◆ m_readCachedSurfaceInformation

Gaudi::Property<bool> ActsTrk::MaterialTrackReader::m_readCachedSurfaceInformation {this, "ReadCachedSurface", false, "Read surface information for the root file"}
private

Read surface information for the root file.

Definition at line 59 of file MaterialTrackReader.h.

59{this, "ReadCachedSurface", false, "Read surface information for the root file"};

◆ m_skipEvents

Gaudi::Property<std::size_t> ActsTrk::MaterialTrackReader::m_skipEvents {this, "skipEvents", 0ul}
private

The number of events in the file to skip.

Definition at line 45 of file MaterialTrackReader.h.

45{this, "skipEvents", 0ul};

◆ m_treeName

Gaudi::Property<std::string> ActsTrk::MaterialTrackReader::m_treeName {this, "TreeName", "material-tracks", "The input tree name"}
private

The name of the input tree.

Definition at line 57 of file MaterialTrackReader.h.

57{this, "TreeName", "material-tracks", "The input tree name"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: