ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1TestSystems
src
Example3DSystem2.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 Example3DSystem2 //
8
// //
9
// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10
// //
11
// Initial version: June 2007 //
12
// //
14
15
#include "
VP1TestSystems/Example3DSystem2.h
"
16
17
#include "
StoreGate/StoreGateSvc.h
"
18
#include "
TrkTrack/Track.h
"
19
#include "
TrkTrack/TrackCollection.h
"
20
#include "
TrkParameters/TrackParameters.h
"
21
22
#include <Inventor/nodes/SoSeparator.h>
23
#include <Inventor/nodes/SoLineSet.h>
24
#include <Inventor/nodes/SoVertexProperty.h>
25
26
//_____________________________________________________________________________________
27
Example3DSystem2::Example3DSystem2
()
28
:
IVP13DSystemSimple
(
"Ex3DSys2"
,
29
"This is an illustration of a very basic 3D system.\n"
30
"It simply transforms track information found in storegate"
31
" into relevant 3D objects (SoLineSet's)."
,
32
"Thomas.Kittelmann@cern.ch"
)
33
{
34
}
35
36
//_____________________________________________________________________________________
37
void
Example3DSystem2::buildEventSceneGraph
(
StoreGateSvc
* sg, SoSeparator *root)
38
{
39
//1) Try to get the collection of (InDet) tracks from storegate:
40
41
//Sanity check:
42
if
(!sg) {
43
message
(
"Error: Got null storegate pointer"
);
44
return
;
45
}
46
47
const
TrackCollection
*trackColl;
48
std::string trackname=
"Tracks"
;
49
StatusCode status = sg->
retrieve
(trackColl, trackname);
50
if
(status != StatusCode::SUCCESS || !trackColl) {
51
message
(
"Error: Could not retrieve track collection (used key="
+QString(trackname.c_str())+
")"
);
52
return
;
53
}
54
55
//2) Loop over the tracks and construct a relevant 3D object for each of them (a SoLineSet):
56
57
TrackCollection::const_iterator
trackItr, trackItrEnd = trackColl->
end
();
58
59
for
( trackItr = trackColl->
begin
() ; trackItr != trackItrEnd; ++trackItr) {
60
const
Trk::Track
*track = (*trackItr);
61
const
DataVector<const Trk::TrackParameters>
*params = track->trackParameters();
62
63
//Just a sanity check:
64
if
( !params )
65
continue
;
66
67
//The list of points on this track should be set in a so-called
68
//SoVertexProperty (which one realises by reading the
69
//documentation for SoLineSet at http://doc.coin3d.org/Coin/):
70
71
SoVertexProperty *vertices =
new
SoVertexProperty();
72
73
int
iver(0);
74
DataVector<const Trk::TrackParameters>::const_iterator
it, itE = params->end();
75
for
(it = params->begin();it!=itE;++it) {
76
vertices->vertex.set1Value(iver++,(*it)->position().x(),(*it)->position().y(),(*it)->position().z());
77
}
78
79
//Create a set of lines from these vertices:
80
SoLineSet * line =
new
SoLineSet();
81
line->numVertices = iver;
82
line->vertexProperty = vertices;
83
84
//Add to the tree:
85
root->addChild(line);
86
87
//To avoid GUI freeze-ups:
88
updateGUI
();
89
90
}
91
92
}
Example3DSystem2.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.
Example3DSystem2::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition
Example3DSystem2.cxx:37
Example3DSystem2::Example3DSystem2
Example3DSystem2()
Definition
Example3DSystem2.cxx:27
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