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

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

update to last version 4.9.4

File size: 7.8 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#include "G4AtomicTransitionManager.hh"
27#include "G4UAtomicDeexcitation.hh"
28#include "globals.hh"
29#include "G4ios.hh"
30#include <vector>
31#include "G4DynamicParticle.hh"
32#include "AIDA/AIDA.h"
33#include "Randomize.hh"
34#include "G4Proton.hh"
35#include "G4Alpha.hh"
36
37using namespace CLHEP;
38
39int main(int argc, char* argv[]){
40
41  if (!argc) argc=0;
42
43  time_t seconds = time(NULL);
44  G4int seed = seconds;
45 
46  // choose the Random engine
47  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
48  CLHEP::HepRandom::setTheSeed(seed);
49
50  G4int Z;
51  G4int a;
52  G4int b;
53  G4int startId;
54  G4int vacancyIndex;
55  G4int numberOfRun;
56  G4int batch=0;
57  G4int element = 0;
58  if (argv[1]) {batch = atoi(argv[1]);}
59  G4String fileName;
60  if (argv[3]) {element = atoi(argv[3]);}
61  if (argv[4]) {fileName = argv[4];}
62  else {fileName = "transitions.xml";}
63
64  AIDA::ITree* tree;
65  AIDA::IAnalysisFactory* analysisFactory;
66  AIDA::ITupleFactory* tupleFactory;
67  AIDA::ITuple* tupleFluo = 0;
68  if (batch != 1) {
69    G4cout << "Enter Z " << G4endl;
70    G4cin >> a;
71    G4cout << "Enter the id of the vacancy" << G4endl;
72    G4cin >> startId;
73    G4cout<<"Enter the number of runs "<<G4endl;
74    G4cin>> numberOfRun;
75  }
76  else {
77   
78    a = 0;
79    startId = -1;
80    numberOfRun = atoi(argv[2]);
81  }
82  analysisFactory = AIDA_createAnalysisFactory();
83  AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
84  tree = treeFactory->create(fileName,"xml",false,true);
85  tupleFactory = analysisFactory->createTupleFactory(*tree);
86  // Book tuple column names
87  std::vector<std::string> columnNames;
88  // Book tuple column types
89  std::vector<std::string> columnTypes;
90 
91  //if Z=0 a number of runs numberOfRun is generated for all the elements
92  if (a==0)
93    {
94      if (element == 0) { 
95        a = 6;
96        b = 98;
97      }
98      else {
99        a = element;
100        b = a;}
101      columnNames.push_back("AtomicNumber");
102      columnNames.push_back("Particle");
103      columnNames.push_back("Energies");
104     
105      columnTypes.push_back("int");
106      columnTypes.push_back("int");
107      columnTypes.push_back("double");
108      tupleFluo = tupleFactory->create("10", "Total Tuple", columnNames, columnTypes, "");
109      assert(tupleFluo);
110
111    }
112  else { b = a;} 
113 
114  G4AtomicTransitionManager* transitionManager = G4AtomicTransitionManager::Instance();
115 
116  G4UAtomicDeexcitation* deexcitation = new G4UAtomicDeexcitation;
117 
118
119 std::map<G4int,G4int> shellNumberTable;
120 
121 deexcitation->SetPIXECrossSectionModel("ECPSSR_Analytical");
122 deexcitation->InitialiseForNewRun();   
123 deexcitation->SetAugerActive(true);
124 deexcitation->SetPIXEActive(true);
125
126 
127  for (Z = a; Z<=b; Z++) {   
128  G4cout << "******** Z = "<< Z << "*********" << G4endl;
129
130  G4int numberOfPossibleShell = transitionManager->NumberOfShells(Z);
131
132  shellNumberTable[Z] = numberOfPossibleShell;
133  G4int min = 0;
134  G4int max = 0;
135  std::vector<G4DynamicParticle*>* vectorOfParticles = new std::vector<G4DynamicParticle*>;
136
137
138  G4ParticleDefinition* particle;
139
140  assert(vectorOfParticles);
141
142    for(G4int i = 0; i<numberOfRun;i++){ 
143      G4cout<<"**************"<<G4endl;
144      G4cout<<"begin of run "<< i <<G4endl;
145      G4cout<<"**************"<<G4endl;
146      vectorOfParticles->clear();
147      // if shellID = -1 the test runs on every shell of the atom
148      if (startId == -1){
149        min = 1;
150        max = shellNumberTable[Z];
151      }
152      else {
153        min = startId;
154        max = min;
155      }
156
157      for (vacancyIndex = min; vacancyIndex <= max; vacancyIndex++) { 
158
159        G4AtomicShell* shell = transitionManager->Shell(Z, vacancyIndex);
160        G4AtomicShellEnumerator as;
161
162        if (shell->ShellId() == 1) {as = fKShell;}
163        else if (shell->ShellId() == 3) {as = fL1Shell;}
164        else if (shell->ShellId() == 5) {as = fL2Shell;}
165        else if (shell->ShellId() == 6) {as = fL3Shell;}
166        else if (shell->ShellId() == 8) {as = fM1Shell;}
167        else if (shell->ShellId() == 10) {as = fM2Shell;}
168        else if (shell->ShellId() == 11) {as = fM3Shell;}
169        else if (shell->ShellId() == 13) {as = fM4Shell;}
170        else if (shell->ShellId() == 14) {as = fM5Shell;}
171
172        //loop over the energy? no, let's try the "standard" ones
173     
174        particle = G4Proton::Proton();
175
176        G4double crossSecProton = deexcitation->GetShellIonisationCrossSectionPerAtom
177          (particle,Z,as,3.0 * MeV) * barn ;
178
179        particle = G4Alpha::Alpha();
180
181        G4double crossSecAlpha = deexcitation->GetShellIonisationCrossSectionPerAtom
182          (particle, Z, as, 5.8 * MeV) * barn ;
183 
184        deexcitation->GenerateParticles(vectorOfParticles, shell, Z, 0, 0);
185     
186        G4cout<<  vectorOfParticles->size()<<" particles in the vector "<<G4endl;
187        G4cout<<"XS for p @ 3 MeV: "<< crossSecProton/barn  << "barns" << G4endl;
188        G4cout<<"XS for p @ 5.8 MeV: "<< crossSecAlpha/barn << "barns" << G4endl; 
189
190        for (G4int k=0; k< vectorOfParticles->size();k++)
191          {
192
193            G4DynamicParticle* newParticle = (*vectorOfParticles)[k];
194
195            if ( newParticle->GetDefinition()->GetParticleName() == "e-")
196              {
197
198                G4DynamicParticle* newElectron = (*vectorOfParticles)[k];
199                G4ThreeVector augerDirection =newElectron ->GetMomentum();
200                G4double  augerEnergy =newElectron ->GetKineticEnergy();
201
202
203                if (startId==-1){
204                 
205                  tupleFluo->fill(0,Z);
206                  tupleFluo->fill(1,0);
207                  tupleFluo->fill(2,augerEnergy);
208                  tupleFluo->addRow();
209                 
210                }
211                else{         
212                 
213                  G4cout <<" An auger has been generated"<<G4endl;
214                  G4cout<<" vectorOfParticles ["<< k <<"]:"<<G4endl;
215                  G4cout<<"Non zero particle. Index: "<< k <<G4endl;
216                  G4cout<< "The Auger electron has a kinetic energy = "<<augerEnergy
217                        <<" MeV " <<G4endl;
218                }
219              }
220            else{
221                G4cout << "pippo" << G4endl; 
222
223              G4ThreeVector photonDirection = newParticle ->GetMomentum();
224              G4double  photonEnergy =newParticle ->GetKineticEnergy();
225
226              if (startId==-1){
227                G4cout << "pippo2" << G4endl;
228                tupleFluo->fill(0,Z);
229
230                tupleFluo->fill(1,1);
231                tupleFluo->fill(2,photonEnergy);
232                tupleFluo->addRow();           
233
234              }
235              else{
236               
237                G4cout<<" vectorOfParticles ["<<k<<"]:"<<G4endl;
238                G4cout<<"Non zero particle. Index: "<<k<<G4endl;
239                G4cout<< "The photon has a kinetic energy = "<<photonEnergy
240                      <<" MeV " <<G4endl;
241              }
242            }
243          }
244      }
245      if (batch == 1){
246        tree->commit(); // Write histos in file.
247        tree->close();
248      }
249      if (!vectorOfParticles) delete vectorOfParticles;
250    }
251  } 
252  delete deexcitation;
253  G4cout<<"END OF THE MAIN PROGRAM"<<G4endl;
254}
Note: See TracBrowser for help on using the repository browser.