GLAC  1.0
observablestorer.h
Go to the documentation of this file.
1 
13 #ifndef OBSERVABLESTORER_H
14 #define OBSERVABLESTORER_H
15 
16 #include <string>
17 #include <vector>
18 
20 {
21 private:
22  // Observable name
23  std::string m_observableName;
24  // Bool to store if we are to normalize the data by number of processors
25  bool m_normalizeObservableByProcessor = false;
26 
27  // Observable data
28  unsigned long m_NObs;
29  double m_averagedObservable = 0;
30  double m_varianceObservable = 0;
31  double m_averagedObservableSquared = 0;
32  double m_stdObservable = 0;
33  std::vector<double> m_observables;
34  std::vector<double> m_observablesSquared;
35 public:
36  ObservableStorer(unsigned long int NSize);
38 
39  // Accessor for the observable
40  double &operator[](unsigned long int iObs) { return m_observables.at(iObs); }
41 // double &operator[](unsigned long int iObs) { return m_observables[iObs]; }
42 
43  // Runs statistics, perhaps create its own class? But that increases overhead, so maybe not
44  void gatherResults();
45  void runStatistics();
46 
47  // Printers
48  void printStatistics();
49 
50  // File writers
51  void writeObservableToFile(double acceptanceRatio);
52  void writeFlowObservableToFile(unsigned long int configNumber);
53 
54  // Getters
55  std::vector<double> getObservableArray() { return m_observables; }
56  double getObservable(unsigned long int iObs) { return m_observables[iObs]; }
57  std::string getObservableName() { return m_observableName; }
58 
59  // Setters
60  void setObservableName(std::string observableName) { m_observableName = observableName; }
61  void setNormalizeObservableByProcessor(bool norm) { m_normalizeObservableByProcessor = norm; }
62  void reset();
63 };
64 
65 #endif // OBSERVABLESTORER_H
void printStatistics()
Definition: observablestorer.cpp:100
double getObservable(unsigned long int iObs)
Definition: observablestorer.h:56
A class for storing the observable data.
Definition: observablestorer.h:19
void setObservableName(std::string observableName)
Definition: observablestorer.h:60
ObservableStorer(unsigned long int NSize)
ObservableStorer::ObservableStorer.
Definition: observablestorer.cpp:14
~ObservableStorer()
Definition: observablestorer.cpp:29
void gatherResults()
ObservableStorer::gatherResults.
Definition: observablestorer.cpp:38
std::vector< double > getObservableArray()
Definition: observablestorer.h:55
std::string getObservableName()
Definition: observablestorer.h:57
void setNormalizeObservableByProcessor(bool norm)
Definition: observablestorer.h:61
void runStatistics()
ObservableStorer::runStatistics.
Definition: observablestorer.cpp:77
void reset()
ObservableStorer::reset set all the members for observable storage to zero.
Definition: observablestorer.cpp:146
void writeObservableToFile(double acceptanceRatio)
ObservableStorer::writeObservableToFile.
Definition: observablestorer.cpp:120
void writeFlowObservableToFile(unsigned long int configNumber)
ObservableStorer::writeFlowObservableToFile.
Definition: observablestorer.cpp:135
double & operator[](unsigned long int iObs)
Definition: observablestorer.h:40