Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GarfieldEventAction.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: GarfieldEventAction.cc 999993 2015-12-11 14:47:43Z dpfeiffe $
27//
28/// \file GarfieldEventAction.cc
29/// \brief Implementation of the GarfieldEventAction class
30
31#include "GarfieldPhysics.hh"
32
34#include "GarfieldRunAction.hh"
35#include "GarfieldAnalysis.hh"
36
37#include "G4RunManager.hh"
38#include "G4Event.hh"
39#include "G4UnitsTable.hh"
40
41#include "Randomize.hh"
42#include <iomanip>
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
47 G4UserEventAction(), fEnergyAbs(0.), fEnergyGas(0.), fTrackLAbs(0.) {
48}
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
53}
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56
57void GarfieldEventAction::BeginOfEventAction(const G4Event* /*event*/) {
58 // initialisation per event
59 fEnergyAbs = 0;
60 fEnergyGas = 0;
61 fTrackLAbs = 0;
62 fAvalancheSize = 0;
63 fGain = 0;
64
66 garfieldPhysics->Clear();
67}
68
69//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70
71void GarfieldEventAction::EndOfEventAction(const G4Event* event) {
72 // Accumulate statistics
73 //
75
76 // get analysis manager
77 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
78 //fEnergyGas += garfieldPhysics->GetEnergyDeposit_MeV();
79 fAvalancheSize = garfieldPhysics->GetAvalancheSize();
80 fGain = garfieldPhysics->GetGain();
81
82 // fill histograms
83 analysisManager->FillH1(1, fEnergyAbs);
84 analysisManager->FillH1(2, fTrackLAbs);
85 analysisManager->FillH1(3, fEnergyGas);
86 analysisManager->FillH1(4, fAvalancheSize);
87 analysisManager->FillH1(5, fGain);
88
89
90
91 // fill ntuple
92 analysisManager->FillNtupleDColumn(0, fEnergyAbs);
93 analysisManager->FillNtupleDColumn(1, fTrackLAbs);
94 analysisManager->FillNtupleDColumn(2, fEnergyGas);
95 analysisManager->FillNtupleDColumn(3, fAvalancheSize);
96 analysisManager->FillNtupleDColumn(4, fGain);
97
98 // Print per event (modulo n)
99 //
100 G4int eventID = event->GetEventID();
101 G4int printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
102 if ((printModulo > 0) && (eventID % printModulo == 0)) {
103 G4cout << "---> End of event: " << eventID << G4endl;
104
105 G4cout << " Absorber: total energy: " << std::setw(7)
106 << G4BestUnit(fEnergyAbs, "Energy")
107 << " total track length: " << std::setw(7)
108 << G4BestUnit(fTrackLAbs, "Length") << G4endl;
109
110 G4cout << " Gas: total energy: " << std::setw(7)
111 << G4BestUnit(fEnergyGas, "Energy") << " avalanche size: " << fAvalancheSize << " gain: " << fGain << G4endl;
112
113
114 }
115}
116
117//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Selection of the analysis technology.
Definition of the GarfieldEventAction class.
Definition of the GarfieldPhysics class.
Definition of the GarfieldRunAction class.
virtual void BeginOfEventAction(const G4Event *event)
virtual void EndOfEventAction(const G4Event *event)
static GarfieldPhysics * GetInstance()
double GetAvalancheSize()