1#include "KVIsoscaling.h"
45 Info(
"ReadYieldsFile",
"===== Starting reading system %s =====\n", system_name.c_str());
48 std::ifstream my_file;
49 my_file.open(file_path);
51 if (my_file.is_open()) {
54 fSystemList_[system_name].file_path = std::string(file_path);
59 while (getline(my_file,
line)) {
74 fSystemList_[system_name].yields[zz][aa].yield = yy;
75 fSystemList_[system_name].yields[zz][aa].yield_err = yy_err;
78 if (fdebug_) printf(
"(line=%d) (zz=%d, aa=%d, yy=%lf, yy_err=%lf)\n", nline, zz, aa, yy, yy_err);
87 Info(
"ReadYieldsFile",
"[system_name=%s] file %s closed, masses and yields saved\n", system_name.c_str(), file_path);
93 Error(
"ReadYieldsFile",
"!!! Can't open file '%s' !!!", file_path);
97 BuildGaussianPlots(system_name);
115 if (
fdebug_)
Info(
"BuildGaussianPlots",
"====== STARTING BUILDING GAUSSIAN PLOTS FOR SYSTEM %s ======", system_name.c_str());
118 YieldData_t my_yields =
fSystemList_[system_name].yields;
121 for (
auto it = my_yields.begin(); it != my_yields.end(); it++){
122 Int_t zz = it->first;
123 Element_t my_element = it->second;
127 gr->
SetName(
Form(
"gr_Yield_vs_N_Z%d_%s", zz, system_name.c_str()));
133 grln->
SetName(
Form(
"gr_LnYield_vs_N_Z%d_%s", zz, system_name.c_str()));
143 for (
auto itt = my_element.begin(); itt != my_element.end(); itt++){
144 Int_t aa = itt->first;
157 if (
fdebug_)
Info(
"BuildGaussianPlots",
"(Z=%d, N=%d, A=%d) Yield=%lf +/- %lf", zz, nn, aa, yield, yielderr);
163 TF1* gaus =
new TF1(
Form(
"gausfit_yield_vs_N_Z%d_%s", zz, system_name.c_str()),
"gaus(0)", 0, 60);
164 gr->
Fit(
Form(
"gausfit_yield_vs_N_Z%d_%s", zz, system_name.c_str()),
"Q");
173 if (
fdebug_)
Info(
"BuildGaussianPlots",
"====== END BUILDING GAUSSIAN PLOTS FOR SYSTEM %s ======", system_name.c_str());
209 gr_sys1_tol->
SetName(
Form(
"gr_yields_vs_N_Z%d_%s_tol", zz, system_name1.c_str()));
211 gr_sys2_tol->
SetName(
Form(
"gr_yields_vs_N_Z%d_%s_tol", zz, system_name1.c_str()));
214 gr_ratio_all->
SetName(
Form(
"gr_ratio_all_Z%d_%s_%s", zz, system_name1.c_str(), system_name2.c_str()));
216 gr_ratio_tol->
SetName(
Form(
"gr_ratio_tol_Z%d_%s_%s", zz, system_name1.c_str(), system_name2.c_str()));
221 if (
fdebug_)
Info(
"TestGaussianApproxe",
"=== Starting iteration over isotope list='%s' for Z=%d ===", nl_inter_a.
GetList(), zz);
224 Int_t npoint_all = 0;
227 Int_t npoint_tol = 0;
229 while (!nl_inter_a.
End()) {
231 Int_t nn = next_aa - zz;
239 Float_t ratio = yield2 / yield1;
243 gr_ratio_all->
SetPoint(npoint_all, nn, ratio);
251 if (diff1 < tol * gaus1->GetParameter(2)) {
252 gr_sys1_tol->
SetPoint(np1, nn, yield1);
257 if (diff2 < tol * gaus2->GetParameter(2)) {
258 gr_sys2_tol->
SetPoint(np2, nn, yield2);
263 if ((diff1 < tol * gaus1->GetParameter(2)) && (diff2 < tol * gaus2->GetParameter(2))) {
264 gr_ratio_tol->
SetPoint(npoint_tol, nn, ratio);
271 TF1* gaus_ratio =
new TF1(
Form(
"gaus_ratio_Z%d_%ss_%s", zz, system_name1.c_str(), system_name2.c_str()),
"gaus(0)/(gaus(3))", 0, 60);
295 gr_ratio_all->
Draw(
"ap");
297 gr_sys1_all->
Draw(
"p");
298 gr_sys2_all->
Draw(
"p");
301 gaus_ratio->
Draw(
"same");
302 gr_sys1_tol->
Draw(
"p");
303 gr_sys2_tol->
Draw(
"p");
304 gr_ratio_tol->
Draw(
"p");
330 if (
fdebug_)
Info(
"BuildLnR21vsNPlots",
"====== STARTING BUILDING PLOTS FOR %s/%s ======", system_name1.c_str(), system_name2.c_str());
333 if(system_name1!=system_name2){
334 std::string my_str = system_name1+
"_"+system_name2;
338 if (
fdebug_)
Info(
"BuildLnR21vsNPlots",
"%s/%s - list of shared Z ='%s'", system_name1.c_str(), system_name2.c_str(), nl_inter.
GetList());
343 while (!nl_inter.
End()) {
348 gr_all->
SetName(
Form(
"gr_lnR21_vs_N_Z%d_%s_%s_all", next_zz, system_name1.c_str(), system_name2.c_str()));
355 gr->
SetName(
Form(
"gr_lnR21_vs_N_Z%d_%s_%s", next_zz, system_name1.c_str(), system_name2.c_str()));
380 TF1* gaus_ratio =
new TF1(
Form(
"gaus_ratio_Z%d_%s_%s", next_zz, system_name1.c_str(), system_name2.c_str()),
"gaus(0)/(gaus(3))", 0, 60);
382 gaus_ratio->
SetParameters(par0, par1, par2, par3, par4, par5);
385 TF1* gaus_ratio_ln =
new TF1(
Form(
"gaus_ratio_ln_Z%d_%s_%s", next_zz, system_name1.c_str(), system_name2.c_str()),
"TMath::Log(gaus(0)/(gaus(3)))", 0, 60);
387 gaus_ratio_ln->
SetParameters(par0, par1, par2, par3, par4, par5);
394 if (
fdebug_)
Info(
"BuildLnR21vsNPlots",
"=== Starting iteration over shared A list='%s' for Z=%d ===", nl_inter_a.
GetList(), next_zz);
399 while (!nl_inter_a.
End()) {
401 Int_t nn = next_aa - next_zz;
414 gr_all->
SetPoint(npp_all, nn, lnr21);
421 if (diff1 <
ftol_ * par2 && diff2 <
ftol_ * par5) {
427 printf(
"[Z=%d, N=%d, A=%d] Point refused : (tol1=%lf, diff1=%lf), (tol2=%lf, diff2=%lf) - (mean1=%lf, sigma1=%lf), (mean2=%lf, sigma2=%lf)",
428 next_zz, next_aa - next_zz, next_aa,
ftol_ * par2, diff1,
ftol_ * par5, diff2, par1, par2, par4, par5);
430 if (
fdebug_)
Info(
"BuildLnR21vsNPlots",
"[Z=%d, N=%d, A=%d] Yield1(%s)=%lf, Yield2(%s)=%lf", next_zz, next_aa - next_zz, next_aa, system_name1.c_str(), yield1, system_name2.c_str(), yield2);
440 if (
fdebug_)
Info(
"BuildLnR21vsNPlots",
"====== END OF BUILDING PLOTS FOR %s/%s ======", system_name1.c_str(), system_name2.c_str());
444 Error(
"BuildLnR21Plots",
"!!! Something is wrong in the input systems !!!");
469 if (
fdebug_)
Info(
"FitLnR21vsNPlots",
"====== STARTING FITS FOR %s/%s ======", system_name1.c_str(), system_name2.c_str());
475 std::string my_str = system_name1+
"_"+system_name2;
479 for(
auto it = my_isograph.begin(); it != my_isograph.end(); it++){
480 Int_t zz = it->first;
487 func =
new TF1(
Form(
"fit_lnR21_vs_N_Z%d_%s_%s", zz, system_name1.c_str(), system_name2.c_str()),
"pol1",
float(nmin),
float(nmax));
490 for (
Int_t ii = 0; ii < 10; ii++)
gr->
Fit(func,
option, gooption,
float(nmin + 2),
float(nmax - 2));
497 if (
fdebug_)
Info(
"BuildLnR21vsNPlots",
"====== END OF FITS FOR %s/%s ======", system_name1.c_str(), system_name2.c_str());
515 std::string my_str = system_name1+
"_"+system_name2;
523 for(
auto it = my_isograph.begin(); it != my_isograph.end(); it++){
524 Int_t zz = it->first;
536 for(
auto itt = my_isofit.begin(); itt != my_isofit.end(); itt++){
537 Int_t zz = itt->first;
595 if (
fdebug_)
Info(
"BuildIsoscalingPlots",
"====== STARTING BUILDING PLOTS FOR %s/%s ======", system_name1.c_str(), system_name2.c_str());
596 std::string my_str = system_name1+
"_"+system_name2;
600 gr_alpha->
SetName(
Form(
"Alpha_vs_Z_%s", my_str.c_str()));
608 gr_delta->
SetName(
Form(
"Delta_vs_Z_%s", my_str.c_str()));
616 gr_alpha_delta->
SetName(
Form(
"Alpha_vs_Delta_%s", my_str.c_str()));
624 gr_csymT->
SetName(
Form(
"CsymOverT_vs_Z_%s", my_str.c_str()));
638 Float_t alpha, alpha_err, delta, delta_err, csymT, csymT_err;
639 Bool_t is_ok_alpha =
GetAlpha(system_name1, system_name2, zz, alpha, alpha_err);
643 if (is_ok_delta && is_ok_alpha && is_ok_csymT) {
670 if (
fdebug_)
Info(
"BuildIsoscalingPlots",
"====== END BUILDING PLOTS FOR %s/%s ======", system_name1.c_str(), system_name2.c_str());
689 std::string str_sys = it->first;
695 Info(
"CreateCsymOverTMultiGraph",
"%s added to the MultiGraph",
gr->
GetName());
717 TF1 *gr_gauss =
nullptr;
720 std::string str_sys = it0->first;
724 YieldGraph_t my_graphs = my_system.
graphs;
725 for(
auto itt0 = my_graphs.begin(); itt0 != my_graphs.end(); itt0++){
726 Int_t zz = itt0->first;
727 gr_yield = itt0->second;
733 YieldGraph_t my_lngraphs = my_system.
lngraphs;
734 for(
auto ittt0 = my_lngraphs.begin(); ittt0 != my_lngraphs.end(); ittt0++){
735 Int_t zz = ittt0->first;
736 gr_lnyield = ittt0->second;
742 YieldGauss_t my_gauss = my_system.
gauss;
743 for(
auto itttt0 = my_gauss.begin(); itttt0 != my_gauss.end(); itttt0++){
744 Int_t zz = itttt0->first;
745 gr_gauss= itttt0->second;
753 TF1 *fit_lnR21=
nullptr;
760 std::string str_sys = it->first;
763 IsoGraph_t my_graphs = my_iso.
graphs;
764 for(
auto itt = my_graphs.begin(); itt != my_graphs.end(); itt++){
765 Int_t zz = itt->first;
766 gr_lnR21 = itt->second;
771 IsoFit_t my_fits = my_iso.
fits;
772 for(
auto ittt = my_fits.begin(); ittt != my_fits.end(); ittt++){
773 Int_t zz = ittt->first;
774 fit_lnR21 = ittt->second;
787 gr_alpha_delta->
Write();
807 std::ofstream my_file;
808 my_file.open(fname.
Data(), std::ofstream::out);
809 my_file <<
"### system_pair Z Alpha d(Alpha) <A_1> d<A_1> <A_2> d<A_2> denum d(denum) Csym/T d(Csym/T) ###" << std::endl;
813 std::string str_sys = it0->first;
819 std::string sys1(((
TObjString*) arr->
At(0))->GetString().Data());
820 std::string sys2(((
TObjString*) arr->
At(1))->GetString().Data());
822 my_file <<
"### " << sys1 <<
" " << sys2 <<
" ###" << std::endl;
824 IsoFit_t my_isofit = my_iso.
fits;
827 for(
auto it1 = my_isofit.begin(); it1 != my_isofit.end(); it1++){
828 Int_t zz = it1->first;
834 GetAlpha(sys1, sys2, zz, alpha, alpha_err);
851 GetAMean(sys1, zz, meanA1, meanA1_err);
852 GetAMean(sys2, zz, meanA2, meanA2_err);
855 KVString line(
Form(
"%s %s %d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", sys1.c_str(), sys2.c_str(), zz, alpha, alpha_err, meanA1, meanA1_err, meanA2, meanA2_err, denum, denum_err, csymT, csymT_err));
856 my_file <<
line.Data() << std::endl;
859 if (
fdebug_)
Info(
"SaveResultsASCII",
"[%s/%s] results saved\n", sys1.c_str(), sys2.c_str());
865 if (
fdebug_)
Info(
"SaveResultsASCII",
"File '%s' saved", fname.
Data());
903 Error(
"GetAMean",
"[sys=%s] Z=%d is out of range", system_name.c_str(), zz);
935 GetAMean(system_name, next_zz, aa_real, aa_real_err);
938 if (delta_aa < min_val) {
942 if (
fdebug_)
Info(
"FindZFromAmean",
"[%s - A=%d] : Z=%d -> <A(Z)>=%lf +/- %lf [FOUND] delta=%lf, min_val=%lf", system_name.c_str(), aa, next_zz, aa_real, aa_real_err, delta_aa, min_val);
944 else if (
fdebug_)
Info(
"FindZFromAmean",
"[%s - A=%d] : Z=%d -> <A(Z)>=%lf +/- %lf [NOT FOUND] delta=%lf, min_val=%lf", system_name.c_str(), aa, next_zz, aa_real, aa_real_err, delta_aa, min_val);
978 std::string my_str = system_name1+
"_"+system_name2;
986 Error(
"GetAlpha",
"!!! (%s / %s) [Z=%d] : Fit function not found !!!", system_name1.c_str(), system_name2.c_str(), zz);
1036 if (debug)
Info(
"GetDeltaZA2",
"(%s / %s) [Z=%d] : denum=%lf +/- %lf", system_name1.c_str(), system_name2.c_str(), zz, denum, denum_err);
1039 if (!ok1)
Warning(
"GetDeltaZA2",
"<A1> was not found for Z=%d of system %s/%s", zz, system_name1.c_str(), system_name2.c_str());
1040 if (!ok2)
Warning(
"GetDeltaZA2",
"<A2> was not found for Z=%d of system %s/%s", zz, system_name1.c_str(), system_name2.c_str());
1080 is_oka =
GetAlpha(system_name1, system_name2, zz, alpha, alpha_err);
1085 is_okd =
GetDeltaZA2(system_name1, system_name2, zz, denum, denum_err, debug);
1088 if (is_oka && is_okd) {
1090 csymT = alpha / 4. / denum;
1094 Info(
"GetCsymOverT",
"(%s / %s) [Z=%d] : alpha=%lf +/- %lf, denum=%lf +/- %lf, Csym/T=%lf +/- %lf", system_name1.c_str(), system_name2.c_str(), zz, alpha, alpha_err, denum, denum_err, csymT, csymT_err);
1119 YieldData_t my_yields =
fSystemList_[system_name].yields;
1121 for(
auto it = my_yields.begin(); it != my_yields.end(); it++){
1122 Int_t zz = it->first;
1151 nl_z1.
Copy(nl_inter);
1152 nl_inter.
Inter(nl_z2);
1155 Info(
"GetSharedZNumberList",
"Zlist[%s]= %s, Zlist[%s]= %s, shared Zlist= %s",
1182 Element_t my_element =
fSystemList_[system_name].yields[zz];
1184 for(
auto it = my_element.begin(); it != my_element.end(); it++){
1185 Int_t aa = it->first;
1216 nl_a1.
Copy(nl_inter_a);
1217 nl_inter_a.
Inter(nl_a2);
1220 Info(
"GetSharedANumberList",
"Z=%d : Alist[%s]= %s, Alist[%s]= %s, shared Alist= %s",
1221 zz, system_name1.c_str(), nl_a1.
GetList(), system_name2.c_str(), nl_a2.
GetList(), nl_inter_a.
GetList()) ;
1236 Info(
"PrintYields",
"Printing the list of yields : ");
1241 std::string sys_name = it0->first;
1244 std::string my_path = my_system.
file_path;
1245 YieldData_t my_yields = my_system.
yields;
1247 printf(
"\n====== %s =====\n", sys_name.c_str());
1248 printf(
"extracted from path = '%s'\n", my_path.c_str());
1251 for(
auto it1 = my_yields.begin(); it1 != my_yields.end(); it1++){
1252 Int_t zz = it1->first;
1253 Element_t my_ele = it1->second;
1256 for(
auto it2 = my_ele.begin(); it2 != my_ele.end(); it2++){
1257 Int_t aa = it2->first;
1260 printf(
" Y(Z=%d, A=%d) = %lf +/- %lf\n", zz, aa, yield.
yield, yield.
yield_err);
1265 Info(
"PrintYields",
"That's all folks !");
1274 Info(
"PrintSystemsList",
"Printing the list of available systems : ");
1279 std::string sys_name = it0->first;
1282 std::string my_path = my_system.
file_path;
1283 YieldData_t my_yields = my_system.
yields;
1285 printf(
"\n====== %s =====\n", sys_name.c_str());
1286 printf(
"extracted from path = '%s'\n", my_path.c_str());
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
char * Form(const char *fmt,...)
KVNumberList GetANumberList(const std::string &system_name, Int_t zz)
std::unordered_map< std::string, System_t > fSystemList_
(hash) map by name
void PrintYieldsList()
— Printers —
Bool_t GetAMean(const std::string &system_name, Int_t zz, Float_t &meanA, Float_t &meanA_err)
— Getters —
void BuildIsoscalingPlots(const std::string &system_name1, const std::string &system_name2, Int_t mcolor, Int_t mstyle, Bool_t draw=kFALSE)
Bool_t fdebug_
verbose mode for debugging
void FitLnR21vsNPlots(const std::string &system_name1, const std::string &system_name2, Option_t *option="MNVR", Option_t *gooption="goff")
Double_t ftol_
tolerance for the gaussian approximation (in sigma)
KVNumberList GetSharedZNumberList(const std::string &system_name1, const std::string &system_name2)
void BuildLnR21vsNPlots(const std::string &system_name1, const std::string &system_name2)
void DrawLnR21vsNFits(const std::string &system_name1, const std::string &system_name2)
Bool_t GetCsymOverT(const std::string &system_name1, const std::string &system_name2, Int_t zz, Float_t &csymT, Float_t &csymT_err, Bool_t debug)
Bool_t GetAlpha(const std::string &system_name1, const std::string &system_name2, Int_t zz, Float_t &alpha, Float_t &alpha_err)
void TestGaussianApprox(const std::string &system_name1, const std::string &system_name2, Int_t zz, Double_t tol)
std::unordered_map< std::string, Isoscaling_t > fIsoscalingList_
(hash) map by name
void BuildGaussianPlots(const std::string &system_name)
void SaveResultsROOT(const Char_t *file_name="./isoscaling_output_file.root")
KVNumberList GetSharedANumberList(const std::string &system_name1, const std::string &system_name2, Int_t zz)
void CreateCsymOverTMultiGraph(TMultiGraph *mgr)
KVNumberList GetZNumberList(const std::string &system_name)
void SaveResultsASCII(const Char_t *file_name="./isoscaling_output_file.txt")
Bool_t GetDeltaZA2(const std::string &system_name1, const std::string &system_name2, Int_t zz, Float_t &denum, Float_t &denum_err, Bool_t debug)
Int_t FindZFromAmean(const std::string &system_name, Int_t aa)
Strings used to represent a set of ranges of values.
void Inter(const KVNumberList &list)
void Copy(TObject &) const
Copy content of this number list into 'o'.
const Char_t * GetList() const
Bool_t Contains(Int_t val) const
returns kTRUE if the value 'val' is contained in the ranges defined by the number list
Int_t First() const
Returns smallest number included in list.
void Add(Int_t)
Add value 'n' to the list.
Int_t Last() const
Returns largest number included in list.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual Double_t GetParameter(const TString &name) const
virtual Double_t GetParError(Int_t ipar) const
void Draw(Option_t *option="") override
virtual void SetParameters(const Double_t *params)
virtual void SetPointError(Double_t ex, Double_t ey)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
void SetName(const char *name="") override
void Draw(Option_t *chopt="") override
virtual void Add(TGraph *graph, Option_t *chopt="")
void Draw(Option_t *chopt="") override
virtual void SetTitle(const char *title="")
const char * GetName() const override
TObject * At(Int_t idx) const override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
fit(model, train_loader, val_loader, num_epochs, batch_size, optimizer, criterion, save_best, scheduler)
Double_t Power(Double_t x, Double_t y)
Double_t Sqrt(Double_t x)
TGraphErrors * gr_alpha_delta