Skip to content

Commit

Permalink
avoid crash when create a 'ones' var from multi-branch var (HeavyIonA…
Browse files Browse the repository at this point in the history
  • Loading branch information
lubynets authored Feb 14, 2024
1 parent 9b0649e commit 5062445
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(AnalysisTreeQA_BUILD_TASKS OFF CACHE BOOL "Build user' AnalysisTreeQA tasks
set(AnalysisTreeQA_BUILD_EXAMPLES ON CACHE BOOL "Build AnalysisTreeQA examples (examples/)")
set(AnalysisTreeQA_BUILD_TESTS OFF CACHE BOOL "Build tests for AnalysisTreeQA")
set(AnalysisTreeQA_BUNDLED_AT ON CACHE BOOL "Get and build AnalysisTree")
set(AnalysisTreeQA_BUNDLED_AT_VERSION "v2.3.4" CACHE STRING "Bundled AnalysisTree version")
set(AnalysisTreeQA_BUNDLED_AT_VERSION "v2.3.5" CACHE STRING "Bundled AnalysisTree version")
set(AnalysisTreeQA_BUNDLED_AT_GIT_SHALLOW ON CACHE BOOL "Use CMake GIT_SHALLOW option")
set(AnalysisTreeQA_BUNDLED_CUTS ON CACHE BOOL "Get and build AnalysisTreeCuts")
set(AnalysisTreeQA_BUNDLED_CUTS_VERSION "v0.0.1" CACHE STRING "Bundled AnalysisTreeCuts version")
Expand Down
16 changes: 4 additions & 12 deletions src/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,31 @@ class Task : public AnalysisTask {
void Finish() override;

size_t AddH1(const Axis& x, Cuts* cuts = nullptr, Variable weight = Variable{}) {
if(weight.GetNumberOfBranches() == 0) {
weight = Variable::FromString(x.GetBranchName() + ".ones");
}
weight.IfEmptyVariableConvertToOnes(x);
entries_.emplace_back(EntryConfig(x, weight, cuts, false));
auto var_id = AddEntry(AnalysisEntry(entries_.back().GetVariables(), entries_.back().GetEntryCuts(), entries_.back().GetVariableForWeight()));
entries_.back().SetVariablesId({{var_id.first, var_id.second.at(0)}});
return entries_.size() - 1;
}

size_t AddH2(const Axis& x, const Axis& y, Cuts* cuts = nullptr, Variable weight = Variable{}) {
if(weight.GetNumberOfBranches() == 0) {
weight = Variable::FromString(x.GetBranchName() + ".ones");
}
weight.IfEmptyVariableConvertToOnes(x);
entries_.emplace_back(EntryConfig(x, y, weight, cuts));
auto var_id = AddEntry(AnalysisEntry(entries_.back().GetVariables(), entries_.back().GetEntryCuts(), entries_.back().GetVariableForWeight()));
entries_.back().SetVariablesId({ {var_id.first, var_id.second.at(0)}, {var_id.first, var_id.second.at(1)} });
return entries_.size() - 1;
}

size_t AddProfile(const Axis& x, const Axis& y, Cuts* cuts = nullptr, Variable weight = Variable{}) {
if(weight.GetNumberOfBranches() == 0) {
weight = Variable::FromString(x.GetBranchName() + ".ones");
}
weight.IfEmptyVariableConvertToOnes(x);
entries_.emplace_back(EntryConfig(x, y, weight, cuts, true));
auto var_id = AddEntry(AnalysisEntry(entries_.back().GetVariables(), entries_.back().GetEntryCuts(), entries_.back().GetVariableForWeight()));
entries_.back().SetVariablesId({ {var_id.first, var_id.second.at(0)}, {var_id.first, var_id.second.at(1)} });
return entries_.size() - 1;
}

size_t AddIntegral(const Axis& x, Cuts* cuts = nullptr, Variable weight = Variable{}) {
if(weight.GetNumberOfBranches() == 0) {
weight = Variable::FromString(x.GetBranchName() + ".ones");
}
weight.IfEmptyVariableConvertToOnes(x);
entries_.emplace_back(EntryConfig(x, weight, cuts, true));
auto var_id = AddEntry(AnalysisEntry(entries_.back().GetVariables(), entries_.back().GetEntryCuts(), entries_.back().GetVariableForWeight()));
entries_.back().SetVariablesId({{var_id.first, var_id.second.at(0)}});
Expand Down

0 comments on commit 5062445

Please sign in to comment.