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
HepMC3Writer.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file HepMC3Writer.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2018-2020 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/HepMC3/HepMC3Writer.hpp
"
10
11
#include "
ActsExamples/Utilities/Paths.hpp
"
12
13
ActsExamples::HepMC3AsciiWriter::HepMC3AsciiWriter
(
const
Config
&
config
,
14
Acts::Logging::Level
level
)
15
:
WriterT
(config.inputEvents,
"HepMC3EventWriter"
, level),
m_cfg
(config) {
16
if
(
m_cfg
.
outputStem
.empty()) {
17
throw
std::invalid_argument(
"Missing output stem file name"
);
18
}
19
}
20
21
ActsExamples::ProcessCode
ActsExamples::HepMC3AsciiWriter::writeT
(
22
const
ActsExamples::AlgorithmContext
& ctx,
23
const
std::vector<HepMC3::GenEvent>&
events
) {
24
auto
path
=
perEventFilepath
(
m_cfg
.outputDir,
m_cfg
.outputStem +
".hepmc3"
,
25
ctx.
eventNumber
);
26
27
ACTS_DEBUG
(
"Attempting to write event to "
<<
path
);
28
HepMC3::WriterAscii
writer
(
path
);
29
30
for
(
const
auto
&
event
: events) {
31
writer.write_event(
event
);
32
if
(writer.failed()) {
33
return
ActsExamples::ProcessCode::ABORT;
34
}
35
}
36
37
writer.close();
38
return
ActsExamples::ProcessCode::SUCCESS
;
39
}
acts
blob
sPHENIX
Examples
Io
HepMC3
src
HepMC3Writer.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration