KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVSpinParityTable.cpp
1//Created by KVClassFactory on Wed Feb 23 16:10:14 2011
2//Author: bonnet
3
4#include "KVSpinParityTable.h"
5#include "KVFileReader.h"
6#include "TEnv.h"
7#include "KVBase.h"
8
10
11
12
13
15
17{
18 // Default constructor
19 init();
20}
21
22
23
26
28{
29 // Destructor
30 init();
31}
32
33
34
36
38{
39 SetName("SpinParity");
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 //Lecture du nombre de noyaux a enregistrer
68
69 while (fr->IsOK()) {
70
71 fr->ReadLine(" ");
72 if (fr->GetCurrentLine().IsNull()) {
73 break;
74 }
75 else if (fr->GetNparRead() == 0) {
76 break;
77 }
78 else if (fr->GetReadPar(0).BeginsWith("//")) {
79
81 kcomments += "\n";
82
83 }
84 else {
85 Int_t zz = fr->GetIntReadPar(0);
86 Int_t nn = fr->GetIntReadPar(1);
87 GiveIndexToNucleus(zz, nn + zz, ntot);
88 ntot += 1;
89 }
90 }
91
92 if (!fr->PreparForReadingAgain()) return;
93 CreateTable(ntot);
94
95 KVSpinParity* lf = 0;
96 ntot = 0;
97 while (fr->IsOK()) {
98 fr->ReadLine(" ");
99 if (fr->GetCurrentLine().IsNull()) {
100 break;
101 }
102 else if (fr->GetNparRead() == 0) {
103 break;
104 }
105 else if (fr->GetReadPar(0).BeginsWith("//")) { }
106 else {
107
108 CreateElement(ntot);
109 lf = (KVSpinParity*)GetCurrent();
110 Double_t spin = -555;
111 Double_t parity = 0;
112 KVString sp = fr->GetReadPar(2);
113 if (sp == "NA") {
114 lf->SetMeasured(kFALSE);
115 lf->SetMultiple(kFALSE);
116 }
117 else if (sp.BeginsWith("(") || sp.Contains(",")) {
118
119 if (sp.Contains("(")) {
120 sp.ReplaceAll("(", "");
121 sp.ReplaceAll(")", "");
122 lf->SetMeasured(kFALSE);
123 }
124
125 KVString stmp = sp;
126 if (sp.Contains(",")) {
127 lf->SetMultiple(kTRUE);
128 sp.Begin(",");
129 stmp = sp.Next();
130 }
131 else {
132 lf->SetMultiple(kFALSE);
133 }
134 //traitement de la parite
135 if (stmp.Contains("-")) {
136 parity = -1;
137 stmp.ReplaceAll("-", "");
138 }
139 else if (stmp.Contains("+")) {
140 parity = 1;
141 stmp.ReplaceAll("+", "");
142 }
143
144 //traitement du spin
145 if (stmp.Contains("/")) {
146 //fraction
147 stmp.Begin("/");
148 Int_t num = stmp.Next().Atoi();
149 Int_t den = stmp.Next().Atoi();
150 spin = Double_t(num) / den;
151 }
152 else {
153 //valeur entiere
154 spin = stmp.Atof();
155 }
156 }
157 else {
158 lf->SetMultiple(kFALSE);
159 lf->SetMeasured(kTRUE);
160
161 //traitement de la parite
162 if (sp.Contains("-")) {
163 sp.ReplaceAll("-", "");
164 parity = -1;
165 }
166 if (sp.Contains("+")) {
167 sp.ReplaceAll("+", "");
168 parity = 1;
169 }
170
171 //traitement du spin
172 if (sp.Contains("/")) {
173 sp.Begin("/");
174 Int_t num = sp.Next().Atoi();
175 Int_t den = sp.Next().Atoi();
176 spin = Double_t(num) / den;
177 }
178 else {
179 spin = sp.Atof();
180 }
181 }
182
183 if (parity != 0)
184 spin *= parity;
185 lf->SetValue(spin);
186
187 ntot += 1;
188 }
189
190 }
191
192 fr->CloseFile();
193 delete fr;
194
195}
196
197
198
200
202{
203
204 return (KVSpinParity*)GetData(zz, aa);
205
206}
207
208
209
214
216{
217 // Returns bit of the registered KVNuclData object associated to the couple (Z,A).
218 // indicating if the nucleus as multiple possible values or a certain one
219 // returns kFALSE if no such object is present
220
221 KVSpinParity* nd = 0;
222 if ((nd = GetSpinParity(zz, aa)))
223 return nd->IsMultiple();
224 else
225 return kFALSE;
226
227
228}
229
230
int Int_t
bool Bool_t
constexpr Bool_t kFALSE
double Double_t
constexpr 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.
KVString GetCurrentLine()
Bool_t PreparForReadingAgain()
ReadStatus ReadLine(const KVString &pattern="")
Int_t GetIntReadPar(Int_t pos) const
Int_t GetNparRead() const
Bool_t IsOK()
KVString GetReadPar(Int_t pos) const
Bool_t OpenFileToRead(const KVString &filename)
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)
void SetMeasured(Bool_t measured)
Definition KVNuclData.h:56
Table of spin parity values for nuclear levels.
Bool_t IsMultiple(Int_t zz, Int_t aa) const
virtual ~KVSpinParityTable()
Destructor.
KVSpinParity * GetSpinParity(Int_t zz, Int_t aa) const
virtual void Initialize()
Spin parity assignment of nuclear levels.
Bool_t IsMultiple() const
void SetMultiple(Bool_t multiple)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73
void Begin(TString delim) const
Definition KVString.cpp:565
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition KVString.cpp:695
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetTitle(const char *title="")
const char * GetName() const override
virtual void SetName(const char *name)
virtual void Error(const char *method, const char *msgfmt,...) const
Int_t Atoi() const
Double_t Atof() const
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t IsNull() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
void init()
ClassImp(TPyArg)