Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions Framework/Core/include/Framework/HistogramRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@
#define FRAMEWORK_HISTOGRAMREGISTRY_H_

#include "Framework/HistogramSpec.h"
#include "Framework/ASoA.h"
#include "Framework/FunctionalHelpers.h"
#include "Framework/Logger.h"
#include "Framework/OutputRef.h"
#include "Framework/OutputObjHeader.h"
#include "Framework/OutputSpec.h"
#include "Framework/SerializationMethods.h"
#include "Framework/TableBuilder.h"
#include "Framework/RuntimeError.h"
#include "Framework/Expressions.h"
#include "StepTHn.h"

#include <TDataMember.h>
Expand Down Expand Up @@ -294,20 +290,14 @@ void HistFiller::fillHistAny(std::shared_ptr<T> hist, Ts... positionAndWeight)
}

template <typename... Cs, typename R, typename T>
void HistFiller::fillHistAny(std::shared_ptr<R> hist, const T& table, const o2::framework::expressions::Filter& filter)
void HistFiller::fillHistAny(std::shared_ptr<R>, const T&, const o2::framework::expressions::Filter&)
requires(!ValidComplexFillStep<R, sizeof...(Cs)>) && requires(T t) { t.asArrowTable(); }
{
auto s = o2::framework::expressions::createSelection(table.asArrowTable(), filter);
auto filtered = o2::soa::Filtered<T>{{table.asArrowTable()}, s};
for (auto& t : filtered) {
fillHistAny(hist, (*(static_cast<Cs>(t).getIterator()))...);
}
}

template <typename... Cs, typename R, typename T>
void HistFiller::fillHistAny(std::shared_ptr<R> hist, const T& table, const o2::framework::expressions::Filter& filter)
void HistFiller::fillHistAny(std::shared_ptr<R>, const T&, const o2::framework::expressions::Filter&)
{
HistFiller::badHistogramFill(hist->GetName());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this supposed to work? why not simply dropping the method?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a histogram registry example code in Tutorials that uses this code path. And I intend to rework this feature in the future rather than completely removing it, this is left for compatibility.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a FATAL "not implemented"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used anywhere except that one tutorial, there is no point.

}

template <typename T>
Expand Down Expand Up @@ -485,6 +475,5 @@ void HistogramRegistry::fill(const HistName& histName, const T& table, const o2:
{
std::visit([&table, &filter](auto&& hist) { HistFiller::fillHistAny<Cs...>(hist, table, filter); }, mRegistryValue[getHistIndex(histName)]);
}

} // namespace o2::framework
#endif // FRAMEWORK_HISTOGRAMREGISTRY_H_
1 change: 1 addition & 0 deletions Framework/Core/src/HistogramRegistry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// or submit itself to any jurisdiction.

#include "Framework/HistogramRegistry.h"
#include "Framework/ASoA.h"
#include <regex>
#include <TList.h>
#include <TClass.h>
Expand Down
2 changes: 0 additions & 2 deletions Framework/Core/test/benchmark_HistogramRegistry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// or submit itself to any jurisdiction.

#include "Framework/HistogramRegistry.h"
#include "Framework/Logger.h"

#include "TList.h"

Expand All @@ -19,7 +18,6 @@

using namespace o2::framework;
using namespace arrow;
using namespace o2::soa;

/// Number of lookups to perform
const int nLookups = 100000;
Expand Down
71 changes: 37 additions & 34 deletions Framework/Core/test/test_HistogramRegistry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// or submit itself to any jurisdiction.

#include "Framework/HistogramRegistry.h"
#include "Framework/ASoA.h"
#include "Framework/TableBuilder.h"
#include <catch_amalgamated.hpp>

using namespace o2;
Expand Down Expand Up @@ -70,40 +72,41 @@ TEST_CASE("HistogramRegistryLookup")
*/
}

TEST_CASE("HistogramRegistryExpressionFill")
{
TableBuilder builderA;
auto rowWriterA = builderA.persist<float, float>({"x", "y"});
rowWriterA(0, 0.0f, -2.0f);
rowWriterA(0, 1.0f, -4.0f);
rowWriterA(0, 2.0f, -1.0f);
rowWriterA(0, 3.0f, -5.0f);
rowWriterA(0, 4.0f, 0.0f);
rowWriterA(0, 5.0f, -9.0f);
rowWriterA(0, 6.0f, -7.0f);
rowWriterA(0, 7.0f, -4.0f);
auto tableA = builderA.finalize();
REQUIRE(tableA->num_rows() == 8);
using TestA = o2::soa::InPlaceTable<"A/1"_h, o2::soa::Index<>, test::X, test::Y>;
TestA tests{tableA};
REQUIRE(8 == tests.size());

/// Construct a registry object with direct declaration
HistogramRegistry registry{
"registry", {
{"x", "test x", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, //
{"xy", "test xy", {HistType::kTH2F, {{100, -10.0f, 10.01f}, {100, -10.0f, 10.01f}}}} //
} //
};

/// Fill histogram with expression and table
registry.fill<test::X>(HIST("x"), tests, test::x > 3.0f);
REQUIRE(registry.get<TH1>(HIST("x"))->GetEntries() == 4);

/// Fill histogram with expression and table
registry.fill<test::X, test::Y>(HIST("xy"), tests, test::x > 3.0f && test::y > -5.0f);
REQUIRE(registry.get<TH2>(HIST("xy"))->GetEntries() == 2);
}
// FIXME: feature not used in its current state, requires rework
// TEST_CASE("HistogramRegistryExpressionFill")
// {
// TableBuilder builderA;
// auto rowWriterA = builderA.persist<float, float>({"x", "y"});
// rowWriterA(0, 0.0f, -2.0f);
// rowWriterA(0, 1.0f, -4.0f);
// rowWriterA(0, 2.0f, -1.0f);
// rowWriterA(0, 3.0f, -5.0f);
// rowWriterA(0, 4.0f, 0.0f);
// rowWriterA(0, 5.0f, -9.0f);
// rowWriterA(0, 6.0f, -7.0f);
// rowWriterA(0, 7.0f, -4.0f);
// auto tableA = builderA.finalize();
// REQUIRE(tableA->num_rows() == 8);
// using TestA = o2::soa::InPlaceTable<"A/1"_h, o2::soa::Index<>, test::X, test::Y>;
// TestA tests{tableA};
// REQUIRE(8 == tests.size());

// /// Construct a registry object with direct declaration
// HistogramRegistry registry{
// "registry", {
// {"x", "test x", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, //
// {"xy", "test xy", {HistType::kTH2F, {{100, -10.0f, 10.01f}, {100, -10.0f, 10.01f}}}} //
// } //
// };

// /// Fill histogram with expression and table
// registry.fill<test::X>(HIST("x"), tests, test::x > 3.0f);
// REQUIRE(registry.get<TH1>(HIST("x"))->GetEntries() == 4);

// /// Fill histogram with expression and table
// registry.fill<test::X, test::Y>(HIST("xy"), tests, test::x > 3.0f && test::y > -5.0f);
// REQUIRE(registry.get<TH2>(HIST("xy"))->GetEntries() == 2);
// }

TEST_CASE("HistogramRegistryStepTHn")
{
Expand Down