ATLAS Offline Software
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"
18 #include "AtlasHepMC/GenParticle.h"
19 #include "AtlasHepMC/GenVertex.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 //____________________________________________________________________
38 public:
40  : genVertex(v), genParticle(p), simhit(nullptr) {}
42  : genVertex(nullptr), genParticle(nullptr), simhit(s) {}
46 };
47 
48 
49 //____________________________________________________________________
52 {
53 }
54 
55 //____________________________________________________________________
58 {
59 }
60 
61 //____________________________________________________________________
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();
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;
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 }
AscObj_TruthPoint::buildShapes
void buildShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
Definition: AscObj_TruthPoint.cxx:68
AssociatedObjectHandleBase
Definition: AssociatedObjectHandleBase.h:35
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
checkFileSG.line
line
Definition: checkFileSG.py:75
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MuonEDMPrinterTool.h
VP1Msg.h
GenVertex.h
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
AscObj_TruthPoint::~AscObj_TruthPoint
virtual ~AscObj_TruthPoint()
Definition: AscObj_TruthPoint.cxx:62
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
GenParticle.h
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
SimHitHandleBase::momentumDirection
virtual Amg::Vector3D momentumDirection() const =0
SimHitHandleBase::posStart
virtual Amg::Vector3D posStart() const =0
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
GeoPrimitives.h
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
python.TriggerHandler.th
th
Definition: TriggerHandler.py:296
AscObj_TruthPoint.h
AmgStringHelpers.h
SimHitHandleBase::type
virtual QString type() const =0
AscObj_TruthPoint::Imp
Definition: AscObj_TruthPoint.cxx:37
AscObj_TruthPoint::AscObj_TruthPoint
AscObj_TruthPoint(TrackHandleBase *, HepMC::ConstGenVertexPtr v, HepMC::ConstGenParticlePtr p)
Definition: AscObj_TruthPoint.cxx:50
SimHitHandleBase::momentum
double momentum() const
Definition: SimHitHandleBase.h:41
AscObj_TruthPoint::Imp::simhit
SimHitHandleBase * simhit
Definition: AscObj_TruthPoint.cxx:45
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
AscObj_TruthPoint::m_d
Imp * m_d
Definition: AscObj_TruthPoint.h:43
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
SimHitHandleBase.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
AscObj_TruthPoint::Imp::Imp
Imp(SimHitHandleBase *s)
Definition: AscObj_TruthPoint.cxx:41
AscObj_TruthPoint::Imp::Imp
Imp(HepMC::ConstGenVertexPtr v, HepMC::ConstGenParticlePtr p)
Definition: AscObj_TruthPoint.cxx:39
AscObj_TruthPoint::regionIndex
int regionIndex() const
Definition: AscObj_TruthPoint.cxx:147
python.PyAthena.v
v
Definition: PyAthena.py:154
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
AscObj_TruthPoint::clicked
QStringList clicked()
Definition: AscObj_TruthPoint.cxx:111
SimHitHandleBase::actualMomentum
virtual double actualMomentum() const
Definition: SimHitHandleBase.h:40
Amg::AsString
std::string AsString(const T &m)
write an Amg Eigen object to std::string
Definition: AmgStringHelpers.h:26
SimHitHandleBase
Definition: SimHitHandleBase.h:32
AscObj_TruthPoint::Imp::genVertex
HepMC::ConstGenVertexPtr genVertex
Definition: AscObj_TruthPoint.cxx:43
AscObj_TruthPoint::Imp::genParticle
HepMC::ConstGenParticlePtr genParticle
Definition: AscObj_TruthPoint.cxx:44
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
TrackHandleBase
Definition: TrackHandleBase.h:56
AscObj_TruthPoint::lodCrossOverValue
double lodCrossOverValue() const
Definition: AscObj_TruthPoint.cxx:153