GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Cascade.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 #include <iostream>
24 
25 #ifndef ROOT_TGraphErrors
26 #include "TGraphErrors.h"
27 #endif
28 
29 #ifndef ROOT_TMath
30 #include "TMath.h"
31 #endif
32 
33 #ifndef ROOT_TPad
34 #include "TPad.h"
35 #endif
36 
37 #ifndef ROOT_TString
38 #include <TString.h>
39 #endif
40 
41 #ifndef Gw_Cascade
42 #include "Cascade.h"
43 #endif
44 
45 #ifndef Gw_Link
46 #include "Link.h"
47 #endif
48 
49 #ifndef Gw_NuclearLevel
50 #include "NuclearLevel.h"
51 #endif
52 
53 using namespace Gw;
54 using namespace std;
55 
57 
58 const Int_t Cascade::fgkMaxColor = 2;
59 const Int_t Cascade::fgkMaxStyle = 2;
60 Float_t Cascade::fgDefaultLabelSize = 0.03;
61 Style_t Cascade::fgDefaultStyle[fgkMaxStyle] = {1, 2};
62 Color_t Cascade::fgDefaultColor[fgkMaxColor] = {1, 4};
63 
64 //__________________________________________________________
66  : TList(),
67  fName(0,0,""),
68  fType(0,0,"ND"),
69  fDefaultStyle(kKnown),
70  fDefaultColor(kDefault),
71  fIsSelected(false),
72  fIsVisible(true),
73  fLog("Cascade"),
74  fXName(0.0),
75  fYName(0.0)
76 {
77  SetOwner(kFALSE);
78  fName.SetTextAlign(22);
79  fName.SetTextColor(1);
80  fName.SetTextSize(fgDefaultLabelSize);
81  fType.SetTextAlign(22);
82 }
83 
84 //__________________________________________________________
86 {
87 
88 }
89 
90 //__________________________________________________________
91 TLatex& Cascade::GetLatex(Option_t *opt)
92 {
93  TString o = opt;
94  if ( o.Contains("name") ) return fName;
95  else return fType;
96 }
97 
98 //__________________________________________________________
99 void Cascade::SetLabels(const Char_t* name, const Char_t* type, Double_t x, Double_t y)
100 {
101  fType.SetTitle(type);
102  if (x != 0 && y != 0)
103  fName.SetText(x, y, name);
104  else
105  fName.SetTitle(name);
106 }
107 
108 //__________________________________________________________
109 void Cascade::Paint(Option_t* opt)
110 {
111  // paint
112  fName.Paint(opt);
113 }
114 
115 //__________________________________________________________
116 void Cascade::Draw(Option_t* opt)
117 {
118  // draw
119  fName.Draw(opt);
120  AppendPad(opt);
121 }
122 
123 //__________________________________________________________
124 void Cascade::SetVisible(Bool_t visu)
125 {
126  fIsVisible = visu;
127 
128  TIter next(this);
129 
130  Link* link;
131  while ( (link = (Link*)next()) ){
132  if ( IsVisible() ) {
133  link->SetVisible();
134  link->GetIL()->SetVisible();
135  link->GetFL()->SetVisible();
136  } else {
137  link->SetUnvisible();
138  link->GetIL()->SetUnvisible();
139  link->GetFL()->SetUnvisible();
140  }
141  }
142 }
143 
144 //__________________________________________________________
145 Int_t Cascade::DistancetoPrimitive(Int_t px, Int_t py)
146 {
147  Int_t d = fName.DistancetoPrimitive(px, py);
148  return d;
149 }
150 
151 
152 //__________________________________________________________
153 void Cascade::ExecuteEvent(Int_t event, Int_t px, Int_t py)
154 {
155  fName.ExecuteEvent(event, px, py);
156 }
157 
158 
159 //__________________________________________________________
160 void Cascade::ls(Option_t* /*opt*/) const
161 {
162  for (Int_t i = 0; i < GetEntries(); ++i) {
163  cout << Form("Link # %d", i) << endl;
164  Link* link = static_cast<Link*> ( At(i) );
165  link->ls();
166  }
167 }
168 
169 //__________________________________________________________
170 TGraphErrors* Cascade::DoJ1() const
171 {
172 
173  fLog.SetProcessMethod("DoJ1()");
174 
175  Float_t j1[GetEntries()];
176  Float_t deltaJ1[GetEntries()];
177  Float_t omega[GetEntries()];
178  Float_t deltaOmega[GetEntries()];
179  Int_t nPoints = 0;
180 
181  for (Int_t i = 0; i < GetEntries(); ++i ) {
182  Link* link1 = static_cast<Link*> ( At(i) );
183  NuclearLevel* level1 = dynamic_cast<NuclearLevel*>( link1->GetFL() );
184  NuclearLevel* level2 = dynamic_cast<NuclearLevel*>( link1->GetIL() );
185 
186  if (level1 == 0x0 || level2 == 0x0) {
187  fLog << error << "Energy and/or Spin not defined for these levels " << dolog;
188  return 0x0;
189  }
190 
191 
192  Float_t E1 = level1->GetEnergy().Get();
193  Float_t E2 = level2->GetEnergy().Get();
194  Float_t deltaE1 = level1->GetEnergy().GetError();
195  Float_t deltaE2 = level2->GetEnergy().GetError();
196 
197  Float_t deltaE = TMath::Abs( E2 - E1);
198  if (deltaE == 0) {
199  fLog << warning << "Delta E is null" << nline;
200  continue;
201  }
202 
203  if (level2->GetSpin().Get() == 0 || level1->GetSpin().Get() == 0) {
204  fLog << warning << "Spin I is null" << nline;
205  continue;
206  }
207 
208  Float_t deltaI = TMath::Abs( level2->GetSpin().Get() - level1->GetSpin().Get() );
209  if (deltaI == 0) {
210  fLog << warning << "Delta I is null" << nline;
211  continue;
212  }
213 
214 
215  j1[nPoints] = deltaI/deltaE*level1->GetSpin().Get();
216  omega[nPoints] = TMath::Abs( E2 - E1 )/deltaI;
217 
218  deltaJ1[nPoints] = TMath::Sqrt( (deltaE1/E1)*(deltaE1/E1) + (deltaE2/E2)*(deltaE2/E2) );
219 
220  deltaOmega[nPoints] = TMath::Sqrt( (deltaE1/E1)*(deltaE1/E1) + (deltaE2/E2)*(deltaE2/E2) );
221  nPoints++;
222  }
223 
224  fLog << dolog;
225 
226  if (nPoints != 0)
227  return new TGraphErrors(nPoints, omega, j1, deltaOmega, deltaJ1);
228  else
229  return 0x0;
230 
231 }
232 
233 //__________________________________________________________
234 TGraphErrors* Cascade::DoJ2() const
235 {
236 
237  fLog.SetProcessMethod("DoJ2()");
238 
239  Float_t j2[GetEntries()-1];
240  Float_t deltaJ2[GetEntries()-1];
241  Float_t omega[GetEntries()-1];
242  Float_t deltaOmega[GetEntries()-1];
243  Int_t nPoints = 0;
244 
245  for (Int_t i = 0; i < GetEntries() - 1; ++i ) {
246  Link* link1 = static_cast<Link*> ( At(i) );
247  Link* link2 = static_cast<Link*> ( At(i+1) );
248  NuclearLevel* level1 = dynamic_cast<NuclearLevel*>( link1->GetFL() );
249  NuclearLevel* level2 = dynamic_cast<NuclearLevel*>( link1->GetIL() );
250  NuclearLevel* level3 = dynamic_cast<NuclearLevel*>( link2->GetIL() );
251 
252  if (level1 == 0x0 || level2 == 0x0 || level3 == 0x0) {
253  fLog << error << "Energy and/or Spin not defined for these levels " << dolog;
254  return 0x0;
255  }
256 
257  Float_t E1 = level1->GetEnergy().Get();
258  Float_t E2 = level2->GetEnergy().Get();
259  Float_t E3 = level3->GetEnergy().Get();
260  Float_t deltaE1 = level1->GetEnergy().GetError();
261  Float_t deltaE2 = level2->GetEnergy().GetError();
262  Float_t deltaE3 = level3->GetEnergy().GetError();
263 
264 
265  Float_t deltaE = TMath::Abs( E1 - 2*E2 + E3);
266  if (deltaE == 0) {
267  fLog << warning << "Delta E is null" << dolog;
268  continue;
269  }
270 
271  if (level2->GetSpin().Get() == 0 || level1->GetSpin().Get() == 0) {
272  fLog << warning << "Spin I is null" << nline;
273  continue;
274  }
275 
276 
277  Float_t deltaI = TMath::Abs( level1->GetSpin().Get() - level3->GetSpin().Get() );
278  if (deltaI == 0) {
279  fLog << warning << "Delta I is null" << nline ;
280  continue;
281  }
282 
283  j2[nPoints] = deltaI/deltaE;
284  omega[nPoints] = TMath::Abs( E1 - E3 )/deltaI;
285 
286  deltaJ2[nPoints] = TMath::Sqrt( (deltaE1/E1)*(deltaE1/E1) + 4*(deltaE2/E2)*(deltaE2/E2)
287  + (deltaE3/E3)*(deltaE3/E3) );
288 
289  deltaOmega[nPoints] = TMath::Sqrt( (deltaE1/E1)*(deltaE1/E1) + (deltaE3/E3)*(deltaE3/E3) );
290  nPoints++;
291  }
292 
293  fLog << dolog;
294 
295  if (nPoints != 0)
296  return new TGraphErrors(nPoints, omega, j2, deltaOmega, deltaJ2);
297  else
298  return 0x0;
299 
300 
301 }
302 
303 
virtual Data_T GetError() const
return the error on the measured value
Definition: Measure.h:109
TLatex fType
Definition: Cascade.h:69
ClassImp(Cascade)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance to object.
Definition: Cascade.cpp:145
TGraphErrors * DoJ2() const
Compute J2.
Definition: Cascade.cpp:234
A cascade is a list of links.
Definition: Cascade.h:51
LogMessage & error(LogMessage &)
LogMessage & warning(LogMessage &)
virtual ~Cascade()
Definition: Cascade.cpp:85
header file for a NuclearLevel
A nuclear level.
Definition: NuclearLevel.h:66
Float_t Get() const
To get the spin as a float.
Definition: Spin.h:166
LogMessage & nline(LogMessage &)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
to execute an event for this cascade
Definition: Cascade.cpp:153
virtual void SetVisible()
Set link visible.
Definition: Level.h:213
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
virtual void SetUnvisible()
Set link unvisble.
Definition: Level.h:216
Measure< Float_t > & GetEnergy()
Definition: NuclearLevel.h:91
void ls(Option_t *opt="") const
Print out.
Definition: Cascade.cpp:160
Bool_t fIsVisible
Definition: Cascade.h:75
LogMessage & dolog(LogMessage &)
header file for a Cascade
virtual void Draw(Option_t *opt="")
Definition: Cascade.cpp:116
virtual void SetLabels(const Char_t *name, const Char_t *type="ND", Double_t x=0, Double_t y=0)
set cascade label
Definition: Cascade.cpp:99
ADF::LogMessage & endl(ADF::LogMessage &log)
LogMessage fLog
Definition: Cascade.h:77
Spin & GetSpin()
to get the spin and modify it if it is needed
Definition: NuclearLevel.h:84
virtual void SetVisible(Bool_t visu)
Set cascade (un)visible, do not delete the objects, still present, just not drawn ! ...
Definition: Cascade.cpp:124
virtual void SetProcessMethod(const char *)
To set the current method.
virtual TLatex & GetLatex(Option_t *opt="name")
to get and modify the displayed properties of name and type
Definition: Cascade.cpp:91
virtual void Paint(Option_t *opt="")
Draw/Paint methods.
Definition: Cascade.cpp:109
TLatex fName
Definition: Cascade.h:68
TGraphErrors * DoJ1() const
Compute J1.
Definition: Cascade.cpp:170
virtual Bool_t IsVisible()
return visible
Definition: Cascade.h:160