source: trunk/examples/extended/electromagnetic/TestEm6/src/RunAction.cc

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

tag geant4.9.4 beta 1 + modifs locales

File size: 5.3 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// $Id: RunAction.cc,v 1.14 2009/11/27 14:54:58 hbu Exp $
27// GEANT4 tag $Name: geant4-09-04-beta-01 $
28//
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
32#include "RunAction.hh"
33
34#include "G4Run.hh"
35#include "G4RunManager.hh"
36
37#include "Randomize.hh"
38
39#ifdef G4ANALYSIS_USE
40 #include "AIDA/AIDA.h"
41#endif
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45RunAction::RunAction()
46:af(0), tree(0)
47{
48 for (G4int j=0; j<6; j++) histo[j] = 0;
49
50#ifdef G4ANALYSIS_USE
51 // Creating the analysis factory
52 af = AIDA_createAnalysisFactory();
53
54 if (af) {
55 // Creating the tree factory
56 AIDA::ITreeFactory* tf = af->createTreeFactory();
57
58 // Creating a tree mapped to an hbook file.
59 G4bool readOnly = false;
60 G4bool createNew = true;
61 G4String options = "--noErrors export=root uncompress";
62 //tree = tf->create("testem6.hbook","hbook",readOnly,createNew,options);
63 tree = tf->create("testem6.root", "root",readOnly,createNew,options);
64 //tree = tf->create("testem6.XML" ,"XML" ,readOnly,createNew,options);
65 delete tf;
66
67 if (tree) {
68 // Creating a histogram factory
69 AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree);
70
71 // Creating histograms
72 histo[0] = hf->createHistogram1D("1","1/(1+(theta+[g]+)**2)",100, 0 ,1.);
73 histo[1] = hf->createHistogram1D("2","log10(theta+ [g]+)", 100,-3.,1.);
74 histo[2] = hf->createHistogram1D("3","log10(theta- [g]-)", 100,-3.,1.);
75 histo[3] = hf->createHistogram1D("4","log10(theta+ [g]+ -theta- [g]-)",
76 100,-3.,1.);
77 histo[4] = hf->createHistogram1D("5","xPlus" ,100,0.,1.);
78 histo[5] = hf->createHistogram1D("6","xMinus",100,0.,1.);
79
80 delete hf;
81 G4cout << "\n----> Histogram tree is opened" << G4endl;
82 }
83 }
84#endif
85
86}
87
88//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89
90RunAction::~RunAction()
91{
92#ifdef G4ANALYSIS_USE
93 tree->commit(); // Writing the histograms to the file
94 tree->close(); // and closing the tree (and the file)
95
96 delete tree;
97 delete af;
98#endif
99}
100
101//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102
103void RunAction::BeginOfRunAction(const G4Run* aRun)
104{
105 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
106
107 // save Rndm status
108 G4RunManager::GetRunManager()->SetRandomNumberStore(true);
109 CLHEP::HepRandom::showEngineStatus();
110 ProcCounter = new ProcessesCount;
111}
112
113//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114
115void RunAction::CountProcesses(G4String procName)
116{
117 //does the process already encounted ?
118 size_t nbProc = ProcCounter->size();
119 size_t i = 0;
120 while ((i<nbProc)&&((*ProcCounter)[i]->GetName()!=procName)) i++;
121 if (i == nbProc) ProcCounter->push_back( new OneProcessCount(procName));
122
123 (*ProcCounter)[i]->Count();
124}
125
126//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127
128void RunAction::EndOfRunAction(const G4Run*)
129{
130 // show Rndm status
131 CLHEP::HepRandom::showEngineStatus();
132 //total number of process calls
133 G4double countTot = 0.;
134 G4cout << "\n Number of process calls --->";
135 for (size_t i=0; i< ProcCounter->size();i++) {
136 G4String procName = (*ProcCounter)[i]->GetName();
137 if (procName != "Transportation") {
138 G4int count = (*ProcCounter)[i]->GetCounter();
139 G4cout << "\t" << procName << " : " << count;
140 countTot += count;
141 }
142 }
143 G4cout << G4endl;
144
145}
146
147//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.