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 "STCyclotronSensitiveTarget.hh"
0032
0033 #include "G4AnalysisManager.hh"
0034 #include "G4RunManager.hh"
0035 #include "G4HCofThisEvent.hh"
0036 #include "G4UnitsTable.hh"
0037 #include "G4Step.hh"
0038 #include "G4SteppingManager.hh"
0039 #include "G4ThreeVector.hh"
0040 #include "G4SDManager.hh"
0041 #include "G4ios.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4ThreeVector.hh"
0044 #include "G4Track.hh"
0045 #include "G4ParticleDefinition.hh"
0046 #include "G4DecayTable.hh"
0047 #include "G4VDecayChannel.hh"
0048 #include "G4TrackVector.hh"
0049 #include "G4VProcess.hh"
0050 #include "G4Tubs.hh"
0051 #include <map>
0052
0053 STCyclotronSensitiveTarget::STCyclotronSensitiveTarget(G4String name,
0054 STCyclotronDetectorConstruction* det)
0055 : G4VSensitiveDetector(name),
0056 fDet(det)
0057 {
0058 fTempTrack = 0;
0059 fTempTrack1 = 0;
0060 fTempEnergy = 0.;
0061 fTempVector = G4ThreeVector(0.,0.,0.);
0062 fTrack=0;
0063 }
0064
0065 STCyclotronSensitiveTarget::~STCyclotronSensitiveTarget()
0066 {
0067 delete fTrack;
0068 }
0069
0070 G4bool STCyclotronSensitiveTarget::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0071 {
0072
0073 STCyclotronRun* fRun = static_cast<STCyclotronRun*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0074 fTrack = aStep->GetTrack();
0075
0076 auto analysisManager = G4AnalysisManager::Instance();
0077
0078
0079
0080
0081 G4double targetHalfDiameter= (fDet->GetTargetDiameter())/2.;
0082
0083
0084
0085
0086
0087 G4double edep = aStep->GetTotalEnergyDeposit();
0088 G4double energy = aStep->GetPreStepPoint()->GetKineticEnergy();
0089 G4ThreeVector momentumDirection = aStep->GetPreStepPoint()->GetMomentumDirection();
0090 G4ThreeVector vectorPosition = aStep->GetPreStepPoint()->GetPosition();
0091
0092
0093
0094
0095
0096 G4ParticleDefinition* thePartDef = fTrack->GetDefinition();
0097 G4String partType= fTrack->GetDefinition()->GetParticleType();
0098 G4String name = fTrack->GetDefinition()->GetParticleName();
0099 G4double timeLife = fTrack->GetDefinition()->GetPDGLifeTime();
0100 const G4VProcess* process = fTrack->GetCreatorProcess();
0101
0102
0103
0104
0105
0106
0107 fRun->EnergyDepositionTarget(edep);
0108
0109
0110
0111
0112
0113
0114 if(name == "proton" || name == "deuteron")
0115 {
0116
0117 if(fTrack->GetTrackID()!=fTempTrack && (momentumDirection.getZ()>0.) &&
0118 vectorPosition.getX()<targetHalfDiameter &&
0119 vectorPosition.getX()>-targetHalfDiameter &&
0120 vectorPosition.getY()<targetHalfDiameter &&
0121 vectorPosition.getY()>-targetHalfDiameter)
0122 {
0123 analysisManager->FillH2(0,vectorPosition.getX(),vectorPosition.getY());
0124 analysisManager->FillH1(0,energy);
0125 fRun->CountParticlesTarget();
0126 fTempTrack = fTrack->GetTrackID();
0127 }
0128
0129 if(fTempTrack1 == 0)
0130 {
0131 fTempTrack1 = fTrack->GetTrackID();
0132 }
0133
0134 if(fTrack->GetTrackID()!=fTempTrack1 && (momentumDirection.getZ()>0.) &&
0135 fTempVector.getX()<targetHalfDiameter &&
0136 fTempVector.getX()>-targetHalfDiameter &&
0137 fTempVector.getY()<targetHalfDiameter &&
0138 fTempVector.getY()>-targetHalfDiameter )
0139 {
0140
0141 analysisManager->FillH2(4,fTempVector.getX(),fTempVector.getY());
0142 analysisManager->FillH1(2,fTempEnergy);
0143 fTempTrack1 = fTrack->GetTrackID();
0144 }
0145
0146 fTempVector = aStep->GetPostStepPoint()->GetPosition();
0147 fTempEnergy = aStep->GetPostStepPoint()->GetKineticEnergy();
0148
0149 analysisManager->FillH2(3,vectorPosition.getZ(),energy);
0150
0151 }
0152
0153
0154
0155
0156
0157
0158 if((name != "proton") && (name != "e-") && (name != "deuteron"))
0159 {
0160 fRun->StoreIsotopeID(fTrack->GetTrackID(),name);
0161 }
0162
0163
0164
0165
0166
0167
0168 if (name!="deuteron")
0169 {
0170 if (( partType == "nucleus") && !(thePartDef->GetPDGStable()) && (fTrack->GetCurrentStepNumber()==1) && timeLife!=0.)
0171 {
0172
0173 G4int Z=thePartDef->GetAtomicNumber();
0174 G4int A=thePartDef->GetAtomicMass();
0175 analysisManager->FillH2(2,Z,A);
0176
0177
0178
0179
0180
0181 fRun->PrimaryIsotopeCountTarget(name,timeLife);
0182 analysisManager->FillH1(4,fTrack->GetPosition().getZ());
0183
0184 std::map<G4int,G4String> parentID = fRun->GetIsotopeID();
0185 G4String nameParent = parentID[fTrack->GetParentID()];
0186 fRun->ParticleParent(name, process->GetProcessName());
0187
0188
0189
0190 }
0191 }
0192
0193
0194
0195
0196
0197
0198 if (name!="deuteron")
0199 {
0200 if (( partType == "nucleus") && (thePartDef->GetPDGStable()) && (process->GetProcessName() != "RadioactiveDecay") && (fTrack->GetCurrentStepNumber()==1) )
0201 {
0202
0203
0204
0205 fRun->CountStableIsotopes(name);
0206 }
0207 }
0208
0209
0210
0211
0212
0213
0214 if (( partType == "nucleus") && !(thePartDef->GetPDGStable()) && (process->GetProcessName() == "RadioactiveDecay") && (fTrack->GetCurrentStepNumber()==1) && timeLife!=0)
0215 {
0216 std::map<G4int,G4String>::iterator itbis;
0217 std::map<G4int,G4String> parentID = fRun->GetIsotopeID();
0218 G4String nameParent = parentID[fTrack->GetParentID()];
0219 fRun->DecayIsotopeCountTarget(name,nameParent,timeLife);
0220 }
0221
0222
0223
0224
0225
0226 if((partType!="nucleus")&&(name!="proton")&&(name!="deuteron"))
0227 {
0228 fRun->ParticleCountTarget(name);
0229
0230 if((fTrack->GetCurrentStepNumber()==1))
0231 {
0232 if(process->GetProcessName() != "RadioactiveDecay")
0233 {
0234 if(name=="e+"){
0235 analysisManager->FillH1(5,energy);
0236 }
0237 if(name=="e-"){
0238 analysisManager->FillH1(6,energy);
0239 }
0240 if(name=="gamma"){
0241 analysisManager->FillH1(7,energy);
0242 }
0243 if(name=="neutron"){
0244 analysisManager->FillH1(8,energy);
0245 }
0246 }
0247
0248 if(process->GetProcessName() == "RadioactiveDecay")
0249 {
0250 if(name=="e+"){
0251 analysisManager->FillH1(9,energy);
0252 }
0253 if(name=="e-"){
0254 analysisManager->FillH1(10,energy);
0255 }
0256 if(name=="gamma"){
0257 analysisManager->FillH1(11,energy);
0258 }
0259 if(name=="neutron"){
0260 analysisManager->FillH1(12,energy);
0261 }
0262 if(name=="nu_e"){
0263 analysisManager->FillH1(13,energy);
0264 }
0265 if(name=="anti_nu_e"){
0266 analysisManager->FillH1(14,energy);
0267 }
0268 }
0269 }
0270 }
0271
0272
0273 fRun->SetTargetVolume(fDet->GetTargetVolume());
0274 fRun->SetTargetThickness(fDet->GetTargetThickness());
0275 fRun->SetTargetDiameter(fDet->GetTargetDiameter());
0276
0277 return true;
0278
0279 }
0280
0281