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
CsvTrackParameterReader.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file CsvTrackParameterReader.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2022 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/CsvTrackParameterReader.hpp
"
10
11
#include "
Acts/Definitions/Algebra.hpp
"
12
#include "
Acts/Definitions/TrackParametrization.hpp
"
13
#include "
Acts/Surfaces/PerigeeSurface.hpp
"
14
#include "
Acts/Surfaces/Surface.hpp
"
15
#include "
ActsExamples/EventData/Track.hpp
"
16
#include "
ActsExamples/Framework/AlgorithmContext.hpp
"
17
#include "
ActsExamples/Utilities/Paths.hpp
"
18
19
#include <algorithm>
20
#include <stdexcept>
21
#include <string>
22
23
#include <dfe/dfe_io_dsv.hpp>
24
25
#include "
CsvOutputData.hpp
"
26
27
ActsExamples::CsvTrackParameterReader::CsvTrackParameterReader
(
28
const
ActsExamples::CsvTrackParameterReader::Config
&
config
,
29
Acts::Logging::Level
level
)
30
:
m_cfg
(config),
31
m_eventsRange(
32
determineEventFilesRange
(
m_cfg
.
inputDir
,
m_cfg
.inputStem +
".csv"
)),
33
m_logger
(Acts::
getDefaultLogger
(
"CsvTrackParameterReader"
, level)) {
34
if
(
m_cfg
.
inputStem
.empty()) {
35
throw
std::invalid_argument(
"Missing input filename stem"
);
36
}
37
if
(
m_cfg
.
outputTrackParameters
.empty()) {
38
throw
std::invalid_argument(
"Missing output collection"
);
39
}
40
41
m_outputTrackParameters
.
initialize
(
m_cfg
.
outputTrackParameters
);
42
}
43
44
std::string
45
ActsExamples::CsvTrackParameterReader::CsvTrackParameterReader::name
()
const
{
46
return
"CsvTrackParameterReader"
;
47
}
48
49
std::pair<size_t, size_t>
50
ActsExamples::CsvTrackParameterReader::availableEvents
()
const
{
51
return
m_eventsRange;
52
}
53
54
ActsExamples::ProcessCode
ActsExamples::CsvTrackParameterReader::read
(
55
const
ActsExamples::AlgorithmContext
& ctx) {
56
TrackParametersContainer
trackParameters;
57
58
auto
surface
= Acts::Surface::makeShared<Acts::PerigeeSurface>(
59
Acts::Vector3
(
m_cfg
.beamspot[0],
m_cfg
.beamspot[1],
m_cfg
.beamspot[2]));
60
61
auto
path
=
perEventFilepath
(
m_cfg
.inputDir,
m_cfg
.inputStem +
".csv"
,
62
ctx.
eventNumber
);
63
dfe::NamedTupleCsvReader<TrackParameterData>
reader
(path);
64
TrackParameterData
d{};
65
66
while
(reader.read(d)) {
67
Acts::BoundVector
params = Acts::BoundVector::Zero();
68
params[
Acts::eBoundLoc0
] = d.d0;
69
params[
Acts::eBoundLoc1
] = d.z0;
70
params[
Acts::eBoundPhi
] = d.phi;
71
params[
Acts::eBoundTheta
] = d.theta;
72
params[
Acts::eBoundQOverP
] = d.qop;
73
74
Acts::BoundSquareMatrix
cov
= Acts::BoundSquareMatrix::Zero();
75
cov
(
Acts::eBoundLoc0
,
Acts::eBoundLoc0
) = d.var_d0;
76
cov
(
Acts::eBoundLoc1
,
Acts::eBoundLoc1
) = d.var_z0;
77
cov
(
Acts::eBoundPhi
,
Acts::eBoundPhi
) = d.var_phi;
78
cov
(
Acts::eBoundTheta
,
Acts::eBoundTheta
) = d.var_theta;
79
cov
(
Acts::eBoundQOverP
,
Acts::eBoundQOverP
) = d.var_qop;
80
cov
(
Acts::eBoundTime
,
Acts::eBoundTime
) = 1;
81
82
cov
(
Acts::eBoundLoc0
,
Acts::eBoundLoc1
) = d.cov_d0z0;
83
cov
(
Acts::eBoundLoc0
,
Acts::eBoundPhi
) = d.cov_d0phi;
84
cov
(
Acts::eBoundLoc0
,
Acts::eBoundTheta
) = d.cov_d0theta;
85
cov
(
Acts::eBoundLoc0
,
Acts::eBoundQOverP
) = d.cov_d0qop;
86
87
cov
(
Acts::eBoundLoc1
,
Acts::eBoundLoc0
) = d.cov_z0d0;
88
cov
(
Acts::eBoundLoc1
,
Acts::eBoundPhi
) = d.cov_z0phi;
89
cov
(
Acts::eBoundLoc1
,
Acts::eBoundTheta
) = d.cov_z0theta;
90
cov
(
Acts::eBoundLoc1
,
Acts::eBoundQOverP
) = d.cov_z0qop;
91
92
cov
(
Acts::eBoundPhi
,
Acts::eBoundLoc0
) = d.cov_phid0;
93
cov
(
Acts::eBoundPhi
,
Acts::eBoundLoc1
) = d.cov_phiz0;
94
cov
(
Acts::eBoundPhi
,
Acts::eBoundTheta
) = d.cov_phitheta;
95
cov
(
Acts::eBoundPhi
,
Acts::eBoundQOverP
) = d.cov_phiqop;
96
97
cov
(
Acts::eBoundTheta
,
Acts::eBoundLoc0
) = d.cov_thetad0;
98
cov
(
Acts::eBoundTheta
,
Acts::eBoundLoc1
) = d.cov_thetaz0;
99
cov
(
Acts::eBoundTheta
,
Acts::eBoundPhi
) = d.cov_thetaphi;
100
cov
(
Acts::eBoundTheta
,
Acts::eBoundQOverP
) = d.cov_thetaqop;
101
102
cov
(
Acts::eBoundQOverP
,
Acts::eBoundLoc0
) = d.cov_qopd0;
103
cov
(
Acts::eBoundQOverP
,
Acts::eBoundLoc1
) = d.cov_qopz0;
104
cov
(
Acts::eBoundQOverP
,
Acts::eBoundPhi
) = d.cov_qopphi;
105
cov
(
Acts::eBoundQOverP
,
Acts::eBoundTheta
) = d.cov_qoptheta;
106
107
// TODO we do not have a hypothesis at hand here. defaulting to pion
108
trackParameters.emplace_back(
surface
, params, cov,
109
Acts::ParticleHypothesis::pion
());
110
}
111
112
m_outputTrackParameters(ctx,
std::move
(trackParameters));
113
114
return
ProcessCode::SUCCESS
;
115
}
acts
blob
sPHENIX
Examples
Io
Csv
src
CsvTrackParameterReader.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration