GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TestFeeding.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_TESTFEEDING_H
24 #include "TestFeeding.h"
25 #endif
26 
27 #ifndef GW_NUCLEARLEVEL_H
28 #include "NuclearLevel.h"
29 #endif
30 
31 #ifndef GW_GAMMALINK_H
32 #include "GammaLink.h"
33 #endif
34 
35 #define MAX_E1 100
36 #define MAX_E2 100
37 
38 using namespace Gw;
39 
41 {
42  Link::SetIL(&fTop);
43 
44  fNbE1 = fNbE2 = 0;
45  fE1 = new TObjArray(MAX_E1); fE1->SetOwner(kTRUE); fE2 = new TObjArray(MAX_E2); fE2->SetOwner(kTRUE);
46 
47  // set E1 and E2 properties of the gammas
48  GammaLink *gamma;
49 
50  for (Int_t i = 0; i < MAX_E1; i++ ) {
51  gamma = new GammaLink(); gamma->SetEM("E1"); fE1->AddAt(gamma,i);
52  }
53  for (Int_t i = 0; i < MAX_E2; i++ ) {
54  gamma = new GammaLink(); gamma->SetEM("E2"); fE2->AddAt(gamma,i);
55  }
56  // to get the single Rand instance
57  fRand = Random::Instance();
58 }
59 
61 {
62  // delete the tempory collection used
63  fNbE1 = fNbE2 = 0;
64  delete fE1; fE1 = NULL; delete fE2; fE2 = NULL;
65 }
66 
67 Int_t TestFeeding::DoCascade(TSeqCollection &col, Option_t */*opt*/)
68 {
69  GammaLink *gamma;
70 
71  // determine what is the energy difference between the initial and the final level
72  Float_t e, e_top, e_feeding, delta;
73 
74  e_top = fTop.GetEnergy().GetValue();
75  e_feeding = ((NuclearLevel *)fFinal)->GetEnergy().GetValue();
76  delta = e_top - e_feeding;
77 
78  if ( delta < 0.0 )
79  return 0;
80 
81  // now starts the random process up which consist in adding alternatively an E2 and
82  // an E2 transition to fill the energy gap delta.
83  // E1 are choosen randomly between 0 and 8 MeV. E2 between 0 and 1 MeV
84  bool is_E1;
85  fNbE1 = 0; fNbE2 = 0;
86 
87  is_E1 = true; // true means an E1 has just been produced .. so it is E2 to be produced
88  do {
89 
90  if ( fNbE1 > MAX_E1-1 || fNbE2 > MAX_E2-1 ) break; // TODO throw error
91  e = fRand->Current()->Rndm();
92 
93  if ( is_E1 ) { // E2 to be produced
94 
95  // set the proper energy
96  e = 8000 * e;
97  if ( e > delta ) e = delta; // check out if the random process ends
98 
99  // set the gamma-ray properties and add it to the cascade
100  gamma = static_cast<GammaLink *>(fE2->At(fNbE2++));
101  gamma->GetEnergy().SetValue(e); col.Add(gamma);
102 
103  // next is E1
104  is_E1 = false;
105  }
106  else { // E1 to be produced
107 
108  // set the proper energy
109  e = 8000 * e;
110  if ( e > delta ) e = delta; // check out if the random process ends
111 
112  // set the gamma-ray properties and add it to the cascade
113  gamma = static_cast<GammaLink *>(fE1->At(fNbE1++));
114  gamma->GetEnergy().SetValue(e); col.Add(gamma);
115 
116  // next is E2
117  is_E1 = true;
118  }
119  delta = delta - e;
120  } while (delta > 0) ;
121 
122  return 1;
123 }
124 
virtual ~TestFeeding()
Definition: TestFeeding.cpp:60
NuclearLevel fTop
Unique Rand instance.
Definition: TestFeeding.h:50
#define MAX_E1
Definition: TestFeeding.cpp:35
void SetValue(Data_T data)
set the value, cannot be overloaded
Definition: Data.h:116
header file for a NuclearLevel
A nuclear level.
Definition: NuclearLevel.h:66
TRandom * Current() const
to get the current TRandomom object
Definition: Random.h:118
#define MAX_E2
Definition: TestFeeding.cpp:36
Measure< Float_t > & GetEnergy()
Definition: NuclearLevel.h:91
virtual Int_t DoCascade(TSeqCollection &col, Option_t *opt="")
do cascade
Definition: TestFeeding.cpp:67
static Random * Instance()
to access the unique instance
Definition: Random.cpp:69
TestFeeding()
array of E2 transitions
Definition: TestFeeding.cpp:40
header file for a GEM (gamma-rays generator)
Data_T GetValue() const
get the value, cannot be overloaded
Definition: Data.h:114