source: trunk/source/processes/hadronic/models/de_excitation/photon_evaporation/test/G4PhotonEvaporationTest.cc @ 1199

Last change on this file since 1199 was 1199, checked in by garnier, 15 years ago

nvx fichiers dans CVS

File size: 8.7 KB
Line 
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:     G4PhotonEvaporationTest.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 <assert.h>
46#include <fstream>
47#include <iomanip>
48#include <iostream>
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 "G4PhotonEvaporation.hh"
56#include "G4VGammaDeexcitation.hh"
57#include "G4DataVector.hh"
58#include "G4ContinuumGammaDeexcitation.hh"
59#include "G4DiscreteGammaDeexcitation.hh"
60#include "G4LorentzVector.hh"
61#include "G4ThreeVector.hh"
62#include "G4NucleiProperties.hh"
63#include "G4NucleiPropertiesTable.hh"
64#include "G4Fragment.hh"
65#include "Randomize.hh"
66#include "G4FragmentVector.hh"
67#include "G4ParticleTypes.hh"
68#include "G4ParticleDefinition.hh"
69
70int main()
71{
72  // MGP ---- HBOOK initialization
73  HepTupleManager* hbookManager;
74  hbookManager = new HBookFile("mgcarlo.hbook", 58);
75  assert (hbookManager != 0);
76
77  // MGP ---- Book histograms
78
79  HepHistogram* hGammaE;
80  hGammaE = hbookManager->histogram("Gamma energy", 100,0.,10.);
81  assert (hGammaE != 0); 
82
83  HepHistogram* hNProducts;
84  hNProducts = hbookManager->histogram("Number of products", 20,0.,20.);
85  assert (hNProducts != 0); 
86
87  HepHistogram* hProb;
88  hProb = hbookManager->histogram("Probability * 1.e25", 100,0.,10.);
89  assert (hProb != 0); 
90
91  // MGP ---- Book a ntuple
92  HepTuple* ntuple;
93  ntuple = hbookManager->ntuple("G4PhotonEvaporation");
94  assert (ntuple != 0);
95
96  HepTuple* ntupleCons;
97  ntupleCons = hbookManager->ntuple("Conservation");
98  assert (ntupleCons != 0);
99
100  G4int Z;
101  G4int A;
102
103  G4cout << "Enter Z and A" << G4endl;
104  G4cin >> Z >> A;
105
106  assert (Z > 0);
107  assert (A > 0);
108  assert (A > Z);
109 
110 
111  G4int verbose;
112  G4cout << "Enter verbose level " << G4endl;
113  G4cin >> verbose;
114
115  G4int mode = 0;
116  G4cout << "Enter continuum (0) or discrete (1) deexcitation mode" << G4endl;
117  G4cin >> mode;
118
119  G4int iter = 1;
120  G4cout << "Enter number of iterations " << G4endl;
121  G4cin >> iter;
122  if (iter <1) iter = 1;
123
124  G4double excMin;
125  G4double excMax;   
126  G4cout << "Enter initial min an max excitation energy" << G4endl;
127  G4cin >> excMin >> excMax;
128  assert (excMin >= 0.);
129  assert (excMax > 0.);
130  assert (excMax >= excMin);
131 
132
133  G4ParticleDefinition* gamma = G4Gamma::GammaDefinition();
134
135  G4ParticleDefinition* proton = G4Proton::ProtonDefinition();
136  G4ParticleDefinition* antiProton = G4AntiProton::AntiProtonDefinition();
137  G4ParticleDefinition* neutron = G4Neutron::NeutronDefinition();   
138  G4ParticleDefinition* antiNeutron = G4AntiNeutron::AntiNeutronDefinition();   
139
140  G4ParticleDefinition* pionPlus = G4PionPlus::PionPlusDefinition();
141  G4ParticleDefinition* pionMinus = G4PionMinus::PionMinusDefinition();
142  G4ParticleDefinition* pionZero = G4PionZero::PionZeroDefinition();
143
144  G4ParticleDefinition* kaonPlus = G4KaonPlus::KaonPlusDefinition();
145  G4ParticleDefinition* kaonMinus = G4KaonMinus::KaonMinusDefinition();
146   
147  G4ParticleDefinition* lambda = G4Lambda::LambdaDefinition();
148
149  G4ParticleDefinition* theMuonPlus = G4MuonPlus::MuonPlusDefinition();
150  G4ParticleDefinition* theMuonMinus = G4MuonMinus::MuonMinusDefinition();
151
152  G4ParticleDefinition* theNeutrinoMu = G4NeutrinoMu::NeutrinoMuDefinition();
153  G4ParticleDefinition* theAntiNeutrinoMu = G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
154
155  // G4PhotonEvaporation for this (Z,A) material
156  G4PhotonEvaporation* photonEvaporation = new G4PhotonEvaporation;
157  G4cout << "TEST ---- G4PhotonEvaporation created ----" << G4endl;
158
159  photonEvaporation->SetVerboseLevel(verbose);
160
161  G4int i;
162  for (i=0; i<iter; i++)
163    {
164      G4double excitation = excMin + G4UniformRand() * (excMax - excMin);
165
166          G4cout << G4endl << "TEST >>>>>>>>> Iteration " << i
167                 << " <<<<<<<<< Initial excitation " << excitation << " ";
168
169      if (mode > 0) 
170        {
171          // Transform excitation energy into nearest level energy
172
173          G4NuclearLevelManager levelManager;
174          levelManager.SetNucleus(Z,A);
175          const G4NuclearLevel* level = levelManager.NearestLevel(excitation);
176          if (level != 0)
177            {
178              excitation = level->Energy();
179              G4cout << "Transformed into excitation " << excitation << G4endl;
180            }
181        }
182      else
183        {
184          G4cout << G4endl;
185        }
186
187      G4LorentzVector p4(0.,0.,0.,G4NucleiProperties::GetNuclearMass(A,Z)+excitation);
188      G4Fragment nucleus(A,Z,p4);
189      //      nucleus.SetExcitationEnergy(excitation);
190      G4double initialE = nucleus.GetMomentum().e();
191         
192      G4FragmentVector* products = photonEvaporation->BreakItUp(nucleus);
193      if(verbose >= 0) G4cout << "TEST: BreakItUp done" << G4endl;
194
195      G4double scale = 1./millibarn;
196      G4double prob = photonEvaporation->GetEmissionProbability() * scale;
197      if(verbose >= 0) G4cout << "TEST: probability " << prob << G4endl;
198 
199      // Fill histograms
200
201      G4int nProducts = 0;
202      if (products !=0) nProducts = products->entries();
203      hNProducts->accumulate(nProducts);
204
205      hProb->accumulate(prob);
206
207      if(verbose >= 0) G4cout << "TEST: " << nProducts << " products generated: gammaE ";
208
209      G4double currentExcitation = excitation;
210      G4double sumPx = 0.;
211      G4double sumPy = 0.;
212      G4double sumPz = 0.;
213      G4double sumE = 0.;
214      G4double sumEgamma = 0.;
215
216      G4int ig = 0;
217      for (ig=0; ig<nProducts; ig++)
218        {
219          G4double productE = products->at(ig)->GetMomentum().e();
220          G4ThreeVector pProd(products->at(ig)->GetMomentum());
221          sumPx = sumPx + pProd.x();
222          sumPy = sumPy + pProd.y();
223          sumPz = sumPz + pProd.z();
224          sumE = sumE + productE;
225          if (products->at(ig)->GetA() < 1)
226            {
227              if(verbose >= 0) G4cout << productE << " ";
228              sumEgamma = sumEgamma + productE;
229              hGammaE->accumulate(productE);
230              ntuple->column("exc",currentExcitation);
231              ntuple->column("egamma",productE);
232              ntuple->column("prob",prob);
233              ntuple->dumpData();
234              // ntuple->column("px",pProd.x());
235              // ntuple->column("py",pProd.y());
236              // ntuple->column("pz",pProd.z());
237              currentExcitation = currentExcitation - productE;
238            }
239          else
240            { if(verbose >= 0) G4cout << "(" << products->at(ig)->GetZ() << "," << products->at(ig)->GetA() << ") "; }
241        }
242      if(verbose >= 0) G4cout << G4endl;
243
244      if(verbose >= 0) G4cout << "TEST: Sum of product energies = " << sumE
245             << ", Sum of gamma energies = " << sumEgamma << G4endl;
246
247      if (products != 0) 
248        {
249          products->clearAndDestroy();
250
251          ntupleCons->column("px",sumPx);
252          ntupleCons->column("py",sumPy);
253          ntupleCons->column("pz",sumPz);
254          ntupleCons->column("eprod",sumE);
255          ntupleCons->column("exc",excitation);
256          ntupleCons->column("egammas",sumEgamma);
257          ntupleCons->column("ein",initialE);
258          ntupleCons->dumpData();
259        }
260      delete products;
261    }
262
263  hbookManager->write();
264
265  delete photonEvaporation;
266 
267  return EXIT_SUCCESS;
268}
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
Note: See TracBrowser for help on using the repository browser.