source: trunk/source/processes/electromagnetic/lowenergy/test/testExp.cc@ 1350

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

update to last version 4.9.4

File size: 5.1 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// GEANT4 Test file
29//
30// File name: testExp.cc
31//
32// Author: Simona Saliceti (simona.saliceti@ge.infn.it)
33//
34// History:
35// --------
36// Structor from AtomicDexecitation's test
37// 13/04/2004 Simona Saliceti 1st implementation
38// --------------------------------------------------------------------
39//
40// Test Description:
41// ------------------
42// Test of Empiric Model for shell cross sections in proton ionisation
43// --------------------------------------------------------------------
44// $Id: testExp.cc,v 1.4 2010/11/10 00:29:46 asaim Exp $
45// GEANT4 tag $Name: geant4-09-04-ref-00 $
46
47#include "globals.hh"
48#include "G4ios.hh"
49#include <stdio.h>
50#include <vector>
51#include <iostream>
52#include <fstream>
53#include "G4VhShellCrossSection.hh"
54#include "G4hShellCrossSection.hh"
55#include "G4hShellCrossSectionExp.hh"
56#include "G4AtomicTransitionManager.hh"
57#include "G4Proton.hh"
58#include "AIDA/AIDA.h"
59
60int main()
61{
62 G4int Z;
63 G4double incidentEnergy;
64 G4double mass;
65 G4double deltaEnergy;
66 size_t shellNumber;
67
68 G4VhShellCrossSection* shellExp = new G4hShellCrossSectionExp();
69
70 //proton mass in Kg
71 //mass = 1.67262158e-27 * kg;
72 G4Proton* aProtone = G4Proton::Proton();
73 mass = aProtone->GetPDGMass();
74
75 std::vector<G4double> energies;
76 //Energy from 0.005 MeV to 500 MeV
77 for (G4double i=-5.5; i<6.5; i=i+0.25)
78 {
79 energies.push_back(std::exp(i));
80 }
81
82 G4cout << "Enter shell number: " << G4endl;
83 G4cin >> shellNumber;
84
85 // Creating the analysis factory and the tree factory
86 AIDA::IAnalysisFactory* analysisFactory = AIDA_createAnalysisFactory();
87 AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
88
89 G4String fileName = "crossSectionElement";
90 char buffer[3];
91
92 //Z is the atomic number
93 for (Z = 6; Z<=92; Z++)
94 {
95 G4cout << "Z = " << Z << G4endl;
96 snprintf(buffer, 3, "%d", Z);
97 fileName = fileName + buffer + ".xml";
98
99 // Creating a tree in uncompress XML
100 AIDA::ITree* tree = treeFactory->create(fileName,"xml",0,1,""); // output file
101 // Creating a data point set factory, which will be handled by the tree
102 AIDA::IDataPointSetFactory* dataPointSetFactory = analysisFactory->createDataPointSetFactory(*tree);
103 // Creating a 2 D data point set
104 AIDA::IDataPointSet* dataPointSetElement = dataPointSetFactory->create("CS","Cross section", 2);
105 fileName = "crossSectionElement";
106
107 //Cross section for each incident energy
108 for (size_t k=0; k<energies.size();k++)
109 {
110 incidentEnergy = energies[k]*MeV;
111 deltaEnergy = 0.0;
112
113 // *************************************************************** //
114 // From Empiric Model //
115 // *************************************************************** //
116
117 std::vector<G4double> CS = shellExp->GetCrossSection(Z,incidentEnergy,mass,deltaEnergy,true);
118
119 // Write in a file.xml
120 // Fill the two dimensional IDataPointSet
121 dataPointSetElement->addPoint();
122 AIDA::IDataPoint & point = *(dataPointSetElement->point(k));
123 AIDA::IMeasurement& xPoint = *(point.coordinate(0));
124 xPoint.setValue(incidentEnergy);
125 AIDA::IMeasurement& yPoint = *(point.coordinate(1));
126 yPoint.setValue(CS[0]/barn);
127 }
128
129 // Flushing the histograms into the file
130 tree->commit();
131 // Explicitly closing the tree
132 tree->close();
133 }
134 delete shellExp;
135
136 G4cout<<"END OF THE MAIN PROGRAM"<<G4endl;
137}
Note: See TracBrowser for help on using the repository browser.