24void customize(std::vector<ConfigParamSpec>& options)
26 options.push_back({
"obj-bins", VariantType::Int, 100, {
"Number of bins in a histogram"}});
27 options.push_back({
"obj-rate", VariantType::Double, 1.0, {
"Number of objects per second sent by one producer"}});
28 options.push_back({
"obj-producers", VariantType::Int, 4, {
"Number of objects producers"}});
29 options.push_back({
"obj-per-message", VariantType::Int, 1, {
"Number objects per message (in one TCollection)"}});
30 options.push_back({
"output-channel-config", VariantType::String,
"", {
"Proxy output FMQ channel configuration"}});
31 options.push_back({
"first-subspec", VariantType::Int, 1, {
"First subSpec of the parallel producers, the rest will be incremental"}});
46 int objectsBins = config.
options().
get<
int>(
"obj-bins");
47 double objectsRate = config.
options().
get<
double>(
"obj-rate");
48 int objectsProducers = config.
options().
get<
int>(
"obj-producers");
49 int objectsPerMessage = config.
options().
get<
int>(
"obj-per-message");
50 std::string outputChannelConfig = config.
options().
get<std::string>(
"output-channel-config");
55 for (
size_t p = 0; p < objectsProducers; p++, subSpec++) {
59 Outputs{ { {
"histo" },
"TST",
"HISTO", subSpec} },
62 const size_t randoms = 10000;
63 int periodus =
static_cast<int>(1000000 / objectsRate);
67 double randomsArray[randoms];
68 TObjArray* collection =
new TObjArray();
69 collection->SetOwner(
true);
71 for (
size_t i = 0;
i < objectsPerMessage;
i++) {
78 static auto lastTime = steady_clock::now() - std::chrono::microseconds(periodus * p / objectsProducers);
79 auto now = steady_clock::now();
80 if (duration_cast<microseconds>(now - lastTime).
count() > periodus) {
81 lastTime += microseconds(periodus);
83 if (objectsPerMessage > 1) {
84 for (
auto o : *collection) {
85 gen.RndmArray(randoms, randomsArray);
87 TH1I*
h =
dynamic_cast<TH1I*
>(
o);
89 h->FillN(randoms, randomsArray,
nullptr);
92 collection->SetOwner(
false);
93 pctx.outputs().snapshot({
"TST",
"HISTO", subSpec}, *collection);
94 collection->SetOwner(
true);
96 gen.RndmArray(randoms, randomsArray);
98 TH1I*
h =
dynamic_cast<TH1I*
>(collection->At(0));
100 h->FillN(randoms, randomsArray,
nullptr);
102 pctx.outputs().snapshot({
"TST",
"HISTO", subSpec}, *
h);
109 specs.push_back(producer);
116 {{
"histo",
"TST",
"HISTO", subSpec }}, outputChannelConfig.c_str())));
ConfigParamRegistry & options() const