File indexing completed on 2025-02-23 09:20:26
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 #include "STCyclotronRun.hh"
0031 #include "STCyclotronSensitiveFoil.hh"
0032 #include "G4AnalysisManager.hh"
0033 #include "G4RunManager.hh"
0034 #include "G4HCofThisEvent.hh"
0035 #include "G4Step.hh"
0036 #include "G4ThreeVector.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4ios.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4ThreeVector.hh"
0041
0042 STCyclotronSensitiveFoil::STCyclotronSensitiveFoil(const G4String& name,
0043 STCyclotronDetectorConstruction* det)
0044 : G4VSensitiveDetector(name),
0045 fDet(det)
0046 {
0047 fTempTrack = 0;
0048 fTempTrack1 = 0;
0049 fTempEnergy = 0.;
0050 fTempVector = G4ThreeVector(0.,0.,0.);
0051 fRun =0;
0052 }
0053
0054 STCyclotronSensitiveFoil::~STCyclotronSensitiveFoil()
0055 {
0056 delete fRun;
0057 }
0058
0059 G4bool STCyclotronSensitiveFoil::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0060 {
0061
0062 fRun = static_cast<STCyclotronRun*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0063 G4Track* fTrack = aStep->GetTrack();
0064
0065 auto analysisManager = G4AnalysisManager::Instance();
0066
0067
0068 G4double edep = aStep->GetTotalEnergyDeposit();
0069 G4double energy = aStep->GetPreStepPoint()->GetKineticEnergy();
0070 G4ThreeVector momentumDirection = aStep->GetPreStepPoint()->GetMomentumDirection();
0071 G4ThreeVector vectorPosition = aStep->GetPreStepPoint()->GetPosition();
0072 G4String name = fTrack->GetDefinition()->GetParticleName();
0073
0074
0075 fRun->EnergyDepositionFoil(edep);
0076
0077
0078 if(name == "proton" || name == "deuteron"){
0079
0080 if(fTrack->GetTrackID()!=fTempTrack && (momentumDirection.getZ()>0.) &&
0081 vectorPosition.getX()< 7.5 &&
0082 vectorPosition.getX()>-7.5 &&
0083 vectorPosition.getY()< 7.5 &&
0084 vectorPosition.getY()>-7.5){
0085
0086 analysisManager->FillH2(1,vectorPosition.getX(),vectorPosition.getY());
0087 analysisManager->FillH1(1,energy);
0088
0089 fTempTrack = fTrack->GetTrackID();
0090
0091 }
0092
0093 if(fTempTrack1 == 0){
0094 fTempTrack1 = fTrack->GetTrackID();
0095 }
0096
0097 if(fTrack->GetTrackID()!=fTempTrack1 && (momentumDirection.getZ()>0.) &&
0098 vectorPosition.getX()< 7.5 &&
0099 vectorPosition.getX()>-7.5 &&
0100 vectorPosition.getY()< 7.5 &&
0101 vectorPosition.getY()>-7.5 ){
0102
0103 analysisManager->FillH2(5,fTempVector.getX(),fTempVector.getY());
0104 analysisManager->FillH1(3,fTempEnergy);
0105
0106 fTempTrack1 = fTrack->GetTrackID();
0107
0108 }
0109
0110 fTempVector = aStep->GetPostStepPoint()->GetPosition();
0111 fTempEnergy = aStep->GetPostStepPoint()->GetKineticEnergy();
0112 }
0113
0114 fRun->SetFoilVolume(fDet->GetFoilVolume());
0115 fRun->SetFoilThickness(fDet->GetFoilThickness());
0116 return true;
0117 }