source: trunk/source/processes/electromagnetic/lowenergy/test/hTest/src/hTestTrackingAction.cc @ 1350

Last change on this file since 1350 was 1350, checked in by garnier, 13 years ago

update to last version 4.9.4

File size: 5.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#define hTestTrackingAction_CPP
27
28//---------------------------------------------------------------------------
29//
30// ClassName:   hTestTrackingAction
31// 
32// Description: Implementation file for MC truth.
33//
34// Author:      V.Ivanchenko 17/03/01
35//
36// Modified:
37//
38//----------------------------------------------------------------------------
39//
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43
44#include "hTestTrackingAction.hh"
45#include "G4ParticleDefinition.hh"
46#include "G4DynamicParticle.hh"
47#include "G4Track.hh"
48#include "G4ThreeVector.hh"
49#include "G4Gamma.hh"
50#include "G4Electron.hh"
51#include "G4EventManager.hh"
52#include "G4Event.hh"
53
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55
56hTestTrackingAction::hTestTrackingAction():
57  theHisto(hTestHisto::GetPointer())
58{;}
59
60//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
61
62hTestTrackingAction::~hTestTrackingAction()
63{;}
64
65//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66
67void hTestTrackingAction::PreUserTrackingAction(const G4Track* aTrack)
68{
69
70  G4ParticleDefinition* particle = aTrack->GetDefinition();
71  G4String name = particle->GetParticleName();
72  theHisto->ResetTrackLength();
73  G4int pid = aTrack->GetParentID(); 
74
75  if(0 < theHisto->GetVerbose() &&
76    (theHisto->GetMaxEnergy() < aTrack->GetKineticEnergy() && pid > 0)) {
77    G4cout << "Track #" 
78           << aTrack->GetTrackID() << " of " << name
79           << " Emax(MeV)= " << theHisto->GetMaxEnergy()/MeV
80           << " Ekin(MeV)= " << aTrack->GetKineticEnergy()/MeV
81           << " ## EventID= " 
82           << (G4EventManager::GetEventManager())->GetConstCurrentEvent()
83              ->GetEventID() 
84           << G4endl;
85  }
86
87  //Save primary parameters
88
89  if(0 == pid) {
90
91    //    theHisto->StartEvent();     
92
93    G4double kinE = aTrack->GetKineticEnergy();
94    theHisto->SaveToTuple("TKIN", kinE/MeV);     
95
96    G4double mass = 0.0;
97    if(particle) {
98      mass = particle->GetPDGMass();
99      theHisto->SaveToTuple("MASS", mass/MeV);     
100      theHisto->SaveToTuple("CHAR",(particle->GetPDGCharge())/eplus);     
101      G4double beta = 1.;
102        if(mass > 0.) {
103          G4double gamma = kinE/mass + 1.;
104          beta = std::sqrt(1. - 1./(gamma*gamma));
105        }
106      theHisto->SaveToTuple("BETA", beta);           
107    }
108
109    G4ThreeVector pos = aTrack->GetPosition();
110    G4ThreeVector dir = aTrack->GetMomentumDirection();
111    /*
112    theHisto->SaveToTuple("X0",(pos.x())/mm);
113    theHisto->SaveToTuple("Y0",(pos.y())/mm);
114    theHisto->SaveToTuple("Z0",(pos.z())/mm);
115    */
116    if(1 < theHisto->GetVerbose()) {
117      G4cout << "hTestTrackingAction: Primary kinE(MeV)= " << kinE/MeV
118           << "; m(MeV)= " << mass/MeV   
119           << "; pos= " << pos << ";  dir= " << dir << G4endl;
120    }
121
122    // delta-electron
123  } else if ("e-" == name) {
124    if(1 < theHisto->GetVerbose()) {
125      G4cout << "hTestTrackingAction: Secondary electron " << G4endl;
126    }
127    theHisto->AddDeltaElectron(aTrack->GetDynamicParticle());
128
129  } else if ("e+" == name) {
130    if(1 < theHisto->GetVerbose()) {
131      G4cout << "hTestTrackingAction: Secondary positron " << G4endl;
132    }
133    //    theHisto->AddPositron(aTrack->GetDynamicParticle());
134
135  } else if ("gamma" == name) {
136    if(0 < theHisto->GetVerbose()) {
137      G4cout << "hTestTrackingAction: Secondary gamma " 
138             << aTrack->GetDynamicParticle() << G4endl;
139      aTrack->GetDynamicParticle()->DumpInfo();
140    }
141    theHisto->AddPhoton(aTrack->GetDynamicParticle());
142 
143  }
144}
145
146//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
147
148
149
150
151
152
153
154
Note: See TracBrowser for help on using the repository browser.