ATLAS Offline Software
Loading...
Searching...
No Matches
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
17#include "VP1Base/VP1Msg.h"
20
21// Eigen migration
22//#include "TrkEventPrimitives/GlobalPosition.h"
23//#include "TrkEventPrimitives/GlobalMomentum.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>
32
33#include <string> // for C++11 to_string features
34
35
36//____________________________________________________________________
47
48
49//____________________________________________________________________
54
55//____________________________________________________________________
60
61//____________________________________________________________________
66
67//____________________________________________________________________
68void 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//____________________________________________________________________
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//____________________________________________________________________
148{
149 return 0;
150}
151
152//____________________________________________________________________
154{
155 return 100;
156}
SimHitHandleBase * simhit
Imp(HepMC::ConstGenVertexPtr v, HepMC::ConstGenParticlePtr p)
HepMC::ConstGenVertexPtr genVertex
HepMC::ConstGenParticlePtr genParticle
Imp(SimHitHandleBase *s)
AscObj_TruthPoint(TrackHandleBase *, HepMC::ConstGenVertexPtr v, HepMC::ConstGenParticlePtr p)
double lodCrossOverValue() const
void buildShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
static QString str(const QString &s)
Definition VP1String.h:49
std::string AsString(const T &m)
write an Amg Eigen object to std::string
Eigen::Matrix< double, 3, 1 > Vector3D
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60