ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
FlavorTagDiscriminants::getter_utils::SeqGetter< T > Class Template Reference

Template class to extract features from sequence of constituents. More...

#include <CustomGetterUtils.h>

Collaboration diagram for FlavorTagDiscriminants::getter_utils::SeqGetter< T >:

Public Types

using Const = Constituents< T >
 
using InputSequence = std::function< std::pair< std::string, std::vector< double > >(const xAOD::Jet &, const Const &)>
 

Public Member Functions

 SeqGetter (std::vector< InputVariableConfig > inputs, const FTagOptions &options)
 
std::pair< std::vector< float >, std::vector< int64_t > > getFeats (const xAOD::Jet &jet, const Const &constituents) const
 
std::map< std::string, std::vector< double > > getDL2Feats (const xAOD::Jet &jet, const Const &constituents) const
 
std::set< std::string > getDependencies () const
 
std::set< std::string > getUsedRemap () const
 

Private Member Functions

std::pair< InputSequence, std::set< std::string > > getNamedCustomSeqGetter (const std::string &name, const std::string &prefix)
 
std::pair< InputSequence, std::set< std::string > > seqFromConsituents (const InputVariableConfig &cfg, const FTagOptions &options)
 

Private Attributes

std::vector< InputSequencem_sequence_getters
 
std::set< std::string > m_deps
 
std::set< std::string > m_used_remap
 

Detailed Description

template<typename T>
class FlavorTagDiscriminants::getter_utils::SeqGetter< T >

Template class to extract features from sequence of constituents.

Template Parameters
Tconstituent type

It supports the following types of constituents:

Definition at line 70 of file CustomGetterUtils.h.

Member Typedef Documentation

◆ Const

template<typename T >
using FlavorTagDiscriminants::getter_utils::SeqGetter< T >::Const = Constituents<T>

Definition at line 72 of file CustomGetterUtils.h.

◆ InputSequence

template<typename T >
using FlavorTagDiscriminants::getter_utils::SeqGetter< T >::InputSequence = std::function<std::pair<std::string, std::vector<double> >( const xAOD::Jet&, const Const&)>

Definition at line 73 of file CustomGetterUtils.h.

Constructor & Destructor Documentation

◆ SeqGetter()

template<typename T >
FlavorTagDiscriminants::getter_utils::SeqGetter< T >::SeqGetter ( std::vector< InputVariableConfig inputs,
const FTagOptions options 
)

Definition at line 389 of file CustomGetterUtils.cxx.

390  {
391  std::map<std::string, std::string> remap = options.remap_scalar;
392  for (const InputVariableConfig& input_cfg: inputs) {
393  auto [seqGetter, seq_deps] = seqFromConsituents(input_cfg, options);
394 
395  if(input_cfg.flip_sign){
396  auto seqGetter_flip=[g=seqGetter](const xAOD::Jet&jet, const Const& constituents){
397  auto [n,v] = g(jet,constituents);
398  std::for_each(v.begin(), v.end(), [](double &n){ n=-1.0*n; });
399  return std::make_pair(n,v);
400  };
401  m_sequence_getters.push_back(seqGetter_flip);
402  }
403  else{
404  m_sequence_getters.push_back(seqGetter);
405  }
406  m_deps.merge(seq_deps);
407  if (auto h = remap.extract(input_cfg.name)){
408  m_used_remap.insert(h.key());
409  }
410  }
411  }

Member Function Documentation

◆ getDependencies()

template<typename T >
std::set< std::string > FlavorTagDiscriminants::getter_utils::SeqGetter< T >::getDependencies

Definition at line 452 of file CustomGetterUtils.cxx.

452  {
453  return m_deps;
454  }

◆ getDL2Feats()

template<typename T >
std::map< std::string, std::vector< double > > FlavorTagDiscriminants::getter_utils::SeqGetter< T >::getDL2Feats ( const xAOD::Jet jet,
const Const constituents 
) const

Definition at line 441 of file CustomGetterUtils.cxx.

443  {
444  std::map<std::string, std::vector<double>> feats;
445  for (const auto& seq_getter: m_sequence_getters){
446  feats.insert(seq_getter(jet, constituents));
447  }
448  return feats;
449  }

◆ getFeats()

template<typename T >
std::pair< std::vector< float >, std::vector< int64_t > > FlavorTagDiscriminants::getter_utils::SeqGetter< T >::getFeats ( const xAOD::Jet jet,
const Const constituents 
) const

Definition at line 414 of file CustomGetterUtils.cxx.

416  {
417  std::vector<float> cnsts_feats;
418  int num_vars = m_sequence_getters.size();
419  int num_cnsts = 0;
420 
421  int cnst_var_idx = 0;
422  for (const auto& seq_getter: m_sequence_getters){
423  auto input_sequence = seq_getter(jet, constituents).second;
424 
425  if (cnst_var_idx==0){
426  num_cnsts = static_cast<int>(input_sequence.size());
427  cnsts_feats.resize(num_cnsts * num_vars);
428  }
429 
430  // need to transpose + flatten
431  for (unsigned int cnst_idx=0; cnst_idx<input_sequence.size(); cnst_idx++){
432  cnsts_feats.at(cnst_idx*num_vars + cnst_var_idx) = input_sequence.at(cnst_idx);
433  }
434  cnst_var_idx++;
435  }
436  std::vector<int64_t> cnsts_feat_dim = {num_cnsts, num_vars};
437  return {cnsts_feats, cnsts_feat_dim};
438  }

◆ getNamedCustomSeqGetter()

template<typename T >
std::pair< typename SeqGetter< T >::InputSequence, std::set< std::string > > FlavorTagDiscriminants::getter_utils::SeqGetter< T >::getNamedCustomSeqGetter ( const std::string &  name,
const std::string &  prefix 
)
private

Definition at line 351 of file CustomGetterUtils.cxx.

351  {
352  auto [getter, deps] = buildCustomSeqGetter<T>(name, prefix);
353  return {
354  [n=name, g=getter](const xAOD::Jet& j, const std::vector<const T*>& t) {
355  return std::make_pair(n, g(j, t));
356  },
357  deps
358  };
359  }

◆ getUsedRemap()

template<typename T >
std::set< std::string > FlavorTagDiscriminants::getter_utils::SeqGetter< T >::getUsedRemap

Definition at line 456 of file CustomGetterUtils.cxx.

456  {
457  return m_used_remap;
458  }

◆ seqFromConsituents()

template<typename T >
std::pair< typename SeqGetter< T >::InputSequence, std::set< std::string > > FlavorTagDiscriminants::getter_utils::SeqGetter< T >::seqFromConsituents ( const InputVariableConfig cfg,
const FTagOptions options 
)
private

Definition at line 363 of file CustomGetterUtils.cxx.

363  {
364  const std::string prefix = options.track_prefix;
365  switch (cfg.type) {
366  case ConstituentsEDMType::INT: return {
367  NamedSeqGetter<int, T>(cfg.name), {cfg.name}
368  };
369  case ConstituentsEDMType::FLOAT: return {
370  NamedSeqGetter<float, T>(cfg.name), {cfg.name}
371  };
372  case ConstituentsEDMType::CHAR: return {
373  NamedSeqGetter<char, T>(cfg.name), {cfg.name}
374  };
375  case ConstituentsEDMType::UCHAR: return {
376  NamedSeqGetter<unsigned char, T>(cfg.name), {cfg.name}
377  };
380  cfg.name, options.track_prefix);
381  }
382  default: {
383  throw std::logic_error("Unknown EDM type for constituent.");
384  }
385  }
386  }

Member Data Documentation

◆ m_deps

template<typename T >
std::set<std::string> FlavorTagDiscriminants::getter_utils::SeqGetter< T >::m_deps
private

Definition at line 93 of file CustomGetterUtils.h.

◆ m_sequence_getters

template<typename T >
std::vector<InputSequence> FlavorTagDiscriminants::getter_utils::SeqGetter< T >::m_sequence_getters
private

Definition at line 92 of file CustomGetterUtils.h.

◆ m_used_remap

template<typename T >
std::set<std::string> FlavorTagDiscriminants::getter_utils::SeqGetter< T >::m_used_remap
private

Definition at line 94 of file CustomGetterUtils.h.


The documentation for this class was generated from the following files:
FlavorTagDiscriminants::getter_utils::SeqGetter::m_sequence_getters
std::vector< InputSequence > m_sequence_getters
Definition: CustomGetterUtils.h:92
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FlavorTagDiscriminants::getter_utils::SeqGetter::seqFromConsituents
std::pair< InputSequence, std::set< std::string > > seqFromConsituents(const InputVariableConfig &cfg, const FTagOptions &options)
Definition: CustomGetterUtils.cxx:363
FlavorTagDiscriminants::getter_utils::SeqGetter::m_deps
std::set< std::string > m_deps
Definition: CustomGetterUtils.h:93
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
FlavorTagDiscriminants::getter_utils::SeqGetter::m_used_remap
std::set< std::string > m_used_remap
Definition: CustomGetterUtils.h:94
FlavorTagDiscriminants::getter_utils::SeqGetter::Const
Constituents< T > Const
Definition: CustomGetterUtils.h:72
FlavorTagDiscriminants::ConstituentsEDMType::CUSTOM_GETTER
@ CUSTOM_GETTER
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
beamspotman.n
n
Definition: beamspotman.py:731
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
FlavorTagDiscriminants::ConstituentsEDMType::UCHAR
@ UCHAR
python.PyAthena.v
v
Definition: PyAthena.py:157
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
FlavorTagDiscriminants::ConstituentsEDMType::CHAR
@ CHAR
h
remap
std::map< std::string, std::string > remap
list of directories to be explicitly remapped
Definition: hcg.cxx:92
FlavorTagDiscriminants::ConstituentsEDMType::FLOAT
@ FLOAT
FlavorTagDiscriminants::ConstituentsEDMType::INT
@ INT
FlavorTagDiscriminants::getter_utils::SeqGetter::getNamedCustomSeqGetter
std::pair< InputSequence, std::set< std::string > > getNamedCustomSeqGetter(const std::string &name, const std::string &prefix)
Definition: CustomGetterUtils.cxx:351