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