source: trunk/examples/extended/electromagnetic/TestEm14/src/SteppingAction.cc@ 1338

Last change on this file since 1338 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.3 KB
Line 
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.6 2010/04/02 13:22:02 maire Exp $
27// GEANT4 tag $Name: geant4-09-04-beta-01 $
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
37#include "G4RunManager.hh"
38
39//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40
41SteppingAction::SteppingAction(PrimaryGeneratorAction* prim,
42 RunAction* RuAct, HistoManager* Hist)
43:primary(prim),runAction(RuAct), histoManager(Hist)
44{ }
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47
48SteppingAction::~SteppingAction()
49{ }
50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52
53void SteppingAction::UserSteppingAction(const G4Step* aStep)
54{
55 G4StepPoint* endPoint = aStep->GetPostStepPoint();
56 G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
57 G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary);
58 if (transmit) runAction->CountProcesses(procName);
59 else {
60 //count real processes and sum track length
61 G4double stepLength = aStep->GetStepLength();
62 runAction->CountProcesses(procName);
63 runAction->SumTrack(stepLength);
64 }
65
66 //plot final state (only if continuous energy loss is small enough)
67 //
68
69 //scattered primary particle
70 //
71 G4int id = 1;
72 if (aStep->GetTrack()->GetTrackStatus() == fAlive) {
73 G4double energy = endPoint->GetKineticEnergy();
74 histoManager->FillHisto(id,energy);
75
76 id = 2;
77 G4ThreeVector direction = endPoint->GetMomentumDirection();
78 G4double costeta = direction.x();
79 histoManager->FillHisto(id,costeta);
80 }
81
82 //secondaries
83 //
84 G4TrackVector* secondary = fpSteppingManager->GetSecondary();
85 for (size_t lp=0; lp<(*secondary).size(); lp++) {
86 G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge();
87 if (charge != 0.) id = 3; else id = 5;
88 G4double energy = (*secondary)[lp]->GetKineticEnergy();
89 histoManager->FillHisto(id,energy);
90
91 id++;
92 G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection();
93 G4double costeta = direction.x();
94 histoManager->FillHisto(id,costeta);
95
96 //energy tranferred to charged secondaries
97 if (charge != 0.) runAction->SumeTransf(energy);
98 }
99
100 // kill event after first interaction
101 //
102 G4RunManager::GetRunManager()->AbortEvent();
103}
104
105//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106
107
Note: See TracBrowser for help on using the repository browser.