KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVLifeTimeTable.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Wed Feb 9 13:04:29 2011
2 //Author: bonnet
3 
4 #include "KVLifeTimeTable.h"
5 #include "KVFileReader.h"
6 #include "TEnv.h"
7 #include "KVBase.h"
8 
10 
11 
12 
16 {
17  // Default constructor
18  init();
19 }
20 
21 
22 
25 
27 {
28  // Destructor
29 
30 }
31 
32 
33 
34 // suppress spurious warnings about out-of-bounds indices in
35 // the 2 lines
36 // conversion_t[ii][jj]=conversion_t[ii][jj-1]*conversion_t[jj-1][jj];
37 #pragma GCC diagnostic ignored "-Warray-bounds"
38 
39 
42 
44 {
45 
46  //Initialisation de la table de conversion en unite de temps
47  list_t = "y d h m s ms micros ns ps fs";
48  list_vt = "365 24 60 60 1.e3 1.e3 1.e3 1.e3 1.e3";
49 
50  kNu_t = 0;
51  list_t.Begin(" ");
52  while (!list_t.End()) {
54  }
55 
56  if (kNu_t > 15)
57  Warning("init", "Pb de dimensionnement de tableau conversion_t");
58 
59  for (Int_t jj = 0; jj < kNu_t; jj += 1)
60  for (Int_t ii = 0; ii < kNu_t; ii += 1)
61  conversion_t[ii][jj] = 1.;
62 
63  Int_t nn = 0;
64  list_vt.Begin(" ");
65  while (!list_vt.End()) {
66  Double_t coef = list_vt.Next().Atof();
67  //cout << nn << " " << nn+1 << " " << coef << endl;
68  conversion_t[nn][nn + 1] = coef;
69  nn += 1;
70  }
71  for (Int_t ii = 0; ii < kNu_t; ii += 1) {
72  for (Int_t jj = ii + 2; jj < kNu_t; jj += 1) {
73  conversion_t[ii][jj] = conversion_t[ii][jj - 1] * conversion_t[jj - 1][jj];
74  }
75  }
76  for (Int_t ii = 0; ii < kNu_t; ii += 1) {
77  for (Int_t jj = ii; jj < kNu_t; jj += 1) {
78  conversion_t[jj][ii] = 1. / conversion_t[ii][jj];
79  }
80  }
81 
82  //Initialisation de la table de conversion en unite d'energie
83 
84  list_e = "MeV keV eV";
85  list_ve = "1.e3 1.e3";
86 
87  kNu_e = 0;
88  list_e.Begin(" ");
89  while (!list_e.End()) {
91  }
92 
93  if (kNu_e > 15)
94  Warning("init", "Pb de dimensionnement de tableau conversion_e");
95 
96  for (Int_t jj = 0; jj < kNu_e; jj += 1)
97  for (Int_t ii = 0; ii < kNu_e; ii += 1)
98  conversion_e[ii][jj] = 1.;
99 
100  nn = 0;
101  list_ve.Begin(" ");
102  while (!list_ve.End()) {
103  Double_t coef = list_ve.Next().Atof();
104  //cout << nn << " " << nn+1 << " " << coef << endl;
105  conversion_e[nn][nn + 1] = coef;
106  nn += 1;
107  }
108 
109  for (Int_t ii = 0; ii < kNu_e; ii += 1) {
110  for (Int_t jj = ii + 2; jj < kNu_e; jj += 1) {
111  conversion_e[ii][jj] = conversion_e[ii][jj - 1] * conversion_e[jj - 1][jj];
112  }
113  }
114  for (Int_t ii = 0; ii < kNu_e; ii += 1) {
115  for (Int_t jj = ii; jj < kNu_e; jj += 1) {
116  conversion_e[jj][ii] = 1. / conversion_e[ii][jj];
117  }
118  }
119 
120  SetName("LifeTime");
121 
122 }
123 
124 
125 
126 
128 
130 {
131 
132  TString dfile;
133  dfile.Form("%s.DataFile", GetName());
134  TString cl_path;
135  if (!KVBase::SearchKVFile(gEnv->GetValue(dfile.Data(), ""), cl_path, "data")) {
136  Error("Initialize", "No file found for %s", GetName());
137  return;
138  }
139  else {
140  //Info("Initialize","%s will be read",gEnv->GetValue(dfile.Data(),""));
141  }
142  SetTitle(gEnv->GetValue(dfile.Data(), ""));
143 
144  Int_t ntot = 0;
145  nucMap = new TMap(50, 2);
146  KVFileReader* fr = new KVFileReader();
147  fr->OpenFileToRead(cl_path.Data());
148 
149  //Premier passage
150  while (fr->IsOK()) {
151 
152  fr->ReadLine(" ");
153  if (fr->GetNparRead() == 0) break;
154  else if (fr->GetReadPar(0).BeginsWith("//")) {
155 
156  kcomments += fr->GetCurrentLine();
157  kcomments += "\n";
158 
159  }
160  else {
161  Int_t zz = fr->GetIntReadPar(0);
162  Int_t aa = fr->GetIntReadPar(1);
163  GiveIndexToNucleus(zz, aa, ntot);
164  ntot += 1;
165  }
166  }
167 
168  if (!fr->PreparForReadingAgain()) return;
169 
170  //Info("Initialize","Set up map for %d nuclei", ntot);
171  CreateTable(ntot);
172 
173  KVLifeTime* lf = 0;
174  ntot = 0;
175  while (fr->IsOK()) {
176 
177  fr->ReadLine(" ");
178  if (fr->GetCurrentLine().IsNull()) {
179  break;
180  }
181  else if (fr->GetNparRead() == 0) {
182  break;
183  }
184  else if (fr->GetReadPar(0).BeginsWith("//")) { }
185  else {
186  Double_t val = fr->GetDoubleReadPar(2);
187 
188  CreateElement(ntot);
189  lf = (KVLifeTime*)GetCurrent();
190 
191  if (fr->GetNparRead() > 3) {
192  TString unit = fr->GetReadPar(3);
193  if (unit.EndsWith("eV")) {
194  lf->SetResonance(kTRUE);
195  val *= ToMeV(unit);
196  }
197  else {
198  lf->SetResonance(kFALSE);
199  val *= ToSecond(unit);
200  }
201  if (fr->GetNparRead() > 4) {
202  Int_t meas = fr->GetReadPar(4).Atoi();
203  lf->SetMeasured(meas);
204  }
205  else {
206  if (ntot == 0) InfoOnMeasured();
207  }
208  }
209  lf->SetValue(val);
210 
211  ntot += 1;
212  }
213 
214  }
215 
216  //Info("Initialize","table initialised correctly for %d nuclei", ntot);
217  fr->CloseFile();
218  delete fr;
219 
220 }
221 
222 
223 
226 
228 {
229 
230  //Allow conversion from a given time unit to second
231  Int_t from = lu_t.GetIntValue(unit.Data());
232  Int_t to = lu_t.GetIntValue("s");
233  Double_t coef = conversion_t[from][to];
234  return coef;
235 }
236 
237 
238 
241 
243 {
244 
245  //Allow conversion from a given energy unit to MeV
246  Int_t from = lu_e.GetIntValue(unit.Data());
247  Int_t to = lu_e.GetIntValue("MeV");
248  Double_t coef = conversion_e[from][to];
249  return coef;
250 }
251 
252 
253 
255 
257 {
258 
259  return (KVLifeTime*)GetData(zz, aa);
260 
261 }
262 
263 
264 
269 
271 {
272  // Returns bit of the registered KVNuclData object associated to the couple (Z,A).
273  // indicating if the nucleus as lifetime (in second) or a resonnance width (in MeV)
274  // returns kFALSE if no such object is present
275 
276  KVLifeTime* nd = 0;
277  if ((nd = GetLifeTime(zz, aa)))
278  return nd->IsAResonance();
279  else
280  return kFALSE;
281 
282 
283 }
284 
285 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
R__EXTERN TEnv * gEnv
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:538
Handle reading columns of numeric data in text files.
Definition: KVFileReader.h:119
KVString GetCurrentLine()
Definition: KVFileReader.h:319
Bool_t PreparForReadingAgain()
Definition: KVFileReader.h:199
void CloseFile()
Definition: KVFileReader.h:236
ReadStatus ReadLine(const KVString &pattern="")
Definition: KVFileReader.h:242
Double_t GetDoubleReadPar(Int_t pos) const
Definition: KVFileReader.h:333
Int_t GetIntReadPar(Int_t pos) const
Definition: KVFileReader.h:337
Int_t GetNparRead() const
Definition: KVFileReader.h:324
Bool_t IsOK()
Definition: KVFileReader.h:230
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:341
Bool_t OpenFileToRead(const KVString &filename)
Definition: KVFileReader.h:209
Store life time information of nuclei.
Int_t kNu_e
number of possible energy units (resonnance)
virtual void Initialize()
KVLifeTime * GetLifeTime(Int_t zz, Int_t aa) const
Double_t conversion_e[15][15]
KVNameValueList lu_t
virtual ~KVLifeTimeTable()
Destructor.
KVNameValueList lu_e
virtual void init()
Initialisation de la table de conversion en unite de temps.
KVString list_t
an energy resonnance from one unit to an other one
Int_t kNu_t
number of possible time units
Double_t ToSecond(TString unit)
Allow conversion from a given time unit to second.
Double_t conversion_t[15][15]
matrice kNu_t*kNu_t to convert a life time from one unit to an other one
Bool_t IsAResonance(Int_t zz, Int_t aa) const
Double_t ToMeV(TString unit)
Allow conversion from a given energy unit to MeV.
Simple class to store lifetime information of nucleus.
Definition: KVLifeTime.h:15
Bool_t IsAResonance() const
Definition: KVLifeTime.h:44
void SetResonance(Bool_t resonnance)
Definition: KVLifeTime.h:35
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
Abstract base class for nuclear data table.
KVString kcomments
Commentaire provenant de la lecture fichier.
TMap * nucMap
mapping (Z,A) -> nucleus index
void InfoOnMeasured() const
KVNuclData * GetCurrent() const
TObjArray* tobj_rangeA; //! array where range of A associated to each Z is stored via KVIntegerList.
KVNuclData * GetData(Int_t zz, Int_t aa) const
void CreateTable(Int_t ntot)
virtual void GiveIndexToNucleus(Int_t zz, Int_t aa, Int_t ntot)
Add a new entry in the table.
void CreateElement(Int_t idx)
void SetValue(Double_t val)
Definition: KVNuclData.cpp:97
void SetMeasured(Bool_t measured)
Definition: KVNuclData.h:55
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
virtual const char * GetValue(const char *name, const char *dflt) const
virtual const char * GetName() const
virtual void SetTitle(const char *title="")
virtual void SetName(const char *name)
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
Int_t Atoi() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Double_t Atof() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t IsNull() const
void Form(const char *fmt,...)