Garfield++ 5.0
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/// \file GarfieldEventAction.cc
27/// \brief Implementation of the GarfieldEventAction class
28
30
31#include <iomanip>
32
33#include "G4Event.hh"
34#include "G4RunManager.hh"
35#include "G4UnitsTable.hh"
36#include "GarfieldAnalysis.hh"
37#include "GarfieldPhysics.hh"
38#include "GarfieldRunAction.hh"
39#include "Randomize.hh"
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42
44
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
47void GarfieldEventAction::BeginOfEventAction(const G4Event* /*event*/) {
48 // initialisation per event
49 fEnergyAbs = 0.;
50 fEnergyGas = 0.;
51 fTrackLAbs = 0.;
52 fAvalancheSize = 0.;
53 fGain = 0.;
54
56 garfieldPhysics->Clear();
57}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60
61void GarfieldEventAction::EndOfEventAction(const G4Event* event) {
62 // Accumulate statistics
64
65 // Get analysis manager
66 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
67 // fEnergyGas += garfieldPhysics->GetEnergyDeposit_MeV();
68 fAvalancheSize = garfieldPhysics->GetAvalancheSize();
69 fGain = garfieldPhysics->GetGain();
70
71 // fill histograms
72 analysisManager->FillH1(1, fEnergyAbs);
73 analysisManager->FillH1(2, fTrackLAbs);
74 analysisManager->FillH1(3, fEnergyGas);
75 analysisManager->FillH1(4, fAvalancheSize);
76 analysisManager->FillH1(5, fGain);
77
78 // fill ntuple
79 analysisManager->FillNtupleDColumn(0, fEnergyAbs);
80 analysisManager->FillNtupleDColumn(1, fTrackLAbs);
81 analysisManager->FillNtupleDColumn(2, fEnergyGas);
82 analysisManager->FillNtupleDColumn(3, fAvalancheSize);
83 analysisManager->FillNtupleDColumn(4, fGain);
84
85 // Print per event (modulo n)
86 //
87 G4int eventID = event->GetEventID();
88 G4int printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
89 if ((printModulo > 0) && (eventID % printModulo == 0)) {
90 G4cout << "---> End of event: " << eventID << G4endl;
91
92 G4cout << " Absorber: total energy: " << std::setw(7)
93 << G4BestUnit(fEnergyAbs, "Energy")
94 << " total track length: " << std::setw(7)
95 << G4BestUnit(fTrackLAbs, "Length") << G4endl;
96
97 G4cout << " Gas: total energy: " << std::setw(7)
98 << G4BestUnit(fEnergyGas, "Energy")
99 << " avalanche size: " << fAvalancheSize
100 << " gain: " << fGain << G4endl;
101 }
102}
103
104//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Selection of the analysis technology.
Definition of the GarfieldEventAction class.
Definition of the GarfieldPhysics class.
Definition of the GarfieldRunAction class.
void EndOfEventAction(const G4Event *event) override
void BeginOfEventAction(const G4Event *event) override
double GetAvalancheSize() const
static GarfieldPhysics * GetInstance()
double GetGain() const