Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
event
src
TG4GeoTrackManager.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 "
TG4GeoTrackManager.h
"
16
#include "
TG4Globals.h
"
17
18
#include <G4Track.hh>
19
20
#include <TDatabasePDG.h>
21
#include <TGeoManager.h>
22
#include <TParticlePDG.h>
23
#include <TVirtualGeoTrack.h>
24
#include <TVirtualMC.h>
25
26
// static data members
27
const
G4double
TG4GeoTrackManager::fgkMinPointDistance
= 0.01;
28
29
//_____________________________________________________________________________
30
TG4GeoTrackManager::TG4GeoTrackManager
()
31
:
TG4Verbose
(
"geoTrackManager"
),
32
fCollectTracks
(kFALSE),
33
fCurrentTGeoTrack
(0),
34
fParentTGeoTrack
(0)
35
{
37
}
38
39
//_____________________________________________________________________________
40
TG4GeoTrackManager::~TG4GeoTrackManager
()
41
{
43
}
44
45
//
46
// public methods
47
//
48
49
//_____________________________________________________________________________
50
void
TG4GeoTrackManager::UpdateRootTrack
(
const
G4Step* step)
51
{
53
54
G4Track* track = step->GetTrack();
55
G4int stepNumber = track->GetCurrentStepNumber();
56
57
if
(stepNumber == 1) {
58
// Find and update parent track if it exists
59
Int_t trackNumber = gMC->GetStack()->GetCurrentTrackNumber();
60
Int_t parentTrackNumber = gMC->GetStack()->GetCurrentParentTrackNumber();
61
Int_t pdg = gMC->TrackPid();
62
if
(parentTrackNumber >= 0) {
63
fParentTGeoTrack
= gGeoManager->FindTrackWithId(parentTrackNumber);
64
if
(!
fParentTGeoTrack
) {
65
TString text =
"No parent track with id="
;
66
text += parentTrackNumber;
67
TG4Globals::Exception
(
"TG4GeoTrackManager"
,
"UpdateRootTrack"
, text);
68
}
69
fCurrentTGeoTrack
=
fParentTGeoTrack
->AddDaughter(trackNumber, pdg);
70
gGeoManager->SetCurrentTrack(
fCurrentTGeoTrack
);
71
72
if
(
VerboseLevel
() > 1) {
73
G4cout <<
"New TGeo track with id="
<< trackNumber <<
" pdg="
<< pdg
74
<<
" parent="
<< parentTrackNumber << G4endl;
75
}
76
}
77
else
{
78
Int_t itrack = gGeoManager->AddTrack(trackNumber, pdg);
79
gGeoManager->SetCurrentTrack(itrack);
80
fCurrentTGeoTrack
= gGeoManager->GetCurrentTrack();
81
if
(
VerboseLevel
() > 1) {
82
G4cout <<
"New primary TGeo track with id="
<< trackNumber
83
<<
" pdg="
<< pdg << G4endl;
84
}
85
}
86
TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdg);
87
if
(particle) {
88
fCurrentTGeoTrack
->SetName(particle->GetName());
89
fCurrentTGeoTrack
->SetParticle(particle);
90
}
91
}
92
93
// Skip point if its distance from the previous one is smaller than the limit
94
Double_t x, y, z;
95
gMC->TrackPosition(x, y, z);
96
Bool_t skipPoint = kFALSE;
97
if
(
fCurrentTGeoTrack
->HasPoints()) {
98
Double_t xo, yo, zo, to;
99
fCurrentTGeoTrack
->GetLastPoint(xo, yo, zo, to);
100
Double_t rdist = TMath::Sqrt(
101
(xo - x) * (xo - x) + (yo - y) * (yo - y) + (zo - z) * (zo - z));
102
if
(rdist <
fgkMinPointDistance
) skipPoint = kTRUE;
103
}
104
if
(skipPoint)
return
;
105
106
// Add point to the track
107
G4double time = gMC->TrackTime();
108
fCurrentTGeoTrack
->AddPoint(x, y, z, time);
109
if
(
VerboseLevel
() > 2) {
110
G4cout <<
"Added point (x,y,z,t)="
<< x <<
", "
<< y <<
", "
<< z <<
", "
111
<< time << G4endl;
112
}
113
}
TG4GeoTrackManager.h
Definition of the TG4GeoTrackManager class.
TG4Globals.h
Definition of the TG4Globals class and basic container types.
TG4GeoTrackManager::TG4GeoTrackManager
TG4GeoTrackManager()
Definition
TG4GeoTrackManager.cxx:30
TG4GeoTrackManager::fCollectTracks
G4bool fCollectTracks
control to collect Root tracks
Definition
TG4GeoTrackManager.h:54
TG4GeoTrackManager::fParentTGeoTrack
TVirtualGeoTrack * fParentTGeoTrack
parent of the current Root track
Definition
TG4GeoTrackManager.h:60
TG4GeoTrackManager::fCurrentTGeoTrack
TVirtualGeoTrack * fCurrentTGeoTrack
current Root track
Definition
TG4GeoTrackManager.h:57
TG4GeoTrackManager::fgkMinPointDistance
static const G4double fgkMinPointDistance
minimum point distance to store a point in TGeo track
Definition
TG4GeoTrackManager.h:48
TG4GeoTrackManager::UpdateRootTrack
void UpdateRootTrack(const G4Step *step)
Definition
TG4GeoTrackManager.cxx:50
TG4GeoTrackManager::~TG4GeoTrackManager
virtual ~TG4GeoTrackManager()
Definition
TG4GeoTrackManager.cxx:40
TG4Globals::Exception
static void Exception(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:33
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