Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/exoticphysics/monopole/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 107534 2017-11-21 13:13:36Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "RunAction.hh"
35 #include "RunActionMessenger.hh"
36 #include "DetectorConstruction.hh"
37 #include "PrimaryGeneratorAction.hh"
38 #include "Run.hh"
39 
40 #include "G4UnitsTable.hh"
41 #include "G4SystemOfUnits.hh"
42 #include "G4ios.hh"
43 #include "Randomize.hh"
44 
45 #include "G4EmCalculator.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  :fDetector(det),fKinematic(kin)
51 {
52  fMessenger = new RunActionMessenger(this);
53  fBinLength = 5 * CLHEP::mm;
54  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
55  analysisManager->SetFileName("monopole");
56  analysisManager->SetVerboseLevel(1);
57  analysisManager->SetActivation(true);
58 }
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {
64 #ifdef G4MULTITHREADED
65  if(isMaster) delete fKinematic;
66 #endif
67  delete fMessenger;
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
75  return fRun;
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
80 void RunAction::BeginOfRunAction(const G4Run* aRun)
81 {
82  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
83  //histograms
84  //
85  Book();
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
91 {
92  // print Run summary
93  //
95 
96  // save histograms
97  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
98  if ( analysisManager->IsActive() ) {
99  analysisManager->Write();
100  analysisManager->CloseFile();
101  }
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
107 {
108  fBinLength = size;
111  }
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
116 void RunAction::Book()
117 {
118  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
119  analysisManager->SetFirstHistoId(1);
120 
121  G4double length = fDetector->GetAbsorSizeX();
122  G4int nbBins = G4lrint(length / fBinLength);
123 
124  // Create histograms
125  analysisManager->CreateH1("h1","Edep (MeV/mm) along absorber (mm)",
126  nbBins, 0, length);
127  analysisManager->CreateH1("h2","DEDX (MeV/mm) of proton", 100, -3., 7.);
128  analysisManager->CreateH1("h3","DEDX (MeV/mm) of monopole", 100, -3., 7.);
129  analysisManager->CreateH1("h4","Range(mm) of proton", 100, -3., 7., "mm");
130  analysisManager->CreateH1("h5","Range(mm) of monopole", 100, -3., 7., "mm");
131  analysisManager->OpenFile();
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4int GetRunID() const
Definition: G4Run.hh:76
The primary generator action class with particle gun.
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Run.hh:46
int G4lrint(double ad)
Definition: templates.hh:151
int G4int
Definition: G4Types.hh:78
static constexpr double mm
Definition: SystemOfUnits.h:95
G4GLOB_DLL std::ostream G4cout
Simple detector construction with a box volume placed in a world.