1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // $Id: SteppingAction.cc,v 1.5 2007/06/23 22:23:20 maire Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
28 | // |
---|
29 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
31 | |
---|
32 | #include "SteppingAction.hh" |
---|
33 | #include "PrimaryGeneratorAction.hh" |
---|
34 | #include "RunAction.hh" |
---|
35 | #include "HistoManager.hh" |
---|
36 | #include "SteppingMessenger.hh" |
---|
37 | |
---|
38 | #include "G4RunManager.hh" |
---|
39 | |
---|
40 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
41 | |
---|
42 | SteppingAction::SteppingAction(PrimaryGeneratorAction* prim, |
---|
43 | RunAction* RuAct, HistoManager* Hist) |
---|
44 | :primary(prim),runAction(RuAct), histoManager(Hist) |
---|
45 | { |
---|
46 | stepMessenger = new SteppingMessenger(this); |
---|
47 | fract = 0.1; |
---|
48 | } |
---|
49 | |
---|
50 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
51 | |
---|
52 | SteppingAction::~SteppingAction() |
---|
53 | { |
---|
54 | delete stepMessenger; |
---|
55 | } |
---|
56 | |
---|
57 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
58 | |
---|
59 | void SteppingAction::UserSteppingAction(const G4Step* aStep) |
---|
60 | { |
---|
61 | G4StepPoint* endPoint = aStep->GetPostStepPoint(); |
---|
62 | G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName(); |
---|
63 | G4TrackVector* secondary = fpSteppingManager->GetSecondary(); |
---|
64 | G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary); |
---|
65 | if (transmit) runAction->CountProcesses(procName); |
---|
66 | else { |
---|
67 | //count real processes and sum track length |
---|
68 | G4double stepLength = aStep->GetStepLength(); |
---|
69 | G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge(); |
---|
70 | if ((charge == 0.) || ((charge != 0.) && (((*secondary).size() > 0)))) |
---|
71 | { |
---|
72 | runAction->CountProcesses(procName); |
---|
73 | runAction->SumTrack(stepLength); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | //plot final state (only if continuous energy loss is small enough) |
---|
78 | // |
---|
79 | G4double edep = aStep->GetTotalEnergyDeposit(); |
---|
80 | G4double E0 = primary->GetParticleGun()->GetParticleEnergy(); |
---|
81 | if (edep < fract*E0) { |
---|
82 | |
---|
83 | //scattered primary particle |
---|
84 | // |
---|
85 | G4int id = 1; |
---|
86 | if (aStep->GetTrack()->GetTrackStatus() == fAlive) { |
---|
87 | G4double energy = endPoint->GetKineticEnergy(); |
---|
88 | histoManager->FillHisto(id,energy); |
---|
89 | |
---|
90 | id = 2; |
---|
91 | G4ThreeVector direction = endPoint->GetMomentumDirection(); |
---|
92 | G4double costeta = direction.x(); |
---|
93 | histoManager->FillHisto(id,costeta); |
---|
94 | } |
---|
95 | |
---|
96 | //secondaries |
---|
97 | // |
---|
98 | //G4TrackVector* secondary = fpSteppingManager->GetSecondary(); |
---|
99 | for (size_t lp=0; lp<(*secondary).size(); lp++) { |
---|
100 | G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge(); |
---|
101 | if (charge != 0.) id = 3; else id = 5; |
---|
102 | G4double energy = (*secondary)[lp]->GetKineticEnergy(); |
---|
103 | histoManager->FillHisto(id,energy); |
---|
104 | |
---|
105 | id++; |
---|
106 | G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection(); |
---|
107 | G4double costeta = direction.x(); |
---|
108 | histoManager->FillHisto(id,costeta); |
---|
109 | |
---|
110 | //energy tranferred to charged secondaries |
---|
111 | if (charge != 0.) runAction->SumeTransf(energy); |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | // kill event after first interaction |
---|
116 | // |
---|
117 | G4RunManager::GetRunManager()->AbortEvent(); |
---|
118 | } |
---|
119 | |
---|
120 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
121 | |
---|
122 | |
---|