ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1TestSystems
src
Example3DSystem3.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// //
7
// Implementation of class Example3DSystem3 //
8
// //
9
// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10
// //
11
// Initial version: June 2007 //
12
// //
14
15
#include "
VP1TestSystems/Example3DSystem3.h
"
16
17
#include <Inventor/nodes/SoSeparator.h>
18
#include <Inventor/nodes/SoLineSet.h>
19
#include <Inventor/nodes/SoVertexProperty.h>
20
21
#include "
StoreGate/StoreGateSvc.h
"
22
#include "
TrkTrack/Track.h
"
23
#include "
TrkTrack/TrackCollection.h
"
24
#include "
TrkParameters/TrackParameters.h
"
25
//#include "CLHEP/Units/SystemOfUnits.h"
26
#include "GaudiKernel/SystemOfUnits.h"
27
28
29
//_____________________________________________________________________________________
30
Example3DSystem3::Example3DSystem3
()
31
:
IVP13DSystemSimple
(
"Ex3DSys3"
,
32
"This is an illustration of a very basic 3D system.\n"
33
"It transforms track information found in storegate"
34
" into relevant 3D objects (SoLineSet's), and displays track information when tracks are selected by the cursor."
,
35
"Thomas.Kittelmann@cern.ch"
)
36
{
37
}
38
39
//_____________________________________________________________________________________
40
void
Example3DSystem3::buildEventSceneGraph
(
StoreGateSvc
* sg, SoSeparator *root)
41
{
42
//Clear node2Track info:
43
m_nodeToTrack
.clear();
44
45
//1) Try to get the collection of (InDet) tracks from storegate:
46
47
//Sanity check:
48
if
(!sg) {
49
message
(
"Error: Got null storegate pointer"
);
50
return
;
51
}
52
53
const
TrackCollection
*trackColl;
54
std::string trackname=
"Tracks"
;
55
StatusCode status = sg->
retrieve
(trackColl, trackname);
56
if
(status != StatusCode::SUCCESS || !trackColl) {
57
message
(
"Error: Could not retrieve track collection (used key="
+QString(trackname.c_str())+
")"
);
58
return
;
59
}
60
61
//2) Loop over the tracks and construct a relevant 3D object for each of them (a SoLineSet):
62
63
TrackCollection::const_iterator
trackItr, trackItrEnd = trackColl->
end
();
64
65
for
( trackItr = trackColl->
begin
() ; trackItr != trackItrEnd; ++trackItr) {
66
const
Trk::Track
*track = (*trackItr);
67
const
DataVector<const Trk::TrackParameters>
*params = track->trackParameters();
68
69
//Just a sanity check (we need at least two points on the track):
70
if
( !params || params->size()<2 )
71
continue
;
72
73
//The list of points on this track should be set in a so-called
74
//SoVertexProperty (which one realises by reading the
75
//documentation for SoLineSet at http://doc.coin3d.org/Coin/):
76
77
SoVertexProperty *vertices =
new
SoVertexProperty();
78
79
int
iver(0);
80
DataVector<const Trk::TrackParameters>::const_iterator
it, itE = params->end();
81
for
(it = params->begin();it!=itE;++it) {
82
vertices->vertex.set1Value(iver++,(*it)->position().x(),(*it)->position().y(),(*it)->position().z());
83
}
84
85
//Create a set of lines from these vertices:
86
SoLineSet * line =
new
SoLineSet();
87
line->numVertices = iver;
88
line->vertexProperty = vertices;
89
90
//Add to the tree:
91
root->addChild(line);
92
93
//Bookkeep which track this 3D object corresponds to (we will need this to display track info when the user clicks):
94
m_nodeToTrack
[line] = track;
95
96
//To avoid GUI freeze-ups:
97
updateGUI
();
98
99
}
100
101
}
102
103
//_____________________________________________________________________________________
104
void
Example3DSystem3::userPickedNode
(SoNode* pickedNode, SoPath *
/*pickedPath*/
) {
105
106
//User clicked on "pickedNode". We should know which track this belongs to:
107
if
(
m_nodeToTrack
.find(pickedNode)==
m_nodeToTrack
.end()) {
108
message
(
"Error: Does not have track information for picked node"
);
109
return
;
110
}
111
112
//Get parameters:
113
const
DataVector<const Trk::TrackParameters>
*params =
m_nodeToTrack
[pickedNode]->trackParameters();
114
if
( !params || params->empty() ) {
115
message
(
"Error: Track has no trackparameters"
);
116
return
;
117
}
118
119
//Show some interesting information (from the first trackparameter):
120
message
(
"===> Track info:"
);
121
message
(
" |p| = "
+QString::number(params->front()->momentum().mag()/Gaudi::Units::GeV)+
" GeV"
);
122
message
(
" pT = "
+QString::number(params->front()->pT()/Gaudi::Units::GeV)+
" GeV"
);
123
message
(
" Q = "
+QString::number(params->front()->charge()));
124
message
(
" eta = "
+QString::number(params->front()->eta()));
125
126
}
Example3DSystem3.h
StoreGateSvc.h
TrackCollection.h
TrackCollection
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Definition
TrackCollection.h:19
TrackParameters.h
Track.h
DataVector
Derived DataVector<T>.
Definition
DataVector.h:795
DataVector< Trk::Track >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Example3DSystem3::Example3DSystem3
Example3DSystem3()
Definition
Example3DSystem3.cxx:30
Example3DSystem3::m_nodeToTrack
std::map< SoNode *, const Trk::Track * > m_nodeToTrack
Definition
Example3DSystem3.h:38
Example3DSystem3::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition
Example3DSystem3.cxx:40
Example3DSystem3::userPickedNode
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Definition
Example3DSystem3.cxx:104
IVP13DSystemSimple::IVP13DSystemSimple
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
Definition
IVP13DSystemSimple.cxx:50
IVP13DSystemSimple::updateGUI
void updateGUI()
Definition
IVP13DSystemSimple.h:89
IVP1System::message
void message(const QString &) const
Definition
IVP1System.cxx:336
StoreGateSvc
The Athena Transient Store API.
Definition
StoreGateSvc.h:120
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
Trk::Track
The ATLAS Track class.
Definition
Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Generated on
for ATLAS Offline Software by
1.17.0