ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1TrackSystems
src
AscObj_TruthPoint.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Implementation of class AscObj_TruthPoint //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: May 2008 //
12
// //
14
15
#include "
VP1TrackSystems/AscObj_TruthPoint.h
"
16
#include "
VP1TrackSystems/SimHitHandleBase.h
"
17
#include "
VP1Base/VP1Msg.h
"
18
#include "
AtlasHepMC/GenParticle.h
"
19
#include "
AtlasHepMC/GenVertex.h
"
20
21
// Eigen migration
22
//#include "TrkEventPrimitives/GlobalPosition.h"
23
//#include "TrkEventPrimitives/GlobalMomentum.h"
24
#include "
GeoPrimitives/GeoPrimitives.h
"
25
#include "
GeoPrimitives/AmgStringHelpers.h
"
26
27
#include <Inventor/C/errors/debugerror.h>
28
#include <Inventor/nodes/SoLineSet.h>
29
#include <Inventor/nodes/SoSeparator.h>
30
#include <Inventor/nodes/SoVertexProperty.h>
31
#include "
MuonRecHelperTools/MuonEDMPrinterTool.h
"
32
33
#include <string>
// for C++11 to_string features
34
35
36
//____________________________________________________________________
37
class
AscObj_TruthPoint::Imp
{
38
public
:
39
Imp
(
HepMC::ConstGenVertexPtr
v,
HepMC::ConstGenParticlePtr
p)
40
:
genVertex
(v),
genParticle
(p),
simhit
(nullptr) {}
41
Imp
(
SimHitHandleBase
*s)
42
:
genVertex
(nullptr),
genParticle
(nullptr),
simhit
(s) {}
43
HepMC::ConstGenVertexPtr
genVertex
;
44
HepMC::ConstGenParticlePtr
genParticle
;
45
SimHitHandleBase
*
simhit
;
46
};
47
48
49
//____________________________________________________________________
50
AscObj_TruthPoint::AscObj_TruthPoint
(
TrackHandleBase
*th,
HepMC::ConstGenVertexPtr
v,
HepMC::ConstGenParticlePtr
p)
51
:
AssociatedObjectHandleBase
(th),
m_d
(new
Imp
(v,p))
52
{
53
}
54
55
//____________________________________________________________________
56
AscObj_TruthPoint::AscObj_TruthPoint
(
TrackHandleBase
*th,
SimHitHandleBase
*s)
57
:
AssociatedObjectHandleBase
(th),
m_d
(new
Imp
(s))
58
{
59
}
60
61
//____________________________________________________________________
62
AscObj_TruthPoint::~AscObj_TruthPoint
()
63
{
64
delete
m_d
;
65
}
66
67
//____________________________________________________________________
68
void
AscObj_TruthPoint::buildShapes
(SoSeparator*&shape_simple, SoSeparator*&shape_detailed)
69
{
70
VP1Msg::message
(
"AscObj_TruthPoint::buildShapes."
);
71
72
// Eigen migration
73
// Trk::GlobalPosition p1;//point
74
// Trk::GlobalMomentum u;//mom direction
75
Amg::Vector3D
p1;
//point
76
Amg::Vector3D
u;
//mom direction
77
78
79
if
(
m_d
->simhit) {
80
p1 =
m_d
->simhit->posStart();
81
u =
m_d
->simhit->momentumDirection();
82
}
83
else
84
{
85
// Eigen migration
86
p1 =
Amg::Vector3D
(
m_d
->genVertex->position().x(),
m_d
->genVertex->position().y(),
m_d
->genVertex->position().z());
87
u =
Amg::Vector3D
(
m_d
->genParticle->momentum().px(),
m_d
->genParticle->momentum().py(),
m_d
->genParticle->momentum().pz()).unit();
88
}
89
90
// Eigen migration
91
// Trk::GlobalPosition p2 = p1+5*CLHEP::cm*u;
92
Amg::Vector3D
p2 = p1+5*CLHEP::cm*u;
93
94
SoLineSet * line =
new
SoLineSet();
95
SoVertexProperty * vertices =
new
SoVertexProperty();
96
vertices->vertex.set1Value(0,p1.x(),p1.y(),p1.z());
97
vertices->vertex.set1Value(1,p2.x(),p2.y(),p2.z());
98
line->numVertices.set1Value(0,2);
99
line->vertexProperty = vertices;
100
101
shape_simple =
new
SoSeparator;
102
shape_simple->addChild(line);
103
shape_detailed = shape_simple;
104
105
// //Fixme: Uncomment these two lines:
106
// shape_detailed = new SoSeparator;
107
// shape_detailed->addChild(line);
108
}
109
110
//____________________________________________________________________
111
QStringList
AscObj_TruthPoint::clicked
()
112
{
113
VP1Msg::messageVerbose
(
"AscObj_TruthPoint::clicked()"
);
114
115
QStringList l;
116
117
l <<
" ==> Truth point"
;
118
if
(
m_d
->simhit) {
119
l <<
"Sim Hit ("
+
m_d
->simhit->type()+
")"
;
121
// l << " Direction: "+VP1Msg::str( m_d->simhit->momentumDirection() );
122
// l << " Momentum: "+VP1Msg::str(m_d->simhit->momentum()/CLHEP::GeV)+" GeV"+(m_d->simhit->actualMomentum()==m_d->simhit->momentum()?"":" (fudged)");
123
l <<
" Position: "
+ QString::fromStdString(
Amg::AsString
(
m_d
->simhit->posStart()));
124
l <<
" Direction: "
+ QString::fromStdString(
Amg::AsString
(
m_d
->simhit->momentumDirection()));
125
l <<
" Momentum: "
+
VP1Msg::str
(
m_d
->simhit->momentum()/CLHEP::GeV)+
" GeV"
+(
m_d
->simhit->actualMomentum()==
m_d
->simhit->momentum()?
""
:
" (fudged)"
);
126
}
else
{
127
if
(!
m_d
->genVertex||!
m_d
->genParticle) {
128
l <<
"ERROR"
;
129
return
l;
130
}
131
132
Amg::Vector3D
p(
m_d
->genVertex->position().x(),
m_d
->genVertex->position().y(),
m_d
->genVertex->position().z());
133
Amg::Vector3D
mom(
m_d
->genParticle->momentum().px(),
m_d
->genParticle->momentum().py(),
m_d
->genParticle->momentum().pz());
134
135
l <<
"Gen Particle vertex"
;
136
// l << " Position: "+VP1Msg::str(p);
137
// l << " Direction: "+ VP1Msg::str(mom.unit());
138
l <<
" Position: "
+ QString::fromStdString(
Amg::AsString
(p));
139
l <<
" Direction: "
+ QString::fromStdString(
Amg::AsString
(mom.unit()) );
140
l <<
" Momentum: "
+
VP1Msg::str
(mom.mag()/CLHEP::GeV)+
" GeV"
;
141
}
142
143
return
l;
144
}
145
146
//____________________________________________________________________
147
int
AscObj_TruthPoint::regionIndex
()
const
148
{
149
return
0;
150
}
151
152
//____________________________________________________________________
153
double
AscObj_TruthPoint::lodCrossOverValue
()
const
154
{
155
return
100;
156
}
AmgStringHelpers.h
AscObj_TruthPoint.h
GenParticle.h
GenVertex.h
GeoPrimitives.h
MuonEDMPrinterTool.h
SimHitHandleBase.h
VP1Msg.h
AscObj_TruthPoint::Imp
Definition
AscObj_TruthPoint.cxx:37
AscObj_TruthPoint::Imp::simhit
SimHitHandleBase * simhit
Definition
AscObj_TruthPoint.cxx:45
AscObj_TruthPoint::Imp::Imp
Imp(HepMC::ConstGenVertexPtr v, HepMC::ConstGenParticlePtr p)
Definition
AscObj_TruthPoint.cxx:39
AscObj_TruthPoint::Imp::genVertex
HepMC::ConstGenVertexPtr genVertex
Definition
AscObj_TruthPoint.cxx:43
AscObj_TruthPoint::Imp::genParticle
HepMC::ConstGenParticlePtr genParticle
Definition
AscObj_TruthPoint.cxx:44
AscObj_TruthPoint::Imp::Imp
Imp(SimHitHandleBase *s)
Definition
AscObj_TruthPoint.cxx:41
AscObj_TruthPoint::regionIndex
int regionIndex() const
Definition
AscObj_TruthPoint.cxx:147
AscObj_TruthPoint::~AscObj_TruthPoint
virtual ~AscObj_TruthPoint()
Definition
AscObj_TruthPoint.cxx:62
AscObj_TruthPoint::m_d
Imp * m_d
Definition
AscObj_TruthPoint.h:44
AscObj_TruthPoint::AscObj_TruthPoint
AscObj_TruthPoint(TrackHandleBase *, HepMC::ConstGenVertexPtr v, HepMC::ConstGenParticlePtr p)
Definition
AscObj_TruthPoint.cxx:50
AscObj_TruthPoint::lodCrossOverValue
double lodCrossOverValue() const
Definition
AscObj_TruthPoint.cxx:153
AscObj_TruthPoint::clicked
QStringList clicked()
Definition
AscObj_TruthPoint.cxx:111
AscObj_TruthPoint::buildShapes
void buildShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
Definition
AscObj_TruthPoint.cxx:68
AssociatedObjectHandleBase::AssociatedObjectHandleBase
AssociatedObjectHandleBase(TrackHandleBase *)
Definition
AssociatedObjectHandleBase.cxx:111
AssociatedObjectHandleBase::TrackHandleBase
friend class TrackHandleBase
Definition
AssociatedObjectHandleBase.h:101
SimHitHandleBase
Definition
SimHitHandleBase.h:32
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition
VP1Msg.cxx:84
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition
VP1Msg.cxx:30
VP1String::str
static QString str(const QString &s)
Definition
VP1String.h:49
Amg::AsString
std::string AsString(const T &m)
write an Amg Eigen object to std::string
Definition
AmgStringHelpers.h:26
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
HepMC::ConstGenParticlePtr
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition
GenParticle.h:20
HepMC::ConstGenVertexPtr
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
Definition
GenVertex.h:24
Generated on
for ATLAS Offline Software by
1.17.0