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"
19
22#include "VP1Base/VP1Msg.h"
24#include "VP1Base/VP1QtUtils.h"
25
27
28#include <Inventor/C/errors/debugerror.h>
29#include <Inventor/nodes/SoLineSet.h>
30#include <Inventor/nodes/SoVertexProperty.h>
31#include <Inventor/nodes/SoSeparator.h>
32#include <Inventor/nodes/SoMaterial.h>
33#include <Inventor/nodes/SoPickStyle.h>
34#include <Inventor/nodes/SoSphere.h>
35#include <Inventor/nodes/SoMatrixTransform.h>
36#include <Inventor/SbRotation.h>
37#include <Inventor/SbMatrix.h>
38#include <Inventor/nodes/SoTranslation.h>
39#include <Inventor/nodes/SoText2.h>
40
43
44#include <cassert>
45
46//____________________________________________________________________
48public:
49 static double dist(const SbVec3f& p1,const SbVec3f& p2);
50
51 static std::atomic<int> nvtxhandles;
52
53 Imp(VertexHandle*tc, const xAOD::Vertex* vtx) : theclass(tc), vertex(vtx), collHandle(nullptr),sep(nullptr), sphere(nullptr){}
54 ~Imp() { }
58
59 SoSeparator * sep; // everything hangs from this.
60 SoSphere * sphere;//This represents the cone representing the jet.
61};
62
63
64//____________________________________________________________________
65std::atomic<int> VertexHandle::Imp::nvtxhandles = 0;
66
67//____________________________________________________________________
69 : AODHandleBase(ch), m_d(new Imp(this,vertex))
70{
71 m_d->collHandle=ch;
73}
74
75//____________________________________________________________________
81
82//____________________________________________________________________
87
88
89//____________________________________________________________________
91{
92 return 0!=m_d->sep;
93}
94
95//____________________________________________________________________
97 // VP1Msg::messageVerbose("VertexHandle::clear3DObjects()");
98
99 if (m_d->sphere) {
100 m_d->sphere->unref();
101 m_d->sphere = 0;
102 }
103 if (m_d->sep) {
104 m_d->sep->unref();
105 m_d->sep = 0;
106 }
107
108}
109
110//____________________________________________________________________
112
113 VP1Msg::messageVerbose("VertexHandle::nodes()");
114
115 if (m_d->sep) {
116 VP1Msg::messageVerbose("d->sep already defined (" + VP1Msg::str(m_d->sep) + "). Returning d->sep.");
117 return m_d->sep; // FIXME - do we need to check if anything need to be redrawn?
118 }
119 if (!m_d->sep) {
120 VP1Msg::messageVerbose("d->sep not defined. Creating shapes and a new d->sep.");
121 m_d->sep = new SoSeparator();
122 m_d->sep->ref();
123 }
124
125 // SbVec3f origin(0.,0.,0.);
126 /* TODO: ask if origin info is present in xAOD, like in the old Jet class
127 if ( m_d->m_jet->origin() ) {
128 origin.setValue(m_d->m_jet->origin()->position().x(),
129 m_d->m_jet->origin()->position().y(),
130 m_d->m_jet->origin()->position().z());
131 }
132 */
133
134 VP1Msg::messageVerbose("creating the shapes");
135
136 SoTranslation * translation = new SoTranslation;
137 translation->translation.setValue ( m_d->vertex->x(), m_d->vertex->y(), m_d->vertex->z() );
138 m_d->sep->addChild ( translation );
139 m_d->sphere = new SoSphere;
140 m_d->sphere->radius = m_d->collHandle->collSettingsButton().vertexSize();
141 m_d->sep->addChild ( m_d->sphere );
142
143 return m_d->sep;
144}
145
146//____________________________________________________________________
148 // By default we use the collection material.
149 // std::cout<<"VertexHandle::determineMaterial() - collHandle()->material()"<<collHandle()->material()<<std::endl;
150 return collHandle()->material();
151}
152
153//____________________________________________________________________
154QStringList VertexHandle::baseInfo() const
155{
156 QStringList l;
157 l << shortInfo() ;
158 // vertex position
159 l << "Vx: " << VP1Msg::str(m_d->vertex->x()) << "Vy: " << VP1Msg::str(m_d->vertex->y()) << "Vz: " << VP1Msg::str(m_d->vertex->z());
160 return l;
161}
162
163//____________________________________________________________________
165 using namespace xAOD;
166
167 switch (m_d->vertex->vertexType()){
169 return QString("Type: Dummy");
171 return QString("Type: Primary");
173 return QString("Type: Secondary");
175 return QString("Type: Pileup");
177 return QString("Type: Conversion");
179 return QString("Type: Kink");
181 return QString("Type: Not specified (default)");
182 default:
183 return QString("Unknown vertex type - probably VP1 needs updating!");
184 }
185}
186
187//____________________________________________________________________
189 return m_d->vertex->x();
190}
191//____________________________________________________________________
193 return m_d->vertex->y();
194}
195//____________________________________________________________________
197 return m_d->vertex->z();
198}
199
200
201//____________________________________________________________________
202QString VertexHandle::shortInfo() const {
203 QString l = vertexType();
204 return l;
205}
206
207//____________________________________________________________________
208QStringList VertexHandle::clicked() const
209{
210 QStringList l;
211 l << "--Vertex:";
213 #ifndef BUILDVP1LIGHT
214 try {
215 l<< "Has "<<VP1Msg::str(m_d->vertex->vxTrackAtVertex ().size()) <<" associated tracks.";
216 } catch ( SG::ExcBadAuxVar& ) {
217 l<<"Vertex is missing links to tracks!";
218 }
219 #endif
220 return l;
221}
222
223
224
225
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.