80 lines
1.9 KiB
C++
80 lines
1.9 KiB
C++
//
|
|
// log_scale.h
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 06.06.19.
|
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#ifndef log_scale_h
|
|
#define log_scale_h
|
|
|
|
#include "lin_scale.h"
|
|
|
|
class Log_Scale : public Scale {
|
|
Lin_Scale lin_scale;
|
|
public:
|
|
Log_Scale() {};
|
|
Log_Scale(const double &min_x, const double &max_x, const int &number_bins) {
|
|
lin_scale = Lin_Scale(std::log10(min_x), std::log10(max_x), number_bins);
|
|
};
|
|
~Log_Scale() {};
|
|
|
|
double get_lower_scale_end();
|
|
double get_upper_scale_end();
|
|
int get_number_bins();
|
|
|
|
int calc_index(const double &x);
|
|
double get_lower_bin_bound(const int &index);
|
|
double get_bin_mid(const int &index);
|
|
double get_upper_bin_bound(const int &index);
|
|
bool is_valid_index (const int &index);
|
|
|
|
friend bool operator==(const Log_Scale &scale1, const Log_Scale &scale2);
|
|
};
|
|
|
|
|
|
inline double Log_Scale::get_lower_scale_end() {
|
|
double min_x = pow(10,lin_scale.get_lower_scale_end());
|
|
return min_x;
|
|
}
|
|
inline double Log_Scale::get_upper_scale_end() {
|
|
double max_x = pow(10,lin_scale.get_upper_scale_end());
|
|
return max_x;
|
|
}
|
|
|
|
inline int Log_Scale::get_number_bins() {
|
|
return lin_scale.get_number_bins();
|
|
}
|
|
|
|
inline int Log_Scale::calc_index(const double &x) {
|
|
double p = std::log10(x);
|
|
return lin_scale.calc_index(p);
|
|
}
|
|
|
|
inline double Log_Scale::get_lower_bin_bound(const int &index) {
|
|
double p = lin_scale.get_lower_bin_bound(index);
|
|
return pow(10,p);
|
|
}
|
|
|
|
inline double Log_Scale::get_bin_mid(const int &index) {
|
|
double p = lin_scale.get_bin_mid(index);
|
|
return pow(10,p);
|
|
}
|
|
|
|
inline double Log_Scale::get_upper_bin_bound(const int &index) {
|
|
double p = lin_scale.get_upper_bin_bound(index);
|
|
return pow(10,p);
|
|
}
|
|
|
|
inline bool Log_Scale::is_valid_index (const int &index) {
|
|
return lin_scale.is_valid_index(index);
|
|
}
|
|
|
|
inline bool operator==(const Log_Scale &scale1, const Log_Scale &scale2) {
|
|
return scale1.lin_scale == scale2.lin_scale;
|
|
}
|
|
|
|
|
|
#endif /* log_scale_h */
|