Added class for population logging.

This commit is contained in:
Christian
2019-06-04 09:23:55 +02:00
parent 8af5ca0427
commit 142197d10a
25 changed files with 669 additions and 80 deletions
+53 -14
View File
@@ -12,31 +12,70 @@
using namespace std;
Pop3_Container::~Pop3_Container() {
};
Pop3_Container::Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
z_scale = Lin_Scale(Katrin_Geo::get_z_RW_m(), Katrin_Geo::get_z_WGTSend_m(), num_z_bins);
r_scale = Lin_Scale(0,Katrin_Geo::get_radius_m(), num_r_bins);
phi_scale = Lin_Scale(0, 180, num_phi_bins);
int z_dimension = z_scale.get_dimension();
int r_dimension = r_scale.get_dimension();
int phi_dimension = phi_scale.get_dimension();
data = new double **[num_z_bins+1];
for (int i = 0; i <= num_z_bins; i++)
{
data[i] = new double *[num_r_bins+1];
for(int j = 0; j<=num_r_bins; j++)
data[i][j] = new double[num_phi_bins+1];
}
for (int i = 0; i<=num_z_bins; i++) {
for (int j = 0; j<=num_r_bins; j++) {
for (int k = 0; k<=num_phi_bins; k++) {
data = new double **[z_dimension];
for (int i = 0; i < z_dimension; i++) {
data[i] = new double *[r_dimension];
for(int j = 0; j < r_dimension; j++) {
data[i][j] = new double[phi_dimension];
for (int k = 0; k < phi_dimension; k++) {
data[i][j][k] = 0;
}
}
}
}
Pop3_Container::~Pop3_Container() {
int z_dimension = z_scale.get_dimension();
int r_dimension = r_scale.get_dimension();
for (int i = 0; i < z_dimension; i++) {
for(int j = 0; j < r_dimension; j++) {
delete[] data[i][j];
}
delete[] data[i];
}
delete[] data;
};
Pop3_Container::Pop3_Container(const Pop3_Container& other) {
z_scale = other.z_scale;
r_scale = other.r_scale;
phi_scale = other.phi_scale;
int z_dimension = z_scale.get_dimension();
int r_dimension = r_scale.get_dimension();
int phi_dimension = phi_scale.get_dimension();
data = new double **[z_dimension];
for (int i = 0; i < z_dimension; i++) {
data[i] = new double *[r_dimension];
for(int j = 0; j < r_dimension; j++) {
data[i][j] = new double[phi_dimension];
for (int k = 0; k < phi_dimension; k++) {
data[i][j][k] = other.data[i][j][k];
}
}
}
}
Pop3_Container& Pop3_Container::operator=(const Pop3_Container& other) {
Pop3_Container tmp(other);
swap(z_scale, tmp.z_scale);
swap(z_scale, tmp.z_scale);
swap(z_scale, tmp.z_scale);
swap(data, tmp.data);
return (*this);
}
void Pop3_Container::increase_value(const double &value, const vec3 &loc_m) {
int zbin = z_scale.calc_index(get_z_m(loc_m));
int rbin = r_scale.calc_index(get_r_m(loc_m));