Geant4  10.03.p02
 All Classes 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 #include "XrayFluoDataSet.hh"
45 
46 #include "G4SystemOfUnits.hh"
47 #include "G4Event.hh"
48 #include "G4EventManager.hh"
49 #include "G4HCofThisEvent.hh"
50 #include "G4VHitsCollection.hh"
51 #include "G4SDManager.hh"
52 #include "G4UImanager.hh"
53 #include "G4ios.hh"
54 #include "G4UnitsTable.hh"
55 #include "Randomize.hh"
56 #include <fstream>
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
61  :drawFlag("all"),
62  HPGeCollID(0),
63  eventMessenger(0),
64  printModulo(1),
65  detectorType(0)
66 {
67  eventMessenger = new XrayFluoEventActionMessenger(this);
68 
69  if (!(det->GetPhaseSpaceFlag()) ){
70  detectorType = det->GetDetectorType();
71  HPGeCollID=-1;
72  }
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
76 
78  :drawFlag("all"),
79  HPGeCollID(-1),
80  eventMessenger(0),
81  printModulo(1),
82  detectorType(0)
83 {
84  eventMessenger = new XrayFluoEventActionMessenger(this);
85  detectorType = det->GetDetectorType();
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
89 
91  :drawFlag("all"),
92  HPGeCollID(-1),
93  eventMessenger(0),
94  printModulo(1),
95  detectorType(0)
96 {
97  eventMessenger = new XrayFluoEventActionMessenger(this);
98  detectorType = det->GetDetectorType();
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
102 
104 {
105  delete eventMessenger;
106  eventMessenger = 0;
107 }
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
110 
112 {
113 
114  G4int eventNumber = (evt->GetEventID())+1;
115  if ( eventNumber == 1){
116 
117  G4cout << "# = 100000 events" << G4endl;
118  G4cout << "1--------+---------+---------+---------+---------5e6"<<G4endl;
119  }
120 
121  if ( ((eventNumber) % 100000) == 0 ) {
122 
123  if ( eventNumber % (G4int)5e6 != 0 ) G4cout << "#" << std::flush;
124  else G4cout << "#"<< G4endl;
125  }
126 
127  if (HPGeCollID==-1)
128  {
130  HPGeCollID = SDman->GetCollectionID("HPGeCollection");
131  //the pointer points to the ID number of the sensitive detector
132  }
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
136 
138 {
139 
140  if (detectorType) {
141 
142  // extracted from hits, compute the total energy deposit (and total charged
143  // track length)
144  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
145 
146  XrayFluoSensorHitsCollection* HPGeHC = 0;
147  G4int n_hit = 0;
148  G4double totEnergyDetect=0., totEnergy=0., energyD=0.;
149 
150  if (HCE) HPGeHC =
151  (XrayFluoSensorHitsCollection*)(HCE->GetHC(HPGeCollID));
152 
153  if(HPGeHC)
154  {
155  n_hit = HPGeHC->entries();
156 
157  for (G4int i=0;i<n_hit;i++)
158  {
159  totEnergy += (*HPGeHC)[i]->GetEdepTot();
160  energyD = detectorType->ResponseFunction(totEnergy);
162  analysis->analyseEnergyDep(energyD);
163  totEnergyDetect += energyD;
164  }
165  }
166  }
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
170 
171 
172 G4double XrayFluoEventAction::RandomCut(G4double energy)
173 
174 {
175  G4double efficiency = 1.;
176  G4double F = 0.15;
177  G4double epsilon = 2.96 * eV;
178  G4double deltaE = 220 * eV;
179  G4double EdepDetect = 0.;
180 
181  G4double Random = G4UniformRand();
182 
183  if ( Random<efficiency )
184  {
185  G4double sigma = std::sqrt(F*epsilon*energy+std::pow(deltaE/2355,2));
186  EdepDetect = G4RandGauss::shoot(energy, sigma );
187 
188  }
189  else {EdepDetect = 0.;}
190 
191  return EdepDetect;
192 }
193 
194 
ThreeVector shoot(const G4int Ap, const G4int Af)
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
G4int entries() const
XrayFluoVDetectorType * GetDetectorType() const
XrayFluoEventAction(const XrayFluoDetectorConstruction *)
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:151
XrayFluoVDetectorType * GetDetectorType() const
virtual G4double ResponseFunction(G4double)=0
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
static XrayFluoAnalysisManager * getInstance()
static constexpr double eV
Definition: G4SIunits.hh:215
G4double energy(const ThreeVector &p, const G4double m)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual void BeginOfEventAction(const G4Event *)
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
void analyseEnergyDep(G4double eDep)
double G4double
Definition: G4Types.hh:76
virtual void EndOfEventAction(const G4Event *)
double epsilon(double density, double temperature)