source: trunk/source/processes/electromagnetic/lowenergy/test/fluoTest/src/XrayFluoAnalysisManager.cc@ 1201

Last change on this file since 1201 was 1199, checked in by garnier, 16 years ago

nvx fichiers dans CVS

File size: 8.2 KB
Line 
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: XrayFluoAnalysisManager.cc
28// GEANT4 tag $Name: xray_fluo-V03-02-00
29//
30// Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
31//
32// History:
33// -----------
34// 28 Nov 2001 Elena Guardincerri Created
35//
36// -------------------------------------------------------------------
37#ifdef G4ANALYSIS_USE
38
39#include "XrayFluoAnalysisManager.hh"
40#include "XrayFluoAnalysisMessenger.hh"
41#include "G4Step.hh"
42
43XrayFluoAnalysisManager* XrayFluoAnalysisManager::instance = 0;
44
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46
47XrayFluoAnalysisManager::XrayFluoAnalysisManager()
48{
49 analysisMessenger = new XrayFluoAnalysisMessenger(this);
50 histoManager = createIHistoManager();
51 factory = Lizard::createNTupleFactory();
52}
53
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55
56XrayFluoAnalysisManager::~XrayFluoAnalysisManager()
57{
58
59 delete analysisMessenger;
60 analysisMessenger = 0;
61 delete histoManager;
62 histoManager = 0;
63 delete factory;
64 factory = 0;
65}
66
67//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
68
69XrayFluoAnalysisManager* XrayFluoAnalysisManager::getInstance()
70{
71 if (instance == 0) instance = new XrayFluoAnalysisManager;
72 return instance;
73}
74//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
75
76
77void XrayFluoAnalysisManager::book()
78
79{
80 histoManager->selectStore("XrayFluo.his");
81
82 // Book histograms
83 histoManager->create1D("1","Energy Deposit", 100,0.,10.);
84 histoManager->create1D("2","Gamma born in the sample", 100,0.,10.);
85 histoManager->create1D("3","Electrons born in the sample", 100,0.,10.);
86 histoManager->create1D("4","Gammas leaving the sample", 100,0.,10.);
87 histoManager->create1D("5","Electrons leaving the sample ", 100,0.,10.);
88 histoManager->create1D("6","Gammas reaching the detector", 100,0.,10.);
89 histoManager->create1D("7","Spectrum of the incident particles", 100,0.,10.);
90 histoManager->create1D("8","Protons reaching the detector", 100,0.,10.);
91 histoManager->create1D("9","Protons leaving the sample", 100,0.,10.);
92
93 // Book ntuples
94 ntuple = factory->createC("XrayFluo.his::1");
95
96 // Add and bind the attributes to the ntuple
97 if ( !( ntuple->addAndBind( "energy", eDep) &&
98 ntuple->addAndBind( "counts" , counts ) ) )
99
100 {
101 delete ntuple;
102 G4Exception("XrayFluoAnalysisManager::book - Could not addAndBind ntuple");
103 }
104}
105
106//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
107
108void XrayFluoAnalysisManager::finish()
109{
110
111 histoManager->store("1");
112 histoManager->store("3");
113 histoManager->store("2");
114 histoManager->store("4");
115 histoManager->store("5");
116 histoManager->store("6");
117 histoManager->store("7");
118 histoManager->store("8");
119 histoManager->store("9");
120
121
122 delete ntuple;
123 ntuple = 0;
124 G4cout << "Deleted ntuple" << G4endl;
125}
126
127//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
128
129void XrayFluoAnalysisManager::analyseStepping(const G4Step* aStep)
130{
131 G4double gammaAtTheDetPre=0;
132 G4double protonsAtTheDetPre=0;
133 G4double gammaLeavingSample=0;
134 G4double eleLeavingSample=0;
135 G4double protonsLeavSam=0;
136 G4double gammaBornInSample=0;
137 G4double eleBornInSample=0;
138 if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Sample"){
139
140 if(aStep->GetTrack()->GetNextVolume()->GetName() == "World" )
141 {
142 if ((aStep->GetTrack()->GetDynamicParticle()
143 ->GetDefinition()-> GetParticleName()) == "gamma" )
144 {
145 gammaLeavingSample = (aStep->GetPreStepPoint()->GetKineticEnergy());
146 IHistogram1D* h1 = histoManager->retrieveHisto1D("4");
147 h1->fill(gammaLeavingSample/keV);
148 }
149 }
150 }
151 if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Sample"){
152
153 if(aStep->GetTrack()->GetNextVolume()->GetName() == "World" )
154 {
155 if ((aStep->GetTrack()->GetDynamicParticle()
156 ->GetDefinition()-> GetParticleName()) == "e-" )
157 {
158 eleLeavingSample = (aStep->GetPreStepPoint()->GetKineticEnergy());
159
160 IHistogram1D* h2 = histoManager->retrieveHisto1D("5");
161 h2->fill(eleLeavingSample/keV);
162 }
163 else if ((aStep->GetTrack()->GetDynamicParticle()
164 ->GetDefinition()-> GetParticleName()) == "proton" )
165 {
166 protonsLeavSam = (aStep->GetPreStepPoint()->GetKineticEnergy());
167 IHistogram1D* h3 = histoManager->retrieveHisto1D("9");
168 h3->fill(protonsLeavSam/keV);
169 }
170
171 }
172 }
173
174
175 if((aStep->GetTrack()->GetDynamicParticle()
176 ->GetDefinition()-> GetParticleName()) == "gamma" )
177
178 {if(1== (aStep->GetTrack()->GetCurrentStepNumber()))
179
180 {if(0 != aStep->GetTrack()->GetParentID())
181
182 {if(aStep->GetTrack()->GetVolume()->GetName() == "Sample")
183 {
184 gammaBornInSample = (aStep->GetPreStepPoint()->GetKineticEnergy());
185 IHistogram1D* h4 = histoManager->retrieveHisto1D("2");
186 h4->fill(gammaBornInSample);
187
188 }
189 }
190 }
191 }
192 if((aStep->GetTrack()->GetDynamicParticle()
193 ->GetDefinition()-> GetParticleName()) == "e-" )
194
195 {if(1== (aStep->GetTrack()->GetCurrentStepNumber()))
196
197 {if(0 != aStep->GetTrack()->GetParentID())
198
199 {if(aStep->GetTrack()->GetVolume()->GetName() == "Sample")
200 {
201 eleBornInSample = (aStep->GetPreStepPoint()->GetKineticEnergy());
202 IHistogram1D* h5 = histoManager->retrieveHisto1D("3");
203 h5->fill(eleBornInSample);
204 }
205 }
206 }
207 }
208
209 if(aStep->GetTrack()->GetNextVolume()){
210
211 if(aStep->GetTrack()->GetVolume()->GetName() == "World"){
212
213 if(aStep->GetTrack()->GetNextVolume()->GetName() == "HPGeDetector")
214
215 {
216 if ((aStep->GetTrack()->GetDynamicParticle()
217 ->GetDefinition()-> GetParticleName()) == "gamma" )
218 {
219 gammaAtTheDetPre = (aStep->GetPreStepPoint()->GetKineticEnergy());
220 IHistogram1D* h6 = histoManager->retrieveHisto1D("6");
221 h6->fill( gammaAtTheDetPre);
222 }
223 else if ((aStep->GetTrack()->GetDynamicParticle()
224 ->GetDefinition()-> GetParticleName()) == "proton" )
225 {
226 protonsAtTheDetPre = (aStep->GetPreStepPoint()->GetKineticEnergy());
227 IHistogram1D* h7 = histoManager->retrieveHisto1D("8");
228 h7->fill( protonsAtTheDetPre);
229 }
230 }
231 }
232 }
233}
234//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
235
236void XrayFluoAnalysisManager::analyseEnergyDep(G4double energyDep)
237{
238 IHistogram1D* h8 = histoManager->retrieveHisto1D("1");
239 h8->fill(energyDep/keV);
240 counts = 1.;
241 ntuple->addRow();
242
243}
244
245//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
246
247void XrayFluoAnalysisManager::analysePrimaryGenerator(G4double energy)
248{
249 IHistogram1D* h9 = histoManager->retrieveHisto1D("7");
250 h9->fill(energy/keV);
251
252}
253#endif
254
255
256
257
258
259
260
Note: See TracBrowser for help on using the repository browser.