GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ENSDF.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef GW_ENSDF_H
24 #include "ENSDF.h"
25 #endif
26 
27 #ifndef GW_XGAMMALINK_H
28 #include "XGammaLink.h"
29 #endif
30 
31 #ifndef GW_NUCLEARLEVEL_H
32 #include "NuclearLevel.h"
33 #endif
34 
35 #ifndef GW_LEVELSCHEME_H
36 #include "LevelScheme.h"
37 #endif
38 
39 #include <iostream>
40 #include <sstream>
41 
42 using namespace std;
43 using namespace Gw;
44 
46 
47 ENSDF::ENSDF()
48 {
49 }
50 
51 ENSDF::~ENSDF() { ; }
52 
53 Link *ENSDF::GetLink(const char *record, TString &/*opt*/)
54 {
55  string s, tmp; Link *newlink;
56 
57  newlink = NULL; s = "";
58  if ( IsRecord(record,"GAMMA") ) {
59  if ( GetCC(record) == 0 ) {
60  newlink = new GammaLink;
61  } else {
62  newlink = new XGammaLink;
63  ((GammaLink *)newlink)->GetConversion().Set(GetCC(record), GetDCC(record));
64  }
65 
66  // possible offset in energy is ignored ..
67  tmp = "";
68  ((GammaLink *)newlink)->GetEnergy().Set(GetE(record,tmp), GetDE(record));
69  if ( tmp.find("?") != string::npos )
70  { ((GammaLink *)newlink)->GetEnergy().SetInfo(InfoData::kTentative);}
71 
72  tmp = "";
73  newlink->GetStrength().Set(GetRI(record,tmp), GetDRI(record));
74  if ( tmp.find("?") != string::npos )
75  { newlink->GetStrength().SetInfo(InfoData::kTentative);}
76 
77  if ( record[77] == 'C' || record[77] == '?' ) {
78  ((GammaLink *)newlink)->GetEnergy().SetInfo(InfoData::kTentative);
79  }
80  } // if gamma
81 
82  return newlink;
83 }
84 
85 Level *ENSDF::GetLevel(const char *record, TString &opt)
86 {
87  static char spinoffset[] = "JKLMNOPQRSTUVWXYZABCDEFGHI";
88 
89  string s,tmp1, tmp2; NuclearLevel *lev;
90 
91  lev = NULL; s = "";
92  if ( IsRecord(record,"LEVEL") ) { // a new level
93 
94  lev = new NuclearLevel();
95 
96  // half-life and energy related
97  Float_t unit_t;
98  unit_t = 0.0;
99  lev->GetT().Set(GetT(record,unit_t,tmp1),GetDT(record));
100  if ( tmp1.find("?") != string::npos )
101  { lev->GetT().SetInfo(InfoData::kTentative); } // tentative
102 
103  // printf("Energy %f \n",GetE(record,tmp1));
104  lev->GetEnergy().Set(GetE(record,tmp1),GetDE(record));
105  // lev->GetEnergy().Set(10.0,GetDE(record));
106  if ( tmp1.find("?") != string::npos ) {
107  lev->GetE().SetInfo(InfoData::kTentative);
108  lev->SetStyle(Level::kTentative);
109  tmp1.erase(tmp1.find("?"),1);
110  }
111  else {
112  lev->GetE().SetInfo(InfoData::kKnown);
113  lev->SetStyle(Level::kKnown);
114  }
115  // lev->ls();
116  s = tmp1; // copy the possible offset in s
117 
118  // spin-parity related
119  // supposed to be known since they are about to be read ..
120  lev->GetSpin().SetInfo(InfoData::kKnown);lev->GetParity().SetInfo(InfoData::kKnown);
121 
122  // the spin-parity field is complexe to be decoded !!!
123  // What is done here:
124  //
125 
126  tmp1 = GetJPI(record);
127  if (tmp1.find("NATURAL/UNNATURAL") != string::npos) {
128  if ( gDebug == 1) printf("NATURAL/UNNATURAL J in ENSDF::GetLevel() \n");
129  lev->GetSpin().SetInfo(InfoData::kUnknown);
130  lev->GetParity().SetInfo(InfoData::kUnknown);
131  } // I don't know what this means !
132  if (tmp1.find("NOT") != string::npos) {
133  if ( gDebug == 1) printf("NOT J in ENSDF::GetLevel()\n");
134  lev->GetSpin().SetInfo(InfoData::kUnknown);
135  lev->GetParity().SetInfo(InfoData::kUnknown);
136  } // I don't know what this means !
137 
138  // check out if there is an offset. if true, the corresponding
139  // character is added to the s string.
140  size_t l;
141  for (int i = 0; i < 26; i++) {
142  // WARNING tmp2 = spinoffset[i] + "+" doesn't work !
143  tmp2 = spinoffset[i]; tmp2 += "+" ;
144  if ( (l = tmp1.find(tmp2,0)) != string::npos )
145  { s += spinoffset[i]; tmp1.erase(l,2); break; }
146  if ( (l = tmp1.find(spinoffset[i],0)) != string::npos )
147  { s += spinoffset[i]; tmp1.erase(l,1); break; }
148  }
149  // now determine the parity part.
150  if ( tmp1.find("-") != string::npos && tmp1.find("+") != string::npos ) {
151  if ( gDebug == 1) printf(" - and + in ENSDF::GetLevel()\n");
152  lev->GetParity().SetInfo(InfoData::kUnknown); // both value => Unknown !
153  }
154  else { // only one or no value.
155  lev->GetParity().SetInfo(InfoData::kUnknown);
156  lev->SetLabel("",1);
157  lev->SetColor(Level::kUnknown);
158  if ( tmp1.find("-") != string::npos ) {
159  lev->GetParity().Set(Parity::kMinus);
160  lev->GetParity().SetInfo(InfoData::kKnown);
161  lev->SetLabel("-",1);
162  lev->SetColor(Level::kMinus);
163  if ( gDebug == 1) printf(" - in ENSDF::GetLevel()\n");
164  }
165  if ( tmp1.find("-)") != string::npos ) {
166  lev->GetParity().Set(Parity::kMinus);
167  lev->GetParity().SetInfo(InfoData::kTentative);
168  lev->SetLabel("(-)",1);
169  lev->SetColor(Level::kMinus);
170  if ( gDebug == 1) printf(" -? in ENSDF::GetLevel()\n");
171  }
172  if ( tmp1.find("+") != string::npos ) {
173  lev->GetParity().Set(Parity::kPlus);
174  lev->GetParity().SetInfo(InfoData::kKnown);
175  lev->SetLabel("+",1);
176  lev->SetColor(Level::kPlus);
177  if ( gDebug == 1) printf(" + in ENSDF::GetLevel()\n");
178  }
179  if ( tmp1.find("+)") != string::npos ) {
180  lev->GetParity().Set(Parity::kPlus);
181  lev->GetParity().SetInfo(InfoData::kTentative);
182  lev->SetLabel("(+)",1);
183  lev->SetColor(Level::kPlus);
184  if ( gDebug == 1) printf(" +? in ENSDF::GetLevel()\n");
185  }
186  }
187  // now keep only the first assumption in case of several possibilities
188  // case 2, 3, 4, and 6 in the ENSDF doc.
189  if ( gDebug > 0 )cout << " Multiple values of spin and/or parity "<< tmp1 << endl;
190  bool multiple = false; l = string::npos;
191  if ( (l = tmp1.find("OR")) != string::npos ) { tmp1.erase(l); multiple = true;}
192  if ( (l = tmp1.find(",")) != string::npos ) { tmp1.erase(l); multiple = true;}
193  if ( (l = tmp1.find("AND")) != string::npos ) { tmp1.erase(l); multiple = true;}
194  if ( (l = tmp1.find("&")) != string::npos ) { tmp1.erase(l); multiple = true;}
195  if ( (l = tmp1.find("TO")) != string::npos ) { tmp1.erase(l); multiple = true;}
196  if ( (l = tmp1.find(":")) != string::npos ) { tmp1.erase(l); multiple = true;}
197  if ( (l = tmp1.find("AP")) != string::npos ) { tmp1.erase(l,2); multiple = true;}
198  if ( (l = tmp1.find("LE")) != string::npos ) { tmp1.erase(l,2); multiple = true;}
199  if ( (l = tmp1.find("GE")) != string::npos ) { tmp1.erase(l,2); multiple = true;}
200  if ( multiple ) {
201  if ( gDebug > 0 ) cout << " Multiple values of spin and/or parity "<< tmp1 << endl;
202  lev->GetSpin().SetInfo(InfoData::kTentative);
203  } // tentative value for spin since several values are proposed
204 
205  // !Unknown means there might be something to decode
206  if ( ! lev->GetSpin().IsData(InfoData::kUnknown) ) {
207  if ( (l = tmp1.find("(")) != string::npos ) {
208  tmp1.erase(l,1); lev->GetSpin().SetInfo(InfoData::kTentative);
209  }
210  if ( (l = tmp1.find(")")) != string::npos ) {
211  tmp1.erase(l,1); lev->GetSpin().SetInfo(InfoData::kTentative);
212  }
213 
214  // now try to read the spin value
215  Int_t n, d;
216 
217  d = 1;
218  if ( (l = tmp1.find("/2")) != string::npos ) {
219  tmp1.erase(l,2); d = 2;
220  }
221  istringstream spinstring(tmp1); spinstring >> n ;
222  if ( spinstring.fail() ) { // cannot read the value for some reason
223  lev->GetSpin().Set(0);
224  lev->GetSpin().SetInfo(InfoData::kUnknown);
225  }
226  else {
227  lev->GetSpin().Set(n,d);
228 
229  }
230  } // spin decoding
231 
232  // drawing part related
233  lev->SetY1(lev->GetEnergy().GetValue());
234  lev->SetX1(-50); lev->SetX2(50);
235  }
236 
237  opt = s.data(); return lev;
238 }
239 
240 void ENSDF::ls(std::ostream &/*out*/) const
241 {
242  BaseENSDF::ls(cout);
243 }
244 
245 void ENSDF::test()
246 {
247  TString tmp;
248 
249  char *record = BlankRecord();
250 
251  Open("DY_ENSDF.ens"); BaseENSDF::ls(cout);
252 
253  unsigned int idset; bool ok;
254 
255  idset = IsDataSet("152DY");
256  if ( idset > 0 ) {
257  ok = FirstRecord(idset,record);
258  while( ok ) {
259  if ( IsRecord(record,"LEVEL") ) {
260  GetLevel(record,tmp)->ls();
261  }
262  if ( IsRecord(record,"GAMMA") ) {
263  //GetLink(record,tmp)->ls();
264  }
265  ok = NextRecord(idset,record);
266  }
267  }
268  else { printf("Cannot find data set in test \n "); }
269 
270  Close();
271 
272  delete record;
273 }
274 
275 
276 
printf("******************************************************************** \n")
virtual void SetColor(EDefaultColor color)
Set color.
Definition: Level.cpp:107
ClassImp(ENSDF)
virtual void Set(Data_T data)
set the measure and its error (default err=0)
Definition: Measure.h:66
virtual bool IsData(UShort_t) const
to get some information about this data
Definition: InfoData.h:82
void Set(Int_t n, Int_t d=1)
To set the spin.
Definition: Spin.cpp:124
interface to ENSDF Evaluated Nuclear Structure Data File
header file for a NuclearLevel
A nuclear level.
Definition: NuclearLevel.h:66
Parity & GetParity()
get the parity and modify it if it is needed
Definition: NuclearLevel.h:87
Measure< Float_t > & GetEnergy()
Definition: NuclearLevel.h:91
Measure< Float_t > & GetE()
to get the energy and modify it if it is needed
Definition: NuclearLevel.h:90
ENSDF: Interface between ENSDF files and the GammaWare Nuclear data related objects.
Definition: ENSDF.h:52
void Set(Parity::EParity)
Definition: Parity.h:77
header file for a LevelScheme
virtual void SetX2(Double_t)
All labels are shifted when moving a level to another position.
Definition: Level.cpp:273
virtual void SetY1(Double_t)
All labels are shifted when moving a level to another position.
Definition: Level.cpp:284
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual void SetLabel(const char *, Int_t)
to set labels
Definition: Level.cpp:204
virtual void SetX1(Double_t)
All labels are shifted when moving a level to another position.
Definition: Level.cpp:262
Spin & GetSpin()
to get the spin and modify it if it is needed
Definition: NuclearLevel.h:84
virtual void SetInfo(InfoData::EData)
to set some information about this data
Definition: InfoData.h:83
Measure< Float_t > & GetT()
Definition: NuclearLevel.h:94
virtual void SetStyle(EDefaultStyle style)
Set style.
Definition: Level.cpp:99
Data_T GetValue() const
get the value, cannot be overloaded
Definition: Data.h:114
Base class describing a general level.
Definition: Level.h:53