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 | // $Id: G4FluoDataTest.cc,v ???? |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | // ------------------------------------------------------------------- |
---|
31 | // GEANT 4 class file --- Copyright CERN 1998 |
---|
32 | // CERN Geneva Switzerland |
---|
33 | // |
---|
34 | // |
---|
35 | // File name: G4DataSetManagerTest |
---|
36 | // |
---|
37 | // Author: Elena Guardincerri |
---|
38 | // |
---|
39 | // Creation date: 6 August 2001 |
---|
40 | // |
---|
41 | // Modifications: 26 April 2002 -- AM |
---|
42 | // |
---|
43 | // ------------------------------------------------------------------- |
---|
44 | |
---|
45 | #include "globals.hh" |
---|
46 | #include "G4DataVector.hh" |
---|
47 | #include "G4ios.hh" |
---|
48 | #include <fstream> |
---|
49 | #include <iomanip> |
---|
50 | #include "AIDA/AIDA.h" |
---|
51 | #include "G4FluoData.hh" |
---|
52 | |
---|
53 | |
---|
54 | int main(int argc, char* argv[]) |
---|
55 | |
---|
56 | { |
---|
57 | G4cout.setf( std::ios::scientific, std::ios::floatfield ); |
---|
58 | |
---|
59 | if (argc == 2) { |
---|
60 | G4int Z = atoi(argv[1]); |
---|
61 | G4FluoData* dataSet = new G4FluoData(); |
---|
62 | dataSet->LoadData(Z); |
---|
63 | G4int vac= dataSet->NumberOfVacancies(); |
---|
64 | AIDA::ITree* tree; |
---|
65 | AIDA::IAnalysisFactory* analysisFactory; |
---|
66 | AIDA::IHistogramFactory* cloudFactory; |
---|
67 | AIDA::ICloud1D* cloudFluo; |
---|
68 | |
---|
69 | AIDA::ITree* treeTuple; |
---|
70 | AIDA::ITupleFactory* tupleFactory; |
---|
71 | AIDA::ITuple* tupleFluo; |
---|
72 | |
---|
73 | analysisFactory = AIDA_createAnalysisFactory(); |
---|
74 | AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory(); |
---|
75 | G4String zString; |
---|
76 | std::ostringstream stream; |
---|
77 | stream << "fluorescence" << Z << ".xml"; |
---|
78 | G4String fileName = stream.str(); |
---|
79 | tree = treeFactory->create(fileName,"xml",false,true); |
---|
80 | cloudFactory = analysisFactory->createHistogramFactory(*tree); |
---|
81 | cloudFluo = cloudFactory->createCloud1D("c1"); |
---|
82 | assert(cloudFluo); |
---|
83 | stream.str(""); |
---|
84 | stream << "fluorescenceTuple" << Z << ".hbk"; |
---|
85 | G4String fileNameTuple = stream.str(); |
---|
86 | treeTuple = treeFactory->create(fileNameTuple,"hbook",false,true); |
---|
87 | tupleFactory = analysisFactory->createTupleFactory(*treeTuple); |
---|
88 | // Book tuple column names |
---|
89 | std::vector<std::string> columnNames; |
---|
90 | // Book tuple column types |
---|
91 | std::vector<std::string> columnTypes; |
---|
92 | |
---|
93 | columnNames.push_back("Z"); |
---|
94 | columnNames.push_back("DataType"); |
---|
95 | columnNames.push_back("ShellStart"); |
---|
96 | columnNames.push_back("ShellStop"); |
---|
97 | columnNames.push_back("ShellOrigAuger"); |
---|
98 | columnNames.push_back("Energy"); |
---|
99 | columnNames.push_back("Probability"); |
---|
100 | columnNames.push_back("EnUnc"); |
---|
101 | columnNames.push_back("Type"); |
---|
102 | |
---|
103 | columnTypes.push_back("int"); |
---|
104 | columnTypes.push_back("int"); |
---|
105 | columnTypes.push_back("int"); |
---|
106 | columnTypes.push_back("int"); |
---|
107 | columnTypes.push_back("int"); |
---|
108 | columnTypes.push_back("double"); |
---|
109 | columnTypes.push_back("double"); |
---|
110 | columnTypes.push_back("double"); |
---|
111 | columnTypes.push_back("int"); |
---|
112 | |
---|
113 | tupleFluo = tupleFactory->create("10", "Total Tuple", columnNames, columnTypes, ""); |
---|
114 | assert(tupleFluo); |
---|
115 | |
---|
116 | for (G4int vacancyIndex=0; vacancyIndex < vac; vacancyIndex++) { |
---|
117 | G4int n = dataSet->NumberOfTransitions(vacancyIndex); |
---|
118 | for (G4int initIndex=0; initIndex < n; initIndex++){ |
---|
119 | G4int id = dataSet->VacancyId(vacancyIndex); |
---|
120 | G4double startingShellEnergy = dataSet->StartShellEnergy(initIndex,vacancyIndex); |
---|
121 | G4int startingShellId = dataSet->StartShellId(initIndex,vacancyIndex); |
---|
122 | G4double startingShellProb = dataSet-> StartShellProb(initIndex,vacancyIndex); |
---|
123 | cloudFluo->fill(startingShellEnergy); |
---|
124 | |
---|
125 | tupleFluo->fill(0,Z); |
---|
126 | tupleFluo->fill(1,0); |
---|
127 | tupleFluo->fill(2,id); |
---|
128 | tupleFluo->fill(3,startingShellId); |
---|
129 | tupleFluo->fill(4,0); |
---|
130 | tupleFluo->fill(5,startingShellEnergy); |
---|
131 | tupleFluo->fill(6,startingShellProb); |
---|
132 | G4double error = 0; |
---|
133 | if (startingShellEnergy/eV < 100) { |
---|
134 | error = startingShellEnergy*0.3; |
---|
135 | } |
---|
136 | else {error = startingShellEnergy*0.10; |
---|
137 | } |
---|
138 | tupleFluo->fill(7,error); |
---|
139 | tupleFluo->fill(8,0); |
---|
140 | |
---|
141 | tupleFluo->addRow(); |
---|
142 | } |
---|
143 | } |
---|
144 | tree->commit(); // Write histos in file. |
---|
145 | tree->close(); |
---|
146 | treeTuple->commit(); // Write histos in file. |
---|
147 | treeTuple->close(); |
---|
148 | delete dataSet; |
---|
149 | } |
---|
150 | else { |
---|
151 | |
---|
152 | G4cout << "Enter Z" << G4endl; |
---|
153 | G4int Z; |
---|
154 | G4cin >> Z; |
---|
155 | |
---|
156 | G4FluoData* dataSet = new G4FluoData(); |
---|
157 | |
---|
158 | dataSet->LoadData(Z); |
---|
159 | |
---|
160 | G4int vac= dataSet->NumberOfVacancies(); |
---|
161 | G4cout << "The atom of atomic number "<<Z<<" has " |
---|
162 | << vac<<" vacancies "<<G4endl; |
---|
163 | G4cout << "Enter the index of the vacancy" << G4endl; |
---|
164 | G4int vacancyIndex; |
---|
165 | G4cin >> vacancyIndex; |
---|
166 | |
---|
167 | |
---|
168 | G4int n = dataSet->NumberOfTransitions(vacancyIndex); |
---|
169 | G4int id = dataSet->VacancyId(vacancyIndex); |
---|
170 | G4cout << " The shell whose index is " <<vacancyIndex |
---|
171 | << " has identity " << id << G4endl; |
---|
172 | G4cout <<" Electrons can reach it from "<< n <<" shells."<<G4endl; |
---|
173 | G4cout << "Enter the index of the starting shell" << G4endl; |
---|
174 | G4int initIndex; |
---|
175 | G4cin >>initIndex; |
---|
176 | G4int startingShellId = dataSet->StartShellId(initIndex,vacancyIndex); |
---|
177 | G4double startingShellEnergy = dataSet-> StartShellEnergy(initIndex,vacancyIndex); |
---|
178 | G4double startingShellProb = dataSet-> StartShellProb(initIndex,vacancyIndex); |
---|
179 | G4cout <<" The identity of the starting shell is "<<startingShellId<<G4endl; |
---|
180 | G4cout<<" The energy of the transition to the final shell is " |
---|
181 | << startingShellEnergy<< " MeV "<<G4endl; |
---|
182 | G4cout<<" The probability of the transition to the final shell is " |
---|
183 | <<startingShellProb <<G4endl; |
---|
184 | |
---|
185 | G4cout << "PRINT DATA"<<G4endl; |
---|
186 | |
---|
187 | dataSet->PrintData(); |
---|
188 | delete dataSet; |
---|
189 | } |
---|
190 | |
---|
191 | |
---|
192 | G4cout << "END OF THE MAIN PROGRAM" << G4endl; |
---|
193 | } |
---|
194 | |
---|
195 | |
---|
196 | |
---|
197 | |
---|
198 | |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | |
---|
203 | |
---|
204 | |
---|
205 | |
---|
206 | |
---|