ATLAS Offline Software
EMAPMatrix.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
17 
19 #ifndef EMAPMATRIX_H
20 #define EMAPMATRIX_H
21 
22 #include <iostream>
23 #include <stdexcept>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 #include "GaudiKernel/StatusCode.h"
29 
30 // a helper class
32 {
33 public:
34 
39  EMAPMatrixAxis(std::string name, const std::vector <double> &bins): m_name(std::move(name)), m_vecBins(bins) {};
40 
41 
44 
45  std::vector<double> getBinningInformation() const {return m_vecBins; };
46 
48  unsigned int getNumberOfBins() const;
49 
51  int getBinIndex(double x) const;
53 // double getMeanOfBin(unsigned int i) const;
54 // /** returns width of bin at index i*/
55 // double getWidthOfBin(unsigned int i) const;
56 
57  bool isInRange(double x) const;
58 
59 // /** set name of axis*/
60 // void setName(std::string name);
61 // /** return name of axis*/
62  std::string getName() const {return m_name; };
63 
64 private:
65  std::string m_name;
66  std::vector<double> m_vecBins;
67 };
68 
69 
70 template<class T>
72 {
73 public:
74  // Constructors
75 
81  EMAPMatrix(const std::vector<EMAPMatrixAxis>& axes, const std::string& textDescription);
85  // EMAPMatrix(std::vector<EMAPMatrixAxis> axes, T emptyObject);
86 
88  EMAPMatrix(const EMAPMatrix& ob) = default;
89 
92 
94  EMAPMatrix& operator = (const EMAPMatrix& ob) = default;
95 
96  // Constructor Methods
98  StatusCode setupMatrix(std::vector<EMAPMatrixAxis> axes);
99  // /** Setup matrix with std::vector of axes to define dimensions and binnging of this matrix
100  // @param axes: std::vector of EMAPMatrixAxis objects
101  // @emptyObject: Standard object which is used to fill the matrix if it is supposed to be empty/cleaned*/
102  // void setupMatrix(std::vector<EMAPMatrixAxis> axes, T emptyObject);
103 
104  // Accessing the Matrix via Functions
113  StatusCode setBinContent(double x, double y, T value);
119  StatusCode setBinContent(double x, double y, double z, T value);
121  StatusCode setBinContent(double x, double y, double z, double u, T value);
123  StatusCode setBinContent(double x, double y, double z, double u, double v, T value);
128  StatusCode setBinContent(const std::vector<double>& x, T value);
129 
133  const T* getBinContent(double x) const;
138  const T* getBinContent(double x, double y) const;
144  const T* getBinContent(double x, double y, double z) const;
146  const T* getBinContent(double x, double y, double z, double u) const;
148  const T* getBinContent(double x, double y, double z, double u, double v) const;
153  const T* getBinContent(const std::vector<double>& x) const;
154 
155  // /** Add "T" to bin which corresponds to value std::vector x. Can only used for n-dimensional
156  // matrix if the length of the std::vector x ind n.
157  // @param x: std::vector of length n which represents the values on all axes
158  // @param T: value which should be added*/
159  // bool addBinContent(std::vector<double> x, T value);
160 
161  // Get StatusCode
163  // bool getStatusCode() { return m_StatusCode;}
165  int getDimensions() const { return m_dimensions;}
166 
167  // Get Axis Information
168  EMAPMatrixAxis getAxis(unsigned int i) const { return m_axis[i];}
169 
171  std::vector<T> getValues() const { return m_matrix;}
172 
173 
174  // Clearing functions
175 
177  void clear();
179  void clearEntries();
180 
181  bool isInRange(const std::vector<double>& x) const;
182 
184  void setTextDescription(const std::string& text);
186  std::string getTextDescription() const;
187 
188 protected:
189 
190  // T *m_emptyObject;
191  unsigned int m_dimensions;
192  // bool m_StatusCode;
193  std::vector<EMAPMatrixAxis> m_axis;
194 
195  std::vector< T > m_matrix;
196  std::vector< unsigned int > m_base;
197  std::string m_textDescription;
198 
199  // private:
200  //static const unsigned int m_dimMax=5;
201 
203 
204  unsigned int Index(const std::vector<unsigned int>& x) const;
205  std::vector<unsigned int> Index(unsigned int id);
206  // T& Access(std::vector<unsigned int> x);
207 };
208 
210 
211 #endif
EMAPMatrix::setBinContent
StatusCode setBinContent(double x, T value)
Set Bin-content to "T" in bin which corresponds to value "x".
EMAPMatrix::m_axis
std::vector< EMAPMatrixAxis > m_axis
Definition: EMAPMatrix.h:193
EMAPMatrix::setBinContent
StatusCode setBinContent(double x, double y, double z, double u, T value)
Set Bin-content to "T" in bin which corresponds to value "x,y,z,u".
python.App.bins
bins
Definition: App.py:410
EMAPMatrix::setBinContent
StatusCode setBinContent(double x, double y, T value)
Set Bin-content to "T" in bin which corresponds to value "x" and "y".
EMAPMatrix::clearEntries
void clearEntries()
Clear Matrix content but not binning, dimensions and axis.
EMAPMatrix::getValues
std::vector< T > getValues() const
return the std::vector<T> which contains all content information of the matrix.
Definition: EMAPMatrix.h:171
EMAPMatrixAxis::getNumberOfBins
unsigned int getNumberOfBins() const
Return number of bins.
EMAPMatrix::getBinContent
const T * getBinContent(double x, double y, double z, double u, double v) const
Get Bin-content to "T" in bin which corresponds to value "x,y,z,u,v".
EMAPMatrix::getTextDescription
std::string getTextDescription() const
The user can add a Description of what this matrix contains and how it was produced,...
EMAPMatrixAxis::m_name
std::string m_name
Definition: EMAPMatrix.h:62
athena.value
value
Definition: athena.py:122
EMAPMatrix::getBinContent
const T * getBinContent(const std::vector< double > &x) const
Get Bin-content to "T" in bin which corresponds to value std::vector x.
EMAPMatrixAxis::EMAPMatrixAxis
EMAPMatrixAxis(std::string name, const std::vector< double > &bins)
Setup the axis again.
Definition: EMAPMatrix.h:39
x
#define x
EMAPMatrix::Index
unsigned int Index(const std::vector< unsigned int > &x) const
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
EMAPMatrix::m_dimensions
unsigned int m_dimensions
Definition: EMAPMatrix.h:191
EMAPMatrixAxis::isInRange
bool isInRange(double x) const
returns mean of bin at index i
EMAPMatrix::m_base
std::vector< unsigned int > m_base
representation of the content of matrix
Definition: EMAPMatrix.h:196
EMAPMatrix::setupMatrix
StatusCode setupMatrix(std::vector< EMAPMatrixAxis > axes)
Setup Matrix via given std::vector of EMAPMatrixAxis objects.
EMAPMatrix
Definition: EMAPMatrix.h:72
EMAPMatrixAxis::getName
std::string getName() const
Definition: EMAPMatrix.h:62
EMAPMatrix::setBinContent
StatusCode setBinContent(double x, double y, double z, T value)
Set Bin-content to "T" in bin which corresponds to value "x,y,z".
EMAPMatrix::getBinContent
const T * getBinContent(double x, double y, double z) const
Get Bin-content to "T" in bin which corresponds to value "x,y,z".
EMAPMatrix::setBinContent
StatusCode setBinContent(double x, double y, double z, double u, double v, T value)
Set Bin-content to "T" in bin which corresponds to value "x,y,z,u,v".
lumiFormat.i
int i
Definition: lumiFormat.py:92
EMAPMatrix::isInRange
bool isInRange(const std::vector< double > &x) const
z
#define z
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EMAPMatrix::getBinContent
const T * getBinContent(double x) const
Get Bin-content to "T" in bin which corresponds to value "x".
EMAPMatrix::setTextDescription
void setTextDescription(const std::string &text)
The user can add a Description of what this matrix contains and how it was produced,...
EMAPMatrix::EMAPMatrix
EMAPMatrix(const EMAPMatrix &ob)=default
Constructor with std::vector of axes to define dimensions and binnging of this matrix.
EMAPMatrix::EMAPMatrix
EMAPMatrix(const std::vector< EMAPMatrixAxis > &axes, const std::string &textDescription)
Constructor with std::vector of axes to define dimensions and binnging of this matrix.
EMAPMatrixAxis::getBinningInformation
std::vector< double > getBinningInformation() const
Definition: EMAPMatrix.h:45
EMAPMatrix.icc
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EMAPMatrixAxis::getBinIndex
int getBinIndex(double x) const
Returns number of index of bin in which the value x falls.
EMAPMatrix::EMAPMatrix
EMAPMatrix()
Default constructor.
EMAPMatrix::setBinContent
StatusCode setBinContent(const std::vector< double > &x, T value)
Set Bin-content to "T" in bin which corresponds to value std::vector x.
EMAPMatrix::Index
std::vector< unsigned int > Index(unsigned int id)
EMAPMatrix::m_matrix
std::vector< T > m_matrix
Definition: EMAPMatrix.h:195
python.PyAthena.v
v
Definition: PyAthena.py:157
EMAPMatrix::clear
void clear()
Clear all Matrix information (Also binning,...)
y
#define y
EMAPMatrixAxis::~EMAPMatrixAxis
~EMAPMatrixAxis()
Default Destructor.
Definition: EMAPMatrix.h:43
EMAPMatrix::getBinContent
const T * getBinContent(double x, double y) const
Get Bin-content to "T" in bin which corresponds to value "x,y".
EMAPMatrix::m_textDescription
std::string m_textDescription
helper object which is used to "convert" the 1dim m_matrix into a n-dimensional object
Definition: EMAPMatrix.h:197
EMAPMatrix::getAxis
EMAPMatrixAxis getAxis(unsigned int i) const
Definition: EMAPMatrix.h:168
EMAPMatrix::setupEntries
StatusCode setupEntries()
Description of the content of this matrix.
EMAPMatrix::~EMAPMatrix
~EMAPMatrix()
Default destructor.
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
EMAPMatrix::operator=
EMAPMatrix & operator=(const EMAPMatrix &ob)=default
Operator = Overload.
EMAPMatrixAxis::m_vecBins
std::vector< double > m_vecBins
Definition: EMAPMatrix.h:66
EMAPMatrix::getDimensions
int getDimensions() const
Return status code of last operations.
Definition: EMAPMatrix.h:165
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
EMAPMatrix::getBinContent
const T * getBinContent(double x, double y, double z, double u) const
Get Bin-content to "T" in bin which corresponds to value "x,y,z,u".
EMAPMatrixAxis
Definition: EMAPMatrix.h:32