Skip to content
Snippets Groups Projects
Commit 10d21a83 authored by Nils Erik Krumnack's avatar Nils Erik Krumnack Committed by Atlas Nightlybuild
Browse files

Merge branch 'expose-custom-getters' into '21.2'

Make customSeqGetter avaliable outside FlavorTagDiscriminants

See merge request atlas/athena!32346

(cherry picked from commit 912f02ee)

9816fbd0 make customSeqGetter avaliable outside this package
4614e125 formatting changes
253c79a3 Change year
0362581d Change year
3d23cd03 copyright commit noise
3851344d Update formatting
95491864 Add experts only warning
8deab175 add another column of / for doxygen
parent 2619f257
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
// The customGetter file is a catch-all for various getter functinos
......@@ -18,6 +18,32 @@
#define CUSTOM_GETTER_H
namespace FlavorTagDiscriminants {
/// Factory function to produce TrackParticle -> vector<double> functions
///
/// DL2 configures the its inputs when the algorithm is initalized,
/// meaning that the list of track and jet properties that are used
/// as inputs won't be known at compile time. Instead we build an
/// array of "getter" functions, each of which returns one input for
/// the tagger. The function here returns those getter functions.
///
/// Many of the getter functions are trivial: they will, for example,
/// read one double of auxdata off of the BTagging object. The
/// sequence input getters tend to be more complicated. Since we'd
/// like to avoid reimplementing the logic in these functions in
/// multiple places, they are exposed here.
///
/// This function will return a getter based on a string key. See the
/// implementation for the definitions.
///
/// NOTE: This function is for experts only, don't expect support.
///
std::function<std::vector<double>(
const xAOD::Jet&,
const std::vector<const xAOD::TrackParticle*>&)>
customSequenceGetter(const std::string& name);
// internal functions
namespace internal {
std::function<std::pair<std::string, double>(const xAOD::Jet&)>
customGetterAndName(const std::string&);
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "FlavorTagDiscriminants/customGetter.h"
#include "FlavorTagDiscriminants/BTagTrackAugmenter.h"
......@@ -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 = customSequenceGetter(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
//
......@@ -76,8 +110,8 @@ namespace {
//
std::function<std::vector<double>(
const xAOD::Jet&,
const std::vector<const xAOD::TrackParticle*>&)> customSeqGetter(
const std::string& name) {
const std::vector<const xAOD::TrackParticle*>&)>
customSequenceGetter(const std::string& name) {
typedef std::vector<const xAOD::TrackParticle*> Tracks;
if (name == "IP3D_signed_d0_significance") {
return SignedD0SequenceGetter();
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment