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