Geant4  10.02.p02
HadrontherapyEventAction.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 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 
29 #include "G4SystemOfUnits.hh"
30 #include "G4Event.hh"
31 #include "G4EventManager.hh"
32 #include "G4HCofThisEvent.hh"
33 #include "G4VHitsCollection.hh"
34 #include "G4SDManager.hh"
35 #include "G4VVisManager.hh"
36 
41 #include "HadrontherapyMatrix.hh"
43 
46  drawFlag("all" ),printModulo(1000), pointerEventMessenger(0)
47 {
48  hitsCollectionID = -1;
50 }
51 
54 {
55  delete pointerEventMessenger;
56 }
57 
60 {
61  G4int evtNb = evt->GetEventID();
62 
63  //printing survey
64  if (evtNb%printModulo == 0)
65  G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
66 
68  if(hitsCollectionID == -1)
69  hitsCollectionID = pSDManager -> GetCollectionID("HadrontherapyDetectorHitsCollection");
70 
71 }
72 
75 {
76  if(hitsCollectionID < 0)
77  return;
78  G4HCofThisEvent* HCE = evt -> GetHCofThisEvent();
79 
80  // Clear voxels hit list
82  if (matrix) matrix -> ClearHitTrack();
83 
84  if(HCE)
85  {
87  if(CHC)
88  {
89  if(matrix)
90  {
91  // Fill the matrix with the information: voxel and associated energy deposit
92  // in the detector at the end of the event
93 
94  G4int HitCount = CHC -> entries();
95  for (G4int h=0; h<HitCount; h++)
96  {
97  G4int i = ((*CHC)[h]) -> GetXID();
98  G4int j = ((*CHC)[h]) -> GetYID();
99  G4int k = ((*CHC)[h]) -> GetZID();
100  G4double energyDeposit = ((*CHC)[h]) -> GetEdep();
101  matrix -> Fill(i, j, k, energyDeposit/MeV);
102  }
103  }
104  }
105  }
106 }
107 
static const double MeV
Definition: G4SIunits.hh:211
int G4int
Definition: G4Types.hh:78
void EndOfEventAction(const G4Event *)
G4int GetEventID() const
Definition: G4Event.hh:151
static HadrontherapyMatrix * GetInstance()
G4GLOB_DLL std::ostream G4cout
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
void BeginOfEventAction(const G4Event *)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
HadrontherapyEventActionMessenger * pointerEventMessenger