diff --git a/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/FlavorTagDiscriminants/customGetter.h b/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/FlavorTagDiscriminants/customGetter.h index 820f82556063429726b36889e773e934bf95d360..937f5dcd15fc0565d2e83532de752fa02b391602 100644 --- a/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/FlavorTagDiscriminants/customGetter.h +++ b/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/FlavorTagDiscriminants/customGetter.h @@ -18,6 +18,12 @@ #define CUSTOM_GETTER_H namespace FlavorTagDiscriminants { + + std::function<std::vector<double>( + const xAOD::Jet&, + const std::vector<const xAOD::TrackParticle*>&)> customSeqGetter( + const std::string& name); + namespace internal { std::function<std::pair<std::string, double>(const xAOD::Jet&)> customGetterAndName(const std::string&); diff --git a/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/Root/customGetter.cxx b/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/Root/customGetter.cxx index e8753e238d45bf8ba01a05cd56cec9229677d0c9..b37110af8789bb67fe9fdc6e5adea4658b9211b5 100644 --- a/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/Root/customGetter.cxx +++ b/PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/Root/customGetter.cxx @@ -68,6 +68,40 @@ namespace { }; +} + +namespace FlavorTagDiscriminants { + namespace internal { + + // ________________________________________________________________ + // Interface functions + // + // As long as we're giving lwtnn pair<name, double> objects, we + // can't use the raw getter functions above (which only return a + // double). Instead we'll wrap those functions in another function, + // which returns the pair we wanted. + // + // Case for jet variables + std::function<std::pair<std::string, double>(const xAOD::Jet&)> + customGetterAndName(const std::string& name) { + auto getter = customGetter(name); + return [name, getter](const xAOD::Jet& j) { + return std::make_pair(name, getter(j)); + }; + } + + // Case for track variables + std::function<std::pair<std::string, std::vector<double>>( + const xAOD::Jet&, + const std::vector<const xAOD::TrackParticle*>&)> + customNamedSeqGetter(const std::string& name) { + auto getter = customSeqGetter(name); + return [name, getter](const xAOD::Jet& j, + const std::vector<const xAOD::TrackParticle*>& t) { + return std::make_pair(name, getter(j, t)); + }; + } + } // ________________________________________________________________________ // Master track getter list // @@ -116,40 +150,21 @@ namespace { return log_dr; }; } - throw std::logic_error("no match for custom getter " + name); - } -} - -namespace FlavorTagDiscriminants { - namespace internal { - - // ________________________________________________________________ - // Interface functions - // - // As long as we're giving lwtnn pair<name, double> objects, we - // can't use the raw getter functions above (which only return a - // double). Instead we'll wrap those functions in another function, - // which returns the pair we wanted. - // - // Case for jet variables - std::function<std::pair<std::string, double>(const xAOD::Jet&)> - customGetterAndName(const std::string& name) { - auto getter = customGetter(name); - return [name, getter](const xAOD::Jet& j) { - return std::make_pair(name, getter(j)); + if (name == "pt") { + return [](const xAOD::Jet&, const Tracks& t) { + std::vector<double> tracks; + for (auto* trk: t) tracks.push_back(trk->pt()); + return tracks; }; } - - // Case for track variables - std::function<std::pair<std::string, std::vector<double>>( - const xAOD::Jet&, - const std::vector<const xAOD::TrackParticle*>&)> - customNamedSeqGetter(const std::string& name) { - auto getter = customSeqGetter(name); - return [name, getter](const xAOD::Jet& j, - const std::vector<const xAOD::TrackParticle*>& t) { - return std::make_pair(name, getter(j, t)); + if (name == "eta") { + return [](const xAOD::Jet&, const Tracks& t) { + std::vector<double> tracks; + for (auto* trk: t) tracks.push_back(trk->eta()); + return tracks; }; } + throw std::logic_error("no match for custom getter " + name); } + }