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
EDM4hepTrackWriter.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EDM4hepTrackWriter.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/EDM4hep/EDM4hepTrackWriter.hpp
"
10
11
#include "
Acts/Plugins/EDM4hep/EDM4hepUtil.hpp
"
12
#include "
ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp
"
13
14
#include <stdexcept>
15
16
#include <edm4hep/TrackCollection.h>
17
#include <podio/Frame.h>
18
19
namespace
ActsExamples {
20
21
EDM4hepTrackWriter::EDM4hepTrackWriter
(
const
Config
&
config
,
22
Acts::Logging::Level
level
)
23
:
WriterT
<
ConstTrackContainer
>(config.
inputTracks
,
"EDM4hepTrackWriter"
,
24
level),
25
m_cfg
(config),
26
m_writer(config.outputPath) {
27
if
(
m_cfg
.
inputTracks
.empty()) {
28
throw
std::invalid_argument(
"Missing input trajectories collection"
);
29
}
30
}
31
32
ActsExamples::ProcessCode
EDM4hepTrackWriter::finalize
() {
33
m_writer
.finish();
34
35
return
ProcessCode::SUCCESS
;
36
}
37
38
ProcessCode
EDM4hepTrackWriter::writeT
(
const
AlgorithmContext
& context,
39
const
ConstTrackContainer
&
tracks
) {
40
podio::Frame frame{};
41
42
edm4hep::TrackCollection trackCollection;
43
44
for
(
const
auto
& from : tracks) {
45
auto
to = trackCollection.create();
46
Acts::EDM4hepUtil::writeTrack
(context.
geoContext
, from, to,
m_cfg
.
Bz
);
47
}
48
49
frame.put(
std::move
(trackCollection),
m_cfg
.
outputTracks
);
50
51
m_writer
.writeFrame(frame,
"events"
);
52
53
return
ProcessCode::SUCCESS
;
54
}
55
56
}
// namespace ActsExamples
acts
blob
sPHENIX
Examples
Io
EDM4hep
src
EDM4hepTrackWriter.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration