KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVChargeRadiusTable.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Wed Jan 30 12:13:08 2013
2 //Author: bonnet
3 
4 #include "KVChargeRadiusTable.h"
5 #include "TEnv.h"
6 #include "KVFileReader.h"
7 #include "KVBase.h"
8 
10 
11 
12 
16 {
17  // Default constructor
18  init();
19 
20 }
21 
22 
24 
26 {
27 
28  SetName("ChargeRadius");
29 
30 }
31 
32 
33 
36 
38 {
39  // Destructor
40 }
41 
42 
43 
45 
47 {
48 
49  TString dfile;
50  dfile.Form("%s.DataFile", GetName());
51  TString cl_path;
52  if (!KVBase::SearchKVFile(gEnv->GetValue(dfile.Data(), ""), cl_path, "data")) {
53  Error("Initialize", "No file found for %s", GetName());
54  return;
55  }
56  else {
57  //Info("Initialize","%s will be read",gEnv->GetValue(dfile.Data(),""));
58  }
59  SetTitle(gEnv->GetValue(dfile.Data(), ""));
60 
61  Int_t ntot = 0;
62  nucMap = new TMap(50, 2);
63  KVFileReader* fr = new KVFileReader();
64  fr->OpenFileToRead(cl_path.Data());
65 
66  //Premier passage
67  while (fr->IsOK()) {
68 
69  fr->ReadLine(" ");
70  if (fr->GetNparRead() == 0) break;
71  else if (fr->GetReadPar(0).BeginsWith("//")) {
72 
73  kcomments += fr->GetCurrentLine();
74  kcomments += "\n";
75 
76  }
77  else {
78  Int_t aa = fr->GetIntReadPar(0);
79  Int_t zz = fr->GetIntReadPar(1);
80  GiveIndexToNucleus(zz, aa, ntot);
81  ntot += 1;
82  }
83  }
84 
85  if (!fr->PreparForReadingAgain()) return;
86 
87  //Info("Initialize","Set up map for %d nuclei", ntot);
88  CreateTable(ntot);
89 
90  KVChargeRadius* cr = 0;
91  ntot = 0;
92  while (fr->IsOK()) {
93 
94  fr->ReadLine(" ");
95  if (fr->GetCurrentLine().IsNull()) {
96  break;
97  }
98  else if (fr->GetNparRead() == 0) {
99  break;
100  }
101  else if (fr->GetReadPar(0).BeginsWith("//")) { }
102  else {
103  Double_t val = fr->GetDoubleReadPar(2);
104  Double_t eval = fr->GetDoubleReadPar(3);
105 
106  CreateElement(ntot);
107  cr = (KVChargeRadius*)GetCurrent();
108 
109  cr->SetValue(val);
110  cr->SetError(eval);
111 
112  ntot += 1;
113  }
114 
115  }
116 
117  //Info("Initialize","table initialised correctly for %d nuclei", ntot);
118  fr->CloseFile();
119  delete fr;
120 
121 }
122 
123 
124 
126 
128 {
129 
130  return (KVChargeRadius*)GetData(zz, aa);
131 
132 }
133 
134 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
double Double_t
R__EXTERN TEnv * gEnv
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:538
Table of charge radius information for nuclei.
KVChargeRadius * GetChargeRadius(Int_t zz, Int_t aa) const
virtual ~KVChargeRadiusTable()
Destructor.
Simple class for storing charge radius information of nuclei.
void SetError(Double_t err)
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
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)
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,...)