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
EDM4hepParticleWriter.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EDM4hepParticleWriter.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/EDM4hep/EDM4hepParticleWriter.hpp
"
10
11
#include "
Acts/Definitions/Units.hpp
"
12
#include "
ActsExamples/Framework/WhiteBoard.hpp
"
13
#include "
ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp
"
14
#include "
ActsExamples/Utilities/Paths.hpp
"
15
16
#include <stdexcept>
17
18
#include <edm4hep/MCParticle.h>
19
#include <edm4hep/MCParticleCollection.h>
20
#include <podio/Frame.h>
21
22
namespace
ActsExamples {
23
24
EDM4hepParticleWriter::EDM4hepParticleWriter
(
25
const
EDM4hepParticleWriter::Config
&
cfg
,
Acts::Logging::Level
lvl)
26
:
WriterT
(cfg.
inputParticles
,
"EDM4hepParticleWriter"
, lvl),
27
m_cfg
(cfg),
28
m_writer(cfg.outputPath) {
29
ACTS_VERBOSE
(
"Created output file "
<< cfg.
outputPath
);
30
31
if
(
m_cfg
.
inputParticles
.empty()) {
32
throw
std::invalid_argument(
"Missing particles input collection"
);
33
}
34
}
35
36
ActsExamples::ProcessCode
EDM4hepParticleWriter::finalize
() {
37
m_writer
.finish();
38
39
return
ProcessCode::SUCCESS
;
40
}
41
42
ProcessCode
EDM4hepParticleWriter::writeT
(
43
const
AlgorithmContext
&
/*ctx*/
,
const
SimParticleContainer
&
particles
) {
44
podio::Frame frame;
45
46
edm4hep::MCParticleCollection mcParticleCollection;
47
48
for
(
const
auto
&
particle
: particles) {
49
auto
p
= mcParticleCollection->create();
50
EDM4hepUtil::writeParticle
(
particle
,
p
);
51
}
52
53
frame.put(
std::move
(mcParticleCollection),
m_cfg
.
outputParticles
);
54
55
m_writer
.writeFrame(frame,
"events"
);
56
57
return
ProcessCode::SUCCESS
;
58
}
59
60
}
// namespace ActsExamples
acts
blob
sPHENIX
Examples
Io
EDM4hep
src
EDM4hepParticleWriter.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration