26#include <gsl/pointers>
43 template <
typename... COLUMNS>
47 void initTree( TFile& file, std::string
const& algName, std::string name,
48 std::array<std::string,
sizeof...( COLUMNS )>
const& branchNames ) {
50 auto pos = name.rfind(
'/' );
52 m_dir = name.substr( 0, pos );
53 name = name.substr( pos + 1 );
60 m_tree = std::make_unique<TTree>( name.c_str(),
"Tree of Writer Algorithm" ).release();
72 [&](
const auto&... elems ) {
74 ( ...,
m_branchWrappers[index++].setDataPtr(
const_cast<void*
>(
static_cast<const void*
>( &elems ) ) ) );
81 void writeTree( TFile& file, std::string
const& algName ) {
84 if (
m_tree->Write() <= 0 ) {
97 template <std::size_t... Is>
99 std::array<std::string,
sizeof...( COLUMNS )>
const& branchNames )
const {
102 branchNames[Is],
"", algName ) );
114 template <
typename Base>
120 return Base::initialize().
andThen( [
this]() {
123 this->error() <<
"Failed to retrieve TFile." <<
endmsg;
140 template <
typename Signature,
typename Traits_ = Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>>
163 template <
typename... OUTPUTs,
typename... INPUTs,
typename Traits_>
165 :
FileHolder<Gaudi::Functional::Consumer<void( const INPUTs&... ), Traits_>> {
167 using Consumer_t::Consumer_t;
171 this,
"BranchNames", {},
"Names of the tree branches." };
186 m_ntuple.writeTree( *this->file(), this->name() );
187 return Consumer_t::finalize();
198 template <
typename Signature,
typename Traits_ = Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>>
216 template <
typename... OUTPUTs,
typename... INPUTs,
typename Traits_>
217 struct Writer<
std::tuple<OUTPUTs...>( const INPUTs&... ), Traits_>
218 :
SimpleWriter<std::tuple<OUTPUTs...>( const INPUTs&... ), Traits_> {
221 using SimpleWriter_t::SimpleWriter_t;
232 auto transformedData =
transform( inputs... );
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Collection of utilities, which allows to use class std::array as property for Gaudi-components.
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
make_integer_sequence< size_t, _Num > make_index_sequence
constexpr auto data(_Container &__cont) noexcept(noexcept(__cont.data())) -> decltype(__cont.data())
integer_sequence< size_t, _Idx... > index_sequence
const _CharT * c_str() const noexcept
static const size_type npos
constexpr void reserve(size_type __n)
constexpr size_type size() const noexcept
Wrapper around a given NTuple.
void fillTree(std::tuple< COLUMNS... > const &data) const
fills the tree with given data this is safe to be called in the threaded context
std::vector< Gaudi::details::BranchWrapper > m_branchWrappers
void writeTree(TFile &file, std::string const &algName)
void createBranches(std::index_sequence< Is... > const, std::string const &algName, std::array< std::string, sizeof...(COLUMNS)> const &branchNames) const
void initTree(TFile &file, std::string const &algName, std::string name, std::array< std::string, sizeof...(COLUMNS)> const &branchNames)
Implementation of property with value of concrete type.
const ValueType & value() const
GaudiException(std::string Message, std::string Tag, StatusCode Code)
Constructor (1).
Handle to be used in lieu of naked pointers to services.
This class is used for returning status codes from appropriate routines.
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
virtual std::shared_ptr< TFile > getFile(const std::string &identifier)=0
Get a shared pointer to a TFile based on an identifier.
Small class wrapping an algorithm and adding management of a Root File via the FileSvc.
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_fileId
std::shared_ptr< TFile > m_file
ServiceHandle< Gaudi::Interfaces::IFileSvc > m_fileSvc
FileHolder< Gaudi::Functional::Consumer< void(const INPUTs &...), Traits_ > > Consumer_t
Gaudi::Property< std::string > m_ntupleTname
void fillTree(const std::tuple< OUTPUTs... > &data) const
virtual StatusCode initialize() override
virtual StatusCode finalize() override
Wrapper< OUTPUTs... > m_ntuple
Gaudi::Property< std::array< std::string, sizeof...(OUTPUTs)> > m_branchNames
void operator()(const INPUTs &... inputs) const override
virtual std::tuple< OUTPUTs... > transform(const INPUTs &... inputs) const =0
Transform input data to the desired output format.
SimpleWriter< std::tuple< OUTPUTs... >(const INPUTs &...), Traits_ > SimpleWriter_t