Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RemSimRunAction.cc
Go to the documentation of this file.
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 // * *
29 // * RemSimRunAction.cc *
30 // * *
31 // *******************************
32 //
33 // Code developed by: S.Guatelli, susanna@uow.edu.au
34 // $Id$
35 //
36 
37 #include "RemSimRunAction.hh"
40 #include "G4Run.hh"
41 #include "G4RunManager.hh"
42 #include "G4ios.hh"
43 #include "RemSimRunAction.hh"
44 #include "RemSimAnalysis.hh"
45 
47 {
48  // Create analysis manager
49  G4AnalysisManager::Instance();
50 }
51 
53 {
54  delete G4AnalysisManager::Instance();
55  }
56 
58 {
59  G4cout << "### Run " << aRun -> GetRunID() << " start." << G4endl;
60 
61  // Get analysis manager
62  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
63 
64  // Open a ROOT output file
65  //
66  G4String fileName = "remsim.root";
67  analysisManager -> OpenFile(fileName);
68  analysisManager -> SetFirstHistoId(1);
69 
70  // Create the histograms
71  analysisManager -> CreateH1("1","Energy of secondary p reaching the phantom",1000, 0., 10000.);
72  analysisManager -> CreateH1("2","Energy of secondary n reaching the phantom", 1000, 0., 10000.);
73  analysisManager -> CreateH1("3","Energy of secondary pions reaching the phantom",1000, 0., 10000.);
74  analysisManager -> CreateH1("4","Energy of secondary alpha reaching the phantom",100, 0., 100.);
75  analysisManager -> CreateH1("5","Energy of secondary p produced in the phantom",100, 0., 1000.);
76  analysisManager -> CreateH1("6","Energy of secondary n produced in the phantom", 100, 0., 1000.);
77  analysisManager -> CreateH1("7","Energy of secondary pions produced in the phantom",200, 0., 2000.);
78  analysisManager -> CreateH1("8","Energy of secondary alpha produced in the phantom", 100, 0.,100.);
79 }
80 
82 {
83  G4double numberEvents = aRun -> GetNumberOfEvent();
84  G4cout<< "Number of events:" << numberEvents << G4endl;
85 
86  // Get analysis manager
87  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
88 
89  // Save the histograms and close the ROOT file
90  analysisManager -> Write();
91  analysisManager -> CloseFile();
92 }
93