1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // ------------------------------------------------------------------- |
---|
28 | // GEANT 4 class file --- Copyright CERN 1998 |
---|
29 | // CERN Geneva Switzerland |
---|
30 | // |
---|
31 | // |
---|
32 | // File name: G4GammaDeexcitationTest.cc |
---|
33 | // |
---|
34 | // Author: Maria Grazia Pia (pia@genova.infn.it), |
---|
35 | // |
---|
36 | // Creation date: 27 October 1998 |
---|
37 | // |
---|
38 | // Modifications: |
---|
39 | // |
---|
40 | // ------------------------------------------------------------------- |
---|
41 | |
---|
42 | #include "globals.hh" |
---|
43 | |
---|
44 | #include "G4ios.hh" |
---|
45 | #include <fstream> |
---|
46 | #include <iomanip> |
---|
47 | #include <iostream> |
---|
48 | #include <assert.h> |
---|
49 | |
---|
50 | #include "CLHEP/Hist/TupleManager.h" |
---|
51 | #include "CLHEP/Hist/HBookFile.h" |
---|
52 | #include "CLHEP/Hist/Histogram.h" |
---|
53 | #include "CLHEP/Hist/Tuple.h" |
---|
54 | |
---|
55 | #include "G4VGammaDeexcitation.hh" |
---|
56 | #include "G4DataVector.hh" |
---|
57 | #include "G4ContinuumGammaDeexcitation.hh" |
---|
58 | #include "G4DiscreteGammaDeexcitation.hh" |
---|
59 | #include "G4LorentzVector.hh" |
---|
60 | #include "G4NucleiProperties.hh" |
---|
61 | #include "G4NucleiPropertiesTable.hh" |
---|
62 | #include "G4Fragment.hh" |
---|
63 | #include "Randomize.hh" |
---|
64 | #include "G4FragmentVector.hh" |
---|
65 | |
---|
66 | int main() |
---|
67 | { |
---|
68 | // MGP ---- HBOOK initialization |
---|
69 | HepTupleManager* hbookManager; |
---|
70 | hbookManager = new HBookFile("gammadeex.hbook", 58); |
---|
71 | assert (hbookManager != 0); |
---|
72 | |
---|
73 | // MGP ---- Book histograms |
---|
74 | |
---|
75 | HepHistogram* hGammaE; |
---|
76 | hGammaE = hbookManager->histogram("Gamma energy", 100,0.,10.); |
---|
77 | assert (hGammaE != 0); |
---|
78 | |
---|
79 | HepHistogram* hNGammas; |
---|
80 | hNGammas = hbookManager->histogram("Number of gammas", 20,0.,20.); |
---|
81 | assert (hNGammas != 0); |
---|
82 | |
---|
83 | // MGP ---- Book a ntuple |
---|
84 | HepTuple* ntuple; |
---|
85 | ntuple = hbookManager->ntuple("G4GammaDeexcitation ntuple"); |
---|
86 | assert (ntuple != 0); |
---|
87 | |
---|
88 | G4int Z; |
---|
89 | G4int A; |
---|
90 | |
---|
91 | G4cout << "Enter Z and A" << G4endl; |
---|
92 | G4cin >> Z >> A; |
---|
93 | |
---|
94 | assert (Z > 0); |
---|
95 | assert (A > 0); |
---|
96 | assert (A > Z); |
---|
97 | |
---|
98 | G4NuclearLevelManager levelManager(Z,A); |
---|
99 | |
---|
100 | G4int verbose; |
---|
101 | G4cout << "Enter verbose level " << G4endl; |
---|
102 | G4cin >> verbose; |
---|
103 | |
---|
104 | G4int mode = 0; |
---|
105 | G4cout << "Enter continuum (0) or discrete (1) deexcitation mode" << G4endl; |
---|
106 | G4cin >> mode; |
---|
107 | |
---|
108 | G4int iter = 1; |
---|
109 | G4cout << "Enter number of iterations " << G4endl; |
---|
110 | G4cin >> iter; |
---|
111 | if (iter <1) iter = 1; |
---|
112 | |
---|
113 | G4double excMin; |
---|
114 | G4double excMax; |
---|
115 | G4cout << "Enter initial min an max excitation energy" << G4endl; |
---|
116 | G4cin >> excMin >> excMax; |
---|
117 | assert (excMin >= 0.); |
---|
118 | assert (excMax > 0.); |
---|
119 | assert (excMax >= excMin); |
---|
120 | |
---|
121 | G4int i; |
---|
122 | for (i=0; i<iter; i++) |
---|
123 | { |
---|
124 | G4double excitation = excMin + G4UniformRand() * (excMax - excMin); |
---|
125 | G4VGammaDeexcitation* deexcitation; |
---|
126 | |
---|
127 | G4cout << G4endl << "TEST >>>>>>>>> Iteration " << i |
---|
128 | << " <<<<<<<<< Initial excitation " << excitation << " "; |
---|
129 | |
---|
130 | // Discrete deexcitation |
---|
131 | |
---|
132 | if (mode > 0) |
---|
133 | { |
---|
134 | // Transform excitation energy into nearest level energy |
---|
135 | const G4NuclearLevel* level = levelManager.NearestLevel(excitation); |
---|
136 | if (level != 0) |
---|
137 | { |
---|
138 | excitation = level->Energy(); |
---|
139 | G4cout << "Transformed into excitation " << excitation << G4endl; |
---|
140 | } |
---|
141 | |
---|
142 | deexcitation = new G4DiscreteGammaDeexcitation(); |
---|
143 | G4cout << "TEST ---- G4DiscreteGammaDeexcitation created ----" << G4endl; |
---|
144 | } |
---|
145 | |
---|
146 | // Continuum deexcitation |
---|
147 | |
---|
148 | else |
---|
149 | { |
---|
150 | deexcitation = new G4ContinuumGammaDeexcitation(); |
---|
151 | G4cout << G4endl << "TEST ---- G4ContinuumGammaDeexcitation created ----" << G4endl; |
---|
152 | } |
---|
153 | |
---|
154 | deexcitation->SetVerboseLevel(verbose); |
---|
155 | |
---|
156 | G4LorentzVector p4(0.,0.,0.,G4NucleiProperties::GetNuclearMass(A,Z)); |
---|
157 | G4Fragment nucleus(A,Z,p4); |
---|
158 | nucleus.SetExcitationEnergy(excitation); |
---|
159 | deexcitation->SetNucleus(nucleus); |
---|
160 | |
---|
161 | G4FragmentVector* gammas = deexcitation->DoChain(); |
---|
162 | |
---|
163 | // Fill histograms |
---|
164 | G4int nGammas = 0; |
---|
165 | if (gammas !=0) nGammas = gammas->entries(); |
---|
166 | hNGammas->accumulate(nGammas); |
---|
167 | G4cout << "TEST: " << nGammas << " photons generated: "; |
---|
168 | G4int ig = 0; |
---|
169 | for (ig=0; ig<nGammas; ig++) |
---|
170 | { |
---|
171 | G4double gammaE = gammas->at(ig)->GetMomentum().e(); |
---|
172 | G4cout << gammaE << " "; |
---|
173 | hGammaE->accumulate(gammaE); |
---|
174 | } |
---|
175 | G4cout << G4endl; |
---|
176 | |
---|
177 | if (gammas != 0) gammas->clearAndDestroy(); |
---|
178 | delete gammas; |
---|
179 | gammas = 0; |
---|
180 | delete deexcitation; |
---|
181 | deexcitation = 0; |
---|
182 | } |
---|
183 | |
---|
184 | hbookManager->write(); |
---|
185 | |
---|
186 | return EXIT_SUCCESS; |
---|
187 | } |
---|
188 | |
---|
189 | |
---|
190 | |
---|
191 | |
---|
192 | |
---|