Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/electromagnetic/TestEm1/src/TrackingAction.cc
이 파일의 문서화 페이지로 가기
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 //
28 //
29 // $Id: TrackingAction.cc 79976 2014-03-27 15:13:45Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "TrackingAction.hh"
35 #include "PrimaryGeneratorAction.hh"
36 #include "Run.hh"
37 #include "HistoManager.hh"
38 
39 #include "G4RunManager.hh"
40 #include "G4Track.hh"
41 
42 #include "G4SystemOfUnits.hh"
43 #include "G4UnitsTable.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :G4UserTrackingAction(),fPrimary(prim)
49 { }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {
55 /*
56  //debug
57  const G4DynamicParticle* dynamic = aTrack->GetDynamicParticle();
58  G4double dynamCharge = dynamic->GetCharge();
59  G4int occup = dynamic->GetTotalOccupancy();
60  G4double pdgMass = dynamic->GetParticleDefinition()->GetPDGMass();
61  G4double invarMass = dynamic->Get4Momentum().m();
62  G4double dynamMass = dynamic->GetMass();
63  G4double dif1 = invarMass - pdgMass;
64  G4double dif2 = dynamMass - pdgMass;
65 
66  G4cout
67  << "\n Begin of track :"
68  << "\n charge= " << dynamCharge << " occupancy= " << occup
69  << "\n pdgMass= " << G4BestUnit (pdgMass , "Energy")
72  << "\n dynamMass= " << G4BestUnit (dynamMass, "Energy")
73  << " dynam-pdg= " << G4BestUnit (dif2 , "Energy")
74  << G4endl;
75 */
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  //increase nb of processed tracks
83  //count nb of steps of this track
84  G4int nbSteps = aTrack->GetCurrentStepNumber();
85  G4double Trleng = aTrack->GetTrackLength();
86 
87  Run* run = static_cast<Run*>(
89 
90  if (aTrack->GetDefinition()->GetPDGCharge() == 0.) {
91  run->CountTraks0(1);
92  run->CountSteps0(nbSteps);
93 
94  } else {
95  run->CountTraks1(1);
96  run->CountSteps1(nbSteps);
97  }
98 
99  //true and projected ranges for primary particle
100  if (aTrack->GetTrackID() == 1) {
101  run->AddTrueRange(Trleng);
103  G4ThreeVector position = aTrack->GetPosition() - vertex;
104  run->AddProjRange(position.x());
105  run->AddTransvDev(position.y());
106  run->AddTransvDev(position.z());
107 
108  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
109  analysisManager->FillH1(1,Trleng);
110  analysisManager->FillH1(2,(float)nbSteps);
111  }
112 /*
113  //debug
114  const G4DynamicParticle* dynamic = aTrack->GetDynamicParticle();
115  G4double dynamCharge = dynamic->GetCharge();
116  G4int occup = dynamic->GetTotalOccupancy();
117  G4double pdgMass = dynamic->GetParticleDefinition()->GetPDGMass();
118  G4double invarMass = dynamic->Get4Momentum().m();
119  G4double dynamMass = dynamic->GetMass();
120  G4double dif1 = invarMass - pdgMass;
121  G4double dif2 = dynamMass - pdgMass;
122 
123  G4cout
124  << "\n End of track :"
125  << "\n charge= " << dynamCharge << " occupancy= " << occup
126  << "\n pdgMass= " << G4BestUnit (pdgMass , "Energy")
129  << "\n dynamMass= " << G4BestUnit (dynamMass, "Energy")
130  << " dynam-pdg= " << G4BestUnit (dif2 , "Energy")
131  << G4endl;
132 */
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136 
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
G4int GetTrackID() const
G4double GetPDGCharge() const
double z() const
G4int GetCurrentStepNumber() const
G4ParticleDefinition * GetDefinition() const
void PostUserTrackingAction(const G4Track *)
G4double GetTrackLength() const
double G4double
Definition: G4Types.hh:76
const G4ThreeVector & GetPosition() const
The primary generator action class with particle gun.
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const
int G4int
Definition: G4Types.hh:78
G4ThreeVector GetParticlePosition()
double x() const
double y() const
void PreUserTrackingAction(const G4Track *)