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
EDM4hepMultiTrajectoryWriter.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EDM4hepMultiTrajectoryWriter.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2021 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/EDM4hepMultiTrajectoryWriter.hpp
"
10
11
#include "
ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp
"
12
#include "
ActsExamples/Utilities/Paths.hpp
"
13
#include "
ActsExamples/Validation/TrackClassification.hpp
"
14
15
#include <stdexcept>
16
17
#include <edm4hep/TrackCollection.h>
18
#include <podio/Frame.h>
19
20
namespace
ActsExamples {
21
22
EDM4hepMultiTrajectoryWriter::EDM4hepMultiTrajectoryWriter
(
23
const
EDM4hepMultiTrajectoryWriter::Config
&
config
,
24
Acts::Logging::Level
level
)
25
:
WriterT
<
TrajectoriesContainer
>(config.
inputTrajectories
,
26
"EDM4hepMultiTrajectoryWriter"
, level),
27
m_cfg
(config),
28
m_writer(config.outputPath) {
29
if
(
m_cfg
.
inputTrajectories
.empty()) {
30
throw
std::invalid_argument(
"Missing input trajectories collection"
);
31
}
32
33
if
(
m_cfg
.
inputMeasurementParticlesMap
.empty()) {
34
throw
std::invalid_argument{
"Missing input hit to particle map"
};
35
}
36
37
m_inputMeasurementParticlesMap
.
initialize
(
m_cfg
.
inputMeasurementParticlesMap
);
38
}
39
40
ActsExamples::ProcessCode
EDM4hepMultiTrajectoryWriter::finalize
() {
41
m_writer
.finish();
42
43
return
ProcessCode::SUCCESS
;
44
}
45
46
ProcessCode
EDM4hepMultiTrajectoryWriter::writeT
(
47
const
AlgorithmContext
& context,
48
const
TrajectoriesContainer
& trajectories) {
49
podio::Frame frame{};
50
51
const
auto
& hitParticlesMap =
m_inputMeasurementParticlesMap
(context);
52
53
edm4hep::TrackCollection trackCollection;
54
55
for
(
const
auto
& from : trajectories) {
56
for
(
const
auto
& trackTip : from.tips()) {
57
auto
to = trackCollection.create();
58
EDM4hepUtil::writeTrajectory
(context.
geoContext
,
m_cfg
.
Bz
, from, to,
59
trackTip,
m_cfg
.
particleHypothesis
,
60
hitParticlesMap);
61
}
62
}
63
64
frame.put(
std::move
(trackCollection),
"ActsTracks"
);
65
66
m_writer
.writeFrame(frame,
"events"
);
67
68
return
ProcessCode::SUCCESS
;
69
}
70
71
}
// namespace ActsExamples
acts
blob
sPHENIX
Examples
Io
EDM4hep
src
EDM4hepMultiTrajectoryWriter.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration