Skip to content

Commit

Permalink
Upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
taehyounpark committed Feb 3, 2024
1 parent ab31492 commit d7ef1f9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions analogical.h
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ template <typename DS> class input : public source {
decltype(auto) read_column(const ana::dataset::range &part,
const std::string &name);

virtual partition allocate() = 0;
virtual partition parallelize() = 0;
virtual double normalize();
};

Expand Down Expand Up @@ -3858,7 +3858,7 @@ ana::dataset::reader<DS> ana::dataflow::open(Args &&...args) {
m_source = std::move(source);

// 1. allocate the dataset partition
this->m_partition = ds->allocate();
this->m_partition = ds->parallelize();
// 2. truncate entries to limit
this->m_partition.truncate(this->m_nrows);
// 3. merge parts to concurrency limit
Expand Down Expand Up @@ -3990,7 +3990,7 @@ auto ana::dataflow::agg(Args &&...args) -> delayed<aggregation::booker<Cnt>> {
return delayed<aggregation::booker<Cnt>>(
*this, this->m_processors.get_lockstep_node(
[&args...](dataset::processor &proc) {
return proc.template book<Cnt>(std::forward<Args>(args)...);
return proc.template agg<Cnt>(std::forward<Args>(args)...);
}));
}

Expand Down
8 changes: 4 additions & 4 deletions docs/demo/hww/notebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ auto cut_2lsf_wwcr = cut_2lsf.filter("wwcr")(mll > mll_cut); // path = "2lsf/cr
```
```cpp title="Book histograms"
// Hist<1,float> is user-implemented.
auto pth_hist = df.book<Hist<1,float>>("pth",100,0,400).fill(pth).at(cut_2los);
auto pth_hist = df.agg<Hist<1,float>>("pth",100,0,400).fill(pth).at(cut_2los);

// also at "2ldf/wwcr", "2lsf/wwcr"
auto l1n2_pt_hists_wwcrs = l1n2_pt_hist.at(cut_2lsf_sr, cut_2lsf_wwcr);
```
```cpp title="(Optional) Dump out results"
// booked at multiple selections
auto pth_hists = df.book<Hist<1,float>>("pth",100,0,400).fill(pth).at(cut_2los, cut_2ldf, cut_2lsf);
auto pth_hists = df.agg<Hist<1,float>>("pth",100,0,400).fill(pth).at(cut_2los, cut_2ldf, cut_2lsf);

// want to write histogram at each selection, using its path as sub-folders
auto out_file = TFile::Open("hww_hists.root","recreate");
Expand Down Expand Up @@ -163,7 +163,7 @@ cut_2l.has_variation("sf_var"); // true
// ...
auto mll_vars = df.book<Hist<1,float>>("mll",50,0,100).fill(mll).at(cut_2los);
auto mll_vars = df.agg<Hist<1,float>>("mll",50,0,100).fill(mll).at(cut_2los);
mll_vars.has_variation("lp4_up"); // true : mll & cut_2los varied
mll_vars.has_variation("sf_var"); // true : mll nominal & cut_2los varied
```
Expand All @@ -176,7 +176,7 @@ mll_vars["lp4_up"]->Draw("same");
```cpp title="Booking multiple selections and variations at once"
// mll contains variations = {lp4_up, sf_var}
// booked at selections = {cut_2ldf, cut_2lsf}
auto mll_channels_vars = df.book<Hist<1,float>>("mll",50,0,200).fill(mll).at(cut_2ldf, cut_2lsf);
auto mll_channels_vars = df.agg<Hist<1,float>>("mll",50,0,200).fill(mll).at(cut_2ldf, cut_2lsf);
// specify variation name, followed by selection path
mll_channels_vars.nominal()["2ldf"]->GetEntries();
Expand Down
4 changes: 2 additions & 2 deletions docs/features/column/column.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Consider the following JSON data:
json(const nlohmann::json &data);
~json() = default;

ana::dataset::partition allocate();
ana::dataset::partition parallelize();

template <typename T>
std::unique_ptr<column<T>> read(const ana::dataset::range &part,
Expand Down Expand Up @@ -58,7 +58,7 @@ Consider the following JSON data:
const std::string &name)
: m_data(data), m_name(name) {}

ana::dataset::partition ana::json::allocate() {
ana::dataset::partition ana::json::parallelize() {
ana::dataset::partition parts;
auto nentries = m_data.size();
for (unsigned int i = 0; i < nentries; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions include/ana/interface/aggregation_experiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class aggregation::experiment : public selection::cutflow {

public:
template <typename Cnt, typename... Args>
std::unique_ptr<booker<Cnt>> book(Args &&...args);
std::unique_ptr<booker<Cnt>> agg(Args &&...args);

template <typename Cnt>
auto select_aggregation(booker<Cnt> const &bkr, const selection &sel)
Expand Down Expand Up @@ -56,7 +56,7 @@ inline void ana::aggregation::experiment::clear_aggregations() {

template <typename Cnt, typename... Args>
std::unique_ptr<ana::aggregation::booker<Cnt>>
ana::aggregation::experiment::book(Args &&...args) {
ana::aggregation::experiment::agg(Args &&...args) {
auto bkr = std::make_unique<booker<Cnt>>(std::forward<Args>(args)...);
return bkr;
}
Expand Down
2 changes: 1 addition & 1 deletion include/ana/interface/dataflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ auto ana::dataflow::agg(Args &&...args) -> delayed<aggregation::booker<Cnt>> {
return delayed<aggregation::booker<Cnt>>(
*this, lockstep::get_node(
[&args...](dataset::processor *proc) {
return proc->template book<Cnt>(std::forward<Args>(args)...);
return proc->template agg<Cnt>(std::forward<Args>(args)...);
},
this->m_processors));
}
Expand Down
5 changes: 3 additions & 2 deletions include/ana/interface/lazy.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class lazy : public systematic::resolver<lazy<Action>>,
template <typename V = Action,
std::enable_if_t<ana::aggregation::template has_output_v<V>, bool> =
false>
auto result() const;
auto result() const -> decltype(std::declval<V>().get_result());

template <typename V = Action,
std::enable_if_t<ana::aggregation::template has_output_v<V>, bool> =
Expand Down Expand Up @@ -316,7 +316,8 @@ auto ana::lazy<Action>::book(Aggs &&...aggs) const {
template <typename Action>
template <typename V,
std::enable_if_t<ana::aggregation::template has_output_v<V>, bool>>
auto ana::lazy<Action>::result() const {
auto ana::lazy<Action>::result() const
-> decltype(std::declval<V>().get_result()) {
this->m_df->analyze();
this->merge_results();
return this->get_model()->get_result();
Expand Down
2 changes: 1 addition & 1 deletion tests/test-selection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TEST_CASE("correctness & consistency of selections") {
auto cut_a2 = weighted_entries.filter("a2")(cut_ab && cut_a);
auto cut_b2 = weighted_entries.filter("b2")(cut_ab && cut_b);

// auto sumw_a = df.book<SumOfWeights>().at(cut_a);
// auto sumw_a = df.agg<SumOfWeights>().at(cut_a);
auto sumw_a = cut_a.book(df.agg<SumOfWeights>());

auto sumw_one = df.agg<SumOfWeights>().book(cut_a, cut_b, cut_c);
Expand Down

0 comments on commit d7ef1f9

Please sign in to comment.