Belle II Software  release-08-01-10
NamedFloatTuple.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include <tracking/trackFindingCDC/varsets/NamedFloatTuple.h>
9 
10 using namespace Belle2;
11 using namespace TrackFindingCDC;
12 
14 
15 std::map<std::string, Float_t> NamedFloatTuple::getNamedValues(std::string prefix) const
16 {
17  std::map<std::string, Float_t> namedValues;
18  size_t nVars = size();
19 
20  for (size_t iVar = 0; iVar < nVars; ++iVar) {
21  std::string name = prefix + getName(iVar);
22  Float_t value = get(iVar);
23  namedValues[name] = value;
24  }
25 
26  return namedValues;
27 }
28 
29 std::vector<Named<Float_t*> > NamedFloatTuple::getNamedVariables(std::string prefix)
30 {
31  std::vector<Named<Float_t*> > namedVariables;
32  int nVars = size();
33  namedVariables.reserve(nVars);
34 
35  for (int iVar = 0; iVar < nVars; ++iVar) {
36  std::string name = prefix + getName(iVar);
37  Float_t& value = operator[](iVar);
38  namedVariables.emplace_back(name, &value);
39  }
40 
41  return namedVariables;
42 }
virtual Float_t & operator[](int iValue)=0
Reference getter for the value of the ith part.
std::vector< Named< Float_t * > > getNamedVariables(std::string prefix="")
Getter for named references to the variables in this tuple.
virtual Float_t get(int iValue) const =0
Getter for the value of the ith part.
virtual size_t size() const =0
Getter for the number of parts.
virtual std::string getName(int iValue) const =0
Getter for the ith name.
virtual ~NamedFloatTuple()
Marking the destructor virtual since we are using virtual functions.
std::map< std::string, Float_t > getNamedValues(std::string prefix="") const
Getter for a map of all name and value pairs in this tuple.
Abstract base class for different kinds of events.