ATLAS Offline Software
Loading...
Searching...
No Matches
VP1VertexSystem.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
9
13#include <Inventor/nodes/SoSeparator.h>
14#include <Inventor/nodes/SoSwitch.h>
15#include <Inventor/SoPath.h>
16
17//____________________________________________________________________
19public:
21 std::map<const VP1StdCollection*,QList< std::pair<const SoMaterial*, QList< const Trk::Track*> > > > tracksFromVertices ;
22};
23
24//_____________________________________________________________________________________
26 : IVP13DSystemSimple ( "Vertex","Vertex system",
27 "Thomas.Kittelmann@cern.ch, Andreas.Wildauer@cern.ch" ),
28 m_d(new Imp)
29{
30 m_d->controller = 0;
31}
32
33//____________________________________________________________________
38
39//_____________________________________________________________________________________
41{
42 //Save present states and then clear all event data and related gui elements.
43 m_d->controller->collWidget()->clear();
44 m_d->tracksFromVertices.clear();
45}
46
47//_____________________________________________________________________________________
49{
50 root->addChild(m_d->controller->drawOptions());
51
52 QList<VP1StdCollection*> cols;
53 //Create collection list based on contents of event store:
56
57 //Populate gui (also applies states):
58 m_d->controller->collWidget()->setCollections(cols);
59
60 //Add collections to event scenegraph:
61 for (VP1StdCollection* col : cols){
62 root->addChild(col->collSwitch());
63 VP1VertexCollection* vertColl = dynamic_cast<VP1VertexCollection*> (col);
64 if (vertColl) vertColl->recheckAllCuts(); //bit of a hack - the idea is to force the emission of the signal about track from vertices
65 }
66
67
68}
69
70//_____________________________________________________________________________________
72{
73 m_d->controller = new VertexSysController(this);
74 return m_d->controller;
75}
76
77//_____________________________________________________________________________________
78void VP1VertexSystem::userPickedNode(SoNode*, SoPath * pickedPath) {
79
80 //Find in which collection an object was picked:
81 VP1StdCollection* pickedCol(0);
82 for (VP1StdCollection* col : m_d->controller->collWidget()->collections<VP1StdCollection>()) {
83 if (col->visible()&&pickedPath->containsNode(col->collSep())) {
84 pickedCol = col;
85 break;
86 }
87 }
88 if (!pickedCol) {
89 message("Error: Could not determine in which collection click took place.");
90 return;
91 }
92
93 //React to click:
94 VP1VertexCollection * recoCol = dynamic_cast<VP1VertexCollection *>(pickedCol);
95 if (recoCol) {
96 message(recoCol->infoOnClicked(pickedPath));
97 return;
98 }
99 VP1TruthVertexCollection * truthCol = dynamic_cast<VP1TruthVertexCollection *>(pickedCol);
100 if (truthCol) {
101 message(truthCol->infoOnClicked(pickedPath));
102 return;
103 }
104 message("Error: Unknown vertex collection type.");
105}
106
107//_____________________________________________________________________________________
109{
111 VP1Serialise serialise(1/*version*/,this);
112 serialise.save(IVP13DSystemSimple::saveState());
113 serialise.save(m_d->controller->saveSettings());//Version 1+
114 serialise.save(m_d->controller->collWidget());
115 serialise.disableUnsavedChecks();//We do the testing in the controller
116 return serialise.result();
117}
118
119//_____________________________________________________________________________________
121{
122 VP1Deserialise state(ba,this);
123 if (state.version()<0||state.version()>1) {
124 message("Warning: State data in .vp1 file is in wrong format - ignoring!");
125 return;
126 }
129 if (state.version()>=1)
130 m_d->controller->restoreSettings(state.restoreByteArray());
131 state.restore(m_d->controller->collWidget());
132
133 state.disableUnrestoredChecks();//We do the testing in the controller
134}
135
136void VP1VertexSystem::updateVertexToTracks(QList< std::pair<const SoMaterial*, QList< const Trk::Track*> > >& newTracksFromVertices)
137{
138 messageVerbose(" updateVertexToTracks with "+QString::number(newTracksFromVertices.size())+" vertices.");
139 const VP1StdCollection* coll = static_cast<const VP1StdCollection*> (QObject::sender());
140 if (!coll) return;
141 m_d->tracksFromVertices[coll]=newTracksFromVertices;
142 QList< std::pair<const SoMaterial*, QList< const Trk::Track*> > > tmpList; // fill and emit
143
144 std::map<const VP1StdCollection*,QList< std::pair<const SoMaterial*, QList< const Trk::Track*> > > >::const_iterator
145 it=m_d->tracksFromVertices.begin(), itEnd=m_d->tracksFromVertices.end();
146
147 for ( ;it!=itEnd; ++it){
148 tmpList+=it->second;
149 }
150 messageVerbose(" emitting tracksFromVerticesChanged "+QString::number(tmpList.size())+" collections.");
151
152 emit tracksFromVertexChanged(tmpList);
153}
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
void messageVerbose(const QString &) const
virtual void restoreFromState(QByteArray)
State state() const
void message(const QString &) const
virtual QByteArray saveState()
The Athena Transient Store API.
QStringList infoOnClicked(SoPath *pickedPath)
static QList< VP1StdCollection * > createCollections(VertexSysController *)
QStringList infoOnClicked(SoPath *pickedPath)
static QList< VP1StdCollection * > createCollections(VertexSysController *controller)
VertexSysController * controller
std::map< const VP1StdCollection *, QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > > tracksFromVertices
void restoreFromState(QByteArray ba)
QWidget * buildController()
void tracksFromVertexChanged(QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > &)
void updateVertexToTracks(QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > &)
QByteArray saveState()
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
virtual ~VP1VertexSystem()
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)