Belle II Software  release-05-02-19
VariableExtractor.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jonas Wagner *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 #include <vector>
13 #include <string>
14 #include <tracking/trackFindingVXD/utilities/Named.h>
15 #include <unordered_map>
16 
17 
18 namespace Belle2 {
23  class VariableExtractor {
25  public:
26 
27  protected:
29  void addVariable(const std::string& identifier, std::vector<Named<float*>>& variables)
30  {
31  //todo: verify if it is faster to check explicitly or not
32  auto value = m_variables.emplace(identifier, NAN).first;
33  variables.emplace_back(identifier, &(value->second));
34  }
35 
37  std::unordered_map<std::string, float> m_variables;
38  };
40 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VariableExtractor::m_variables
std::unordered_map< std::string, float > m_variables
unordered_map to associate float value with a string name
Definition: VariableExtractor.h:45
Belle2::VariableExtractor::addVariable
void addVariable(const std::string &identifier, std::vector< Named< float * >> &variables)
add a variable to the variable set
Definition: VariableExtractor.h:37