source: trunk/examples/extended/electromagnetic/TestEm8/src/Em8SteppingAction.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.8 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//
27// $Id: Em8SteppingAction.cc,v 1.10 2007/11/12 10:54:49 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34
35#include "Em8DetectorConstruction.hh"
36//#include "G4EnergyLossTables.hh"
37//#include "G4SteppingManager.hh"
38//#include "G4TrackVector.hh"
39#include "Em8SteppingAction.hh"
40#include "Em8PrimaryGeneratorAction.hh"
41#include "Em8EventAction.hh"
42#include "Em8RunAction.hh"
43#include "G4Event.hh"
44#include "G4Gamma.hh"
45#include "G4Electron.hh"
46#include "G4Positron.hh"
47//#include "G4EventManager.hh"
48//#include "G4ios.hh"
49//#include <iomanip>
50//#include "G4UImanager.hh"
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53
54Em8SteppingAction::Em8SteppingAction(Em8DetectorConstruction* DET,
55                                     Em8EventAction* EA,
56                                     Em8RunAction* RA)
57:detector (DET),eventaction (EA),runaction (RA),
58 IDold(-1) ,evnoold(-1)
59{}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
63Em8SteppingAction::~Em8SteppingAction()
64{}
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
67
68void Em8SteppingAction::UserSteppingAction(const G4Step* aStep)
69{ 
70  G4Track* track = aStep->GetTrack();
71  G4int trackID = track->GetTrackID();
72  G4int stepID = track->GetCurrentStepNumber();
73  if(trackID == 1 && stepID == 1)
74    runaction->Fillvertexz(track->GetVertexPosition().z());
75
76  const G4ParticleDefinition* part = track->GetDynamicParticle()->GetDefinition();
77  G4VPhysicalVolume* preVolume = aStep->GetPreStepPoint()->GetPhysicalVolume(); 
78  G4VPhysicalVolume* postVolume = aStep->GetPostStepPoint()->GetPhysicalVolume(); 
79  G4double ekin = track->GetKineticEnergy() ; 
80
81  // Secondary - first step
82  if(trackID != 1 && stepID == 1) {
83     if (part == G4Gamma::Gamma() ) {
84       eventaction->AddNeutral();
85
86     } else if (part == G4Electron::Electron()) {
87       eventaction->AddE();
88       runaction->FillTsec(ekin);
89
90     } else if (part == G4Positron::Positron()) {
91       eventaction->AddP();
92       runaction->FillTsec(ekin);
93     }
94  }
95
96  // step inside absorber
97  if(preVolume == postVolume) { 
98    if(preVolume->GetName() == "Absorber") {
99      if(part->GetPDGCharge() == 0.0) eventaction->CountStepsNeutral();
100      else eventaction->CountStepsCharged();
101    }
102    // exit of absorber
103  } else if (preVolume->GetName() == "Absorber") {
104
105    // primary
106    if (trackID == 1) {
107      if (track->GetMomentumDirection().z()>0.) {
108        eventaction->SetTr();
109        runaction->FillTh(track->GetMomentumDirection().theta()) ;
110        runaction->FillTt(ekin) ;
111        G4double xend= track->GetPosition().x() ;
112        G4double yend= track->GetPosition().y() ;
113        runaction->FillR(std::sqrt(xend*xend+yend*yend));
114      } else {
115        eventaction->SetRef();
116        runaction->FillThBack(track->GetMomentumDirection().theta() - 0.5*pi) ;
117        runaction->FillTb(ekin);
118      }
119    }
120    // transmitted gamma
121    if(track->GetMomentumDirection().z()>0. && part == G4Gamma::Gamma()) {
122      runaction->FillGammaSpectrum(ekin);
123    }
124  }
125}
126
127//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
128
Note: See TracBrowser for help on using the repository browser.