12#ifndef ALICEO2_VECTORTOPOLOGYCOMMON_H_
13#define ALICEO2_VECTORTOPOLOGYCOMMON_H_
19#include <fairlogger/Logger.h>
35void customize(std::vector<o2::framework::CompletionPolicy>& policies)
50template <
typename Deleter,
size_t Size>
53 return std::equal(vectorOfHistos->begin(), vectorOfHistos->end(),
expected.begin(),
expected.end(),
55 const auto& histo = *dynamic_cast<TH1F const*>(object);
56 return std::equal(array.begin(), array.end(), histo.GetArray(), histo.GetArray() + histo.GetSize());
60template <
size_t HistoSize>
63 static constexpr const char origin[] = {
"TST"};
64 static constexpr const char description[] = {
"VEC"};
67 VectorMergerTestGenerator(std::vector<std::array<float, HistoSize>>&& expectedResult,
size_t histoBinsCount,
double histoMin,
double histoMax)
68 : mExpectedResult{expectedResult}, mHistoBinsCount{histoBinsCount}, mHistoMin{histoMin}, mHistoMax{histoMax}
76 for (
size_t producerIdx = 1; producerIdx < numberOfProducers + 1; ++producerIdx) {
77 mergersInputs.push_back({
"mo", origin, description,
static_cast<SubSpecificationType>(producerIdx), Lifetime::Sporadic});
84 auto vectorOfHistos = std::make_unique<mergers::VectorOfRawTObjects>(2);
87 for (
auto& hist_ptr : *vectorOfHistos) {
89 auto* hist =
new TH1F(histoname.c_str(), histoname.c_str(), binsCount, histoMin, histoMax);
90 hist->Fill(producerIdx);
95 processingContext.outputs().snapshot(
OutputRef{
"mo", subspec}, *vectorOfHistos);
96 for_each(vectorOfHistos->begin(), vectorOfHistos->end(), [](
auto& histoPtr) { delete histoPtr; });
99 specs.push_back(producer);
101 return mergersInputs;
106 using namespace mergers;
108 MergerInfrastructureBuilder mergersBuilder;
109 mergersBuilder.setInfrastructureName(
"vec");
110 mergersBuilder.setInputSpecs(mergersInputs);
111 mergersBuilder.setOutputSpec({{
"main"}, origin, description, 0});
113 config.inputObjectTimespan = {mergerType};
114 std::vector<std::pair<size_t, size_t>>
param = {{5, 1}};
115 config.publicationDecision = {PublicationDecision::EachNSeconds,
param};
116 config.mergedObjectTimespan = {MergedObjectTimespan::FullHistory};
117 config.topologySize = {TopologySize::NumberOfLayers, 2};
118 mergersBuilder.setConfig(config);
120 mergersBuilder.generateInfrastructure(specs);
127 Inputs{{
"vec", origin, description, 0, Lifetime::Sporadic}},
131 auto success = std::make_shared<bool>(
false);
138 const auto vectorOfHistos = processingContext.inputs().get<std::vector<TObject*>*>(
"vec");
141 if (vectorOfHistos == expectedResult) {
142 LOG(info) <<
"Received the expected object, test successful";
148 if (retryNumber++ > retries) {
158 std::vector<ExpectedType<HistoSize>> mExpectedResult;
159 size_t mHistoBinsCount;
o2::framework::DataAllocator::SubSpecificationType SubSpecificationType
Definition of O2 MergerInfrastructureBuilder, v0.1.
Definition of ObjectStore for Mergers, v0.1.
void generateMergers(WorkflowSpec &specs, const Inputs &mergersInputs, mergers::InputObjectsTimespan mergerType)
Inputs generateHistoProducers(WorkflowSpec &specs, size_t numberOfProducers)
void generateChecker(WorkflowSpec &specs)
VectorMergerTestGenerator(std::vector< std::array< float, HistoSize > > &&expectedResult, size_t histoBinsCount, double histoMin, double histoMax)
static void customizeInfrastructure(std::vector< framework::CompletionPolicy > &)
Configures mergers to consume any data immediately.
Defining PrimaryVertex explicitly as messageable.
bool operator==(const std::unique_ptr< const std::vector< TObject * >, Deleter > &vectorOfHistos, std::vector< ExpectedType< Size > > &expected)
std::vector< DataProcessorSpec > WorkflowSpec
@ Me
Only quit this data processor.
@ All
Quit all data processor, regardless of their state.
header::DataHeader::SubSpecificationType SubSpecificationType
std::array< float, Size > ExpectedType
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
void registerCallbacksForTestFailure(framework::CallbackService &cb, std::shared_ptr< bool > success)
std::string to_string(gsl::span< T, Size > span)
std::function< ProcessCallback(InitContext &)> InitCallback
std::function< void(ProcessingContext &)> ProcessCallback
std::map< std::string, ID > expected
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
void customize(std::vector< o2::framework::CompletionPolicy > &policies)