File indexing completed on 2026-05-20 07:41:28
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 #include "ExGflashEventAction.hh"
0030
0031 #include "ExGflashDetectorConstruction.hh"
0032 #include "ExGflashHistoManager.hh"
0033 #include "ExGflashHit.hh"
0034
0035 #include "G4Event.hh"
0036 #include "G4EventManager.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4UImanager.hh"
0040
0041 #include <algorithm>
0042 #include <iostream>
0043 #include <vector>
0044
0045 using MyVector = std::vector<G4double>;
0046
0047
0048 using namespace std;
0049
0050
0051
0052 ExGflashEventAction::ExGflashEventAction(ExGflashDetectorConstruction* det) : fDet(det) {}
0053
0054
0055
0056 ExGflashEventAction::~ExGflashEventAction() = default;
0057
0058
0059
0060 void ExGflashEventAction::BeginOfEventAction(const G4Event* ) {}
0061
0062
0063
0064 void ExGflashEventAction::EndOfEventAction(const G4Event* evt)
0065 {
0066 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0067 G4String colNam;
0068 fCalorimeterCollectionId = SDman->GetCollectionID(colNam = "ExGflashCollection");
0069
0070 if (fCalorimeterCollectionId < 0) {
0071 return;
0072 }
0073
0074 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0075 ExGflashHitsCollection* THC = nullptr;
0076 G4double totE = 0;
0077
0078
0079 THC = (ExGflashHitsCollection*)(HCE->GetHC(fCalorimeterCollectionId));
0080
0081 if (THC != nullptr) {
0082
0083 int n_hit = THC->entries();
0084
0085 G4PrimaryVertex* pvertex = evt->GetPrimaryVertex();
0086
0087 G4ThreeVector vtx = pvertex->GetPosition();
0088 G4PrimaryParticle* pparticle = pvertex->GetPrimary();
0089
0090 G4ThreeVector mom = pparticle->GetMomentumDirection();
0091
0092 G4double Ekin = pparticle->GetKineticEnergy();
0093 G4double mass = pparticle->GetParticleDefinition()->GetPDGMass();
0094 G4double Etot = Ekin / MeV + mass / MeV;
0095
0096 G4int nLbin = fDet->GetnLtot();
0097 G4int nRbin = fDet->GetnRtot();
0098 G4double dLradl = fDet->GetdLradl();
0099 G4double dRradl = fDet->GetdRradl();
0100
0101 G4double SDRadl = fDet->GetSDRadLen();
0102 G4double SDRm = fDet->GetSDRm();
0103
0104
0105 MyVector dEdL(nLbin, 0.0);
0106 MyVector dEdR(nRbin, 0.0);
0107
0108 G4AnalysisManager* fAnalysisManager = G4AnalysisManager::Instance();
0109
0110 fAnalysisManager->FillH1(1, n_hit + 0.5);
0111
0112 for (int i = 0; i < n_hit; i++) {
0113 G4double estep = (*THC)[i]->GetEdep();
0114 fAnalysisManager->FillH1(2, estep / MeV);
0115 estep /= MeV;
0116
0117 if (estep > 0.0) {
0118 totE += estep;
0119
0120 G4ThreeVector hitpos = (*THC)[i]->GetPos();
0121
0122
0123 G4ThreeVector l = hitpos - vtx;
0124
0125 G4ThreeVector longitudinal = l.dot(mom) * mom;
0126
0127 G4ThreeVector radial = l - longitudinal;
0128
0129 auto SlideNb = G4int((longitudinal.mag() / SDRadl) / dLradl);
0130 auto RingNb = G4int((radial.mag() / SDRm) / dRradl);
0131
0132 if ((SlideNb >= 0 && SlideNb < nLbin) && (RingNb >= 0 && RingNb < nRbin)) {
0133 dEdL[SlideNb] += estep;
0134 dEdR[RingNb] += estep;
0135 }
0136 }
0137 }
0138
0139 G4double Lnorm = 100. / dLradl / Etot;
0140 G4double Lsum = 0.0;
0141 for (int i = 0; i < nLbin; i++) {
0142 fAnalysisManager->FillP1(0, (i + 0.5) * dLradl, dEdL[i] * Lnorm);
0143 Lsum += dEdL[i];
0144 fAnalysisManager->FillP1(2, (i + 0.5) * dLradl, Lsum * Lnorm);
0145 }
0146 G4double Rnorm = 100. / dRradl / Etot;
0147 G4double Rsum = 0.0;
0148 for (int i = 0; i < nRbin; i++) {
0149 fAnalysisManager->FillP1(1, (i + 0.5) * dRradl, dEdR[i] * Rnorm);
0150 Rsum += dEdR[i];
0151 fAnalysisManager->FillP1(3, (i + 0.5) * dRradl, Rsum * Rnorm);
0152 }
0153
0154 fAnalysisManager->FillH1(0, totE / Etot * 100.);
0155 }
0156 }
0157
0158