Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 // $Id$
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 {
45  // Create analysis manager
46  // The choice of analysis technology is done via selection of a namespace
47  //
48  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
49 
50  // Open an output file
51  //
52  G4String fileName = "testem6";
53  analysisManager->OpenFile(fileName);
54  analysisManager->SetVerboseLevel(1);
55  G4String extension = analysisManager->GetFileType();
56  fileName = fileName + "." + extension;
57 
58  // Creating histograms
59  //
60  analysisManager->SetFirstHistoId(1);
61  analysisManager->CreateH1("1","1/(1+(theta+[g]+)**2)",100, 0 ,1.);
62  analysisManager->CreateH1("2","log10(theta+ [g]+)", 100,-3.,1.);
63  analysisManager->CreateH1("3","log10(theta- [g]-)", 100,-3.,1.);
64  analysisManager->CreateH1("4","log10(theta+ [g]+ -theta- [g]-)", 100,-3.,1.);
65  analysisManager->CreateH1("5","xPlus" ,100,0.,1.);
66  analysisManager->CreateH1("6","xMinus",100,0.,1.);
67 
68  G4cout << "\n----> Histogram file is opened in " << fileName << G4endl;
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 {
75  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
76 
77  analysisManager->Write();
78  analysisManager->CloseFile();
79 
80  delete G4AnalysisManager::Instance();
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
85 void RunAction::BeginOfRunAction(const G4Run* aRun)
86 {
87  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
88 
89  // save Rndm status
92  fProcCounter = new ProcessesCount;
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96 
98 {
99  //does the process already encounted ?
100  size_t nbProc = fProcCounter->size();
101  size_t i = 0;
102  while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
103  if (i == nbProc) fProcCounter->push_back( new OneProcessCount(procName));
104 
105  (*fProcCounter)[i]->Count();
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
110 void RunAction::EndOfRunAction(const G4Run*)
111 {
112  // show Rndm status
114  //total number of process calls
115  G4double countTot = 0.;
116  G4cout << "\n Number of process calls --->";
117  for (size_t i=0; i< fProcCounter->size();i++) {
118  G4String procName = (*fProcCounter)[i]->GetName();
119  if (procName != "Transportation") {
120  G4int count = (*fProcCounter)[i]->GetCounter();
121  G4cout << "\t" << procName << " : " << count;
122  countTot += count;
123  }
124  }
125  G4cout << G4endl;
126 
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......