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 | // HadrontherapyAnalysisManager.hh; May 2005 |
---|
27 | // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy |
---|
28 | |
---|
29 | #ifndef HADRONTHERAPYANALYSISMANAGER_HH |
---|
30 | #define HADRONTHERAPYANALYSISMANAGER_HH 1 |
---|
31 | |
---|
32 | #include "globals.hh" |
---|
33 | |
---|
34 | #ifdef ANALYSIS_USE ///< If we use analysis |
---|
35 | |
---|
36 | #ifdef G4ANALYSIS_USE ///< If analysis is done via AIDA |
---|
37 | #include <AIDA/AIDA.h> |
---|
38 | |
---|
39 | namespace AIDA{ |
---|
40 | class ITree; |
---|
41 | class IAnalysisFactory; |
---|
42 | class ITreeFactory; |
---|
43 | } |
---|
44 | #endif |
---|
45 | |
---|
46 | #ifdef G4ANALYSIS_USE_ROOT ///< If analysis is done directly with ROOT |
---|
47 | #include "TROOT.h" |
---|
48 | #include "TFile.h" |
---|
49 | #include "TNtuple.h" |
---|
50 | #include "TH1F.h" |
---|
51 | #endif |
---|
52 | |
---|
53 | /** |
---|
54 | * Messenger class for analysis-settings for HadronTherapyAnalysisManager |
---|
55 | */ |
---|
56 | class HadrontherapyAnalysisFileMessenger; |
---|
57 | |
---|
58 | /** |
---|
59 | * A class for connecting the simulation to an analysis package. |
---|
60 | */ |
---|
61 | class HadrontherapyAnalysisManager |
---|
62 | { |
---|
63 | private: |
---|
64 | /** |
---|
65 | * Analysis manager is a singleton object (there is only one instance). |
---|
66 | * The pointer to this object is available through the use of the method getInstance(); |
---|
67 | * |
---|
68 | * @see getInstance |
---|
69 | */ |
---|
70 | HadrontherapyAnalysisManager(); |
---|
71 | |
---|
72 | public: |
---|
73 | ~HadrontherapyAnalysisManager(); |
---|
74 | |
---|
75 | /** |
---|
76 | * Get the pointer to the analysis manager. |
---|
77 | */ |
---|
78 | static HadrontherapyAnalysisManager* getInstance(); |
---|
79 | |
---|
80 | /** |
---|
81 | * Book the histograms and ntuples in an AIDA or ROOT file. |
---|
82 | */ |
---|
83 | void book(); |
---|
84 | /** |
---|
85 | * Set name for the analysis file .root (used by macro) |
---|
86 | */ |
---|
87 | void SetAnalysisFileName(G4String); |
---|
88 | |
---|
89 | /** |
---|
90 | * Fill the ntuple with the energy deposit in the phantom |
---|
91 | */ |
---|
92 | void FillEnergyDeposit(G4int voxelXId, G4int voxelYId, G4int voxelZId, |
---|
93 | G4double energyDeposit); |
---|
94 | |
---|
95 | void BraggPeak(G4int, G4double); ///< Fill 1D histogram with the Bragg peak in the phantom |
---|
96 | |
---|
97 | void SecondaryProtonEnergyDeposit(G4int slice, G4double energy); |
---|
98 | ///< Fill 1D histogram with the energy deposit of secondary protons |
---|
99 | |
---|
100 | void SecondaryNeutronEnergyDeposit(G4int slice, G4double energy); |
---|
101 | ///< Fill 1D histogram with the energy deposit of secondary neutrons |
---|
102 | |
---|
103 | void SecondaryAlphaEnergyDeposit(G4int slice, G4double energy); |
---|
104 | ///< Fill 1D histogram with the energy deposit of secondary alpha particles |
---|
105 | |
---|
106 | void SecondaryGammaEnergyDeposit(G4int slice, G4double energy); |
---|
107 | ///< Fill 1D histogram with the energy deposit of secondary gamma |
---|
108 | |
---|
109 | void SecondaryElectronEnergyDeposit(G4int slice, G4double energy); |
---|
110 | ///< Fill 1D histogram with the energy deposit of secondary electrons |
---|
111 | |
---|
112 | void SecondaryTritonEnergyDeposit(G4int slice, G4double energy); |
---|
113 | ///< Fill 1D histogram with the energy deposit of secondary tritons |
---|
114 | |
---|
115 | void SecondaryDeuteronEnergyDeposit(G4int slice, G4double energy); |
---|
116 | ///< Fill 1D histogram with the energy deposit of secondary deuterons |
---|
117 | |
---|
118 | void SecondaryPionEnergyDeposit(G4int slice, G4double energy); |
---|
119 | ///< Fill 1D histogram with the energy deposit of secondary pions |
---|
120 | |
---|
121 | void electronEnergyDistribution(G4double secondaryParticleKineticEnergy); |
---|
122 | ///< Energy distribution of secondary electrons originated in the phantom |
---|
123 | |
---|
124 | void gammaEnergyDistribution(G4double secondaryParticleKineticEnergy); |
---|
125 | ///< Energy distribution of secondary gamma originated in the phantom |
---|
126 | |
---|
127 | void deuteronEnergyDistribution(G4double secondaryParticleKineticEnergy); |
---|
128 | ///< Energy distribution of secondary deuterons originated in the phantom |
---|
129 | |
---|
130 | void tritonEnergyDistribution(G4double secondaryParticleKineticEnergy); |
---|
131 | ///< Energy distribution of secondary tritons originated in the phantom |
---|
132 | |
---|
133 | void alphaEnergyDistribution(G4double secondaryParticleKineticEnergy); |
---|
134 | ///< Energy distribution of secondary alpha originated in the phantom |
---|
135 | |
---|
136 | void heliumEnergy(G4double secondaryParticleKineticEnergy); |
---|
137 | ///< Energy distribution of the helium (He3 and alpha) particles after the phantom |
---|
138 | |
---|
139 | void hydrogenEnergy(G4double secondaryParticleKineticEnergy); |
---|
140 | ///< Energy distribution of the hydrogen (proton, d, t) particles after the phantom |
---|
141 | |
---|
142 | void fillFragmentTuple(G4int A, G4double Z, G4double energy, G4double posX, G4double posY, G4double posZ); |
---|
143 | ///< Energy ntuple |
---|
144 | |
---|
145 | void genericIonInformation(G4int, G4double, G4int, G4double); |
---|
146 | |
---|
147 | void ThintargetBeamDisp(G4double,G4double); |
---|
148 | |
---|
149 | void startNewEvent(); |
---|
150 | ///< Tell the analysis manager that a new event is starting |
---|
151 | |
---|
152 | void setGeometryMetaData(G4double, G4double, G4double); |
---|
153 | ///< from the detector construction information about the geometry can be written as metadata |
---|
154 | |
---|
155 | void setBeamMetaData(G4double, G4double); |
---|
156 | ///< metadata about the beam can be written this way |
---|
157 | |
---|
158 | void finish(); |
---|
159 | ///< Close the .hbk file with the histograms and the ntuples |
---|
160 | |
---|
161 | void flush(); |
---|
162 | |
---|
163 | #ifdef G4ANALYSIS_USE_ROOT |
---|
164 | private: |
---|
165 | TH1F *createHistogram1D(const TString name, const TString title, int bins, double xmin, double xmax) { |
---|
166 | TH1F *histo = new TH1F(name, title, bins, xmin, xmax); |
---|
167 | histo->SetLineWidth(2); |
---|
168 | return histo; |
---|
169 | } |
---|
170 | #endif |
---|
171 | |
---|
172 | private: |
---|
173 | static HadrontherapyAnalysisManager* instance; |
---|
174 | HadrontherapyAnalysisFileMessenger* fMess; |
---|
175 | G4String analysisFileName; |
---|
176 | #ifdef G4ANALYSIS_USE |
---|
177 | AIDA::IAnalysisFactory* aFact; |
---|
178 | AIDA::ITree* theTree; |
---|
179 | AIDA::IHistogramFactory *histFact; |
---|
180 | AIDA::ITupleFactory *tupFact; |
---|
181 | AIDA::IHistogram1D *h1; |
---|
182 | AIDA::IHistogram1D *h2; |
---|
183 | AIDA::IHistogram1D *h3; |
---|
184 | AIDA::IHistogram1D *h4; |
---|
185 | AIDA::IHistogram1D *h5; |
---|
186 | AIDA::IHistogram1D *h6; |
---|
187 | AIDA::IHistogram1D *h7; |
---|
188 | AIDA::IHistogram1D *h8; |
---|
189 | AIDA::IHistogram1D *h9; |
---|
190 | AIDA::IHistogram1D *h10; |
---|
191 | AIDA::IHistogram1D *h11; |
---|
192 | AIDA::IHistogram1D *h12; |
---|
193 | AIDA::IHistogram1D *h13; |
---|
194 | AIDA::IHistogram1D *h14; |
---|
195 | AIDA::IHistogram1D *h15; |
---|
196 | AIDA::IHistogram1D *h16; |
---|
197 | AIDA::ITuple *ntuple; |
---|
198 | AIDA::ITuple *ionTuple; |
---|
199 | AIDA::ITuple *fragmentTuple; |
---|
200 | #endif |
---|
201 | #ifdef G4ANALYSIS_USE_ROOT |
---|
202 | TFile *theTFile; |
---|
203 | TH1F *histo1; |
---|
204 | TH1F *histo2; |
---|
205 | TH1F *histo3; |
---|
206 | TH1F *histo4; |
---|
207 | TH1F *histo5; |
---|
208 | TH1F *histo6; |
---|
209 | TH1F *histo7; |
---|
210 | TH1F *histo8; |
---|
211 | TH1F *histo9; |
---|
212 | TH1F *histo10; |
---|
213 | TH1F *histo11; |
---|
214 | TH1F *histo12; |
---|
215 | TH1F *histo13; |
---|
216 | TH1F *histo14; |
---|
217 | TH1F *histo15; |
---|
218 | TH1F *histo16; |
---|
219 | |
---|
220 | TNtuple *theROOTNtuple; |
---|
221 | TNtuple *theROOTIonTuple; |
---|
222 | TNtuple *fragmentNtuple; // fragments |
---|
223 | TNtuple *metaData; |
---|
224 | #endif |
---|
225 | G4long eventCounter; // Simulation metadata |
---|
226 | G4double detectorDistance; |
---|
227 | G4double phantomDepth; |
---|
228 | G4double beamEnergy; |
---|
229 | G4double energyError; |
---|
230 | G4double phantomCenterDistance; |
---|
231 | }; |
---|
232 | #endif |
---|
233 | |
---|
234 | #endif |
---|
235 | |
---|