Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RadioNuclides.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Macro that demonstrates usage of radioactive elements/materials/mixtures
4/// with TGeo package.
5///
6/// A radionuclide (TGeoElementRN) derives from the class TGeoElement and
7/// provides additional information related to its radioactive properties and
8/// decay modes.
9///
10/// The radionuclides table is loaded on demand by any call:
11///
12/// ~~~{.cpp}
13/// TGeoElementRN *TGeoElementTable::GetElementRN(Int_t atomic_number,
14/// Int_t atomic_charge,
15/// Int_t isomeric_number)
16/// ~~~
17///
18/// The isomeric number is optional and the default value is 0.
19///
20/// To create a radioactive material based on a radionuclide, one should use the
21/// constructor:
22///
23/// ~~~{.cpp}
24/// TGeoMaterial(const char *name, TGeoElement *elem, Double_t density)
25/// ~~~
26///
27/// To create a radioactive mixture, one can use radionuclides as well as stable
28/// elements:
29///
30/// ~~~{.cpp}
31/// TGeoMixture(const char *name, Int_t nelements, Double_t density);
32/// TGeoMixture::AddElement(TGeoElement *elem, Double_t weight_fraction);
33/// ~~~
34///
35/// Once defined, one can retrieve the time evolution for the radioactive
36/// materials/mixtures by using one of the 2 methods:
37///
38/// ~~~{.cpp}
39/// void TGeoMaterial::FillMaterialEvolution(TObjArray *population,
40/// Double_t precision=0.001)
41/// ~~~
42///
43/// To use this method, one has to provide an empty TObjArray object that will
44/// be filled with all elements coming from the decay chain of the initial
45/// radionuclides contained by the material/mixture. The precision represent the
46/// cumulative branching ratio for which decay products are still considered.
47/// The POPULATION list may contain stable elements as well as radionuclides,
48/// depending on the initial elements. To test if an element is a radionuclide:
49///
50/// ~~~{.cpp}
51/// Bool_t TGeoElement::IsRadioNuclide() const
52/// ~~~
53///
54/// All radionuclides in the output population list have attached objects that
55/// represent the time evolution of their fraction of nuclei with respect to the
56/// top radionuclide in the decay chain. These objects (Bateman solutions) can be
57/// retrieved and drawn:
58///
59/// ~~~{.cpp}
60/// TGeoBatemanSol *TGeoElementRN::Ratio();
61/// void TGeoBatemanSol::Draw();
62/// ~~~
63///
64/// Another method allows to create the evolution of a given radioactive
65/// material/mixture at a given moment in time:
66///
67/// ~~~{.cpp}
68/// TGeoMaterial::DecayMaterial(Double_t time, Double_t precision=0.001)
69/// ~~~
70///
71/// The method will create the mixture that result from the decay of a initial
72/// material/mixture at TIME, while all resulting elements having a fractional
73/// weight less than PRECISION are excluded.
74///
75/// \macro_image
76/// \macro_code
77///
78/// \author Mihaela Gheata
79
80void DrawPopulation(TObjArray *vect, TCanvas *can, Double_t tmin = 0., Double_t tmax = 0., Bool_t logx = kFALSE);
81
82void RadioNuclides()
83{
84 TGeoManager *geom = new TGeoManager("", "");
86 TGeoElementRN *c14 = table->GetElementRN(14, 6);
87 TGeoElementRN *el1 = table->GetElementRN(53, 20);
88 TGeoElementRN *el2 = table->GetElementRN(78, 38);
89 // Radioactive material
90 TGeoMaterial *mat = new TGeoMaterial("C14", c14, 1.3);
91 printf("___________________________________________________________\n");
92 printf("Radioactive material:\n");
93 mat->Print();
94 Double_t time = 1.5e11; // seconds
95 TGeoMaterial *decaymat = mat->DecayMaterial(time);
96 printf("Radioactive material evolution after %g years:\n", time / 3.1536e7);
97 decaymat->Print();
98 // Radioactive mixture
99 TGeoMixture *mix = new TGeoMixture("mix", 2, 7.3);
100 mix->AddElement(el1, 0.35);
101 mix->AddElement(el2, 0.65);
102 printf("___________________________________________________________\n");
103 printf("Radioactive mixture:\n");
104 mix->Print();
105 time = 1000.;
106 decaymat = mix->DecayMaterial(time);
107 printf("Radioactive mixture evolution after %g seconds:\n", time);
108 decaymat->Print();
109 TObjArray *vect = new TObjArray();
110 TCanvas *c1 = new TCanvas("c1", "C14 decay", 800, 600);
111 c1->SetGrid();
112 mat->FillMaterialEvolution(vect);
113 DrawPopulation(vect, c1, 0, 1.4e12);
114 TLatex *tex = new TLatex(8.35e11, 0.564871, "C_{N^{14}_{7}}");
115 tex->SetTextSize(0.0388601);
116 tex->SetLineWidth(2);
117 tex->Draw();
118 tex = new TLatex(3.33e11, 0.0620678, "C_{C^{14}_{6}}");
119 tex->SetTextSize(0.0388601);
120 tex->SetLineWidth(2);
121 tex->Draw();
122 tex = new TLatex(9.4e11, 0.098, "C_{X}=#frac{N_{X}(t)}{N_{0}(t=0)}=\
123 #sum_{j}#alpha_{j}e^{-#lambda_{j}t}");
124 tex->SetTextSize(0.0388601);
125 tex->SetLineWidth(2);
126 tex->Draw();
127 TPaveText *pt = new TPaveText(2.6903e+11, 0.0042727, 1.11791e+12, 0.0325138, "br");
128 pt->SetFillColor(5);
129 pt->SetTextAlign(12);
130 pt->SetTextColor(4);
131 pt->AddText("Time evolution of a population of radionuclides.");
132 pt->AddText("The concentration of a nuclide X represent the ");
133 pt->AddText("ratio between the number of X nuclei and the ");
134 pt->AddText("number of nuclei of the top element of the decay");
135 pt->AddText("from which X derives from at T=0. ");
136 pt->Draw();
137 c1->Modified();
138 vect->Clear();
139 TCanvas *c2 = new TCanvas("c2", "Mixture decay", 1000, 800);
140 c2->SetGrid();
141 mix->FillMaterialEvolution(vect);
142 DrawPopulation(vect, c2, 0.01, 1000., kTRUE);
143 tex = new TLatex(0.019, 0.861, "C_{Ca^{53}_{20}}");
144 tex->SetTextSize(0.0388601);
145 tex->SetTextColor(1);
146 tex->Draw();
147 tex = new TLatex(0.0311, 0.078064, "C_{Sc^{52}_{21}}");
148 tex->SetTextSize(0.0388601);
149 tex->SetTextColor(2);
150 tex->Draw();
151 tex = new TLatex(0.1337, 0.010208, "C_{Ti^{52}_{22}}");
152 tex->SetTextSize(0.0388601);
153 tex->SetTextColor(3);
154 tex->Draw();
155 tex = new TLatex(1.54158, 0.00229644, "C_{V^{52}_{23}}");
156 tex->SetTextSize(0.0388601);
157 tex->SetTextColor(4);
158 tex->Draw();
159 tex = new TLatex(25.0522, 0.00135315, "C_{Cr^{52}_{24}}");
160 tex->SetTextSize(0.0388601);
161 tex->SetTextColor(5);
162 tex->Draw();
163 tex = new TLatex(0.1056, 0.5429, "C_{Sc^{53}_{21}}");
164 tex->SetTextSize(0.0388601);
165 tex->SetTextColor(6);
166 tex->Draw();
167 tex = new TLatex(0.411, 0.1044, "C_{Ti^{53}_{22}}");
168 tex->SetTextSize(0.0388601);
169 tex->SetTextColor(7);
170 tex->Draw();
171 tex = new TLatex(2.93358, 0.0139452, "C_{V^{53}_{23}}");
172 tex->SetTextSize(0.0388601);
173 tex->SetTextColor(8);
174 tex->Draw();
175 tex = new TLatex(10.6235, 0.00440327, "C_{Cr^{53}_{24}}");
176 tex->SetTextSize(0.0388601);
177 tex->SetTextColor(9);
178 tex->Draw();
179 tex = new TLatex(15.6288, 0.782976, "C_{Sr^{78}_{38}}");
180 tex->SetTextSize(0.0388601);
181 tex->SetTextColor(1);
182 tex->Draw();
183 tex = new TLatex(20.2162, 0.141779, "C_{Rb^{78}_{37}}");
184 tex->SetTextSize(0.0388601);
185 tex->SetTextColor(2);
186 tex->Draw();
187 tex = new TLatex(32.4055, 0.0302101, "C_{Kr^{78}_{36}}");
188 tex->SetTextSize(0.0388601);
189 tex->SetTextColor(3);
190 tex->Draw();
191 tex = new TLatex(117., 1.52, "C_{X}=#frac{N_{X}(t)}{N_{0}(t=0)}=#sum_{j}\
192 #alpha_{j}e^{-#lambda_{j}t}");
193 tex->SetTextSize(0.03);
194 tex->SetLineWidth(2);
195 tex->Draw();
196 TArrow *arrow = new TArrow(0.0235313, 0.74106, 0.0385371, 0.115648, 0.02, ">");
197 arrow->SetFillColor(1);
198 arrow->SetFillStyle(1001);
199 arrow->SetLineWidth(2);
200 arrow->SetAngle(30);
201 arrow->Draw();
202 arrow = new TArrow(0.0543138, 0.0586338, 0.136594, 0.0146596, 0.02, ">");
203 arrow->SetFillColor(1);
204 arrow->SetFillStyle(1001);
205 arrow->SetLineWidth(2);
206 arrow->SetAngle(30);
207 arrow->Draw();
208 arrow = new TArrow(0.31528, 0.00722919, 1.29852, 0.00306079, 0.02, ">");
209 arrow->SetFillColor(1);
210 arrow->SetFillStyle(1001);
211 arrow->SetLineWidth(2);
212 arrow->SetAngle(30);
213 arrow->Draw();
214 arrow = new TArrow(4.13457, 0.00201942, 22.5047, 0.00155182, 0.02, ">");
215 arrow->SetFillColor(1);
216 arrow->SetFillStyle(1001);
217 arrow->SetLineWidth(2);
218 arrow->SetAngle(30);
219 arrow->Draw();
220 arrow = new TArrow(0.0543138, 0.761893, 0.0928479, 0.67253, 0.02, ">");
221 arrow->SetFillColor(1);
222 arrow->SetFillStyle(1001);
223 arrow->SetLineWidth(2);
224 arrow->SetAngle(30);
225 arrow->Draw();
226 arrow = new TArrow(0.238566, 0.375717, 0.416662, 0.154727, 0.02, ">");
227 arrow->SetFillColor(1);
228 arrow->SetFillStyle(1001);
229 arrow->SetLineWidth(2);
230 arrow->SetAngle(30);
231 arrow->Draw();
232 arrow = new TArrow(0.653714, 0.074215, 2.41863, 0.0213142, 0.02, ">");
233 arrow->SetFillColor(1);
234 arrow->SetFillStyle(1001);
235 arrow->SetLineWidth(2);
236 arrow->SetAngle(30);
237 arrow->Draw();
238 arrow = new TArrow(5.58256, 0.00953882, 10.6235, 0.00629343, 0.02, ">");
239 arrow->SetFillColor(1);
240 arrow->SetFillStyle(1001);
241 arrow->SetLineWidth(2);
242 arrow->SetAngle(30);
243 arrow->Draw();
244 arrow = new TArrow(22.0271, 0.601935, 22.9926, 0.218812, 0.02, ">");
245 arrow->SetFillColor(1);
246 arrow->SetFillStyle(1001);
247 arrow->SetLineWidth(2);
248 arrow->SetAngle(30);
249 arrow->Draw();
250 arrow = new TArrow(27.2962, 0.102084, 36.8557, 0.045686, 0.02, ">");
251 arrow->SetFillColor(1);
252 arrow->SetFillStyle(1001);
253 arrow->SetLineWidth(2);
254 arrow->SetAngle(30);
255 arrow->Draw();
256}
257
258void DrawPopulation(TObjArray *vect, TCanvas *can, Double_t tmin, Double_t tmax, Bool_t logx)
259{
260 Int_t n = vect->GetEntriesFast();
261 TGeoElementRN *elem;
262 TGeoBatemanSol *sol;
263 can->SetLogy();
264
265 if (logx)
266 can->SetLogx();
267
268 for (Int_t i = 0; i < n; i++) {
269 TGeoElement *el = (TGeoElement *)vect->At(i);
270 if (!el->IsRadioNuclide())
271 continue;
272 TGeoElementRN *elem = (TGeoElementRN *)el;
273 TGeoBatemanSol *sol = elem->Ratio();
274 if (sol) {
275 sol->SetLineColor(1 + (i % 9));
276 sol->SetLineWidth(2);
277 if (tmax > 0.)
278 sol->SetRange(tmin, tmax);
279 if (i == 0) {
280 sol->Draw();
281 TF1 *func = (TF1 *)can->FindObject(Form("conc%s", sol->GetElement()->GetName()));
282 if (func) {
283 if (!strcmp(can->GetName(), "c1"))
284 func->SetTitle("Concentration of C14 derived elements;time[s];Ni/N0(C14)");
285 else
286 func->SetTitle("Concentration of elements derived from mixture Ca53+Sr78;\
287 time[s];Ni/N0(Ca53)");
288 }
289 } else
290 sol->Draw("SAME");
291 }
292 }
293}
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
Draw all kinds of Arrows.
Definition TArrow.h:29
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:42
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:44
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:47
The Canvas class.
Definition TCanvas.h:23
1-Dim function class
Definition TF1.h:233
void SetTitle(const char *title="") override
Set function title if title has the form "fffffff;xxxx;yyyy", it is assumed that the function title i...
Definition TF1.cxx:3558
void SetRange(Double_t tmin=0., Double_t tmax=0.)
void Draw(Option_t *option="") override
Draw the solution of Bateman equation versus time.
TGeoElementRN * GetElement() const
Class representing a radionuclidevoid TGeoManager::SetDefaultRootUnits() { if ( fgDefaultUnits == kRo...
TGeoBatemanSol * Ratio() const
Table of elements.
TGeoElementRN * GetElementRN(Int_t ENDFcode) const
Retrieve a radionuclide by ENDF code.
Base class for chemical elements.
Definition TGeoElement.h:36
virtual Bool_t IsRadioNuclide() const
Definition TGeoElement.h:82
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
TGeoElementTable * GetElementTable()
Returns material table. Creates it if not existing.
Base class describing materials.
virtual TGeoMaterial * DecayMaterial(Double_t time, Double_t precision=0.001)
Create the material representing the decay product of this material at a given time.
virtual void FillMaterialEvolution(TObjArray *population, Double_t precision=0.001)
Fills a user array with all the elements deriving from the possible decay of the top element composin...
void Print(const Option_t *option="") const override
print characteristics of this material
Mixtures of elements.
void AddElement(Double_t a, Double_t z, Double_t weight)
add an element to the mixture using fraction by weight Check if the element is already defined
TGeoMaterial * DecayMaterial(Double_t time, Double_t precision=0.001) override
Create the mixture representing the decay product of this material at a given time.
void FillMaterialEvolution(TObjArray *population, Double_t precision=0.001) override
Fills a user array with all the elements deriving from the possible decay of the top elements composi...
void Print(const Option_t *option="") const override
print characteristics of this material
To draw Mathematical Formula.
Definition TLatex.h:18
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
void Clear(Option_t *option="") override
Remove all objects from the array.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:6100
TObject * FindObject(const char *name) const override
Search if object named name is inside this pad or in pads inside this pad.
Definition TPad.cxx:2700
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:6086
const char * GetName() const override
Returns name of object.
Definition TPad.h:260
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
TPaveText * pt
return c1
Definition legend1.C:41
const Int_t n
Definition legend1.C:16
return c2
Definition legend2.C:14