ATLAS Offline Software
Loading...
Searching...
No Matches
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//____________________________________________________________________
49public:
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//____________________________________________________________________
66std::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//____________________________________________________________________
82
83//____________________________________________________________________
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;
141 m_d->sphere->radius = m_d->collHandle->collSettingsButton().vertexSize();
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//____________________________________________________________________
155QStringList 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//____________________________________________________________________
166 using namespace xAOD;
167
168 switch (m_d->vertex->vertexType()){
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//____________________________________________________________________
203QString VertexHandle::shortInfo() const {
204 QString l = vertexType();
205 return l;
206}
207
208//____________________________________________________________________
209QStringList 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
static Double_t tc
const AODCollHandleBase * collHandle() const
AODHandleBase(AODCollHandleBase *)
Exception — Attempt to retrieve nonexistent aux data item.
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
SoMaterial * material() const
static QString str(const QString &s)
Definition VP1String.h:49
const xAOD::Vertex * vertex
SoSeparator * sep
static double dist(const SbVec3f &p1, const SbVec3f &p2)
static std::atomic< int > nvtxhandles
VertexHandle * theclass
Imp(VertexHandle *tc, const xAOD::Vertex *vtx)
VertexCollHandle * collHandle
virtual SoNode * nodes()
Returns the 3Dobjects.
virtual void clear3DObjects()
Delete objects.
SoMaterial * determineMaterial()
Should be implemented by children, in order to change the material depending on the interface etc.
VertexHandle(VertexCollHandle *, const xAOD::Vertex *vertex)
QStringList baseInfo() const
double getPositionZ() const
QString vertexType() const
double getPositionX() const
virtual QStringList clicked() const
Called when user selects the node (stringlist is displayed in messagebox).
double getPositionY() const
static int numberOfInstances()
virtual bool has3DObjects()
Returns true if the 3D objects have been created.
virtual QString shortInfo() const
returns position & type information about vertex
virtual ~VertexHandle()
@ KinkVtx
Kink vertex.
@ PileUp
Pile-up vertex.
@ ConvVtx
Conversion vertex.
@ NotSpecified
Default value, no explicit type set.
@ PriVtx
Primary vertex.
@ SecVtx
Secondary vertex.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Vertex_v1 Vertex
Define the latest version of the vertex class.