ATLAS Offline Software
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 
16 
17 #include "StoreGate/StoreGateSvc.h"
18 #include "TrkTrack/Track.h"
21 
22 #include <Inventor/nodes/SoSeparator.h>
23 #include <Inventor/nodes/SoLineSet.h>
24 #include <Inventor/nodes/SoVertexProperty.h>
25 
26 //_____________________________________________________________________________________
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 //_____________________________________________________________________________________
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);
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::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition: Example3DSystem2.cxx:37
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
checkFileSG.line
line
Definition: checkFileSG.py:75
IVP13DSystemSimple
Definition: IVP13DSystemSimple.h:24
TrackParameters.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Example3DSystem2::Example3DSystem2
Example3DSystem2()
Definition: Example3DSystem2.cxx:27
skel.it
it
Definition: skel.GENtoEVGEN.py:423
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
TruthTest.itE
itE
Definition: TruthTest.py:25
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
Track.h
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TrackCollection.h
DataVector< Trk::Track >
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
IVP13DSystemSimple::updateGUI
void updateGUI()
Definition: IVP13DSystemSimple.h:89
merge.status
status
Definition: merge.py:17
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
Example3DSystem2.h
StoreGateSvc.h
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.