Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TrkrTruthTrackContainerv1.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TrkrTruthTrackContainerv1.cc
1
#include "
TrkrTruthTrackContainerv1.h
"
2
#include "
TrkrTruthTrackv1.h
"
3
4
#include <algorithm>
5
#include <
g4main/PHG4Particle.h
>
6
#include <
g4main/PHG4TruthInfoContainer.h
>
7
#include <
g4main/PHG4VtxPoint.h
>
8
#include <iostream>
9
#include <
phool/phool.h
>
10
#include <set>
11
12
using
std::endl;
13
using
std::cout;
14
using
std::set
;
15
16
void
TrkrTruthTrackContainerv1::Reset
()
17
{
18
for
(
auto
entry
:
m_data
)
19
{
20
delete
entry
.second;
21
}
22
m_data.clear();
23
}
24
25
void
TrkrTruthTrackContainerv1::addTruthTrack
(
TrkrTruthTrack
* track)
26
{
27
if
(!track)
return
;
28
const
auto
id
{ track->
getTrackid
() };
29
if
(
hasTrackid
(
id
)) {
30
cout <<
PHWHERE
<<
"Warning, replacing existing track-id("
<<
id
<<
")"
<< endl;
31
}
32
m_data
[
id
] = track;
33
}
34
35
TrkrTruthTrack
*
TrkrTruthTrackContainerv1::getTruthTrack
(
unsigned
int
trackid)
36
{
37
if
(!
hasTrackid
(trackid)) {
38
cout <<
PHWHERE
<<
" Asking for TrkrTruthTrack "
<< trackid
39
<<
" which is not present. Returning empty track."
<< endl;
40
TrkrTruthTrack
* track =
new
TrkrTruthTrackv1
();
41
return
track;
42
}
43
return
m_data
[trackid];
44
}
45
46
TrkrTruthTrack
*
TrkrTruthTrackContainerv1::getTruthTrack
(
unsigned
int
id
,
PHG4TruthInfoContainer
* truth_info) {
47
// return the track if already in m_data, otherwise make it and return the newly made track
48
if
(
hasTrackid
(
id
))
return
m_data
[
id
];
49
PHG4Particle
*
particle
=
/*(PHG4Particlev3*)*/
truth_info->
GetParticle
(
id
);
50
if
(particle ==
nullptr
) {
51
cout <<
PHWHERE
<<
" Note: embedded track from PHG4TruthInfoContainer, id( "
52
<<
id
<<
" )without an associated PHG4Particle"
<< endl;
53
auto
current_track =
new
TrkrTruthTrackv1
();
54
current_track->setTrackid(
id
);
55
m_data
[
id
] = current_track;
56
return
current_track;
57
}
58
int
vtxid = particle->
get_vtx_id
();
59
PHG4VtxPoint
* vtx = truth_info->
GetVtx
(vtxid);
60
auto
current_track =
new
TrkrTruthTrackv1
(
id
, particle, vtx) ;
61
m_data
[
id
] = current_track;
62
return
current_track;
63
}
64
65
66
TrkrTruthTrackContainer::ConstRange
TrkrTruthTrackContainerv1::getTruthTrackRange
()
const
67
{
68
return
std::make_pair(
m_data
.begin(),
m_data
.end());
69
}
70
71
bool
TrkrTruthTrackContainerv1::hasTrackid
(
unsigned
int
id
)
const
72
{
73
return
(
m_data
.find(
id
) !=
m_data
.end());
74
}
75
76
TrkrTruthTrackContainer::Map
&
TrkrTruthTrackContainerv1::getMap
()
77
{
78
return
m_data
;
79
}
80
81
void
TrkrTruthTrackContainerv1::identify
(std::ostream&
os
)
const
82
{
83
os <<
" TrkrTruthTrackContainer data. Containter "
<< (int)
m_data
.size() <<
" tracks"
<< std::endl;
84
int
cnt = 0;
85
for
(
auto
&
entry
:
m_data
)
86
{
87
os <<
" Track("
<< cnt <<
"): "
<< std::endl;
88
entry
.second->identify(os);
89
++cnt;
90
}
91
}
coresoftware
blob
master
simulation
g4simulation
g4tracking
TrkrTruthTrackContainerv1.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:16
using
1.8.2 with
sPHENIX GitHub integration