source: trunk/examples/advanced/hadrontherapy/src/HadrontherapyRunAction.cc

Last change on this file was 1313, checked in by garnier, 14 years ago

geant4.9.4 beta rc0

File size: 3.9 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: HadrontherapyRunAction.cc
27// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
28
29
30#include "HadrontherapyRunAction.hh"
31#include "HadrontherapyEventAction.hh"
32#include "G4Run.hh"
33#include "G4RunManager.hh"
34#include "G4UImanager.hh"
35#include "G4ios.hh"
36#include "HadrontherapyDetectorConstruction.hh"
37#include "G4SDManager.hh"
38#include "G4Timer.hh"
39#include "HadrontherapyRunAction.hh"
40
41
42#include "HadrontherapyAnalysisManager.hh"
43#include "HadrontherapyMatrix.hh"
44
45HadrontherapyRunAction::HadrontherapyRunAction()
46{
47}
48
49HadrontherapyRunAction::~HadrontherapyRunAction()
50{ 
51}
52
53void HadrontherapyRunAction::BeginOfRunAction(const G4Run* aRun)
54{       
55    G4RunManager::GetRunManager()-> SetRandomNumberStore(true);
56    G4cout << "Run " << aRun -> GetRunID() << " starts ..." << G4endl;
57
58    // Warning! any beamOn will reset all data (dose, fluence, histograms, etc)!
59    //
60
61    // Initialize matrix with energy of primaries clearing data inside
62    if (HadrontherapyMatrix::GetInstance()) 
63    {
64        HadrontherapyMatrix::GetInstance() -> Initialize();
65    }
66
67#ifdef G4ANALYSIS_USE_ROOT
68    HadrontherapyAnalysisManager::GetInstance() -> flush();     // Finalize the root file
69    // Initialize root analysis ----> book
70    HadrontherapyAnalysisManager::GetInstance() -> book();
71#endif
72    electromagnetic = 0;
73    hadronic = 0;
74}
75
76void HadrontherapyRunAction::EndOfRunAction(const G4Run*)
77{
78    // Store dose & fluence data to ASCII & ROOT files
79    if ( HadrontherapyMatrix::GetInstance() )
80    {
81        HadrontherapyMatrix::GetInstance() -> TotalEnergyDeposit(); 
82        HadrontherapyMatrix::GetInstance() -> StoreDoseFluenceAscii();
83
84#ifdef G4ANALYSIS_USE_ROOT
85        if (HadrontherapyAnalysisManager::GetInstance())
86        { 
87            HadrontherapyMatrix::GetInstance() -> StoreDoseFluenceRoot();
88        }
89#endif
90    }
91
92    //G4cout << " Summary of Run " << aRun -> GetRunID() <<" :"<< G4endl;
93    //G4cout << "Number of electromagnetic processes of primary particles in the phantom:"
94    //     << electromagnetic << G4endl;
95    //G4cout << "Number of hadronic processes of primary particles in the phantom:"
96    //     << hadronic << G4endl;
97}
98void HadrontherapyRunAction::AddEMProcess()
99{
100 electromagnetic += 1;
101}
102void HadrontherapyRunAction::AddHadronicProcess()
103{
104  hadronic += 1;
105}
106
Note: See TracBrowser for help on using the repository browser.