Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B3EventAction.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$
27 //
30 
31 #include "B3EventAction.hh"
32 
33 #include "B3RunAction.hh"
34 
35 #include "G4RunManager.hh"
36 #include "G4Event.hh"
37 
38 #include "G4SDManager.hh"
39 #include "G4HCofThisEvent.hh"
40 #include "G4THitsMap.hh"
41 #include "G4UnitsTable.hh"
42 #include "G4SystemOfUnits.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47  : G4UserEventAction(),
48  fRunAct(runAction),
49  fCollID_cryst(0),
50  fCollID_patient(0),
51  fPrintModulo(10000)
52 {}
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 { }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  G4int evtNb = evt->GetEventID();
64 
65  if (evtNb == 0) {
67  fCollID_cryst = SDMan->GetCollectionID("crystal/edep");
68  fCollID_patient = SDMan->GetCollectionID("patient/dose");
69  }
70 
71  if (evtNb%fPrintModulo == 0) {
72  G4cout << "\n---> Begin of event: " << evtNb << G4endl;
73  }
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 {
80  //Hits collections
81  //
82  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
83  if(!HCE) return;
84 
85  //Energy in crystals : identify 'good events'
86  //
87  const G4double eThreshold = 500*keV;
88  G4int nbOfFired = 0;
89 
90  G4THitsMap<G4double>* evtMap =
91  (G4THitsMap<G4double>*)(HCE->GetHC(fCollID_cryst));
92 
93  std::map<G4int,G4double*>::iterator itr;
94  for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
96  G4double edep = *(itr->second);
97  if (edep > eThreshold) nbOfFired++;
99  }
100  if (nbOfFired == 2) fRunAct->CountEvents();
101 
102  //Dose deposit in patient
103  //
104  G4double dose = 0.;
105 
106  evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fCollID_patient));
107 
108  for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
110  dose = *(itr->second);
111  }
112  if (dose > 0.) fRunAct->SumDose(dose);
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......