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 | // Igor Pshenichnov 01.12.2006 |
---|
28 | |
---|
29 | #include "MFTestHistoManager.hh" |
---|
30 | |
---|
31 | #ifdef G4ANALYSIS_USE_ROOT |
---|
32 | #include "TFile.h" |
---|
33 | #include "TH1D.h" |
---|
34 | #include "TH2D.h" |
---|
35 | #endif |
---|
36 | |
---|
37 | MFTestHistoManager::MFTestHistoManager() |
---|
38 | : Z(0), A(0), lowLimitExEn(-1.), upperLimitExEn(-1.), binsExEn(1), eventsPerBin(1) |
---|
39 | { |
---|
40 | std::cout << "######### Test the Statistical Multifragmentation model of GEANT4" << G4endl; |
---|
41 | |
---|
42 | while ( (Z<8) || (Z>100) ) { |
---|
43 | std::cout << "Please choose Z from 8 to 100: "; |
---|
44 | std::cin >> Z; |
---|
45 | } |
---|
46 | |
---|
47 | while ( (A<16) || (A>250) ) { |
---|
48 | std::cout << "Please choose A from 16 to 250: "; |
---|
49 | std::cin >> A; |
---|
50 | } |
---|
51 | |
---|
52 | while ( (lowLimitExEn<0.) || (lowLimitExEn>100.) ) { |
---|
53 | std::cout << "Please choose the low limit for the range of excitation energy (per nucleon in MeV) : from 0 to 100: "; |
---|
54 | std::cin >> lowLimitExEn; |
---|
55 | } |
---|
56 | |
---|
57 | while ( (upperLimitExEn<0.) || (upperLimitExEn>100.) || (upperLimitExEn<lowLimitExEn) ) { |
---|
58 | std::cout << "Please choose the upper limit for the range of excitation energy (per nucleon in MeV) : from 0 to 100: "; |
---|
59 | std::cin >> upperLimitExEn; |
---|
60 | } |
---|
61 | lowLimitExEn *= A; |
---|
62 | lowLimitExEn *= MeV; |
---|
63 | upperLimitExEn *=A; |
---|
64 | upperLimitExEn *=MeV; |
---|
65 | |
---|
66 | |
---|
67 | while ( (binsExEn<10) || (binsExEn>10000) ) { |
---|
68 | std::cout << "Please choose the number of bins in histograms (10 - 1000): "; |
---|
69 | std::cin >> binsExEn; |
---|
70 | } |
---|
71 | |
---|
72 | while ( (eventsPerBin<10) || (eventsPerBin>10000) ) { |
---|
73 | std::cout << "Please enter the average number of break-up events in each bin (10 - 10000): "; |
---|
74 | std::cin >> eventsPerBin; |
---|
75 | } |
---|
76 | iterations = binsExEn*eventsPerBin; |
---|
77 | |
---|
78 | std::cout << "Please enter the file name to write histograms (.root will be supplied): "; |
---|
79 | std::cin >> fileName; |
---|
80 | |
---|
81 | #ifdef G4ANALYSIS_USE_ROOT |
---|
82 | for (G4int j=0; j<20; j++) histo[j] = 0; |
---|
83 | for (G4int l=0; l<10; l++) histo2[l] = 0; |
---|
84 | #endif |
---|
85 | |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | MFTestHistoManager::~MFTestHistoManager() |
---|
90 | {} |
---|
91 | |
---|
92 | void MFTestHistoManager::BookHisto() |
---|
93 | { |
---|
94 | #ifdef G4ANALYSIS_USE_ROOT |
---|
95 | |
---|
96 | // Open a file to keep histograms inside it ... |
---|
97 | |
---|
98 | if ( fileName == "") fileName = "MFTest"; |
---|
99 | fileType = "root"; |
---|
100 | |
---|
101 | fileFullName = fileName+"."+fileType; |
---|
102 | compressionFactor = 8; |
---|
103 | fFile = new TFile(fileFullName, "RECREATE", fileName, compressionFactor); |
---|
104 | G4cout << "Histograms will be written to " << fileFullName << G4endl; |
---|
105 | |
---|
106 | // Book all histograms there ... |
---|
107 | |
---|
108 | histo[0] = new TH1D("multip","Average multiplicity",binsExEn,lowLimitExEn/A,upperLimitExEn/A); |
---|
109 | histo[1] = new TH1D("C10","Yield of C-10",binsExEn,lowLimitExEn/A,upperLimitExEn/A); |
---|
110 | histo[2] = new TH1D("C11","Yield of C-11",binsExEn,lowLimitExEn/A,upperLimitExEn/A); |
---|
111 | histo[3] = new TH1D("<Z>(A)","aver Z for given A", A+2, -0.5, A+1.5); |
---|
112 | histo[4] = new TH1D("NofE(A)","Number of entries for each A", A+2, -0.5, A+1.5); |
---|
113 | |
---|
114 | histo2[0] = new TH2D("Z", "Charge distribution of fragments", |
---|
115 | binsExEn,lowLimitExEn/A,upperLimitExEn/A, |
---|
116 | Z+2, -0.5, Z+1.5); |
---|
117 | histo2[1] = new TH2D("A", "Mass distribution of fragments", |
---|
118 | binsExEn,lowLimitExEn/A,upperLimitExEn/A, |
---|
119 | A+2, -0.5, A+1.5); |
---|
120 | |
---|
121 | #endif |
---|
122 | } |
---|
123 | |
---|
124 | void MFTestHistoManager::NormalizeHisto() |
---|
125 | { |
---|
126 | #ifdef G4ANALYSIS_USE_ROOT |
---|
127 | |
---|
128 | // Divide by the number of events in each energy bin: |
---|
129 | |
---|
130 | G4double factor = 1./eventsPerBin; |
---|
131 | |
---|
132 | histo[0]->Scale(factor); |
---|
133 | histo[1]->Scale(factor); |
---|
134 | histo[2]->Scale(factor); |
---|
135 | histo2[0]->Scale(factor); |
---|
136 | histo2[1]->Scale(factor); |
---|
137 | |
---|
138 | // Special procedure to calculate the average Z for given A |
---|
139 | |
---|
140 | G4double content = 0.; |
---|
141 | G4double NofEventsInTheBin = 0.; |
---|
142 | |
---|
143 | for (G4int i=0; i<=histo[3]->GetNbinsX(); i++){ |
---|
144 | |
---|
145 | content = histo[3]->GetBinContent(i); |
---|
146 | NofEventsInTheBin = histo[4]->GetBinContent(i); |
---|
147 | |
---|
148 | if (NofEventsInTheBin > 0.) { |
---|
149 | content /= NofEventsInTheBin; |
---|
150 | histo[3]->SetBinContent(i,content); |
---|
151 | } |
---|
152 | }; |
---|
153 | |
---|
154 | #endif |
---|
155 | |
---|
156 | } |
---|
157 | |
---|
158 | void MFTestHistoManager::CleanHisto() |
---|
159 | { |
---|
160 | #ifdef G4ANALYSIS_USE_ROOT |
---|
161 | fFile->Write(); |
---|
162 | G4cout << "\n----> Histograms were written into the file " << fileFullName << G4endl; |
---|
163 | // delete [] histo; |
---|
164 | // delete [] histo2; |
---|
165 | delete fFile; |
---|
166 | #endif |
---|
167 | } |
---|
168 | |
---|
169 | void MFTestHistoManager::fill(G4int i, G4double x, G4double y) |
---|
170 | { |
---|
171 | #ifdef G4ANALYSIS_USE_ROOT |
---|
172 | histo[i]->Fill(x,y); |
---|
173 | #endif |
---|
174 | } |
---|
175 | |
---|
176 | void MFTestHistoManager::fill2(G4int i, G4double x, G4double y, G4double z) |
---|
177 | { |
---|
178 | #ifdef G4ANALYSIS_USE_ROOT |
---|
179 | histo2[i]->Fill(x,y,z); |
---|
180 | #endif |
---|
181 | } |
---|