Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:18

0001 // -*- C++ -*-
0002 //
0003 // DataPoint.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef LWH_DataPoint_H
0010 #define LWH_DataPoint_H
0011 //
0012 // This is the declaration of the DataPoint class representing
0013 //
0014 
0015 
0016 #include <limits>
0017 #include <cmath>
0018 #include <algorithm>
0019 #include "AIDataPoint.h"
0020 #include "Measurement.h"
0021 
0022 namespace LWH {
0023 
0024 using namespace AIDA;
0025 
0026 /**
0027  * An DataPoint represents a binned histogram axis. A 1D Histogram would have
0028  * one DataPoint representing the X axis, while a 2D Histogram would have two
0029  * axes representing the X and Y DataPoint.
0030  */
0031 class DataPoint: public IDataPoint {
0032 
0033 public:
0034 
0035   /**
0036    * Construct a data point with a given number of dimensions.
0037    */
0038   DataPoint(int dim = 2)
0039     : m(dim) {}
0040 
0041   /**
0042    * Copy constructor.
0043    */
0044   DataPoint(const DataPoint & d)
0045     : IDataPoint(d), m(d.m) {}
0046 
0047   /**
0048    * Copy from any IDataPoint.
0049    */
0050   DataPoint(const IDataPoint & id)
0051     : m(id.dimension()) {
0052     for ( int i = 0, N = m.size(); i < N; ++i )
0053       m[i] = Measurement(id.coordinate(i)->value(),
0054              id.coordinate(i)->errorPlus(),
0055              id.coordinate(i)->errorMinus());
0056   }
0057 
0058   /**
0059    *  Default assignment operator (to avoid compiler warnings).
0060    */
0061   DataPoint & operator=(const DataPoint &) = default;
0062   
0063   /**
0064    * Destructor.
0065    */
0066   virtual ~DataPoint() {}
0067 
0068   /**
0069    * Get the dimension of the IDataPoint, i.e. the number
0070    * of coordinates the point has.
0071    * @return The dimension.
0072    */
0073   int dimension() const {
0074     return m.size();
0075   }
0076 
0077   /**
0078    * Get the IMeasurement for a given coordinate.
0079    * @param coord The coordinate.
0080    * @return      The corresponding IMeasurement.
0081    */
0082   IMeasurement * coordinate(int coord) {
0083     return &(m[coord]);
0084   }
0085 
0086   /**
0087    * Get the IMeasurement for a given coordinate.
0088    * @param coord The coordinate.
0089    * @return      The corresponding IMeasurement.
0090    */
0091   const IMeasurement * coordinate(int coord) const {
0092     return &(m[coord]);
0093   }
0094 
0095   private:
0096 
0097   /**
0098    * The included measurements.
0099    */
0100   std::vector<Measurement> m;
0101 
0102 };
0103 
0104 }
0105 
0106 #endif /* LWH_DataPoint_H */