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
WriterT.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file WriterT.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2017 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
12
13
#pragma once
14
15
#include "
ActsExamples/Framework/DataHandle.hpp
"
16
#include "
ActsExamples/Framework/IWriter.hpp
"
17
#include "
ActsExamples/Framework/WhiteBoard.hpp
"
18
#include <
Acts/Utilities/Logger.hpp
>
19
20
#include <limits>
21
#include <memory>
22
#include <string>
23
24
namespace
ActsExamples {
25
27
constexpr
double
NaNdouble
= std::numeric_limits<double>::quiet_NaN();
28
constexpr
float
NaNfloat
= std::numeric_limits<float>::quiet_NaN();
29
constexpr
float
NaNint
= std::numeric_limits<int>::quiet_NaN();
30
46
template
<
typename
write_data_t>
47
class
WriterT
:
public
IWriter
{
48
public
:
52
WriterT
(
std::string
objectName,
std::string
writerName,
53
Acts::Logging::Level
level
);
54
56
std::string
name
()
const override
;
57
59
ProcessCode
write
(
const
AlgorithmContext
& context)
override
;
60
62
ProcessCode
finalize
()
override
;
63
64
protected
:
70
virtual
ProcessCode
writeT
(
const
AlgorithmContext
& context,
71
const
write_data_t&
t
) = 0;
72
73
const
Acts::Logger
&
logger
()
const
{
return
*
m_logger
; }
74
75
private
:
76
std::string
m_objectName
;
77
std::string
m_writerName
;
78
std::unique_ptr<const Acts::Logger>
m_logger
;
79
80
ReadDataHandle<write_data_t>
m_inputHandle
{
this
,
"InputHandle"
};
81
};
82
83
}
// namespace ActsExamples
84
85
template
<
typename
write_data_t>
86
ActsExamples::WriterT<write_data_t>::WriterT
(
std::string
objectName,
87
std::string
writerName,
88
Acts::Logging::Level
level
)
89
: m_objectName(std::
move
(objectName)),
90
m_writerName(std::
move
(writerName)),
91
m_logger
(Acts::
getDefaultLogger
(m_writerName, level)) {
92
if
(
m_objectName
.empty()) {
93
throw
std::invalid_argument(
"Missing input collection"
);
94
}
else
if
(
m_writerName
.empty()) {
95
throw
std::invalid_argument(
"Missing writer name"
);
96
}
97
98
m_inputHandle
.
initialize
(
m_objectName
);
99
}
100
101
template
<
typename
write_data_t>
102
inline
std::string
ActsExamples::WriterT<write_data_t>::name
()
const
{
103
return
m_writerName;
104
}
105
106
template
<
typename
write_data_t>
107
inline
ActsExamples::ProcessCode
108
ActsExamples::WriterT<write_data_t>::finalize
() {
109
return
ProcessCode::SUCCESS
;
110
}
111
112
template
<
typename
write_data_t>
113
inline
ActsExamples::ProcessCode
ActsExamples::WriterT<write_data_t>::write
(
114
const
AlgorithmContext
& context) {
115
return
writeT(context, m_inputHandle(context));
116
}
acts
blob
sPHENIX
Examples
Framework
include
ActsExamples
Framework
WriterT.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:38
using
1.8.2 with
sPHENIX GitHub integration