File indexing completed on 2025-01-18 09:17:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #include "XrayFluoEventAction.hh"
0039 #include "XrayFluoSensorHit.hh"
0040 #include "XrayFluoEventActionMessenger.hh"
0041 #include "XrayFluoDataSet.hh"
0042 #include "XrayFluoAnalysisManager.hh"
0043
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4Event.hh"
0046 #include "G4EventManager.hh"
0047 #include "G4HCofThisEvent.hh"
0048 #include "G4VHitsCollection.hh"
0049 #include "G4SDManager.hh"
0050 #include "G4UImanager.hh"
0051 #include "G4ios.hh"
0052 #include "G4UnitsTable.hh"
0053 #include "Randomize.hh"
0054 #include <fstream>
0055
0056
0057
0058 XrayFluoEventAction::XrayFluoEventAction(const XrayFluoDetectorConstruction* det)
0059 :drawFlag("all"),
0060 HPGeCollID(0),
0061 eventMessenger(0),
0062 printModulo(1),
0063 detectorType(0)
0064 {
0065 eventMessenger = new XrayFluoEventActionMessenger(this);
0066
0067 if (!(det->GetPhaseSpaceFlag()) ){
0068 detectorType = det->GetDetectorType();
0069 HPGeCollID=-1;
0070 }
0071 }
0072
0073
0074
0075 XrayFluoEventAction::XrayFluoEventAction(const XrayFluoPlaneDetectorConstruction* det)
0076 :drawFlag("all"),
0077 HPGeCollID(-1),
0078 eventMessenger(0),
0079 printModulo(1),
0080 detectorType(0)
0081 {
0082 eventMessenger = new XrayFluoEventActionMessenger(this);
0083 detectorType = det->GetDetectorType();
0084 }
0085
0086
0087
0088 XrayFluoEventAction::XrayFluoEventAction(const XrayFluoMercuryDetectorConstruction* det)
0089 :drawFlag("all"),
0090 HPGeCollID(-1),
0091 eventMessenger(0),
0092 printModulo(1),
0093 detectorType(0)
0094 {
0095 eventMessenger = new XrayFluoEventActionMessenger(this);
0096 detectorType = det->GetDetectorType();
0097 }
0098
0099
0100
0101 XrayFluoEventAction::~XrayFluoEventAction()
0102 {
0103 delete eventMessenger;
0104 eventMessenger = 0;
0105 }
0106
0107
0108
0109 void XrayFluoEventAction::BeginOfEventAction(const G4Event* evt)
0110 {
0111
0112 G4int eventNumber = (evt->GetEventID())+1;
0113 if ( eventNumber == 1){
0114
0115 G4cout << "# = 100000 events" << G4endl;
0116 G4cout << "1--------+---------+---------+---------+---------5e6"<<G4endl;
0117 }
0118
0119 if ( ((eventNumber) % 100000) == 0 ) {
0120
0121 if ( eventNumber % (G4int)5e6 != 0 ) G4cout << "#" << std::flush;
0122 else G4cout << "#"<< G4endl;
0123 }
0124
0125 if (HPGeCollID==-1)
0126 {
0127 G4SDManager * SDman = G4SDManager::GetSDMpointer();
0128 HPGeCollID = SDman->GetCollectionID("HPGeCollection");
0129
0130 }
0131 }
0132
0133
0134
0135 void XrayFluoEventAction::EndOfEventAction(const G4Event* evt)
0136 {
0137 if (detectorType) {
0138
0139
0140
0141 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0142
0143 XrayFluoSensorHitsCollection* HPGeHC = 0;
0144 G4int n_hit = 0;
0145 G4double totEnergy=0., energyD=0.;
0146
0147 if (HCE) HPGeHC =
0148 (XrayFluoSensorHitsCollection*)(HCE->GetHC(HPGeCollID));
0149
0150 if(HPGeHC)
0151 {
0152 n_hit = HPGeHC->entries();
0153
0154 for (G4int i=0;i<n_hit;i++)
0155 {
0156 totEnergy += (*HPGeHC)[i]->GetEdepTot();
0157 energyD = detectorType->ResponseFunction(totEnergy);
0158 XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
0159 analysis->analyseEnergyDep(energyD);
0160 }
0161 }
0162 }
0163 }
0164
0165
0166
0167
0168 G4double XrayFluoEventAction::RandomCut(G4double energy)
0169
0170 {
0171 G4double efficiency = 1.;
0172 G4double F = 0.15;
0173 G4double epsilon = 2.96 * eV;
0174 G4double deltaE = 220 * eV;
0175 G4double EdepDetect = 0.;
0176
0177 G4double Random = G4UniformRand();
0178
0179 if ( Random<efficiency )
0180 {
0181 G4double sigma = std::sqrt(F*epsilon*energy+std::pow(deltaE/2355,2));
0182 EdepDetect = G4RandGauss::shoot(energy, sigma );
0183
0184 }
0185 else {EdepDetect = 0.;}
0186
0187 return EdepDetect;
0188 }
0189
0190