KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVAbundanceTable.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Wed Feb 23 16:10:14 2011
2 //Author: bonnet
3 
4 #include "KVAbundanceTable.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  init();
30 }
31 
32 
33 
35 
37 {
38  SetName("Abundance");
39 }
40 
41 
42 
44 
46 {
47 
48  TString dfile;
49  dfile.Form("%s.DataFile", GetName());
50  TString cl_path;
51  if (!KVBase::SearchKVFile(gEnv->GetValue(dfile.Data(), ""), cl_path, "data")) {
52  Error("Initialize", "No file found for %s", GetName());
53  return;
54  }
55  else {
56  //Info("Initialize","%s will be read",gEnv->GetValue(dfile.Data(),""));
57  }
58  SetTitle(gEnv->GetValue(dfile.Data(), ""));
59 
60  Int_t ntot = 0;
61  nucMap = new TMap(50, 2);
62  KVFileReader* fr = new KVFileReader();
63  fr->OpenFileToRead(cl_path.Data());
64 
65  //Premier passage
66  //Lecture du nombre de noyaux a enregistrer
67  /*
68  Int_t zmax=-1;
69  Int_t amax=-1;
70  */
71  while (fr->IsOK()) {
72 
73  fr->ReadLine(" ");
74  if (fr->GetCurrentLine().IsNull()) {
75  break;
76  }
77  else if (fr->GetNparRead() == 0) {
78  break;
79  }
80  else if (fr->GetReadPar(0).BeginsWith("//")) {
81 
82  kcomments += fr->GetCurrentLine();
83  kcomments += "\n";
84 
85  }
86  else {
87  Int_t zz = fr->GetIntReadPar(0);
88  Int_t aa = fr->GetIntReadPar(1);
89  /*
90  if (zz>zmax) zmax=zz;
91  if (aa>amax) amax=aa;
92  */
93  GiveIndexToNucleus(zz, aa, ntot);
94  ntot += 1;
95  }
96  }
97 
98  //CreateTableRange(zmax+1);
99  /*
100  tobj_rangeA = new TObjArray(zmax+1);
101  tobj_rangeZ = new TObjArray(amax+1);
102  KVIntegerList* il=0;
103  */
104  if (!fr->PreparForReadingAgain()) return;
105 
106  // Info("Initialize","Set up map for %d nuclei", ntot);
107  CreateTable(ntot);
108 
109  KVNuclData* lf = 0;
110  ntot = 0;
111  while (fr->IsOK()) {
112  fr->ReadLine(" ");
113  if (fr->GetCurrentLine().IsNull()) {
114  break;
115  }
116  else if (fr->GetNparRead() == 0) {
117  break;
118  }
119  else if (fr->GetReadPar(0).BeginsWith("//")) { }
120  else {
121 
122  CreateElement(ntot);
123  lf = GetCurrent();
124 
125  /*
126  Int_t zz = fr->GetIntReadPar(0);
127  Int_t aa = fr->GetIntReadPar(1);
128 
129 
130  if ( !(il = (KVIntegerList* )tobj_rangeA->At(zz)) ) {
131  il = new KVIntegerList();
132  tobj_rangeA->AddAt(il,zz);
133  }
134  il->Add(aa);
135 
136  if ( !(il = (KVIntegerList* )tobj_rangeZ->At(aa)) ) {
137  il = new KVIntegerList();
138  tobj_rangeZ->AddAt(il,aa);
139  }
140  il->Add(zz);
141  */
142  Double_t val = fr->GetDoubleReadPar(2);
143  lf->SetValue(val);
144  //lf->SetMeasured(kTRUE);
145 
146  ntot += 1;
147  }
148 
149  }
150 
151 // Info("Initialize","table initialised correctly for %d/%d nuclei", ntot,GetNumberOfNuclei());
152  fr->CloseFile();
153  delete fr;
154 
155  /*
156  for (Int_t zz=0;zz<=zmax;zz+=1){
157  if ( il = (KVIntegerList* )tobj_rangeA->At(zz) ){
158  il->CheckForUpdate();
159  //printf("%d %s\n",zz,tobj_rangeA->At(zz)->GetName());
160 
161  }
162  }
163 
164  for (Int_t aa=0;aa<=amax;aa+=1){
165  if ( il = (KVIntegerList* )tobj_rangeZ->At(aa) ){
166  il->CheckForUpdate();
167  //printf("%d %s\n",aa,tobj_rangeZ->At(aa)->GetName());
168 
169  }
170  }
171  */
172 
173 }
174 
175 
176 
178 
180 {
181 
182  return (KVAbundance*)GetData(zz, aa);
183 
184 }
185 
186 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
double Double_t
R__EXTERN TEnv * gEnv
Store available values of the relative abundance of isotopes.
virtual ~KVAbundanceTable()
Destructor.
KVAbundance * GetAbundance(Int_t zz, Int_t aa) const
virtual void Initialize()
Value of the relative abundance of isotopes.
Definition: KVAbundance.h:15
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:541
Handle reading text files.
Definition: KVFileReader.h:19
KVString GetCurrentLine()
Definition: KVFileReader.h:131
Bool_t PreparForReadingAgain()
Definition: KVFileReader.h:52
TString GetReadPar(Int_t pos)
Definition: KVFileReader.h:167
void CloseFile()
Definition: KVFileReader.h:79
Bool_t OpenFileToRead(KVString filename)
Definition: KVFileReader.h:59
void ReadLine(const Char_t *pattern)
Definition: KVFileReader.h:84
Double_t GetDoubleReadPar(Int_t pos)
Definition: KVFileReader.h:159
Bool_t IsOK()
Definition: KVFileReader.h:74
Int_t GetIntReadPar(Int_t pos)
Definition: KVFileReader.h:163
Int_t GetNparRead()
Definition: KVFileReader.h:150
Abstract base class for nuclear data table.
KVString kcomments
Commentaire provenant de la lecture fichier.
TMap * nucMap
mapping (Z,A) -> nucleus index
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)
Simple abstract class to store value related to nuclear data.
Definition: KVNuclData.h:17
void SetValue(Double_t val)
Definition: KVNuclData.cpp:97
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 Error(const char *method, const char *msgfmt,...) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t IsNull() const
void Form(const char *fmt,...)