Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application
27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
28 //
29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
30 // the *COMPLETE* version of this program, together with its documentation;
31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
32 // Institute in the framework of the MC-INFN Group
33 //
34 
35 #include "G4SystemOfUnits.hh"
36 #include "G4Event.hh"
37 #include "G4EventManager.hh"
38 #include "G4HCofThisEvent.hh"
39 #include "G4VHitsCollection.hh"
40 #include "G4SDManager.hh"
41 #include "G4VVisManager.hh"
42 
47 #include "HadrontherapyMatrix.hh"
49 
50 /////////////////////////////////////////////////////////////////////////////
52  drawFlag("all" ),printModulo(1000), pointerEventMessenger(0)
53 {
54  hitsCollectionID = -1;
55  pointerEventMessenger = new HadrontherapyEventActionMessenger(this);
56 }
57 
58 /////////////////////////////////////////////////////////////////////////////
60 {
61  delete pointerEventMessenger;
62 }
63 
64 /////////////////////////////////////////////////////////////////////////////
66 {
67  G4int evtNb = evt->GetEventID();
68 
69  //printing survey
70  if (evtNb%printModulo == 0)
71  G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
72 
74  if(hitsCollectionID == -1)
75  hitsCollectionID = pSDManager -> GetCollectionID("HadrontherapyDetectorHitsCollection");
76 
77 }
78 
79 /////////////////////////////////////////////////////////////////////////////
81 {
82  if(hitsCollectionID < 0)
83  return;
84  G4HCofThisEvent* HCE = evt -> GetHCofThisEvent();
85 
86  // Clear voxels hit list
88  if (matrix) matrix -> ClearHitTrack();
89 
90  if(HCE)
91  {
92  HadrontherapyDetectorHitsCollection* CHC = (HadrontherapyDetectorHitsCollection*)(HCE -> GetHC(hitsCollectionID));
93  if(CHC)
94  {
95  if(matrix)
96  {
97  // Fill the matrix with the information: voxel and associated energy deposit
98  // in the detector at the end of the event
99 
100  G4int HitCount = CHC -> entries();
101  for (G4int h=0; h<HitCount; h++)
102  {
103  G4int i = ((*CHC)[h]) -> GetXID();
104  G4int j = ((*CHC)[h]) -> GetYID();
105  G4int k = ((*CHC)[h]) -> GetZID();
106  G4double energyDeposit = ((*CHC)[h]) -> GetEdep();
107  matrix -> Fill(i, j, k, energyDeposit/MeV);
108  }
109  }
110  }
111  }
112 }
113 
int G4int
Definition: G4Types.hh:78
void EndOfEventAction(const G4Event *)
G4int GetEventID() const
Definition: G4Event.hh:140
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