Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GarfieldRunAction.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// $Id: GarfieldRunAction.cc 999999 2015-12-11 14:47:43Z dpfeiffe $
27//
28/// \file GarfieldRunAction.cc
29/// \brief Implementation of the GarfieldRunAction class
30
31
32#include "GarfieldRunAction.hh"
33#include "GarfieldAnalysis.hh"
34
35#include "G4Run.hh"
36#include "G4RunManager.hh"
37#include "G4UnitsTable.hh"
38#include "G4SystemOfUnits.hh"
39
40//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41
43 G4UserRunAction() {
44 // set printing event number per each event
45 G4RunManager::GetRunManager()->SetPrintProgress(1);
46
47 // Create analysis manager
48 // The choice of analysis technology is done via selectin of a namespace
49 // in Garfieldnalysis.hh
50 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
51 G4cout << "Using " << analysisManager->GetType() << G4endl;
52
53 // Create directories
54 //analysisManager->SetHistoDirectoryName("histograms");
55 //analysisManager->SetNtupleDirectoryName("ntuple");
56 analysisManager->SetVerboseLevel(1);
57 analysisManager->SetFirstHistoId(1);
58
59 // Book histograms, ntuple
60 //
61
62 // Creating histograms
63 analysisManager->CreateH1("1", "Edep in absorber", 100, 0., 800 * MeV);
64 analysisManager->CreateH1("2", "trackL in absorber", 100, 0., 1 * m);
65 analysisManager->CreateH1("3", "Edep in gas", 1000, 0., 100 * keV);
66
67 analysisManager->CreateH1("4", "Avalanche size in gas", 10000,0, 10000);
68 analysisManager->CreateH1("5", "gain", 1000, 0., 100);
69 analysisManager->CreateH3("1", "Track position",200, -10*cm, 10*cm, 29, -1.45*cm, 1.45*cm, 29,-1.45*cm, 1.45*cm);
70
71 // Creating ntuple
72 //
73 analysisManager->CreateNtuple("Garfield", "Edep and TrackL");
74 analysisManager->CreateNtupleDColumn("Eabs");
75 analysisManager->CreateNtupleDColumn("Labs");
76 analysisManager->CreateNtupleDColumn("Egas");
77 analysisManager->CreateNtupleDColumn("AvalancheSize");
78 analysisManager->CreateNtupleDColumn("Gain");
79 analysisManager->FinishNtuple();
80
81
82
83}
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86
88 delete G4AnalysisManager::Instance();
89}
90
91//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92
93void GarfieldRunAction::BeginOfRunAction(const G4Run* /*run*/) {
94 //inform the runManager to save random number seed
95 //G4RunManager::GetRunManager()->SetRandomNumberStore(true);
96
97 // Get analysis manager
98 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
99
100 // Open an output file
101 //
102 G4String fileName = "Garfield";
103 analysisManager->OpenFile(fileName);
104}
105
106//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107
108void GarfieldRunAction::EndOfRunAction(const G4Run* /*run*/) {
109 // print histogram statistics
110 //
111 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
112 if (analysisManager->GetH1(1)) {
113 G4cout << G4endl << " ----> print histograms statistic ";
114 if (isMaster) {
115 G4cout << "for the entire run " << G4endl << G4endl;
116 } else {
117 G4cout << "for the local thread " << G4endl << G4endl;
118 }
119
120 G4cout << " EAbs : mean = "
121 << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
122 << " rms = "
123 << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy")
124 << G4endl;
125
126 G4cout << " LAbs : mean = "
127 << G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
128 << " rms = "
129 << G4BestUnit(analysisManager->GetH1(2)->rms(), "Length")
130 << G4endl;
131
132 G4cout << " EGas : mean = "
133 << G4BestUnit(analysisManager->GetH1(3)->mean(), "Energy")
134 << " rms = "
135 << G4BestUnit(analysisManager->GetH1(3)->rms(), "Energy")
136 << G4endl;
137
138 G4cout << " Avalanche size : mean = "
139 << analysisManager->GetH1(4)->mean()
140 << " rms = "
141 << analysisManager->GetH1(4)->rms()
142 << G4endl;
143
144 G4cout << " Gain : mean = "
145 << analysisManager->GetH1(5)->mean()
146 << " rms = "
147 << analysisManager->GetH1(5)->rms()
148 << G4endl;
149 }
150
151 // save histograms & ntuple
152 //
153 analysisManager->Write();
154 analysisManager->CloseFile();
155
156}
157
158//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Selection of the analysis technology.
Definition of the GarfieldRunAction class.
virtual void BeginOfRunAction(const G4Run *)
virtual void EndOfRunAction(const G4Run *)
virtual ~GarfieldRunAction()