Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/electromagnetic/TestEm8/src/RunAction.cc
이 파일의 문서화 페이지로 가기
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: RunAction.cc 110166 2018-05-16 15:54:41Z gcosmo $
30 //
31 //---------------------------------------------------------------------------
32 //
33 // ClassName: RunAction
34 //
35 // Author: V.Ivanchenko 01.09.2010
36 //
37 //----------------------------------------------------------------------------
38 //
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
43 #include "RunAction.hh"
44 #include "Run.hh"
45 #include "TestParameters.hh"
46 #include "G4Run.hh"
47 #include "G4RunManager.hh"
48 #include "G4SystemOfUnits.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53  : G4UserRunAction(), fAnalysisManager(0), fRun(0)
54 {
56  fAnalysisManager = G4AnalysisManager::Instance();
57  fAnalysisManager->SetFileName("testem8");
58  fAnalysisManager->SetVerboseLevel(1);
59  fAnalysisManager->SetActivation(true);
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {}
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
71  // Always creating analysis manager
73  G4int nBinsE = param->GetNumberBins();
74  G4int nBinsCluster = param->GetNumberBinsCluster();
75  G4int nMaxCluster = param->GetMaxCluster();
76  G4double maxEnergy = param->GetMaxEnergy();
77  G4double factorALICE = param->GetFactorALICE();
78 
79  //G4cout << "### maxenergy(keV)= " << maxEnergy/keV
80  // << " factorALICE= " << factorALICE << G4endl;
81 
82  // Creating an 1-dimensional histograms in the root directory of the tree
83  fAnalysisManager->SetFirstHistoId(1);
84  fAnalysisManager->CreateH1("h1","Energy deposition in detector (keV)",
85  nBinsE,0.0,maxEnergy/keV);
86  fAnalysisManager->CreateH1("h2","Number of primary clusters",
87  nBinsCluster,0.0,G4double(nMaxCluster));
88  fAnalysisManager->CreateH1("h3","Energy deposition in detector (ADC)",
89  nBinsE,0.0,maxEnergy*factorALICE);
90  fAnalysisManager->OpenFile();
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
96 {
97  fRun = new Run();
98  return fRun;
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
103 void RunAction::BeginOfRunAction(const G4Run* aRun)
104 {
105  G4int id = aRun->GetRunID();
106  G4cout << "### Run " << id << " start analysis activation: "
107  << G4endl;
108 
109  fRun->BeginOfRun();
110 
111  //histograms
112  Book();
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
117 void RunAction::EndOfRunAction(const G4Run*)
118 {
119  // print Run summary
120  G4cout << "RunAction: End of run actions are started " << isMaster
121  << " Nevt= " << fRun->GetNumberOfEvent()
122  << " Edep= " << fRun->GetStat()->mean() << G4endl;
123  if (isMaster) {
124  fRun->EndOfRun();
125  }
126  // save histos and close analysis
127  if (fAnalysisManager->IsActive()) {
128  fAnalysisManager->Write();
129  fAnalysisManager->CloseFile();
130  }
131  //delete fAnalysisManager;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static constexpr double keV
Definition: G4SIunits.hh:216
#define G4endl
Definition: G4ios.hh:61
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
double G4double
Definition: G4Types.hh:76
G4double mean() const
Definition: G4StatDouble.cc:83
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
const G4StatDouble * GetStat() const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout