16#include <boost/assert/source_location.hpp>
18#include <FairRootManager.h>
21#include <TClonesArray.h>
22#include <TCollection.h>
26#include <fmt/format.h>
31#include <unordered_map>
41 template <
typename InputType>
45 using RawDataType = std::remove_const_t<std::remove_cv_t<InputType>>;
58 void init(
bool is_optional =
false,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
60 auto* ioman = FairRootManager::Instance();
63 throw R3B::runtime_error(fmt::format(
"FairRootManager is nullptr during the initialisation of the "
64 "input data with the branch name \"{}\"",
76 fmt::format(
"The data branch {:?} doesn't exist in the input root file!",
branch_name_));
81 fmt::format(
"Initialisation of the input data with the branch name \"{}\" failed!",
88 [[nodiscard]]
auto get(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const ->
const RawDataType&
94 auto size(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const
102 auto begin(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
105 return data_->cbegin();
107 auto begin(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const
110 return data_->cbegin();
112 auto end(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
115 return data_->cend();
117 auto end(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const
120 return data_->cend();
128 if (
data_ ==
nullptr)
130 throw R3B::runtime_error(fmt::format(
"Input data with the branch name \"{}\" cannot be "
131 "queried without an initialisation!",
138 template <
typename InputType,
139 typename = std::enable_if_t<std::is_base_of_v<TObject, std::remove_const_t<std::remove_cv_t<InputType>>>>>
143 using RawDataType = std::remove_const_t<std::remove_cv_t<InputType>>;
149 void init(
bool is_optional =
false,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
151 auto* ioman = FairRootManager::Instance();
152 if (ioman ==
nullptr)
154 throw R3B::runtime_error(fmt::format(
"FairRootManager is nullptr during the initialisation of the "
155 "input data with the branch name \"{}\"",
161 if (
data_ ==
nullptr)
163 const auto msg = fmt::format(
164 "Input TCA data with the branch name {:?} cannot be retrieved from the input file !",
branch_name_);
167 R3BLOG(warn, msg.c_str());
176 auto read() ->
const std::vector<RawDataType>&
179 if (
data_ ==
nullptr)
185 for (
auto* element : TRangeDynCast<RawDataType>(
data_))
192 [[nodiscard]]
auto size() const -> std::
size_t {
return data_ ==
nullptr ? 0 :
data_->GetEntriesFast(); }
204 if (std::string_view{
data_->GetClass()->GetName() } != InputType::Class_Name())
206 const auto msg = fmt::format(
207 "The type of the retrieved data {:?} is not the same as the type given by the connector class {}!",
208 data_->GetClass()->GetName(),
209 InputType::Class_Name());
212 R3BLOG(warn, msg.c_str());
220#if CPP_STANDARD >= 20
221 template <
typename T>
222 concept CanOutput =
requires(T data) {
223 { data.clear() } -> std::convertible_to<void>;
226 template <CanOutput OutputType>
228 template <
typename OutputType>
233 using RawDataType = std::remove_const_t<std::remove_cv_t<OutputType>>;
254 void init(
bool persistence =
true,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
256 if (
auto* ioman = FairRootManager::Instance(); ioman !=
nullptr)
262 throw R3B::runtime_error(fmt::format(
"FairRootManager is nullptr during the initialisation of the "
263 "output data with the branch name \"{}\"",
275 template <
typename ResetOp>
289 template <
typename ElementType>
292 template <
typename ElementType>
295 template <
typename KeyType,
typename ValueType>
298 template <
typename KeyType,
typename ValueType>
301 template <
typename KeyType,
typename ValueType>
304 template <
typename KeyType,
typename ValueType>
#define R3BLOG(severity, x)
OutputConnector & operator=(const RawDataType &data)
OutputConnector & operator=(OutputConnector &&)=delete
auto operator*() -> RawDataType &
OutputConnector(OutputConnector &&)=delete
OutputConnector(std::string_view branchName)
std::remove_const_t< std::remove_cv_t< OutputType > > RawDataType
auto get_name() const -> const std::string &
auto operator->() -> RawDataType *
~OutputConnector()=default
OutputConnector & operator=(const OutputConnector &other)=delete
auto get_constref() const -> const RawDataType &
auto get() -> RawDataType &
void init(bool persistence=true, const boost::source_location &loc=BOOST_CURRENT_LOCATION)
OutputConnector(const OutputConnector &)=delete
InputConnector< std::vector< ElementType > > InputVectorConnector
OutputConnector< std::map< KeyType, ValueType > > OutputMapConnector
InputConnector< std::map< KeyType, ValueType > > InputMapConnector
OutputConnector< std::unordered_map< KeyType, ValueType > > OutputHashConnector
InputConnector< std::unordered_map< KeyType, ValueType > > InputHashConnector
OutputConnector< std::vector< ElementType > > OutputVectorConnector