ATLAS Offline Software
Loading...
Searching...
No Matches
VP1VertexCollection::Imp::VertexHandle Class Reference
Collaboration diagram for VP1VertexCollection::Imp::VertexHandle:

Public Member Functions

 VertexHandle (const Trk::VxCandidate *v, VP1VertexCollection *collHandle)
 ~VertexHandle ()
VP1VertexCollectioncollHandle ()
void updateShapes (VertexSysController *controller)
SoMaterial * determineMaterial ()
void ensureAttached (SoSeparator *collSep, VertexSysController *controller)
void ensureDetached (SoSeparator *collSep)
const Trk::VxCandidatevertex () const
SoSeparator * sep () const
bool attached () const
VertexCommonFlags::ReconVertexTypeFlag type ()
void rerandomiseRandomMaterial ()

Private Member Functions

void actualBuildShape (VertexSysController *controller)

Private Attributes

VP1VertexCollectionm_collHandle
bool m_attached
const Trk::VxCandidatem_vertex
SoSeparator * m_sep
SoMaterial * m_randommaterial

Detailed Description

Definition at line 75 of file VP1VertexCollection.cxx.

Constructor & Destructor Documentation

◆ VertexHandle()

VP1VertexCollection::Imp::VertexHandle::VertexHandle ( const Trk::VxCandidate * v,
VP1VertexCollection * collHandle )
inline

◆ ~VertexHandle()

VP1VertexCollection::Imp::VertexHandle::~VertexHandle ( )
inline

Definition at line 78 of file VP1VertexCollection.cxx.

78{ if (m_sep) m_sep->unref(); }

Member Function Documentation

◆ actualBuildShape()

void VP1VertexCollection::Imp::VertexHandle::actualBuildShape ( VertexSysController * controller)
inlineprivate

Definition at line 198 of file VP1VertexCollection.cxx.

198 {
199 Amg::Vector3D pos = m_vertex->recVertex().position();
201 if (r==0) {
202 SoPointSet * points = new SoPointSet;
203 SoVertexProperty * vertices = new SoVertexProperty;
204 vertices->vertex.set1Value(0,pos.x(), pos.y(), pos.z());
205 points->numPoints=1;
206 points->vertexProperty.setValue(vertices);
207 m_sep->addChild(points);
208 return;
209 }
210
211 SoTranslation * translation = new SoTranslation;
212 translation->translation.setValue ( pos.x(), pos.y(), pos.z() );
213 m_sep->addChild ( translation );
214
215 if (r>0) {
216 //Transform sphere into an ellipsoid using the error matrix:
217// const Trk::CovarianceMatrix& errMat = m_vertex->recVertex().errorPosition().covariance();
218 const AmgSymMatrix(3)& errMat = m_vertex->recVertex().covariancePosition(); // see https://svnweb.cern.ch/trac/atlasoff/browser/Tracking/TrkEvent/VxVertex/trunk/VxVertex/RecVertex.h
219
220 //FIXME: std::min hack for now!!
221 double a(errMat(0,0)), b(errMat(0,1)), c(errMat(0,2)),
222 d(errMat(1,1)), e(errMat(1,2)),
223 f(errMat(2,2));
224 double det = a*(d*f-e*e) + 2*b*c*e - d*c*c-f*b*b;
225 if (det>0) {
226 double sixthrootofdet = exp(log(det)/6.0);
227 double invdet = 1.0/sixthrootofdet;
228 a *= invdet;
229 b *= invdet;
230 c *= invdet;
231 d *= invdet;
232 e *= invdet;
233 f *= invdet;
234 SbMatrix sbMat(a,b,c,0,
235 b,d,e,0,
236 c,e,f,0,
237 0,0,0,1);
238 SoMatrixTransform * matTrans = new SoMatrixTransform();
239 matTrans->matrix.setValue(sbMat);
240 m_sep->addChild (matTrans);
241 } else {
242 //fixme: warn
243 }
244 }
245
246 SoSphere * sphere = new SoSphere;
247 sphere->radius = fabs(r);
248 m_sep->addChild ( sphere );
249 }
#define AmgSymMatrix(dim)
static Double_t a
VertexSysController * controller
QList< VertexHandle * > vertices
double reconVertexRepresentation() const
int r
Definition globals.cxx:22
Eigen::Matrix< double, 3, 1 > Vector3D

◆ attached()

bool VP1VertexCollection::Imp::VertexHandle::attached ( ) const
inline

Definition at line 134 of file VP1VertexCollection.cxx.

134{ return m_attached; }

◆ collHandle()

VP1VertexCollection * VP1VertexCollection::Imp::VertexHandle::collHandle ( )
inline

Definition at line 80 of file VP1VertexCollection.cxx.

80{return m_collHandle;}

◆ determineMaterial()

SoMaterial * VP1VertexCollection::Imp::VertexHandle::determineMaterial ( )
inline

Definition at line 100 of file VP1VertexCollection.cxx.

100 {
101 switch(collHandle()->colourBy()) {
103 {
104 if (!m_randommaterial) {
105 m_randommaterial = new SoMaterial;
106 m_randommaterial->ref();
108 }
109 return m_randommaterial;
110 }
112 default:
113 return collHandle()->material();
114 }
115 }
SoMaterial * material() const
COLOURBY colourBy() const

◆ ensureAttached()

void VP1VertexCollection::Imp::VertexHandle::ensureAttached ( SoSeparator * collSep,
VertexSysController * controller )
inline

Definition at line 117 of file VP1VertexCollection.cxx.

117 {
118 if (m_attached)
119 return;
120 m_attached = true;
122 collSep->addChild(m_sep);
123 }
SoSeparator * collSep() const
All 3D objects from this coll.
void updateShapes(VertexSysController *controller)

◆ ensureDetached()

void VP1VertexCollection::Imp::VertexHandle::ensureDetached ( SoSeparator * collSep)
inline

Definition at line 124 of file VP1VertexCollection.cxx.

124 {
125 if (!m_attached)
126 return;
127 m_attached = false;
128 if (m_sep)
129 collSep->removeChild(m_sep);
130 }

◆ rerandomiseRandomMaterial()

void VP1VertexCollection::Imp::VertexHandle::rerandomiseRandomMaterial ( )
inline

Definition at line 150 of file VP1VertexCollection.cxx.

150 {
151 // std::cout<<"rerandomiseRandomMaterial"<<std::endl;
152 if ( !m_randommaterial )//We will anyway rerandomize it when we need it
153 return;
154
155 double r2 = 0.3*0.3;
156 unsigned i(0);
157 double r,g,b;
158 bool ok;
159 while (true) {
160 r = (rand() / static_cast<double>(RAND_MAX));
161 g = (rand() / static_cast<double>(RAND_MAX));
162 b = (rand() / static_cast<double>(RAND_MAX));
163 ok = true;
164 //For now we make sure that we avoid black and red. This should be updated from bgd and highlight col automatically! (fixme).
165 // -> and we should probably also make sure that tracks close in (eta,phi) are well separated in colour-space.
166 if ( (r-1.0)*(r-1.0)+g*g+b*b < r2*0.5 )//avoid red (distance)
167 ok = false;
168 else if ( r*r/(r*r+g*g+b*b) > 0.8 )//avoid red (angle)
169 ok = false;
170 else if ( r*r+g*g+b*b < r2*2.0 )//avoid black
171 ok = false;
172 if (ok)
173 break;
174 ++i;
175 if (i>50 ) {
176 r2 *= 0.99;//To avoid problem in case we add too many forbidden spheres.
177 if (i>1000) {
178 //Just a safety
179 collHandle()->systemBase()->message("TrackHandleBase::rerandomiseRandomMaterial Warning: Random colour could"
180 " not be selected such as to satisfy all separation criteria");
181 break;
182 }
183 }
184 }
185 // std::cout<<"rerandomiseRandomMaterial - setting to"<<r<<","<<g<<","<<b<<std::endl;
186
188 0.15, /*brightness*/
189 0.0 /*transparency*/);
190 }
void message(const QString &) const
IVP1System * systemBase() const
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)

◆ sep()

SoSeparator * VP1VertexCollection::Imp::VertexHandle::sep ( ) const
inline

Definition at line 133 of file VP1VertexCollection.cxx.

133{ return m_sep; }

◆ type()

VertexCommonFlags::ReconVertexTypeFlag VP1VertexCollection::Imp::VertexHandle::type ( )
inline

Definition at line 135 of file VP1VertexCollection.cxx.

135 {
136 switch(m_vertex->vertexType()) {
142 case Trk::V0Lambda:
143 case Trk::V0LambdaBar:
144 case Trk::V0KShort:
146 default:
148 }
149 }
@ V0LambdaBar
Temporary addition for V0 LambdaBar.
Definition VertexType.h:34
@ V0Vtx
Vertex from V0 Decay.
Definition VertexType.h:31
@ KinkVtx
Kink Vertex.
Definition VertexType.h:32
@ ConvVtx
Converstion Vertex.
Definition VertexType.h:30
@ PileUp
Pile Up Vertex.
Definition VertexType.h:29
@ SecVtx
Secondary Vertex.
Definition VertexType.h:28
@ PriVtx
Primary Vertex.
Definition VertexType.h:27
@ V0KShort
Temporary addition for KShort.
Definition VertexType.h:35
@ V0Lambda
Temporary addition for V0 Lambda.
Definition VertexType.h:33

◆ updateShapes()

void VP1VertexCollection::Imp::VertexHandle::updateShapes ( VertexSysController * controller)
inline

Definition at line 82 of file VP1VertexCollection.cxx.

82 {
83 if (!m_attached) {
84 if (m_sep)
85 m_sep->removeAllChildren();
86 return;
87 }
88 if (!m_sep) {
89 m_sep = new SoSeparator;
90 m_sep->ref();
91 }
92 if (m_sep->getNumChildren()>0)
93 m_sep->removeAllChildren();
94 SoMaterial* mat = determineMaterial();
95 // std::cout<<"This: "<<this<<" Got material at:"<<mat<<", m_randommaterial="<<m_randommaterial<<std::endl;
96 m_sep->addChild ( mat );
98 }
void actualBuildShape(VertexSysController *controller)

◆ vertex()

const Trk::VxCandidate * VP1VertexCollection::Imp::VertexHandle::vertex ( ) const
inline

Definition at line 132 of file VP1VertexCollection.cxx.

132{ return m_vertex; }

Member Data Documentation

◆ m_attached

bool VP1VertexCollection::Imp::VertexHandle::m_attached
private

Definition at line 194 of file VP1VertexCollection.cxx.

◆ m_collHandle

VP1VertexCollection* VP1VertexCollection::Imp::VertexHandle::m_collHandle
private

Definition at line 193 of file VP1VertexCollection.cxx.

◆ m_randommaterial

SoMaterial* VP1VertexCollection::Imp::VertexHandle::m_randommaterial
private

Definition at line 197 of file VP1VertexCollection.cxx.

◆ m_sep

SoSeparator* VP1VertexCollection::Imp::VertexHandle::m_sep
private

Definition at line 196 of file VP1VertexCollection.cxx.

◆ m_vertex

const Trk::VxCandidate* VP1VertexCollection::Imp::VertexHandle::m_vertex
private

Definition at line 195 of file VP1VertexCollection.cxx.


The documentation for this class was generated from the following file: