29#include "../../Core/test/TestClasses.h"
54 if (mChecks.size() > 0) {
55 throw std::runtime_error(
"Workflow error: Checks have not been executed");
67 for (
auto const&
check : mChecks) {
68 TFile*
file = TFile::Open(
check.fileName.c_str());
69 if (
file ==
nullptr) {
70 setError(std::string(
"missing file ") +
check.fileName.c_str());
73 TTree*
tree =
reinterpret_cast<TTree*
>(
file->GetObjectChecked(
"testtree",
"TTree"));
74 if (
tree ==
nullptr) {
75 setError(std::string(
"can not find tree 'testtree' in file ") +
check.fileName.c_str());
76 }
else if (
tree->GetEntries() !=
check.nEntries) {
78 }
else if (
tree->GetNbranches() !=
check.nBranches) {
82 std::filesystem::remove(
check.fileName.c_str());
85 if (mErrorMessage.empty() ==
false) {
86 throw std::runtime_error(mErrorMessage);
98 if (mErrorMessage.empty()) {
106 mErrorMessage.clear();
110 std::vector<Attributes> mChecks;
111 std::string mErrorMessage;
117 hook = [](
const char* idstring) {
121 if (idstring ==
nullptr) {
131static constexpr int sTreeSize = 10;
135 auto counter = std::make_shared<int>();
144 pc.outputs().snapshot(
OutputRef{
"output", 0},
a);
145 pc.outputs().snapshot(
OutputRef{
"output", 1},
a);
146 int& metadata = pc.outputs().make<
int>(
Output{
"TST",
"METADATA", 0});
155 return processingFct;
159 {
OutputSpec{{
"output"},
"TST",
"SOMEOBJECT", 0, Lifetime::Timeframe},
160 OutputSpec{{
"output"},
"TST",
"SOMEOBJECT", 1, Lifetime::Timeframe},
161 OutputSpec{{
"meta"},
"TST",
"METADATA", 0, Lifetime::Timeframe}},
169 std::string fileName = std::filesystem::temp_directory_path().string();
170 fileName +=
"/test_RootTreeWriter";
171 std::string altFileName = fileName +
"_alt.root";
181 sChecker.
addCheck(altFileName, sTreeSize, 3);
183 auto checkReady = [
counter = std::make_shared<int>(0)](
auto) ->
bool {
187 return (*
counter + 1) >= (2 * sTreeSize);
190 auto getIndex = [](
auto const&
ref) {
191 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
192 return static_cast<size_t>(dh->subSpecification);
200 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
201 LOGP(info,
"got data: {}/{}/{}", dh->dataOrigin, dh->dataDescription, dh->subSpecification);
223 MakeRootTreeWriterSpec::TerminationPolicy::Workflow,
std::string getName(const TDataMember *dm, int index, int size)
Configurable generator for RootTreeWriter processor spec.
A generic writer for ROOT TTrees.
~StaticChecker() noexcept(false)
void setError(T const &message)
void addCheck(std::string filename, int entries, int branches=0)
Generate a processor spec for the RootTreeWriter utility.
std::function< std::string(std::string, size_t)> BranchNameMapper
std::function< size_t(o2::framework::DataRef const &)> IndexExtractor
GLuint GLsizei const GLchar * message
GLboolean GLboolean GLboolean GLboolean a
Defining PrimaryVertex explicitly as messageable.
std::function< void(const char *)> OnWorkflowTerminationHook
void check(const std::vector< std::string > &arguments, const std::vector< ConfigParamSpec > &workflowOptions, const std::vector< DeviceSpec > &deviceSpecs, CheckMatrix &matrix)
std::vector< DataProcessorSpec > WorkflowSpec
std::string to_string(gsl::span< T, Size > span)
DataProcessorSpec getSourceSpec()
void customize(o2::framework::OnWorkflowTerminationHook &hook)
WorkflowSpec defineDataProcessing(ConfigContext const &)
This function hooks up the the workflow specifications into the DPL driver.
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))