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

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

#include <CustomGetterUtils.h>

Collaboration diagram for InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >:

Public Types

using Constituents = std::vector< const T * >
 
using NamedSequenceFromConstituents = std::function< std::pair< std::string, std::vector< double > >(const xAOD::Vertex &, const Constituents &)>
 

Public Member Functions

 CustomSequenceGetter (std::vector< InputVariableConfig > inputs)
 
std::pair< std::vector< float >, std::vector< int64_t > > getFeats (const xAOD::Vertex &jet, const Constituents &constituents) const
 

Private Member Functions

std::pair< NamedSequenceFromConstituents, std::set< std::string > > customNamedSeqGetterWithDeps (const std::string &name)
 
std::pair< NamedSequenceFromConstituents, std::set< std::string > > seqFromConsituents (const InputVariableConfig &cfg)
 

Private Attributes

std::vector< NamedSequenceFromConstituentsm_sequencesFromConstituents
 

Detailed Description

template<typename T>
class InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >

Template class to extract features from sequence of constituents.

Template Parameters
Tconstituent type

It supports the following types of constituents:

Definition at line 81 of file InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/CustomGetterUtils.h.

Member Typedef Documentation

◆ Constituents

template<typename T >
using InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >::Constituents = std::vector<const T*>

◆ NamedSequenceFromConstituents

template<typename T >
using InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >::NamedSequenceFromConstituents = std::function<std::pair<std::string, std::vector<double> >( const xAOD::Vertex&, const Constituents&)>

Constructor & Destructor Documentation

◆ CustomSequenceGetter()

Definition at line 263 of file InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/Root/CustomGetterUtils.cxx.

265  {
266  for (const InputVariableConfig& input_cfg: inputs) {
267  auto [seqGetter, seq_deps] = seqFromConsituents(input_cfg);
268 
269  m_sequencesFromConstituents.push_back(seqGetter);
270  }
271  }

Member Function Documentation

◆ customNamedSeqGetterWithDeps()

template<typename T >
std::pair< typename CustomSequenceGetter< T >::NamedSequenceFromConstituents, std::set< std::string > > InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >::customNamedSeqGetterWithDeps ( const std::string &  name)
private

Definition at line 224 of file InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/Root/CustomGetterUtils.cxx.

224  {
225  auto [getter, deps] = customSequenceGetterWithDeps<T>(name);
226  return {
227  [n=name, g=getter](const xAOD::Vertex& j,
228  const std::vector<const T*>& t) {
229  return std::make_pair(n, g(j, t));
230  },
231  deps
232  };
233  }

◆ getFeats()

template<typename T >
std::pair< std::vector< float >, std::vector< int64_t > > InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >::getFeats ( const xAOD::Vertex jet,
const Constituents constituents 
) const

Definition at line 274 of file InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/Root/CustomGetterUtils.cxx.

276  {
277  std::vector<float> cnsts_feats;
278  int num_vars = m_sequencesFromConstituents.size();
279  int num_cnsts = 0;
280 
281  int cnst_var_idx = 0;
282  for (const auto& seq_builder: m_sequencesFromConstituents){
283  auto double_vec = seq_builder(vertex, constituents).second;
284 
285  if (cnst_var_idx==0){
286  num_cnsts = static_cast<int>(double_vec.size());
287  cnsts_feats.resize(num_cnsts * num_vars);
288  }
289 
290  // need to transpose + flatten
291  for (unsigned int cnst_idx=0; cnst_idx<double_vec.size(); cnst_idx++){
292  cnsts_feats.at(cnst_idx*num_vars + cnst_var_idx)
293  = double_vec.at(cnst_idx);
294  }
295  cnst_var_idx++;
296  }
297  std::vector<int64_t> cnsts_feat_dim = {num_cnsts, num_vars};
298  return {cnsts_feats, cnsts_feat_dim};
299  }

◆ seqFromConsituents()

template<typename T >
std::pair< typename CustomSequenceGetter< T >::NamedSequenceFromConstituents, std::set< std::string > > InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >::seqFromConsituents ( const InputVariableConfig cfg)
private

Definition at line 237 of file InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/Root/CustomGetterUtils.cxx.

238  {
239  switch (cfg.type) {
240  case ConstituentsEDMType::INT: return {
241  SequenceGetter<int, T>(cfg.name), {cfg.name}
242  };
243  case ConstituentsEDMType::FLOAT: return {
244  SequenceGetter<float, T>(cfg.name), {cfg.name}
245  };
246  case ConstituentsEDMType::CHAR: return {
247  SequenceGetter<char, T>(cfg.name), {cfg.name}
248  };
249  case ConstituentsEDMType::UCHAR: return {
250  SequenceGetter<unsigned char, T>(cfg.name), {cfg.name}
251  };
254  cfg.name);
255  }
256  default: {
257  throw std::logic_error("Unknown EDM type for constituent.");
258  }
259  }
260  }

Member Data Documentation

◆ m_sequencesFromConstituents

template<typename T >
std::vector<NamedSequenceFromConstituents> InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter< T >::m_sequencesFromConstituents
private

The documentation for this class was generated from the following files:
InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter::seqFromConsituents
std::pair< NamedSequenceFromConstituents, std::set< std::string > > seqFromConsituents(const InputVariableConfig &cfg)
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/Root/CustomGetterUtils.cxx:237
InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter::customNamedSeqGetterWithDeps
std::pair< NamedSequenceFromConstituents, std::set< std::string > > customNamedSeqGetterWithDeps(const std::string &name)
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/Root/CustomGetterUtils.cxx:224
InDetGNNHardScatterSelection::ConstituentsEDMType::CHAR
@ CHAR
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
InDetGNNHardScatterSelection::ConstituentsEDMType::UCHAR
@ UCHAR
InDetGNNHardScatterSelection::ConstituentsEDMType::INT
@ INT
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:731
InDetGNNHardScatterSelection::ConstituentsEDMType::FLOAT
@ FLOAT
InDetGNNHardScatterSelection::ConstituentsEDMType::CUSTOM_GETTER
@ CUSTOM_GETTER
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
InDetGNNHardScatterSelection::getter_utils::CustomSequenceGetter::m_sequencesFromConstituents
std::vector< NamedSequenceFromConstituents > m_sequencesFromConstituents
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/CustomGetterUtils.h:96