// // multiz_particle_logger.h // mc_electron // // Created by Christian Reiling on 19.05.19. // Copyright © 2019 Christian Reiling. All rights reserved. // #ifndef multiz_particle_logger_h #define multiz_particle_logger_h #include "particle_logger_base.h" class MultiZ_Particle_Logger : public Particle_Logger_Base { H5TB_Particle_Interface *h5tb; int numberZBins; double *zLogValues; public: MultiZ_Particle_Logger(species this_species, const int &numberZBins, double *zLogValues, hid_t *h5g_z) : Particle_Logger_Base(this_species) { this->numberZBins = numberZBins; this->zLogValues = new double[numberZBins]; for (int i = 0; izLogValues[i] = zLogValues[i]; } create(h5g_z); } ~MultiZ_Particle_Logger() { delete[] zLogValues; } private: void create(hid_t *h5g_z); public: void log(const Particle &logPart, const vec3 &oldLoc_m); }; inline void MultiZ_Particle_Logger::create(hid_t *h5g_z) { std::string speciesName = get_species_string(get_species()); if (numberZBins < 1) { std::stringstream ss; ss<<"MultiZ_Particle_Logger::create: numberZBins < 1.\n"; } h5tb = new H5TB_Particle_Interface[numberZBins]; for (int i = 0; i < numberZBins; i++) { h5tb[i] = H5TB_Particle_Interface(speciesName, &h5g_z[i]); } } inline void MultiZ_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) { double zold = oldLoc_m[2]; double znew = logPart.get_x_m()[2]; double zmin = std::min(zold,znew); double zmax = std::max(zold,znew); for (int i=0;i=zmin && zLogValues[i]<=zmax) { h5tb[i].write(logPart); // Location wrong, because set to new Location, instead of logging location. } } } #endif /* multiz_particle_logger_h */