Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
eventgenerator
HepMC
MCTruth
src
MCTruthTrackingAction.cc
Go to the documentation of this file.
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
//
30
// $Id$
31
//
32
//
33
// --------------------------------------------------------------
34
// GEANT 4 - MCTruthTrackingAction class
35
// --------------------------------------------------------------
36
//
37
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
38
//
39
// --------------------------------------------------------------
40
41
#include <iostream>
42
43
#include "
G4Track.hh
"
44
#include "
G4TrackVector.hh
"
45
#include "
G4TrackingManager.hh
"
46
#include "
MCTruthTrackingAction.hh
"
47
#include "
MCTruthTrackInformation.hh
"
48
49
MCTruthTrackingAction::MCTruthTrackingAction
()
50
{}
51
52
MCTruthTrackingAction::~MCTruthTrackingAction
()
53
{}
54
55
void
MCTruthTrackingAction::PreUserTrackingAction
(
const
G4Track
* track)
56
{
57
fmom =
G4LorentzVector
(track->
GetMomentum
(), track->
GetTotalEnergy
());
58
59
if
(!track->
GetUserInformation
())
60
{
61
G4VUserTrackInformation
* mcinf =
new
MCTruthTrackInformation
;
62
fpTrackingManager
->
SetUserTrackInformation
(mcinf);
63
}
64
}
65
66
void
MCTruthTrackingAction::PostUserTrackingAction
(
const
G4Track
* track)
67
{
68
69
G4LorentzVector
prodpos(track->
GetGlobalTime
() - track->
GetLocalTime
(),
70
track->
GetVertexPosition
());
71
G4LorentzVector
endpos(track->
GetGlobalTime
(), track->
GetPosition
());
72
73
// here (?) make all different checks to decide whether to store the particle
74
//
75
if
(trackToBeStored(track))
76
{
77
MCTruthTrackInformation
* mcinf =
78
(
MCTruthTrackInformation
*) track->
GetUserInformation
();
79
80
MCTruthManager::GetInstance
()->
81
AddParticle(fmom, prodpos, endpos,
82
track->
GetDefinition
()->
GetPDGEncoding
(),
83
track->
GetTrackID
(),
84
track->
GetParentID
(), mcinf->
GetDirectParent
());
85
}
86
else
87
{
88
// If track is not to be stored, propagate it's parent ID (stored)
89
// to its secondaries
90
//
91
G4TrackVector
* childrens =
fpTrackingManager
->
GimmeSecondaries
() ;
92
93
for
(
unsigned
int
index
= 0 ;
index
< childrens->size() ; ++
index
)
94
{
95
G4Track
* tr = (*childrens)[
index
] ;
96
tr->
SetParentID
( track->
GetParentID
() );
97
98
// set the flag saying that the direct mother is not stored
99
//
100
MCTruthTrackInformation
* mcinf =
101
(
MCTruthTrackInformation
*) tr->
GetUserInformation
();
102
if
(!mcinf)
103
tr->
SetUserInformation
(mcinf =
new
MCTruthTrackInformation
);
104
105
mcinf->
SetDirectParent
(
false
);
106
}
107
}
108
}
109
110
G4bool
MCTruthTrackingAction::trackToBeStored(
const
G4Track
* track)
111
{
112
MCTruthConfig
*
config
=
MCTruthManager::GetInstance
()->
GetConfig
();
113
114
// check energy
115
if
(fmom.
e
() > config->
GetMinE
())
return
true
;
116
117
// particle type
118
std::vector<G4int> types = config->
GetParticleTypes
();
119
120
if
(std::find( types.begin(), types.end(),
121
track->
GetDefinition
()->
GetPDGEncoding
())
122
!= types.end())
return
true
;
123
124
// creator process
125
126
// etc...
127
128
return
false
;
129
}
Generated on Sat May 25 2013 14:32:24 for Geant4 by
1.8.4