ATLAS Offline Software
Loading...
Searching...
No Matches
AscObj_TrackState.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Implementation of class AscObj_TrackState //
8// //
10
12
13#include <Inventor/nodes/SoCamera.h>
14#include <Inventor/nodes/SoCylinder.h>
15#include <Inventor/nodes/SoLineSet.h>
16#include <Inventor/nodes/SoMaterial.h>
17#include <Inventor/nodes/SoPointSet.h>
18#include <Inventor/nodes/SoRotationXYZ.h>
19#include <Inventor/nodes/SoSeparator.h>
20#include <Inventor/nodes/SoSphere.h>
21#include <Inventor/nodes/SoTransform.h>
22#include <Inventor/nodes/SoTranslation.h>
23#include <Inventor/nodes/SoVertexProperty.h>
25
26#include <set>
27
28#include "Acts/Surfaces/Surface.hpp"
29#include "Acts/EventData/ParticleHypothesis.hpp"
35#include "VP1Base/VP1Msg.h"
37#include "VP1Base/VP1QtUtils.h"
47#include "VP1Utils/VP1DetInfo.h"
50
51#include "Acts/Surfaces/ConeSurface.hpp"
52#include "Acts/Surfaces/CylinderSurface.hpp"
53#include "Acts/Surfaces/DiscSurface.hpp"
54#include "Acts/Surfaces/PerigeeSurface.hpp"
55#include "Acts/Surfaces/PlaneSurface.hpp"
56#include "Acts/Surfaces/RectangleBounds.hpp"
57#include "Acts/Surfaces/StrawSurface.hpp"
58#include "Acts/Surfaces/SurfaceBounds.hpp"
61
62static double surfaceThickness = 0.1;
63
64//____________________________________________________________________
66 TrackHandleBase* track, unsigned indexOfPointOnTrack,
67 const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy& trackstate)
69 m_parts(TrackCommonFlags::TSOS_NoObjects),
70 m_indexOfPointOnTrack(indexOfPointOnTrack),
72 m_objBrowseTree(nullptr),
73 m_trackstate(trackstate)
74{
76 if (m_trackstate.hasReferenceSurface()) {
77 if (surface().isSensitive())
79 else
81 }
82
83 if (m_trackstate.typeFlags().hasParameters())
85
86 if (m_trackstate.typeFlags().hasMeasurement()){
88 if (m_trackstate.typeFlags().isOutlier())
90 else
92 }
93
94 if (m_trackstate.typeFlags().isHole())
96
97 if (m_trackstate.typeFlags().hasMaterial())
99}
100
101//____________________________________________________________________
103 // We assume this is called right after the constructor - so no need
104 // to update 3D objects.
105 m_distToNextPar = d;
106}
107
108//____________________________________________________________________
110 if (hasSurface())
111 return surface().center( common()->geometryContext().context() );
113 "AscObj_TrackState::approxCenter() WARNING: Failed to determine"
114 " position from either params or surface");
115 return Amg::Vector3D(0, 0, 0);
116}
117
118//____________________________________________________________________
121 static const double l = 30.0 * CLHEP::cm;
122 return static_cast<int>(c.z() / l) + 1000 * static_cast<int>(c.y() / l) +
123 1000000 * static_cast<int>(c.x() / l);
124}
125
126// TODO - add back getZTranslationTube
127
128//____________________________________________________________________
129void AscObj_TrackState::addTrackParamInfoToShapes(SoSeparator*& shape_simple,
130 SoSeparator*& shape_detailed,
131 bool showPars,
132 bool showParsErrors,
133 bool ) {
134 ensureInitSeps(shape_simple, shape_detailed);
135
136 SoSeparator* param_simple = new SoSeparator;
137 SoSeparator* param_detailed = new SoSeparator;
138
139 if (!m_trackstate.hasReferenceSurface()) {
140 // FIXME - do not know how to handle this yet, since I think I need the
141 // surface to get the position
143 "AscObj_TrackState::addTrackParamInfoToShapes() - no reference "
144 "surface");
145 return;
146 }
147
148 const Acts::BoundTrackParameters trackparams(
149 m_trackstate.referenceSurface().getSharedPtr(), m_trackstate.parameters(),
150 m_trackstate.covariance(), Acts::ParticleHypothesis::pion());
151 auto p1 = trackparams.position(common()->geometryContext().context());
152 if (showPars) {
153 auto u = trackparams.direction().unit();
154 double length = 15 * CLHEP::cm;
155 if (m_distToNextPar > 0)
156 length = std::min(m_distToNextPar * 0.75, length);
157 Amg::Vector3D p2 = p1 + length * u;
158 // Line:
159 SoLineSet* line = new SoLineSet();
160 SoVertexProperty* vertices = new SoVertexProperty();
161 vertices->vertex.set1Value(0, p1.x(), p1.y(), p1.z());
162 vertices->vertex.set1Value(1, p2.x(), p2.y(), p2.z());
163 line->numVertices.set1Value(0, 2);
164
165 // Point:
166 SoPointSet* points = new SoPointSet;
167 SoVertexProperty* vertices2 = new SoVertexProperty;
168 vertices2->vertex.set1Value(0, p1.x(), p1.y(), p1.z());
169 points->numPoints = 1;
170 line->vertexProperty = vertices;
171 points->vertexProperty = vertices2;
172 bool isHole = m_parts & TrackCommonFlags::TSOS_Hole;
173
174 if (trackHandle()->customColouredTSOSParts() &
176 (isHole && (trackHandle()->customColouredTSOSParts() &
178 SoMaterial* mat = isHole
181 SoSeparator* sep = new SoSeparator;
182 sep->addChild(mat);
183 sep->addChild(line);
184 sep->addChild(points);
185 param_simple->addChild(sep);
186 param_detailed->addChild(sep);
187 } else {
188 param_simple->addChild(line);
189 param_simple->addChild(points);
190 param_detailed->addChild(line);
191 param_detailed->addChild(points);
192 }
193 if (showParsErrors) {
194 // TODO
195 }
196 shape_simple->addChild(param_simple);
197 shape_detailed->addChild(param_detailed);
198 }
199}
200
201//____________________________________________________________________
202void AscObj_TrackState::addSurfaceToShapes(SoSeparator*& shape_simple,
203 SoSeparator*& shape_detailed) {
204 // VP1Msg::messageVerbose("\tAscObj_TrackState::addSurfaceToShapes() start. Type="+QString::number(surface().type())+" Bounds="+QString::number(surface().bounds().type()));
205 // Check if the TrackStateProxy has a surface
206
207 if (!m_trackstate.hasReferenceSurface())
208 return;
209
210 const Acts::Surface& surface = m_trackstate.referenceSurface();
211 if (surface.type()==Acts::Surface::SurfaceType::Straw && common()->controller()->hideTubeSurfaces())
212 return;
213
214 SoTransform* sotra = VP1LinAlgUtils::toSoTransform(surface.localToGlobalTransform(common()->geometryContext().context()));
215 shape_detailed->addChild(sotra);
216
217 //
218 // enum SurfaceType {
219 // Cone = 0,
220 // Cylinder = 1,
221 // Disc = 2,
222 // Perigee = 3,
223 // Plane = 4,
224 // Straw = 5,
225 // Curvilinear = 6,
226 // Other = 7
227 // };
228
229 // enum BoundsType : int {
230 // eCone = 0,
231 // eCylinder = 1,
232 // eDiamond = 2,
233 // eDisc = 3,
234 // eEllipse = 4,
235 // eLine = 5,
236 // eRectangle = 6,
237 // eTrapezoid = 7,
238 // eTriangle = 8,
239 // eDiscTrapezoid = 9,
240 // eConvexPolygon = 10,
241 // eAnnulus = 11,
242 // eBoundless = 12,
243 // eOther = 13
244 // };
245
246
247
248 switch (surface.type()) {
249 case Acts::Surface::SurfaceType::Plane: {
250 addPlaneSurfaceToShapes(shape_simple, shape_detailed, surface);
251 break;
252 }
253 case Acts::Surface::SurfaceType::Straw: {
254 addCylindricalSurfaceToShapes(shape_simple, shape_detailed, surface);
255 break;
256 }
257 default:
258 VP1Msg::messageVerbose("Cannot currently handle surface of type" + QString::number(surface.type()));
259 break;
260 }
261 VP1Msg::messageVerbose("AscObj_TrackState::addSurfaceToShapes() end");
262}
263
265 SoNode*& shape_detailed) {
266 if (trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_AnySurface) {
267 SoMaterial * mat = common()->controller()->customMatSurfaces();
268 if (shape_detailed->getTypeId().isDerivedFrom(SoSeparator::getClassTypeId())) {
269 // static_cast<SoSeparator*>(theSurfSepSimple)->insertChild(mat,0); TODO
270 static_cast<SoSeparator*>(shape_detailed)->insertChild(mat,0);
271 } else {
272
273 // SoSeparator * sepSimple = new SoSeparator;
274 // sepSimple->addChild(mat);
275 // sepSimple->addChild(theSurfSepSimple);
276 // nodeToAddSimple = sepSimple;
277 // TODO ^
278 SoSeparator * sep = new SoSeparator;
279 sep->addChild(mat);
280 sep->addChild(shape_detailed);
281 shape_detailed = sep;
282 }
283 }
284}
285
286void AscObj_TrackState::addPlaneSurfaceToShapes(SoSeparator*& shape_simple,
287 SoSeparator*& shape_detailed,
288 const Acts::Surface& surface) {
289
290 SoNode * nodeToAddSimple = nullptr;
291 SoNode * nodeToAddDetailed = nullptr;
292
293 // Check bounds
294 switch (surface.bounds().type()) {
295 case Acts::SurfaceBounds::BoundsType::eBoundless: {
296 const double halfX = 100.0; // FIXME - make this configurable?
297 const double halfY = 100.0;
298 SoGenericBox* box = new SoGenericBox;
299 box->setParametersForBox(halfX, halfY,
300 0.5 * surfaceThickness);
301 box->drawEdgeLines.setValue(true);
302 nodeToAddDetailed = box;
303 break;
304 }
305 case Acts::SurfaceBounds::BoundsType::eRectangle: {
306
307 const Acts::RectangleBounds& rectBounds =
308 dynamic_cast<const Acts::RectangleBounds&>(surface.bounds());
309 const double halfX = rectBounds.halfLengthX();
310 const double halfY = rectBounds.halfLengthY();
311 SoGenericBox* box = new SoGenericBox;
312 box->setParametersForBox(halfX, halfY,
313 0.5 * surfaceThickness);
314 box->drawEdgeLines.setValue(true);
315 nodeToAddDetailed = box;
316 // TODO simple
317 break;
318 }
319 default: {
320 VP1Msg::messageVerbose("Cannot currently handle surface bound of type" + QString::number(surface.bounds().type()));
321 break;
322 }
323 }
324
325 if (nodeToAddDetailed!=nullptr){
326 addMaterialToSurfaceShapes(nodeToAddSimple, nodeToAddDetailed);
327 shape_simple->addChild(nodeToAddDetailed); // FIXME
328 shape_detailed->addChild(nodeToAddDetailed);
329 }
330}
331
333 SoSeparator*& shape_detailed,
334 const Acts::Surface& surface) {
335 SoNode * nodeToAddSimple = nullptr;
336 SoNode * nodeToAddDetailed = nullptr;
337 // Check bounds
338 switch (surface.bounds().type()) {
339 case Acts::SurfaceBounds::BoundsType::eLine: {
340 const Acts::LineBounds& lineBounds =
341 dynamic_cast<const Acts::LineBounds&>(surface.bounds());
342 double hlength = lineBounds.get(Acts::LineBounds::eHalfLengthZ);
343
344 SoVertexProperty * scatVtxProperty = new SoVertexProperty();
345 scatVtxProperty->vertex.set1Value(0, 0.0,0.0,-hlength);
346 scatVtxProperty->vertex.set1Value(1, 0.0,0.0, hlength);
347 SoLineSet * lineSurface = new SoLineSet();
348 lineSurface->numVertices = 2;
349 lineSurface->vertexProperty = scatVtxProperty;
350
351 nodeToAddSimple = lineSurface;
352
353 double radius = lineBounds.get(Acts::LineBounds::eR);
354
355 SoTubs* lineSurfaceDetailed = new SoTubs();
356 (*lineSurfaceDetailed).pRMin = 0.;
357 (*lineSurfaceDetailed).pRMax = radius;
358 (*lineSurfaceDetailed).pDz = hlength;
359
360 nodeToAddDetailed = lineSurfaceDetailed;
361 break;
362 }
363 default: {
364 VP1Msg::messageVerbose("AscObj_TrackState::addCylindricalSurfaceToShapes(): Unsupported bounds type.");
365 break;
366 }
367 }
368 if (nodeToAddDetailed!=nullptr){
369 addMaterialToSurfaceShapes(nodeToAddSimple, nodeToAddDetailed);
370 shape_simple->addChild(nodeToAddDetailed);
371 shape_detailed->addChild(nodeToAddDetailed);
372 }
373}
374
375//____________________________________________________________________
377 SoSeparator*& , SoSeparator*& ) {}
378
379void AscObj_TrackState::addMeasurementToShapes(SoSeparator*& shape_simple,
380 SoSeparator*& shape_detailed) {
381
382 auto flag = m_trackstate.typeFlags();
383
384 // Check if the TrackStateProxy has a measurement
385 if (!m_trackstate.hasReferenceSurface() ||
386 !flag.hasMeasurement() ||
387 !m_trackstate.hasUncalibratedSourceLink())
388 return;
389
390 ensureInitSeps(shape_simple, shape_detailed);
391 TrackCommonFlags::TSOSPartsFlags f(trackHandle()->shownTSOSParts() & m_parts);
392 const bool showMeas(f & TrackCommonFlags::TSOS_AnyMeasurement);
393 // const bool showMeasErrors(f & TrackCommonFlags::TSOS_MeasError);
394 if (showMeas) {
395 if (m_parts & trackHandle()->customColouredTSOSParts() &
397 SoMaterial* mat;
398 if (m_parts & trackHandle()->customColouredTSOSParts() &
401 else
403 shape_simple->addChild(mat);
404 shape_detailed->addChild(mat);
405 }
406
407 // Handle measurements
408 auto sl = ActsTrk::detail::xAODUncalibMeasCalibrator::unpack(m_trackstate.getUncalibratedSourceLink());
409 assert(sl != nullptr);
410 const xAOD::UncalibratedMeasurement& uncalibMeas = *sl;
411
412 const xAOD::UncalibMeasType measurementType = uncalibMeas.type();
413
414 switch (measurementType) {
416 // Drift tubes
417 break;
418 }
425 // TODO
426 break;
427 }
429 // TODO
430 break;
431 }
433 default: {
435 "AscObj_TrackState::addMeasurementToShapes: Unable to handle this "
436 "measurement type ");
437 break;
438 }
439 }
440 }
441}
442
443//____________________________________________________________________
444void AscObj_TrackState::ensureInitSeps(SoSeparator*& shape_simple,
445 SoSeparator*& shape_detailed) {
446 if (!shape_simple)
447 shape_simple = new SoSeparator;
448 if (!shape_detailed)
449 shape_detailed = new SoSeparator;
450}
451
452//____________________________________________________________________
453void AscObj_TrackState::buildShapes(SoSeparator*& shape_simple,
454 SoSeparator*& shape_detailed) {
455 VP1Msg::messageVerbose("AscObj_TrackState::buildShapes() start");
456
457 TrackCommonFlags::TSOSPartsFlags f(trackHandle()->shownTSOSParts()&m_parts);
459 VP1Msg::messageVerbose("AscObj_TrackState::buildShapes() - no objects to show with shownTSOSParts="+QString::number(trackHandle()->shownTSOSParts())+" and m_parts="+QString::number(m_parts));
460 return;
461 }
462 // TODO Implement the following
463 const bool showPars(f & TrackCommonFlags::TSOS_TrackPars);
464 // const bool showParsErrors(f & TrackCommonFlags::TSOS_AnyParsErrors);
465 // const bool showMeas(f & TrackCommonFlags::TSOS_AnyMeasRioOnTrack);
466 // const bool showCompetingRioOnTrack(f & TrackCommonFlags::TSOS_AnyMeasCompetingRioOnTrack);
467 const bool showSurfaces(f & TrackCommonFlags::TSOS_AnySurface);
468 // const bool showMaterialEffects(f & TrackCommonFlags::TSOS_AnyMaterialEffects);
469 // const bool showMeasErrors(f & TrackCommonFlags::TSOS_MeasError);
470 ensureInitSeps(shape_simple,shape_detailed);
471
472 if (showPars)
473 addTrackParamInfoToShapes( shape_simple, shape_detailed, showPars, false, false);
474
475 if (showSurfaces)
476 addSurfaceToShapes( shape_simple, shape_detailed);
477
478 // addMeasurementToShapes is crashing at the moment. Need to investigate
479 // if (showMeas)
480 // addMeasurementToShapes( shape_simple, shape_detailed);
481
482 VP1Msg::messageVerbose("AscObj_TrackState::buildShapes() end");
483
484}
485
486//____________________________________________________________________
488 QStringList l;
489 return l;
490}
491
495
497 VP1Msg::messageVerbose("AscObj_TrackState::zoomView()");
498 if ( common()->controller()->orientAndZoomOnSingleSelection() )
499 {
500 // Zoom without orientation
501 // TODO - add orientation?
502 VP1Msg::messageVerbose("AscObj_TrackState::zoomView() Zoom without orientation");
503 std::set<SoCamera*> cameras = common()->system()->getCameraList();
504 std::set<SoCamera*>::iterator it,itE = cameras.end();
505 for (it=cameras.begin();it!=itE;++it) {
506 if (common()->controller()->assocObjDetailLevel()==TrackCommonFlags::SIMPLE)
507 {
508 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeSimple(),2.0,1.0);
509 } else
510 {
511 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeDetailed(),2.0,1.0);
512 }
513 }
514 } else {
515 VP1Msg::messageVerbose("AscObj_TrackState::zoomView() - zooming on selection not turned on.");
516 }
517}
518
static double surfaceThickness
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
double length(const pvec &v)
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
void addPlaneSurfaceToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed, const Acts::Surface &surface)
const ActsTrk::TrackStateBackend::ConstTrackStateProxy m_trackstate
void addCylindricalSurfaceToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed, const Acts::Surface &surface)
virtual void setVisible(bool)
static void ensureInitSeps(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void zoomView()
Depending on the controller settings, will attempt to zoom the view to this TSOS, for example in clic...
const Acts::Surface & surface() const
void setDistToNextPar(const double &)
QTreeWidgetItem * m_objBrowseTree
void buildShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void addSurfaceToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
Amg::Vector3D approxCenter() const
void addTrackParamInfoToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed, bool showPars, bool showParsErrors, bool showSurfaces)
void addMaterialEffectsToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void addMaterialToSurfaceShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
void addMeasurementToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
AscObj_TrackState(TrackHandleBase *, unsigned indexOfPointOnTrack, const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy &state)
TrackCommonFlags::TSOSPartsFlags m_parts
TrackSysCommonData * common() const
TrackHandleBase * trackHandle() const
CamList getCameraList()
void setParametersForBox(float dx, float dy, float dz, float xcenter=0.0, float ycenter=0.0, float zcenter=0.0)
SoSFBool drawEdgeLines
static void initClass()
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition SoTubs.h:52
@ TSOS_MeasRioOnTrackOutlier
bit 6
@ TSOS_MeasRioOnTrackNotOutlier
bit 4
VP1TrackSystem * system() const
TrackSystemController * controller() const
SoMaterial * customMatParameters() const
SoMaterial * customMatHoleParameters() const
SoMaterial * customMatMeasurementsOutliers() const
SoMaterial * customMatSurfaces() const
SoMaterial * customMatMeasurements() const
static VP1CameraHelper * animatedZoomToSubTree(SoCamera *camera, SoGroup *sceneroot, SoNode *subtreeroot, double duration_in_secs=1.0, double clipVolPercent=100.0, double lastClipVolPercent=100.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999), bool varySpeed=true, bool forceCircular=false)
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
Eigen::Matrix< double, 3, 1 > Vector3D
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
UncalibMeasType
Define the type of the uncalibrated measurement.