GammaWare  Head Version for release 0.9
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnsdfLevelSchemeReader.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.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_EnsdfLevelSchemeReader
24 #include "EnsdfLevelSchemeReader.h"
25 #endif
26 
27 // root include's
28 
29 
30 #ifndef ROOT_TStyle
31 #include <TStyle.h>
32 #endif
33 
34 #ifndef ROOT_TObjArray
35 #include <TObjArray.h>
36 #endif
37 
38 #ifndef ROOT_TList
39 #include <TList.h>
40 #endif
41 
42 // gw include's
43 #ifndef GW_ENSDF_H
44 #include "ENSDF.h"
45 #endif
46 
47 #ifndef GW_LEVELSCHEME_H
48 #include "LevelScheme.h"
49 #endif
50 
51 #ifndef GW_NUCLEARLEVEL_H
52 #include "NuclearLevel.h"
53 #endif
54 
55 #ifndef GW_XGAMMALINK_H
56 #include "XGammaLink.h"
57 #endif
58 
59 
60 using namespace Gw;
61 
62 //__________________________________________________________
63 EnsdfLevelSchemeReader::EnsdfLevelSchemeReader(const char* filename, Option_t* opt)
64 : BaseLevelSchemeReader(filename, opt)
65 {
66  //Default Constructor
67  fLog.GetProcessName() = "EnsdfLevelSchemeReader";
68 }
69 
70 //__________________________________________________________
72 {
73  // default destructor
74 }
75 
76 
77 //__________________________________________________________
78 TString EnsdfLevelSchemeReader::GetDsid()
79 {
80  TString dsid = fOptions.Data();
81 
82  if ( dsid.First(' ') > 0 ) { // at least two strings
83  dsid.Remove(0,dsid.First(' ')+1);
84  if ( dsid.Length() < 3 )
85  dsid = "ADOPTED LEVELS, GAMMAS";
86  } else {
87  dsid = "ADOPTED LEVELS, GAMMAS";
88  }
89  return dsid;
90 }
91 
92 //__________________________________________________________
93 TString EnsdfLevelSchemeReader::GetNuclide()
94 {
95  TString nuclide = fOptions.Data();
96 
97  if ( nuclide.First(' ') > 0 ) { // at least two strings
98  nuclide.Remove(nuclide.First(' '));
99  } else {
100  if (nuclide.Length() >= 5)
101  nuclide.Remove(5);
102  else
103  nuclide.Remove(nuclide.Length());
104  }
105  return nuclide;
106 }
107 
108 
109 //__________________________________________________________
111 {
112  Int_t ok = 1;
113  TString nuclide = GetNuclide();
114  TString dsid = GetDsid();
115 
116  fLog.SetProcessMethod("Check()");
117 
118  // open the file and check out if the dataset id exists
119  ENSDF ens; unsigned int idset = 0;
120  if ( ! ens.Open(fFileName.Data()) ) {
121  fLog << error << "Cannot open file " << fFileName.Data() << nline ;
122  ok = 0;
123  } else {
124  if ( (idset = ens.IsDataSet(nuclide.Data(),dsid.Data())) == 0 ) {
125  fLog << error << "Cannot find dataset " << fOptions.Data() << nline ;
126  ok = 0;
127  }
128  }
129 
130  // if ok, it reads the data set and build the level scheme.
131  Level *level; Cascade *cascade; Link *link;
132 
133  if ( ok == 1 ) { // a data set has been found, now the level scheme is built
134 
135  fLog << info << Form(" ---> Reading %s in dataset %s \n",nuclide.Data(),dsid.Data()) << nline ;
136 
137  // loop over the dataset and fill temporary collections.
138  char *record = ens.BlankRecord(); bool is_record = ens.FirstRecord(idset,record); Int_t line = -1;
139  while( is_record ) {
140 
141  // to count lines
142  line++;
143 
144  TString tmp;
145  tmp = "";
146  //
147  if ( (level = ens.GetLevel(record,tmp)) ) { // one new level
148  fLevel.Add( level );
149  // cout << " add level " << endl;
150  // level->ls();
151  // band treatment
152  if ( tmp.Length() > 0 && tmp[0] != ' ' ) {
153  // look for a cascade with a name Energy[tmp[0]]
154  TIter iter(&fBand); TObject *obj; TString cname;
155 
156  cname = "Energy"; cname += tmp[0]; cascade = 0x0;
157  while ( (obj = iter() ) ) {
158  if ( cname == obj->GetName() ) {
159  cascade = (Cascade *)obj; break;
160  }
161  }
162  if ( cascade == 0x0 ) { // doesn't exist yet
163  cascade = new Cascade();
164  cascade->SetName(cname.Data()); fBand.Add(cascade);
165  }
166  // modify the level graphical position
167  Int_t whichband = fBand.IndexOf(cascade);
168 
169  // levels belonging to this cascade are moved at another x position
170  Double_t width;
171  width = TMath::Abs(level->GetX2() - level->GetX1());
172 
173  if ( whichband % 2 == 0 ) { // on the left
174  level->SetX1(level->GetX1()-1.1*width*(1+whichband/2));
175  level->SetX2(level->GetX2()-1.1*width*(1+whichband/2));
176  }
177  else { // on the right
178  level->SetX1(level->GetX1()+1.1*width*(1+whichband/2));
179  level->SetX2(level->GetX2()+1.1*width*(1+whichband/2));
180  }
181 
182  cascade->Add( level );
183  // printf("Energy offset %s \n ",tmp.Data());
184  } // there is an unknown energy offset
185  if ( tmp.Length() > 1 && tmp[1] != ' ' ) {
186  // look for a cascade with a name Spin[tmp[0]]
187  TIter iter(&fBand); TObject *obj; TString cname;
188 
189  cname = "Spin"; cname += tmp[1]; cascade = 0x0;
190  while ( (obj = iter() ) ) {
191  if ( cname == obj->GetName() ) {
192  cascade = (Cascade *)obj; break;
193  }
194  }
195  if ( cascade == 0x0 ) { // doesn't exist yet
196  cascade = new Cascade();
197  cascade->SetName(cname.Data()); fBand.Add(cascade);
198  }
199  // modify the level graphical position
200  // NOT FOR SPIN OFFSET, ONLY FOR ENERGY OFFSET
201  //Int_t whichband = fBand.IndexOf(cascade);
202 
203  // levels belonging to this cascade are moved at another x position
204  //Double_t width;
205  //width = TMath::Abs(level->GetX2() - level->GetX1());
206 
207  //if ( whichband % 2 == 0 ) { // on the left
208  // level->SetX1(level->GetX1()-1.1*width*(1+whichband/2));
209  // level->SetX2(level->GetX2()-1.1*width*(1+whichband/2));
210  //}
211  //else { // on the right
212  // level->SetX1(level->GetX1()+1.1*width*(1+whichband/2));
213  // level->SetX2(level->GetX2()+1.1*width*(1+whichband/2));
214  //}
215  cascade->Add( level );
216  // printf("Spin offset %s \n ",tmp.Data());
217  } // there is an unknown spin offset
218  }
219 
220  if ( (link = ens.GetLink(record,tmp)) ) { // one new link
221 
222  // look for the initial & final level attached with this link
223  if ( fLevel.GetEntries() == 0 ) {
224  fLog << warning
225  << Form("Gamma with no initial level \n") << "\n from record at line " << line << nline ;
226  delete link;
227  }
228  else {
229  // last level is the initial level
230  NuclearLevel *initial, *final;
231  initial = (NuclearLevel*) fLevel.Last() ;
232 
233  link->SetIL( initial );
234  //cout << " add link " << endl;
235  //link->ls();
236  // Now look for the final level which gives an energy difference
237  // close to the gamma-ray energy
238  Float_t emin, eini, efin, egamma;
239 
240  egamma = ((GammaLink*)link)->GetEnergy().Get();
241  eini = initial->GetEnergy().Get();
242  emin = 2.0*egamma;
243 
244  //printf("gamma %f from level %f \n",egamma,eini);
245 
246  final = 0x0;
247  for (int i = 0; i < fLevel.GetEntries(); i++ ) { //
248 
249  final = (NuclearLevel*)fLevel.At(i);
250  if ( final == initial )
251  continue;
252 
253  efin = final->GetEnergy().GetValue();
254  if ( TMath::Abs(eini-efin-egamma) < emin ) {
255  link->SetFL( final );
256  link->SetPoints();
257  emin = TMath::Abs(eini-efin-egamma) ;
258  }
259  } // i
260  if ( link->GetFL() == 0x0 ) {
261  fLog << warning
262  << Form("Gamma [record at line %d] from level %f, does not have a final level",line,eini) << nline ;
263  delete link;
264  } else {
265  // fLog << warning << Form("Gamma ok %f not linked with final level",egamma) << nline ;
266  fLink.Add( link );
267  }
268  }
269  }
270  is_record = ens.NextRecord(idset,record);
271  } // ok
272 
273  delete [] record;
274 
275  } // if ok == 1
276 
277  fIsChecked = true;
278 
279  fLog << dolog;
280 
281  return ok;
282 }
283 
284 //__________________________________________________________
286 {
287  TString nuclide = GetNuclide();
288  TString dsid = GetDsid();
289 
290  fLog << info << Form(" ... Reading dataset %s %s DONE", nuclide.Data(), dsid.Data()) << dolog;
291  // set name and reference
292  levelScheme.SetName(nuclide.Data());
293  dsid.Prepend("From ENSDF dataset ");
294  levelScheme.SetReference(dsid.Data());
295 }
296 
297 
298 
A level Scheme.
Definition: LevelScheme.h:82
A BaseLevelSchemeReader class to read level scheme files.
virtual Int_t Check()
check file before imported level scheme
A cascade is a list of links.
Definition: Cascade.h:51
interface to ENSDF Evaluated Nuclear Structure Data File
LogMessage & error(LogMessage &)
LogMessage & warning(LogMessage &)
virtual void SetName(const Char_t *name)
set level scheme name.
Definition: LevelScheme.h:298
header file for a NuclearLevel
A nuclear level.
Definition: NuclearLevel.h:66
EnsdfLevelSchemeReader(const char *filename, Option_t *opt)
TString fFileName
name of level scheme file
LogMessage & nline(LogMessage &)
virtual unsigned int IsDataSet(const char *nuclide, const char *dsid="ADOPTED LEVELS, GAMMAS") const
look for a given data set
Definition: ENSDF.h:97
virtual bool Open(const char *fname)
Definition: ENSDF.h:93
virtual Link * GetLink(const char *, TString &)
to get a link from a record
Definition: ENSDF.cpp:53
Bool_t fIsChecked
flag for reading is ok
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
TObjArray fLevel
list of levels
virtual void FillLabels(LevelScheme &levelScheme)
fill labels
Measure< Float_t > & GetEnergy()
Definition: NuclearLevel.h:91
ENSDF: Interface between ENSDF files and the GammaWare Nuclear data related objects.
Definition: ENSDF.h:52
LogMessage & dolog(LogMessage &)
virtual Level * GetLevel(const char *, TString &)
to get a NuclearLevel from a Level record
Definition: ENSDF.cpp:85
header file for a LevelScheme
virtual bool NextRecord(unsigned int, char *)
to get dataset's records
Definition: BaseENSDF.cpp:133
virtual std::string & GetProcessName()
To get the Process name.
Definition: GwLogMessage.h:224
virtual void SetX2(Double_t)
All labels are shifted when moving a level to another position.
Definition: Level.cpp:273
virtual void SetX1(Double_t)
All labels are shifted when moving a level to another position.
Definition: Level.cpp:262
virtual void SetName(const Char_t *name)
to set only the cascade's name
Definition: Cascade.h:183
TObjArray fLink
list of links
virtual void SetReference(const Char_t *)
set level scheme reference.
Definition: LevelScheme.h:299
virtual void SetProcessMethod(const char *)
To set the current method.
LogMessage fLog
log message
static char * BlankRecord()
returns a proper empty record. It is the charge of the user to delete it
Definition: BaseENSDF.h:106
TObjArray fBand
list of cascades
virtual bool FirstRecord(unsigned int which, char *record)
to init the records reading
Definition: BaseENSDF.cpp:157
Base class describing a general level.
Definition: Level.h:53