112 lines
2.3 KiB
C++
112 lines
2.3 KiB
C++
//
|
|
// parameter.h
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 20.09.18.
|
|
// Copyright © 2018 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#ifndef parameter_h
|
|
#define parameter_h
|
|
|
|
#include "constants.h"
|
|
|
|
class Parameter: protected Constants
|
|
{
|
|
public:
|
|
virtual ~Parameter(){};
|
|
|
|
Parameter() {
|
|
// Simulation Specs
|
|
seed = (int)value("seed");
|
|
numTotalParticles = (long int)value("numTotalParticles");
|
|
dt_s = value("dt_s");
|
|
injectionMethod = (int)value("injectionMethod");
|
|
deltaKinEnergy_eV = value("deltaKinEnergy_eV");
|
|
MBTemp_K = value("MBTemp_K");
|
|
|
|
// Katrin Specs
|
|
wgtsMagField_T = value("wgtsMagField_T");
|
|
wgtsLength_m = value("wgtsLength_m");
|
|
wgtsRadius_m = value("wgtsRadius_m");
|
|
wgtsT2Density_m3 = value("wgtsT2Density_m3");
|
|
wgtsTemp_K = value("wgtsTemp_K");
|
|
wgtsT2FlowSpeed_ms = value("wgtsT2FlowSpeed_ms");
|
|
|
|
// Output
|
|
numberZBins = value ("numberZBins");
|
|
}
|
|
|
|
private:
|
|
double value(std::string strin, char* ext = (char*)("cat")) {
|
|
char* str = strdup(strin.c_str());
|
|
double temp;
|
|
char dummy[256];
|
|
char fname[256],*pname;
|
|
FILE *fcat;
|
|
|
|
if (getenv("poub") == NULL)
|
|
{
|
|
std::cerr<<"Parameter::value: Environment variable poub not defined.\n";
|
|
exit(1);
|
|
}
|
|
strcpy(fname, getenv("poub"));
|
|
pname = getenv("pname");
|
|
if (pname == NULL)
|
|
{
|
|
std::cerr<<"Parameter::value: Environment variable pname not defined.\n";
|
|
exit(1);
|
|
}
|
|
if (!ext)
|
|
{
|
|
ext = (char*)("cat");
|
|
}
|
|
sprintf(fname,"%s/%s.%s",getenv("poub"),getenv("pname"), ext);
|
|
if (!(fcat = fopen(fname, "r")))
|
|
{
|
|
std::cerr<<"Parameter::value: Can not open file " <<fname<<".\n";
|
|
exit(1);
|
|
}
|
|
while (!feof(fcat))
|
|
{
|
|
// fscanf(fcat, "'%s%*[^']'%F%*[^']",dummy,&temp); 1
|
|
fscanf(fcat, "%s = %lf", dummy, &temp);
|
|
// if (strncmp(dummy, str,strlen(str)) == 0) {
|
|
if (strcmp(dummy, str) == 0)
|
|
{
|
|
fclose(fcat);
|
|
return(temp);
|
|
}
|
|
}
|
|
fclose(fcat);
|
|
|
|
std::cerr<<"Parameter::value: Variable "<<str<<" not found.\n";
|
|
exit(1);
|
|
return 0;
|
|
}
|
|
|
|
protected:
|
|
//Simulation Specs
|
|
int seed;
|
|
long int numTotalParticles;
|
|
double dt_s;
|
|
int injectionMethod;
|
|
double deltaKinEnergy_eV;
|
|
double MBTemp_K;
|
|
|
|
//KATRIN Specs
|
|
double wgtsMagField_T;
|
|
double wgtsLength_m;
|
|
double wgtsRadius_m;
|
|
double wgtsT2Density_m3;
|
|
double wgtsTemp_K;
|
|
double wgtsT2FlowSpeed_ms;
|
|
|
|
// Output
|
|
int numberZBins;
|
|
};
|
|
|
|
|
|
|
|
#endif
|