2024-02-13 18:24:56 -05:00
|
|
|
#ifndef ClassReactionConfig_H
|
|
|
|
#define ClassReactionConfig_H
|
|
|
|
|
|
|
|
#include <stdio.h> /// for FILE
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "TMath.h"
|
|
|
|
#include "TString.h"
|
|
|
|
#include "TMacro.h"
|
|
|
|
|
|
|
|
#include "AnalysisLib.h"
|
2024-07-28 20:32:05 -04:00
|
|
|
#include "../Cleopatra/ClassIsotope.h"
|
2024-02-13 18:24:56 -05:00
|
|
|
|
2024-02-15 14:09:29 -05:00
|
|
|
struct Recoil {
|
|
|
|
|
2024-07-28 20:32:05 -04:00
|
|
|
Isotope light;
|
2024-02-15 14:09:29 -05:00
|
|
|
unsigned short lightA, lightZ;
|
|
|
|
unsigned short heavyA, heavyZ;
|
|
|
|
|
|
|
|
std::string lightStoppingPowerFile = ""; ///stopping_power_for_light_recoil
|
|
|
|
std::string heavyStoppingPowerFile = ""; ///stopping_power_for_heavy_recoil
|
|
|
|
|
|
|
|
bool isDecay = false; ///isDacay
|
|
|
|
unsigned short decayA = 0; ///decayNucleus_A
|
|
|
|
unsigned short decayZ = 0; ///decayNucleus_Z
|
|
|
|
|
|
|
|
void Print() const {
|
|
|
|
printf(" light : A = %3d, Z = %2d \n", lightA, lightZ);
|
|
|
|
printf(" heavy : A = %3d, Z = %2d \n", heavyA, heavyZ);
|
|
|
|
|
|
|
|
printf(" light stopping file : %s \n", lightStoppingPowerFile.c_str());
|
|
|
|
printf(" heavy stopping file : %s \n", heavyStoppingPowerFile.c_str());
|
|
|
|
printf(" is simulate decay : %s \n", isDecay ? "Yes" : "No");
|
|
|
|
if( isDecay ){
|
|
|
|
printf(" heavy decay : A = %d, Z = %d \n", decayA, decayZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-02-19 18:31:27 -05:00
|
|
|
struct EnergyLevel{
|
|
|
|
|
|
|
|
float Ex, xsec, SF, sigma;
|
|
|
|
|
|
|
|
EnergyLevel(float Ex, float xsec, float SF, float sigma) {
|
|
|
|
this->Ex = Ex;
|
|
|
|
this->xsec = xsec;
|
|
|
|
this->SF = SF;
|
|
|
|
this->sigma = sigma;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Print(std::string str) const {
|
|
|
|
printf("%11.3f %8.1f %5.1f %5.3f%s", Ex, xsec, SF, sigma, str.c_str() );
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ExcitedEnergies {
|
|
|
|
|
|
|
|
std::vector<EnergyLevel> ExList;
|
|
|
|
|
|
|
|
void Clear(){
|
|
|
|
ExList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Add(float Ex, float xsec, float SF, float sigma){
|
|
|
|
ExList.push_back( EnergyLevel(Ex, xsec, SF, sigma));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Print() const {
|
|
|
|
printf("Energy[MeV] Rel.Xsec SF sigma\n");
|
|
|
|
for( size_t i = 0; i < ExList.size(); i++){
|
|
|
|
ExList[i].Print("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2024-02-15 14:09:29 -05:00
|
|
|
|
2024-02-13 18:24:56 -05:00
|
|
|
class ReactionConfig {
|
|
|
|
|
|
|
|
public:
|
|
|
|
ReactionConfig(){}
|
2024-02-14 16:30:13 -05:00
|
|
|
ReactionConfig(TString configTxt){ LoadReactionConfig(configTxt);}
|
|
|
|
ReactionConfig(TMacro * macro){ LoadReactionConfig(macro);}
|
2024-02-13 18:24:56 -05:00
|
|
|
~ReactionConfig(){}
|
|
|
|
|
2024-07-28 20:32:05 -04:00
|
|
|
Isotope beam;
|
2024-02-15 14:09:29 -05:00
|
|
|
unsigned short beamA, beamZ;
|
|
|
|
float beamEx; ///excitation_energy_of_A[MeV]
|
2024-02-13 18:24:56 -05:00
|
|
|
float beamEnergy; ///MeV/u
|
|
|
|
float beamEnergySigma; ///beam-energy_sigma_in_MeV/u
|
2024-02-19 18:31:27 -05:00
|
|
|
float beamTheta; ///beam-angle_in_mrad
|
|
|
|
float beamThetaSigma; ///beam-emittance_in_mrad
|
2024-02-13 18:24:56 -05:00
|
|
|
float beamX; ///x_offset_of_Beam_in_mm
|
|
|
|
float beamY; ///y_offset_of_Beam_in_mm
|
|
|
|
|
2024-07-28 20:32:05 -04:00
|
|
|
Isotope target;
|
2024-02-15 14:09:29 -05:00
|
|
|
unsigned short targetA, targetZ;
|
2024-02-13 18:24:56 -05:00
|
|
|
bool isTargetScattering; ///isTargetScattering
|
|
|
|
float targetDensity; ///target_density_in_g/cm3
|
|
|
|
float targetThickness; ///targetThickness_in_cm
|
|
|
|
std::string beamStoppingPowerFile; ///stopping_power_for_beam
|
2024-02-15 14:09:29 -05:00
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
std::vector<Recoil> recoil;
|
|
|
|
std::vector<ExcitedEnergies> exList;
|
2024-02-15 14:09:29 -05:00
|
|
|
|
|
|
|
int numEvents; ///number_of_Event_being_generated
|
2024-02-13 18:24:56 -05:00
|
|
|
bool isRedo; ///isReDo
|
|
|
|
|
|
|
|
void SetReactionSimple(int beamA, int beamZ,
|
2024-04-03 17:15:24 -04:00
|
|
|
int targetA, int targetZ,
|
|
|
|
int recoilA, int recoilZ,
|
|
|
|
float beamEnergy_AMeV);
|
2024-02-13 18:24:56 -05:00
|
|
|
|
|
|
|
bool LoadReactionConfig(TString fileName);
|
|
|
|
bool LoadReactionConfig(TMacro * macro);
|
|
|
|
|
2024-02-20 18:15:16 -05:00
|
|
|
void Print(int ID = -1, bool withEx = true) const;
|
2024-02-13 18:24:56 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
inline void ReactionConfig::SetReactionSimple(int beamA, int beamZ,
|
2024-04-03 17:15:24 -04:00
|
|
|
int targetA, int targetZ,
|
|
|
|
int recoilA, int recoilZ,
|
|
|
|
float beamEnergy_AMeV){
|
2024-02-13 18:24:56 -05:00
|
|
|
|
|
|
|
this->beamA = beamA;
|
|
|
|
this->beamZ = beamZ;
|
|
|
|
this->targetA = targetA;
|
|
|
|
this->targetZ = targetZ;
|
2024-02-15 14:09:29 -05:00
|
|
|
|
2024-04-03 17:15:24 -04:00
|
|
|
this->recoil.push_back(Recoil());
|
|
|
|
|
|
|
|
this->recoil.back().lightA = recoilA;
|
|
|
|
this->recoil.back().lightZ = recoilZ;
|
|
|
|
recoil.back().heavyA = this->beamA + this->targetA - recoil.back().lightA;
|
|
|
|
recoil.back().heavyZ = this->beamZ + this->targetZ - recoil.back().lightZ;
|
2024-02-13 18:24:56 -05:00
|
|
|
|
|
|
|
beamEnergy = beamEnergy_AMeV;
|
|
|
|
beamEnergySigma = 0;
|
2024-02-19 18:31:27 -05:00
|
|
|
beamTheta = 0;
|
|
|
|
beamThetaSigma = 0;
|
2024-02-13 18:24:56 -05:00
|
|
|
beamX = 0;
|
|
|
|
beamY = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ReactionConfig::LoadReactionConfig(TString fileName){
|
|
|
|
TMacro * haha = new TMacro();
|
|
|
|
if( haha->ReadFile(fileName) > 0 ) {
|
|
|
|
if( LoadReactionConfig(haha) ){
|
2024-02-14 16:30:13 -05:00
|
|
|
delete haha;
|
2024-02-13 18:24:56 -05:00
|
|
|
return true;
|
|
|
|
}else{
|
2024-02-14 16:30:13 -05:00
|
|
|
delete haha;
|
2024-02-13 18:24:56 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}else{
|
2024-02-14 16:30:13 -05:00
|
|
|
delete haha;
|
2024-02-13 18:24:56 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ReactionConfig::LoadReactionConfig(TMacro * macro){
|
|
|
|
|
|
|
|
if( macro == NULL ) return false;
|
|
|
|
|
2024-02-15 14:09:29 -05:00
|
|
|
int recoilFlag = 0;
|
|
|
|
int recoilLine = 0;
|
|
|
|
|
2024-02-13 18:24:56 -05:00
|
|
|
int numLine = macro->GetListOfLines()->GetSize();
|
|
|
|
|
|
|
|
for( int i = 0; i < numLine; i ++){
|
|
|
|
|
2024-02-15 14:09:29 -05:00
|
|
|
std::string line = macro->GetListOfLines()->At(i)->GetName();
|
|
|
|
if( AnalysisLib::isEmptyOrSpaces(line) ) continue;
|
|
|
|
|
|
|
|
std::vector<std::string> str =AnalysisLib::SplitStr(line, " ");
|
|
|
|
// printf("%d |%s|%d|%d\n", i, str[0].c_str(), recoilFlag, recoilLine);
|
|
|
|
|
|
|
|
if( str[0].find("####") != std::string::npos ) break;
|
2024-02-19 18:31:27 -05:00
|
|
|
if( str[0].find("#---") != std::string::npos ) continue;
|
2024-02-15 14:09:29 -05:00
|
|
|
if( str[0].find("#===") != std::string::npos ) {
|
|
|
|
recoilFlag ++;
|
|
|
|
recoilLine = 0;
|
2024-04-02 13:50:21 -04:00
|
|
|
recoil.push_back(Recoil());
|
|
|
|
exList.push_back(ExcitedEnergies());
|
2024-02-15 14:09:29 -05:00
|
|
|
continue;
|
2024-02-13 18:24:56 -05:00
|
|
|
}
|
2024-02-15 14:09:29 -05:00
|
|
|
|
|
|
|
if( recoilFlag == 0 ){
|
2024-07-28 20:32:05 -04:00
|
|
|
if( recoilLine == 0 ) {
|
|
|
|
beam.SetIsoByName(str[0]);
|
|
|
|
beamA = beam.A;
|
|
|
|
beamZ = beam.Z;
|
|
|
|
}
|
|
|
|
if( recoilLine == 1 ) beamEx = atoi(str[0].c_str());
|
|
|
|
if( recoilLine == 2 ) beamEnergy = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 3 ) beamEnergySigma = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 4 ) beamTheta = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 5 ) beamThetaSigma = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 6 ) beamX = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 7 ) beamY = atof(str[0].c_str());
|
|
|
|
|
|
|
|
if( recoilLine == 8 ) {
|
|
|
|
target.SetIsoByName(str[0]);
|
|
|
|
targetA = target.A;
|
|
|
|
targetZ = target.Z;
|
|
|
|
}
|
2024-07-28 20:52:35 -04:00
|
|
|
if( recoilLine == 9 ) isTargetScattering = str[0].compare("true") == 0 ? true: false;
|
|
|
|
if( recoilLine == 10 ) targetDensity = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 11 ) targetThickness = atof(str[0].c_str());
|
|
|
|
if( recoilLine == 12 ) beamStoppingPowerFile = str[0];
|
2024-07-28 20:32:05 -04:00
|
|
|
|
2024-07-28 20:52:35 -04:00
|
|
|
if( recoilLine == 13 ) numEvents = atoi(str[0].c_str());
|
|
|
|
if( recoilLine == 14 ) isRedo = str[0].compare("true" ) == 0 ? true : false;
|
2024-02-13 18:24:56 -05:00
|
|
|
}
|
2024-02-15 14:09:29 -05:00
|
|
|
|
2024-02-15 16:36:45 -05:00
|
|
|
if( recoilFlag > 0 ){
|
2024-02-15 14:09:29 -05:00
|
|
|
|
2024-02-15 16:36:45 -05:00
|
|
|
unsigned ID = recoilFlag - 1;
|
2024-07-28 20:32:05 -04:00
|
|
|
if( recoilLine == 0 ) {
|
|
|
|
recoil[ID].light.SetIsoByName(str[0]);
|
|
|
|
recoil[ID].lightA = recoil[ID].light.A;
|
|
|
|
recoil[ID].lightZ = recoil[ID].light.Z;
|
|
|
|
}
|
|
|
|
if( recoilLine == 1 ) recoil[ID].lightStoppingPowerFile = str[0];
|
|
|
|
if( recoilLine == 2 ) recoil[ID].heavyStoppingPowerFile = str[0];
|
|
|
|
if( recoilLine == 3 ) recoil[ID].isDecay = str[0].compare("true") == 0 ? true : false;
|
|
|
|
if( recoilLine == 4 ) recoil[ID].decayA = atoi(str[0].c_str());
|
|
|
|
if( recoilLine == 5 ) recoil[ID].decayZ = atoi(str[0].c_str());
|
|
|
|
|
|
|
|
if( recoilLine > 5 && str.size() == 4) {
|
2024-07-28 20:16:43 -04:00
|
|
|
if( str[0].find('#') != std::string::npos) continue;
|
2024-07-28 20:02:58 -04:00
|
|
|
if( str[0] == "IAEA"){
|
2024-07-28 20:16:43 -04:00
|
|
|
|
2024-07-28 20:02:58 -04:00
|
|
|
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()));
|
|
|
|
}
|
|
|
|
}
|
2024-02-19 18:31:27 -05:00
|
|
|
|
2024-02-13 18:24:56 -05:00
|
|
|
}
|
2024-02-15 14:09:29 -05:00
|
|
|
|
|
|
|
recoilLine ++;
|
|
|
|
|
2024-02-13 18:24:56 -05:00
|
|
|
}
|
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
for( size_t i = 0; i < recoil.size(); i++){
|
2024-02-15 16:36:45 -05:00
|
|
|
recoil[i].heavyA = beamA + targetA - recoil[i].lightA;
|
|
|
|
recoil[i].heavyZ = beamZ + targetZ - recoil[i].lightZ;
|
|
|
|
}
|
2024-02-13 18:24:56 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-02-20 18:15:16 -05:00
|
|
|
inline void ReactionConfig::Print(int ID, bool withEx) const{
|
2024-02-13 18:24:56 -05:00
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
printf("#####################################################\n");
|
2024-02-13 18:24:56 -05:00
|
|
|
|
2024-02-15 14:09:29 -05:00
|
|
|
printf("number of Simulation Events : %d \n", numEvents);
|
|
|
|
printf(" is Redo until hit array : %s \n", isRedo ? "Yes" : "No");
|
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
printf("================================= Beam\n");
|
2024-02-15 14:09:29 -05:00
|
|
|
printf(" beam : A = %3d, Z = %2d, Ex = %.2f MeV\n", beamA, beamZ, beamEx);
|
2024-02-13 18:24:56 -05:00
|
|
|
printf(" beam Energy : %.2f +- %.2f MeV/u, dE/E = %5.2f %%\n", beamEnergy, beamEnergySigma, beamEnergySigma/beamEnergy);
|
2024-02-19 18:31:27 -05:00
|
|
|
printf(" Angle : %.2f +- %.2f mrad\n", beamTheta, beamThetaSigma);
|
2024-02-13 18:24:56 -05:00
|
|
|
printf(" offset : (x,y) = (%.2f, %.2f) mmm \n", beamX, beamY);
|
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
printf("================================= Target\n");
|
|
|
|
printf(" target : A = %3d, Z = %2d \n", targetA, targetZ);
|
|
|
|
printf(" enable scattering : %s \n", isTargetScattering ? "Yes" : "No");
|
2024-02-13 18:24:56 -05:00
|
|
|
if(isTargetScattering){
|
|
|
|
printf(" target density : %.f g/cm3\n", targetDensity);
|
|
|
|
printf(" thickness : %.f cm\n", targetThickness);
|
|
|
|
printf(" beam stopping file : %s \n", beamStoppingPowerFile.c_str());
|
|
|
|
}
|
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
printf("================================= Number of recoil reactions : %zu\n", recoil.size());
|
2024-07-08 14:52:46 -04:00
|
|
|
for( int i = 0; i < (int)recoil.size(); i ++ ){
|
2024-02-20 18:15:16 -05:00
|
|
|
if( ID == i || ID < 0 ){
|
2024-07-08 14:52:46 -04:00
|
|
|
printf("------------------------------------------ Recoil-%d\n", i);
|
2024-02-20 18:15:16 -05:00
|
|
|
recoil[i].Print();
|
|
|
|
if( withEx ) exList[i].Print();
|
|
|
|
}
|
2024-02-15 16:36:45 -05:00
|
|
|
}
|
2024-02-15 14:09:29 -05:00
|
|
|
|
2024-02-13 18:24:56 -05:00
|
|
|
|
2024-04-02 13:50:21 -04:00
|
|
|
printf("#####################################################\n");
|
2024-02-13 18:24:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|