Minor Changes
This commit is contained in:
@@ -9,44 +9,12 @@
|
||||
#ifndef parameter_hpp
|
||||
#define parameter_hpp
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "functions.hpp"
|
||||
#include "string"
|
||||
|
||||
|
||||
class Parameter: protected Constants {
|
||||
class Parameter {
|
||||
public:
|
||||
virtual ~Parameter(){};
|
||||
Parameter();
|
||||
|
||||
Parameter() {
|
||||
// Simulation Specs
|
||||
seed = (int)getValue("seed");
|
||||
numTotalElectrons = (long int)getValue("numTotalElectrons");
|
||||
dt_s = getValue("dt_s");
|
||||
injectionMethod = (int)getValue("injectionMethod");
|
||||
deltaKinEnergy_eV = getValue("deltaKinEnergy_eV");
|
||||
MBTemp_K = getValue("MBTemp_K");
|
||||
elaOn = (int)getValue("elaOn");
|
||||
ionOn = (int)getValue("ionOn");
|
||||
propagationMethod = (int)getValue("propagationMethod");
|
||||
|
||||
// Cutoff
|
||||
cutoffMode = (int)getValue("cutoffMode");
|
||||
cutoffEnergySet_eV = getValue("cutoffEnergySet_eV");
|
||||
cutoffFactor = getValue("cutoffFactor");
|
||||
|
||||
// Katrin Specs
|
||||
wgtsMagField_T = getValue("wgtsMagField_T");
|
||||
wgtsLength_m = getValue("wgtsLength_m");
|
||||
wgtsRadius_m = getValue("wgtsRadius_m");
|
||||
wgtsT2Density_m3 = getValue("wgtsT2Density_m3");
|
||||
wgtsTemp_K = getValue("wgtsTemp_K");
|
||||
wgtsT2FlowSpeed_ms = getValue("wgtsT2FlowSpeed_ms");
|
||||
|
||||
// Output
|
||||
numberZBins = getValue ("numberZBins");
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
//Simulation Specs
|
||||
int seed;
|
||||
@@ -76,53 +44,7 @@ protected:
|
||||
int numberZBins;
|
||||
|
||||
private:
|
||||
double getValue(string varName, char* ext = (char*)("cat")) {
|
||||
char* str = strdup(varName.c_str());
|
||||
double temp;
|
||||
char dummy[256];
|
||||
char fname[256],*pname;
|
||||
FILE *fcat;
|
||||
|
||||
if (getenv("poub") == NULL)
|
||||
{
|
||||
throw ("Parameter::value: Environment variable poub not defined.");
|
||||
}
|
||||
strcpy(fname, getenv("poub"));
|
||||
pname = getenv("pname");
|
||||
if (pname == NULL)
|
||||
{
|
||||
throw ("Parameter::value: Environment variable pname not defined.");
|
||||
}
|
||||
if (!ext)
|
||||
{
|
||||
ext = (char*)("cat");
|
||||
}
|
||||
sprintf(fname,"%s/%s.%s",getenv("poub"),getenv("pname"), ext);
|
||||
if (!(fcat = fopen(fname, "r")))
|
||||
{
|
||||
stringstream ss;
|
||||
ss<<"Parameter::value: Can not open file " <<fname<<".";
|
||||
throw (ss.str());
|
||||
}
|
||||
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);
|
||||
|
||||
stringstream ss;
|
||||
ss<<"Parameter::value: Variable "<<str<<" not found.";
|
||||
throw (ss.str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
double getValue(std::string varName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user