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