source: trunk/source/processes/electromagnetic/lowenergy/test/testDoubleExp.cc @ 1199

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

nvx fichiers dans CVS

File size: 5.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// GEANT4     Test file
29//
30// File name: testExp.cc
31//
32// Author:    Simona Saliceti (simona.saliceti@ge.infn.it)
33//
34// History:
35// --------
36//
37// 13/04/2004 Simona Saliceti 1st implementation
38// --------------------------------------------------------------------
39//
40// Test Description:
41// ------------------
42// Test of second implementation of the Empiric Model for shell cross sections in proton ionisation
43// --------------------------------------------------------------------
44// $Id: testDoubleExp.cc,v 1.5 2009/06/12 10:43:45 mantero Exp $
45// GEANT4 tag $Name: geant4-09-03-cand-01 $
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 "G4hShellCrossSectionDoubleExp.hh"
56#include "G4teoCrossSection.hh"
57#include "G4AtomicTransitionManager.hh"
58#include "G4Proton.hh"
59#include "AIDA/AIDA.h"
60
61int main()
62{ 
63   G4int Z; 
64   G4double incidentEnergy;
65   G4double mass;
66   G4double deltaEnergy;
67   size_t shellNumber;
68
69   //    G4VhShellCrossSection* shellExp = new G4hShellCrossSectionDoubleExp();
70 
71   G4VhShellCrossSection* shellExp = new G4teoCrossSection();
72
73   //proton mass in Kg
74   //mass = 1.67262158e-27 * kg;   
75   G4Proton* aProtone = G4Proton::Proton();
76   mass = aProtone->GetPDGMass();
77
78   std::vector<G4double> energies;
79   //Energy from 0.005 MeV to 500 MeV
80   for (G4double i=-5.5; i<6.5; i=i+0.125)
81     {
82       energies.push_back(std::exp(i)*MeV);
83     } 
84
85   G4cout << "Enter shell number: " << G4endl;
86   G4cin >> shellNumber;
87
88   // Creating the analysis factory and  the tree factory
89   AIDA::IAnalysisFactory* analysisFactory = AIDA_createAnalysisFactory();
90   AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
91
92   G4String fileName = "teoCorssSection";           
93
94   G4String fileNameTxt = fileName;
95   char buffer[3];
96   std::ofstream myfile;
97
98   //Z is the atomic number
99   for (Z = 6; Z<=92; Z++)
100     { 
101       G4cout << "Z = " << Z << G4endl;
102       snprintf(buffer, 3, "%d", Z);
103
104       fileName = fileName+ buffer + ".xml";
105
106
107
108
109       // Creating a tree in uncompress XML
110       AIDA::ITree* tree = treeFactory->create(fileName,"xml",0,1,"uncompress"); // output file
111       // Creating a data point set  factory, which will be handled by the tree
112       AIDA::IDataPointSetFactory* dataPointSetFactory = analysisFactory->createDataPointSetFactory(*tree);
113       // Creating a 2 D data point set
114       AIDA::IDataPointSet* dataPointSetElement = dataPointSetFactory->create("CS","Cross section", 2); 
115       fileName = "teoCrossSection";
116       
117       
118       
119       fileNameTxt = fileName + buffer + ".dat";
120       
121       myfile.open (fileNameTxt);
122       
123       
124       //Cross section for each incident energy
125       for (size_t k=0; k<energies.size();k++)
126         {
127           incidentEnergy = energies[k]*MeV;
128           deltaEnergy = 0.0;
129           
130           // *************************************************************** //
131           // From Empiric Model                                              //
132           // *************************************************************** //
133           
134           std::vector<G4double> CS = shellExp->GetCrossSection(Z,incidentEnergy,mass,deltaEnergy,false);
135           
136           //Write in a file.xml
137           // Fill the two dimensional IDataPointSet
138           dataPointSetElement->addPoint();
139           AIDA::IDataPoint & point = *(dataPointSetElement->point(k));
140           AIDA::IMeasurement& xPoint = *(point.coordinate(0));
141           xPoint.setValue(incidentEnergy);
142           AIDA::IMeasurement& yPoint = *(point.coordinate(1));
143           yPoint.setValue(CS[shellNumber]); //barn);        //error in ecpssr class: correct units management!
144           
145           myfile << incidentEnergy << "\t" << CS[shellNumber] << G4endl;
146           
147           
148         }
149       
150       myfile.close();
151       fileNameTxt = fileName;     
152       
153       
154
155       // Flushing the histograms into the file
156       tree->commit();
157       // Explicitly closing the tree
158       tree->close();
159     } 
160   delete shellExp;
161   
162   G4cout<<"END OF THE MAIN PROGRAM"<<G4endl;
163}
Note: See TracBrowser for help on using the repository browser.