KaliVeda
Toolkit for HIC analysis
KVNuclearChart.cpp
1 //Created by KVClassFactory on Thu Nov 22 15:26:52 2012
2 //Author: dgruyer
3 
4 #include "KVNuclearChart.h"
5 #include "KVNucleus.h"
6 #include "KVNucleusBox.h"
7 #include "KVCanvas.h"
8 #include "TStyle.h"
9 #include "TBox.h"
10 #include "TLine.h"
11 #include "TString.h"
12 #include "TLatex.h"
13 #include "KVLevelScheme.h"
14 
16 
17 
18 
21 {
22  fNmin = nMin;
23  fNmax = nMax;
24  fZmin = zMin;
25  fZmax = zMax;
26 
27  if ((fNmax < 0) || (fZmax < 0)) {
28  fNmax = 177;
29  fZmax = 115;
30  }
31 
32  fOwnHisto = 0;
33  fHisto = 0;
34  fShownNucleus = 0;
35  fCanvas = nullptr;
36  fPad = nullptr;
37  fShowMagicNumbers = kTRUE;
38  fShowSymbol = kFALSE;
39 
40  fSymbol = new TPaveText(0.65, 0.16, 0.75, 0.01, "NDC");
41  fSymbol->SetBorderSize(1);
42  fInfo = new TPaveText(0.76, 0.16, 0.99, 0.01, "NDC");
43  fInfo->SetTextAlign(12);
44  fInfo->SetFillColor(kWhite);
45  fInfo->SetLineColor(kBlack);
46  fInfo->SetTextColor(kBlack);
47  fInfo->SetBorderSize(1);
48 
49  KVNucleus nuc;
50  for (int zz = fZmin; zz <= fZmax; zz++) {
51  KVNumberList ll = nuc.GetKnownARange(zz);
52  ll.Begin();
53  while (!ll.End()) {
54  Int_t aa = ll.Next();
55  nuc.SetZandA(zz, aa);
56  Int_t nn = aa - zz;
57  if ((nn >= fNmin) && (nn <= fNmax)) {
58  if (nuc.IsStable() || nuc.GetLifeTime() > life) {
59  KVNucleusBox* nb = new KVNucleusBox(zz, nn);
60  nb->SetNuclearChart(this);
61  fNucleusBoxList.Add(nb);
62  }
63  }
64  }
65  }
66 
67  fNm[0] = 2;
68  fNm[1] = 8;
69  fNm[2] = 20;
70  fNm[3] = 28;
71  fNm[4] = 50;
72  fNm[5] = 82;
73  fNm[6] = 126;
74 
75  fNmMin[0] = 0.;
76  fNmMin[1] = 1.;
77  fNmMin[2] = 12.;
78  fNmMin[3] = 18.;
79  fNmMin[4] = 46.;
80  fNmMin[5] = 93.;
81  fNmMin[6] = 98.;
82  fNmMax[0] = 10.;
83  fNmMax[1] = 22.;
84  fNmMax[2] = 40.;
85  fNmMax[3] = 52.;
86  fNmMax[4] = 90.;
87  fNmMax[5] = 136.;
88  fNmMax[6] = 126.*3;
89 
90  fZmMin[0] = 0.2;
91  fZmMin[1] = 0.2;
92  fZmMin[2] = 6.;
93  fZmMin[3] = 10.;
94  fZmMin[4] = 26.;
95  fZmMin[5] = 44.;
96  fZmMin[6] = 76.;
97  fZmMax[0] = 9.;
98  fZmMax[1] = 17.;
99  fZmMax[2] = 30.;
100  fZmMax[3] = 35.;
101  fZmMax[4] = 53.;
102  fZmMax[5] = 76.;
103  fZmMax[6] = 95.;
104 
105  return;
106 }
107 
108 
109 
110 
117 
119 {
120  // Copy constructor
121  // This ctor is used to make a copy of an existing object (for example
122  // when a method returns an object), and it is always a good idea to
123  // implement it.
124  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
125 
126  obj.Copy(*this);
127 }
128 
129 
130 
138 
140 {
141  // Destructor
142 // if(fCanvas)
143 // {
144 // fCanvas->ResetDisabledClass();
145 // fCanvas->ResetDisabledObject();
146 // }
147  if ((fHisto) && (fOwnHisto)) delete fHisto;
148  if (fSymbol) delete fSymbol;
149  if (fInfo) delete fInfo;
150 }
151 
152 
153 
154 
162 
164 {
165  // This method copies the current state of 'this' object into 'obj'
166  // You should add here any member variables, for example:
167  // (supposing a member variable KVNuclearChart::fToto)
168  // CastedObj.fToto = fToto;
169  // or
170  // CastedObj.SetToto( GetToto() );
171 
172  KVBase::Copy(obj);
173  //KVNuclearChart& CastedObj = (KVNuclearChart&)obj;
174 }
175 
176 
177 
179 
181 {
182  gStyle->SetOptStat(0);
183 
184  TString opt(option);
185  Bool_t DrawSame = opt.Contains("same");
186 
187  if (DrawSame && gPad) {
188  fPad = gPad;
189  TObject* obj = 0;
190  TIter next(gPad->GetListOfPrimitives());
191  while ((obj = next())) {
192  if (obj->InheritsFrom("TH2")) {
193  fHisto = (TH2*) obj;
194  break;
195  }
196  }
197  }
198  else {
199  KVCanvas* cc = new KVCanvas;
200  TPad* pp = (TPad*) cc->cd();
201  fPad = pp;
202 
203  Double_t marging = 0.001;
204  pp->SetTopMargin(marging);
205  pp->SetRightMargin(marging);
206  pp->SetBottomMargin(marging);
207  pp->SetLeftMargin(marging);
208 
209  fHisto = new TH2F("NuclearChart", "", fNmax - fNmin + 2, fNmin - 1, fNmax + 1, fZmax - fZmin + 2, fZmin - 1, fZmax + 1);
210  fOwnHisto = kTRUE;
211  TAxis* ax = 0;
212  ax = fHisto->GetXaxis();
213  ax->SetNdivisions(000);
214  ax = fHisto->GetYaxis();
215  ax->SetNdivisions(000);
216 
217  fHisto->Draw();
218  }
219 
220  if (gPad->GetCanvas()->InheritsFrom("KVCanvas")) {
221  KVCanvas* cc = (KVCanvas*) gPad->GetCanvas();
222  cc->DisableClass("TLine");
223  cc->DisableClass("KVNucleusBox");
224  cc->DisableClass("TLatex");
225  cc->DisableObject(fSymbol);
226  cc->DisableObject(fInfo);
227  fCanvas = cc;
228  }
229 
230  fNucleusBoxList.Execute("SetDrawMode", Form("%d", DrawSame));
231  fNucleusBoxList.Execute("EnableToolTip", "");
232  fNucleusBoxList.Execute("Draw", "");
233 
235 
236  return;
237 }
238 
239 
240 
242 
244 {
245  if ((fShownNucleus) && (fShownNucleus == nuc)) {
246  fSymbol->Clear();
247  fInfo->Clear();
248  fPad->GetListOfPrimitives()->Remove(fSymbol);
249  fPad->GetListOfPrimitives()->Remove(fInfo);
250  update_pad();
251  fShownNucleus = 0;
252  return;
253  }
254 
255  fShownNucleus = nuc;
256  fInfo->Clear();
257  fInfo->AddText(Form("Z = %d N = %d", nuc->GetZ(), nuc->GetN()));
258  if(nuc->GetLifeTime())
259  {
260  if (*nuc->GetLifeTime() > 1.e+30) fInfo->AddText("T_{1/2} > 1.00e+30 s");
261  else fInfo->AddText(Form("T_{1/2} = %3.2e s", *nuc->GetLifeTime()));
262  }
263  if (!fOwnHisto && fHisto) {
264  TAxis* ax = fHisto->GetXaxis();
265  Int_t xmin = ax->FindBin(nuc->GetN() - 0.5);
266  Int_t xmax = ax->FindBin(nuc->GetN() + 0.5);
267  ax = fHisto->GetYaxis();
268  Int_t ymin = ax->FindBin(nuc->GetZ() - 0.5);
269  Int_t ymax = ax->FindBin(nuc->GetZ() + 0.5);
270  Int_t M = fHisto->Integral(xmin, xmax, ymin, ymax);
271  fInfo->AddText(Form("M = %d", M));
272  }
273  fPad->GetListOfPrimitives()->Remove(fInfo);
274  fInfo->Draw("same");
275 
276  TString symbText = nuc->GetSymbol();
277  symbText.ReplaceAll(Form("%d", nuc->GetA()), Form("^{%d}", nuc->GetA()));
278 // symbText += Form("_{%d}", nuc->GetN());
279 
280  if ((!fSymbol) || (!fInfo)) return;
281 
282  fSymbol->Clear();
283  fSymbol->AddText(symbText.Data());
284  fPad->GetListOfPrimitives()->Remove(fSymbol);
285  fSymbol->SetFillColor(kBlack);
286  fSymbol->SetLineColor(kBlack);
287  fSymbol->SetTextColor(kWhite);
288  fSymbol->Draw("same");
289  update_pad();
290 
291 }
292 
293 
294 
296 
297 void KVNuclearChart::ShowLevelScheme(const char* decays)
298 {
299  KVLevelScheme* lvs = new KVLevelScheme(fCurrentNuc->GetSymbol());
300  lvs->Draw();
301 
302  KVString dec = decays;
303  dec.Begin(",");
304  while (!dec.End()) lvs->DrawThreshold(dec.Next());
305 }
306 
307 
308 
310 
312 {
313  fShowSymbol = value;
314  ShowSymbol();
315 }
316 
317 
318 
320 
322 {
323  if (!fShowSymbol) {
324  fSymbolList.Clear();
325  update_pad();
326  return;
327  }
328 
329  KVNucleus nuc;
330  for (int zz = fZmin; zz <= fZmax; zz++) {
331  nuc.SetZ(zz);
332  KVNumberList ll = nuc.GetKnownARange(zz, 1.e-6);
333  if (ll.IsEmpty()) continue;
334  Double_t xx = ll.First() - zz - (zz == 1 ? 1 : 2);
335  Double_t yy = zz;
336 
337  TLatex* label = new TLatex(xx, yy, nuc.GetSymbol("EL"));
338  label->SetTextAlign(22);
339  label->SetTextSize(0.025);
340  label->SetTextFont(42);
341 
342  TLatex* last = (TLatex*)fSymbolList.Last();
343  if (last && (last->GetX() > label->GetX())) last->SetX(label->GetX());
344 
345  fSymbolList.AddLast(label);
346  }
347 
348  TObject* obj = 0;
349  TIter it(&fSymbolList);
350  while ((obj = it())) obj->Draw();
351 
352  update_pad();
353 }
354 
355 
356 
359 
361 {
362  // draw name of isotope in each box
363 
364  TIter it(&fNucleusBoxList);
365  KVNucleusBox* box;
366  while ((box = (KVNucleusBox*)it())) box->SetShowSymbol(on);
367  update_pad();
368 }
369 
370 
371 
373 
375 {
376  TIter it(&fNucleusBoxList);
377  KVNucleusBox* box;
378  while ((box = (KVNucleusBox*)it())) box->SetSymbolSize(size);
379  update_pad();
380 }
381 
382 
383 
385 
387 {
388  fShowMagicNumbers = value;
390 }
391 
392 
393 
395 
397 {
398  if (!fShowMagicNumbers) {
399  fMagicList.Clear();
400  update_pad();
401  return;
402  }
403 
404  for (int i = 0; i < 7; i++) {
405  Int_t num = fNm[i];
406  if ((num >= fNmin + 1) && (num <= fNmax - 1) && (fZmMin[i] < fZmax)) {
407  TLine* ll1 = new TLine(num - 0.5, TMath::Max(fZmin * 1., fZmMin[i]), num - 0.5, TMath::Min(fZmax * 1., fZmMax[i]));
408  TLine* ll2 = new TLine(num + 0.5, TMath::Max(fZmin * 1., fZmMin[i]), num + 0.5, TMath::Min(fZmax * 1., fZmMax[i]));
409  fMagicList.AddLast(ll1);
410  fMagicList.AddLast(ll2);
411  if (num >= 20) {
412  TLatex* label = new TLatex(num * 1., fZmMin[i] - 1.5, Form("N=%d", num));
413  label->SetTextAlign(22);
414  label->SetTextSize(0.025);
415  label->SetTextFont(42);
416  fMagicList.AddLast(label);
417  }
418  }
419  }
420 
421  for (int i = 0; i < 7; i++) {
422  Int_t num = fNm[i];
423  if ((num >= fZmin + 1) && (num <= fZmax - 1) && (fNmMin[i] < fNmax)) {
424  TLine* ll1 = new TLine(TMath::Max(fNmin * 1., fNmMin[i]), num - 0.5, TMath::Min(fNmax * 1., fNmMax[i]), num - 0.5);
425  TLine* ll2 = new TLine(TMath::Max(fNmin * 1., fNmMin[i]), num + 0.5, TMath::Min(fNmax * 1., fNmMax[i]), num + 0.5);
426  fMagicList.AddLast(ll1);
427  fMagicList.AddLast(ll2);
428  if (num >= 20) {
429  TLatex* label = new TLatex(fNmMin[i] - 1.5, num * 1., Form("Z=%d", num));
430  label->SetTextAlign(32);
431  label->SetTextSize(0.025);
432  label->SetTextFont(42);
433  fMagicList.AddLast(label);
434  }
435  }
436  }
437 
438  fMagicList.Execute("Draw", "");
439 
440 }
441 
442 
443 
444 
445 
446 
447 
448 
449 
int Int_t
size_t size(const MatrixT &matrix)
bool Bool_t
float Float_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
kBlack
kWhite
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
float xmin
float ymin
float xmax
float ymax
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
#define gPad
Base class for KaliVeda framework.
Definition: KVBase.h:140
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:396
TCanvas with mouse-controlled dynamic zoom and pan & scan.
Definition: KVCanvas.h:54
Tool to simulate nucleus multi-particle decay.
Definition: KVLevelScheme.h:23
void DrawThreshold(const char *symb, Option_t *option="", double ex=0.)
void Draw(Option_t *option="")
Used to draw nuclear chart.
virtual ~KVNuclearChart()
void Draw(Option_t *option="") override
void ShowNucleusInfo(KVNucleus *nuc)
void ShowLevelScheme(const char *decays)
void SetShowMagicNumbers(Int_t value=1)
void SetBoxSymbolSize(Float_t size=0.02)
KVNuclearChart(Int_t nMin=0, Int_t nMax=-1, Int_t zMin=0, Int_t zMax=-1, Double_t life=1.e-06)
KVNuclearChart();.
void ShowBoxSymbols(Bool_t on=kTRUE)
draw name of isotope in each box
void SetShowSymbol(Int_t value=1)
void Copy(TObject &) const override
A TBox representing a nucleus in a KVNuclearChart.
Definition: KVNucleusBox.h:19
void SetNuclearChart(KVNuclearChart *nuclearchart)
Definition: KVNucleusBox.h:39
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:108
const Char_t * GetSymbol(Option_t *opt="") const
Definition: KVNucleus.cpp:43
std::optional< double > GetLifeTime(std::optional< int > z={}, std::optional< int > a={}) const
Definition: KVNucleus.cpp:1045
Int_t GetA() const
Definition: KVNucleus.cpp:805
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:709
Int_t GetN() const
Return the number of neutron.
Definition: KVNucleus.cpp:787
void SetZandA(Int_t z, Int_t a)
Set atomic number and mass number.
Definition: KVNucleus.cpp:726
KVNumberList GetKnownARange(std::optional< int > z={}, std::optional< double > tmin={}) const
Definition: KVNucleus.cpp:1342
Bool_t IsStable(Double_t min_lifetime=1.0e+15) const
Definition: KVNucleus.cpp:1939
Int_t GetZ() const
Return the number of proton / atomic number.
Definition: KVNucleus.cpp:776
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Int_t First() const
Returns smallest number included in list.
Bool_t End(void) const
Definition: KVNumberList.h:199
void Begin(void) const
Bool_t IsEmpty() const
Definition: KVNumberList.h:175
Int_t Next(void) const
void Execute(const char *method, const char *params, Int_t *error=0) override
void AddLast(TObject *obj) override
TObject * Last() const override
void Clear(Option_t *option="") override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
virtual void SetNdivisions(Int_t n1, Int_t n2, Int_t n3, Bool_t optim=kTRUE)
virtual void SetFillColor(Color_t fcolor)
virtual void SetLineColor(Color_t lcolor)
virtual void SetBottomMargin(Float_t bottommargin)
virtual void SetLeftMargin(Float_t leftmargin)
virtual void SetRightMargin(Float_t rightmargin)
virtual void SetTopMargin(Float_t topmargin)
virtual void SetTextAlign(Short_t align=11)
virtual void SetTextColor(Color_t tcolor=1)
virtual void SetTextFont(Font_t tfont=62)
virtual void SetTextSize(Float_t tsize=1)
virtual Int_t FindBin(const char *label)
TAxis * GetXaxis()
TAxis * GetYaxis()
void Draw(Option_t *option="") override
virtual Double_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t *option="") const
TObject * Remove(const TObjLinkPtr_t &lnk)
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Draw(Option_t *option="")
virtual TText * AddText(const char *label)
void Clear(Option_t *option="") override
void Draw(Option_t *option="") override
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
void SetOptStat(Int_t stat=1)
Double_t GetX() const
virtual void SetX(Double_t x)
virtual TList * GetListOfPrimitives() const=0
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Double_t Min(Double_t a, Double_t b)
Double_t Max(Double_t a, Double_t b)
ClassImp(TPyArg)