MINT2
Public Member Functions | Private Attributes | List of all members
HyperName Class Reference

#include <HyperName.h>

Public Member Functions

 HyperName (int dim)
 
 HyperName (std::vector< TString > names)
 
 HyperName (TString name0)
 
 HyperName (TString name0, TString name1)
 
 HyperName (TString name0, TString name1, TString name2)
 
 HyperName (TString name0, TString name1, TString name2, TString name3)
 
 HyperName (TString name0, TString name1, TString name2, TString name3, TString name4)
 
void setUnits (TString units)
 
void setUnits (TString units, int dim)
 
TString getAxisString (int dim)
 
int getDimension () const
 
HyperName slice (std::vector< int > sliceDims)
 
const TString & at (int dim) const
 
TString & at (int dim)
 
 ~HyperName ()
 

Private Attributes

std::vector< TString > _names
 
std::vector< TString > _units
 

Detailed Description

HyperPlot, Author: Sam Harnew, sam.h.nosp@m.arne.nosp@m.w@gma.nosp@m.il.c.nosp@m.om , Date: Dec 2015

Holds a n-dim vector of names that can be associtated to a n-dim Histogram (for axis titles etc). Also possible to store the units.

Definition at line 24 of file HyperName.h.

Constructor & Destructor Documentation

◆ HyperName() [1/7]

HyperName::HyperName ( int  dim)

Fill HyperName with the standard names {var_0, var_1, ...}

Definition at line 5 of file HyperName.cpp.

5  {
6  for(int i = 0; i < dim; i++){
7  TString name = "var_"; name += i;
8  _names.push_back( name );
9  _units.push_back( " " );
10  }
11 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ HyperName() [2/7]

HyperName::HyperName ( std::vector< TString >  names)

Fill HyperName with a std::vector<TString> of names

Definition at line 15 of file HyperName.cpp.

15  {
16  _names = names;
17  _units = std::vector<TString>(names.size(), " ");
18 
19 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ HyperName() [3/7]

HyperName::HyperName ( TString  name0)

Make a 1D HyperName with the given name

Definition at line 23 of file HyperName.cpp.

23  {
24  _names.push_back(name0);
25  _units.push_back(" ");
26 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ HyperName() [4/7]

HyperName::HyperName ( TString  name0,
TString  name1 
)

Make a 2D HyperName with the given names

Definition at line 30 of file HyperName.cpp.

30  {
31  _names.push_back(name0);
32  _names.push_back(name1);
33  _units.push_back(" ");
34  _units.push_back(" ");
35 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ HyperName() [5/7]

HyperName::HyperName ( TString  name0,
TString  name1,
TString  name2 
)

Make a 3D HyperName with the given names

Definition at line 39 of file HyperName.cpp.

39  {
40  _names.push_back(name0);
41  _names.push_back(name1);
42  _names.push_back(name2);
43  _units.push_back(" ");
44  _units.push_back(" ");
45  _units.push_back(" ");
46 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ HyperName() [6/7]

HyperName::HyperName ( TString  name0,
TString  name1,
TString  name2,
TString  name3 
)

Make a 4D HyperName with the given names

Definition at line 50 of file HyperName.cpp.

50  {
51  _names.push_back(name0);
52  _names.push_back(name1);
53  _names.push_back(name2);
54  _names.push_back(name3);
55  _units.push_back(" ");
56  _units.push_back(" ");
57  _units.push_back(" ");
58  _units.push_back(" ");
59 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ HyperName() [7/7]

HyperName::HyperName ( TString  name0,
TString  name1,
TString  name2,
TString  name3,
TString  name4 
)

Make a 5D HyperName with the given names

Definition at line 63 of file HyperName.cpp.

63  {
64  _names.push_back(name0);
65  _names.push_back(name1);
66  _names.push_back(name2);
67  _names.push_back(name3);
68  _names.push_back(name4);
69  _units.push_back(" ");
70  _units.push_back(" ");
71  _units.push_back(" ");
72  _units.push_back(" ");
73  _units.push_back(" ");
74 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ ~HyperName()

HyperName::~HyperName ( )

Destructor

Definition at line 147 of file HyperName.cpp.

147  {
148 
149 }

Member Function Documentation

◆ at() [1/2]

const TString& HyperName::at ( int  dim) const
inline

access an element of the name vector

Definition at line 50 of file HyperName.h.

◆ at() [2/2]

TString& HyperName::at ( int  dim)
inline

access an element of the name vector

Definition at line 51 of file HyperName.h.

◆ getAxisString()

TString HyperName::getAxisString ( int  dim)

Make a TString sutable for an axis title for a given dimension.

Definition at line 96 of file HyperName.cpp.

96  {
97  if (dim < 0 || dim >= (int)_names.size()){
98  std::cout << "Trying call HyperName::getAxisString on an element that doesn't exist" << std::endl;
99  return "ERROR";
100  }
101  TString retVal = _names.at(dim);
102  if (_units.at(dim) != " ") retVal += " [" + _units.at(dim) + "]";
103  return retVal;
104 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ getDimension()

int HyperName::getDimension ( ) const

Definition at line 107 of file HyperName.cpp.

107  {
108  return _names.size();
109 }
std::vector< TString > _names
Definition: HyperName.h:26

◆ setUnits() [1/2]

void HyperName::setUnits ( TString  units)

The the units of every dimension to be the given TString

Definition at line 78 of file HyperName.cpp.

78  {
79  for(unsigned i = 0; i < _units.size(); i++){
80  _units.at(i) = units;
81  }
82 }
std::vector< TString > _units
Definition: HyperName.h:27

◆ setUnits() [2/2]

void HyperName::setUnits ( TString  units,
int  dim 
)

The the units of the given dimension to be the given TString

Definition at line 86 of file HyperName.cpp.

86  {
87  if (dim < 0 || dim >= (int)_names.size()){
88  std::cout << "Trying to set the units of the HyperName element that doesn't exist" << std::endl;
89  return;
90  }
91  _units.at(dim) = units;
92 }
std::vector< TString > _units
Definition: HyperName.h:27
std::vector< TString > _names
Definition: HyperName.h:26

◆ slice()

HyperName HyperName::slice ( std::vector< int >  sliceDims)

Slice (remove) the given dimesnions, and return new HyperName

Definition at line 114 of file HyperName.cpp.

114  {
115 
116  int nStartingDims = getDimension();
117  int nSliceDims = sliceDims.size();
118 
119  HyperName names( nStartingDims - nSliceDims );
120  int count = 0;
121 
122  for (int i = 0; i < nStartingDims; i++){
123 
124  bool doesExist = false;
125 
126  for (int j = 0; j < nSliceDims; j++){
127  int dim = sliceDims.at(j);
128  if (i == dim) {
129  doesExist = true;
130  break;
131  }
132  }
133 
134  if (doesExist == false) {
135  names.at(count) = at(i); count++;
136  }
137  }
138 
139  return names;
140 
141 }
int getDimension() const
Definition: HyperName.cpp:107
const TString & at(int dim) const
Definition: HyperName.h:50

Member Data Documentation

◆ _names

std::vector<TString> HyperName::_names
private

vector of names

Definition at line 26 of file HyperName.h.

◆ _units

std::vector<TString> HyperName::_units
private

vector of units

Definition at line 27 of file HyperName.h.


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