yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
YODA::Scatter3D Class Reference

A very generic data type which is just a collection of 3D data points with errors. More...

#include <Scatter3D.h>

Inheritance diagram for YODA::Scatter3D:
YODA::AnalysisObject

Public Types

typedef Point3D Point
 Types of the native Point3D collection. More...
 
typedef Utils::sortedvector< Point3DPoints
 
typedef std::shared_ptr< Scatter3DPtr
 
- Public Types inherited from YODA::AnalysisObject
typedef std::map< std::string, std::string > Annotations
 Collection type for annotations, as a string-string map. More...
 

Public Member Functions

size_t dim () const
 Dimension of this data object. More...
 
const std::vector< std::string > variations () const
 Get the list of variations stored in the points. More...
 
void combineWith (const Scatter3D &other)
 
void combineWith (const std::vector< Scatter3D > &others)
 
bool operator== (const Scatter3D &other)
 Equality operator. More...
 
bool operator!= (const Scatter3D &other)
 Non-equality operator. More...
 
Constructors
 Scatter3D (const std::string &path="", const std::string &title="")
 Empty constructor. More...
 
 Scatter3D (const Points &points, const std::string &path="", const std::string &title="")
 Constructor from a set of points. More...
 
 Scatter3D (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::string &path="", const std::string &title="")
 Constructor from vectors of values with no errors. More...
 
 Scatter3D (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< std::pair< double, double > > &ex, const std::vector< std::pair< double, double > > &ey, const std::vector< std::pair< double, double > > &ez, const std::string &path="", const std::string &title="")
 Constructor from vectors of values with asymmetric errors on both x and y. More...
 
 Scatter3D (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > z, const std::vector< double > &exminus, const std::vector< double > &explus, const std::vector< double > &eyminus, const std::vector< double > &eyplus, const std::vector< double > &ezminus, const std::vector< double > &ezplus, const std::string &path="", const std::string &title="")
 Constructor from vectors of values with completely explicit asymmetric errors. More...
 
 Scatter3D (const Scatter3D &s3, const std::string &path="")
 
Scatter3Doperator= (const Scatter3D &s3)
 Assignment operator. More...
 
Scatter3D clone () const
 Make a copy on the stack. More...
 
Scatter3Dnewclone () const
 Make a copy on the heap, via 'new'. More...
 
Modifiers
void reset ()
 Clear all points. More...
 
void scaleX (double scalex)
 Scaling of x axis. More...
 
void scaleY (double scaley)
 Scaling of y axis. More...
 
void scaleZ (double scalez)
 Scaling of z axis. More...
 
void scaleXYZ (double scalex, double scaley, double scalez)
 Scaling of all three axes. More...
 
void scale (double scalex, double scaley, double scalez)
 
Point accessors
size_t numPoints () const
 Number of points in the scatter. More...
 
Pointspoints ()
 Get the collection of points (non-const) More...
 
const Pointspoints () const
 Get the collection of points (const) More...
 
Point3Dpoint (size_t index)
 Get a reference to the point with index index. More...
 
const Point3Dpoint (size_t index) const
 Get the point with index index (const version) More...
 
Point inserters
void addPoint (const Point3D &pt)
 Insert a new point. More...
 
void addPoint (double x, double y, double z)
 Insert a new point, defined as the x/y/z value triplet and no errors. More...
 
void addPoint (double x, double y, double z, double ex, double ey, double ez)
 Insert a new point, defined as the x/y/z value triplet and symmetric errors. More...
 
void addPoint (double x, double y, double z, const std::pair< double, double > &ex, const std::pair< double, double > &ey, const std::pair< double, double > &ez)
 Insert a new point, defined as the x/y/z value triplet and asymmetric error pairs. More...
 
void addPoint (double x, double y, double z, double exminus, double explus, double eyminus, double eyplus, double ezminus, double ezplus)
 Insert a new point, defined as the x/y/z value triplet and asymmetric errors. More...
 
void addPoints (const Points &pts)
 Insert a collection of new points. More...
 
- Public Member Functions inherited from YODA::AnalysisObject
 AnalysisObject ()
 Default constructor. More...
 
 AnalysisObject (const std::string &type, const std::string &path, const std::string &title="")
 Constructor giving a type, a path and an optional title. More...
 
 AnalysisObject (const std::string &type, const std::string &path, const AnalysisObject &ao, const std::string &title="")
 Constructor giving a type, a path, another AO to copy annotation from, and an optional title. More...
 
virtual ~AnalysisObject ()
 Default destructor. More...
 
virtual AnalysisObjectoperator= (const AnalysisObject &ao)
 Default copy assignment operator. More...
 
std::vector< std::string > annotations () const
 
bool hasAnnotation (const std::string &name) const
 Check if an annotation is defined. More...
 
const std::string & annotation (const std::string &name) const
 Get an annotation by name (as a string) More...
 
const std::string & annotation (const std::string &name, const std::string &defaultreturn) const
 Get an annotation by name (as a string) with a default in case the annotation is not found. More...
 
template<typename T >
const T annotation (const std::string &name) const
 Get an annotation by name (copied to another type) More...
 
template<typename T >
const T annotation (const std::string &name, const T &defaultreturn) const
 Get an annotation by name (copied to another type) with a default in case the annotation is not found. More...
 
void setAnnotation (const std::string &name, const std::string &value)
 Add or set a string-valued annotation by name. More...
 
void setAnnotation (const std::string &name, double value)
 Add or set a double-valued annotation by name. More...
 
void setAnnotation (const std::string &name, float value)
 Add or set a float-valued annotation by name. More...
 
void setAnnotation (const std::string &name, long double value)
 Add or set a long-double-valued annotation by name. More...
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name (templated for remaining types) More...
 
void setAnnotations (const Annotations &anns)
 Set all annotations at once. More...
 
template<typename T >
void addAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name. More...
 
void rmAnnotation (const std::string &name)
 Delete an annotation by name. More...
 
void clearAnnotations ()
 Delete an annotation by name. More...
 
const std::string title () const
 Get the AO title. More...
 
void setTitle (const std::string &title)
 Set the AO title. More...
 
const std::string path () const
 Get the AO path. More...
 
void setPath (const std::string &path)
 
const std::string name () const
 
virtual std::string type () const
 Get name of the analysis object type. More...
 

Detailed Description

A very generic data type which is just a collection of 3D data points with errors.

Definition at line 24 of file Scatter3D.h.

Member Typedef Documentation

◆ Point

Types of the native Point3D collection.

Definition at line 28 of file Scatter3D.h.

◆ Points

typedef Utils::sortedvector<Point3D> YODA::Scatter3D::Points

Definition at line 29 of file Scatter3D.h.

◆ Ptr

typedef std::shared_ptr<Scatter3D> YODA::Scatter3D::Ptr

Definition at line 30 of file Scatter3D.h.

Constructor & Destructor Documentation

◆ Scatter3D() [1/6]

YODA::Scatter3D::Scatter3D ( const std::string &  path = "",
const std::string &  title = "" 
)
inline

Empty constructor.

Definition at line 37 of file Scatter3D.h.

Referenced by clone(), YODA::mkScatter(), and newclone().

38  : AnalysisObject("Scatter3D", path, title)
39  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Scatter3D() [2/6]

YODA::Scatter3D::Scatter3D ( const Points points,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a set of points.

Definition at line 43 of file Scatter3D.h.

45  : AnalysisObject("Scatter3D", path, title),
46  _points(points)
47  {
48  std::sort(_points.begin(), _points.end());
49  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.
Points & points()
Get the collection of points (non-const)
Definition: Scatter3D.h:202

◆ Scatter3D() [3/6]

YODA::Scatter3D::Scatter3D ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  z,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from vectors of values with no errors.

Definition at line 53 of file Scatter3D.h.

References addPoint().

58  : AnalysisObject("Scatter3D", path, title)
59  {
60  if (x.size() != y.size() || y.size() != z.size()) {
61  throw RangeError("There are different numbers of x, y, and z values in the provided vectors.");
62  }
63  const std::pair<double,double> nullerr = std::make_pair(0.0, 0.0);
64  for (size_t i = 0; i < x.size(); ++i) {
65  addPoint(Point3D(x[i], y[i], z[i], nullerr, nullerr, nullerr));
66  }
67  std::sort(_points.begin(), _points.end());
68  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.
void addPoint(const Point3D &pt)
Insert a new point.
Definition: Scatter3D.h:233

◆ Scatter3D() [4/6]

YODA::Scatter3D::Scatter3D ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  z,
const std::vector< std::pair< double, double > > &  ex,
const std::vector< std::pair< double, double > > &  ey,
const std::vector< std::pair< double, double > > &  ez,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from vectors of values with asymmetric errors on both x and y.

Definition at line 72 of file Scatter3D.h.

References addPoint().

75  : AnalysisObject("Scatter3D", path, title)
76  {
77  if (x.size() != y.size() || y.size() != z.size()) {
78  throw RangeError("There are different numbers of x, y, and z values in the provided vectors.");
79  }
80  if (x.size() != ex.size() || y.size() != ey.size() || z.size() != ez.size()) {
81  throw RangeError("The sizes of the provided error vectors don't match the corresponding x, y, or z value vectors.");
82  }
83  for (size_t i = 0; i < x.size(); ++i) {
84  addPoint(Point3D(x[i], y[i], z[i], ex[i], ey[i], ez[i]));
85  }
86  std::sort(_points.begin(), _points.end());
87  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.
void addPoint(const Point3D &pt)
Insert a new point.
Definition: Scatter3D.h:233

◆ Scatter3D() [5/6]

YODA::Scatter3D::Scatter3D ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double >  z,
const std::vector< double > &  exminus,
const std::vector< double > &  explus,
const std::vector< double > &  eyminus,
const std::vector< double > &  eyplus,
const std::vector< double > &  ezminus,
const std::vector< double > &  ezplus,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from vectors of values with completely explicit asymmetric errors.

Definition at line 91 of file Scatter3D.h.

References addPoint().

99  : AnalysisObject("Scatter3D", path, title)
100  {
101  if(x.size() != y.size() || y.size() != z.size() ||
102  x.size() != exminus.size() || x.size() != explus.size() ||
103  y.size() != eyminus.size() || y.size() != eyplus.size() ||
104  z.size() != ezminus.size() || z.size() != ezplus.size())
105  throw RangeError("There are either different amounts of points on x/y/z vectors or not every of these vectors has properly defined error vectors!");
106 
107  for (size_t i = 0; i < x.size(); ++i) {
108  addPoint(Point3D(x[i], y[i], z[i], exminus[i], explus[i], eyminus[i], eyplus[i], ezminus[i], ezplus[i]));
109  }
110 
111  std::sort(_points.begin(), _points.end());
112  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.
void addPoint(const Point3D &pt)
Insert a new point.
Definition: Scatter3D.h:233

◆ Scatter3D() [6/6]

YODA::Scatter3D::Scatter3D ( const Scatter3D s3,
const std::string &  path = "" 
)
inline

Copy constructor with optional new path

Todo:
Also allow title setting from the constructor?

Definition at line 117 of file Scatter3D.h.

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), and YODA::AnalysisObject::setAnnotation().

118  : AnalysisObject("Scatter3D", (path.size() == 0) ? s3.path() : path, s3, s3.title()),
119  _points(s3._points)
120  {
121  for ( auto &ann : annotations()){
122  setAnnotation(ann, annotation(ann));
123  }
124  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string & annotation(const std::string &name) const
Get an annotation by name (as a string)
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

Member Function Documentation

◆ addPoint() [1/5]

void YODA::Scatter3D::addPoint ( const Point3D pt)
inline

Insert a new point.

Definition at line 233 of file Scatter3D.h.

Referenced by addPoints(), YODA::divide(), YODA::mkScatter(), Scatter3D(), and YODA::toScatter3D().

233  {
234  _points.insert(pt);
235  }

◆ addPoint() [2/5]

void YODA::Scatter3D::addPoint ( double  x,
double  y,
double  z 
)
inline

Insert a new point, defined as the x/y/z value triplet and no errors.

Definition at line 238 of file Scatter3D.h.

238  {
239  _points.insert(Point3D(x, y, z));
240  }

◆ addPoint() [3/5]

void YODA::Scatter3D::addPoint ( double  x,
double  y,
double  z,
double  ex,
double  ey,
double  ez 
)
inline

Insert a new point, defined as the x/y/z value triplet and symmetric errors.

Definition at line 243 of file Scatter3D.h.

244  {
245  _points.insert(Point3D(x, y, z, ex, ey, ez));
246  }

◆ addPoint() [4/5]

void YODA::Scatter3D::addPoint ( double  x,
double  y,
double  z,
const std::pair< double, double > &  ex,
const std::pair< double, double > &  ey,
const std::pair< double, double > &  ez 
)
inline

Insert a new point, defined as the x/y/z value triplet and asymmetric error pairs.

Definition at line 249 of file Scatter3D.h.

250  {
251  _points.insert(Point3D(x, y, z, ex, ey, ez));
252  }

◆ addPoint() [5/5]

void YODA::Scatter3D::addPoint ( double  x,
double  y,
double  z,
double  exminus,
double  explus,
double  eyminus,
double  eyplus,
double  ezminus,
double  ezplus 
)
inline

Insert a new point, defined as the x/y/z value triplet and asymmetric errors.

Definition at line 255 of file Scatter3D.h.

258  {
259  _points.insert(Point3D(x, y, z, exminus, explus, eyminus, eyplus, ezminus, ezplus));
260  }

◆ addPoints()

void YODA::Scatter3D::addPoints ( const Points pts)
inline

Insert a collection of new points.

Definition at line 263 of file Scatter3D.h.

References addPoint().

Referenced by combineWith().

263  {
264  for (const Point3D& pt : pts) addPoint(pt);
265  }
void addPoint(const Point3D &pt)
Insert a new point.
Definition: Scatter3D.h:233

◆ clone()

Scatter3D YODA::Scatter3D::clone ( ) const
inline

Make a copy on the stack.

Definition at line 134 of file Scatter3D.h.

References Scatter3D().

134  {
135  return Scatter3D(*this);
136  }
Scatter3D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter3D.h:37

◆ combineWith() [1/2]

void YODA::Scatter3D::combineWith ( const Scatter3D other)
inline
Todo:
Better name?

Definition at line 271 of file Scatter3D.h.

References addPoints(), and points().

Referenced by YODA::combine(), and combineWith().

271  {
272  addPoints(other.points());
273  //return *this;
274  }
void addPoints(const Points &pts)
Insert a collection of new points.
Definition: Scatter3D.h:263

◆ combineWith() [2/2]

void YODA::Scatter3D::combineWith ( const std::vector< Scatter3D > &  others)
inline
Todo:

Better name?

Convert to accept a Range or generic

Definition at line 279 of file Scatter3D.h.

References combineWith().

279  {
280  for (const Scatter3D& s : others) combineWith(s);
281  }
void combineWith(const Scatter3D &other)
Definition: Scatter3D.h:271
Scatter3D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter3D.h:37

◆ dim()

size_t YODA::Scatter3D::dim ( ) const
inlinevirtual

Dimension of this data object.

Implements YODA::AnalysisObject.

Definition at line 147 of file Scatter3D.h.

147 { return 3; }

◆ newclone()

Scatter3D* YODA::Scatter3D::newclone ( ) const
inlinevirtual

Make a copy on the heap, via 'new'.

Implements YODA::AnalysisObject.

Definition at line 139 of file Scatter3D.h.

References Scatter3D().

Referenced by YODA::toNewScatter3D().

139  {
140  return new Scatter3D(*this);
141  }
Scatter3D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter3D.h:37

◆ numPoints()

size_t YODA::Scatter3D::numPoints ( ) const
inline

Number of points in the scatter.

Definition at line 196 of file Scatter3D.h.

Referenced by YODA::divide(), point(), YODA::transformX(), YODA::transformY(), and YODA::transformZ().

196  {
197  return _points.size();
198  }

◆ operator!=()

bool YODA::Scatter3D::operator!= ( const Scatter3D other)
inline

Non-equality operator.

Definition at line 290 of file Scatter3D.h.

References operator==().

290  {
291  return ! operator == (other);
292  }
bool operator==(const Scatter3D &other)
Equality operator.
Definition: Scatter3D.h:285

◆ operator=()

Scatter3D& YODA::Scatter3D::operator= ( const Scatter3D s3)
inline

Assignment operator.

Definition at line 127 of file Scatter3D.h.

References YODA::AnalysisObject::operator=().

127  {
128  AnalysisObject::operator = (s3); //< AO treatment of paths etc.
129  _points = s3._points;
130  return *this;
131  }
virtual AnalysisObject & operator=(const AnalysisObject &ao)
Default copy assignment operator.

◆ operator==()

bool YODA::Scatter3D::operator== ( const Scatter3D other)
inline

Equality operator.

Definition at line 285 of file Scatter3D.h.

Referenced by operator!=().

285  {
286  return _points == other._points;
287  }

◆ point() [1/2]

Point3D& YODA::Scatter3D::point ( size_t  index)
inline

Get a reference to the point with index index.

Definition at line 214 of file Scatter3D.h.

References numPoints().

Referenced by YODA::efficiency(), YODA::transformX(), YODA::transformY(), YODA::transformZ(), and variations().

214  {
215  if (index >= numPoints()) throw RangeError("There is no point with this index");
216  return _points.at(index);
217  }
size_t numPoints() const
Number of points in the scatter.
Definition: Scatter3D.h:196

◆ point() [2/2]

const Point3D& YODA::Scatter3D::point ( size_t  index) const
inline

Get the point with index index (const version)

Definition at line 221 of file Scatter3D.h.

References numPoints().

221  {
222  if (index >= numPoints()) throw RangeError("There is no point with such index!");
223  return _points.at(index);
224  }
size_t numPoints() const
Number of points in the scatter.
Definition: Scatter3D.h:196

◆ points() [1/2]

Points& YODA::Scatter3D::points ( )
inline

Get the collection of points (non-const)

Definition at line 202 of file Scatter3D.h.

Referenced by combineWith(), YODA::Histo2D::Histo2D(), YODA::Profile2D::Profile2D(), and YODA::WriterFLAT::writeScatter3D().

202  {
203  return _points;
204  }

◆ points() [2/2]

const Points& YODA::Scatter3D::points ( ) const
inline

Get the collection of points (const)

Definition at line 208 of file Scatter3D.h.

208  {
209  return _points;
210  }

◆ reset()

void YODA::Scatter3D::reset ( )
inlinevirtual

Clear all points.

Implements YODA::AnalysisObject.

Definition at line 154 of file Scatter3D.h.

154  {
155  _points.clear();
156  }

◆ scale()

void YODA::Scatter3D::scale ( double  scalex,
double  scaley,
double  scalez 
)
inline

Scaling of all three axes

Deprecated:
Use scaleXYZ

Definition at line 180 of file Scatter3D.h.

References scaleXYZ(), and variations().

180  {
181  scaleXYZ(scalex, scaley, scalez);
182  }
void scaleXYZ(double scalex, double scaley, double scalez)
Scaling of all three axes.
Definition: Scatter3D.h:174

◆ scaleX()

void YODA::Scatter3D::scaleX ( double  scalex)
inline

Scaling of x axis.

Definition at line 159 of file Scatter3D.h.

159  {
160  for (Point3D& p : _points) p.scaleX(scalex);
161  }

◆ scaleXYZ()

void YODA::Scatter3D::scaleXYZ ( double  scalex,
double  scaley,
double  scalez 
)
inline

Scaling of all three axes.

Definition at line 174 of file Scatter3D.h.

Referenced by scale().

174  {
175  for (Point3D& p : _points) p.scaleXYZ(scalex, scaley, scalez);
176  }

◆ scaleY()

void YODA::Scatter3D::scaleY ( double  scaley)
inline

Scaling of y axis.

Definition at line 164 of file Scatter3D.h.

164  {
165  for (Point3D& p : _points) p.scaleY(scaley);
166  }

◆ scaleZ()

void YODA::Scatter3D::scaleZ ( double  scalez)
inline

Scaling of z axis.

Definition at line 169 of file Scatter3D.h.

169  {
170  for (Point3D& p : _points) p.scaleZ(scalez);
171  }

◆ variations()

const std::vector< std::string > YODA::Scatter3D::variations ( ) const

Get the list of variations stored in the points.

Definition at line 109 of file Scatter3D.cc.

References YODA::Point3D::errMap(), and point().

Referenced by scale().

109  {
110  std::vector<std::string> vecvariations;
111  for (auto &point : this->_points){
112  for (auto &it : point.errMap()){
113  //if the variation is not already in the vector, add it !
114  if (std::find(vecvariations.begin(), vecvariations.end(), it.first) == vecvariations.end()){
115  vecvariations.push_back(it.first);
116  }
117  }
118  }
119  return vecvariations;
120  }
Point3D & point(size_t index)
Get a reference to the point with index index.
Definition: Scatter3D.h:214
const std::map< std::string, std::pair< double, double > > & errMap() const
Get error map for direction i.
Definition: Point3D.h:465

The documentation for this class was generated from the following files: