mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-22 18:28:52 -05:00
Make MassMap less bad, fix some typos
This commit is contained in:
parent
c1d0069f80
commit
54a33d5123
|
@ -18,18 +18,18 @@ MassMap::MassMap()
|
|||
std::ifstream massfile("Assets/amdc2016_mass.txt");
|
||||
if (massfile.is_open())
|
||||
{
|
||||
std::string junk, A, element;
|
||||
int Z;
|
||||
std::string junk, element;
|
||||
uint32_t Z, A, key;
|
||||
double atomicMassBig, atomicMassSmall, isotopicMass;
|
||||
getline(massfile, junk);
|
||||
getline(massfile, junk);
|
||||
while (massfile >> junk)
|
||||
{
|
||||
massfile >> Z >> A >> element >> atomicMassBig >> atomicMassSmall;
|
||||
isotopicMass = (atomicMassBig + atomicMassSmall * 1e-6 - Z * electron_mass) * u_to_mev;
|
||||
std::string key = "(" + std::to_string(Z) + "," + A + ")";
|
||||
isotopicMass = (atomicMassBig + atomicMassSmall * 1e-6 - Z * s_eMass) * s_u2MeV;
|
||||
key = GenerateID(Z, A);
|
||||
massTable[key] = isotopicMass;
|
||||
elementTable[Z] = element;
|
||||
elementTable[key] = std::to_string(A) + element;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -41,10 +41,10 @@ MassMap::MassMap()
|
|||
MassMap::~MassMap() {}
|
||||
|
||||
//Returns nuclear mass in MeV
|
||||
double MassMap::FindMass(int Z, int A)
|
||||
double MassMap::FindMass(uint32_t Z, uint32_t A)
|
||||
{
|
||||
SPEC_PROFILE_FUNCTION();
|
||||
std::string key = "(" + std::to_string(Z) + "," + std::to_string(A) + ")";
|
||||
uint32_t key = GenerateID(Z, A);
|
||||
auto data = massTable.find(key);
|
||||
if (data == massTable.end())
|
||||
{
|
||||
|
@ -55,15 +55,17 @@ double MassMap::FindMass(int Z, int A)
|
|||
}
|
||||
|
||||
//returns element symbol
|
||||
std::string MassMap::FindSymbol(int Z, int A)
|
||||
std::string MassMap::FindSymbol(uint32_t Z, uint32_t A)
|
||||
{
|
||||
SPEC_PROFILE_FUNCTION();
|
||||
auto data = elementTable.find(Z);
|
||||
static std::string nullResult = "";
|
||||
|
||||
uint32_t key = GenerateID(Z, A);
|
||||
auto data = elementTable.find(key);
|
||||
if (data == elementTable.end())
|
||||
{
|
||||
SPEC_ERROR("Invalid nucleus at MassMap::FindSymbol()! Z: {0} A: {1}", Z, A);
|
||||
return "";
|
||||
return nullResult;
|
||||
}
|
||||
std::string fullsymbol = std::to_string(A) + data->second;
|
||||
return fullsymbol;
|
||||
return data->second;
|
||||
}
|
|
@ -16,16 +16,21 @@ class MassMap
|
|||
public:
|
||||
MassMap();
|
||||
~MassMap();
|
||||
double FindMass(int Z, int A);
|
||||
std::string FindSymbol(int Z, int A);
|
||||
double FindMass(uint32_t Z, uint32_t A);
|
||||
std::string FindSymbol(uint32_t Z, uint32_t A);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, double> massTable;
|
||||
std::unordered_map<int, std::string> elementTable;
|
||||
//As demonstrated elsewhere, using Szudzik pairing function to make unique id for two unsigned ints
|
||||
uint32_t GenerateID(uint32_t Z, uint32_t A)
|
||||
{
|
||||
return Z >= A ? (Z * Z + Z + A) : (A * A + Z);
|
||||
}
|
||||
std::unordered_map<uint32_t, double> massTable;
|
||||
std::unordered_map<uint32_t, std::string> elementTable;
|
||||
|
||||
//constants
|
||||
static constexpr double u_to_mev = 931.4940954;
|
||||
static constexpr double electron_mass = 0.000548579909;
|
||||
static constexpr double s_u2MeV = 931.4940954;
|
||||
static constexpr double s_eMass = 0.000548579909;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,12 +38,12 @@ namespace Specter {
|
|||
//a text file to get detector ID information, detector channel number, etc.
|
||||
std::vector<std::string> sabre_list; //list of names will allow us to create a summary histogram.
|
||||
uint32_t uuid;
|
||||
for (uint32_t board = 0; board < 7; board++)
|
||||
for (uint32_t board = 0; board < 8; board++)
|
||||
{
|
||||
for (uint32_t channel = 0; channel < 16; channel++)
|
||||
{
|
||||
//ImGui & spdlog come prepackaged with the fmt library, so make good use of it!
|
||||
sabre_list.push_back(fmt::format("sabre_%d", board*16 + channel));
|
||||
//spdlog comes prepackaged with the fmt library, so make good use of it!
|
||||
sabre_list.push_back(fmt::format("sabre_{}", board*16 + channel));
|
||||
uuid = Utilities::GetBoardChannelUUID(board, channel);
|
||||
sabre[uuid] = Parameter(sabre_list.back());
|
||||
manager->BindParameter(sabre[uuid]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user