KaliVeda
Toolkit for HIC analysis
KVCaloBase.cpp
1 /*
2 $Id: KVCaloBase.cpp,v 1.4 2009/01/23 15:25:52 franklan Exp $
3 $Revision: 1.4 $
4 $Date: 2009/01/23 15:25:52 $
5 */
6 
7 //Created by KVClassFactory on Mon Apr 14 15:01:51 2008
8 //Author: eric bonnet,,,
9 
10 #include "KVCaloBase.h"
11 
13 
14 
15 
18 void KVCaloBase::Copy(TObject& a) const
19 {
20 // Methode de Copy
22  nvl_ing.Copy(dynamic_cast<KVCaloBase&>(a).nvl_ing);
23 }
24 
25 
26 
30 
32 {
33  // Init() is called by KVGVList::MakeBranches(), so this is the latest they
34  // can be set up.
35  SetNameIndex("Zsum", 0);
36  SetNameIndex("Asum", 1);
37  SetNameIndex("Eksum", 2);
38  SetNameIndex("Qsum", 3);
39  SetNameIndex("Msum", 4);
40  SetNameIndex("Qini", 5);
41  SetNameIndex("Exci", 6);
42 }
43 
44 
45 
49 
51 {
52  // Remise a zero avant le
53  // traitement d'un evenement
54 
55 #ifdef WITH_CPP11
56  for (auto& par : nvl_ing) {
57  par.Set(0.0);
58  }
59 #else
60  for (KVNameValueList::Iterator it = nvl_ing.begin(); it != nvl_ing.end(); ++it)(*it).Set(0.0);
61 #endif
62  kIsModified = kTRUE;
63 }
64 
65 
66 
71 
72 void KVCaloBase::Print(Option_t* option) const
73 {
74  //printf information on the object
75  //opt==ing, print the list of ingredients computed
76  //opt==par, print the list of parameters
77 
78  if (!strcmp(option, "ing"))
79  nvl_ing.Print();
80  else if (!strcmp(option, "par"))
81  GetParameters().Print();
82  else
84 
85 }
86 
87 
88 
93 
95 {
96  //retourne la KVNameValueList ou sont enregistres les ingredients (option=="ing")
97  //ou les parametres (option=="par")
98  //
99  if (!strcmp(option, "ing"))
100  return nvl_ing;
101  if (!strcmp(option, "par"))
102  return GetParameters();
103  else {
104  Info("GetList", "type has to be equal to \"ing\" or \"par\"");
105  return GetParameters();
106  }
107 
108 }
109 
110 
111 
116 
117 Double_t KVCaloBase::getvalue_int(Int_t i) const
118 {
119  // can't assume all ingredients declared to SetNameIndex in list nvl_ing exist
120  // - as they are dynamically created as data is filled
121  // therefore use NameIndex to retrieve name, then look for value in list by name
122 
123  return GetIngValue(GetValueName(i));
124 }
125 
126 
127 
152 
154 {
155  // Returns type of value depending on name:
156  // Zsum I
157  // Asum I
158  // Eksum D
159  // Qsum D
160  // Msum I
161  // Aneu I
162  // Qneu D
163  // Mneu I
164  // Qini D
165  // Temp D
166  // Exci D
167  // Ekneu D
168  // Zpart I
169  // Apart I
170  // Ekpart D
171  // Qpart D
172  // Mpart I
173  // Zfrag I
174  // Afrag I
175  // Ekfrag D
176  // Qfrag D
177  // Mfrag I
178 
180  if (name.BeginsWith("E") || name.BeginsWith("Q") || name.BeginsWith("T")) return 'D';
181  else return 'I';
182 }
183 
184 
185 
188 
189 std::vector<Double_t> KVCaloBase::GetValueVector(void) const
190 {
191  // On retourne un tableau rassemblant l'ensemble des ingredients
192 
193  std::vector<Double_t> tab;
194  for (Int_t ii = 0; ii < GetNumberOfValues(); ++ii)
195  tab.push_back(getvalue_int(ii));
196  return tab;
197 }
198 
199 
200 
205 
206 void KVCaloBase::init_KVCaloBase()
207 {
208  // protected method
209  // Private initialisation method called by all constructors.
210  // All member initialisations should be done here.
211 
212  fType = KVVarGlob::kOneBody; // this is a 1-body variable
213  //KVNameValueList contentant les ingredients et les parametres
214  //de la variable globale
215  //Elles sont remplies au fur et a mesure des
216  //methodes, pas besoin de definition a priori des
217  //noms des ingredients / parametres
218  nvl_ing.SetName("Ingredients");
219  kIsModified = kTRUE;
220 }
221 
222 
223 
227 
228 Double_t KVCaloBase::GetIngValue(const KVString& name) const
229 {
230  //return the value of a name given ingredient
231  //if it is not defined return 0
232  if (!nvl_ing.HasParameter(name.Data())) return 0;
233  return nvl_ing.GetDoubleValue(name.Data());
234 }
235 
236 
240 
241 Double_t KVCaloBase::GetIngValue(Int_t idx) const
242 {
243  // protected method,
244  //return the value of a index given ingredient
245  return nvl_ing.GetDoubleValue(idx);
246 }
247 
248 
252 
253 void KVCaloBase::SetIngValue(KVString name, Double_t value)
254 {
255  // protected method,
256  //set the value a name given ingredient
257  nvl_ing.SetValue(name.Data(), value);
258 }
259 
260 
265 
266 void KVCaloBase::AddIngValue(KVString name, Double_t value)
267 {
268  // protected method,
269  //increment the value of a name given ingredient
270  //if it is not defined, it's created
271  Double_t before = GetIngValue(name);
272  before += value;
273  SetIngValue(name, before);
274 }
275 
276 
277 
285 
286 void KVCaloBase::fill(const KVNucleus* n)
287 {
288  // Remplissage des energies, masse, charge et defaut de masse
289  // Pour l'energie cinetique, si l'utilisateur a utilise en amont
290  // la methode KVVarGlob::SetFrame(const Char_t*), c'est dans ce repere que les energies sont sommees
291  // (a condition que chaque KVNucleus possede le repere avec un nom identique)
292  //
293  // somme simple sur les A, Z, Ek, Q sans distinction du type de particules
294 
295  kIsModified = kTRUE;
296  AddIngValue("Zsum", n->GetZ());
297  AddIngValue("Asum", n->GetA());
298  AddIngValue("Eksum", n->GetKE());
299  AddIngValue("Qsum", n->GetMassExcess());
300  AddIngValue("Msum", 1);
301 }
302 
303 
304 
317 
318 void KVCaloBase::SumUp()
319 {
320  // protected method
321  // Appele par Calculate pour mettre a jour les differents ingredients
322  // de la calorimetrie :
323  //
324  // Trois modes de sommes:
325  //------------------
326  //
327  // determination de l exces de masse de la source recontruite, dernier ingredient de l'equation :
328  // Exci + Qini = \Sigma Ek + \Sigma Q -> Exci = \Sigma Ek + \Sigma Q - Qini
329  //
330  // defaut de masse de la source reconstruite
331 
332  SetIngValue("Qini", nn.GetMassExcess(TMath::Nint(GetIngValue("Zsum")), TMath::Nint(GetIngValue("Asum"))));
333 
334 }
335 
336 
337 
339 
340 void KVCaloBase::ComputeExcitationEnergy()
341 {
342  Double_t exci = GetIngValue("Qsum") + GetIngValue("Eksum") - GetIngValue("Qini");
343  SetIngValue("Exci", exci);
344 }
345 
346 
347 
351 
353 {
354  //Add extra neutrons
355  // multiplicity (number) and mean kinetic energy
356 
357  kIsModified = kTRUE;
358  AddIngValue("Asum", mult);
359  AddIngValue("Eksum", mult * mke);
360  AddIngValue("Qsum", mult * nn.GetMassExcess(0, 1));
361  AddIngValue("Msum", mult);
362 
363 }
364 
365 
376 
378 {
379  //Realisation de la calorimetrie
380  //Calcul de l'energie d'excitation
381  //appel de SumUp()
382  //
383  // Resolution de l'equation
384  // Exci + Qini = \Sigma Ek + \Sigma Q
385  // -> Exci = \Sigma Ek + \Sigma Q - Qini
386  //
387  //
388 
389  if (!kIsModified) return;
390  kIsModified = kFALSE;
391  // premier calcul depuis le dernier remplissage par Fill
392  SumUp();
393 
394  ComputeExcitationEnergy();
395 }
396 
397 
398 
415 
416 Bool_t KVCaloBase::RootSquare(Double_t aa, Double_t bb, Double_t cc)
417 {
418  // protected method
419  //
420  // calcul les racines du polynome d'ordre 2 : aa*x*x + bb*xx + cc = 0
421  // les racines sont accessibles par les variables kracine_min et kracine_max
422  //
423  // kroot_status>=0 -> tout c'est bien passe la fonction retourne kTRUE
424  // =0 2 racines reelles distinctes
425  // =1 2 racines reelles egales (aa==0)
426  //
427  // kroot_status<0 les deux racines sont mises a zero la fonction retourne kFALSE
428  // =-1 2 racines imaginaires (Delta<0)
429  // =-2 aa=bb=0
430  // le calcul n'est alors pas poursuivi, la methode Calculate() retournera kFALSE
431  // la cause peut etre discriminee en appelant la methode GetValue("RootStatus")
432  //
433  kracine_max = 0, kracine_min = 0;
434  Double_t x1, x2;
435  kroot_status = 0;
436  if (aa != 0) {
437  Double_t Delta = TMath::Power(bb, 2.) - 4.*aa * cc;
438  if (Delta < 0) {
439  //Warning("RootSquare","Delta<0 - Solutions imaginaires");
440  kroot_status = -1;
441  SetIngValue("RootStatus", kroot_status);
442  }
443  else {
444  Double_t racDelta = TMath::Sqrt(Delta);
445  x1 = (-1.*bb + racDelta) / (2.*aa);
446  x2 = (-1.*(bb + racDelta)) / (2.*aa);
447  kroot_status = 0;
448  if (x1 > x2) {
449  kracine_max = x1;
450  kracine_min = x2;
451  }
452  else {
453  kracine_max = x2;
454  kracine_min = x1;
455  }
456  }
457  }
458  else {
459  if (bb != 0) {
460  kroot_status = 1;
461  kracine_max = kracine_min = -1.*cc / bb;
462  }
463  else {
464  kroot_status = -2;
465  kracine_max = kracine_min = 0;
466  SetIngValue("RootStatus", kroot_status);
467  }
468  }
469  if (kroot_status < 0) {
470  SetIngValue("RootStatus", kroot_status);
471  return kFALSE;
472  }
473  else {
474  return kTRUE;
475  }
476 
477 }
478 
479 
int Int_t
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
void GetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
char name[80]
Calorimetry of hot nuclei.
Definition: KVCaloBase.h:63
Char_t GetValueType(Int_t) const override
Definition: KVCaloBase.cpp:153
void Print(Option_t *opt="") const override
Definition: KVCaloBase.cpp:72
void Init() override
Definition: KVCaloBase.cpp:31
void AddNeutrons(Int_t mult, Double_t mke)
Definition: KVCaloBase.cpp:352
void Reset() override
Definition: KVCaloBase.cpp:50
const KVNameValueList & GetList(Option_t *opt="ing") const
Definition: KVCaloBase.cpp:94
void Calculate() override
Definition: KVCaloBase.cpp:377
std::vector< Double_t > GetValueVector(void) const override
On retourne un tableau rassemblant l'ensemble des ingredients.
Definition: KVCaloBase.cpp:189
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
Bool_t HasParameter(const Char_t *name) const
void Print(Option_t *opt="") const override
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:108
Double_t GetMassExcess(std::optional< int > z={}, std::optional< int > a={}) const
Definition: KVNucleus.cpp:911
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
virtual Int_t GetNumberOfValues() const
Definition: KVVarGlob.h:638
void Print(Option_t *="") const override
Definition: KVVarGlob.cpp:277
void Copy(TObject &obj) const override
Definition: KVVarGlob.h:346
virtual TString GetValueName(Int_t i) const
Definition: KVVarGlob.h:654
virtual void SetName(const char *name)
virtual void Info(const char *method, const char *msgfmt,...) const
const Int_t n
Int_t Nint(T x)
Double_t Power(Double_t x, Double_t y)
Double_t Sqrt(Double_t x)
const long double cc
volumes
Definition: KVUnits.h:86
TArc a
ClassImp(TPyArg)