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

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

update to geant4.9.3

File size: 4.4 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.13 2008/09/18 16:42:07 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  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}
111
112//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113
114void RunAction::EndOfRunAction(const G4Run*)
115{
116  // show Rndm status
117  CLHEP::HepRandom::showEngineStatus();
118}
119
120//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.