YODA is hosted by Hepforge, IPPP Durham
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
< Point3D
Points
 
- 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

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...
 
const std::vector< std::string > annotations () const
 Get all the annotation names. More...
 
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...
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name. 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
 
void setTitle (const std::string &title)
 Set the AO title. More...
 
const std::string path () const
 
void setPath (const std::string &path)
 Set the AO path. More...
 
virtual std::string type () const
 Get name of the analysis object type, for persistency. More...
 

Detailed Description

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

Definition at line 23 of file Scatter3D.h.

Member Typedef Documentation

Types of the native Point3D collection.

Definition at line 27 of file Scatter3D.h.

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

Definition at line 28 of file Scatter3D.h.

Constructor & Destructor Documentation

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

Empty constructor.

Definition at line 35 of file Scatter3D.h.

Referenced by clone(), and newclone().

36  : AnalysisObject("Scatter3D", path, title)
37  { }
AnalysisObject()
Default constructor.
const std::string path() const
const std::string title() const
YODA::Scatter3D::Scatter3D ( const Points points,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a set of points.

Definition at line 41 of file Scatter3D.h.

43  : AnalysisObject("Scatter3D", path, title),
44  _points(points)
45  {
46  std::sort(_points.begin(), _points.end());
47  }
AnalysisObject()
Default constructor.
const std::string path() const
Points & points()
Get the collection of points (non-const)
Definition: Scatter3D.h:187
const std::string title() const
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 51 of file Scatter3D.h.

References addPoint().

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

References addPoint().

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

References addPoint().

97  : AnalysisObject("Scatter3D", path, title)
98  {
99  if(x.size() != y.size() || y.size() != z.size() ||
100  x.size() != exminus.size() || x.size() != explus.size() ||
101  y.size() != eyminus.size() || y.size() != eyplus.size() ||
102  z.size() != ezminus.size() || z.size() != ezplus.size())
103  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!");
104 
105  for (size_t i = 0; i < x.size(); ++i) {
106  addPoint(Point3D(x[i], y[i], z[i], exminus[i], explus[i], eyminus[i], eyplus[i], ezminus[i], ezplus[i]));
107  }
108 
109  std::sort(_points.begin(), _points.end());
110  }
AnalysisObject()
Default constructor.
const std::string path() const
const std::string title() const
void addPoint(const Point3D &pt)
Insert a new point.
Definition: Scatter3D.h:218
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 115 of file Scatter3D.h.

116  : AnalysisObject("Scatter3D", (path.size() == 0) ? s3.path() : path, s3, s3.title()),
117  _points(s3._points)
118  { }
AnalysisObject()
Default constructor.
const std::string path() const

Member Function Documentation

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

Insert a new point.

Definition at line 218 of file Scatter3D.h.

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

218  {
219  _points.insert(pt);
220  }
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 223 of file Scatter3D.h.

223  {
224  _points.insert(Point3D(x, y, z));
225  }
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 228 of file Scatter3D.h.

229  {
230  _points.insert(Point3D(x, y, z, ex, ey, ez));
231  }
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 234 of file Scatter3D.h.

235  {
236  _points.insert(Point3D(x, y, z, ex, ey, ez));
237  }
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 240 of file Scatter3D.h.

243  {
244  _points.insert(Point3D(x, y, z, exminus, explus, eyminus, eyplus, ezminus, ezplus));
245  }
void YODA::Scatter3D::addPoints ( const Points pts)
inline

Insert a collection of new points.

Definition at line 248 of file Scatter3D.h.

References addPoint().

Referenced by combineWith().

248  {
249  BOOST_FOREACH (const Point3D& pt, pts) addPoint(pt);
250  }
void addPoint(const Point3D &pt)
Insert a new point.
Definition: Scatter3D.h:218
Scatter3D YODA::Scatter3D::clone ( ) const
inline

Make a copy on the stack.

Definition at line 128 of file Scatter3D.h.

References Scatter3D().

128  {
129  return Scatter3D(*this);
130  }
Scatter3D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter3D.h:35
void YODA::Scatter3D::combineWith ( const Scatter3D other)
inline
Todo:
Better name?

Definition at line 256 of file Scatter3D.h.

References addPoints(), and points().

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

256  {
257  addPoints(other.points());
258  //return *this;
259  }
void addPoints(const Points &pts)
Insert a collection of new points.
Definition: Scatter3D.h:248
void YODA::Scatter3D::combineWith ( const std::vector< Scatter3D > &  others)
inline
Todo:

Better name?

Convert to accept a Range or generic

Definition at line 264 of file Scatter3D.h.

References combineWith().

264  {
265  BOOST_FOREACH (const Scatter3D& s, others) combineWith(s);
266  //return *this;
267  }
void combineWith(const Scatter3D &other)
Definition: Scatter3D.h:256
Scatter3D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter3D.h:35
Scatter3D* YODA::Scatter3D::newclone ( ) const
inlinevirtual

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

Implements YODA::AnalysisObject.

Definition at line 133 of file Scatter3D.h.

References Scatter3D().

133  {
134  return new Scatter3D(*this);
135  }
Scatter3D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter3D.h:35
size_t YODA::Scatter3D::numPoints ( ) const
inline

Number of points in the scatter.

Definition at line 181 of file Scatter3D.h.

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

181  {
182  return _points.size();
183  }
bool YODA::Scatter3D::operator!= ( const Scatter3D other)
inline

Non-equality operator.

Definition at line 276 of file Scatter3D.h.

References operator==().

276  {
277  return ! operator == (other);
278  }
bool operator==(const Scatter3D &other)
Equality operator.
Definition: Scatter3D.h:271
Scatter3D& YODA::Scatter3D::operator= ( const Scatter3D s3)
inline

Assignment operator.

Definition at line 121 of file Scatter3D.h.

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

121  {
122  AnalysisObject::operator = (s3); //< AO treatment of paths etc.
123  _points = s3._points;
124  return *this;
125  }
virtual AnalysisObject & operator=(const AnalysisObject &ao)
Default copy assignment operator.
bool YODA::Scatter3D::operator== ( const Scatter3D other)
inline

Equality operator.

Definition at line 271 of file Scatter3D.h.

Referenced by operator!=().

271  {
272  return _points == other._points;
273  }
Point3D& YODA::Scatter3D::point ( size_t  index)
inline

Get a reference to the point with index index.

Definition at line 199 of file Scatter3D.h.

References numPoints().

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

199  {
200  if (index >= numPoints()) throw RangeError("There is no point with this index");
201  return _points.at(index);
202  }
size_t numPoints() const
Number of points in the scatter.
Definition: Scatter3D.h:181
const Point3D& YODA::Scatter3D::point ( size_t  index) const
inline

Get the point with index index (const version)

Definition at line 206 of file Scatter3D.h.

References numPoints().

206  {
207  if (index >= numPoints()) throw RangeError("There is no point with such index!");
208  return _points.at(index);
209  }
size_t numPoints() const
Number of points in the scatter.
Definition: Scatter3D.h:181
Points& YODA::Scatter3D::points ( )
inline

Get the collection of points (non-const)

Definition at line 187 of file Scatter3D.h.

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

187  {
188  return _points;
189  }
const Points& YODA::Scatter3D::points ( ) const
inline

Get the collection of points (const)

Definition at line 193 of file Scatter3D.h.

193  {
194  return _points;
195  }
void YODA::Scatter3D::reset ( )
inlinevirtual

Clear all points.

Implements YODA::AnalysisObject.

Definition at line 144 of file Scatter3D.h.

144  {
145  _points.clear();
146  }
void YODA::Scatter3D::scale ( double  scalex,
double  scaley,
double  scalez 
)
inline

Scaling of all three axes

Deprecated:
Use scaleXYZ

Definition at line 170 of file Scatter3D.h.

References scaleXYZ().

170  {
171  scaleXYZ(scalex, scaley, scalez);
172  }
void scaleXYZ(double scalex, double scaley, double scalez)
Scaling of all three axes.
Definition: Scatter3D.h:164
void YODA::Scatter3D::scaleX ( double  scalex)
inline

Scaling of x axis.

Definition at line 149 of file Scatter3D.h.

References YODA::Point3D::scaleX().

149  {
150  BOOST_FOREACH (Point3D& p, _points) p.scaleX(scalex);
151  }
void scaleX(double scalex)
Scaling of x axis.
Definition: Scatter3D.h:149
void YODA::Scatter3D::scaleXYZ ( double  scalex,
double  scaley,
double  scalez 
)
inline

Scaling of all three axes.

Definition at line 164 of file Scatter3D.h.

References YODA::Point3D::scaleXYZ().

Referenced by scale().

164  {
165  BOOST_FOREACH (Point3D& p, _points) p.scaleXYZ(scalex, scaley, scalez);
166  }
void scaleXYZ(double scalex, double scaley, double scalez)
Scaling of all three axes.
Definition: Scatter3D.h:164
void YODA::Scatter3D::scaleY ( double  scaley)
inline

Scaling of y axis.

Definition at line 154 of file Scatter3D.h.

References YODA::Point3D::scaleY().

154  {
155  BOOST_FOREACH (Point3D& p, _points) p.scaleY(scaley);
156  }
void scaleY(double scaley)
Scaling of y axis.
Definition: Scatter3D.h:154
void YODA::Scatter3D::scaleZ ( double  scalez)
inline

Scaling of z axis.

Definition at line 159 of file Scatter3D.h.

References YODA::Point3D::scaleZ().

159  {
160  BOOST_FOREACH (Point3D& p, _points) p.scaleZ(scalez);
161  }
void scaleZ(double scalez)
Scaling of z axis.
Definition: Scatter3D.h:159

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