Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
CsvProtoTrackWriter.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file CsvProtoTrackWriter.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2023 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#include "
ActsExamples/Io/Csv/CsvProtoTrackWriter.hpp
"
10
11
#include "
Acts/Definitions/Units.hpp
"
12
#include "
Acts/Surfaces/Surface.hpp
"
13
#include "
Acts/Utilities/Intersection.hpp
"
14
#include "
ActsExamples/EventData/Index.hpp
"
15
#include "
ActsExamples/EventData/SimSpacePoint.hpp
"
16
#include "
ActsExamples/Framework/WhiteBoard.hpp
"
17
#include "
ActsExamples/Utilities/EventDataTransforms.hpp
"
18
#include "
ActsExamples/Utilities/Paths.hpp
"
19
#include "
ActsExamples/Utilities/Range.hpp
"
20
21
#include <ios>
22
#include <optional>
23
#include <stdexcept>
24
25
#include <dfe/dfe_io_dsv.hpp>
26
27
#include "
CsvOutputData.hpp
"
28
29
ActsExamples::CsvProtoTrackWriter::CsvProtoTrackWriter
(
30
const
ActsExamples::CsvProtoTrackWriter::Config
&
config
,
31
Acts::Logging::Level
level
)
32
:
WriterT
(config.inputPrototracks,
"CsvProtoTrackWriter"
, level),
33
m_cfg
(config) {
34
m_inputSpacepoints
.
initialize
(
m_cfg
.
inputSpacepoints
);
35
}
36
37
ActsExamples::CsvProtoTrackWriter::~CsvProtoTrackWriter
() =
default
;
38
39
ActsExamples::ProcessCode
ActsExamples::CsvProtoTrackWriter::finalize
() {
40
// Write the tree
41
return
ProcessCode::SUCCESS
;
42
}
43
44
ActsExamples::ProcessCode
ActsExamples::CsvProtoTrackWriter::writeT
(
45
const
AlgorithmContext
& ctx,
const
ProtoTrackContainer
&
tracks
) {
46
const
auto
& spacepoints = m_inputSpacepoints(ctx);
47
48
// Open per-event file for all components
49
std::string
path
=
50
perEventFilepath
(
m_cfg
.outputDir,
"prototracks.csv"
, ctx.
eventNumber
);
51
52
dfe::NamedTupleCsvWriter<ProtoTrackData>
writer
(path,
m_cfg
.outputPrecision);
53
54
for
(
auto
trackId = 0ul; trackId < tracks.size(); ++trackId) {
55
for
(
Index
measurmentId : tracks[trackId]) {
56
const
auto
spr =
findSpacePointForIndex
(measurmentId, spacepoints);
57
if
(spr ==
nullptr
) {
58
ACTS_WARNING
(
"Could not convert index "
<< measurmentId
59
<<
" to spacepoint"
);
60
continue
;
61
}
62
const
auto
& sp = *spr;
63
writer.append({trackId, measurmentId, sp.x(), sp.y(), sp.z()});
64
}
65
}
66
return
ActsExamples::ProcessCode::SUCCESS
;
67
}
acts
blob
sPHENIX
Examples
Io
Csv
src
CsvProtoTrackWriter.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration