ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1VertexSystems
src
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
5
#include "
VP1VertexSystems/VP1VertexSystem.h
"
6
#include "
VP1VertexSystems/VP1VertexCollection.h
"
7
#include "
VP1VertexSystems/VertexSysController.h
"
8
#include "
VP1VertexSystems/VP1TruthVertexCollection.h
"
9
10
#include "
VP1Base/VP1CollectionWidget.h
"
11
#include "
VP1Base/VP1Serialise.h
"
12
#include "
VP1Base/VP1Deserialise.h
"
13
#include <Inventor/nodes/SoSeparator.h>
14
#include <Inventor/nodes/SoSwitch.h>
15
#include <Inventor/SoPath.h>
16
17
//____________________________________________________________________
18
class
VP1VertexSystem::Imp
{
19
public
:
20
VertexSysController
*
controller
=
nullptr
;
21
std::map<const VP1StdCollection*,QList< std::pair<const SoMaterial*, QList< const Trk::Track*> > > >
tracksFromVertices
;
22
};
23
24
//_____________________________________________________________________________________
25
VP1VertexSystem::VP1VertexSystem
()
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
//____________________________________________________________________
34
VP1VertexSystem::~VP1VertexSystem
()
35
{
36
delete
m_d
;
37
}
38
39
//_____________________________________________________________________________________
40
void
VP1VertexSystem::systemerase
( )
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
//_____________________________________________________________________________________
48
void
VP1VertexSystem::buildEventSceneGraph
(
StoreGateSvc
*, SoSeparator *root )
49
{
50
root->addChild(
m_d
->controller->drawOptions());
51
52
QList<VP1StdCollection*> cols;
53
//Create collection list based on contents of event store:
54
cols <<
VP1VertexCollection::createCollections
(
m_d
->controller);
55
cols <<
VP1TruthVertexCollection::createCollections
(
m_d
->controller);
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
//_____________________________________________________________________________________
71
QWidget *
VP1VertexSystem::buildController
()
72
{
73
m_d
->controller =
new
VertexSysController
(
this
);
74
return
m_d
->controller;
75
}
76
77
//_____________________________________________________________________________________
78
void
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
//_____________________________________________________________________________________
108
QByteArray
VP1VertexSystem::saveState
()
109
{
110
ensureBuildController
();
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
//_____________________________________________________________________________________
120
void
VP1VertexSystem::restoreFromState
(QByteArray ba)
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
}
127
ensureBuildController
();
128
IVP13DSystemSimple::restoreFromState
(
state
.restoreByteArray());
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
136
void
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
}
VP1CollectionWidget.h
VP1Deserialise.h
VP1Serialise.h
VP1TruthVertexCollection.h
VP1VertexCollection.h
VP1VertexSystem.h
VertexSysController.h
const_iterator
IVP13DSystemSimple::IVP13DSystemSimple
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
Definition
IVP13DSystemSimple.cxx:50
IVP13DSystemSimple::ensureBuildController
void ensureBuildController()
Definition
IVP13DSystemSimple.cxx:90
IVP1System::messageVerbose
void messageVerbose(const QString &) const
Definition
IVP1System.cxx:354
IVP1System::restoreFromState
virtual void restoreFromState(QByteArray)
Definition
IVP1System.cxx:302
IVP1System::state
State state() const
Definition
IVP1System.cxx:129
IVP1System::message
void message(const QString &) const
Definition
IVP1System.cxx:336
IVP1System::saveState
virtual QByteArray saveState()
Definition
IVP1System.cxx:294
StoreGateSvc
The Athena Transient Store API.
Definition
StoreGateSvc.h:120
VP1Deserialise
Definition
VP1Deserialise.h:44
VP1Serialise
Definition
VP1Serialise.h:45
VP1StdCollection
Definition
VP1StdCollection.h:31
VP1TruthVertexCollection
Definition
VP1TruthVertexCollection.h:31
VP1TruthVertexCollection::infoOnClicked
QStringList infoOnClicked(SoPath *pickedPath)
Definition
VP1TruthVertexCollection.cxx:262
VP1TruthVertexCollection::createCollections
static QList< VP1StdCollection * > createCollections(VertexSysController *)
Definition
VP1TruthVertexCollection.cxx:43
VP1VertexCollection
Definition
VP1VertexCollection.h:32
VP1VertexCollection::infoOnClicked
QStringList infoOnClicked(SoPath *pickedPath)
Definition
VP1VertexCollection.cxx:489
VP1VertexCollection::recheckAllCuts
void recheckAllCuts()
Definition
VP1VertexCollection.cxx:436
VP1VertexCollection::createCollections
static QList< VP1StdCollection * > createCollections(VertexSysController *controller)
Definition
VP1VertexCollection.cxx:52
VP1VertexSystem::Imp
Definition
VP1VertexSystem.cxx:18
VP1VertexSystem::Imp::controller
VertexSysController * controller
Definition
VP1VertexSystem.cxx:20
VP1VertexSystem::Imp::tracksFromVertices
std::map< const VP1StdCollection *, QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > > tracksFromVertices
Definition
VP1VertexSystem.cxx:21
VP1VertexSystem::restoreFromState
void restoreFromState(QByteArray ba)
Definition
VP1VertexSystem.cxx:120
VP1VertexSystem::systemerase
void systemerase()
Definition
VP1VertexSystem.cxx:40
VP1VertexSystem::buildController
QWidget * buildController()
Definition
VP1VertexSystem.cxx:71
VP1VertexSystem::tracksFromVertexChanged
void tracksFromVertexChanged(QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > &)
VP1VertexSystem::updateVertexToTracks
void updateVertexToTracks(QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > &)
Definition
VP1VertexSystem.cxx:136
VP1VertexSystem::VP1VertexSystem
VP1VertexSystem()
Definition
VP1VertexSystem.cxx:25
VP1VertexSystem::saveState
QByteArray saveState()
Definition
VP1VertexSystem.cxx:108
VP1VertexSystem::userPickedNode
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Definition
VP1VertexSystem.cxx:78
VP1VertexSystem::~VP1VertexSystem
virtual ~VP1VertexSystem()
Definition
VP1VertexSystem.cxx:34
VP1VertexSystem::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition
VP1VertexSystem.cxx:48
VP1VertexSystem::m_d
Imp * m_d
Definition
VP1VertexSystem.h:40
VertexSysController
Definition
VertexSysController.h:24
Generated on
for ATLAS Offline Software by
1.17.0