Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XrayFluoEventAction.cc
Go to the documentation of this file.
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: XrayFluoEventAction.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 // 15 Jul 2003 Alfonso Mantero "DetectorType" use integration
36 // 23 Sep 2003 Alfonso Mantero differnt geometries integration
37 //
38 // -------------------------------------------------------------------
39 
40 #include "XrayFluoEventAction.hh"
41 #include "XrayFluoSensorHit.hh"
43 
44 //#include "XrayFluoRunAction.hh"
45 #include "XrayFluoDataSet.hh"
46 
48 
49 #include "G4SystemOfUnits.hh"
50 #include "G4Event.hh"
51 #include "G4EventManager.hh"
52 #include "G4HCofThisEvent.hh"
53 #include "G4VHitsCollection.hh"
54 #include "G4SDManager.hh"
55 #include "G4UImanager.hh"
56 #include "G4ios.hh"
57 #include "G4UnitsTable.hh"
58 #include "Randomize.hh"
59 #include <fstream>
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
61 
63  :drawFlag("all"),
64  HPGeCollID(0),
65  eventMessenger(0),
66  printModulo(1),
67  detectorType(0)
68 {
69  eventMessenger = new XrayFluoEventActionMessenger(this);
70 
71  if (!(det->GetPhaseSpaceFlag()) ){
72  detectorType = det->GetDetectorType();
73  HPGeCollID=-1;
74  }
75 
76  //runManager = new XrayFluoRunAction();
77  G4cout << "XrayFluoEventAction created" << G4endl;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81 
83  :drawFlag("all"),
84  HPGeCollID(-1),
85  eventMessenger(0),
86  printModulo(1),
87  detectorType(0)
88 {
89  eventMessenger = new XrayFluoEventActionMessenger(this);
90  detectorType = det->GetDetectorType();
91 
92  //runManager = new XrayFluoRunAction();
93  G4cout << "XrayFluoEventAction created" << G4endl;
94 }
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
97 
99  :drawFlag("all"),
100  HPGeCollID(-1),
101  eventMessenger(0),
102  printModulo(1),
103  detectorType(0)
104 {
105  eventMessenger = new XrayFluoEventActionMessenger(this);
106  detectorType = det->GetDetectorType();
107 
108  //runManager = new XrayFluoRunAction();
109  G4cout << "XrayFluoEventAction created" << G4endl;
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113 
114 
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
117 
119 {
120  delete eventMessenger;
121  eventMessenger = 0;
122  //delete runManager;
123  //runManager = 0;
124  G4cout << "XrayFluoEventAction deleted" << G4endl;
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
128 
130 {
131 
132  G4int eventNumber = (evt->GetEventID())+1;
133  if ( eventNumber == 1){
134 
135  G4cout << "# = 100000 events" << G4endl;
136  G4cout << "1--------+---------+---------+---------+---------5e6"<<G4endl;
137  }
138 
139  if ( ((eventNumber) % 100000) == 0 ) {
140 
141  if ( eventNumber % (G4int)5e6 != 0 ) G4cout << "#" << std::flush;
142  else G4cout << "#"<< G4endl;
143  // if ( eventNumber % 5e6 == 0 ) G4cout << "#"<< G4endl;
144 #ifdef G4ANALYSIS_USE
145  XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
146  analysis->PlotCurrentResults();
147 #endif
148  }
149 
150  if (HPGeCollID==-1)
151 
152  {
154  HPGeCollID = SDman->GetCollectionID("HPGeCollection");
155  //the pointer points to the ID number of the sensitive detector
156  }
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
160 
162 {
163 
164  if (detectorType) {
165 
166  // extracted from hits, compute the total energy deposit (and total charged
167  // track length)
168  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
169 
170  XrayFluoSensorHitsCollection* HPGeHC = 0;
171  G4int n_hit = 0;
172  G4double totEnergyDetect=0., totEnergy=0., energyD=0.;
173 
174  if (HCE) HPGeHC = (XrayFluoSensorHitsCollection*)(HCE->GetHC(HPGeCollID));
175  if(HPGeHC)
176 
177 
178  {
179  n_hit = HPGeHC->entries();
180 
181  // if (n_hit) {G4cout << "Ecco quante hit ho nel detector "<< n_hit << G4endl;}
182 
183  for (G4int i=0;i<n_hit;i++)
184  {
185 
186  totEnergy += (*HPGeHC)[i]->GetEdepTot();
187 
188 
189 
190  energyD = detectorType->ResponseFunction(totEnergy);
191  // energyD = totEnergy;
192  // G4cout << "energy deposit: "<< totEnergy << G4endl;
193 #ifdef G4ANALYSIS_USE
194  XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
195  analysis->analyseEnergyDep(energyD);
196 #endif
197  totEnergyDetect += energyD;
198 
199 
200  }
201  }
202  }
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
206 
207 
208 
209 G4double XrayFluoEventAction::RandomCut(G4double energy)
210 
211 {
212  G4double efficiency = 1.;
213  G4double F = 0.15;
214  G4double epsilon = 2.96 * eV;
215  G4double deltaE = 220 * eV;
216  G4double EdepDetect = 0.;
217  //const XrayFluoDataSet* dataSet = runManager->GetEfficiencySet();
218 
219  //G4double id = 0;
220 
221  //efficiency = dataSet->FindValue(energy,id);
222 
224 
225  if ( Random<efficiency )
226  {
227  G4double sigma = std::sqrt(F*epsilon*energy+std::pow(deltaE/2355,2));
228 
229  EdepDetect = G4RandGauss::shoot(energy, sigma );
230 
231  }
232  else {EdepDetect = 0.;}
233  return EdepDetect;
234 
235 }
236 
237 
ThreeVector shoot(const G4int Ap, const G4int Af)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
XrayFluoEventAction(XrayFluoDetectorConstruction *)
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:140
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
virtual G4double ResponseFunction(G4double)=0
#define G4UniformRand()
Definition: Randomize.hh:87
G4GLOB_DLL std::ostream G4cout
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual void BeginOfEventAction(const G4Event *)
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174
double G4double
Definition: G4Types.hh:76
virtual void EndOfEventAction(const G4Event *)
double Random(double min=0.0, double max=1.0)
Definition: UUtils.cc:69