ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsMaterial
src
MaterialTrackWriter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MaterialTrackWriter.h
"
6
#include "
ActsGeometryInterfaces/GeometryContext.h
"
7
#include "GaudiKernel/IInterface.h"
8
9
#include <format>
10
#include "TTree.h"
11
#include "TFile.h"
12
13
14
namespace
ActsTrk
{
15
MaterialTrackWriter::~MaterialTrackWriter
() =
default
;
16
17
StatusCode
MaterialTrackWriter::initialize
() {
18
// Check the input collection key
19
ATH_CHECK
(
m_materialTrackCollectionKey
.initialize());
20
21
m_outputTree
=
new
TTree(
m_treeName
.value().c_str(),
"TTree from MaterialTrackWriter"
);
22
Config_t
cfg{};
23
cfg.prePostStepInfo =
m_prePostStep
;
24
cfg.surfaceInfo =
m_storeSurface
;
25
cfg.volumeInfo =
m_storeVolume
;
26
cfg.recalculateTotals =
m_recalculateTotals
;
27
28
m_accessor
= ActsPlugins::RootMaterialTrackIo{cfg};
29
m_accessor
.connectForWrite(*
m_outputTree
);
30
ATH_CHECK
(
histSvc
()->regTree(std::format(
"/{:}/{:}"
,
m_outStream
.value(),
m_treeName
.value()),
m_outputTree
));
31
ATH_CHECK
(
m_ctxProvider
.initialize(
m_useTrackingGeo
));
32
33
return
StatusCode::SUCCESS;
34
}
35
36
StatusCode
MaterialTrackWriter::execute
(
const
EventContext& ctx) {
37
// Get the collection from storegate
38
const
RecordedMaterialTrackCollection
* materialTracks{
nullptr
};
39
ATH_CHECK
(
SG::get
(materialTracks,
m_materialTrackCollectionKey
, ctx));
40
41
const
Acts::GeometryContext geoContext =
m_useTrackingGeo
?
42
m_ctxProvider
.getGeometryContext(ctx)
43
: Acts::GeometryContext::dangerouslyDefaultConstruct();
44
std::unique_lock
lock
{
m_writeMutex
};
45
46
// Loop over the material tracks and write them out
47
for
(
const
auto
& materialTrack : *materialTracks) {
48
// write & fill
49
m_accessor
.write(geoContext, ctx.evt(), materialTrack);
50
m_outputTree
->Fill();
51
}
52
53
// return success
54
return
StatusCode::SUCCESS;
55
}
56
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
GeometryContext.h
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
MaterialTrackWriter.h
ActsTrk::MaterialTrackWriter::m_outStream
Gaudi::Property< std::string > m_outStream
The output file name.
Definition
MaterialTrackWriter.h:43
ActsTrk::MaterialTrackWriter::initialize
virtual StatusCode initialize() override
Definition
MaterialTrackWriter.cxx:17
ActsTrk::MaterialTrackWriter::m_ctxProvider
ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
Definition
MaterialTrackWriter.h:63
ActsTrk::MaterialTrackWriter::m_treeName
Gaudi::Property< std::string > m_treeName
The output file name.
Definition
MaterialTrackWriter.h:45
ActsTrk::MaterialTrackWriter::m_recalculateTotals
Gaudi::Property< bool > m_recalculateTotals
Re-calculate total values from individual steps (for cross-checks).
Definition
MaterialTrackWriter.h:53
ActsTrk::MaterialTrackWriter::m_useTrackingGeo
Gaudi::Property< bool > m_useTrackingGeo
Definition
MaterialTrackWriter.h:58
ActsTrk::MaterialTrackWriter::m_materialTrackCollectionKey
SG::ReadHandleKey< RecordedMaterialTrackCollection > m_materialTrackCollectionKey
The RecordedMaterialTrackCollection to read.
Definition
MaterialTrackWriter.h:56
ActsTrk::MaterialTrackWriter::Config_t
ActsPlugins::RootMaterialTrackIo::Config Config_t
Definition
MaterialTrackWriter.h:64
ActsTrk::MaterialTrackWriter::~MaterialTrackWriter
virtual ~MaterialTrackWriter()
ActsTrk::MaterialTrackWriter::m_storeVolume
Gaudi::Property< bool > m_storeVolume
Write the volume to which the material step correpond.
Definition
MaterialTrackWriter.h:49
ActsTrk::MaterialTrackWriter::m_accessor
ActsPlugins::RootMaterialTrackIo m_accessor
The read - write payload.
Definition
MaterialTrackWriter.h:66
ActsTrk::MaterialTrackWriter::m_storeSurface
Gaudi::Property< bool > m_storeSurface
Write the surface to which the material step correpond.
Definition
MaterialTrackWriter.h:47
ActsTrk::MaterialTrackWriter::m_outputTree
TTree * m_outputTree
The output file and tree.
Definition
MaterialTrackWriter.h:69
ActsTrk::MaterialTrackWriter::m_writeMutex
std::mutex m_writeMutex
mutex used to protect multi-threaded writes
Definition
MaterialTrackWriter.h:41
ActsTrk::MaterialTrackWriter::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
MaterialTrackWriter.cxx:36
ActsTrk::MaterialTrackWriter::m_prePostStep
Gaudi::Property< bool > m_prePostStep
Write out pre and post step (for G4), otherwise central step position.
Definition
MaterialTrackWriter.h:51
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition
AthHistogramAlgorithm.h:113
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition
MdtCalibInput.h:31
ActsTrk::RecordedMaterialTrackCollection
std::vector< Acts::RecordedMaterialTrack > RecordedMaterialTrackCollection
Definition
RecordedMaterialTrackCollection.h:14
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Generated on
for ATLAS Offline Software by
1.17.0