16#include <boost/assert/source_location.hpp>
18#include <FairRootManager.h>
21#include <TClonesArray.h>
22#include <TCollection.h>
30#include <unordered_map>
36 template <
typename InputType>
40 using RawDataType = std::remove_const_t<std::remove_cv_t<InputType>>;
53 void init(
bool is_optional =
false,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
55 auto* ioman = FairRootManager::Instance();
58 throw R3B::runtime_error(fmt::format(
"FairRootManager is nullptr during the initialisation of the "
59 "input data with the branch name \"{}\"",
71 fmt::format(
"The data branch {:?} doesn't exist in the input root file!",
branch_name_));
76 fmt::format(
"Initialisation of the input data with the branch name \"{}\" failed!",
83 [[nodiscard]]
auto get(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const ->
const RawDataType&
89 auto size(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const
97 auto begin(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
100 return data_->cbegin();
102 auto begin(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const
105 return data_->cbegin();
107 auto end(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
110 return data_->cend();
112 auto end(
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
const
115 return data_->cend();
123 if (
data_ ==
nullptr)
125 throw R3B::runtime_error(fmt::format(
"Input data with the branch name \"{}\" cannot be "
126 "queried without an initialisation!",
133 template <
typename InputType,
134 typename = std::enable_if_t<std::is_base_of_v<TObject, std::remove_const_t<std::remove_cv_t<InputType>>>>>
138 using RawDataType = std::remove_const_t<std::remove_cv_t<InputType>>;
144 void init(
bool is_optional =
false,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
146 auto* ioman = FairRootManager::Instance();
147 if (ioman ==
nullptr)
149 throw R3B::runtime_error(fmt::format(
"FairRootManager is nullptr during the initialisation of the "
150 "input data with the branch name \"{}\"",
156 if (
data_ ==
nullptr)
158 const auto msg = fmt::format(
159 "Input TCA data with the branch name {:?} cannot be retrieved from the input file !",
branch_name_);
162 R3BLOG(warn, msg.c_str());
171 auto read() ->
const std::vector<RawDataType>&
174 if (
data_ ==
nullptr)
180 for (
auto* element : TRangeDynCast<RawDataType>(
data_))
187 [[nodiscard]]
auto size() const -> std::
size_t {
return data_ ==
nullptr ? 0 :
data_->GetEntriesFast(); }
198 if (std::string_view{
data_->GetClass()->GetName() } != InputType::Class_Name())
200 const auto msg = fmt::format(
201 "The type of the retrieved data {:?} is not the same as the type given by the connector class {}!",
202 data_->GetClass()->GetName(),
203 InputType::Class_Name());
206 R3BLOG(warn, msg.c_str());
214 template <
typename OutputType>
218 using RawDataType = std::remove_const_t<std::remove_cv_t<OutputType>>;
231 void init(
bool persistance =
true,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
233 if (
auto* ioman = FairRootManager::Instance(); ioman !=
nullptr)
239 throw R3B::runtime_error(fmt::format(
"FairRootManager is nullptr during the initialisation of the "
240 "output data with the branch name \"{}\"",
251 template <
typename ResetOp>
265 template <
typename ElementType>
268 template <
typename ElementType>
271 template <
typename KeyType,
typename ValueType>
274 template <
typename KeyType,
typename ValueType>
277 template <
typename KeyType,
typename ValueType>
280 template <
typename KeyType,
typename ValueType>
#define R3BLOG(severity, x)
OutputConnector & operator=(OutputConnector &&)=delete
OutputConnector(OutputConnector &&)=delete
OutputConnector(std::string_view branchName)
std::remove_const_t< std::remove_cv_t< OutputType > > RawDataType
void init(bool persistance=true, const boost::source_location &loc=BOOST_CURRENT_LOCATION)
~OutputConnector()=default
OutputConnector & operator=(const OutputConnector &other)=delete
auto get_constref() const -> const RawDataType &
auto get() -> RawDataType &
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