source: trunk/examples/advanced/brachytherapy/src/BrachyPhantomSD.cc @ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.7 KB
Line 
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//
27// Code developed by:
28// S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano, S.Guatelli
29//
30//    ********************************
31//    *                              * 
32//    *    BrachyPhantomSD.cc       *
33//    *                              *
34//    ********************************
35//
36// $Id: BrachyPhantomSD.cc,v 1.14 2009/02/23 17:34:26 gunter Exp $
37// GEANT4 tag $Name: geant4-09-04-beta-01 $
38//
39#include "BrachyPhantomSD.hh"
40#ifdef G4ANALYSIS_USE
41#include "BrachyAnalysisManager.hh"
42#endif
43#include "BrachyDetectorConstruction.hh"
44#include "G4Track.hh"
45#include "G4LogicalVolume.hh"
46#include "G4VPhysicalVolume.hh"
47#include "G4Step.hh"
48#include "G4VTouchable.hh"
49#include "G4TouchableHistory.hh"
50#include "G4SDManager.hh"
51#include "G4ParticleDefinition.hh"
52
53BrachyPhantomSD::BrachyPhantomSD(G4String name):G4VSensitiveDetector(name)
54{
55}
56
57BrachyPhantomSD::~BrachyPhantomSD()
58{
59 
60}
61
62void BrachyPhantomSD::Initialize(G4HCofThisEvent*)
63{
64}
65
66G4bool BrachyPhantomSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
67{
68  //
69  // The energy deposit of the hits is stored in histograms and ntuples
70  //
71
72  if(!ROhist)
73    return false;
74 
75  // Check the volume
76  if(aStep -> GetPreStepPoint() -> GetPhysicalVolume() -> 
77     GetName() != "PhantomPhys")
78    return false;
79
80  G4double energyDeposit = aStep -> GetTotalEnergyDeposit();
81
82  // Check that the energy deposit is not null
83  if(energyDeposit == 0.)
84    return false;
85         
86  if(energyDeposit != 0)                       
87            {           
88              // Read Voxel indexes:
89              // i is the x index,
90              // j is the y index
91              // k is the z index
92              G4int j = ROhist -> GetReplicaNumber();
93              G4int k = ROhist -> GetReplicaNumber(1);
94              G4int i = ROhist -> GetReplicaNumber(2);
95 
96              G4int numberOfVoxel = 300;
97              G4double voxelWidth = 1. *mm;
98       
99              // Retrieve the coordinates of the center of the voxel where
100              // the energy deposit is located
101              x = ( - numberOfVoxel + 1+ 2*i )* voxelWidth/2; 
102              y = ( - numberOfVoxel + 1+ 2*j )* voxelWidth/2;
103              z = ( - numberOfVoxel + 1+ 2*k )* voxelWidth/2;
104
105#ifdef G4ANALYSIS_USE   
106              BrachyAnalysisManager* analysis = 
107                BrachyAnalysisManager::getInstance();   
108             
109              // Fill the ntuple with position and energy deposit in the phantom
110              analysis -> FillNtupleWithEnergy(x,y,z,energyDeposit/MeV);
111
112              if (y < 0.8 * mm && y > -0.8 * mm)
113                { 
114                  // Fill a 2D histogram with the energy deposit in the plane
115                  // containing the source
116                  analysis -> FillHistogramWithEnergy(x,z,energyDeposit/MeV);
117   
118                  //  Fill 1D histogram with the energy deposit
119                  // along the axis perpendicular to the main axis of the source
120                  if (z < 0.8 * mm && z > -0.8 * mm)               
121                    analysis -> DoseDistribution(x,energyDeposit/MeV);
122                }
123#endif 
124            }
125  return true;
126}
127
128void BrachyPhantomSD::EndOfEvent(G4HCofThisEvent*)
129{
130}
131
132void BrachyPhantomSD::clear()
133{
134} 
135
136void BrachyPhantomSD::DrawAll()
137{
138}
139
140void BrachyPhantomSD::PrintAll()
141{
142}
143
144
145
Note: See TracBrowser for help on using the repository browser.