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