Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 // $Id: EventAction.cc 76293 2013-11-08 13:11:23Z gcosmo $
30 //
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "EventAction.hh"
36 
37 #include "Run.hh"
38 #include "HistoManager.hh"
39 
40 #include "G4Event.hh"
41 #include "G4RunManager.hh"
42 #include "G4SystemOfUnits.hh"
43 #include "G4UnitsTable.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
49  fEdep1(0.), fEdep2(0.), fWeight1(0.), fWeight2(0.),
50  fTime0(-1*s)
51 { }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 { }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  fEdep1 = fEdep2 = fWeight1 = fWeight2 = 0.;
63  fTime0 = -1*s;
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69  G4double time, G4double weight)
70 {
71  // initialize t0
72  if (fTime0 < 0.) fTime0 = time;
73 
74  // out of time window ?
75  const G4double TimeWindow (1*microsecond);
76  if (std::fabs(time - fTime0) > TimeWindow) return;
77 
78  if (iVol == 1) { fEdep1 += edep; fWeight1 += edep*weight;}
79  if (iVol == 2) { fEdep2 += edep; fWeight2 += edep*weight;}
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
87 
88  G4double Etot = fEdep1 + fEdep2;
89  G4double Wtot = (fWeight1 + fWeight2)/Etot;
90 
91  // pulse height in target
92  //
93  if (fEdep1 > 0.) {
94  fWeight1 /= fEdep1;
95  analysisManager->FillH1(0, fEdep1, fWeight1);
96  }
97 
98  // pulse height in detector
99  //
100  if (fEdep2 > 0.) {
101  fWeight2 /= fEdep2;
102  analysisManager->FillH1(1, fEdep2, fWeight2);
103  }
104 
105  // total
106  //
107  analysisManager->FillH1(2, Etot, Wtot);
108 
109  // threshold in target and detector
110  const G4double Threshold1(10*keV), Threshold2(10*keV);
111 
112  //coincidence, anti-coincidences
113  //
114  G4bool coincidence = ((fEdep1 >= Threshold1) && (fEdep2 >= Threshold2));
115  G4bool anti_coincidence1 = ((fEdep1 >= Threshold1) && (fEdep2 < Threshold2));
116  G4bool anti_coincidence2 = ((fEdep1 < Threshold1) && (fEdep2 >= Threshold2));
117 
118  if (coincidence) analysisManager->FillH1(3, fEdep2, fWeight2);
119  if (anti_coincidence1) analysisManager->FillH1(4, fEdep1, fWeight1);
120  if (anti_coincidence2) analysisManager->FillH1(5, fEdep2, fWeight2);
121 
122  // pass energies to Run
123  //
124  Run* run = static_cast<Run*>(
126 
127  run->AddEdep (fEdep1, fEdep2);
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 
132 
void AddEdep(G4double Edep)
Definition: EventAction.hh:53
void BeginOfEventAction(const G4Event *)
Definition: EventAction.cc:61
int G4int
Definition: G4Types.hh:78
void EndOfEventAction(const G4Event *)
Definition: EventAction.cc:95
void AddEdep(G4double val)
Definition: Run.hh:61
const XML_Char * s
Definition: expat.h:262
bool G4bool
Definition: G4Types.hh:79
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static constexpr double microsecond
Definition: G4SIunits.hh:160
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
static constexpr double keV
Definition: G4SIunits.hh:216
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const