Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/electromagnetic/TestEm6/src/RunAction.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 /// \file electromagnetic/TestEm6/src/RunAction.cc
27 /// \brief Implementation of the RunAction class
28 //
29 // $Id: RunAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "RunAction.hh"
35 
36 #include "G4Run.hh"
37 #include "G4RunManager.hh"
38 
39 #include "Randomize.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  : G4UserRunAction(),fProcCounter(0)
45 {
46  // Create analysis manager
47  // The choice of analysis technology is done via selection of a namespace
48  //
49  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
50 
51  // Open an output file
52  //
53  G4String fileName = "testem6";
54  analysisManager->OpenFile(fileName);
55  analysisManager->SetVerboseLevel(1);
56  G4String extension = analysisManager->GetFileType();
57  fileName = fileName + "." + extension;
58 
59  // Creating histograms
60  //
61  analysisManager->SetFirstHistoId(1);
62  analysisManager->CreateH1("1","1/(1+(theta+[g]+)**2)",100, 0 ,1.);
63  analysisManager->CreateH1("2","log10(theta+ [g]+)", 100,-3.,1.);
64  analysisManager->CreateH1("3","log10(theta- [g]-)", 100,-3.,1.);
65  analysisManager->CreateH1("4","log10(theta+ [g]+ -theta- [g]-)", 100,-3.,1.);
66  analysisManager->CreateH1("5","xPlus" ,100,0.,1.);
67  analysisManager->CreateH1("6","xMinus",100,0.,1.);
68 
69  G4cout << "\n----> Histogram file is opened in " << fileName << G4endl;
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
77 
78  analysisManager->Write();
79  analysisManager->CloseFile();
80 
81  delete G4AnalysisManager::Instance();
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
86 void RunAction::BeginOfRunAction(const G4Run* aRun)
87 {
88  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
89 
90  // save Rndm status
93  fProcCounter = new ProcessesCount;
94 }
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 
99 {
100  //does the process already encounted ?
101  size_t nbProc = fProcCounter->size();
102  size_t i = 0;
103  while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
104  if (i == nbProc) fProcCounter->push_back( new OneProcessCount(procName));
105 
106  (*fProcCounter)[i]->Count();
107 }
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110 
111 void RunAction::EndOfRunAction(const G4Run*)
112 {
113  // show Rndm status
115  //total number of process calls
116  G4double countTot = 0.;
117  G4cout << "\n Number of process calls --->";
118  for (size_t i=0; i< fProcCounter->size();i++) {
119  G4String procName = (*fProcCounter)[i]->GetName();
120  if (procName != "Transportation") {
121  G4int count = (*fProcCounter)[i]->GetCounter();
122  G4cout << "\t" << procName << " : " << count;
123  countTot += count;
124  }
125  }
126  G4cout << G4endl;
127 
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< OneProcessCount * > ProcessesCount
void SetRandomNumberStore(G4bool flag)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
static void showEngineStatus()
Definition: Random.cc:203
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76