10#if __cplusplus >= 201703L
14static double amu = 931.494043;
24 fSourceDirectory = std::string(getenv(
"GRSISYS")) +
"/libraries/TAnalysis/SourceData/";
25#if __cplusplus >= 201703L
57 infile.open(massFile.c_str());
58 while(!getline(infile, line).fail()) {
62 std::istringstream ss(line);
67 if(strcasecmp(element.c_str(), sym_name.c_str()) == 0) {
72 }
catch(std::out_of_range&) {
73 std::cout <<
"Could not parse element " << name << std::endl
74 <<
"Nucleus not Set!" << std::endl;
78 std::cout <<
"Warning: Element " << element <<
" not found in the mass table " << massFile <<
"." << std::endl
79 <<
"Nucleus not set!" << std::endl;
93 : fN(neutrons), fZ(charge), fMass(mass), fSymbol(symbol)
101 : fN(neutrons), fZ(charge)
104 if(MassFile ==
nullptr) {
112 std::ifstream mass_file;
113 mass_file.open(MassFile, std::ios::in);
114 while(!mass_file.bad() && !mass_file.eof() && i < 3008) {
119 if(n == fN && z == fZ) {
120 fMassExcess = emass / 1000.;
123 std::cout <<
"Symbol " << fSymbol <<
" tmp " << tmp << std::endl;
126 SetSymbol(fSymbol.c_str());
130 mass_file.ignore(256,
'\n');
134 std::string name = fSymbol;
135 std::string number = name.substr(0, name.find_first_not_of(
"0123456789 "));
137 name = name.substr(name.find_first_not_of(
"0123456789 "));
141 LoadTransitionFile();
147 name.append(std::to_string(
GetA()));
148 TNamed::SetName(name.c_str());
167 name.erase(std::remove_if(name.begin(), name.end(), [](
char c) { return std::isalnum(c) == 0; }), name.end());
170 if(name.length() == 1) {
185 std::cout <<
"error, type numbersymbol, or symbolnumber, i.e. 30Mg oder Mg30, not " << name << std::endl;
190 size_t firstDigit = name.find_first_of(
"0123456789");
191 size_t firstLetter = name.find_first_not_of(
"0123456789");
192 if(firstDigit > firstLetter) {
193 number = atoi(name.substr(firstDigit).c_str());
194 symbol.append(name.substr(firstLetter, firstDigit - firstLetter));
196 number = atoi(name.substr(firstDigit, firstLetter - firstDigit).c_str());
197 symbol.append(name.substr(firstLetter));
200 std::transform(symbol.begin(), symbol.end(), symbol.begin(), ::tolower);
201 symbol[0] = toupper(symbol[0]);
202 element.append(std::to_string(number));
203 element.append(symbol);
214 ParseName(std::move(input), symbol, number, element);
256 std::array<std::array<char, 3>, 105> symbols = {{{
"H"}, {
"HE"}, {
"LI"}, {
"BE"}, {
"B"}, {
"C"}, {
"N"}, {
"O"}, {
"F"}, {
"NE"}, {
"NA"}, {
"MG"}, {
"AL"}, {
"SI"}, {
"P"}, {
"S"}, {
"CL"}, {
"AR"}, {
"K"}, {
"CA"}, {
"SC"}, {
"TI"}, {
"V"}, {
"CR"}, {
"MN"}, {
"FE"}, {
"CO"}, {
"NI"}, {
"CU"}, {
"ZN"}, {
"GA"}, {
"GE"}, {
"AS"}, {
"SE"}, {
"BR"}, {
"KR"}, {
"RB"}, {
"SR"}, {
"Y"}, {
"ZR"}, {
"NB"}, {
"MO"}, {
"TC"}, {
"RU"}, {
"RH"}, {
"PD"}, {
"AG"}, {
"CD"}, {
"IN"}, {
"SN"}, {
"SB"}, {
"TE"}, {
"F"}, {
"XE"}, {
"CS"}, {
"BA"}, {
"LA"}, {
"CE"}, {
"PR"}, {
"ND"}, {
"PM"}, {
"SM"}, {
"EU"}, {
"GD"}, {
"TB"}, {
"DY"}, {
"HO"}, {
"ER"}, {
"TM"}, {
"YB"}, {
"LU"}, {
"HF"}, {
"TA"}, {
"W"}, {
"RE"}, {
"OS"}, {
"IR"}, {
"PT"}, {
"AU"}, {
"HG"}, {
"TI"}, {
"PB"}, {
"BI"}, {
"PO"}, {
"AT"}, {
"RN"}, {
"FR"}, {
"RA"}, {
"AC"}, {
"TH"}, {
"PA"}, {
"U"}, {
"NP"}, {
"PU"}, {
"AM"}, {
"CM"}, {
"BK"}, {
"CF"}, {
"ES"}, {
"FM"}, {
"MD"}, {
"NO"}, {
"LR"}, {
"RF"}, {
"HA"}}};
257 size_t length = strlen(symbol);
258 auto* search =
new char[length + 1];
259 for(
size_t i = 0; i < length; i++) {
260 search[i] = toupper(symbol[i]);
262 search[length] =
'\0';
263 for(
int i = 0; i < 105; i++) {
264 if(strcmp(search, symbols[i].data()) == 0) {
280 return 1.12 * pow(
GetA(), 1. / 3.) - 0.94 * pow(
GetA(), -1. / 3.);
284 Double_t intensity_uncertainty)
287 tran->SetEnergy(energy);
288 tran->SetEnergyUncertainty(energy_uncertainty);
289 tran->SetIntensity(intensity);
290 tran->SetIntensityUncertainty(intensity_uncertainty);
299 tran2->SetCompareIntensity(
false);
306 if(tran ==
nullptr) {
307 std::cout <<
"Out of Range" << std::endl;
316 if(tran ==
nullptr) {
317 std::cout <<
"Out of Range" << std::endl;
326 std::cout <<
"Nucleus: " << GetName() << std::endl;
329 while(
auto* tran =
static_cast<TTransition*
>(next())) {
330 std::cout <<
"\t" << counter++ <<
"\t";
337 if(!outfilename.empty()) {
338 std::ofstream sourceout;
339 sourceout.open(outfilename.c_str());
342 sourceout << transtr.c_str();
343 sourceout << std::endl;
345 sourceout << std::endl;
357 std::transform(symbol.begin(), symbol.end(), symbol.begin(), ::tolower);
358 filename.append(symbol);
359 filename.append(std::to_string(
GetA()));
360 filename.append(
".sou");
361 std::ifstream transfile;
362 transfile.open(filename.c_str());
363 if(!transfile.is_open()) {
364 std::cout <<
"failed to open source file: " << filename.c_str() << std::endl;
370 while(!getline(transfile, line).fail()) {
371 if(line.compare(0, 2,
"//") == 0) {
374 if(line.compare(0, 1,
"#") == 0) {
379 std::istringstream str(line);
381 while(!(str >> temp).fail()) {
384 tran->SetEnergy(temp);
385 }
else if(counter == 2) {
386 tran->SetEnergyUncertainty(temp);
387 }
else if(counter == 3) {
388 tran->SetIntensity(temp);
389 }
else if(counter == 4) {
390 tran->SetIntensityUncertainty(temp);
405 double gamma = 1 / std::sqrt(1 - beta * beta);
406 return fMass * (gamma - 1);
411 double gamma = energy_MeV /
fMass + 1;
412 double beta = std::sqrt(1 - 1 / (gamma * gamma));
void SetMass()
Sets the mass based on the A and mass excess of nucleus (in MeV)
TSortedList fTransitionListByIntensity
int GetA() const
Gets the A (Z + N) of the nucleus.
void SetName(const char *name="") override
double fMassExcess
Mass excess (in MeV)
void SetZ(int)
Sets the Z (# of protons) of the nucleus.
void AddTransition(Double_t energy, Double_t intensity, Double_t energy_uncertainty=0.0, Double_t intensity_uncertainty=0.0)
TTransition * GetTransitionByIntensity(Int_t idx)
void Print(Option_t *opt="") const override
double fMass
Mass (in MeV)
TNucleus()=default
Should not be used, here so we can write things to a root file.
double GetEnergyFromBeta(double beta) const
static std::string fSourceDirectory
! path of directory with .sou files
static std::string & SourceDirectory()
bool LoadTransitionFile()
double GetBetaFromEnergy(double energy_MeV) const
int fN
Number of neutrons (N)
int fZ
Number of protons (Z)
void SetN(int)
Sets the N (# of neutrons) of the nucleus.
void SetSymbol(const char *)
Sets the atomic symbol for the nucleus.
TTransition * GetTransitionByEnergy(Int_t idx)
static bool fSourceDirectoryChecked
! flag to indicate whetehr the source directory path has been checked
static std::string & Massfile()
< Returns the directory with the .sou files and the mass file
static void ParseName(const char *name, std::string &symbol, int &number, std::string &element)
void WriteSourceFile(const std::string &outfilename="")
static std::string SortName(const char *input)
TSortedList fTransitionListByEnergy
double GetMassExcess() const
Gets the mass excess of the nucleus (in MeV)
void SetMassExcess(double)
Sets the mass excess of the nucleus (in MeV)
std::string fSymbol
Atomic symbol (ex. Ba, C, O, N)
const char * GetSymbol() const
Gets the atomic symbol of the nucleus.
int GetZfromSymbol(char *)