Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HadrontherapyAnalysisManager.hh
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 #ifndef HADRONTHERAPYANALYSISMANAGER_HH
36 #define HADRONTHERAPYANALYSISMANAGER_HH 1
37 
38 #include "globals.hh"
39 
40 
41 #ifdef G4ANALYSIS_USE_ROOT ///< If analysis is done directly with ROOT
42 #include "TROOT.h"
43 #include "TFile.h"
44 #include "TNtuple.h"
45 #include "TH1F.h"
46 #endif
47 /**
48  * Messenger class for analysis-settings for HadronTherapyAnalysisManager
49  */
51 
52 /**
53  * A class for connecting the simulation to an analysis package.
54  */
56 {
57 private:
58  /**
59  * Analysis manager is a singleton object (there is only one instance).
60  * The pointer to this object is available through the use of the method GetInstance();
61  *
62  * @see GetInstance
63  */
65 
66 public:
68 
69  /**
70  * Get the pointer to the analysis manager.
71  */
73 
74 #ifdef G4ANALYSIS_USE_ROOT
75  /**
76  * Clear analysis manager heap.
77  */
78  void Clear();
79  /**
80  * Check if TFile is there!
81  */
82  G4bool IsTheTFile();
83  /**
84  * Book the histograms and ntuples in an AIDA or ROOT file.
85  */
86  void book();
87  /**
88  * Set name for the analysis file .root (used by macro)
89  */
90  void SetAnalysisFileName(G4String);
91 
92  /**
93  * Fill the ntuple with the energy deposit in the phantom
94  */
95  void FillEnergyDeposit(G4int voxelXId, G4int voxelYId, G4int voxelZId,
96  G4double energyDeposit);
97 
98  void BraggPeak(G4int, G4double); ///< Fill 1D histogram with the Bragg peak in the phantom
99 
100  void SecondaryProtonEnergyDeposit(G4int slice, G4double energy);
101  ///< Fill 1D histogram with the energy deposit of secondary protons
102 
103  void SecondaryNeutronEnergyDeposit(G4int slice, G4double energy);
104  ///< Fill 1D histogram with the energy deposit of secondary neutrons
105 
106  void SecondaryAlphaEnergyDeposit(G4int slice, G4double energy);
107  ///< Fill 1D histogram with the energy deposit of secondary alpha particles
108 
109  void SecondaryGammaEnergyDeposit(G4int slice, G4double energy);
110  ///< Fill 1D histogram with the energy deposit of secondary gamma
111 
112  void SecondaryElectronEnergyDeposit(G4int slice, G4double energy);
113  ///< Fill 1D histogram with the energy deposit of secondary electrons
114 
115  void SecondaryTritonEnergyDeposit(G4int slice, G4double energy);
116  ///< Fill 1D histogram with the energy deposit of secondary tritons
117 
118  void SecondaryDeuteronEnergyDeposit(G4int slice, G4double energy);
119  ///< Fill 1D histogram with the energy deposit of secondary deuterons
120 
121  void SecondaryPionEnergyDeposit(G4int slice, G4double energy);
122  ///< Fill 1D histogram with the energy deposit of secondary pions
123 
124  void electronEnergyDistribution(G4double secondaryParticleKineticEnergy);
125  ///< Energy distribution of secondary electrons originated in the phantom
126 
127  void gammaEnergyDistribution(G4double secondaryParticleKineticEnergy);
128  ///< Energy distribution of secondary gamma originated in the phantom
129 
130  void deuteronEnergyDistribution(G4double secondaryParticleKineticEnergy);
131  ///< Energy distribution of secondary deuterons originated in the phantom
132 
133  void tritonEnergyDistribution(G4double secondaryParticleKineticEnergy);
134  ///< Energy distribution of secondary tritons originated in the phantom
135 
136  void alphaEnergyDistribution(G4double secondaryParticleKineticEnergy);
137  ///< Energy distribution of secondary alpha originated in the phantom
138 
139  void heliumEnergy(G4double secondaryParticleKineticEnergy);
140  ///< Energy distribution of the helium (He3 and alpha) particles after the phantom
141 
142  void hydrogenEnergy(G4double secondaryParticleKineticEnergy);
143  ///< Energy distribution of the hydrogen (proton, d, t) particles after the phantom
144 
145  //Kinetic energy by voxel, mass number A and atomic number Z.
146  void FillKineticFragmentTuple(G4int i, G4int j, G4int k, G4int A, G4double Z, G4double kinEnergy);
147 
148  //Kinetic energy by voxel, mass number A and atomic number Z of only primary particles
149  void FillKineticEnergyPrimaryNTuple(G4int i, G4int j, G4int k, G4double kinEnergy);
150 
151  ///< Energy by voxel, mass number A and atomic number Z.
152  void FillVoxelFragmentTuple(G4int i, G4int j, G4int k, G4int A, G4double Z, G4double energy, G4double fluence);
153 
154  void FillFragmentTuple(G4int A, G4double Z, G4double energy, G4double posX, G4double posY, G4double posZ);
155  ///< Energy ntuple
156 
157  // void FillLetFragmentTuple(G4int i, G4int j, G4int k, G4int A, G4double Z, G4double letT, G4double letD);
158  ///< let ntuple
159  void FillLetFragmentTuple(G4int i, G4int j, G4int k, G4int A, G4double Z, G4double letD);
160  void genericIonInformation(G4int, G4double, G4int, G4double);
161 
162  void ThintargetBeamDisp(G4double,G4double);
163 
164  void startNewEvent();
165  ///< Tell the analysis manager that a new event is starting
166 
167  void setGeometryMetaData(G4double, G4double, G4double);
168  ///< from the detector construction information about the geometry can be written as metadata
169 
170  void setBeamMetaData(G4double, G4double);
171  ///< metadata about the beam can be written this way
172 
173  void flush();
174  ///< Close the .hbk file with the histograms and the ntuples
175 private:
176  TH1F *createHistogram1D(const TString name, const TString title, int bins, double xmin, double xmax) {
177  TH1F *histo = new TH1F(name, title, bins, xmin, xmax);
178  histo->SetLineWidth(2);
179  return histo;
180  }
181 
182 private:
183 #endif
186 #ifdef G4ANALYSIS_USE_ROOT
187  G4String analysisFileName;
188  TFile *theTFile;
189  TH1F *histo1;
190  TH1F *histo2;
191  TH1F *histo3;
192  TH1F *histo4;
193  TH1F *histo5;
194  TH1F *histo6;
195  TH1F *histo7;
196  TH1F *histo8;
197  TH1F *histo9;
198  TH1F *histo10;
199  TH1F *histo11;
200  TH1F *histo12;
201  TH1F *histo13;
202  TH1F *histo14;
203  TH1F *histo15;
204  TH1F *histo16;
205 
206  TNtuple *kinFragNtuple;
207  TNtuple *kineticEnergyPrimaryNtuple;
208 
209  // ntuple containing the fluence of all the particle in any voxel
210  TNtuple *doseFragNtuple;
211 
212  // ntuple containing the fluence of all the particle in any voxel
213  TNtuple *fluenceFragNtuple;
214 
215  // ntuple containing the fluence of all the particle in any voxel
216  TNtuple *letFragNtuple;
217 
218  TNtuple *theROOTNtuple;
219  TNtuple *theROOTIonTuple;
220  TNtuple *fragmentNtuple; // fragments
221  TNtuple *metaData;
222  G4long eventCounter; // Simulation metadata
223  G4double detectorDistance;
224  G4double phantomDepth;
225  G4double beamEnergy;
226  G4double energyError;
227  G4double phantomCenterDistance;
228 #endif
229 };
230 #endif
231 
232 
233 
static HadrontherapyAnalysisManager * GetInstance()
void Clear(Node *)
long G4long
Definition: G4Types.hh:80
const XML_Char * name
static HadrontherapyAnalysisManager * instance
int G4int
Definition: G4Types.hh:78
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
bool G4bool
Definition: G4Types.hh:79
HadrontherapyAnalysisFileMessenger * fMess
subroutine title(NA, NB, NCA, NCB)
Definition: dpm25nuc7.f:1744
double G4double
Definition: G4Types.hh:76