13static double amu = 931.494043;
17 static std::string output = std::string(getenv(
"GRSISYS")) +
"/libraries/TAnalysis/SourceData/mass.dat";
38 infile.open(massFile.c_str());
39 while(!getline(infile, line).fail()) {
40 if(line.length() < 1) {
43 std::istringstream ss(line);
48 if(strcasecmp(element.c_str(), sym_name.c_str()) == 0) {
53 }
catch(std::out_of_range&) {
54 std::cout <<
"Could not parse element " << name << std::endl
55 <<
"Nucleus not Set!" << std::endl;
59 std::cout <<
"Warning: Element " << element <<
" not found in the mass table " << massFile <<
"." << std::endl
60 <<
"Nucleus not set!" << std::endl;
74 : fN(neutrons), fZ(charge), fMass(mass), fSymbol(symbol)
82 : fN(neutrons), fZ(charge)
85 if(MassFile ==
nullptr) {
93 std::ifstream mass_file;
94 mass_file.open(MassFile, std::ios::in);
95 while(!mass_file.bad() && !mass_file.eof() && i < 3008) {
100 if(n == fN && z == fZ) {
101 fMassExcess = emass / 1000.;
104 std::cout <<
"Symbol " << fSymbol <<
" tmp " << tmp << std::endl;
107 SetSymbol(fSymbol.c_str());
111 mass_file.ignore(256,
'\n');
115 std::string name = fSymbol;
116 std::string number = name.substr(0, name.find_first_not_of(
"0123456789 "));
118 name = name.substr(name.find_first_not_of(
"0123456789 "));
122 LoadTransitionFile();
128 name.append(std::to_string(
GetA()));
129 TNamed::SetName(name.c_str());
148 name.erase(std::remove_if(name.begin(), name.end(), [](
char c) { return std::isalnum(c) == 0; }), name.end());
151 if(name.length() == 1) {
166 std::cout <<
"error, type numbersymbol, or symbolnumber, i.e. 30Mg oder Mg30, not " << name << std::endl;
171 size_t firstDigit = name.find_first_of(
"0123456789");
172 size_t firstLetter = name.find_first_not_of(
"0123456789");
173 if(firstDigit > firstLetter) {
174 number = atoi(name.substr(firstDigit).c_str());
175 symbol.append(name.substr(firstLetter, firstDigit - firstLetter));
177 number = atoi(name.substr(firstDigit, firstLetter - firstDigit).c_str());
178 symbol.append(name.substr(firstLetter));
181 std::transform(symbol.begin(), symbol.end(), symbol.begin(), ::tolower);
182 symbol[0] = toupper(symbol[0]);
183 element.append(std::to_string(number));
184 element.append(symbol);
195 ParseName(std::move(input), symbol, number, element);
237 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"}}};
238 size_t length = strlen(symbol);
239 auto* search =
new char[length + 1];
240 for(
size_t i = 0; i < length; i++) {
241 search[i] = toupper(symbol[i]);
243 search[length] =
'\0';
244 for(
int i = 0; i < 105; i++) {
245 if(strcmp(search, symbols[i].data()) == 0) {
261 return 1.12 * pow(
GetA(), 1. / 3.) - 0.94 * pow(
GetA(), -1. / 3.);
265 Double_t intensity_uncertainty)
268 tran->SetEnergy(energy);
269 tran->SetEnergyUncertainty(energy_uncertainty);
270 tran->SetIntensity(intensity);
271 tran->SetIntensityUncertainty(intensity_uncertainty);
280 tran2->SetCompareIntensity(
false);
287 if(tran ==
nullptr) {
288 std::cout <<
"Out of Range" << std::endl;
297 if(tran ==
nullptr) {
298 std::cout <<
"Out of Range" << std::endl;
307 std::cout <<
"Nucleus: " << GetName() << std::endl;
310 while(
auto* tran =
static_cast<TTransition*
>(next())) {
311 std::cout <<
"\t" << counter++ <<
"\t";
318 if(outfilename.length() > 0) {
319 std::ofstream sourceout;
320 sourceout.open(outfilename.c_str());
323 sourceout << transtr.c_str();
324 sourceout << std::endl;
326 sourceout << std::endl;
336 std::string filename;
337 filename = std::string(getenv(
"GRSISYS")) +
"/libraries/TAnalysis/SourceData/";
339 std::transform(symbol.begin(), symbol.end(), symbol.begin(), ::tolower);
340 filename.append(symbol);
341 filename.append(std::to_string(
GetA()));
342 filename.append(
".sou");
343 std::ifstream transfile;
344 transfile.open(filename.c_str());
345 if(!transfile.is_open()) {
346 std::cout <<
"failed to open source file: " << filename.c_str() << std::endl;
352 while(!getline(transfile, line).fail()) {
353 if(line.compare(0, 2,
"//") == 0) {
356 if(line.compare(0, 1,
"#") == 0) {
361 std::istringstream str(line);
363 while(!(str >> temp).fail()) {
366 tran->SetEnergy(temp);
367 }
else if(counter == 2) {
368 tran->SetEnergyUncertainty(temp);
369 }
else if(counter == 3) {
370 tran->SetIntensity(temp);
371 }
else if(counter == 4) {
372 tran->SetIntensityUncertainty(temp);
387 double gamma = 1 / std::sqrt(1 - beta * beta);
388 return fMass * (gamma - 1);
393 double gamma = energy_MeV /
fMass + 1;
394 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
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 std::string & Massfile()
Returns the massfile to be used, which includes Z, N, atomic symbol, and mass excess.
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 *)