KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVNuclearChart.cpp
Go to the documentation of this file.
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 
20 KVNuclearChart::KVNuclearChart(Int_t nMin, Int_t nMax, Int_t zMin, Int_t zMax, Double_t life): fNucleusBoxList(kTRUE), fMagicList(kTRUE), fSymbolList(kTRUE)
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();
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() > 1.e+30) fInfo->AddText("T_{1/2} > 1.00e+30 s");
259  else fInfo->AddText(Form("T_{1/2} = %3.2e s", nuc->GetLifeTime()));
260  if (!fOwnHisto && fHisto) {
261  TAxis* ax = fHisto->GetXaxis();
262  Int_t xmin = ax->FindBin(nuc->GetN() - 0.5);
263  Int_t xmax = ax->FindBin(nuc->GetN() + 0.5);
264  ax = fHisto->GetYaxis();
265  Int_t ymin = ax->FindBin(nuc->GetZ() - 0.5);
266  Int_t ymax = ax->FindBin(nuc->GetZ() + 0.5);
268  fInfo->AddText(Form("M = %d", M));
269  }
271  fInfo->Draw("same");
272 
273  TString symbText = nuc->GetSymbol();
274  symbText.ReplaceAll(Form("%d", nuc->GetA()), Form("^{%d}", nuc->GetA()));
275 // symbText += Form("_{%d}", nuc->GetN());
276 
277  if ((!fSymbol) || (!fInfo)) return;
278 
279  fSymbol->Clear();
280  fSymbol->AddText(symbText.Data());
285  fSymbol->Draw("same");
286  update_pad();
287 
288 }
289 
290 
291 
293 
294 void KVNuclearChart::ShowLevelScheme(const char* decays)
295 {
297  lvs->Draw();
298 
299  KVString dec = decays;
300  dec.Begin(",");
301  while (!dec.End()) lvs->DrawThreshold(dec.Next());
302 }
303 
304 
305 
307 
309 {
310  fShowSymbol = value;
311  ShowSymbol();
312 }
313 
314 
315 
317 
319 {
320  if (!fShowSymbol) {
321  fSymbolList.Clear();
322  update_pad();
323  return;
324  }
325 
326  KVNucleus nuc;
327  for (int zz = fZmin; zz <= fZmax; zz++) {
328  nuc.SetZ(zz);
329  KVNumberList ll = nuc.GetKnownARange(zz, 1.e-6);
330  if (ll.IsEmpty()) continue;
331  Double_t xx = ll.First() - zz - (zz == 1 ? 1 : 2);
332  Double_t yy = zz;
333 
334  TLatex* label = new TLatex(xx, yy, nuc.GetSymbol("EL"));
335  label->SetTextAlign(22);
336  label->SetTextSize(0.025);
337  label->SetTextFont(42);
338 
339  TLatex* last = (TLatex*)fSymbolList.Last();
340  if (last && (last->GetX() > label->GetX())) last->SetX(label->GetX());
341 
342  fSymbolList.AddLast(label);
343  }
344 
345  TObject* obj = 0;
346  TIter it(&fSymbolList);
347  while ((obj = it())) obj->Draw();
348 
349  update_pad();
350 }
351 
352 
353 
356 
358 {
359  // draw name of isotope in each box
360 
361  TIter it(&fNucleusBoxList);
362  KVNucleusBox* box;
363  while ((box = (KVNucleusBox*)it())) box->SetShowSymbol(on);
364  update_pad();
365 }
366 
367 
368 
370 
372 {
373  TIter it(&fNucleusBoxList);
374  KVNucleusBox* box;
375  while ((box = (KVNucleusBox*)it())) box->SetSymbolSize(size);
376  update_pad();
377 }
378 
379 
380 
382 
384 {
385  fShowMagicNumbers = value;
387 }
388 
389 
390 
392 
394 {
395  if (!fShowMagicNumbers) {
396  fMagicList.Clear();
397  update_pad();
398  return;
399  }
400 
401  for (int i = 0; i < 7; i++) {
402  Int_t num = fNm[i];
403  if ((num >= fNmin + 1) && (num <= fNmax - 1) && (fZmMin[i] < fZmax)) {
404  TLine* ll1 = new TLine(num - 0.5, TMath::Max(fZmin * 1., fZmMin[i]), num - 0.5, TMath::Min(fZmax * 1., fZmMax[i]));
405  TLine* ll2 = new TLine(num + 0.5, TMath::Max(fZmin * 1., fZmMin[i]), num + 0.5, TMath::Min(fZmax * 1., fZmMax[i]));
406  fMagicList.AddLast(ll1);
407  fMagicList.AddLast(ll2);
408  if (num >= 20) {
409  TLatex* label = new TLatex(num * 1., fZmMin[i] - 1.5, Form("N=%d", num));
410  label->SetTextAlign(22);
411  label->SetTextSize(0.025);
412  label->SetTextFont(42);
413  fMagicList.AddLast(label);
414  }
415  }
416  }
417 
418  for (int i = 0; i < 7; i++) {
419  Int_t num = fNm[i];
420  if ((num >= fZmin + 1) && (num <= fZmax - 1) && (fNmMin[i] < fNmax)) {
421  TLine* ll1 = new TLine(TMath::Max(fNmin * 1., fNmMin[i]), num - 0.5, TMath::Min(fNmax * 1., fNmMax[i]), num - 0.5);
422  TLine* ll2 = new TLine(TMath::Max(fNmin * 1., fNmMin[i]), num + 0.5, TMath::Min(fNmax * 1., fNmMax[i]), num + 0.5);
423  fMagicList.AddLast(ll1);
424  fMagicList.AddLast(ll2);
425  if (num >= 20) {
426  TLatex* label = new TLatex(fNmMin[i] - 1.5, num * 1., Form("Z=%d", num));
427  label->SetTextAlign(32);
428  label->SetTextSize(0.025);
429  label->SetTextFont(42);
430  fMagicList.AddLast(label);
431  }
432  }
433  }
434 
435  fMagicList.Execute("Draw", "");
436 
437 }
438 
439 
440 
441 
442 
443 
444 
445 
446 
int Int_t
KVIonRangeTableMaterial * M
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
size_t size(const MatrixT &matrix)
const Bool_t kFALSE
bool Bool_t
double Double_t
float Float_t
const Bool_t kTRUE
const char Option_t
kBlack
kWhite
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:135
virtual void Copy(TObject &) const
Make a copy of this object.
Definition: KVBase.cpp:397
TCanvas with mouse-controlled dynamic zoom and pan & scan.
Definition: KVCanvas.h:53
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()
TVirtualPad * fPad
void ShowNucleusInfo(KVNucleus *nuc)
TPaveText * fInfo
KVList fNucleusBoxList
Double_t fZmMin[7]
KVNucleus * fCurrentNuc
void ShowLevelScheme(const char *decays)
Double_t fNmMax[7]
void SetShowMagicNumbers(Int_t value=1)
void Copy(TObject &) const
KVCanvas * fCanvas
Int_t fShowMagicNumbers
TPaveText * fSymbol
Double_t fNmMin[7]
KVNucleus * fShownNucleus
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 Draw(Option_t *option="")
Double_t fZmMax[7]
A TBox representing a nucleus in a KVNuclearChart.
Definition: KVNucleusBox.h:18
void SetNuclearChart(KVNuclearChart *nuclearchart)
Definition: KVNucleusBox.h:38
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:125
const Char_t * GetSymbol(Option_t *opt="") const
Definition: KVNucleus.cpp:81
Int_t GetA() const
Definition: KVNucleus.cpp:799
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:704
KVNumberList GetKnownARange(Int_t z=-1, Double_t tmin=0) const
Definition: KVNucleus.cpp:1398
Int_t GetN() const
Return the number of neutron.
Definition: KVNucleus.cpp:781
void SetZandA(Int_t z, Int_t a)
Set atomic number and mass number.
Definition: KVNucleus.cpp:721
Bool_t IsStable(Double_t min_lifetime=1.0e+15) const
Definition: KVNucleus.cpp:2008
Int_t GetZ() const
Return the number of proton / atomic number.
Definition: KVNucleus.cpp:770
Double_t GetLifeTime(Int_t z=-1, Int_t a=-1) const
Definition: KVNucleus.cpp:1040
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:83
Int_t First() const
Returns smallest number included in list.
Bool_t End(void) const
Definition: KVNumberList.h:196
void Begin(void) const
Bool_t IsEmpty() const
Definition: KVNumberList.h:173
Int_t Next(void) const
virtual void AddLast(TObject *obj)
virtual TObject * Last() const
virtual void Clear(Option_t *option="")
virtual void Execute(const char *method, const char *params, Int_t *error=0)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
void Begin(TString delim) const
Definition: KVString.cpp:562
Bool_t End() const
Definition: KVString.cpp:625
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:675
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()
virtual void Draw(Option_t *option="")
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 void Draw(Option_t *option="")
virtual TText * AddText(const char *label)
virtual void Clear(Option_t *option="")
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)
const long double cc
volumes
Definition: KVUnits.h:83
Double_t Min(Double_t a, Double_t b)
Double_t Max(Double_t a, Double_t b)