source: trunk/examples/extended/electromagnetic/TestEm4/src/RunAction.cc@ 1230

Last change on this file since 1230 was 1230, checked in by garnier, 16 years ago

update to geant4.9.3

File size: 4.0 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.11 2008/09/12 18:46:14 maire Exp $
27// GEANT4 tag $Name: geant4-09-03-cand-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 histo[0] = 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("testem4.hbook","hbook",readOnly,createNew, options);
63 tree = tf->create("testem4.root","root",readOnly,createNew, options);
64 //tree = tf->create("testem4.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 the histogram
72 histo[0]=hf->createHistogram1D
73 ("1","total energy deposit in C6F6(MeV)",100,0.,10.);
74
75 delete hf;
76 G4cout << "\n----> Histogram tree is opened" << G4endl;
77 }
78 }
79#endif
80}
81
82//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83
84RunAction::~RunAction()
85{
86#ifdef G4ANALYSIS_USE
87 tree->commit(); // Writing the histograms to the file
88 tree->close(); // and closing the tree (and the file)
89
90 delete tree;
91 delete af;
92#endif
93}
94
95//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96
97
98void RunAction::BeginOfRunAction(const G4Run* aRun)
99{
100 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
101
102 // save Rndm status
103 G4RunManager::GetRunManager()->SetRandomNumberStore(true);
104 CLHEP::HepRandom::showEngineStatus();
105}
106
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108
109void RunAction::EndOfRunAction(const G4Run*)
110{
111 // show Rndm status
112 CLHEP::HepRandom::showEngineStatus();
113}
114
115//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.