Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
physics
src
TG4ExtDecayer.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Geant4 Virtual Monte Carlo package
3
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
14
15
#include "
TG4ExtDecayer.h
"
16
#include "
TG4G3Units.h
"
17
#include "
TG4ParticlesManager.h
"
18
19
#include <G4DecayProducts.hh>
20
#include <G4DecayTable.hh>
21
#include <G4DynamicParticle.hh>
22
#include <G4ParticleTable.hh>
23
#include <G4Track.hh>
24
25
#include <TClonesArray.h>
26
#include <TLorentzVector.h>
27
#include <TParticle.h>
28
#include <TVirtualMCDecayer.h>
29
30
#include <math.h>
31
32
//_____________________________________________________________________________
33
TG4ExtDecayer::TG4ExtDecayer
(TVirtualMCDecayer* externalDecayer)
34
:
G4VExtDecayer
(
"TG4ExtDecayer"
),
35
TG4Verbose
(
"extDecayer"
),
36
fParticlesManager
(
TG4ParticlesManager
::Instance()),
37
fExternalDecayer
(externalDecayer),
38
fDecayProductsArray
(0),
39
fSkipNeutrino
(false)
40
{
42
43
fDecayProductsArray
=
new
TClonesArray(
"TParticle"
, 1000);
44
}
45
46
//_____________________________________________________________________________
47
TG4ExtDecayer::~TG4ExtDecayer
()
48
{
50
51
delete
fDecayProductsArray
;
52
}
53
54
//
55
// public methods
56
//
57
58
//_____________________________________________________________________________
59
G4DecayProducts*
TG4ExtDecayer::ImportDecayProducts
(
const
G4Track& track)
60
{
62
63
// check if external decayer is defined
64
if
(!
fExternalDecayer
) {
65
G4cerr <<
"TG4ExtDecayer::ImportDecayProducts: "
<< G4endl
66
<<
" No fExternalDecayer is defined."
<< G4endl;
67
return
0;
68
}
69
70
// get particle momentum
71
G4ThreeVector momentum = track.GetMomentum();
72
G4double etot = track.GetDynamicParticle()->GetTotalEnergy();
73
;
74
TLorentzVector p;
75
p[0] = momentum.x() *
TG4G3Units::InverseEnergy
();
76
p[1] = momentum.y() *
TG4G3Units::InverseEnergy
();
77
p[2] = momentum.z() *
TG4G3Units::InverseEnergy
();
78
p[3] = etot *
TG4G3Units::InverseEnergy
();
79
80
// get particle PDG
81
// ask TG4ParticlesManager to get PDG encoding
82
// (in order to get PDG from extended TDatabasePDG
83
// in case the standard PDG code is not defined)
84
G4ParticleDefinition
* particleDef = track.GetDefinition();
85
G4int pdgEncoding =
fParticlesManager
->GetPDGEncoding(particleDef);
86
87
// let TVirtualMCDecayer decay the particle
88
// and import the decay products
89
fExternalDecayer
->Decay(pdgEncoding, &p);
90
G4int nofParticles =
fExternalDecayer
->ImportParticles(
fDecayProductsArray
);
91
92
if
(
VerboseLevel
() > 1) {
93
G4cout <<
"nofParticles: "
<< nofParticles << G4endl;
94
}
95
96
// convert decay products TParticle type
97
// to G4DecayProducts
98
G4DecayProducts* decayProducts =
99
new
G4DecayProducts(*(track.GetDynamicParticle()));
100
101
G4int counter = 0;
102
for
(G4int i = 0; i < nofParticles; i++) {
103
104
// get particle from TClonesArray
105
TParticle* particle =
106
fParticlesManager
->GetParticle(
fDecayProductsArray
, i);
107
108
G4int status = particle->GetStatusCode();
109
G4int pdg = particle->GetPdgCode();
110
if
((status > 0 && status < 11) &&
111
((!
fSkipNeutrino
) ||
112
(abs(pdg) != 12 && abs(pdg) != 14 && abs(pdg) != 16))) {
113
// pass to tracking final particles only;
114
// skip neutrinos if skipping option is active
115
116
if
(
VerboseLevel
() > 1) {
117
G4cout <<
" "
<< i <<
"th particle PDG: "
<< pdg <<
" "
;
118
}
119
120
// create G4DynamicParticle
121
G4DynamicParticle* dynamicParticle =
122
fParticlesManager
->CreateDynamicParticle(particle);
123
124
if
(dynamicParticle) {
125
126
if
(
VerboseLevel
() > 1) {
127
G4cout <<
" G4 particle name: "
128
<< dynamicParticle->GetDefinition()->GetParticleName()
129
<< G4endl;
130
}
131
132
// add dynamicParticle to decayProducts
133
decayProducts->PushProducts(dynamicParticle);
134
135
counter++;
136
}
137
}
138
}
139
if
(
VerboseLevel
() > 1) {
140
G4cout <<
"nofParticles for tracking: "
<< counter << G4endl;
141
}
142
143
return
decayProducts;
144
}
TG4ExtDecayer.h
Definition of the TG4ExtDecayer class.
TG4G3Units.h
Definition of the TG4G3Units class.
TG4ParticlesManager.h
Definition of the TG4ParticlesManager class.
G4ParticleDefinition
G4VExtDecayer
TG4ExtDecayer::ImportDecayProducts
virtual G4DecayProducts * ImportDecayProducts(const G4Track &track)
Definition
TG4ExtDecayer.cxx:59
TG4ExtDecayer::fDecayProductsArray
TClonesArray * fDecayProductsArray
array of decay products
Definition
TG4ExtDecayer.h:60
TG4ExtDecayer::fParticlesManager
TG4ParticlesManager * fParticlesManager
particles manager
Definition
TG4ExtDecayer.h:58
TG4ExtDecayer::TG4ExtDecayer
TG4ExtDecayer(TVirtualMCDecayer *externalDecayer)
Definition
TG4ExtDecayer.cxx:33
TG4ExtDecayer::~TG4ExtDecayer
virtual ~TG4ExtDecayer()
Definition
TG4ExtDecayer.cxx:47
TG4ExtDecayer::fSkipNeutrino
G4bool fSkipNeutrino
option to skip importing neutrinos
Definition
TG4ExtDecayer.h:61
TG4ExtDecayer::fExternalDecayer
TVirtualMCDecayer * fExternalDecayer
the external decayer
Definition
TG4ExtDecayer.h:59
TG4G3Units::InverseEnergy
static G4double InverseEnergy()
Definition
TG4G3Units.h:157
TG4ParticlesManager
Provides mapping between TDatabasePDG and Geant4 particles.
Definition
TG4ParticlesManager.h:48
TG4Verbose::VerboseLevel
virtual G4int VerboseLevel() const
Definition
TG4Verbose.h:78
TG4Verbose::TG4Verbose
TG4Verbose(const G4String &cmdName)
Definition
TG4Verbose.cxx:24
Generated on
for Geant4 VMC by
1.17.0