Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include check for default lorentzvectors in LV combination #278

Merged
merged 2 commits into from
Jul 26, 2024
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
3 changes: 1 addition & 2 deletions include/defaults.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const int default_pdgid = -999;
const float default_float = -10.0;
const UChar_t default_uchar = -10;
const bool default_bool = false;
const auto default_lorentzvector = ROOT::Math::PtEtaPhiMVector(
default_float, default_float, default_float, default_float);
const auto default_lorentzvector = ROOT::Math::PtEtaPhiMVector(0.,0.,0.,0.);

template <typename T> const T default_value() {
if (std::is_same<T, int>::value) {
Expand Down
9 changes: 8 additions & 1 deletion include/lorentzvectors.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ROOT/RDataFrame.hxx"
#include "ROOT/RVec.hxx"
#include "utility/utility.hxx"
#include "defaults.hxx"
#include <Math/Vector4D.h>

namespace lorentzvectors {
Expand Down Expand Up @@ -39,6 +40,12 @@ ROOT::RDF::RNode CombineP4s(ROOT::RDF::RNode df, const std::string &outputflag,
outputflag,
utility::PassAsVec<np4s, ROOT::Math::PtEtaPhiMVector>(
[](const ROOT::RVec<ROOT::Math::PtEtaPhiMVector> &p4s) {
for (int i = 0; i < p4s.size(); i++) {
auto p4 = p4s.at(i);
if (p4.pt() < 0.) {
return default_lorentzvector;
}
}
return Sum(p4s, ROOT::Math::PtEtaPhiMVector());
}),
P4List);
Expand All @@ -57,4 +64,4 @@ ROOT::RDF::RNode build(ROOT::RDF::RNode df, const std::string &pairname,
} // namespace mutau

} // namespace lorentzvectors
#endif /* GUARDLVECS_H */
#endif /* GUARDLVECS_H */
Loading