GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XGammaLink.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_XGammaLink
24 #include "XGammaLink.h"
25 #endif
26 
27 using namespace Gw;
28 
30 
32  : GammaLink()
33 {
34  fIsX = kFALSE; fX.SetOwner(kTRUE);
35 }
36 
38 {
39  fX.Clear();
40 }
41 
42 void XGammaLink::SetX(Int_t nb, Float_t *energy, Float_t *weight)
43 {
44  Int_t i; GammaLink *xray;
45 
46  if ( nb <= 0 ) return;
47  if ( fConv.GetValue() <= 0 ) return;
48 
49  // reset the previous definition
50  fX.Clear(); fRandX.Clear("");
51 
52  // set new definition
53  // slot 0 for this with an intensity = i_link / (1 + conv)
54  fRandX.Add(this,fStrength.GetValue()/(1+fConv.GetValue()));
55 
56  // compute sum weight for X-rays.
57  Float_t sumw, xw;
58  sumw = 0;
59  for (i = 0; i < nb; i++ ) sumw += weight[i];
60 
61  for (i = 0; i < nb; i++ ) {
62 
63  // new x-rays with the same
64  xray = new GammaLink(); (*xray) = (*this);
65 
66  // to set each x-ray properties - to be completed !
68  xw = xw * weight[i] / sumw;
69  xray->GetStrength().Set(xw); xray->GetEnergy().Set(energy[i]);
70 
71  // add a new x-ray to the list of x-rays and the generator
72  fX.Add(xray); fRandX.Add(xray,xw);
73  } // i
74 
75  // now everything is all right to determine X-rays
76  DoX(kTRUE);
77 }
78 
79 /*
80 void XGammaLink::ls(Option_t* option) const
81 {
82 
83 // std::cout << "Gamma " << fEnergy.Get() << " " << fSpin << " " << fParity << std::endl;
84 }
85 */
86 
87 Int_t XGammaLink::DoCascade(TSeqCollection &cas, Option_t */*opt*/)
88 {
89  Link *link; Int_t result = 1;
90 
91  if ( fX.GetSize() == 0 ) { // no X defined, thus no conversion possible
92  cas.Add(this);
93  return result;
94  }
95 
96  if ( fIsX == kTRUE ) {
97  link = (Link *)fRandX.Rand();
98  if ( link == this )
99  cas.Add(this);
100  else
101  result = link->DoCascade(cas);
102  }
103  else { cas.Add(this) ; }
104 
105  return result;
106  /*
107  if ( fX.GetSize() == 0 ) cas.Add(this) ;
108  else {
109  link = (Link *)fRandX.Rand();
110  if ( link == this ) cas.Add ( this) ;
111  else link->DoCascade(cas);
112  }
113  printf("XGammaLink \n");
114  GammaLink *l = (GammaLink *)fRandX.Rand();
115  printf(" %f \n",l->GetEnergy().GetValue());
116  printf("XGammaLink \n"); */
117 
118 // if ( fX.GetSize() == 0 ) cas.Add(this) ;
119 // else cas.Add(fRandX.Rand());
120 
121 }
122 
123 
virtual TObject * Rand()
it returns a pointer to a randomly selected object from the collection
Definition: RandObj.cpp:93
virtual void Set(Data_T data)
set the measure and its error (default err=0)
Definition: Measure.h:66
virtual void Clear(Option_t *opt="")
clear everything (the objects in the collection are not deleted)
Definition: RandObj.cpp:88
virtual void Add(TObject *, Float_t)
it adds an object with a weight to this collection.
Definition: RandObj.cpp:49
Data_T GetValue() const
get the value, cannot be overloaded
Definition: Data.h:114