yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
Scatter1D.cc
Go to the documentation of this file.
1 #include "YODA/Scatter1D.h"
2 #include "YODA/Counter.h"
3 #include <sstream>
4 
5 namespace YODA {
6 
7 
10  Scatter1D rtn;
11  for (const std::string& a : c.annotations())
12  rtn.setAnnotation(a, c.annotation(a));
13  rtn.setAnnotation("Type", c.type()); // might override the copied ones
14  rtn.addPoint(c.val(), c.err());
15  return rtn;
16  }
17 
18  const std::vector<std::string> Scatter1D::variations() const {
19  std::vector<std::string> vecvariations;
20  for (auto &point : this->_points){
21  for (auto &it : point.errMap()){
22  //if the variation is not already in the vector, add it !
23  if (std::find(vecvariations.begin(), vecvariations.end(), it.first) == vecvariations.end()){
24  vecvariations.push_back(it.first);
25  }
26  }
27  }
28  return vecvariations;
29  }
30 }
void addPoint(const Point1D &pt)
Insert a new point.
Definition: Scatter1D.h:188
A weighted counter.
Definition: Counter.h:23
Point1D & point(size_t index)
Get a reference to the point with index index (non-const)
Definition: Scatter1D.h:169
const std::string & annotation(const std::string &name) const
Get an annotation by name (as a string)
const std::vector< std::string > variations() const
Get the list of variations stored in the points.
Definition: Scatter1D.cc:18
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:9
double err() const
Definition: Counter.h:140
double val() const
Get the value.
Definition: Counter.h:135
virtual std::string type() const
Get name of the analysis object type.
const std::map< std::string, std::pair< double, double > > & errMap() const
Get error map for direction i.
Definition: Point1D.h:217
A very generic data type which is just a collection of 1D data points with errors.
Definition: Scatter1D.h:23
void setAnnotation(const std::string &name, const std::string &value)
Add or set a string-valued annotation by name.
std::vector< std::string > annotations() const