File indexing completed on 2025-01-18 09:17:01
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 "SteppingAction.hh"
0030 #include "G4AnalysisManager.hh"
0031 #include "G4SystemOfUnits.hh"
0032
0033
0034
0035 SteppingAction::SteppingAction(RunAction* run,DetectorConstruction* det)
0036 :fRun(run),fDetector(det)
0037 {}
0038
0039
0040
0041 SteppingAction::~SteppingAction()
0042 {}
0043
0044
0045
0046 void SteppingAction::UserSteppingAction(const G4Step* step)
0047
0048 {
0049
0050 G4AnalysisManager* man = G4AnalysisManager::Instance();
0051
0052
0053 if ( (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
0054 G4Proton::ProtonDefinition())
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 && (step->GetPostStepPoint()->GetPosition().z()/mm>249.99999)
0066 && (step->GetPostStepPoint()->GetPosition().z()/mm<250.00001)
0067 && (step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->
0068 GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName())
0069 && (step->GetPostStepPoint()->GetTouchableHandle()->GetVolume()->
0070 GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName())
0071 )
0072
0073 {
0074 fXIn = step->GetPostStepPoint()->GetPosition().x();
0075 fYIn = step->GetPostStepPoint()->GetPosition().y();
0076 fZIn = step->GetPostStepPoint()->GetPosition().z();
0077 fE = step->GetTrack()->GetKineticEnergy();
0078
0079 G4ThreeVector angleIn;
0080 angleIn = step->GetTrack()->GetMomentumDirection();
0081
0082 fThetaIn = std::asin(angleIn[0]/std::sqrt(angleIn[0]
0083 *angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
0084 fPhiIn = std::asin(angleIn[1]/std::sqrt(angleIn[0]
0085 *angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
0086
0087 G4cout << " =>IMAGE : X(microns)=" << fXIn/micrometer
0088 <<" Y(microns)="<< fYIn/micrometer << " THETA(mrad)="
0089 << (fThetaIn/mrad) << " PHI(mrad)=" << (fPhiIn/mrad) << G4endl;
0090 G4cout << G4endl;
0091
0092 if (fDetector->GetCoef()==1)
0093 {
0094 fRun->AddRow();
0095 fRun->AddToXVector(fXIn/um);
0096 fRun->AddToYVector(fYIn/um);
0097 fRun->AddToThetaVector(fThetaIn/mrad);
0098 fRun->AddToPhiVector(fPhiIn/mrad);
0099 }
0100
0101
0102 man->FillNtupleDColumn(3,0,fXIn/um);
0103 man->FillNtupleDColumn(3,1,fYIn/um);
0104 man->FillNtupleDColumn(3,2,fThetaIn/mrad);
0105 man->FillNtupleDColumn(3,3,fPhiIn/mrad);
0106 man->AddNtupleRow(3);
0107
0108 }
0109
0110 if (fDetector->GetProfile()==1)
0111 {
0112
0113 if (
0114 (step->GetTrack()->GetDynamicParticle()->GetDefinition()== G4Proton::ProtonDefinition())
0115 && (step->GetPreStepPoint()->GetTouchableHandle()
0116 ->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName())
0117 && (step->GetPostStepPoint()->GetTouchableHandle()
0118 ->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName())
0119 )
0120 {
0121 fXIn = step->GetPostStepPoint()->GetPosition().x();
0122 fYIn = step->GetPostStepPoint()->GetPosition().y();
0123 fZIn = step->GetPostStepPoint()->GetPosition().z();
0124
0125
0126 man->FillNtupleDColumn(1,0,fXIn/um);
0127 man->FillNtupleDColumn(1,1,fYIn/um);
0128 man->FillNtupleDColumn(1,2,fZIn/um);
0129 man->AddNtupleRow(1);
0130 }
0131 }
0132
0133 if (fDetector->GetGrid()==1)
0134 {
0135
0136 if (
0137 (step->GetTrack()->GetDynamicParticle()->GetDefinition()== G4Proton::ProtonDefinition())
0138 && (step->GetPreStepPoint()->GetTouchableHandle()
0139 ->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalGrid()->GetName())
0140 && (step->GetPostStepPoint()->GetTouchableHandle()
0141 ->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName())
0142 )
0143 {
0144 fXIn = step->GetPostStepPoint()->GetPosition().x();
0145 fYIn = step->GetPostStepPoint()->GetPosition().y();
0146 fE = step->GetTrack()->GetKineticEnergy();
0147
0148
0149 man->FillNtupleDColumn(2,0,fXIn/um);
0150 man->FillNtupleDColumn(2,1,fYIn/um);
0151 man->FillNtupleDColumn(2,2,fE/MeV);
0152 man->AddNtupleRow(2);
0153 }
0154 }
0155
0156
0157 }