Loading...
Searching...
No Matches
EventAction.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//
27/// \file B4/B4a/src/EventAction.cc
28/// \brief Implementation of the B4a::EventAction class
29
30#include "EventAction.hh"
31#include "RunAction.hh"
32
33#include "G4AnalysisManager.hh"
34#include "G4RunManager.hh"
35#include "G4Event.hh"
36#include "G4UnitsTable.hh"
37
38#include "Randomize.hh"
39#include <iomanip>
40
41namespace B4a
42{
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
47{
48 // initialisation per event
49 fEnergyAbs = 0.;
50 fEnergyGap = 0.;
51 fTrackLAbs = 0.;
52 fTrackLGap = 0.;
53}
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56
58{
59 // get analysis manager
60 auto analysisManager = G4AnalysisManager::Instance();
61
62 // fill histograms
63 analysisManager->FillH1(0, fEnergyAbs);
64 analysisManager->FillH1(1, fEnergyGap);
65 analysisManager->FillH1(2, fTrackLAbs);
66 analysisManager->FillH1(3, fTrackLGap);
67
68 // fill ntuple
69 analysisManager->FillNtupleDColumn(0, fEnergyAbs);
70 analysisManager->FillNtupleDColumn(1, fEnergyGap);
71 analysisManager->FillNtupleDColumn(2, fTrackLAbs);
72 analysisManager->FillNtupleDColumn(3, fTrackLGap);
73 analysisManager->AddNtupleRow();
74
75 // Print per event (modulo n)
76 //
77 auto eventID = event->GetEventID();
78 auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
79 if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
80 G4cout
81 << " Absorber: total energy: " << std::setw(7)
82 << G4BestUnit(fEnergyAbs,"Energy")
83 << " total track length: " << std::setw(7)
84 << G4BestUnit(fTrackLAbs,"Length")
85 << G4endl
86 << " Gap: total energy: " << std::setw(7)
87 << G4BestUnit(fEnergyGap,"Energy")
88 << " total track length: " << std::setw(7)
89 << G4BestUnit(fTrackLGap,"Length")
90 << G4endl;
91
92 G4cout << "--> End of event " << eventID << "\n" << G4endl;
93 }
94}
95
96//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
97
98}
G4double fEnergyAbs
G4double fEnergyGap
G4double fTrackLAbs
G4double fTrackLGap
void BeginOfEventAction(const G4Event *event) override
void EndOfEventAction(const G4Event *event) override

Applications | User Support | Publications | Collaboration