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 | // Code developed by: |
---|
27 | // S.Guatelli |
---|
28 | // |
---|
29 | // ******************************* |
---|
30 | // * * |
---|
31 | // * BrachyAnalysisManager.cc * |
---|
32 | // * * |
---|
33 | // ******************************* |
---|
34 | // |
---|
35 | // $Id: BrachyAnalysisManager.cc,v 1.3 2006/06/29 17:32:37 gunter Exp $ |
---|
36 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
37 | // |
---|
38 | #ifdef G4ANALYSIS_USE |
---|
39 | #include <stdlib.h> |
---|
40 | #include <fstream> |
---|
41 | #include "BrachyAnalysisManager.hh" |
---|
42 | |
---|
43 | #include "G4ios.hh" |
---|
44 | |
---|
45 | #include "AIDA/IHistogram1D.h" |
---|
46 | #include "AIDA/IHistogram2D.h" |
---|
47 | |
---|
48 | #include "AIDA/IManagedObject.h" |
---|
49 | #include "AIDA/IAnalysisFactory.h" |
---|
50 | #include "AIDA/IHistogramFactory.h" |
---|
51 | #include "AIDA/ITupleFactory.h" |
---|
52 | #include "AIDA/ITreeFactory.h" |
---|
53 | #include "AIDA/ITree.h" |
---|
54 | #include "AIDA/ITuple.h" |
---|
55 | |
---|
56 | BrachyAnalysisManager* BrachyAnalysisManager::instance = 0; |
---|
57 | |
---|
58 | BrachyAnalysisManager::BrachyAnalysisManager() : |
---|
59 | aFact(0), theTree(0), histFact(0), h1(0), h2(0) |
---|
60 | |
---|
61 | { |
---|
62 | //build up the factories |
---|
63 | aFact = AIDA_createAnalysisFactory(); |
---|
64 | |
---|
65 | AIDA::ITreeFactory *treeFact = aFact -> createTreeFactory(); |
---|
66 | |
---|
67 | //parameters for the TreeFactory |
---|
68 | |
---|
69 | std::string fileName = "brachytherapy.xml"; |
---|
70 | theTree = treeFact -> create(fileName,"xml",false, true, "uncompressed"); |
---|
71 | |
---|
72 | delete treeFact; |
---|
73 | |
---|
74 | histFact = aFact -> createHistogramFactory( *theTree ); |
---|
75 | } |
---|
76 | |
---|
77 | BrachyAnalysisManager::~BrachyAnalysisManager() |
---|
78 | { |
---|
79 | delete histFact; |
---|
80 | histFact = 0; |
---|
81 | |
---|
82 | delete theTree; |
---|
83 | histFact = 0; |
---|
84 | |
---|
85 | delete aFact; |
---|
86 | aFact = 0; |
---|
87 | } |
---|
88 | |
---|
89 | BrachyAnalysisManager* BrachyAnalysisManager::getInstance() |
---|
90 | { |
---|
91 | if (instance == 0) instance = new BrachyAnalysisManager; |
---|
92 | return instance; |
---|
93 | } |
---|
94 | |
---|
95 | void BrachyAnalysisManager::book() |
---|
96 | { |
---|
97 | //creating a 1D histogram ... |
---|
98 | h1 = histFact -> createHistogram2D("10","Energy, pos", //histoID,histo name |
---|
99 | 300 ,-150.,150., //bins'number,xmin,xmax |
---|
100 | 300,-150.,150. );//bins'number,ymin,ymax |
---|
101 | //creating a 2D histogram ... |
---|
102 | h2 = histFact -> createHistogram1D("20","Initial Energy", //histoID,histo name |
---|
103 | 100,0.,1.); //bins' number, xmin, xmax |
---|
104 | |
---|
105 | h3 = histFact -> createHistogram1D("30","Dose Distribution", |
---|
106 | 300,-150.,150.); //bins' number, xmin, xmax |
---|
107 | } |
---|
108 | |
---|
109 | void BrachyAnalysisManager::FillHistogramWithEnergy(G4double x, |
---|
110 | G4double z, |
---|
111 | G4double energyDeposit) |
---|
112 | { |
---|
113 | h1 -> fill(x,z,energyDeposit); |
---|
114 | } |
---|
115 | |
---|
116 | void BrachyAnalysisManager::PrimaryParticleEnergySpectrum(G4double primaryParticleEnergy) |
---|
117 | { |
---|
118 | //1DHisotgram: energy spectrum of primary particles |
---|
119 | h2 -> fill(primaryParticleEnergy); |
---|
120 | } |
---|
121 | void BrachyAnalysisManager::DoseDistribution(G4double x,G4double energy) |
---|
122 | { |
---|
123 | //1DHisotgram: energy spectrum of primary particles |
---|
124 | h3 -> fill(x,energy); |
---|
125 | } |
---|
126 | |
---|
127 | void BrachyAnalysisManager::finish() |
---|
128 | { |
---|
129 | // write all histograms to file ... |
---|
130 | theTree -> commit(); |
---|
131 | |
---|
132 | // close (will again commit) ... |
---|
133 | theTree -> close(); |
---|
134 | } |
---|
135 | #endif |
---|
136 | |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | |
---|