11static double amu = 931.494043;
15 static std::string output = std::string(getenv(
"GRSISYS")) +
"/libraries/TAnalysis/SourceData/mass.dat";
36 infile.open(massFile.c_str());
37 while(!getline(infile, line).fail()) {
41 std::istringstream ss(line);
46 if(strcasecmp(element.c_str(), sym_name.c_str()) == 0) {
51 }
catch(std::out_of_range&) {
52 std::cout <<
"Could not parse element " << name << std::endl
53 <<
"Nucleus not Set!" << std::endl;
57 std::cout <<
"Warning: Element " << element <<
" not found in the mass table " << massFile <<
"." << std::endl
58 <<
"Nucleus not set!" << std::endl;
72 : fN(neutrons), fZ(charge), fMass(mass), fSymbol(symbol)
80 : fN(neutrons), fZ(charge)
83 if(MassFile ==
nullptr) {
91 std::ifstream mass_file;
92 mass_file.open(MassFile, std::ios::in);
93 while(!mass_file.bad() && !mass_file.eof() && i < 3008) {
98 if(n == fN && z == fZ) {
99 fMassExcess = emass / 1000.;
102 std::cout <<
"Symbol " << fSymbol <<
" tmp " << tmp << std::endl;
105 SetSymbol(fSymbol.c_str());
109 mass_file.ignore(256,
'\n');
113 std::string name = fSymbol;
114 std::string number = name.substr(0, name.find_first_not_of(
"0123456789 "));
116 name = name.substr(name.find_first_not_of(
"0123456789 "));
120 LoadTransitionFile();
126 name.append(std::to_string(
GetA()));
127 TNamed::SetName(name.c_str());
146 name.erase(std::remove_if(name.begin(), name.end(), [](
char c) { return std::isalnum(c) == 0; }), name.end());
149 if(name.length() == 1) {
164 std::cout <<
"error, type numbersymbol, or symbolnumber, i.e. 30Mg oder Mg30, not " << name << std::endl;
169 size_t firstDigit = name.find_first_of(
"0123456789");
170 size_t firstLetter = name.find_first_not_of(
"0123456789");
171 if(firstDigit > firstLetter) {
172 number = atoi(name.substr(firstDigit).c_str());
173 symbol.append(name.substr(firstLetter, firstDigit - firstLetter));
175 number = atoi(name.substr(firstDigit, firstLetter - firstDigit).c_str());
176 symbol.append(name.substr(firstLetter));
179 std::transform(symbol.begin(), symbol.end(), symbol.begin(), ::tolower);
180 symbol[0] = toupper(symbol[0]);
181 element.append(std::to_string(number));
182 element.append(symbol);
193 ParseName(std::move(input), symbol, number, element);
235 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"}}};
236 size_t length = strlen(symbol);
237 auto* search =
new char[length + 1];
238 for(
size_t i = 0; i < length; i++) {
239 search[i] = toupper(symbol[i]);
241 search[length] =
'\0';
242 for(
int i = 0; i < 105; i++) {
243 if(strcmp(search, symbols[i].data()) == 0) {
259 return 1.12 * pow(
GetA(), 1. / 3.) - 0.94 * pow(
GetA(), -1. / 3.);
263 Double_t intensity_uncertainty)
266 tran->SetEnergy(energy);
267 tran->SetEnergyUncertainty(energy_uncertainty);
268 tran->SetIntensity(intensity);
269 tran->SetIntensityUncertainty(intensity_uncertainty);
278 tran2->SetCompareIntensity(
false);
285 if(tran ==
nullptr) {
286 std::cout <<
"Out of Range" << std::endl;
295 if(tran ==
nullptr) {
296 std::cout <<
"Out of Range" << std::endl;
305 std::cout <<
"Nucleus: " << GetName() << std::endl;
308 while(
auto* tran =
static_cast<TTransition*
>(next())) {
309 std::cout <<
"\t" << counter++ <<
"\t";
316 if(!outfilename.empty()) {
317 std::ofstream sourceout;
318 sourceout.open(outfilename.c_str());
321 sourceout << transtr.c_str();
322 sourceout << std::endl;
324 sourceout << std::endl;
334 std::string filename;
335 filename = std::string(getenv(
"GRSISYS")) +
"/libraries/TAnalysis/SourceData/";
337 std::transform(symbol.begin(), symbol.end(), symbol.begin(), ::tolower);
338 filename.append(symbol);
339 filename.append(std::to_string(
GetA()));
340 filename.append(
".sou");
341 std::ifstream transfile;
342 transfile.open(filename.c_str());
343 if(!transfile.is_open()) {
344 std::cout <<
"failed to open source file: " << filename.c_str() << std::endl;
350 while(!getline(transfile, line).fail()) {
351 if(line.compare(0, 2,
"//") == 0) {
354 if(line.compare(0, 1,
"#") == 0) {
359 std::istringstream str(line);
361 while(!(str >> temp).fail()) {
364 tran->SetEnergy(temp);
365 }
else if(counter == 2) {
366 tran->SetEnergyUncertainty(temp);
367 }
else if(counter == 3) {
368 tran->SetIntensity(temp);
369 }
else if(counter == 4) {
370 tran->SetIntensityUncertainty(temp);
385 double gamma = 1 / std::sqrt(1 - beta * beta);
386 return fMass * (gamma - 1);
391 double gamma = energy_MeV /
fMass + 1;
392 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 *)