ATLAS Offline Software
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 
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 //____________________________________________________________________
19 public:
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 //____________________________________________________________________
35 {
36  delete m_d;
37 }
38 
39 //_____________________________________________________________________________________
41 {
42  //Save present states and then clear all event data and related gui elements.
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):
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 //_____________________________________________________________________________________
78 void VP1VertexSystem::userPickedNode(SoNode*, SoPath * pickedPath) {
79 
80  //Find in which collection an object was picked:
81  VP1StdCollection* pickedCol(0);
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);
113  serialise.save(m_d->controller->saveSettings());//Version 1+
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  }
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 }
VP1Serialise.h
VP1VertexSystem.h
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
IVP13DSystemSimple
Definition: IVP13DSystemSimple.h:24
VP1VertexSystem::Imp::controller
VertexSysController * controller
Definition: VP1VertexSystem.cxx:20
VP1VertexCollection.h
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
VP1VertexSystem::restoreFromState
void restoreFromState(QByteArray ba)
Definition: VP1VertexSystem.cxx:120
VertexSysController.h
VP1VertexSystem::updateVertexToTracks
void updateVertexToTracks(QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > &)
Definition: VP1VertexSystem.cxx:136
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1VertexSystem::tracksFromVertexChanged
void tracksFromVertexChanged(QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > &)
VP1VertexCollection::recheckAllCuts
void recheckAllCuts()
Definition: VP1VertexCollection.cxx:436
VP1VertexCollection
Definition: VP1VertexCollection.h:32
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
VP1CollectionWidget::clear
void clear(bool deleteCollections=true, bool deleteGuiElements=false)
Definition: VP1CollectionWidget.cxx:81
VP1Controller::saveSettings
QByteArray saveSettings() const
Definition: VP1Controller.cxx:405
VP1CollectionWidget::setCollections
void setCollections(QList< VP1Collection * >, bool applySavedStates=true)
Definition: VP1CollectionWidget.cxx:258
VP1CollectionWidget.h
IVP1System::state
State state() const
Definition: IVP1System.cxx:129
IVP1System::saveState
virtual QByteArray saveState()
Definition: IVP1System.cxx:294
VP1VertexSystem::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition: VP1VertexSystem.cxx:48
beamspotnt.cols
list cols
Definition: bin/beamspotnt.py:1114
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
VP1VertexSystem::userPickedNode
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Definition: VP1VertexSystem.cxx:78
VP1TruthVertexCollection::infoOnClicked
QStringList infoOnClicked(SoPath *pickedPath)
Definition: VP1TruthVertexCollection.cxx:277
VP1Controller::restoreSettings
void restoreSettings(QByteArray)
Definition: VP1Controller.cxx:387
VP1VertexCollection::infoOnClicked
QStringList infoOnClicked(SoPath *pickedPath)
Definition: VP1VertexCollection.cxx:489
VP1VertexSystem::saveState
QByteArray saveState()
Definition: VP1VertexSystem.cxx:108
IVP13DSystemSimple::ensureBuildController
void ensureBuildController()
Definition: IVP13DSystemSimple.cxx:90
VP1CollectionWidget::collections
QList< VP1Collection * > collections() const
Definition: VP1CollectionWidget.cxx:61
VP1TruthVertexCollection
Definition: VP1TruthVertexCollection.h:31
VP1TruthVertexCollection::createCollections
static QList< VP1StdCollection * > createCollections(VertexSysController *)
Definition: VP1TruthVertexCollection.cxx:43
VP1Deserialise
Definition: VP1Deserialise.h:44
python.selection.number
number
Definition: selection.py:20
VP1VertexSystem::VP1VertexSystem
VP1VertexSystem()
Definition: VP1VertexSystem.cxx:25
VertexSysController::drawOptions
SoGroup * drawOptions() const
Definition: VertexSysController.cxx:247
VertexSysController::collWidget
VP1CollectionWidget * collWidget() const
Definition: VertexSysController.cxx:253
VP1VertexSystem::Imp::tracksFromVertices
std::map< const VP1StdCollection *, QList< std::pair< const SoMaterial *, QList< const Trk::Track * > > > > tracksFromVertices
Definition: VP1VertexSystem.cxx:21
query_example.col
col
Definition: query_example.py:7
VP1VertexSystem::Imp
Definition: VP1VertexSystem.cxx:18
VP1TruthVertexCollection.h
VP1VertexSystem::systemerase
void systemerase()
Definition: VP1VertexSystem.cxx:40
VP1VertexSystem::buildController
QWidget * buildController()
Definition: VP1VertexSystem.cxx:71
VP1StdCollection
Definition: VP1StdCollection.h:31
VP1VertexSystem::m_d
Imp * m_d
Definition: VP1VertexSystem.h:39
VP1VertexCollection::createCollections
static QList< VP1StdCollection * > createCollections(VertexSysController *controller)
Definition: VP1VertexCollection.cxx:52
VertexSysController
Definition: VertexSysController.h:24
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
IVP1System::messageVerbose
void messageVerbose(const QString &) const
Definition: IVP1System.cxx:354
VP1VertexSystem::~VP1VertexSystem
virtual ~VP1VertexSystem()
Definition: VP1VertexSystem.cxx:34
IVP1System::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1System.cxx:302