Geant4  10.02.p01
B4aEventAction.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: B4aEventAction.cc 75604 2013-11-04 13:17:26Z gcosmo $
27 //
30 
31 #include "B4aEventAction.hh"
32 #include "B4RunAction.hh"
33 #include "B4Analysis.hh"
34 
35 #include "G4RunManager.hh"
36 #include "G4Event.hh"
37 #include "G4UnitsTable.hh"
38 
39 #include "Randomize.hh"
40 #include <iomanip>
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
46  fEnergyAbs(0.),
47  fEnergyGap(0.),
48  fTrackLAbs(0.),
49  fTrackLGap(0.)
50 {}
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {}
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61  // initialisation per event
62  fEnergyAbs = 0.;
63  fEnergyGap = 0.;
64  fTrackLAbs = 0.;
65  fTrackLGap = 0.;
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 {
72  // Accumulate statistics
73  //
74 
75  // get analysis manager
76  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
77 
78  // fill histograms
79  analysisManager->FillH1(1, fEnergyAbs);
80  analysisManager->FillH1(2, fEnergyGap);
81  analysisManager->FillH1(3, fTrackLAbs);
82  analysisManager->FillH1(4, fTrackLGap);
83 
84  // fill ntuple
85  analysisManager->FillNtupleDColumn(0, fEnergyAbs);
86  analysisManager->FillNtupleDColumn(1, fEnergyGap);
87  analysisManager->FillNtupleDColumn(2, fTrackLAbs);
88  analysisManager->FillNtupleDColumn(3, fTrackLGap);
89  analysisManager->AddNtupleRow();
90 
91  // Print per event (modulo n)
92  //
93  G4int eventID = event->GetEventID();
95  if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
96  G4cout << "---> End of event: " << eventID << G4endl;
97 
98  G4cout
99  << " Absorber: total energy: " << std::setw(7)
100  << G4BestUnit(fEnergyAbs,"Energy")
101  << " total track length: " << std::setw(7)
102  << G4BestUnit(fTrackLAbs,"Length")
103  << G4endl
104  << " Gap: total energy: " << std::setw(7)
105  << G4BestUnit(fEnergyGap,"Energy")
106  << " total track length: " << std::setw(7)
107  << G4BestUnit(fTrackLGap,"Length")
108  << G4endl;
109  }
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void EndOfEventAction(const G4Event *event)
G4int GetPrintProgress()
virtual void BeginOfEventAction(const G4Event *event)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4double fEnergyAbs
G4GLOB_DLL std::ostream G4cout
G4double fTrackLGap
virtual ~B4aEventAction()
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
Definition of the B4aEventAction class.
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4double fEnergyGap
G4double fTrackLAbs
#define G4endl
Definition: G4ios.hh:61