ATLAS Offline Software
VertexHandle.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class VertexHandle //
9 // //
10 // //
12 
13 #include "VertexHandle.h"
14 #include "VertexCollHandle.h"
20 
23 #include "VP1Base/VP1Msg.h"
25 #include "VP1Base/VP1QtUtils.h"
26 
28 
29 #include <Inventor/C/errors/debugerror.h>
30 #include <Inventor/nodes/SoLineSet.h>
31 #include <Inventor/nodes/SoVertexProperty.h>
32 #include <Inventor/nodes/SoSeparator.h>
33 #include <Inventor/nodes/SoMaterial.h>
34 #include <Inventor/nodes/SoPickStyle.h>
35 #include <Inventor/nodes/SoSphere.h>
36 #include <Inventor/nodes/SoMatrixTransform.h>
37 #include <Inventor/SbRotation.h>
38 #include <Inventor/SbMatrix.h>
39 #include <Inventor/nodes/SoTranslation.h>
40 #include <Inventor/nodes/SoText2.h>
41 
44 
45 #include <cassert>
46 
47 //____________________________________________________________________
49 public:
50  static double dist(const SbVec3f& p1,const SbVec3f& p2);
51 
52  static std::atomic<int> nvtxhandles;
53 
54  Imp(VertexHandle*tc, const xAOD::Vertex* vtx) : theclass(tc), vertex(vtx), collHandle(nullptr),sep(nullptr), sphere(nullptr){}
55  ~Imp() { }
59 
60  SoSeparator * sep; // everything hangs from this.
61  SoSphere * sphere;//This represents the cone representing the jet.
62 };
63 
64 
65 //____________________________________________________________________
66 std::atomic<int> VertexHandle::Imp::nvtxhandles = 0;
67 
68 //____________________________________________________________________
70  : AODHandleBase(ch), m_d(new Imp(this,vertex))
71 {
72  m_d->collHandle=ch;
74 }
75 
76 //____________________________________________________________________
78 {
79  delete m_d;
81 }
82 
83 //____________________________________________________________________
85 {
86  return Imp::nvtxhandles;
87 }
88 
89 
90 //____________________________________________________________________
92 {
93  return 0!=m_d->sep;
94 }
95 
96 //____________________________________________________________________
98  // VP1Msg::messageVerbose("VertexHandle::clear3DObjects()");
99 
100  if (m_d->sphere) {
101  m_d->sphere->unref();
102  m_d->sphere = 0;
103  }
104  if (m_d->sep) {
105  m_d->sep->unref();
106  m_d->sep = 0;
107  }
108 
109 }
110 
111 //____________________________________________________________________
113 
114  VP1Msg::messageVerbose("VertexHandle::nodes()");
115 
116  if (m_d->sep) {
117  VP1Msg::messageVerbose("d->sep already defined (" + VP1Msg::str(m_d->sep) + "). Returning d->sep.");
118  return m_d->sep; // FIXME - do we need to check if anything need to be redrawn?
119  }
120  if (!m_d->sep) {
121  VP1Msg::messageVerbose("d->sep not defined. Creating shapes and a new d->sep.");
122  m_d->sep = new SoSeparator();
123  m_d->sep->ref();
124  }
125 
126  // SbVec3f origin(0.,0.,0.);
127  /* TODO: ask if origin info is present in xAOD, like in the old Jet class
128  if ( m_d->m_jet->origin() ) {
129  origin.setValue(m_d->m_jet->origin()->position().x(),
130  m_d->m_jet->origin()->position().y(),
131  m_d->m_jet->origin()->position().z());
132  }
133  */
134 
135  VP1Msg::messageVerbose("creating the shapes");
136 
137  SoTranslation * translation = new SoTranslation;
138  translation->translation.setValue ( m_d->vertex->x(), m_d->vertex->y(), m_d->vertex->z() );
139  m_d->sep->addChild ( translation );
140  m_d->sphere = new SoSphere;
142  m_d->sep->addChild ( m_d->sphere );
143 
144  return m_d->sep;
145 }
146 
147 //____________________________________________________________________
149  // By default we use the collection material.
150  // std::cout<<"VertexHandle::determineMaterial() - collHandle()->material()"<<collHandle()->material()<<std::endl;
151  return collHandle()->material();
152 }
153 
154 //____________________________________________________________________
155 QStringList VertexHandle::baseInfo() const
156 {
157  QStringList l;
158  l << shortInfo() ;
159  // vertex position
160  l << "Vx: " << VP1Msg::str(m_d->vertex->x()) << "Vy: " << VP1Msg::str(m_d->vertex->y()) << "Vz: " << VP1Msg::str(m_d->vertex->z());
161  return l;
162 }
163 
164 //____________________________________________________________________
165 QString VertexHandle::vertexType() const {
166  using namespace xAOD;
167 
168  switch (m_d->vertex->vertexType()){
169  case xAOD::VxType::NoVtx:
170  return QString("Type: Dummy");
172  return QString("Type: Primary");
174  return QString("Type: Secondary");
176  return QString("Type: Pileup");
178  return QString("Type: Conversion");
180  return QString("Type: Kink");
182  return QString("Type: Not specified (default)");
183  default:
184  return QString("Unknown vertex type - probably VP1 needs updating!");
185  }
186 }
187 
188 //____________________________________________________________________
190  return m_d->vertex->x();
191 }
192 //____________________________________________________________________
194  return m_d->vertex->y();
195 }
196 //____________________________________________________________________
198  return m_d->vertex->z();
199 }
200 
201 
202 //____________________________________________________________________
203 QString VertexHandle::shortInfo() const {
204  QString l = vertexType();
205  return l;
206 }
207 
208 //____________________________________________________________________
209 QStringList VertexHandle::clicked() const
210 {
211  QStringList l;
212  l << "--Vertex:";
214  #ifndef BUILDVP1LIGHT
215  try {
216  l<< "Has "<<VP1Msg::str(m_d->vertex->vxTrackAtVertex ().size()) <<" associated tracks.";
217  } catch ( SG::ExcBadAuxVar& ) {
218  l<<"Vertex is missing links to tracks!";
219  }
220  #endif
221  return l;
222 }
223 
224 
225 
226 
xAOD::Vertex_v1::x
float x() const
Returns the x position.
VertexHandle::shortInfo
virtual QString shortInfo() const
returns position & type information about vertex
Definition: VertexHandle.cxx:203
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
AODHandleBase
Definition: AODHandleBase.h:43
VP1StdCollection::material
SoMaterial * material() const
Definition: VP1StdCollection.cxx:220
VertexCollHandle::collSettingsButton
const VertexCollectionSettingsButton & collSettingsButton() const
Definition: VertexCollHandle.cxx:190
VP1MaterialButton.h
VP1ExtraSepLayerHelper.h
VertexHandle::Imp::collHandle
VertexCollHandle * collHandle
Definition: VertexHandle.cxx:58
VP1Msg.h
VertexHandle::has3DObjects
virtual bool has3DObjects()
Returns true if the 3D objects have been created.
Definition: VertexHandle.cxx:91
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
AODSystemController.h
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
VP1QtUtils.h
VP1ParticleData.h
AODHandleBase::collHandle
const AODCollHandleBase * collHandle() const
Definition: AODHandleBase.h:55
VertexHandle::getPositionY
double getPositionY() const
Definition: VertexHandle.cxx:193
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VertexHandle.h
VertexHandle::determineMaterial
SoMaterial * determineMaterial()
Should be implemented by children, in order to change the material depending on the interface etc.
Definition: VertexHandle.cxx:148
VertexHandle::VertexHandle
VertexHandle(VertexCollHandle *, const xAOD::Vertex *vertex)
Definition: VertexHandle.cxx:69
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
xAOD::Vertex_v1::vertexType
VxType::VertexType vertexType() const
The type of the vertex.
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition: TrackingPrimitives.h:570
VertexHandle::Imp::vertex
const xAOD::Vertex * vertex
Definition: VertexHandle.cxx:57
VertexHandle::clear3DObjects
virtual void clear3DObjects()
Delete objects.
Definition: VertexHandle.cxx:97
VertexHandle::Imp::Imp
Imp(VertexHandle *tc, const xAOD::Vertex *vtx)
Definition: VertexHandle.cxx:54
VP1LinAlgUtils.h
GeoPrimitives.h
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
VertexHandle::Imp::theclass
VertexHandle * theclass
Definition: VertexHandle.cxx:56
SG::ExcBadAuxVar
Exception — Attempt to retrieve nonexistent aux data item.
Definition: Control/AthContainers/AthContainers/exceptions.h:59
AmgStringHelpers.h
VertexCollHandle.h
xAOD::VxType::SecVtx
@ SecVtx
Secondary vertex.
Definition: TrackingPrimitives.h:572
VertexHandle::Imp
Definition: VertexHandle.cxx:48
VertexHandle::clicked
virtual QStringList clicked() const
Called when user selects the node (stringlist is displayed in messagebox).
Definition: VertexHandle.cxx:209
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
VP1AODSystem.h
xAOD::VxType::KinkVtx
@ KinkVtx
Kink vertex.
Definition: TrackingPrimitives.h:576
xAOD::Vertex_v1::z
float z() const
Returns the z position.
VertexHandle::baseInfo
QStringList baseInfo() const
Definition: VertexHandle.cxx:155
VertexHandle::nodes
virtual SoNode * nodes()
Returns the 3Dobjects.
Definition: VertexHandle.cxx:112
xAOD::VxType::PileUp
@ PileUp
Pile-up vertex.
Definition: TrackingPrimitives.h:573
VertexCollHandle
Definition: VertexCollHandle.h:42
VertexHandle::Imp::dist
static double dist(const SbVec3f &p1, const SbVec3f &p2)
VertexHandle::getPositionZ
double getPositionZ() const
Definition: VertexHandle.cxx:197
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
VertexHandle::Imp::nvtxhandles
static std::atomic< int > nvtxhandles
Definition: VertexHandle.cxx:52
VertexCollectionSettingsButton.h
VertexHandle
Definition: VertexHandle.h:39
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
VertexHandle::Imp::sphere
SoSphere * sphere
Definition: VertexHandle.cxx:61
VertexHandle::getPositionX
double getPositionX() const
Definition: VertexHandle.cxx:189
VertexHandle::vertexType
QString vertexType() const
Definition: VertexHandle.cxx:165
VertexHandle::numberOfInstances
static int numberOfInstances()
Definition: VertexHandle.cxx:84
xAOD::Vertex_v1::y
float y() const
Returns the y position.
VertexHandle::Imp::sep
SoSeparator * sep
Definition: VertexHandle.cxx:60
VP1JobConfigInfo.h
xAOD::VxType::ConvVtx
@ ConvVtx
Conversion vertex.
Definition: TrackingPrimitives.h:574
SurfaceToSoNode.h
xAOD::Vertex_v1::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
Definition: Vertex_v1.cxx:181
VertexHandle::m_d
Imp * m_d
Definition: VertexHandle.h:82
VertexHandle::Imp::~Imp
~Imp()
Definition: VertexHandle.cxx:55
xAOD::VxType::NotSpecified
@ NotSpecified
Default value, no explicit type set.
Definition: TrackingPrimitives.h:577
VertexCollectionSettingsButton::vertexSize
int vertexSize() const
Definition: VertexCollectionSettingsButton.cxx:240
VertexHandle::~VertexHandle
virtual ~VertexHandle()
Definition: VertexHandle.cxx:77