| 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: HadrontherapyEventAction.cc;
|
|---|
| 27 | //
|
|---|
| 28 | // See more at: http://workgroup.lngs.infn.it/geant4lns
|
|---|
| 29 | //
|
|---|
| 30 | // ----------------------------------------------------------------------------
|
|---|
| 31 | // GEANT 4 - Hadrontherapy example
|
|---|
| 32 | // ----------------------------------------------------------------------------
|
|---|
| 33 | // Code developed by:
|
|---|
| 34 | //
|
|---|
| 35 | // G.A.P. Cirrone(a)*, G. Candiano, F. Di Rosa(a), S. Guatelli(b), G. Russo(a)
|
|---|
| 36 | //
|
|---|
| 37 | // (a) Laboratori Nazionali del Sud
|
|---|
| 38 | // of the National Institute for Nuclear Physics, Catania, Italy
|
|---|
| 39 | // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy
|
|---|
| 40 | //
|
|---|
| 41 | // * cirrone@lns.infn.it
|
|---|
| 42 | // --------------------------------------------------------------
|
|---|
| 43 | #include "G4Event.hh"
|
|---|
| 44 | #include "G4EventManager.hh"
|
|---|
| 45 | #include "G4HCofThisEvent.hh"
|
|---|
| 46 | #include "G4VHitsCollection.hh"
|
|---|
| 47 | #include "G4SDManager.hh"
|
|---|
| 48 | #include "G4VVisManager.hh"
|
|---|
| 49 |
|
|---|
| 50 | #include "HadrontherapyEventAction.hh"
|
|---|
| 51 | #include "HadrontherapyDetectorHit.hh"
|
|---|
| 52 | #include "HadrontherapyDetectorSD.hh"
|
|---|
| 53 | #include "HadrontherapyDetectorConstruction.hh"
|
|---|
| 54 | #include "HadrontherapyMatrix.hh"
|
|---|
| 55 | #include "HadrontherapyEventActionMessenger.hh"
|
|---|
| 56 |
|
|---|
| 57 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 58 | HadrontherapyEventAction::HadrontherapyEventAction() :
|
|---|
| 59 | drawFlag("all" ),printModulo(1000), pointerEventMessenger(0)
|
|---|
| 60 | {
|
|---|
| 61 | hitsCollectionID = -1;
|
|---|
| 62 | pointerEventMessenger = new HadrontherapyEventActionMessenger(this);
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 66 | HadrontherapyEventAction::~HadrontherapyEventAction()
|
|---|
| 67 | {
|
|---|
| 68 | delete pointerEventMessenger;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 72 | void HadrontherapyEventAction::BeginOfEventAction(const G4Event* evt)
|
|---|
| 73 | {
|
|---|
| 74 | G4int evtNb = evt->GetEventID();
|
|---|
| 75 |
|
|---|
| 76 | //printing survey
|
|---|
| 77 | if (evtNb%printModulo == 0)
|
|---|
| 78 | G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
|
|---|
| 79 |
|
|---|
| 80 | G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
|
|---|
| 81 | if(hitsCollectionID == -1)
|
|---|
| 82 | hitsCollectionID = pSDManager -> GetCollectionID("HadrontherapyDetectorHitsCollection");
|
|---|
| 83 |
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 87 | void HadrontherapyEventAction::EndOfEventAction(const G4Event* evt)
|
|---|
| 88 | {
|
|---|
| 89 | if(hitsCollectionID < 0)
|
|---|
| 90 | return;
|
|---|
| 91 | G4HCofThisEvent* HCE = evt -> GetHCofThisEvent();
|
|---|
| 92 |
|
|---|
| 93 | // Clear voxels hit list
|
|---|
| 94 | HadrontherapyMatrix* matrix = HadrontherapyMatrix::GetInstance();
|
|---|
| 95 | if (matrix) matrix -> ClearHitTrack();
|
|---|
| 96 |
|
|---|
| 97 | if(HCE)
|
|---|
| 98 | {
|
|---|
| 99 | HadrontherapyDetectorHitsCollection* CHC = (HadrontherapyDetectorHitsCollection*)(HCE -> GetHC(hitsCollectionID));
|
|---|
| 100 | if(CHC)
|
|---|
| 101 | {
|
|---|
| 102 | if(matrix)
|
|---|
| 103 | {
|
|---|
| 104 | // Fill the matrix with the information: voxel and associated energy deposit
|
|---|
| 105 | // in the detector at the end of the event
|
|---|
| 106 |
|
|---|
| 107 | G4int HitCount = CHC -> entries();
|
|---|
| 108 | for (G4int h=0; h<HitCount; h++)
|
|---|
| 109 | {
|
|---|
| 110 | G4int i = ((*CHC)[h]) -> GetXID();
|
|---|
| 111 | G4int j = ((*CHC)[h]) -> GetYID();
|
|---|
| 112 | G4int k = ((*CHC)[h]) -> GetZID();
|
|---|
| 113 | G4double energyDeposit = ((*CHC)[h]) -> GetEdep();
|
|---|
| 114 | matrix -> Fill(i, j, k, energyDeposit/MeV);
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|