-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstepping.cc
More file actions
65 lines (41 loc) · 1.82 KB
/
stepping.cc
File metadata and controls
65 lines (41 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "stepping.hh"
MySteppingAction::MySteppingAction(MyEventAction *eventAction)
{
fEventAction = eventAction;
}
MySteppingAction::~MySteppingAction()
{
}
void MySteppingAction::UserSteppingAction(const G4Step *step)
{
G4Track *track = step->GetTrack();
//track->SetTrackStatus(fStopAndKill);
if (track->GetTrackID() == 1 && track->GetTrackStatus() == fStopAndKill) {
G4StepPoint* prePoint = step->GetPreStepPoint();
G4StepPoint* postPoint = step->GetPostStepPoint();
G4ThreeVector preDir = prePoint->GetMomentumDirection();
G4ThreeVector postDir = postPoint->GetMomentumDirection();
/*
G4double angleRad = preDir.angle(postDir);
G4double angleDeg = angleRad * (180.0 / CLHEP::pi);
G4cout << "Scattering angle (deg): " << angleDeg << G4endl;
G4cout << "Scattering angle (rad): " << angleRad << G4endl;
*/
G4String pName = track->GetDefinition()->GetParticleName();
auto analysisManager = G4AnalysisManager::Instance();
//G4int eventID = step->GetEventID();
G4int trackID = track->GetTrackID();
G4int pdgCode = track->GetDefinition()->GetPDGEncoding();
analysisManager->FillNtupleIColumn(0,pdgCode);
analysisManager->FillNtupleSColumn(1,pName);
analysisManager->FillNtupleIColumn(3,trackID);
//analysisManager->AddNtupleRow();
}
/*G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
const MyDetectorConstruction *detectorConstruction = static_cast<const MyDetectorConstruction*> (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4LogicalVolume *fScoringVolume = detectorConstruction->GetScoringVolume();
if(volume != fScoringVolume)
return;
G4double edep = step->GetTotalEnergyDeposit();
fEventAction->AddEdep(edep);*/
}