TkN 2.1
Toolkit for Nuclei
draw_differential_binding.C
1#include "tkmanager.h"
2#include "TGraph.h"
3#include "TLine.h"
4#include "TF1.h"
5#include "TH2F.h"
6#include "TLegend.h"
7#include "TLegendEntry.h"
8#include "TROOT.h"
9#include "TLatex.h"
10
11using namespace tkn;
12using namespace std;
13
14int mn[]={2,8,20,28,50,82};
15
16Double_t fitfunc(Double_t *x,Double_t *par);
17TLine* get_line(unsigned int MagicNumber);
18TLatex* get_shell(unsigned int MagicNumber, const char* shell);
19TLegend* get_legend();
20void set_style(TGraph* g1, TGraph* g2);
21
22void draw_differential_binding()
23{
24 gROOT->SetStyle("tkn-histo");
25
26 TGraph* nuc_neqz = new TGraph;
27 nuc_neqz->SetTitle("N = Z");
28 TGraph* nuc_other = new TGraph;
29 nuc_other->SetTitle("N #neq Z");
30
31 set_style(nuc_neqz, nuc_other);
32
33 tkmanager dtm;
34 for(const auto &nuc : dtm.get_nuclei([&](auto nuc) {return (nuc->get_z()%2==0 &&
35 nuc->get_n()%2==0 &&
36 nuc->get_z()<50&&
37 dtm.known_nucleus(nuc->get_z()-2, nuc->get_a()-2)&&
38 dtm.known_nucleus(nuc->get_z(), nuc->get_a()-2)&&
39 dtm.known_nucleus(nuc->get_z()-2, nuc->get_a()-4));}))
40 {
41 int Z = nuc->get_z();
42 int A = nuc->get_a();
43
44 double binding_diff = -0.25*(nuc->get_binding_energy_over_a()*A
45 - dtm.get_nucleus(Z-2, A-2)->get_binding_energy_over_a()*(A-2)
46 - dtm.get_nucleus(Z,A-2)->get_binding_energy_over_a()*(A-2)
47 + dtm.get_nucleus(Z-2,A-4)->get_binding_energy_over_a()*(A-4));
48
49 if(Z==A-Z) nuc_neqz->AddPoint(Z, binding_diff);
50 else nuc_other->AddPoint(Z, binding_diff);
51 }
52
53 TF1* func = new TF1("fit",fitfunc,2,50,5);
54 func->SetParameters(-8,-4.1,-2,-1.5,-1);
55 func->SetMarkerStyle(1);
56 func->SetMarkerColor(func->GetLineColor());
57 nuc_neqz->Fit(func,"QN","",2,50);
58
59 TH2* hdum = new TH2F("dum","dum",10,2,50,10,-8,0);
60 hdum->GetYaxis()->SetTitle("#Delta^{2}B (MeV)");
61 hdum->GetXaxis()->SetTitle("Proton Number");
62 hdum->Draw();
63
64 for(auto z: {1,2,3}) get_line(mn[z])->Draw();
65
66 const char* shells[] = {"1p","2s/1d","1f","1g,1f,2p"};
67 for(auto z: {1,2,3,4}) get_shell(mn[z],shells[z-1])->Draw();
68
69 func->Draw("same");
70 nuc_neqz->Draw("P");
71 nuc_other->Draw("P");
72 get_legend()->Draw();
73}
74
75Double_t fitfunc(Double_t *x,Double_t *par)
76{
77 if(x[0]<mn[0]||x[0]>mn[4]) return std::nan("1");
78 int idx = 0;
79 for(; idx<6; idx++) if(x[0]<=mn[idx]) break;
80 return (par[idx]-par[idx-1])/(mn[idx]-mn[idx-1])*(x[0]-mn[idx-1]) + par[idx-1];
81}
82
83TLine* get_line(unsigned int MagicNumber)
84{
85 TLine *ll = new TLine(MagicNumber,-8+0.01,MagicNumber,-0.01);
86 ll->SetLineColor(kGray+1);
87 return ll;
88}
89
90TLatex* get_shell(unsigned int MagicNumber, const char* shell)
91{
92 TLatex* tex = new TLatex(MagicNumber-1,-7.5,shell);
93 tex->SetTextAlign(32);
94 tex->SetTextFont(132);
95 tex->SetTextColor(kGray+2);
96 tex->SetTextSize(0.0630252);
97 tex->SetLineWidth(2);
98 return tex;
99}
100
101TLegend *get_legend()
102{
103 TLegend *leg = new TLegend(0.747492,0.432773,0.956522,0.64916,NULL,"brNDC");
104 leg->SetBorderSize(0);
105 leg->SetTextFont(132);
106 leg->SetLineColor(0);
107 leg->SetLineStyle(0);
108 leg->SetLineWidth(0);
109 leg->SetFillColor(0);
110 leg->SetFillStyle(1001);
111
112 TLegendEntry *entry = 0;
113 entry=leg->AddEntry("","N #neq Z","lpf");
114 entry->SetFillStyle(1000);
115 entry->SetLineStyle(0);
116 entry->SetLineColor(kWhite);
117 entry->SetLineWidth(0);
118 entry->SetMarkerColor(kAzure-3);
119 entry->SetMarkerStyle(20);
120 entry->SetMarkerSize(1);
121 entry->SetTextFont(132);
122
123 entry=leg->AddEntry("","N = Z","lpf");
124 entry->SetFillStyle(1000);
125 entry->SetLineStyle(0);
126 entry->SetLineWidth(0);
127 entry->SetLineColor(kWhite);
128 entry->SetMarkerColor(kCyan-2);
129 entry->SetMarkerStyle(21);
130 entry->SetMarkerSize(1.2);
131 entry->SetTextFont(132);
132
133 return leg;
134}
135
136void set_style(TGraph* g1, TGraph* g2)
137{
138 g1->SetMarkerStyle(21);
139 g1->SetMarkerSize(1.2);
140 g1->SetMarkerColor(kCyan-2);
141 g1->SetLineColor(kWhite);
142 g1->SetTitle("N = Z");
143
144 g2->SetMarkerStyle(20);
145 g2->SetMarkerSize(1);
146 g2->SetMarkerColor(kAzure-3);
147 g2->SetLineColor(kWhite);
148 g2->SetTitle("N #neq Z");
149}
Manages the database loading and provides access to the physics properties.
Definition: tkmanager.h:55
shared_ptr< tknucleus > get_nucleus(const tkstring &_nuc)
return a shared pointer to a nucleus from its name
Definition: tkmanager.h:126
vector< shared_ptr< tknucleus > > get_nuclei(std::function< bool(shared_ptr< tknucleus >)>const &_selection)
return a vector containing all the known nuclei filtered by the lambda function
Definition: tkmanager.cpp:367
Definition: tklog.cpp:39