KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVIsoscaling.cpp
Go to the documentation of this file.
1 #include "KVIsoscaling.h"
2 #include "KVString.h"
3 
4 #include "TGraphErrors.h"
5 #include "TString.h"
6 #include "TObjArray.h"
7 #include "TObjString.h"
8 #include "TMath.h"
9 #include "TF1.h"
10 #include "TFile.h"
11 #include "TAxis.h"
12 
13 #include <fstream>
14 
16 
17 // BEGIN_HTML <!--
19 /* -->
20 <h2>KVIsoscaling</h2>
21 <h4>KVClass</h4>
22 <!-- */
23 // --> END_HTML
25 
26 
27 
28 //____________________________________________________________________________//
29 
30 
38 Bool_t KVIsoscaling::ReadYieldsFile(Int_t system, const Char_t* file_path)
39 {
40  // Read and save yields from a user's file
41  // Construct the corresponding vectors
42  // Input file format is :
43  // Z A Yield Yield_err
44  // \param[in] system index
45  // \param[in] path for ASCII file
46 
47  Bool_t ok = kTRUE;
48 
49  // --- Check that the system was not set before ---
50  if (fnl_sys_.Contains(system)) {
51  ok = kFALSE;
52  Warning("ReadYieldsFile", "system %d already set, %s will be ignored", system, file_path);
53  }
54  else if (fdebug_) Info("ReadYieldsFile", "===== Starting reading system %d =====\n", system);
55 
56  // --- Open the file for a new system ---
57  std::ifstream my_file;
58  my_file.open(file_path);
59 
60  if (ok && my_file.is_open()) {
61  // --- Init the buffers ---
62  Int_t oldZ = -666;
63  KVNumberList my_a_nl; //buffer number list of A for a given (system, Z)
64  std::vector<Int_t> my_a_vec; //buffer list of A (for the current (system, Z))
65  std::vector<Float_t> my_yield_vec; //buffer list of Yields (for the current (system, Z))
66  std::vector<Float_t> my_yield_err_vec; //buffer list of Yields (for the current (system, Z))
67 
68  // --- Init the variables ---
69  std::vector<Int_t> my_z_vec; //list of Z for the current system
70  std::vector< std::vector<Int_t> > my_z_a_vec; //list of A for each Z of the current system
71  std::vector< std::vector<Float_t> > my_z_yield_vec; //list of Yields for each (A,Z) of the current system
72  std::vector< std::vector<Float_t> > my_z_yielderr_vec; //list of Yield errors for each (A,Z) of the current system
73 
74  KVNumberList* my_z_nl = new KVNumberList(); //number list of Z for the current system
75  KVList* my_nla_list = new KVList(); //list of all number list of A for each (system, Z)
76 
77  // --- Read the file ---
78  Int_t nline = 0;
79  std::string line;
80  while (getline(my_file, line)) {
81  TString my_str(line);
82 
83  // --- Ignore comments ---
84  if (my_str.BeginsWith("#")) continue;
85 
86  // --- Extract infos ---
87  TObjArray* my_str_array = my_str.Tokenize(" \t,;");
88 
89  //debug
90  /*if(fdebug_){
91  Int_t nn = my_str_array->GetEntries();
92  for(Int_t jj=0; jj<nn; jj++){
93  printf("Tokenize[%d] = %s\n", jj, (((TObjString *) my_str_array->At(jj))->String()).Data());
94  }
95  }
96  */
97 
98  Int_t zz = ((TObjString*) my_str_array->At(0))->String().Atoi();
99  Int_t aa = ((TObjString*) my_str_array->At(1))->String().Atoi();
100  Float_t yy = ((TObjString*) my_str_array->At(2))->String().Atof();
101  Float_t yy_err = ((TObjString*) my_str_array->At(3))->String().Atof();
102 
103  //--- Check of the charge Z ---
104  // If new Z value :
105  // - Add the new Z in the list of Z (for the current system)
106  // - Save the current mass vector (for the former Z and the current system)
107  // - Clear the mass buffer vector
108  // - Reset the 'actualA' buffer
109  if (zz != oldZ) {
110  // - Save the current Z -
111  my_z_vec.push_back(zz);
112  my_z_nl->Add(zz);
113 
114  //debug
115  if (fdebug_) Info("ReadYieldsFile", "=== New Z=%d ===", zz);
116 
117  // - Save the list of A for the former Z (except at initialization) -
118  if (oldZ != -666) {
119  my_z_a_vec.push_back(my_a_vec);
120  my_z_yield_vec.push_back(my_yield_vec);
121  my_z_yielderr_vec.push_back(my_yield_err_vec);
122  my_nla_list->Add(new KVNumberList(my_a_nl.GetList()));
123 
124  if (fdebug_) {
125  KVNumberList* nl = (KVNumberList*) my_nla_list->Last();
126  printf("Saving the former Z(=%d) associated A list=(%s)\n", oldZ, nl->GetList());
127  }
128  }
129 
130  //- Reset -
131  my_a_vec.clear();
132  my_yield_vec.clear();
133  my_yield_err_vec.clear();
134  my_a_nl.Clear();
135  }// end of new Z
136 
137  // --- In any case, add data ---
138  // - We add the mass to the actual A list (for the current Z and system)
139  // - We add the yield to the actual Y(system, A, Z) list
140  // - We add the yield_err to the actual Y_err(suystem, A, Z) list
141  my_a_vec.push_back(aa);
142  my_yield_vec.push_back(yy);
143  my_yield_err_vec.push_back(yy_err);
144  my_a_nl.Add(aa);
145 
146  // --- Debug ---
147  if (fdebug_) printf("(line=%d) (zz=%d, aa=%d, yy=%lf, yy_err=%lf)\n", nline, zz, aa, yy, yy_err);
148 
149  //- Update the Z buffer -
150  oldZ = zz;
151 
152  nline++;
153  }//end getline
154 
155  // - Save the last values -
156  my_nla_list->Add(new KVNumberList(my_a_nl.GetList()));
157  my_z_a_vec.push_back(my_a_vec);
158  my_z_yield_vec.push_back(my_yield_vec);
159  my_z_yielderr_vec.push_back(my_yield_err_vec);
160  if (fdebug_) {
161  KVNumberList* nl = (KVNumberList*) my_nla_list->Last();
162  printf("Saving the former Z(=%d) associated A list=(%s)\n", oldZ, nl->GetList());
163  }
164 
165  // --- Fill the global vectors ---
166  fvec_sys_.push_back(system);
167  fvec_sys_z_.push_back(my_z_vec);
168  fvec_sys_z_a_.push_back(my_z_a_vec);
169  fvec_sys_z_yields_.push_back(my_z_yield_vec);
170  fvec_sys_z_yields_err_.push_back(my_z_yielderr_vec);
171 
172  // --- Fill the global number lists ---
173  flist_z_.Add(my_z_nl);
174  flist_a_.Add(my_nla_list);
175 
176  // --- Add the system to the number list --
177  fnl_sys_.Add(system);
178 
179  // --- Close file ---
180  my_file.close();
181 
182  //debug
183  Info("ReadYieldsFile", "[sys=%d] file %s closed, masses and yields saved at position %d\n", system, file_path, int(fvec_sys_.size() - 1));
184 
185  }//end file.is_opened
186 
187  // --- Handle the errors ---
188  else {
189  if (!ok) Error("ReadYieldsFile", "!!! System=%d already set !!!", system);
190  if (!my_file.is_open()) {
191  Error("ReadYieldsFile", "!!! Can't open file '%s' !!!", file_path);
192  ok = kFALSE;
193  }
194  }
195 
196  // --- Push back of meanA vectors for the given system ---
197  // (It allows to keep the same ordering in systems for the <A(Z)> and <A(Z)>_err vectors )
198  std::vector<Float_t> my_dumb_vec;
199  fvec_sys_z_meanA_.push_back(my_dumb_vec);
200  fvec_sys_z_meanerrA_.push_back(my_dumb_vec);
201 
202  // --- Apply a gaussian fit to the provided yields ---
203  BuildGaussianPlots(system);
204 
205  return ok;
206 }
207 
208 
209 
214 
216 {
217  // Method to build the plots used to check the gaussian approximation
218  // Also compute the average masses for each charge <A(Z)>
219  // \param[in] system index
220 
221  if (fdebug_) Info("BuildGaussianPlots", "====== STARTING BUILDING GAUSSIAN PLOTS FOR SYSTEM %d ======", system);
222 
223  // ---- Check that system is OK ---
224  if (fnl_sys_.Contains(system)) {
225 
226  // - vector of the mean values -
227  std::vector<Float_t> my_meanA_vec;
228  std::vector<Float_t> my_meanAerr_vec;
229 
230  // --- Iterate over existing Z ---
231  Int_t pos = GetSystemPos(system);
232 
233  KVNumberList* nl_zz = GetZNumberList(system);
234  nl_zz->Begin();
235  while (!nl_zz->End()) {
236  Int_t next_zz = nl_zz->Next();
237 
238  // - create the graphs -
239  TGraphErrors* gr = new TGraphErrors();
240  gr->SetName(Form("gr_yields_%d_vs_N_%d", system, next_zz));
241  gr->GetXaxis()->SetTitle("N");
242  gr->GetYaxis()->SetTitle("Y1");
243  gr->SetMarkerStyle(20);
245 
246  TGraphErrors* grln = new TGraphErrors();
247  grln->SetName(Form("gr_lnyields_%d_vs_N_%d", system, next_zz));
248  grln->GetXaxis()->SetTitle("N");
249  grln->GetYaxis()->SetTitle("Ln(Y1)");
250  grln->SetMarkerStyle(20);
251  fhlist_yields_.Add(grln);
252 
253  if (fdebug_) Info("BuildGaussianPlots", "Graph %s created", gr->GetName());
254 
255  Int_t pos_zz = GetZPos(system, next_zz);
256  std::vector<Int_t> aa_vec = GetAVectorFromPos(pos, pos_zz);
257  std::vector<Float_t> yy_vec = GetYieldVectorFromPos(pos, pos_zz);
258  std::vector<Float_t> yyerr_vec = GetYieldErrVectorFromPos(pos, pos_zz);
259 
260  KVNumberList* nl_aa = GetANumberList(system, next_zz);
261  Int_t npoint = 0;
262  nl_aa->Begin();
263  while (!nl_aa->End()) {
264  Int_t next_aa = nl_aa->Next();
265  Int_t nn = next_aa - next_zz;
266  Int_t aa_pos = GetAPos(system, next_zz, next_aa);
267 
268  Float_t yield = yy_vec.at(aa_pos);
269  Float_t yielderr = yyerr_vec.at(aa_pos);
270 
271  gr->SetPoint(npoint, nn, yield);
272  gr->SetPointError(npoint, 0, yielderr);
273 
274  grln->SetPoint(npoint, nn, TMath::Log(yield));
275  grln->SetPointError(npoint, 0, TMath::Abs(yielderr / yield));
276 
277  npoint++;
278 
279  if (fdebug_) Info("BuildGaussianPlots", "[Z=%d, N=%d, A=%d] Yield(%d)=%lf +/- %lf", next_zz, next_aa - next_zz, next_aa, system, yield, yielderr);
280  }//end a iter
281 
282  // --- Apply individual gaussian fit and save the results ---
283  TF1* gaus = new TF1(Form("gaus_yields_%d_vs_N_%d", system, next_zz), "gaus(0)", 0, 60);
284  gr->Fit(Form("gaus_yields_%d_vs_N_%d", system, next_zz), "Q");
285  fhlist_yields_.Add(gaus);
286 
287  // - Add the average <A(Z)> values -
288  my_meanA_vec.push_back(gaus->GetParameter(1) + next_zz);
289  my_meanAerr_vec.push_back(gaus->GetParError(1));
290 
291  }//end Z-iter
292 
293  // --- Save the <A(Z)> vectors ---
294  Int_t syspos = GetSystemPos(system);
295  if (syspos > -1) {
296  fvec_sys_z_meanA_.at(syspos) = my_meanA_vec;
297  fvec_sys_z_meanerrA_.at(syspos) = my_meanAerr_vec;
298  }
299  }//end system ok
300 
301  if (fdebug_) Info("BuildGaussianPlots", "====== END BUILDING GAUSSIAN PLOTS FOR SYSTEM %d ======", system);
302 }
303 
304 
305 
315 
317 {
318  // Method to test the tolerance threshold of the gaussian approximation for a fixed charge \f$Z\f$.
319  // Assuming a tolerance \f$tol\f$ set by the user and an average mass \f$\langle A(Z)\rangle\f$ with a standard deviation \f$ rms(Z) \f$,
320  // the region of experimental points will be limited to \f$ \langle A(Z)\rangle \pm tol \cdot rms(Z) \f$.
321  // This method allows to test and plot the results of various tolerance thresholds.
322  // \param[in] system1 n-deficient system index
323  // \param[in] system2 n-rich system index
324  // \param[in] zz fixed charge for the isotopic yields to be tested
325  // \param[in] tol threshold to be tested
326 
327  TGraphErrors* gr_sys1_all = (TGraphErrors*) fhlist_yields_.FindObject(Form("gr_yields_%d_vs_N_%d", system1, zz));
328  TGraphErrors* gr_sys2_all = (TGraphErrors*) fhlist_yields_.FindObject(Form("gr_yields_%d_vs_N_%d", system2, zz));
329  TF1* gaus1 = (TF1*) fhlist_yields_.FindObject(Form("gaus_yields_%d_vs_N_%d", system1, zz));
330  TF1* gaus2 = (TF1*) fhlist_yields_.FindObject(Form("gaus_yields_%d_vs_N_%d", system2, zz));
331 
332  // --- Build the graphs with thresholds and ratios of the yields ---
333  // Use only the A (N) shared between the 2 systems
334  TGraphErrors* gr_sys1_tol = new TGraphErrors();
335  gr_sys1_tol->SetName(Form("gr_yields_%d_vs_N_%d_tol", system1, zz));
336  TGraphErrors* gr_sys2_tol = new TGraphErrors();
337  gr_sys2_tol->SetName(Form("gr_yields_%d_vs_N_%d_tol", system2, zz));
338 
339  TGraphErrors* gr_ratio_all = new TGraphErrors();
340  gr_ratio_all->SetName(Form("gr_ratio_all_%d_%d_%d", system1, system2, zz));
341  TGraphErrors* gr_ratio_tol = new TGraphErrors();
342  gr_ratio_tol->SetName(Form("gr_ratio_tol_%d_%d_%d", system1, system2, zz));
343 
344  // - First find the position in vectors corresponding to our two systems -
345  Int_t pos1 = GetSystemPos(system1);
346  Int_t pos2 = GetSystemPos(system2);
347  // - Then find charge pos. in vector and associated values -
348  Int_t pos_zz1 = GetZPos(system1, zz);
349  Int_t pos_zz2 = GetZPos(system2, zz);
350 
351  std::vector<Int_t> aa1_vec = GetAVectorFromPos(pos1, pos_zz1);
352  std::vector<Int_t> aa2_vec = GetAVectorFromPos(pos2, pos_zz2);
353  std::vector<Float_t> yy1_vec = GetYieldVectorFromPos(pos1, pos_zz1);
354  std::vector<Float_t> yy2_vec = GetYieldVectorFromPos(pos2, pos_zz2);
355  std::vector<Float_t> yyerr1_vec = GetYieldErrVectorFromPos(pos1, pos_zz1);
356  std::vector<Float_t> yyerr2_vec = GetYieldErrVectorFromPos(pos2, pos_zz2);
357 
358  // - Extract all A shared between the 2 systems -
359  KVNumberList nl_inter_a = GetSharedANumberList(system1, system2, zz);
360 
361  if (fdebug_) Info("TestRMSTolerance", "=== Starting iteration over shared A list for Z=%d ===", zz);
362 
363  // - Build graphs with tolerance applied -
364  Int_t npoint_all = 0;
365  Int_t np1 = 0;
366  Int_t np2 = 0;
367  Int_t npoint_tol = 0;
368  nl_inter_a.Begin();
369  while (!nl_inter_a.End()) {
370  Int_t next_aa = nl_inter_a.Next();
371  Int_t nn = next_aa - zz;
372  Int_t aa1_pos = GetAPos(system1, zz, next_aa);
373  Int_t aa2_pos = GetAPos(system2, zz, next_aa);
374 
375  Float_t yield1 = yy1_vec.at(aa1_pos);
376  Float_t yield2 = yy2_vec.at(aa2_pos);
377 
378  Float_t yielderr1 = yyerr1_vec.at(aa1_pos);
379  Float_t yielderr2 = yyerr2_vec.at(aa2_pos);
380 
381  Float_t ratio = yield2 / yield1;
382  Float_t ratio_err = TMath::Sqrt(TMath::Power(yielderr2 / yield1, 2.) + TMath::Power(yielderr1 * yield2 / yield1 / yield1, 2.));
383 
384  // - Fill the graph of the ratios with all points -
385  gr_ratio_all->SetPoint(npoint_all, nn, ratio);
386  gr_ratio_all->SetPointError(npoint_all, 0, ratio_err);
387  npoint_all++;
388 
389  // - Apply tolerance cut for the gaussian approximation -
390  Double_t diff1 = TMath::Abs(gaus1->GetParameter(1) - nn);
391  Double_t diff2 = TMath::Abs(gaus2->GetParameter(1) - nn);
392 
393  if (diff1 < tol * gaus1->GetParameter(2)) {
394  gr_sys1_tol->SetPoint(np1, nn, yield1);
395  gr_sys1_tol->SetPointError(np1, 0., yielderr1);
396  np1++;
397  }
398 
399  if (diff2 < tol * gaus2->GetParameter(2)) {
400  gr_sys2_tol->SetPoint(np2, nn, yield2);
401  gr_sys2_tol->SetPointError(np2, 0., yielderr2);
402  np2++;
403  }
404 
405  if ((diff1 < tol * gaus1->GetParameter(2)) && (diff2 < tol * gaus2->GetParameter(2))) {
406  gr_ratio_tol->SetPoint(npoint_tol, nn, ratio);
407  gr_ratio_tol->SetPointError(npoint_tol, 0, ratio_err);
408  npoint_tol++;
409  }
410  }//end shared A iter
411 
412  // --- Build ratio of the gaussian fits ---
413  TF1* gaus_ratio = new TF1(Form("gaus_ratio_%d_%d_%d", system1, system2, zz), "gaus(0)/(gaus(3))", 0, 60);
414  gaus_ratio->SetLineColor(kBlack);
415  gaus_ratio->SetParameters(gaus2->GetParameter(0), gaus2->GetParameter(1), gaus2->GetParameter(2), gaus1->GetParameter(0), gaus1->GetParameter(1), gaus1->GetParameter(2));
416 
417  // --- Set some draw opt ---
418  gr_sys1_all->SetMarkerColor(kRed);
419  gr_sys1_all->SetMarkerStyle(24);
420  gr_sys2_all->SetMarkerColor(kBlue);
421  gr_sys2_all->SetMarkerStyle(26);
422  gr_ratio_all->SetMarkerColor(kBlack);
423  gr_ratio_all->SetMarkerStyle(25);
424 
425  gr_sys1_tol->SetMarkerColor(kRed);
426  gr_sys1_tol->SetMarkerStyle(20);
427  gr_sys2_tol->SetMarkerColor(kBlue);
428  gr_sys2_tol->SetMarkerStyle(22);
429  gr_ratio_tol->SetMarkerColor(kBlack);
430  gr_ratio_tol->SetMarkerStyle(21);
431 
432  gaus1->SetLineColor(kRed);
433  gaus2->SetLineColor(kBlue);
434  gaus_ratio->SetLineColor(kBlack);
435 
436  // --- Draw ---
437  gr_ratio_all->Draw("ap");
438  //gPad->SetLogy();
439  gr_sys1_all->Draw("p");
440  gr_sys2_all->Draw("p");
441  gaus1->Draw("same");
442  gaus2->Draw("same");
443  gaus_ratio->Draw("same");
444  gr_sys1_tol->Draw("p");
445  gr_sys2_tol->Draw("p");
446  gr_ratio_tol->Draw("p");
447 }
448 
449 
450 
459 
461 {
462  // Method to compute the Ln of the ratio 'LnR21' of the yields 'Yi(A,Z)' of 2 asymetric reactions noted '(2)' and '(1)'
463  // (projectiles and targets of reactions (2) and (1) only differ in their respective number of neutrons)
464  // We are interested in extracting the alpha isoscaling parameter, thus we want to draw LnR21 as a function of N for a given Z
465 
466  // Added 27/10/2021 : addition of "np" = number of points (isotopes) used to build the plots
467  // if np=-1 use all the isotopes (as before)
468 
469  // [in] system1 n-deficient system index
470  // [in] system2 n-rich system index
471 
472  if (fdebug_) Info("BuildLnR21vsNPlots", "====== STARTING BUILDING PLOTS FOR %d/%d ======", system1, system2);
473 
474  // --- Check the systems ---
475  if (system1 != system2 && fnl_sys_.Contains(system1) && fnl_sys_.Contains(system2)) {
476  // --- Create a vector of the ratios for each Z available ---
477  // - First find the position in vectors corresponding to our two systems -
478  Int_t pos1 = GetSystemPos(system1);
479  Int_t pos2 = GetSystemPos(system2);
480 
481  // - Then create the corresponding number list of shared Z for the 2 systems
482  KVNumberList nl_inter = GetSharedZNumberList(system1, system2);
483 
484  // - Debug -
485  if (fdebug_) {
486  Info("BuildLnR21vsNPlots", "system1=%d is at position %d | system2=%d is at position %d", system1, pos1, system2, pos2);
487  printf("The list of shared Z is '%s'\n", nl_inter.GetList());
488  }
489 
490  // - Now we have the list of shared Z to use -
491  // We find the corresponding masses, yields and yields errors positions in vectors
492 
493  Int_t ip = 0;
494  nl_inter.Begin();
495  while (!nl_inter.End()) {
496  Int_t next_zz = nl_inter.Next();
497 
498  // - Create the associated graph for ratios -
499  TGraphErrors* gr_all = new TGraphErrors();
500  gr_all->SetName(Form("gr_lnR21_vs_N_%d_%d_%d_all", system1, system2, next_zz));
501  gr_all->GetXaxis()->SetTitle("N");
502  gr_all->GetYaxis()->SetTitle("ln(R21)");
503  gr_all->SetMarkerStyle(20);
504  gr_all->SetMarkerColor(next_zz % 9 + 1);
505  fhlist_lnR21N_all_.Add(gr_all);
506 
507  TGraphErrors* gr = new TGraphErrors();
508  gr->SetName(Form("gr_lnR21_vs_N_%d_%d_%d", system1, system2, next_zz));
509  gr->GetXaxis()->SetTitle("N");
510  gr->GetYaxis()->SetTitle("ln(R21)");
511  gr->SetMarkerStyle(20);
512  gr->SetMarkerColor(next_zz % 9 + 1);
514 
515  if (fdebug_) Info("BuildLnR21vsNPlots", "Graph %s created", gr->GetName());
516 
517  // - Find individual fits of the yields -
518  TF1* gaus_np = (TF1*) fhlist_yields_.FindObject(Form("gaus_yields_%d_vs_N_%d", system1, next_zz));
519  TF1* gaus_nr = (TF1*) fhlist_yields_.FindObject(Form("gaus_yields_%d_vs_N_%d", system2, next_zz));
520  Double_t par0 = gaus_nr->GetParameter(0);
521  Double_t par0_err = gaus_nr->GetParError(0);
522  Double_t par1 = gaus_nr->GetParameter(1);
523  Double_t par1_err = gaus_nr->GetParError(1);
524  Double_t par2 = gaus_nr->GetParameter(2);
525  Double_t par2_err = gaus_nr->GetParError(2);
526  Double_t par3 = gaus_np->GetParameter(0);
527  Double_t par3_err = gaus_np->GetParError(0);
528  Double_t par4 = gaus_np->GetParameter(1);
529  Double_t par4_err = gaus_np->GetParError(1);
530  Double_t par5 = gaus_np->GetParameter(2);
531  Double_t par5_err = gaus_np->GetParError(2);
532 
533  // - Compute gauss2/gauss1 function -
534  TF1* gaus_ratio = new TF1(Form("gaus_ratio_%d_%d_%d", system1, system2, next_zz), "gaus(0)/(gaus(3))", 0, 60);
535  gaus_ratio->SetLineColor(kBlack);
536  gaus_ratio->SetParameters(par0, par1, par2, par3, par4, par5);
537  fhlist_yields_.Add(gaus_ratio);
538 
539  TF1* gaus_ratio_ln = new TF1(Form("gaus_ratio_ln_%d_%d_%d", system1, system2, next_zz), "TMath::Log(gaus(0)/(gaus(3)))", 0, 60);
540  gaus_ratio_ln->SetLineColor(kBlack);
541  gaus_ratio_ln->SetParameters(par0, par1, par2, par3, par4, par5);
542  fhlist_yields_.Add(gaus_ratio_ln);
543 
544  // - Find charge pos. in vector and associated values -
545  Int_t pos_zz1 = GetZPos(system1, next_zz);
546  Int_t pos_zz2 = GetZPos(system2, next_zz);
547 
548  std::vector<Int_t> aa1_vec = GetAVectorFromPos(pos1, pos_zz1);
549  std::vector<Int_t> aa2_vec = GetAVectorFromPos(pos2, pos_zz2);
550 
551  std::vector<Float_t> yy1_vec = GetYieldVectorFromPos(pos1, pos_zz1);
552  std::vector<Float_t> yy2_vec = GetYieldVectorFromPos(pos2, pos_zz2);
553 
554  std::vector<Float_t> yyerr1_vec = GetYieldErrVectorFromPos(pos1, pos_zz1);
555  std::vector<Float_t> yyerr2_vec = GetYieldErrVectorFromPos(pos2, pos_zz2);
556 
557  // --- Compute ln(R21) ---
558  // - Extract all A shared between the 2 systems -
559  KVNumberList nl_inter_a = GetSharedANumberList(system1, system2, next_zz);
560 
561  if (fdebug_) Info("BuildLnR21vsNPlots", "=== Starting iteration over shared A list for Z=%d ===", next_zz);
562 
563  Int_t npoint = 0;
564  Int_t npoint_all = 0;
565  nl_inter_a.Begin();
566  while (!nl_inter_a.End()) {
567  Int_t next_aa = nl_inter_a.Next();
568  Int_t nn = next_aa - next_zz;
569  Int_t aa1_pos = GetAPos(system1, next_zz, next_aa);
570  Int_t aa2_pos = GetAPos(system2, next_zz, next_aa);
571 
572  Float_t yield1 = yy1_vec.at(aa1_pos);
573  Float_t yield2 = yy2_vec.at(aa2_pos);
574 
575  Float_t lnr21 = TMath::Log(yield2 / yield1);
576 
577  Float_t yielderr1 = yyerr1_vec.at(aa1_pos);
578  Float_t yielderr2 = yyerr2_vec.at(aa2_pos);
579  Float_t err = TMath::Sqrt(TMath::Power(yielderr2 / yield2, 2.) + TMath::Power(yielderr1 / yield1, 2.));
580  //Float_t err = TMath::Abs(yielderr2/yield2) + TMath::Abs(yielderr1/yield1);
581 
582  // --- Fill the graph with all points ---
583  gr_all->SetPoint(npoint_all, nn, lnr21);
584  gr_all->SetPointError(npoint_all, 0, err);
585  npoint_all++;
586 
587  // --- Apply tolerance cut for the gaussian approximation ---
588  Double_t diff1 = TMath::Abs(par1 - nn);
589  Double_t diff2 = TMath::Abs(par4 - nn);
590  if (diff1 < ftol_ * par2 && diff2 < ftol_ * par5) {
591  gr->SetPoint(npoint, nn, lnr21);
592  gr->SetPointError(npoint, 0, err);
593  npoint++;
594  }
595  else if (fdebug_) {
596  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) - ",
597  next_zz, next_aa - next_zz, next_aa, ftol_ * par2, diff1, ftol_ * par5, diff2, par1, par2, par4, par5);
598  }
599  if (fdebug_) Info("BuildLnR21vsNPlots", "[Z=%d, N=%d, A=%d] Yield1(%d)=%lf, Yield2(%d)=%lf", next_zz, next_aa - next_zz, next_aa, system1, yield1, system2, yield2);
600  }
601 
602  ip++;
603  }//end z list iter
604 
605  fvec_iso_pairs_.push_back(std::make_pair(system1, system2));
606 
607  if (fdebug_) Info("BuildLnR21vsNPlots", "====== END OF BUILDING PLOTS FOR %d/%d ======", system1, system2);
608 
609  }//end of systems OK
610  else {
611  Error("BuildLnR21Plots", "!!! Something is wrong in the input systems !!!");
612  }
613 
614  return;
615 }
616 
617 
618 
625 
626 void KVIsoscaling::FitLnR21vsNPlots(Int_t system1, Int_t system2, Option_t* option, Option_t* gooption)
627 {
628  // This method apply the fit to extract alpha isoscaling parameters for each charge
629  // \param[in] system1 n-deficient system index
630  // \param[in] system2 n-rich system index
631  // \param[in] option fit options
632  // \param[in] gooption graphic fit options
633 
634  if (fdebug_) Info("FitLnR21vsNPlots", "====== STARTING FITS FOR %d/%d ======", system1, system2);
635 
636  TGraphErrors* gr = NULL;
637  TF1* func = NULL;
638 
639  Int_t ip = 0;
640  TIter it(&fhlist_lnR21N_);
641  while ((gr = (TGraphErrors*) it.Next())) {
642  //Tokenize
643  KVString my_str(gr->GetName());
644  TObjArray* my_str_array = my_str.Tokenize("_"); //gr_lnR21_vs_N_%d_%d_%d
645 
646  Int_t sys1 = ((TObjString*) my_str_array->At(4))->String().Atoi();
647  Int_t sys2 = ((TObjString*) my_str_array->At(5))->String().Atoi();
648  Int_t zz = ((TObjString*) my_str_array->At(6))->String().Atoi();
649 
650  if (sys1 == system1 && sys2 == system2) {
651  KVNumberList nl = GetSharedANumberList(sys1, sys2, zz);
652  Int_t nmin = nl.First() - zz - 2;
653  Int_t nmax = nl.Last() - zz + 2;
654  func = new TF1(Form("func_%d_%d_%d", system1, system2, zz), "pol1", float(nmin), float(nmax));
655  func->SetLineColor(zz % 9 + 1);
656 
657  for (Int_t ii = 0; ii < 10; ii++) gr->Fit(func, option, gooption, float(nmin + 2), float(nmax - 2));
658 
659  fhlist_fit_.Add(func);
660 
661  ip++;
662  }
663  }
664 
665  if (fdebug_) Info("BuildLnR21vsNPlots", "====== END OF FITS FOR %d/%d ======", system1, system2);
666 }
667 
668 
669 
674 
676 {
677  // This method allows to draw the results of LnR21 vs N linear fits for the given system1/system2 combination
678  // \param[in] system1 n-deficient system index
679  // \param[in] system2 n-rich system index
680 
681  TMultiGraph* mgr = new TMultiGraph();
682 
683  TGraphErrors* gr = NULL;
684  TIter it0(&fhlist_lnR21N_);
685  while ((gr = (TGraphErrors*) it0.Next())) {
686  //Tokenize
687  KVString my_str(gr->GetName());
688  TObjArray* my_str_array = my_str.Tokenize("_"); //gr_lnR21_vs_N_%d_%d_%d
689 
690  Int_t sys1 = ((TObjString*) my_str_array->At(4))->String().Atoi();
691  Int_t sys2 = ((TObjString*) my_str_array->At(5))->String().Atoi();
692  Int_t zz = ((TObjString*) my_str_array->At(6))->String().Atoi();
693 
694  if (sys1 == system1 && sys2 == system2) {
695  mgr->Add(gr);
696  }
697  }
698 
699  mgr->Draw("ap");
700  mgr->GetXaxis()->SetTitle("N");
701  mgr->GetYaxis()->SetTitle("ln(R21)");
702 
703  TF1* func = NULL;
704  TIter it1(&fhlist_fit_);
705  while ((func = (TF1*) it1.Next())) {
706  //Tokenize
707  KVString my_str(func->GetName());
708  TObjArray* my_str_array = my_str.Tokenize("_"); //func_%d_%d_%d
709 
710  Int_t sys1 = ((TObjString*) my_str_array->At(1))->String().Atoi();
711  Int_t sys2 = ((TObjString*) my_str_array->At(2))->String().Atoi();
712  Int_t zz = ((TObjString*) my_str_array->At(3))->String().Atoi();
713 
714  if (sys1 == system1 && sys2 == system2) func->Draw("same");
715  }
716 }
717 
718 
719 
727 
728 void KVIsoscaling::BuildAlphaPlot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw)
729 {
730  // This method allows to create the alpha vs Z plots for a given system1/system2 combination
731  // \param[in] system1 n-deficient system index
732  // \param[in] system2 n-rich system index
733  // \param[in] mcolor color to use for drawing
734  // \param[in] mstyle style to use for drawing
735  // \param[in] draw =kTRUE if we want to plot the result
736 
737  if (fdebug_) Info("BuildAlphaPlot", "====== STARTING BUILDING ALPHA PLOTS FOR %d/%d ======", system1, system2);
738 
739  // Compute then plot Csym/T as a function of Z for the given system1/system2 combination
740  TGraphErrors* gr = new TGraphErrors();
741  gr->SetName(Form("Alpha_%d_%d", system1, system2));
742  gr->SetMarkerStyle(20);
743  gr->GetXaxis()->SetTitle("Z");
744  gr->GetYaxis()->SetTitle("#alpha");
745  gr->SetMarkerStyle(mstyle);
746  gr->SetMarkerColor(mcolor);
747 
748  Int_t np = 0;
749  TF1* func = NULL;
750  TIter it1(&fhlist_fit_);
751  while ((func = (TF1*) it1.Next())) {
752  //Tokenize
753  KVString my_str(func->GetName());
754  TObjArray* my_str_array = my_str.Tokenize("_"); //func_%d_%d_%d
755 
756  Int_t sys1 = ((TObjString*) my_str_array->At(1))->String().Atoi();
757  Int_t sys2 = ((TObjString*) my_str_array->At(2))->String().Atoi();
758  Int_t zz = ((TObjString*) my_str_array->At(3))->String().Atoi();
759 
760  if (sys1 == system1 && sys2 == system2) {
761  // --- Get the corresponding Csym/T ---
762  Float_t alpha = -666.;
763  Float_t alpha_err = -666.;
764  Bool_t is_ok = GetAlpha(system1, system2, zz, alpha, alpha_err);
765 
766  if (is_ok) {
767  gr->SetPoint(np, zz, alpha);
768  gr->SetPointError(np, 0, alpha_err);
769 
770  np++;
771  }
772  }
773  }//end iter
774 
776 
777  if (draw) gr->Draw("ap");
778 
779  if (fdebug_) Info("BuildAlphaPlot", "====== END BUILDING ALPHA PLOTS FOR %d/%d ======", system1, system2);
780 }
781 
782 
783 
791 
792 void KVIsoscaling::BuildDeltaZA2Plot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw)
793 {
794  // This method allows to create the delta vs Z plots for a given system1/system2 combination
795  // \param[in] system1 n-deficient system index
796  // \param[in] system2 n-rich system index
797  // \param[in] mcolor color to use for drawing
798  // \param[in] mstyle style to use for drawing
799  // \param[in] draw =kTRUE if we want to plot the result
800 
801  if (fdebug_) Info("BuildDeltaZA2Plot", "====== STARTING BUILDING DELTA PLOTS FOR %d/%d ======", system1, system2);
802 
803  // Compute then plot Csym/T as a function of Z for the given system1/system2 combination
804  TGraphErrors* gr = new TGraphErrors();
805  gr->SetName(Form("Delta_%d_%d", system1, system2));
806  gr->SetMarkerStyle(20);
807  gr->GetXaxis()->SetTitle("Z");
808  gr->GetYaxis()->SetTitle("#Delta");
809  gr->SetMarkerStyle(mstyle);
810  gr->SetMarkerColor(mcolor);
811 
812  Int_t np = 0;
813  KVNumberList nl = GetSharedZNumberList(system1, system2);
814  nl.Begin();
815  while (!nl.End()) {
816  Int_t zz = nl.Next();
817  Float_t delta, delta_err;
818  Bool_t is_ok = GetDeltaZA2(system1, system2, zz, delta, delta_err, fdebug_);
819 
820  if (is_ok) {
821  gr->SetPoint(np, zz, delta);
822  gr->SetPointError(np, 0., delta_err);
823  np++;
824  }
825  }
826 
828 
829  if (draw) gr->Draw("ap");
830 
831  if (fdebug_) Info("BuildDeltaZA2Plot", "====== END BUILDING DELTA PLOTS FOR %d/%d ======", system1, system2);
832 }
833 
834 
835 
843 
844 void KVIsoscaling::BuildAlphavsDeltaPlot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw)
845 {
846  // This method allows to create the alpha vs delta plots for a given system1/system2 combination
847  // \param[in] system1 n-deficient system index
848  // \param[in] system2 n-rich system index
849  // \param[in] mcolor color to use for drawing
850  // \param[in] mstyle style to use for drawing
851  // \param[in] draw =kTRUE if we want to plot the result
852 
853  if (fdebug_) Info("BuildAlphavsDeltaPlot", "====== STARTING BUILDING DELTA PLOTS FOR %d/%d ======", system1, system2);
854 
855  TGraphErrors* gr = new TGraphErrors();
856  gr->SetName(Form("Alpha_vs_Delta_%d_%d", system1, system2));
857  gr->SetMarkerStyle(20);
858  gr->GetYaxis()->SetTitle("#alpha");
859  gr->GetXaxis()->SetTitle("#Delta");
860  gr->SetMarkerStyle(mstyle);
861  gr->SetMarkerColor(mcolor);
862 
863  Int_t np = 0;
864  KVNumberList nl = GetSharedZNumberList(system1, system2);
865  nl.Begin();
866  while (!nl.End()) {
867  Int_t zz = nl.Next();
868  Float_t delta, delta_err, alpha, alpha_err;
869  Bool_t is_ok_delta = GetDeltaZA2(system1, system2, zz, delta, delta_err, fdebug_);
870  Bool_t is_ok_alpha = GetAlpha(system1, system2, zz, alpha, alpha_err);
871 
872  if (is_ok_delta && is_ok_alpha) {
873  gr->SetPoint(np, delta, alpha);
874  gr->SetPointError(np, delta_err, alpha_err);
875  np++;
876  }
877  }
878 
880 
881  if (draw) gr->Draw("ap");
882 
883  if (fdebug_) Info("BuildAlphavsDeltaPlot", "====== END BUILDING DELTA PLOTS FOR %d/%d ======", system1, system2);
884 }
885 
886 
887 
898 
899 void KVIsoscaling::BuildCsymOverTPlot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw)
900 {
901  // This method allows to create the Csym/T vs Z plots for a given system1/system2 combination
902  // \param[in] system1 n-deficient system index
903  // \param[in] system2 n-rich system index
904  // \param[in] mcolor color to use for drawing
905  // \param[in] mstyle style to use for drawing
906  // \param[in] draw =kTRUE if we want to plot the result
907 
908  // 2 ways to compute Csym/T (see for ex. Raduta & Gulminelli, PRC 75 044605 (2007):
909  // - Eq.(16) : usual isoscaling formula : Csym(<A(Z)>)/T = alpha(Z)/delta; where delta = (Z/<A1(Z)>)**2-(Z/<A2(Z)>)**2
910  // - Eq.(15) : Csym/T =
911  if (fdebug_) Info("BuildCsymOverTPlot", "====== STARTING BUILDING PLOTS FOR %d/%d ======", system1, system2);
912 
913  // Compute then plot Csym/T as a function of Z for the given system1/system2 combination
914  TGraphErrors* gr = new TGraphErrors();
915  gr->SetName(Form("CsymOverT_%d_%d", system1, system2));
916  gr->SetMarkerStyle(mstyle);
917  gr->SetMarkerColor(mcolor);
918  gr->GetXaxis()->SetTitle("Z");
919  gr->GetYaxis()->SetTitle("#alpha/4#Delta");
920 
921  Int_t np = 0;
922  TF1* func = NULL;
923  TIter it1(&fhlist_fit_);
924  while ((func = (TF1*) it1.Next())) {
925  //Tokenize
926  KVString my_str(func->GetName());
927  TObjArray* my_str_array = my_str.Tokenize("_"); //func_%d_%d_%d
928 
929  Int_t sys1 = ((TObjString*) my_str_array->At(1))->String().Atoi();
930  Int_t sys2 = ((TObjString*) my_str_array->At(2))->String().Atoi();
931  Int_t zz = ((TObjString*) my_str_array->At(3))->String().Atoi();
932 
933  if (sys1 == system1 && sys2 == system2) {
934  // --- Get the corresponding Csym/T ---
935  Float_t csymT = -666.;
936  Float_t csymT_err = -666.;
937  Bool_t is_ok = GetCsymOverT(system1, system2, zz, csymT, csymT_err, fdebug_);
938 
939  if (is_ok) {
940  gr->SetPoint(np, zz, csymT);
941  gr->SetPointError(np, 0, csymT_err);
942  np++;
943  }
944  }
945  }//end iter
946 
948 
949  if (draw) gr->Draw("ap");
950 
951  if (fdebug_) Info("BuildCsymOverTPlot", "====== END BUILDING PLOTS FOR %d/%d ======", system1, system2);
952 }
953 
954 
955 
957 
959 {
960  TGraphErrors* gr = NULL;
961 
962  Int_t nn = 0;
963  TIter it(&fhlist_csymT_);
964  while ((gr = (TGraphErrors*) it.Next())) {
965  Info("CreateCsymOverTMultiGraph", "%s added to the MultiGraph", gr->GetName());
966  mgr->Add(gr);
967  }
968 }
969 
970 
971 
975 
976 void KVIsoscaling::SaveResultsROOT(const Char_t* file_name)
977 {
978  // This method allows to save the lnR21, fits and Csym/T graphs in a *.root file
979  // \param[in] file_name output file path
980 
981  TFile my_file(Form("%s", file_name), "RECREATE");
982 
985  fhlist_fit_.Write();
987 
992 
993  if (fdebug_) Info("SaveResultsROOT", "File '%s' saved", file_name);
994 }
995 
996 
997 
1001 
1003 {
1004  // This method allows to save results in a *.txt file
1005  // \param[in] file_name output file path
1006  KVString fname(file_name);
1007 
1008  std::ofstream my_file;
1009  my_file.open(fname.Data(), std::ofstream::out);
1010  my_file << "### system_1 system_2 Z Alpha d(Alpha) <A_1> d<A_1> <A_2> d<A_2> denum d(denum) Csym/T d(Csym/T) ###" << std::endl;
1011 
1012  for (std::vector< std::pair<Int_t, Int_t> >::iterator it = fvec_iso_pairs_.begin(); it != fvec_iso_pairs_.end(); ++it) {
1013  std::pair<Int_t, Int_t> my_pair = *it;
1014  Int_t sys1 = my_pair.first;
1015  Int_t sys2 = my_pair.second;
1016 
1017  my_file << "# " << sys1 << " / " << sys2 << " #" << std::endl;
1018 
1019  KVNumberList nl = GetSharedZNumberList(sys1, sys2);
1020  nl.Begin();
1021  while (!nl.End()) {
1022  Int_t next_z = nl.Next();
1023 
1024  // Alpha
1025  Float_t alpha = -666.;
1026  Float_t alpha_err = -666.;
1027  GetAlpha(sys1, sys2, next_z, alpha, alpha_err);
1028 
1029  // Denum
1030  Float_t denum = -666.;
1031  Float_t denum_err = -666.;
1032  GetDeltaZA2(sys1, sys2, next_z, denum, denum_err, kFALSE);
1033 
1034  //Csym/T
1035  Float_t csymT = -666.;
1036  Float_t csymT_err = -666.;
1037  GetCsymOverT(sys1, sys2, next_z, csymT, csymT_err, kFALSE);
1038 
1039  //<A1> and <A2>
1040  Float_t meanA1 = -666.;
1041  Float_t meanA1_err = -666.;
1042  Float_t meanA2 = -666.;
1043  Float_t meanA2_err = -666.;
1044  GetAMean(sys1, next_z, meanA1, meanA1_err);
1045  GetAMean(sys2, next_z, meanA2, meanA2_err);
1046 
1047 
1048  KVString line(Form("%d %d %d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", sys1, sys2, next_z, alpha, alpha_err, meanA1, meanA1_err, meanA2, meanA2_err, denum, denum_err, csymT, csymT_err));
1049  my_file << line.Data() << std::endl;
1050  }
1051 
1052  if (fdebug_) Info("SaveResultsASCII", "[%d/%d] results saved with the following Z list : %s\n", sys1, sys2, nl.GetList());
1053  }
1054 
1055  my_file.close();
1056 
1057  if (fdebug_) Info("SaveResultsASCII", "File '%s' saved", fname.Data());
1058 }
1059 
1060 
1061 
1062 //============================
1063 //== GETTERS ==
1064 //============================
1065 
1068 
1069 Bool_t KVIsoscaling::GetAMean(Int_t system, Int_t zz, Float_t& meanA, Float_t& meanA_err)
1070 {
1071  // return the <A(Z)> for the given system
1072  Bool_t is_ok = kTRUE;
1073 
1074  Int_t zpos = GetZPos(system, zz);
1075  KVNumberList* nl = GetZNumberList(system);
1076 
1077  if (zpos > -1 && nl->Contains(zz)) {
1078  meanA = GetAMeanVector(system).at(zpos);
1079  meanA_err = GetAMeanErrVector(system).at(zpos);
1080  }
1081  else {
1082  if (zpos <= -1) Error("GetAMean", "[sys=%d] Can't find mean A vector for z=%d ", system, zz);
1083  if (!nl->Contains(zz)) Error("GetAMean", "[sys=%d] Z=%d is out of range", system, zz);
1084  }
1085 
1086  return is_ok;
1087 }
1088 
1089 
1090 
1093 
1094 Bool_t KVIsoscaling::GetAlpha(Int_t system1, Int_t system2, Int_t zz, Float_t& alpha, Float_t& alpha_err)
1095 {
1096  // --- Find the corresponding alpha parameter in fit function list ---
1097  Bool_t is_ok = kFALSE;
1098 
1099  TF1* func = NULL;
1100  TIter it1(&fhlist_fit_);
1101  while ((func = (TF1*) it1.Next())) {
1102  //Tokenize
1103  KVString my_str(func->GetName());
1104  TObjArray* my_str_array = my_str.Tokenize("_"); //func_%d_%d_%d
1105 
1106  Int_t sys1 = ((TObjString*) my_str_array->At(1))->String().Atoi();
1107  Int_t sys2 = ((TObjString*) my_str_array->At(2))->String().Atoi();
1108  Int_t zzz = ((TObjString*) my_str_array->At(3))->String().Atoi();
1109 
1110  if (sys1 == system1 && sys2 == system2 && zzz == zz) {
1111  is_ok = kTRUE;
1112  alpha = func->GetParameter(1);
1113  alpha_err = func->GetParError(1);
1114  }
1115  }
1116 
1117  if (!is_ok) Error("GetAlpha", "!!! [Z=%d] (%d, %d) : Fit function not found !!!", zz, system1, system2);
1118 
1119  return is_ok;
1120 }
1121 
1122 
1123 
1126 
1127 Bool_t KVIsoscaling::GetDeltaZA2(Int_t system1, Int_t system2, Int_t zz, Float_t& denum, Float_t& denum_err, Bool_t debug)
1128 {
1129  // Return the value of the denumerator (Z/<A1>)**2-(Z/<A2>)**2 for Csym/T estimation
1130 
1131  Bool_t is_ok = kFALSE;
1132 
1133  Float_t meanA1 = -666.;
1134  Float_t meanA2 = -666.;
1135  Float_t meanA1_err = -666.;
1136  Float_t meanA2_err = -666.;
1137 
1138  Bool_t ok1 = GetAMean(system1, zz, meanA1, meanA1_err);
1139  Bool_t ok2 = GetAMean(system2, zz, meanA2, meanA2_err);
1140 
1141  if (ok1 && ok2) {
1142  is_ok = kTRUE;
1143 
1144  denum = TMath::Power(1.*zz / meanA1, 2.) - TMath::Power(1.*zz / meanA2, 2.);
1145  denum_err = TMath::Sqrt(TMath::Power(zz * zz * 2.*meanA1_err / meanA1 / meanA1 / meanA1, 2.) + TMath::Power(zz * zz * 2.*meanA2_err / meanA2 / meanA2 / meanA2, 2.));
1146 
1147  if (debug) Info("GetDeltaZA2", "[Z=%d] (%d / %d) : denum=%lf +/- %lf", zz, system1, system2, denum, denum_err);
1148  }
1149  else {
1150  if (!ok1) Warning("GetDeltaZA2", "<A1> was not found for Z=%d of system %d/%d", zz, system1, system2);
1151  if (!ok2) Warning("GetDeltaZA2", "<A2> was not found for Z=%d of system %d/%d", zz, system1, system2);
1152  }
1153 
1154  return is_ok;
1155 }
1156 
1157 
1158 
1160 
1161 Bool_t KVIsoscaling::GetCsymOverT(Int_t system1, Int_t system2, Int_t zz, Float_t& csymT, Float_t& csymT_err, Bool_t debug)
1162 {
1163  Bool_t is_ok = kFALSE;
1164  Bool_t is_oka = kFALSE;
1165  Bool_t is_okd = kFALSE;
1166 
1167  // --- Get corresponding alpha isoscaling parameter ---
1168  Float_t alpha = -666.;
1169  Float_t alpha_err = -666.;
1170  is_oka = GetAlpha(system1, system2, zz, alpha, alpha_err);
1171 
1172  // --- Get the denum ---
1173  Float_t denum = -666.;
1174  Float_t denum_err = -666.;
1175  is_okd = GetDeltaZA2(system1, system2, zz, denum, denum_err, debug);
1176 
1177  // --- Compute Csym/T ---
1178  if (is_oka && is_okd) {
1179  is_ok = kTRUE;
1180  csymT = alpha / 4. / denum;
1181  csymT_err = TMath::Sqrt(TMath::Power(alpha_err / 4. / denum, 2.) + TMath::Power(alpha * denum_err / 4. / denum / denum, 2.));
1182 
1183  if (debug) {
1184  Info("GetCsymOverT", "[Z=%d] (%d / %d) : alpha=%lf +/- %lf, denum=%lf +/- %lf, Csym/T=%lf +/- %lf", zz, system1, system2, alpha, alpha_err, denum, denum_err, csymT, csymT_err);
1185  }
1186  }
1187 
1188  return is_ok;
1189 }
1190 
1191 
1192 
1194 
1196 {
1197  Int_t pos = -1;
1198 
1199  if (fnl_sys_.Contains(system)) {
1200  Bool_t found = kFALSE;
1201  Int_t ii = 0;
1202 
1203  while (!found || ii < int(fvec_sys_.size())) {
1204  Int_t sys = fvec_sys_.at(ii);
1205  if (sys == system) {
1206  found = kTRUE;
1207  pos = ii;
1208  }
1209 
1210  ii++;
1211  }
1212  }
1213  if (pos == -1) Warning("GetSystemPos", "!!! system %d was not set !!!", system);
1214  else if (fdebug_) Info("GetSystemPos", "system= %d found at position %d", system, pos);
1215 
1216  return pos;
1217 }
1218 
1219 
1220 
1223 
1225 {
1226 // Returns the position of the charge 'ZZ' in the vector corresponding to 'system' in fvec_sys_z_
1227 
1228  Int_t pos_zz = -1;
1229  Int_t pos_system = GetSystemPos(system);
1230 
1231  if (pos_system > -1) {
1232  std::vector<Int_t> my_vec_zz = fvec_sys_z_.at(pos_system);
1233  Bool_t found = kFALSE;
1234  Int_t ii = 0;
1235 
1236  while (!found && ii < int(my_vec_zz.size())) {
1237  Int_t zz = my_vec_zz.at(ii);
1238  if (zz == ZZ) {
1239  found = kTRUE;
1240  pos_zz = ii;
1241  }
1242 
1243  ii++;
1244  }
1245 
1246  if (!found) Warning("GetZPos", "!!! Charge Z=%d for system= %d was not found !!!", ZZ, system);
1247  else if (fdebug_) Info("GetZPos", "Charge Z=%d for system %d is at position %d", ZZ, system, pos_zz);
1248  }
1249 
1250  return pos_zz;
1251 }
1252 
1253 
1254 
1258 
1260 {
1261  // Returns the position of the mass 'AA' in the vector corresponding to the (ZZ, system) combination in fvec_sys_z_a_.
1262  // The returned position can also be used for the 'yields' and 'yields_err' (respectively in fvec_sys_z_yields_ and fvec_sys_z_yields_err_).
1263 
1264  Int_t pos_aa = -1;
1265  Int_t pos_system = GetSystemPos(system);
1266  Int_t pos_zz = GetZPos(system, ZZ);
1267 
1268  if (pos_zz > -1) {
1269  // first find the vectors of all A for the system (one vector per Z)
1270  std::vector< std::vector<Int_t> > my_vec_zz_aa = fvec_sys_z_a_.at(pos_system);
1271  // then find the vector of A for the given (system,Z)
1272  std::vector<Int_t> my_vec_aa = my_vec_zz_aa.at(pos_zz);
1273 
1274  Bool_t found = kFALSE;
1275  Int_t ii = 0;
1276 
1277  while (!found && ii < int(my_vec_aa.size())) {
1278  Int_t aa = my_vec_aa.at(ii);
1279  if (aa == AA) {
1280  found = kTRUE;
1281  pos_aa = ii;
1282  }
1283 
1284  ii++;
1285  }
1286 
1287  if (!found) Warning("GetAPos", "!!! mass A=%d for (system= %d, Z= %d) was not found !!!", AA, system, ZZ);
1288  else if (fdebug_) Info("GetAPos", "mass A=%d for (system= %d, Z= %d) is at position %d", AA, system, ZZ, pos_aa);
1289  }
1290 
1291  return pos_aa;
1292 }
1293 
1294 
1295 
1297 
1298 std::vector<Int_t> KVIsoscaling::GetAVector(Int_t system, Int_t ZZ)
1299 {
1300  Int_t pos_system = GetSystemPos(system);
1301  Int_t pos_zz = GetZPos(system, ZZ);
1302 
1303  return GetAVectorFromPos(pos_system, pos_zz);
1304 }
1305 
1306 
1307 
1309 
1310 std::vector<Int_t> KVIsoscaling::GetAVectorFromPos(Int_t pos_system, Int_t pos_zz)
1311 {
1312  std::vector< std::vector<Int_t> > my_vec_zz_aa = fvec_sys_z_a_.at(pos_system);
1313  std::vector<Int_t> my_vec_aa = my_vec_zz_aa.at(pos_zz);
1314 
1315  return my_vec_aa;
1316 }
1317 
1318 
1319 
1321 
1322 std::vector<Float_t> KVIsoscaling::GetYieldVector(Int_t system, Int_t ZZ)
1323 {
1324  Int_t pos_system = GetSystemPos(system);
1325  Int_t pos_zz = GetZPos(system, ZZ);
1326 
1327  return GetYieldVectorFromPos(pos_system, pos_zz);
1328 }
1329 
1330 
1331 
1333 
1334 std::vector<Float_t> KVIsoscaling::GetYieldVectorFromPos(Int_t pos_system, Int_t pos_zz)
1335 {
1336  std::vector< std::vector<Float_t> > my_vec_zz_yy = fvec_sys_z_yields_.at(pos_system);
1337  std::vector<Float_t> my_vec_yy = my_vec_zz_yy.at(pos_zz);
1338 
1339  return my_vec_yy;
1340 }
1341 
1342 
1343 
1345 
1346 std::vector<Float_t> KVIsoscaling::GetYieldErrVector(Int_t system, Int_t ZZ)
1347 {
1348  Int_t pos_system = GetSystemPos(system);
1349  Int_t pos_zz = GetZPos(system, ZZ);
1350 
1351  return GetYieldErrVectorFromPos(pos_system, pos_zz);
1352 }
1353 
1354 
1355 
1357 
1358 std::vector<Float_t> KVIsoscaling::GetYieldErrVectorFromPos(Int_t pos_system, Int_t pos_zz)
1359 {
1360  std::vector< std::vector<Float_t> > my_vec_zz_yy = fvec_sys_z_yields_err_.at(pos_system);
1361  std::vector<Float_t> my_vec_yy = my_vec_zz_yy.at(pos_zz);
1362 
1363  return my_vec_yy;
1364 }
1365 
1366 
1367 
1369 
1371 {
1372  Int_t sys_pos = GetSystemPos(system);
1373  Int_t zz_pos = GetZPos(system, zz);
1374 
1375  if (fdebug_) Info("GetANumberList", "Looking at sys_pos=%d, z_pos=%d", sys_pos, zz_pos);
1376 
1377  KVList* mylist = (KVList*)(flist_a_.At(sys_pos));
1378  KVNumberList* mynlist = (KVNumberList*)(mylist->At(zz_pos));
1379 
1380  return mynlist;
1381 }
1382 
1383 
1384 
1387 
1389 {
1390  // Returns the number list of all Z shared between the 2 systems
1391 
1392  KVNumberList* nl_z1 = GetZNumberList(system1);
1393  KVNumberList* nl_z2 = GetZNumberList(system2);
1394  KVNumberList nl_inter;
1395  nl_z1->Copy(nl_inter);
1396  nl_inter.Inter(*nl_z2);
1397 
1398  if (fdebug_) {
1399  Info("GetSharedZNumberList", "Zlist[%d]= %s, Zlist[%d]= %s, shared Zlist= %s",
1400  system1, nl_z1->GetList(), system2, nl_z2->GetList(), nl_inter.GetList()) ;
1401  }
1402 
1403  return nl_inter;
1404 }
1405 
1406 
1407 
1410 
1412 {
1413  // Returns the number list of all A shared between the 2 systems
1414  KVNumberList* nl_a1 = GetANumberList(system1, zz);
1415  KVNumberList* nl_a2 = GetANumberList(system2, zz);
1416  KVNumberList nl_inter_a;
1417  nl_a1->Copy(nl_inter_a);
1418  nl_inter_a.Inter(*nl_a2);
1419 
1420  if (fdebug_) {
1421  Info("GetSharedANumberList", "Z=%d : Alist[%d]= %s, Alist[%d]= %s, shared Alist= %s",
1422  zz, system1, nl_a1->GetList(), system2, nl_a2->GetList(), nl_inter_a.GetList()) ;
1423  }
1424 
1425  return nl_inter_a;
1426 }
1427 
1428 
1429 
1432 
1434 {
1435  // Returns the charge ZZ associated to the provided mass AA such as <A(ZZ)> == AA
1436 
1437  Int_t zz = -666;
1438  Double_t min_val = 10.;
1439 
1440  KVNumberList* nl = GetZNumberList(system);
1441  nl->Begin();
1442  while (!nl->End()) {
1443  Int_t next_zz = nl->Next();
1444 
1445  // extract mean aa
1446  Float_t aa_real, aa_real_err;
1447  GetAMean(system, next_zz, aa_real, aa_real_err);
1448 
1449  Double_t delta_aa = TMath::Abs(aa - aa_real);
1450  if (delta_aa < min_val) {
1451  zz = next_zz;
1452  min_val = delta_aa;
1453 
1454  if (fdebug_) Info("FindZFromAmean", "[%d - A=%d] : Z=%d -> <A(Z)>=%lf +/- %lf [FOUND] delta=%lf, min_val=%lf", system, aa, next_zz, aa_real, aa_real_err, delta_aa, min_val);
1455  }
1456  else if (fdebug_) Info("FindZFromAmean", "[%d - A=%d] : Z=%d -> <A(Z)>=%lf +/- %lf [NOT FOUND] delta=%lf, min_val=%lf", system, aa, next_zz, aa_real, aa_real_err, delta_aa, min_val);
1457  }
1458 
1459  return zz;
1460 }
1461 
1462 
1463 //============================
1464 //== PRINTERS ==
1465 //============================
1466 
1468 
1470 {
1471  Info("PrintYields", "Printing the list of yields : ");
1472 
1473  // --- Iterate over systems ---
1474  Int_t nn_sys = 0;
1475  for (std::vector<Int_t>::iterator sys_it = fvec_sys_.begin(); sys_it != fvec_sys_.end(); ++sys_it) {
1476  Int_t system = *sys_it;
1477 
1478  printf(" =====================================\n");
1479 
1480  // --- Iterate over Z for the given system ---
1481  std::vector<Int_t> zz_vec = fvec_sys_z_.at(nn_sys);
1482  std::vector< std::vector<Int_t> > aa_vec_vec = fvec_sys_z_a_.at(nn_sys);
1483  std::vector< std::vector<Float_t> > yy_vec_vec = fvec_sys_z_yields_.at(nn_sys);
1484  std::vector< std::vector<Float_t> > yyerr_vec_vec = fvec_sys_z_yields_err_.at(nn_sys);
1485 
1486  Int_t nn_zz = 0;
1487  for (std::vector<Int_t>::iterator zz_it = zz_vec.begin(); zz_it != zz_vec.end(); ++zz_it) {
1488  Int_t zz = *zz_it;
1489 
1490  std::vector<Int_t> aa_vec = aa_vec_vec.at(nn_zz);
1491  std::vector<Float_t> yy_vec = yy_vec_vec.at(nn_zz);
1492  std::vector<Float_t> yyerr_vec = yyerr_vec_vec.at(nn_zz);
1493 
1494  for (std::vector<Float_t>::size_type ii = 0; ii != aa_vec.size(); ii++) {
1495  Int_t aa = aa_vec.at(ii);
1496  Float_t yy = yy_vec.at(ii);
1497  Float_t yy_err = yyerr_vec.at(ii);
1498 
1499  printf(" [%d] : Y(%d, %d) = %lf +/- %lf\n", system, aa, zz, yy, yy_err);
1500  }
1501 
1502  nn_zz++;
1503  }
1504 
1505  nn_sys++;
1506  }
1507 
1508  Info("PrintYields", "That's all folks !");
1509 }
1510 
1511 
1512 
1514 
1516 {
1517  fnl_sys_.Begin();
1518  Int_t nn = 0;
1519 
1520  Info("PrintSystemsList", "Printing the list of available systems : ");
1521 
1522  while (!fnl_sys_.End()) {
1523  Int_t next_val = fnl_sys_.Next();
1524  printf("[%d] %d\n", nn, next_val);
1525 
1526  nn++;
1527  }
1528 }
1529 
1530 
1531 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
float Float_t
const Bool_t kTRUE
const char Option_t
kRed
kBlack
kBlue
char * Form(const char *fmt,...)
Isoscaling class.
Definition: KVIsoscaling.h:145
void BuildAlphaPlot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw=kFALSE)
std::vector< std::vector< Int_t > > fvec_sys_z_
vectors of charge Z (one vector per system)
Definition: KVIsoscaling.h:275
Int_t GetAPos(Int_t system, Int_t zz, Int_t aa)
Bool_t GetAlpha(Int_t system1, Int_t system2, Int_t zz, Float_t &alpha, Float_t &alpha_err)
— Find the corresponding alpha parameter in fit function list —
KVHashList fhlist_alpha_delta_
contains all Alpha vs Delta graphs
Definition: KVIsoscaling.h:297
void DrawLnR21vsNFits(Int_t system1, Int_t system2)
std::vector< Float_t > GetAMeanVector(Int_t system)
Definition: KVIsoscaling.h:205
Int_t GetZPos(Int_t system, Int_t zz)
Returns the position of the charge 'ZZ' in the vector corresponding to 'system' in fvec_sys_z_.
std::vector< std::vector< Float_t > > fvec_sys_z_meanA_
— (system, Z, <A(Z)>, <A(Z)>_err) vectors for Isoscaling —
Definition: KVIsoscaling.h:281
void FitLnR21vsNPlots(Int_t system1, Int_t system2, Option_t *option="MNVR", Option_t *gooption="goff")
void BuildGaussianPlots(Int_t system)
void PrintYieldsList()
— Printers —
std::vector< std::vector< std::vector< Float_t > > > fvec_sys_z_yields_err_
vector of yields uncertainties (one vector per (system, Z) combination - same order than fvec_sys_z_a...
Definition: KVIsoscaling.h:278
std::vector< Int_t > GetAVectorFromPos(Int_t pos_system, Int_t pos_zz)
std::vector< Float_t > GetYieldErrVectorFromPos(Int_t pos_system, Int_t pos_zz)
KVNumberList fnl_sys_
— Lists —
Definition: KVIsoscaling.h:288
KVHashList fhlist_delta_
contains all Delta vs Z graphs
Definition: KVIsoscaling.h:295
Bool_t fdebug_
verbose mode for debugging
Definition: KVIsoscaling.h:268
Double_t ftol_
tolerance for the gaussian approximation (in sigma)
Definition: KVIsoscaling.h:269
std::vector< Float_t > GetYieldVector(Int_t system, Int_t zz)
Int_t FindZFromAmean(Int_t system, Int_t aa)
Returns the charge ZZ associated to the provided mass AA such as <A(ZZ)> == AA.
KVNumberList * GetANumberList(Int_t system, Int_t zz)
KVList flist_a_
contains all lists of masses A (one list of KVNumberList per (system, Z) combination)
Definition: KVIsoscaling.h:290
std::vector< Float_t > GetAMeanErrVector(Int_t system)
Definition: KVIsoscaling.h:209
void PrintSystemsList()
Bool_t GetCsymOverT(Int_t system1, Int_t system2, Int_t zz, Float_t &csymT, Float_t &csymT_err, Bool_t debug)
KVHashList fhlist_lnR21N_all_
contains all graphs of lnR21 vs N (without tolerance applied)
Definition: KVIsoscaling.h:292
void BuildDeltaZA2Plot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw=kFALSE)
KVNumberList GetSharedANumberList(Int_t system1, Int_t system2, Int_t zz)
Returns the number list of all A shared between the 2 systems.
std::vector< Int_t > fvec_sys_
— (system, Z, A, yields, yields_err) vectors for Isoscaling —
Definition: KVIsoscaling.h:274
std::vector< Float_t > GetYieldVectorFromPos(Int_t pos_system, Int_t pos_zz)
KVHashList fhlist_yields_
contains all yield plots vs N
Definition: KVIsoscaling.h:294
std::vector< std::pair< Int_t, Int_t > > fvec_iso_pairs_
— list of isoscaling systems —
Definition: KVIsoscaling.h:285
KVHashList fhlist_alpha_
contains all Aplha vs Z graphs
Definition: KVIsoscaling.h:296
KVHashList fhlist_fit_
contains all linear fits attempted from lnR21_vs_N graphs
Definition: KVIsoscaling.h:293
void BuildLnR21vsNPlots(Int_t system1, Int_t system2)
Int_t GetSystemPos(Int_t system)
— Getters —
Bool_t GetDeltaZA2(Int_t system1, Int_t system2, Int_t zz, Float_t &denum, Float_t &denum_err, Bool_t debug)
Return the value of the denumerator (Z/<A1>)**2-(Z/<A2>)**2 for Csym/T estimation.
KVNumberList GetSharedZNumberList(Int_t system1, Int_t system2)
Returns the number list of all Z shared between the 2 systems.
std::vector< Float_t > GetYieldErrVector(Int_t system, Int_t zz)
void TestGaussianApprox(Int_t system1, Int_t system2, Int_t zz, Double_t tol)
void SaveResultsROOT(const Char_t *file_name="./isoscaling_output_file.root")
void BuildAlphavsDeltaPlot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw=kFALSE)
KVNumberList * GetZNumberList(Int_t system)
Definition: KVIsoscaling.h:240
KVHashList fhlist_csymT_
contains all Csym/T vs Z graphs
Definition: KVIsoscaling.h:298
std::vector< std::vector< std::vector< Float_t > > > fvec_sys_z_yields_
vector of yields (one vector per (system, Z) combination - same order than fvec_sys_z_a_)
Definition: KVIsoscaling.h:277
std::vector< std::vector< Float_t > > fvec_sys_z_meanerrA_
vectors of <A(Z)> uncertainties (one vector per system)
Definition: KVIsoscaling.h:282
Bool_t GetAMean(Int_t system, Int_t zz, Float_t &meanA, Float_t &meanA_err)
return the <A(Z)> for the given system
void CreateCsymOverTMultiGraph(TMultiGraph *mgr)
void BuildCsymOverTPlot(Int_t system1, Int_t system2, Int_t mcolor, Int_t mstyle, Bool_t draw=kFALSE)
void SaveResultsASCII(const Char_t *file_name="./isoscaling_output_file.txt")
std::vector< Int_t > GetAVector(Int_t system, Int_t zz)
std::vector< std::vector< std::vector< Int_t > > > fvec_sys_z_a_
vectors of A(Z) (one vector per (system, Z) combination)
Definition: KVIsoscaling.h:276
KVHashList fhlist_lnR21N_
contains all graphs of lnR21 vs N (with tolerance applied)
Definition: KVIsoscaling.h:291
Extended TList class which owns its objects by default.
Definition: KVList.h:27
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:83
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.
Bool_t End(void) const
Definition: KVNumberList.h:197
void Begin(void) const
void Add(Int_t)
Add value 'n' to the list.
void Clear(Option_t *="")
Empty number list, reset it to initial state.
Int_t Last() const
Returns largest number included in list.
Int_t Next(void) const
virtual TObject * Last() const
virtual TObject * At(Int_t idx) const
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
virtual Double_t GetParameter(const TString &name) const
virtual Double_t GetParError(Int_t ipar) const
virtual void Draw(Option_t *option="")
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 void SetName(const char *name="")
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
virtual void Draw(Option_t *chopt="")
TAxis * GetXaxis() const
TAxis * GetYaxis() const
TObject * Next()
virtual void Add(TGraph *graph, Option_t *chopt="")
virtual void Draw(Option_t *chopt="")
TAxis * GetYaxis()
TAxis * GetXaxis()
virtual const char * GetName() const
virtual void SetTitle(const char *title="")
TObject * At(Int_t idx) const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
TObjArray * Tokenize(const TString &delim) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
TLine * line
TGraphErrors * gr
void Info(const char *location, const char *va_(fmt),...)
void Error(const char *location, const char *va_(fmt),...)
void Warning(const char *location, const char *va_(fmt),...)
Double_t Power(Double_t x, Double_t y)
Double_t Log(Double_t x)
Double_t Sqrt(Double_t x)
Double_t Abs(Double_t d)
const char * String
std::pair< PtrSize_t, Bool_t > iterator