16#include "ui_example5controllerform.h"
24#include "GaudiKernel/SystemOfUnits.h"
27#include <Inventor/nodes/SoSeparator.h>
28#include <Inventor/nodes/SoLineSet.h>
29#include <Inventor/nodes/SoVertexProperty.h>
30#include <Inventor/nodes/SoSwitch.h>
38 "This is an illustration of a very basic 3D system.\n"
39 "It transforms track information found in storegate"
40 " into 3D objects, displays track information and zooms to them upon selection, "
41 "and has a controller which allows the user to set a pt cut on tracks."
42 " It also has a multiple selection mode which can be used to display the combined invariant mass of tracks",
58 message(
"Error: Got null storegate pointer");
63 std::string trackname=
"Tracks";
64 StatusCode status = sg->
retrieve(trackColl, trackname);
65 if (status != StatusCode::SUCCESS || !trackColl) {
66 message(
"Error: Could not retrieve track collection (used key="+QString(trackname.c_str())+
")");
92 for ( trackItr = trackColl->
begin() ; trackItr != trackItrEnd; ++trackItr) {
97 if ( !params || params->size()<2 )
104 SoVertexProperty *vertices =
new SoVertexProperty();
108 for (it = params->begin();it!=itE;++it) {
109 vertices->vertex.set1Value(iver++,(*it)->position().x(),(*it)->position().y(),(*it)->position().z());
113 SoLineSet * line =
new SoLineSet();
114 line->numVertices = iver;
115 line->vertexProperty = vertices;
118 SoSwitch * sw =
new SoSwitch();
121 double pt = params->front()->pT();
122 sw->whichChild = pt >
m_ptcut ? SO_SWITCH_ALL : SO_SWITCH_NONE;
147 message(
"Error: Does not have track information for picked node");
153 if ( !params || params->empty() ) {
154 message(
"Error: Track has no trackparameters");
160 message(
" |p| = "+QString::number(params->front()->momentum().mag()/Gaudi::Units::GeV)+
" GeV");
161 message(
" pT = "+QString::number(params->front()->pT()/Gaudi::Units::GeV)+
" GeV");
162 message(
" Q = "+QString::number(params->front()->charge()));
163 message(
" eta = "+QString::number(params->front()->eta()));
167 for (
CamListItr itCam = cameras.begin(); itCam!=cameras.end(); ++itCam) {
181 double totalenergy(0);
183 for (SoNode *
node : nodes) {
186 message(
"Error: Does not have track information for all nodes");
191 if ( !params || params->empty() ) {
192 message(
"Error: Track has no trackparameters");
195 total3mom += params->front()->momentum();
196 totalenergy += params->front()->momentum().mag();
199 double invmasssq = totalenergy*totalenergy - total3mom.mag2();
200 QString invmass_str = invmasssq>=0.0 ? QString::number(sqrt(invmasssq)/Gaudi::Units::GeV) :
"sqrt(-1)*"+QString::number(sqrt(-invmasssq)/Gaudi::Units::GeV);
201 message(
"Invariant mass of "+QString::number(nodes.count())+
" selected tracks (massless particles): "+invmass_str+
" GeV");
207 QWidget * controller =
new QWidget(0);
208 Ui::Example5ControllerForm ui;
209 ui.setupUi(controller);
211 m_ptcut = ui.doubleSpinBox_ptcut->value()*Gaudi::Units::GeV;
212 connect(ui.doubleSpinBox_ptcut,SIGNAL(valueChanged(
double)),
this,SLOT(
ptCutChanged(
double)));
213 connect(ui.radioButton_select_single,SIGNAL(toggled(
bool)),
this,SLOT(
updateSelectionMode(
bool)));
222 m_ptcut = ptcut*Gaudi::Units::GeV;
225 std::map<SoSwitch*,double>::iterator it, itE =
m_switchToPt.end();
227 it->first->whichChild = ( it->second>
m_ptcut ? SO_SWITCH_ALL : SO_SWITCH_NONE );
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
SoCooperativeSelection * m_multiselection
void ptCutChanged(double)
std::map< SoNode *, const Trk::Track * > m_nodeToTrack
void userChangedSelection(SoCooperativeSelection *, const QSet< SoNode * > &, QSet< SoPath * >)
std::map< SoSwitch *, double > m_switchToPt
void updateSelectionMode(bool single)
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
QWidget * buildController()
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
std::set< SoCamera * > CamList
virtual void deselectAll(SoCooperativeSelection *exception_sel=0)
void registerSelectionNode(SoCooperativeSelection *)
CamList::iterator CamListItr
void message(const QString &) const
The Athena Transient Store API.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
static VP1CameraHelper * animatedZoomToSubTree(SoCamera *camera, SoGroup *sceneroot, SoNode *subtreeroot, double duration_in_secs=1.0, double clipVolPercent=100.0, double lastClipVolPercent=100.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999), bool varySpeed=true, bool forceCircular=false)
Eigen::Matrix< double, 3, 1 > Vector3D
=============================================================================