Commit 06127c50 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Added copy constructor to EmitDb and applied clang-format.

parent 590c9f20
Pipeline #147696 passed with stages
in 19 minutes and 3 seconds
......@@ -9,32 +9,38 @@ namespace radix
{
EmitDb::EmitDb()
{
load_mpdkxgam(EmitDb::XGAMDATA4);
// load_mpdkxgam(EmitDb::XGAMDATA3);
load_ensdfbeta(EmitDb::BETADATA);
load_mpdkxgam(EmitDb::XGAMDATA4);
// load_mpdkxgam(EmitDb::XGAMDATA3);
load_ensdfbeta(EmitDb::BETADATA);
}
EmitDb::EmitDb(const EmitDb& orig)
{
mIsotope = orig.mIsotope;
mIsotopeTitle = orig.mIsotopeTitle;
}
void EmitDb::load_mpdkxgam(std::string file)
{
std::string revStr = radix::split_string(".", file)[1];
int revNum = std::atoi(revStr.substr(revStr.size() - 1, 1).c_str());
int revNum = std::atoi(revStr.substr(revStr.size() - 1, 1).c_str());
int indexThreshold, indexIterator;
int linecount = 0;
if (revNum == 3)
{
indexThreshold = 70;
indexIterator = 20;
indexIterator = 20;
}
else if (revNum == 4)
{
indexThreshold = 77;
indexIterator = 22;
indexIterator = 22;
}
std::ifstream xgamFile(file);
std::string line, prev;
std::vector<float> energies, intensities;
int zaid = -1;
int totalLines = 0;
int zaid = -1;
int totalLines = 0;
float totalEnergy = 0.f;
while (std::getline(xgamFile, line))
{
......@@ -45,23 +51,23 @@ void EmitDb::load_mpdkxgam(std::string file)
if (zaid != -1 && energies.size() > 0)
{
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = totalLines;
emitEntry.nBetas = 0;
emitEntry.xgamEnergy = totalEnergy;
emitEntry.betaEnergy = 0.0f;
emitEntry.photonEnergies = energies;
emitEntry.betaEnergies = {};
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = totalLines;
emitEntry.nBetas = 0;
emitEntry.xgamEnergy = totalEnergy;
emitEntry.betaEnergy = 0.0f;
emitEntry.photonEnergies = energies;
emitEntry.betaEnergies = {};
emitEntry.photonIntensities = intensities;
emitEntry.betaIntensities = {};
emitEntry.betaIntensities = {};
mIsotope.insert(std::make_pair(zaid, emitEntry));
energies.clear();
intensities.clear();
}
zaid = thisZaid;
totalLines = std::atoi(line.substr(9, 12).c_str());
zaid = thisZaid;
totalLines = std::atoi(line.substr(9, 12).c_str());
totalEnergy = std::atof(line.substr(60, 10).c_str());
}
else
......@@ -70,18 +76,19 @@ void EmitDb::load_mpdkxgam(std::string file)
int jumpLength;
if (revNum == 3)
{
index = 10;
index = 10;
jumpLength = 10;
}
else
{
index = 10;
index = 10;
jumpLength = 11;
}
while (index < indexThreshold && index < line.size())
{
float energy = std::atof(line.substr(index, 10).c_str());
float intensity = std::atof(line.substr(index + jumpLength, 10).c_str());
float intensity =
std::atof(line.substr(index + jumpLength, 10).c_str());
energies.push_back(energy);
intensities.push_back(intensity);
index += indexIterator;
......@@ -90,17 +97,17 @@ void EmitDb::load_mpdkxgam(std::string file)
prev = line;
}
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = totalLines;
emitEntry.nBetas = 0;
emitEntry.xgamEnergy = totalEnergy;
emitEntry.betaEnergy = 0.0f;
emitEntry.photonEnergies = energies;
emitEntry.betaEnergies = {};
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = totalLines;
emitEntry.nBetas = 0;
emitEntry.xgamEnergy = totalEnergy;
emitEntry.betaEnergy = 0.0f;
emitEntry.photonEnergies = energies;
emitEntry.betaEnergies = {};
emitEntry.photonIntensities = intensities;
emitEntry.betaIntensities = {};
emitEntry.betaIntensities = {};
mIsotope.insert(std::make_pair(zaid, emitEntry));
energies.clear();
intensities.clear();
......@@ -111,7 +118,7 @@ void EmitDb::load_ensdfbeta(std::string file)
std::ifstream betaFile(file);
std::string line, prev;
int zaidCount = 0;
int zaid = -1;
int zaid = -1;
int linecount = 0;
std::vector<float> energies, intensities;
while (std::getline(betaFile, line))
......@@ -131,7 +138,7 @@ void EmitDb::load_ensdfbeta(std::string file)
zaidCount++;
}
float intensity = std::atof(line.substr(10, 8).c_str());
float energy = std::atof(line.substr(19, 9).c_str());
float energy = std::atof(line.substr(19, 9).c_str());
energies.push_back(energy);
intensities.push_back(intensity);
}
......@@ -145,23 +152,24 @@ void EmitDb::load_ensdfbeta(std::string file)
totalEnergy += (intensities[i] * energies[i]);
}
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = 0;
emitEntry.nBetas = zaidCount;
emitEntry.xgamEnergy = 0.0f;
emitEntry.betaEnergy = totalEnergy;
emitEntry.photonEnergies = {};
emitEntry.betaEnergies = energies;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = 0;
emitEntry.nBetas = zaidCount;
emitEntry.xgamEnergy = 0.0f;
emitEntry.betaEnergy = totalEnergy;
emitEntry.photonEnergies = {};
emitEntry.betaEnergies = energies;
emitEntry.photonIntensities = {};
emitEntry.betaIntensities = intensities;
const auto& isOutside = mIsotope.insert(std::make_pair(zaid, emitEntry));
emitEntry.betaIntensities = intensities;
const auto& isOutside =
mIsotope.insert(std::make_pair(zaid, emitEntry));
if (!isOutside.second)
{
isOutside.first->second.nBetas = zaidCount;
isOutside.first->second.betaEnergy = totalEnergy;
isOutside.first->second.betaEnergies = energies;
isOutside.first->second.nBetas = zaidCount;
isOutside.first->second.betaEnergy = totalEnergy;
isOutside.first->second.betaEnergies = energies;
isOutside.first->second.betaIntensities = intensities;
}
zaidCount = 0;
......@@ -180,23 +188,23 @@ void EmitDb::load_ensdfbeta(std::string file)
totalEnergy += (intensities[i] * energies[i]);
}
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = 0;
emitEntry.nBetas = zaidCount;
emitEntry.xgamEnergy = 0.0f;
emitEntry.betaEnergy = totalEnergy;
emitEntry.photonEnergies = {};
emitEntry.betaEnergies = energies;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.nLines = 0;
emitEntry.nBetas = zaidCount;
emitEntry.xgamEnergy = 0.0f;
emitEntry.betaEnergy = totalEnergy;
emitEntry.photonEnergies = {};
emitEntry.betaEnergies = energies;
emitEntry.photonIntensities = {};
emitEntry.betaIntensities = intensities;
emitEntry.betaIntensities = intensities;
const auto& isOutside = mIsotope.insert(std::make_pair(zaid, emitEntry));
if (!isOutside.second)
{
isOutside.first->second.nBetas = zaidCount;
isOutside.first->second.betaEnergy = totalEnergy;
isOutside.first->second.betaEnergies = energies;
isOutside.first->second.nBetas = zaidCount;
isOutside.first->second.betaEnergy = totalEnergy;
isOutside.first->second.betaEnergies = energies;
isOutside.first->second.betaIntensities = intensities;
}
zaidCount = 0;
......
......@@ -76,6 +76,7 @@ class RADIX_PUBLIC EmitDb
public:
EmitDb();
EmitDb(const EmitDb& orig);
void load_mpdkxgam(std::string file);
void load_ensdfbeta(std::string file);
const std::string& isotope_title() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment