Files
katrin-plasma/src/mc_electron/logger.hpp
T
Christian 649c278084 Minior Changes on new structure, exported elastic cross section to seperate file.
Please enter the commit message for your changes. Lines starting
2019-05-02 13:29:21 +02:00

151 lines
3.1 KiB
C++

//
// logger.hpp
// mc_electron
//
// Created by Christian Reiling on 27.02.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef logger_hpp
#define logger_hpp
#include "particle.hpp"
#include "katrin.hpp"
#include "hdf5.h"
typedef struct logParticle {
unsigned int Id;
unsigned int parentId;
double x_m;
double y_m;
double z_m;
double vx_ms;
double vy_ms;
double vz_ms;
} logParticle;
// Base_Logger: Base_Class for all Logger: Reading Paramter and calculating z-Barrieres.
class Base_Logger {
public:
Base_Logger(Katrin *Kat);
protected:
static const int numberZBins;
bool logging;
std::vector<double> zLogValues;
void set_zLogValues();
std::string getparName();
std::string remove_catEnding (std::string inString);
bool isFile(std::string fileName);
bool isDir(std::string dirPath);
Katrin *Kat;
};
// ASCI_Logger: Log to ASCI-File. Only Electron Logger. Not very efficient.
class ASCI_Logger : public Base_Logger {
public:
ASCI_Logger(Katrin *Kat);
void log_Particle(Particle *inPart , vec3 oldLoc_m);
private:
std::string outdirName;
std::ofstream *outStream;
void set_outdirName();
void create_outdir();
void set_outStream();
};
class ParticleH5TB_Properties {
public:
ParticleH5TB_Properties() {};
protected:
static const size_t size;
static const char *fieldNames[8];
static const size_t offset[8];
static const hid_t fieldTypes[8];
static const hsize_t chunkSize;
static const size_t sizes[8];
};
class ParticleLogger : ParticleH5TB_Properties{
public:
ParticleLogger(species Species, hid_t *particle_zH5G, std::vector<double> zLogValues) {
this->Species = Species;
this->particle_zH5G = particle_zH5G;
this->zLogValues = zLogValues;
numberZBins = zLogValues.size();
singleFile = (numberZBins == 1) ? true : false;
stringstream ss;
ss<<Species;
speciesIdentifier = ss.str();
create_particle_H5TBs();
};
private:
void create_particle_H5TBs();
private:
hid_t *particle_zH5G;
std::vector<double> zLogValues;
hid_t *particle_H5TB;
species Species;
int numberZBins;
bool singleFile;
std::string speciesIdentifier;
public:
void log_Particle(const Particle &logPart, const vec3 &oldLoc_m);
private:
logParticle transformTo_logParticle(const Particle &logPart);
public:
species get_Species() const {return(Species);};
private:
void check_Species(const Particle &logPart);
};
typedef std::vector<ParticleLogger*> ParticleLoggerVec;
class H5_Logger : private Base_Logger {
public:
H5_Logger(Katrin *Kat) : Base_Logger(Kat) {
create_outH5F();
create_particleH5G();
create_particle_zH5G();
add_ParticleLogger(new ParticleLogger(electron, particle_zH5G,zLogValues));
};
private:
hid_t outH5F;
hid_t particleH5G;
hid_t *particle_zH5G;
ParticleLoggerVec ParticleLoggers;
private:
void create_outH5F();
std::string get_outH5F_fullPath();
void create_particleH5G();
void create_particle_zH5G();
public:
void add_ParticleLogger(ParticleLogger* addParticleLogger);
private:
ParticleLoggerVec::iterator find_ParticleLogger (species findSpec);
public:
void log_Particle(const Particle &logPart, vec3 oldLoc_m);
};
#endif /* logger_hpp */