reactionConfig can use IAEA for excited energies

This commit is contained in:
HELIOS_Mac 2024-07-28 19:02:58 -05:00
parent 90df60b650
commit 874918c275
4 changed files with 99 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include <vector>
#include <fstream>
#include <string>
#include <iostream>
#include <TMacro.h>
#include <TList.h>
@ -16,6 +17,27 @@
namespace AnalysisLib {
//*######################################### Execute Python Script
std::vector<std::string> executePythonScript(std::string command) {
std::vector<std::string> result;
printf("Python : %s \n", command.c_str());
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
std::cerr << "Failed to open pipe for command: " << command << std::endl;
return result;
}
constexpr int buffer_size = 256;
char buffer[buffer_size];
while (fgets(buffer, buffer_size, pipe) != nullptr) {
result.emplace_back(buffer);
}
pclose(pipe);
return result;
}
//*######################################### TRAPEZOID
TGraph * TrapezoidFilter(TGraph * trace, int baseLineEnd = 80, int riseTime = 10, int flatTop = 20, float decayTime = 2000){
///Trapezoid filter https://doi.org/10.1016/0168-9002(94)91652-7

View File

@ -225,7 +225,64 @@ inline bool ReactionConfig::LoadReactionConfig(TMacro * macro){
if( recoilLine == 5 ) recoil[ID].decayA = atoi(str[0].c_str());
if( recoilLine == 6 ) recoil[ID].decayZ = atoi(str[0].c_str());
if( recoilLine > 6 && str.size() == 4) exList[ID].Add( atoi(str[0].c_str()), atoi(str[1].c_str()), atoi(str[2].c_str()), atoi(str[3].c_str()));
if( recoilLine > 6 && str.size() == 4) {
if( str[0] == "IAEA"){
exList[ID].Clear();
recoil[ID].heavyA = beamA + targetA - recoil[ID].lightA;
recoil[ID].heavyZ = beamZ + targetZ - recoil[ID].lightZ;
printf(">>>>>>>>>>>>> Retrieving Ex data from IAEA website....\n");
std::string scriptPath = "../WebSimHelper/getEx.py " + std::to_string(recoil[ID].heavyA) + " " + std::to_string(recoil[ID].heavyZ) + " " + str[2];
std::vector<std::string> output = AnalysisLib::executePythonScript(scriptPath);
if( output.size() > 1 ){
for( size_t dudu = 1 ; dudu < output.size(); dudu ++ ){
printf("%s", output[dudu].c_str());
std::vector<std::string> dondon = AnalysisLib::SplitStr(output[dudu], " ");
if( str[1].find("all") == std::string::npos){ // only comfirm states
if(dondon[2].find(')') != std::string::npos ) continue;
if(dondon[2].find('N') != std::string::npos ) continue;
// printf("kdlsakdas ---- %s\n", str[1].c_str());
if(str[1] == "+" && dondon[2].find('+') != std::string::npos ){
// printf(" only comfim + states\n");
exList[ID].Add( atoi(dondon[1].c_str()), 1.0, 1.0, atoi(str[3].c_str()));
}
if(str[1] == "-" && dondon[2].find('-') != std::string::npos ){
// printf(" only comfim - states\n");
exList[ID].Add( atoi(dondon[1].c_str()), 1.0, 1.0, atoi(str[3].c_str()));
}
if( str[1] == "known" ){
// printf(" All comfim state\n");
exList[ID].Add( atoi(dondon[1].c_str()), 1.0, 1.0, atoi(str[3].c_str()));
}
}else{
if(str[1] == "+all" && dondon[2].find('+') != std::string::npos ){
// printf(" All state : %s\n", str[1].c_str());
exList[ID].Add( atoi(dondon[1].c_str()), 1.0, 1.0, atoi(str[3].c_str()));
}
if(str[1] == "-all" && dondon[2].find('-') != std::string::npos ){
// printf(" All state : %s\n", str[1].c_str());
exList[ID].Add( atoi(dondon[1].c_str()), 1.0, 1.0, atoi(str[3].c_str()));
}
if( str[1] == "all" ){
// printf(" All state \n");
exList[ID].Add( atoi(dondon[1].c_str()), 1.0, 1.0, atoi(str[3].c_str()));
}
}
}
}else{
printf(" No states found from IAEA database, assume ground state.");
exList[ID].Add( 0, 1.0, 1.0, 0.01);
}
}else{
exList[ID].Add( atoi(str[0].c_str()), atoi(str[1].c_str()), atoi(str[2].c_str()), atoi(str[3].c_str()));
}
}
}

18
WebSimHelper/getEx.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env /usr/bin/python3
import isotopeLib as iso
import sys
if len(sys.argv) < 3:
print("Usage: python getEx.py A Z Ex")
sys.exit(1)
A = int(sys.argv[1])
Z = int(sys.argv[2])
Ex = float(sys.argv[3])
ASym = iso.GetSymbol(A, Z)
ExList = iso.GetExList(ASym, Ex)
print(ExList)

View File

@ -41,7 +41,7 @@ except FileNotFoundError:
## 'ENSDFauthors', 'Extraction_date']
def GetExList(ASym : str, maxEx : float):
def GetExList(ASym : str, maxEx : float) ->pd.DataFrame:
try:
exList = lc_read_csv(livechart + "fields=levels&nuclides=" + ASym)
exJpi = exList[['energy', 'jp']]