ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventAction.cc
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 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "EventAction.hh"
35 
36 #include "Run.hh"
37 #include "HistoManager.hh"
38 
39 #include "G4Event.hh"
40 #include "G4RunManager.hh"
41 #include "G4SystemOfUnits.hh"
42 #include "G4UnitsTable.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
48  fEdep1(0.), fEdep2(0.), fWeight1(0.), fWeight2(0.),
49  fTime0(-1*s)
50 { }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 { }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61  fEdep1 = fEdep2 = fWeight1 = fWeight2 = 0.;
62  fTime0 = -1*s;
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
69 {
70  // initialize t0
71  if (fTime0 < 0.) fTime0 = time;
72 
73  // out of time window ?
74  const G4double TimeWindow (1*microsecond);
75  if (std::fabs(time - fTime0) > TimeWindow) return;
76 
77  if (iVol == 1) { fEdep1 += edep; fWeight1 += edep*weight;}
78  if (iVol == 2) { fEdep2 += edep; fWeight2 += edep*weight;}
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
86 
87  G4double Etot = fEdep1 + fEdep2;
88  G4double Wtot = (fWeight1 + fWeight2)/Etot;
89 
90  // pulse height in target
91  //
92  if (fEdep1 > 0.) {
93  fWeight1 /= fEdep1;
94  analysisManager->FillH1(0, fEdep1, fWeight1);
95  }
96 
97  // pulse height in detector
98  //
99  if (fEdep2 > 0.) {
100  fWeight2 /= fEdep2;
101  analysisManager->FillH1(1, fEdep2, fWeight2);
102  }
103 
104  // total
105  //
106  analysisManager->FillH1(2, Etot, Wtot);
107 
108  // threshold in target and detector
109  const G4double Threshold1(10*keV), Threshold2(10*keV);
110 
111  //coincidence, anti-coincidences
112  //
113  G4bool coincidence = ((fEdep1 >= Threshold1) && (fEdep2 >= Threshold2));
114  G4bool anti_coincidence1 = ((fEdep1 >= Threshold1) && (fEdep2 < Threshold2));
115  G4bool anti_coincidence2 = ((fEdep1 < Threshold1) && (fEdep2 >= Threshold2));
116 
117  if (coincidence) analysisManager->FillH1(3, fEdep2, fWeight2);
118  if (anti_coincidence1) analysisManager->FillH1(4, fEdep1, fWeight1);
119  if (anti_coincidence2) analysisManager->FillH1(5, fEdep2, fWeight2);
120 
121  // pass energies to Run
122  //
123  Run* run = static_cast<Run*>(
125 
126  run->AddEdep (fEdep1, fEdep2);
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 
131