GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GammaLink.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_GammaLink
24 #include "GammaLink.h"
25 #endif
26 
27 #ifndef ROOT_TString
28 #include <TString.h>
29 #endif
30 
31 #include <iostream>
32 #include <iomanip>
33 
34 using namespace std;
35 using namespace Gw;
36 
37 Int_t GammaLink::fgMaxAttributes = 6;
38 
39 //__________________________________________________________
40 GammaLink::GammaLink()
41  : Link(),
42  fAttrLabel("504")
43 {
44  fEnergy.Set(0,0); fMixing.Set(0,0); fConv.Set(0.0,0.0); fEM = '-'; fLambda = 0;
45  fLog.GetProcessName() = "GammaLink";
46 }
47 
48 //__________________________________________________________
49 GammaLink::GammaLink(const GammaLink &link) : Link(link)
50 {
51  fEM = link.fEM;
52  fLambda = link.fLambda;
53  fEnergy = link.fEnergy;
54  fMixing = link.fMixing;
55  fConv = link.fConv;
56 }
57 
58 //__________________________________________________________
60 {
61  if (this == &link) return *this;
62  Link::operator=(link);
63 
64  fEM = link.fEM;
65  fLambda = link.fLambda;
66  fEnergy = link.fEnergy;
67  fMixing = link.fMixing;
68  fConv = link.fConv;
69 
70  return *this;
71 }
72 
73 //__________________________________________________________
75 {
76 }
77 
78 //__________________________________________________________
79 const char* GammaLink::GetLabel0()
80 {
81  Int_t idx = fAttrLabel[0]-'0';
82 
83  TString tmp(GetAttr(idx));
84  Int_t pos = tmp.Last(' ');
85  if (pos != -1)
86  tmp[pos] = '\0';
87 
88  return Form("%s", tmp.Data());
89 }
90 
91 //__________________________________________________________
92 const char* GammaLink::GetLabel1()
93 {
94  Int_t idx = fAttrLabel[1]-'0';
95 
96  TString tmp(GetAttr(idx));
97  Int_t pos = tmp.Last(' ');
98  if (pos != -1)
99  tmp[pos] = '\0';
100 
101  return Form("%s", tmp.Data());
102 }
103 
104 //__________________________________________________________
105 const char* GammaLink::GetLabel2()
106 {
107  Int_t idx = fAttrLabel[2]-'0';
108 
109  TString tmp(GetAttr(idx));
110  Int_t pos = tmp.Last(' ');
111  if (pos != -1)
112  tmp[pos] = '\0';
113 
114  return Form("%s", tmp.Data());
115 }
116 
117 //__________________________________________________________
118 void GammaLink::SetAttrLabel(const char *s)
119 {
120  fLog.SetProcessMethod("SetAttrLabel(const char* )");
121 
122  TString st = s; Short_t end = (st.Length() < fgkMaxLinkLabel) ? st.Length(): fgkMaxLinkLabel;
123 
124  for( Short_t i = 0; i < end; ++i ) {
125  if (st.CountChar(st[i]) > 1 && st[i]-'0' >= fgkMaxLinkLabel) {
126  fAttrLabel = "504";
127  fLog << warning << Form("Unambiguous position label pattern, set to %s", fAttrLabel.Data()) << nline;
128  return;
129  }
130  }
131  fLog << dolog;
132 
133  fAttrLabel = s;
134 }
135 
136 //__________________________________________________________
137 const char* GammaLink::GetAttr(Int_t idx)
138 {
139 
140  switch (idx) {
141  case 0:
142  return GetAttr0();
143  case 1:
144  return GetAttr1();
145  case 2:
146  return GetAttr2();
147  case 3:
148  return GetAttr3();
149  case 4:
150  return GetAttr4();
151  case 5:
152  return GetAttr5();
153  default:
154  fLog.SetProcessMethod("GetAttr(Int_t )");
155  fLog << warning << "wrong index, set to zero" << dolog;
156  return GetAttr0();
157  }
158 }
159 
160 //__________________________________________________________
161 void GammaLink::SetGamma(const char* energy, const char* multipolarity,
162  const char* mixing, const char* conversion,
163  const char* strength, const char* tau)
164 {
165  fAttr0 = energy; fAttr1 = multipolarity; fAttr2 = mixing; fAttr3 = conversion; fAttr4 = strength; fAttr5 = tau;
166  fEnergy.Set(energy); SetEM(multipolarity); fMixing.Set(mixing); fConv.Set(conversion); GetStrength().Set(strength); GetTau().Set(tau);
167 
168 
169  for (Int_t i = 0; i < 3; ++i) {
170  Int_t idx = fAttrLabel[i] - '0';
171  TString tmp;
172 
173  switch (idx) {
174  case 0:
175  tmp = energy;
176  break;
177  case 1:
178  tmp = multipolarity;
179  break;
180  case 2:
181  tmp = mixing;
182  break;
183  case 3:
184  tmp = conversion;
185  break;
186  case 4:
187  tmp = strength;
188  break;
189  case 5:
190  tmp = tau;
191  break;
192  }
193 
194  Int_t pos = tmp.Last(' ');
195  if (pos != -1)
196  tmp[pos] = '\0';
197 
198  SetLabel(tmp.Data(), i);
199  }
200 
201  SetPoints(GetX()[0]+(GetX()[2]-(GetX()[0]))/2.,GetX()[5]);
202 }
203 
204 //__________________________________________________________
205 void GammaLink::SetEM(const char *em)
206 {
207  TString s = em;
208 
210  if ( s.BeginsWith("E") ) { fEM = 'E'; fEM.SetInfo(InfoData::kKnown); }
211  if ( s.BeginsWith("M") ) { fEM = 'M'; fEM.SetInfo(InfoData::kKnown); }
212 
213  s.Remove(0,1);
214 
216 
217  fLambda = 0;
218 
219  for (Int_t i = 0; i < 10; i++ )
220  {
221  if (((TString)s[0]).Atoi() == i )
222  {
224  fLambda = i;
225  break;
226  }
227  }
228 
229  /* pour version de root ou IsAlnum est defini
230  if ( s.IsAlnum() == kFALSE ) {
231  fLambda.SetInfo(InfoData::kUnknown); fLambda = 0;
232  }
233  else {
234  UShort_t tmp; sprintf(s.Data(),"%d",&tmp);
235  fLambda.SetInfo(InfoData::kKnown); fLambda = tmp;
236  }
237  */
238 }
239 
240 //__________________________________________________________
241 void GammaLink::ls(Option_t* o) const
242 {
243 
244  TString opt = o; string sep1, sep2;
245 
246  if ( opt.Contains("header") ) std::cout<< " Gamma energy (keV), \t Intensity, \t Multipolarity, \t Conversion" << std::endl;
247 
248  sep1 = sep2 = "";
249  if ( fEnergy.IsData(InfoData::kTentative) ) { sep1 = '('; sep2 = ')'; }
250  if ( fEnergy.IsData(InfoData::kTheo) ) { sep1 = '['; sep2 = ']'; }
251  if ( fEnergy.IsData(InfoData::kAbout) ) { sep1 = '~'; sep2 = ""; }
252  cout << sep1 << "Energy: " << fEnergy.GetValue() << " <" << fEnergy.GetError() << ">" << sep2 << "\t" ;
253 
254  sep1 = sep2 = "";
255  if ( fStrength.IsData(InfoData::kTentative) ) { sep1 = '('; sep2 = ')'; }
256  if ( fStrength.IsData(InfoData::kTheo) ) { sep1 = '['; sep2 = ']'; }
257  if ( fStrength.IsData(InfoData::kAbout) ) { sep1 = '~'; sep2 = ""; }
258  cout << sep1 << "Strength: " << fStrength.GetValue() << " <" << fStrength.GetError() << ">" << sep2 << "\t" ;
259 
260  if ( fConv.GetValue() != 0 ) {
261  sep1 = sep2 = "";
262  if ( fConv.IsData(InfoData::kTentative) ) { sep1 = '('; sep2 = ')'; }
263  if ( fConv.IsData(InfoData::kTheo) ) { sep1 = '['; sep2 = ']'; }
264  if ( fConv.IsData(InfoData::kAbout) ) { sep1 = '~'; sep2 = ""; }
265  cout << sep1 << "Convertion: " << fConv.GetValue() << " <" << fConv.GetError() << ">" << sep2 << "\n" ;
266  }
267  else cout << endl;
268 
269  // if ( gDebug > 0 ) TLine::ls(o);
270 
271 // std::cout << "Gamma " << fEnergy.Get() << " " << fSpin << " " << fParity << std::endl;
272 }
273 
274 //__________________________________________________________
275 Int_t GammaLink::DoCascade(TSeqCollection &cas, Option_t */*opt*/)
276 {
277  cas.Add(this);
278  return 1;
279 }
280 
282 
283 
virtual Data_T GetError() const
return the error on the measured value
Definition: Measure.h:109
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
LogMessage & warning(LogMessage &)
LogMessage & nline(LogMessage &)
LogMessage & dolog(LogMessage &)
virtual std::string & GetProcessName()
To get the Process name.
Definition: GwLogMessage.h:224
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual void SetInfo(InfoData::EData)
to set some information about this data
Definition: InfoData.h:83
virtual void SetProcessMethod(const char *)
To set the current method.
Data_T GetValue() const
get the value, cannot be overloaded
Definition: Data.h:114