// // velocity_container.cpp // mc_electron // // Created by Christian Reiling on 30.07.19. // Copyright © 2019 Christian Reiling. All rights reserved. // #include "velocity_container.hpp" #include "read_system.h" Velocity_Container::Velocity_Container(std::string load_path) { z_scale = Lin_Scale(z_WGTS_start_m, z_WGTS_end_m, num_z_bins); r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins); int num_tot_bins = num_z_bins * num_r_bins; vz_data = new double[num_tot_bins]; vr_data = new double[num_tot_bins]; load_data(load_path); } Velocity_Container::~Velocity_Container() { delete[] vz_data; delete[] vr_data; } Velocity_Container::Velocity_Container(const Velocity_Container& other) : vz_data(nullptr), vr_data(nullptr) { *this = other; } Velocity_Container &Velocity_Container::operator=(const Velocity_Container& other) { z_scale = other.z_scale; r_scale = other.r_scale; delete[] vz_data; delete[] vr_data; int num_tot_bins = num_z_bins * num_r_bins; vz_data = new double[num_tot_bins]; vr_data = new double[num_tot_bins]; for (int i=0; i< num_tot_bins; i++) { vz_data[i] = other.vz_data[i]; vr_data[i] = other.vr_data[i]; } return *this; } void Velocity_Container::load_data(std::string load_path) { int num_tot_bins = num_z_bins * num_r_bins; bool *check_array = new bool[num_tot_bins]; for (int i = 0; i< num_tot_bins; i++) { check_array[i] = false; } std::ifstream importStream(load_path); if (!importStream.good()) { std::stringstream ss; ss<<"Velocity_Container::load_data: Could not open file. \n loadFilePath= "<>temp_bin && ss>>temp_vz && ss>>temp_vr) { vz_data[temp_bin] = temp_vz; vr_data[temp_bin] = temp_vr; check_array[temp_bin] = true; } else { std::cout<<"Velocity_Container::load_data: Warning could not read line in inputFile. \nloadFilePath\t"<