ATLAS Offline Software
Loading...
Searching...
No Matches
AscObj_TSOS.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 AscObj_TSOS //
9// //
10// Author: Troels Kofoed Jacobsen //
11// Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
12// Initial version: June 2008 //
13// //
15
16//Surface from materialeffects.
17
18//Troels todo:
19// projections (not right away)
20
21//Thomas todo:
22// print truth info (get rid of truth points)
23// Notify when path changes.
24//
25// Fixme: shared objects? Or cache scene parts for faster updating??
26
34
35#include "VP1Base/VP1Msg.h"
39#include "VP1Base/VP1QtUtils.h"
43#include "VP1Utils/VP1DetInfo.h"
45
47
50
51
63
65
75
76#include <Inventor/nodes/SoLineSet.h>
77#include <Inventor/nodes/SoSeparator.h>
78#include <Inventor/nodes/SoVertexProperty.h>
79#include <Inventor/nodes/SoPointSet.h>
80#include <Inventor/nodes/SoCamera.h>
81#include <Inventor/nodes/SoCylinder.h>
82#include <Inventor/nodes/SoMaterial.h>
83#include <Inventor/nodes/SoRotationXYZ.h>
84#include <Inventor/nodes/SoTransform.h>
85#include <Inventor/nodes/SoTranslation.h>
86#include <Inventor/nodes/SoSphere.h>
87
88#include <set>
89
92
93//____________________________________________________________________
95 const Trk::TrackStateOnSurface * tsos,
96 unsigned indexOfPointOnTrack )
97 : AssociatedObjectHandleBase(track), m_tsos(tsos),
98 m_parts(TrackCommonFlags::TSOS_NoObjects),
99 m_indexOfPointOnTrack(indexOfPointOnTrack),
100 m_distToNextPar(-1),
101 m_objBrowseTree(nullptr)
102{
104
105 const Trk::Surface * surf(nullptr);
106
108
109 if (m_tsos->trackParameters()) {
111 if (dynamic_cast<const Trk::TrackParameters *>(m_tsos->trackParameters())) {
114 }
115 else {
117 }
118 }
119 surf = &(m_tsos->trackParameters()->associatedSurface());
120 }
121
122 if (measurement()) {
124 if (rioOnTrack()) {
127 else
129 } else if (competingRIOsOnTrack()) {
132 else
134 } else
135 VP1Msg::messageDebug("Warning: Ignoring measurement which is not a (competing) rio on track.");
136 if (!surf) surf = &(measurement()->associatedSurface());
137 }
138 const Trk::MaterialEffectsBase* matEff = m_tsos->materialEffectsOnTrack();
139 if (matEff) {
140 const Trk::MaterialEffectsOnTrack * meot = dynamic_cast<const Trk::MaterialEffectsOnTrack * >(matEff);
141 if (meot) {
142 if (meot->energyLoss()&&meot->energyLoss()->deltaE()!=0)
144 else
146 } else {
147 if (dynamic_cast<const Trk::EstimatedBremOnTrack * >(matEff))
148 VP1Msg::messageDebug("Warning: Ignoring EstimatedBremOnTrack.");
149 else
150 VP1Msg::messageDebug("Warning: Ignoring material effect which is not MaterialEffectsOnTrack.");
151 }
152 if (!surf)
153 surf = &(matEff->associatedSurface());
154 }
155 if (surf) {
156 if (surf->associatedDetectorElement())
158 else
160
161 }
162}
163
164//____________________________________________________________________
165void AscObj_TSOS::setDistToNextPar(const double& d)
166{
167 //We assume this is called right after the constructor - so no need
168 //to update 3D objects.
169 m_distToNextPar = d;
170}
171
172//____________________________________________________________________
174{
175 if (hasParameters())
176 return m_tsos->trackParameters()->position();
177 if (hasSurface())
178 return surface()->center();
179 VP1Msg::message("AscObj_TSOS::approxCenter() WARNING: Failed to determine"
180 " position from either params or surface");
181 return Amg::Vector3D(0,0,0);
182}
183
184//____________________________________________________________________
186{
188 static const double l=30.0*CLHEP::cm;
189 return static_cast<int>(c.z()/l)
190 +1000*static_cast<int>(c.y()/l)
191 +1000000*static_cast<int>(c.x()/l);
192}
193
194//____________________________________________________________________
196{
197 return m_tsos->measurementOnTrack();
198}
199
200//____________________________________________________________________
201SoTranslation* AscObj_TSOS::getZTranslationTube( const Trk::Surface * theSurface,
202 const double& maxTrans ) const
203{
204 const Amg::Vector3D origo = theSurface->localToGlobal(Amg::Vector2D(0,0));
205 const Amg::Vector3D unitz = theSurface->localToGlobal(Amg::Vector2D(0,1));
206
207 std::vector< Amg::Vector3D > * points = trackHandle()->hackGetPointsPropagated();//FIXME
208
209 double min = std::numeric_limits<double>::max();
210 double smin=0;
211 size_t imin=0;
212 //First we find the point in PointsPropageted closest to the line.
213 for ( size_t i = 0; i<points->size(); i++)
214 {
215 double s;
216 double dist = VP1LinAlgUtils::distPointLine2( (*points)[i], origo, unitz, s );
217 if (dist < min)
218 {
219 min = dist;
220 imin = i;
221 }
222 }
223
224 if (points->size()>1 ){
225 // FIXME - don't think we should ever really need this test. EJWM.
226
227 //Then we get the parameters on the forward and backward lines giving the points with
228 //the shortest distances.
229 //We then use the line which has the parameter closest to 0.5 which means that it
230 //is inside the part of the line between this point and the next/previous
231 double sp,tp,sm,tm;
232 if (imin+1 < points->size() && imin >= 1)
233 {
234 VP1LinAlgUtils::distLineLineParam((*points).at(imin),(*points).at(imin+1),origo,unitz,tp,sp);
235 VP1LinAlgUtils::distLineLineParam((*points).at(imin-1),(*points).at(imin),origo,unitz,tm,sm);
236 smin = std::abs(tm - 0.5) < std::abs(tp - 0.5) ? sm : sp;
237 } else if (imin+1 >= points->size() && imin >= 1 )
238 {
239 VP1LinAlgUtils::distLineLineParam((*points).at(imin-1),(*points).at(imin),origo,unitz,tm,sm);
240 smin = sm;
241 } else
242 {
243 VP1LinAlgUtils::distLineLineParam((*points).at(imin),(*points).at(imin+1),origo,unitz,tp,sp);
244 smin = sp;
245 }
246 } else {
247 // probably something is wrong!
248 VP1Msg::message("AscObj_TSOS::getZTranslationTube: <2 points returned by trackHandle!");
249 }
250
251 //Ensure that we do not get out of bounds, preserve sign of translation.
252 if (std::abs(smin) > maxTrans)
253 {
254 double sign = smin > 0 ? 1.0 : -1.0;
255 smin = sign*maxTrans;
256 }
257
258 SoTranslation * trans = new SoTranslation;
259 trans->translation.setValue(0,0,smin);
260
261 return trans;
262}
263
264double AscObj_TSOS::deviationFromMeasurement(const bool& absolute)
265{
266 double rioValue = 0;
267 double paramValue = 0;
268 double sigma = 1;
269
270 const Trk::RIO_OnTrack* rio = rioOnTrack();
271 if (!rio && competingRIOsOnTrack()!=nullptr ) {
272 // must be crot
273 rio = &(competingRIOsOnTrack()->rioOnTrack(competingRIOsOnTrack()->indexOfMaxAssignProb () ));
274 } else {
275 VP1Msg::message(" No ROT or cROT in AscObj_TSOS::deviationFromMeasurement(const bool& absolute)!");
276 return 0.0;
277 }
278 Identifier id = rio->identify();
279 const AtlasDetectorID * idhelper = VP1DetInfo::atlasIDHelper();
280 //FIXME: should we check for idhelper before?
281 const bool isTRT = idhelper && idhelper->is_indet(id) && idhelper->is_trt(id);
282 const bool isMDT = idhelper && idhelper->is_muon(id) && idhelper->is_mdt(id);
283 if ( idhelper && ( isTRT||isMDT ) )
284 {
285 //Value from the measurement
286 rioValue = std::abs(rio->localParameters().get(Trk::driftRadius));
287
288 //Value from the track
289 const Trk::TrackParameters* trackParams = m_tsos->trackParameters();
290 const Trk::TrackParameters * meas = dynamic_cast<const Trk::TrackParameters *>(trackParams);
291 const Trk::AtaStraightLine * atas = dynamic_cast<const Trk::AtaStraightLine *>(meas);
292 if (not atas) return std::nan("");
293 const Amg::Vector2D& localposMeas = atas->localPosition();
294 paramValue = std::abs(localposMeas[Trk::locR]);
295
296 if (!absolute)
297 {
298 const AmgSymMatrix(5) covmat = *(meas->covariance());
299 sigma = sqrt( covmat(0,0) );
300 }
301 }
302
303 return absolute ? std::abs( rioValue - paramValue ) : std::abs( rioValue - paramValue )/sigma;
304}
305
306void AscObj_TSOS::addDeviationFromMeasurementInfoToShapes( SoSeparator*&shape_simple, SoSeparator*&shape_detailed)
307{
308 const Trk::RIO_OnTrack* rio = rioOnTrack();
309 Identifier id = rio->identify();
310 const AtlasDetectorID * idhelper = VP1DetInfo::atlasIDHelper();
311 //FIXME: should we check for idhelper before?
312 const bool isTRT = idhelper && idhelper->is_indet(id) && idhelper->is_trt(id);
313 const bool isMDT = idhelper && idhelper->is_muon(id) && idhelper->is_mdt(id);
314 if ( idhelper && ( isTRT||isMDT ) )
315 {
316 const Trk::Surface& theSurface = rio->associatedSurface();
317 const Amg::Vector3D origo = theSurface.localToGlobal(Amg::Vector2D(0,0));
318 const Amg::Vector3D unitz = theSurface.localToGlobal(Amg::Vector2D(0,1));
319 const Amg::Vector3D& point = m_tsos->trackParameters()->position(); //FIXME: use the one from rio when it is fixed.
320 //const Amg::Vector3D& point = rio->globalPosition();
321 //this is currently returning a position on the z-axis which is wrong. Re-enable this feature
322 //when this is fixed
323
324 //Get the point 'pointMeas' on the measurement z-axis which is closest to the point 'point'
325 double s;
326 VP1LinAlgUtils::distPointLineParam( point, origo, unitz, s );
327 const Amg::Vector3D pointMeas = origo + s*(unitz - origo);
328
329 SoLineSet * line = new SoLineSet();
330 SoVertexProperty * vertices = new SoVertexProperty();
331 vertices->vertex.set1Value(0,point.x(),point.y(),point.z());
332 vertices->vertex.set1Value(1,pointMeas.x(),pointMeas.y(),pointMeas.z());
333 line->numVertices = 2;
334 line->vertexProperty = vertices;
335
336 //colour according to side() (left=red, right=green)
337 if (isTRT)
338 {
339 const InDet::TRT_DriftCircleOnTrack * dcot = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>(rio);
340 if (not dcot) return;
341 if (dcot->side()!=Trk::NONE)
342 {
343 SoSeparator * sep = new SoSeparator;
344 SoMaterial * mat = new SoMaterial;
345 if (dcot->side()==Trk::LEFT)
346 mat->diffuseColor.setValue(1,0,0);
347 else //(dcot->side()==Trk::RIGHT)
348 mat->diffuseColor.setValue(0,1,0);
349 sep->addChild(mat);
350 sep->addChild(line);
351 shape_detailed->addChild(sep);
352 return;
353 }
354 } else if (isMDT){
355 const Muon::MdtDriftCircleOnTrack * dcot = dynamic_cast<const Muon::MdtDriftCircleOnTrack *>(rio);
356 if (not dcot) return;
357 if (dcot->side()!=Trk::NONE)
358 {
359 SoSeparator * sep = new SoSeparator;
360 SoMaterial * mat = new SoMaterial;
361 if (dcot->side()==Trk::LEFT)
362 mat->diffuseColor.setValue(1,0,0);
363 else //(dcot->side()==Trk::RIGHT)
364 mat->diffuseColor.setValue(0,1,0);
365 sep->addChild(mat);
366 sep->addChild(line);
367 shape_detailed->addChild(sep);
368 return;
369 }
370 }
371
372 ensureInitSeps(shape_simple,shape_detailed);
373 shape_detailed->addChild(line);
374 }
375}
376
377//____________________________________________________________________
378void AscObj_TSOS::addTrackParamInfoToShapes( SoSeparator*&shape_simple,
379 SoSeparator*&shape_detailed,
380 bool showPars, bool showParsErrors, bool showSurfaces)
381{
382 const Trk::TrackParameters* trackParams = m_tsos->trackParameters();
383 Q_ASSERT(trackParams);
384 ensureInitSeps(shape_simple,shape_detailed);
385
386 Amg::Vector3D p1(trackParams->position());//point
387
388 if (showPars) {
389
390// Trk::GlobalMomentum u(trackParams->momentum().unit());//mom direction
391 Amg::Vector3D u(trackParams->momentum().unit());//mom direction
392
393 double length = 5*CLHEP::cm;
394 if (m_distToNextPar>0)
395 length = std::min(m_distToNextPar*0.75,length);
396 Amg::Vector3D p2 = p1+length*u;
397
398 //Line:
399 SoLineSet * line = new SoLineSet();
400 SoVertexProperty * vertices = new SoVertexProperty();
401 vertices->vertex.set1Value(0,p1.x(),p1.y(),p1.z());
402 vertices->vertex.set1Value(1,p2.x(),p2.y(),p2.z());
403 line->numVertices.set1Value(0,2);
404
405 //Point:
406 SoPointSet * points = new SoPointSet;
407 SoVertexProperty * vertices2 = new SoVertexProperty;
408 vertices2->vertex.set1Value(0,p1.x(),p1.y(),p1.z());
409 points->numPoints=1;
410 line->vertexProperty = vertices;
411 points->vertexProperty = vertices2;
412
414 if (trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_TrackPars
415 || (isHole&&(trackHandle()->customColouredTSOSParts() & TrackCommonFlags::TSOS_Hole) ) ) {
416 SoMaterial * mat = isHole?common()->controller()->customMatHoleParameters():common()->controller()->customMatParameters();
417 SoSeparator * sep = new SoSeparator;
418 sep->addChild(mat);
419 sep->addChild(line);
420 sep->addChild(points);
421 shape_simple->addChild(sep);
422 shape_detailed->addChild(sep);
423 } else {
424 shape_simple->addChild(line);
425 shape_simple->addChild(points);
426 shape_detailed->addChild(line);
427 shape_detailed->addChild(points);
428 }
429 }
430
431 if ( showParsErrors ){
432 SoTransform* theHitTransform = VP1LinAlgUtils::toSoTransform(surface()->transform()); // FIXME - remove if working in local coords
433 shape_detailed->addChild(theHitTransform);
434 // Need to cast in order to get error Matrix
435 if (trackParams->covariance()) // Only draw error if point is a measurement
436 {
437 // fixme! This is really ugly - can't be cast to a base class? MeasuredTrackParameters doesn't know LP.
438 const Trk::AtaStraightLine * atas = dynamic_cast<const Trk::AtaStraightLine *>(trackParams);
439 const Trk::Perigee * per = dynamic_cast<const Trk::Perigee *>(trackParams);
440 const Trk::AtaPlane * aap = dynamic_cast<const Trk::AtaPlane *>(trackParams);
441 const Trk::AtaDisc * aad = dynamic_cast<const Trk::AtaDisc *>(trackParams);
442 if (per||atas||aap||aad){
443 const Amg::Vector2D& localPos = atas ? atas->localPosition() : (per ? per->localPosition() : (aap ? aap->localPosition() : aad->localPosition()));
444// addErrors(*(trackParams->associatedSurface()), meas->localErrorMatrix().covariance(), localPos, p1, showSurfaces, shape_simple, shape_detailed, false, false); //FIXME - last parameter false when working in correct local coords
445 addErrors(trackParams->associatedSurface(), *trackParams->covariance(), localPos, p1, showSurfaces, shape_simple, shape_detailed, false, false); //FIXME - last parameter false when working in correct local coords
446 } else {
447 VP1Msg::messageVerbose("Not a supported parameter for errors: ");
448 // std::cout<<(*trackParams)<<std::endl;
449 }
450 }
451 }
452}
453
454void AscObj_TSOS::addErrors(const Trk::Surface& theSurface, const AmgSymMatrix(5)& tmpCovMat,
455 const Amg::Vector2D& localPos, const Amg::Vector3D& p1, bool showSurfaces, SoSeparator* shape_simple, SoSeparator* shape_detailed, bool force1D, bool applyLocalTrans )
456{
457 VP1Msg::messageVerbose("addErrors");
458 if (applyLocalTrans) VP1Msg::messageVerbose("applyLocalTrans");
459
460 //Fixme: get from collhandle:!!
461 const bool settingsDRAWCYLINDER = common()->controller()->parTubeErrorsDrawCylinders();
462 const bool settingsDRAWZERRCIRCLES = settingsDRAWCYLINDER;
463 const double settingsSIGMASCALE = common()->controller()->nStdDevForParamErrors();
464
465 SoSeparator * errSimple = new SoSeparator;
466 SoSeparator * errDetailed = new SoSeparator;
467
468 //Possibly a custom colour
469 if (trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_AnyParsErrors) {
470 // FIXME - what about meas errors?
471 SoMaterial * mat = common()->controller()->customMatParameterErrors();
472 errSimple->addChild( mat );
473 errDetailed->addChild( mat );
474 }
475 // SoTransparency * transparent = new SoTransparency;
476 // transparent->transparency.setValue(0.5);
477 // errSimple->addChild( transparent );
478 // errDetailed->addChild( transparent );
479
480 const int npoints = common()->controller()->numberOfPointsOnCircles();
481 // Check for type of associated surface
482 // const Trk::Surface * theSurface = trackParams->associatedSurface();
483 const Trk::CylinderSurface * cylSurf = dynamic_cast<const Trk::CylinderSurface *>(&theSurface);
484 const Trk::DiscSurface * disSurf = dynamic_cast<const Trk::DiscSurface *>(&theSurface);
485 const Trk::PerigeeSurface * perSurf = dynamic_cast<const Trk::PerigeeSurface *>(&theSurface);
486 const Trk::PlaneSurface * plaSurf = dynamic_cast<const Trk::PlaneSurface *>(&theSurface);
487 const Trk::StraightLineSurface * strSurf = dynamic_cast<const Trk::StraightLineSurface *>(&theSurface);
488 if ( plaSurf ) /* Plane Surface */
489 {
490 // Shift from Surface centre to correct position
491 if (applyLocalTrans) {
492 SoTranslation * theTransform = new SoTranslation;
493 std::optional<Amg::Vector2D> locPosTmp = surface()->globalToLocal(p1);
494 if (locPosTmp) {
495 theTransform->translation.setValue(locPosTmp->x(),locPosTmp->y(),0.0);
496 // std::cout<<"applyLocalTrans & Offset=("<<locPosTmp->x()<<","<<locPosTmp->y()<<std::endl;
497 errSimple->addChild(theTransform);
498 errDetailed->addChild(theTransform);
499 } else {
500 VP1Msg::message("AscObj_TSOS::addErrors - failed to get tmp position");
501 }
502 }
503
504 VP1Msg::messageVerbose("Plane surf error of size:"+QString::number(tmpCovMat.rows()));
505 if (force1D) VP1Msg::messageVerbose("Forcing 1D");
506 VP1ErrorUtils::errorAtPlaneSurface(errSimple, errDetailed, tmpCovMat, &theSurface, p1, settingsSIGMASCALE, npoints, showSurfaces, force1D, false );
507 ensureInitSeps(shape_simple,shape_detailed);
508 shape_simple->addChild( errSimple );
509 shape_detailed->addChild( errDetailed );
510 } else if ( strSurf || perSurf) {
511 /* Straight Line Surface or perigee surface*/
512 // Shift from Surface centre to correct position
513 if (applyLocalTrans){
514 SoTranslation * theTransform = getZTranslationTube(&theSurface,10000.0);
515 errSimple->addChild(theTransform);
516 errDetailed->addChild(theTransform);
517 }
518 VP1ErrorUtils::errorAtStraightLineSurface(errSimple, errDetailed, tmpCovMat, localPos, &theSurface, settingsSIGMASCALE, settingsDRAWZERRCIRCLES, settingsDRAWCYLINDER, npoints, force1D, false);
519 ensureInitSeps(shape_simple,shape_detailed);
520 shape_simple->addChild( errSimple );
521 shape_detailed->addChild( errDetailed );
522 } else if ( cylSurf ) {
523 VP1Msg::message("WARNING: Visualisation of errors on Cylinder Surface not implemented");
524 } else if ( disSurf ) {
525 VP1Msg::message("WARNING: Visualisation of errors on Disc Surface not implemented");
526 }
527 VP1Msg::messageVerbose("leaving addErrors");
528}
529
530//____________________________________________________________________
531void AscObj_TSOS::addSurfaceToShapes( SoSeparator*&shape_simple, SoSeparator*&shape_detailed)
532{
533 // static int ignoreTubes=-1;
534 // if (ignoreTubes==-1)
535 // ignoreTubes = VP1QtUtils::environmentVariableIsOn("VP1_TRKSYS_NEVERSHOWTUBESURFACES") ? 1 : 0;
536 static int ignoreECModules=-1;
537 if (ignoreECModules==-1)
538 ignoreECModules = VP1QtUtils::environmentVariableIsOn("VP1_TRKSYS_NEVERSHOW_ENDCAPMODULES") ? 1 : 0;
539
540 if (common()->controller()->hideTubeSurfaces() &&dynamic_cast<const Trk::StraightLineSurface*>(surface()))
541 return;
542
543 if (ignoreECModules) {
544 const Trk::PlaneSurface* ps = dynamic_cast<const Trk::PlaneSurface*>(surface());
545 if (ps) {
546 Amg::Vector3D z(0.0,0.0,1.0);
547 double angle_z_normal = Amg::angle(z, ps->normal());
548 double abscostheta = std::abs(cos(angle_z_normal));
549 if (abscostheta>0.707) return;
550 }
551 }
552
553 SurfaceToSoNode surfCnv;//fixme: check if need in common()
554 SoNode* theSurfSepSimple = surfCnv.translateSurface(*(surface()),true);
555 SoNode* theSurfSep = surfCnv.translateSurface(*(surface()));
556 if (theSurfSep) {
557 SoNode * nodeToAddSimple = theSurfSepSimple;
558 SoNode * nodeToAdd = theSurfSep;
559 ensureInitSeps(shape_simple,shape_detailed);
560 if (trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_AnySurface) {
561 SoMaterial * mat = common()->controller()->customMatSurfaces();
562 if (theSurfSep->getTypeId().isDerivedFrom(SoSeparator::getClassTypeId())) {
563 static_cast<SoSeparator*>(theSurfSepSimple)->insertChild(mat,0);
564 static_cast<SoSeparator*>(theSurfSep)->insertChild(mat,0);
565 } else {
566 SoSeparator * sepSimple = new SoSeparator;
567 sepSimple->addChild(mat);
568 sepSimple->addChild(theSurfSepSimple);
569 nodeToAddSimple = sepSimple;
570 SoSeparator * sep = new SoSeparator;
571 sep->addChild(mat);
572 sep->addChild(theSurfSep);
573 nodeToAdd = sep;
574 }
575 }
576// shape_simple->addChild(nodeToAdd); //todo: check this. I changed nodeToAdd to nodeToAddSimple
577 shape_simple->addChild(nodeToAddSimple);
578 shape_detailed->addChild(nodeToAdd);
579 } else {
580 VP1Msg::message("AscObj_TSOS::addSurfaceToShapes WARNING: Got null shape.");
581 }
582}
583
584//____________________________________________________________________
585void AscObj_TSOS::addMaterialEffectsToShapes( SoSeparator*&shape_simple, SoSeparator*&shape_detailed)
586{
587 const double settingsForceOnTrack = false;
588
589 ensureInitSeps(shape_simple,shape_detailed);
590 SoSeparator * matSepSimple = new SoSeparator;
591 SoSeparator * matSepDetailed = new SoSeparator;
592
593 //1) Transformation.
594
595 if (m_tsos->trackParameters()) {
596 //Put on position of track parameter
597 Amg::Vector3D p1(m_tsos->trackParameters()->position());//point
598 SoTranslation * theTransform = new SoTranslation;
599 theTransform->translation.setValue(p1.x(),p1.y(),p1.z());
600 matSepSimple->addChild(theTransform);
601 matSepDetailed->addChild(theTransform);
602 } else {
603 const Trk::Surface * surf = surface();
604 if (!surf) {
605 VP1Msg::message("AscObj_TSOS::addMaterialEffectsToShapes WARNING: Has neither surface or parameter to get position!");
606 } else {
607 if (settingsForceOnTrack) {
608 VP1Msg::message("AscObj_TSOS::addMaterialEffectsToShapes WARNING: settingsForceOnTrack not implemented");
609
610 //Take position from surface and somehow constrain it onto the line.
611 //(Fixme... same kind of treatment as in the "short tubes"... how?).
612 } else {
613 //Take center of surface if present.
614 SoTransform * theTransform = VP1LinAlgUtils::toSoTransform(surf->transform());
615 matSepSimple->addChild(theTransform);
616 matSepDetailed->addChild(theTransform);
617 }
618 }
619 }
620 //2) Possibly a custom colour
621
622 if (trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_AnyMaterialEffects) {
623 SoMaterial * mat = common()->controller()->customMatMaterialEffects();
624 matSepSimple->addChild(mat);
625 matSepDetailed->addChild(mat);
626 }
627
628 //3) The shape
629
630 SoPointSet * point = common()->singlePoint();
631 matSepSimple->addChild(point);
632
634 matSepDetailed->addChild(point);
635 } else {
636 const Trk::MaterialEffectsBase* matEff = m_tsos->materialEffectsOnTrack();
637 const Trk::MaterialEffectsOnTrack* matEffOnTrk = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(matEff);
638 if (matEffOnTrk){
639 const double absDeltaE = std::abs(matEffOnTrk->energyLoss()->deltaE());
640 const double radius(absDeltaE > 1*CLHEP::eV ? 5.0*exp(log(absDeltaE/CLHEP::MeV)/3.0) : 0);//\propto cube root
641 //TK: radius used to be: 5.0*sqrt(absDE), but we want sphere volume \propto deltaE
642 const double scale = common()->controller()->materialEffectsOnTrackScale();
643 if (scale * radius > 0.1) {
644 SoSphere * meotSphere = new SoSphere;
645 meotSphere->radius.setValue( scale * radius );
646 matSepDetailed->addChild(meotSphere);
647 } else {
648 matSepDetailed->addChild(point);
649 }
650 }
651 }
652
653 //Attach:
654 shape_simple->addChild(matSepSimple);
655 shape_detailed->addChild(matSepDetailed);
656}
657
658//____________________________________________________________________
659void AscObj_TSOS::addRIO_OnTrackInfoToShapes( SoSeparator*&shape_simple,
660 SoSeparator*&shape_detailed,
661 const Trk::RIO_OnTrack* rio, bool blockDrawingOfGP)
662{
663 // VP1Msg::messageVerbose("AscObj_TSOS::addRIO_OnTrackInfoToShapes() start");
664
665 if (!rio) { return;}
666// Identifier id = rio->identify();
667
668 ensureInitSeps(shape_simple,shape_detailed);
669
670 TrackCommonFlags::TSOSPartsFlags f(trackHandle()->shownTSOSParts()&m_parts);
671 const bool showMeas(f & TrackCommonFlags::TSOS_AnyMeasurement);
672 const bool showMeasErrors(f & TrackCommonFlags::TSOS_MeasError);
673
675 // std::cout<<">>>>>>>>>>> addRIO_OnTrackInfoToShapes: Have measurement of type: "<<static_cast<unsigned int>(type)<<" & showRioOnTrack="<<showMeas<<std::endl;
676 if (showMeas){
677 // std::pair<SoSeparator*, std::vector<SoNode*> > detailed_nodes, simple_nodes;
678 // handle colouring
679 // VP1Msg::message(m_objToType.name(*rio));
680
681 if (m_parts & trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_AnyMeasRioOnTrack) {
682 SoMaterial * mat;
685 else
687 shape_simple->addChild(mat);
688 shape_detailed->addChild(mat);
689 }
690
693 if (isStrip)
694 m_hitToSoNode.buildStripShapes(*rio,shape_simple,shape_detailed,blockDrawingOfGP); // transforms to localPos (i.e. assumes in surface frame)
695 else {
696 if (isDC) {
697 float zShift=0.0;
698 if (isShortMeasurement()){
699 SoTranslation * theTransform = getZTranslationTube(&(rio->associatedSurface ()),10000.0);
700 float x,y; // dummy
701 theTransform->translation.getValue().getValue(x,y,zShift);
702 shape_simple->addChild(theTransform);
703 shape_detailed->addChild(theTransform);
704 }
705 m_hitToSoNode.buildTubeShapes(*rio,shape_simple,shape_detailed,blockDrawingOfGP,isShortMeasurement()?common()->controller()->measurementsShorttubesScale():0.0, false);
706 if (isShortMeasurement()){
707 SoTranslation * theTransform = new SoTranslation;
708 theTransform->translation.setValue(0,0,-zShift);
709 shape_simple->addChild(theTransform);
710 shape_detailed->addChild(theTransform);
711 }
712 }
713 }
714 }
715
716//Errors
717 if (showMeasErrors){
718 const Trk::LocalParameters & locParams = rio->localParameters () ;
719// VP1Msg::message( "Trying to draw measurement errors for ROT with id="+QString::number(rio->identify().get_compact())+" locparams have dim="+QString::number(locParams.dimension())+", locellmat="+QString::number(rio->localErrorMatrix().covariance().num_row()));
720 VP1Msg::message( "Trying to draw measurement errors for ROT with id="+QString::number(rio->identify().get_compact())+" locparams have dim="+QString::number(locParams.dimension())+", locellmat="+QString::number(rio->localCovariance().rows()));
721
722 Amg::Vector2D localPos;
723 /*
724 * see:
725 * Tracking/TrkEvent/TrkEventPrimitives/trunk/TrkEventPrimitives/LocalParameters.h
726 * Tracking/TrkEvent/TrkEventPrimitives/trunk/src/LocalParameters.cxx
727 */
728 if (locParams.contains(Trk::loc1)) {
729 localPos( locParams.get(Trk::loc1), locParams.contains(Trk::loc2) ? locParams.get(Trk::loc2) : 0 );
730 } else{
731 VP1Msg::message( "WARNING: locParams.contains(Trk::loc1) is FALSE!!");
732 }
733
734 bool force1D=false;
735 if (locParams.dimension ()!=rio->localCovariance().rows()){
736 VP1Msg::message( "WARNING: ROT has inconsistent dimensions between cov matrix and local parameters. Forcing to 1D.");
737 force1D=true;
738 }
739 force1D=true; //FIXME!
740
741 // last parameter sets whether we do a local shift.
742 addErrors(rio->associatedSurface(), rio->localCovariance(), localPos, rio->globalPosition(), false,
743 shape_simple, shape_detailed, force1D, true);
744 VP1Msg::message( "Done with measurement errors");
745 }
746}
747
748//____________________________________________________________________
750 SoSeparator*&shape_detailed)
751{
752 // std::cout<<"addCompetingRIO_OnTrackInfoToShapes"<<std::endl;
754
755 ensureInitSeps(shape_simple,shape_detailed);
756
757 //Possibly a custom colour
759 SoMaterial * mat = common()->controller()->customMatMeasurements();
760 shape_simple->addChild(mat);
761 shape_detailed->addChild(mat);
762 } else if (m_parts & trackHandle()->customColouredTSOSParts()&TrackCommonFlags::TSOS_MeasCompetingRioOnTrackOutlier) {
763 SoMaterial * mat = common()->controller()->customMatMeasurementsOutliers();
764 shape_simple->addChild(mat);
765 shape_detailed->addChild(mat);
766 }
767
768 if (common()->controller()->drawMeasGlobalPositions()){
769 // std::cout<<"cROT - showing globalpositions."<<std::endl;
770
771 // if (surface()!=crio->rioOnTrack(crio->indexOfMaxAssignProb ())->associatedSurface())
772 // VP1Msg::message("AscObj_TSOS::addCompetingRIO_OnTrackInfoToShapes WARNING: cROT surface doesn't match one from surface()") ;
773//Draw cross marking global position of the rio on track
774 SoTranslation * theTransform = new SoTranslation;
775 Amg::Vector3D offset = crio->globalPosition() - crio->associatedSurface().center();
776 // std::cout<<"globalPOS=("<<crio->globalPosition().x()<<","<<crio->globalPosition().y()<<","<<crio->globalPosition().z()<<")"<<std::endl;
777 // std::cout<<"associatedSurf centre =("<<crio->associatedSurface().center().x()<<","<<crio->associatedSurface().center().y()<<","<<crio->associatedSurface().center().z()<<")"<<std::endl;
778 // std::cout<<"offset=("<<offset.x()<<","<<offset.y()<<","<<offset.z()<<")"<<std::endl;
779 // theTransform->translation.setValue( offset.x(), offset.y(), offset.z());
780
781
782 Amg::Vector3D locPos = (crio->associatedSurface().transform().rotation().inverse())*(offset);
783 theTransform->translation.setValue( locPos.x(), locPos.y(), locPos.z());
784 // std::cout<<"the GP Transform=("<<locPos.x()<<","<<locPos.y()<<","<<locPos.z()<<")"<<std::endl;
785
786 // double xoff= crio->localParameters().get(Trk::loc1);
787 // double yoff= crio->localParameters().get(Trk::loc2);
788 // double zoff= globalpos.z()-surface().center().z();
789 // theTransform->translation.setValue(xoff,yoff,0.0);
790 // SoTranslation * theTransformBack = new SoTranslation;
791 // theTransformBack->translation.setValue(-locPos.x(), -locPos.y(), -locPos.z());
792 // std::cout<<"theTransformBack="<<Amg::toString(*theTransformBack)<<std::endl;
793
794 SoSeparator * gpSep = new SoSeparator;
795
796 gpSep->addChild(theTransform);
797 gpSep->addChild(common()->nodeManager().getShapeNode_Cross(50));
798 shape_detailed->addChild(gpSep);
799 }
800
801 //Draw all contained rio on tracks
802 TrackCommonFlags::TSOSPartsFlags f(trackHandle()->shownTSOSParts()&m_parts);
803 const bool showcRioOnTrack(f & TrackCommonFlags::TSOS_AnyMeasurement);
804
805 if (showcRioOnTrack){
806
807 // FIXME - shouldn't need to use so many seps, but having problems with transformations.
808 SoSeparator * rotSepSimple = new SoSeparator;
809 SoSeparator * rotSepDetailed = new SoSeparator;
810
811 // std::cout<<"addCompetingRIO_OnTrackInfoToShapes: About to draw most probable ROT"<<std::endl;
812 unsigned int maxProb = crio->indexOfMaxAssignProb ();
813 // std::cout<<"Drawing maxProb ["<<maxProb<<"] strip "<<std::endl;
814 addRIO_OnTrackInfoToShapes(rotSepSimple,rotSepDetailed, &(crio->rioOnTrack(maxProb)), true);
815 shape_detailed->addChild(rotSepDetailed);
816 shape_simple->addChild(rotSepSimple);
817
818 // std::cout<<"addCompetingRIO_OnTrackInfoToShapes: Done drawing most probable"<<std::endl;
819
820 SoTransparency * transparent = new SoTransparency;
821 transparent->transparency.setValue(0.5);
822 shape_detailed->addChild( transparent );
823
824 const Trk::RIO_OnTrack* rot = &(crio->rioOnTrack(maxProb));
825 //if (rot==0 || rot == NULL) { VP1Msg::message("WARNING: cROT max prob ROT is NULL. Aborting."); return;}
826 if (!rot) { VP1Msg::message("WARNING: cROT has empty max prob ROT. Aborting."); return;}
827 // Now, last position drawn was that of strip pos for most probable ROT. So take this as basis.
828 if (!rot->detectorElement()) { VP1Msg::message("WARNING: most prob ROT from cROT has empty DE. Aborting."); return;}
829
830 const MuonGM::TgcReadoutElement* tgcDetEl =
831 dynamic_cast<const MuonGM::TgcReadoutElement*>(rot->detectorElement());
832 const MuonGM::RpcReadoutElement* rpcDetEl =
833 dynamic_cast<const MuonGM::RpcReadoutElement*>(rot->detectorElement());
834
835 // FIXME - could do all this a bit more elegantly with templates
836 if ( (!tgcDetEl) && (!rpcDetEl)) { VP1Msg::message("WARNING: most prob ROT from cROT has Unknown DE type. Aborting."); std::cout<<*rot<<std::endl;return;}
837
838 // Amg::Vector3D lastPos,currPos;
839 // if (tgcDetEl){
840 // lastPos = tgcDetEl->stripPos(rot->identify());
841 // } else {
842 // lastPos = rpcDetEl->stripPos(rot->identify());
843 // }
844
845 const Trk::Surface* lastSurf=&(crio->rioOnTrack(maxProb).associatedSurface());
846
847 // std::cout<<"lastSurf = ("<<*lastSurf<<") for most prob="<<rot->identify().get_compact()<<std::endl;
848 unsigned int nrio = crio->numberOfContainedROTs();
849 for (unsigned int n = 0; n < nrio; n++)
850 {
851 if (n==maxProb) continue; // already drawn.
852 // std::cout<<"Strip #"<<n<<std::endl;
853 const Trk::RIO_OnTrack* rot = &(crio->rioOnTrack(n));
854
855 // SoTranslation * theTransform = new SoTranslation;
856 if (!rot) { VP1Msg::message("WARNING: cROT has empty ROT. Skipping."); continue;}
857
858 // Now do offset from last strip pos, to new one (for strips on different layers, this will include a zoffset)
859 // const MuonGM::TgcReadoutElement* tgcDetEl =
860 // dynamic_cast<const MuonGM::TgcReadoutElement*>(rot->detectorElement());
861 // const MuonGM::RpcReadoutElement* rpcDetEl =
862 // dynamic_cast<const MuonGM::RpcReadoutElement*>(rot->detectorElement());
863 //
864 // // FIXME - could do all this a bit more elegantly with templates
865 //
866 // if ( (!tgcDetEl) && (!rpcDetEl)) { VP1Msg::message("WARNING: ROT from cROT has Unknown DE type. Skipping."); std::cout<<*rot<<std::endl; continue;}
867 //
868 // if (tgcDetEl){
869 // currPos = tgcDetEl->stripPos(rot->identify());
870 // } else {
871 // currPos = rpcDetEl->stripPos(rot->identify());
872 // }
873 // Amg::Vector3D offset = currPos - lastPos;
874 // Amg::Vector3D<double> locPos = (rot->associatedSurface().transform().inverse())*(offset);
875 // theTransform->translation.setValue( locPos.x(), locPos.y(), locPos.z());
876 // lastPos=currPos;
877 SoSeparator * rotSepSimple = new SoSeparator;
878 SoSeparator * rotSepDetailed = new SoSeparator;
879
880 if ( &(rot->associatedSurface ())!=lastSurf) {
881 // std::cout<<"New surface!"<<std::endl;
882 // Do transformation to centre of new surface, especially important if there is a zoffset.
883 // NB we're assuming that the surfaces are aligned! Might not be entirely safe, but really should be!
884 // (I hate cROTs)
885 Amg::Vector3D offset = rot->associatedSurface().center() - lastSurf->center();
886 // std::cout<<"new surf offset = "<<Amg::toString(offset)<<std::endl;
887
888 // lastSurf = &(rot->associatedSurface());
889 Amg::Vector3D locPos = (rot->associatedSurface().transform().rotation().inverse())*(offset);
890 // std::cout<<"new surf locPos = "<<Amg::toString(locPos)<<std::endl;
891
892 SoTranslation * theTransform = new SoTranslation;
893 theTransform->translation.setValue( locPos.x(), locPos.y(), locPos.z());
894 rotSepDetailed->addChild(theTransform);
895 rotSepSimple->addChild(theTransform);
896 }
897 // lastSurf = &(rot->associatedSurface());
898
899 // rotSepDetailed->addChild(theTransform);
900 // rotSepSimple->addChild(theTransform);
901
902
903 m_hitToSoNode.buildStripShapes(crio->rioOnTrack(n),rotSepSimple,rotSepDetailed,true);
904 shape_simple->addChild(rotSepSimple);
905 shape_detailed->addChild(rotSepDetailed);
906 // back to centre
907
908 // std::cout<<"Rot "<<n<<" Done"<<std::endl;
909
910 }
911 }
912}
913
914//____________________________________________________________________
915void AscObj_TSOS::ensureInitSeps( SoSeparator*&shape_simple,
916 SoSeparator*&shape_detailed)
917{
918 if (!shape_simple)
919 shape_simple = new SoSeparator;
920 if (!shape_detailed)
921 shape_detailed = new SoSeparator;
922}
923
924//____________________________________________________________________
926{
927 return dynamic_cast<const Trk::RIO_OnTrack *>(m_tsos->measurementOnTrack());
928}
929
930//____________________________________________________________________
932{
933 return dynamic_cast<const Trk::CompetingRIOsOnTrack *>(m_tsos->measurementOnTrack());
934}
935
936//____________________________________________________________________
938{
939 const Trk::Surface * surf(nullptr);
940 if (m_tsos->trackParameters())
941 surf = &(m_tsos->trackParameters()->associatedSurface());
942 if (!surf&&m_tsos->measurementOnTrack())
943 surf = &(m_tsos->measurementOnTrack()->associatedSurface());
944 if (!surf&&m_tsos->materialEffectsOnTrack())
945 surf = &(m_tsos->materialEffectsOnTrack()->associatedSurface());
946 return surf;
947}
948
949void AscObj_TSOS::addTransformToSurface(SoSeparator*& shape_simple,SoSeparator*& shape_detailed){
950 // SurfaceToSoNode surfCnv;//fixme: check if need in common()
951 // SoNode* theSurfSepSimple = surfCnv.translateSurface(*(surface()),true);
952 // SoNode* theSurfSep = surfCnv.translateSurface(*(surface()));
953 if (!surface()) {VP1Msg::message( "AscObj_TSOS::addTransformToSurface: WARNING: TSOS without Surface! Unable to get transform!");return;}
954
955 // This is all a bit complicated, and can probably be cleaned up. The point is that TGCs need to be handled specially, or we could just use
956 // surface(), I think.
957
959 if (surface()->associatedDetectorElement()) type= TrkObjToString::type(surface()->associatedDetectorElement());
960
961// const Trk::RIO_OnTrack* rio = rioOnTrack() ? rioOnTrack() : competingRIOsOnTrack() ? competingRIOsOnTrack()->rioOnTrack(competingRIOsOnTrack()->indexOfMaxAssignProb()) : 0;
962 const Trk::RIO_OnTrack* rio = rioOnTrack() ? rioOnTrack() : competingRIOsOnTrack() ? &(competingRIOsOnTrack()->rioOnTrack(competingRIOsOnTrack()->indexOfMaxAssignProb())) : nullptr;
964
965 SoTransform* theHitTransform=nullptr;
966 if (rio) {
968 // std::cout<<"Got ROT of type"<<static_cast<unsigned int>(type)<<std::endl;
969 switch (type) {
978 {
979 theHitTransform=m_hitToSoNode.createTransform(*rio, true);
980 break;
981 }
983 {
984 theHitTransform=m_hitToSoNode.createTGC_Transform(*rio, true);
985 break;
986 }
987 default:
988 {
989 VP1Msg::message( "AscObj_TSOS::addTransformToSurface: WARNING: Unknown type of ROT.");
990 // std::cout<<"ROT: "<<*rio<<std::endl;
991 }
992 }
993 } else {
994 if (hasSurface() ) theHitTransform = VP1LinAlgUtils::toSoTransform(surface()->transform());
995 }
996
997 if (!theHitTransform) {
998 VP1Msg::message( "AscObj_TSOS::addTransformToSurface: WARNING: Unable to build transform");
999 return;
1000 }
1001 shape_simple->addChild(theHitTransform);
1002 shape_detailed->addChild(theHitTransform);
1003}
1004
1005//____________________________________________________________________
1006void AscObj_TSOS::buildShapes(SoSeparator*&shape_simple,
1007 SoSeparator*&shape_detailed)
1008{
1009 VP1Msg::messageVerbose("AscObj_TSOS::buildShapes() start");
1010
1011 TrackCommonFlags::TSOSPartsFlags f(trackHandle()->shownTSOSParts()&m_parts);
1013 return;
1014 const bool showPars(f & TrackCommonFlags::TSOS_TrackPars);
1015 const bool showParsErrors(f & TrackCommonFlags::TSOS_AnyParsErrors);
1016 const bool showRioOnTrack(f & TrackCommonFlags::TSOS_AnyMeasRioOnTrack);
1017 const bool showCompetingRioOnTrack(f & TrackCommonFlags::TSOS_AnyMeasCompetingRioOnTrack);
1018 const bool showSurfaces(f & TrackCommonFlags::TSOS_AnySurface);
1019 const bool showMaterialEffects(f & TrackCommonFlags::TSOS_AnyMaterialEffects);
1020 const bool showMeasErrors(f & TrackCommonFlags::TSOS_MeasError);
1021
1022 ensureInitSeps(shape_simple,shape_detailed);
1023
1024 // FIXME - would like to simplify this and use transform returned from surface, but means internal changes below
1025 SoSeparator* param_simple= new SoSeparator;
1026 SoSeparator* param_detailed= new SoSeparator;
1027 if (showPars||showParsErrors)
1028 addTrackParamInfoToShapes(param_simple,param_detailed,showPars,showParsErrors,showSurfaces);
1029 shape_simple->addChild(param_simple);
1030 shape_detailed->addChild(param_detailed);
1031
1032 if (showMaterialEffects)
1033 addMaterialEffectsToShapes( shape_simple, shape_detailed);
1034
1035 if (showSurfaces)
1036 addSurfaceToShapes( shape_simple, shape_detailed);
1037
1038 // Transform to centre of surface. All other seps will (eventually) hang from this.
1039 // TGCs are special, in that the position returned is that of the strip, due to rotation
1040 addTransformToSurface(shape_simple,shape_detailed);
1041
1042 // Measurements are a bit different and create a sep outside addRIO_OnTrackInfoToShapes, because addRIO_OnTrackInfoToShapes is used
1043 // by addCompetingRIO_OnTrackInfoToShapes too
1044 SoSeparator* meas_simple= new SoSeparator;
1045 SoSeparator* meas_detailed= new SoSeparator;
1046 if (rioOnTrack() && (showRioOnTrack||showMeasErrors))
1047 addRIO_OnTrackInfoToShapes(meas_simple,meas_detailed,rioOnTrack(), !(common()->controller()->drawMeasGlobalPositions()));
1048 if (showCompetingRioOnTrack)
1049 addCompetingRIO_OnTrackInfoToShapes(meas_simple,meas_detailed); // FIXME - handle cROT errors too.
1050 shape_simple->addChild(meas_simple);
1051 shape_detailed->addChild(meas_detailed);
1052
1053 //Currently this doesn't do much as rio->globalPosition() returns a position
1054 //along the axis!
1062 VP1Msg::messageVerbose("AscObj_TSOS::buildShapes() end");
1063
1064}
1065
1066//____________________________________________________________________
1068{
1069 QStringList l;
1070 if (!m_tsos) {
1071 l << "ERROR: This associated object handle has a NULL TSOS pointer!!";
1072 return l;
1073 }
1074
1075
1076 l << "---"<<"Track State On Surface #"+VP1Msg::str(m_indexOfPointOnTrack)+":";
1077
1078 if (hasParameters())
1079 {
1080 l << "----> "+TrkObjToString::name(*(m_tsos->trackParameters()));
1081 QStringList list = TrkObjToString::fullInfo( *(m_tsos->trackParameters()) );
1082 for (int i = 0; i < (list.size()-1); ){
1083 l<< (list.at(i)+QString(" = ")+list.at(i+1) );
1084 i+=2;
1085 }
1086 // l << " -> Position (x,y,z) [CLHEP::mm]: "+VP1Msg::str(m_tsos->trackParameters()->position()/CLHEP::mm);
1087 // l << " -> Momentum (Px,Py,Pz) [MeV]: "+VP1Msg::str(m_tsos->trackParameters()->momentum()/MeV) + ", |P| [GeV]: "+VP1Msg::str(m_tsos->trackParameters()->momentum().mag()/GeV);
1088 // l << " -> Momentum (Pt) [GeV]: "+VP1Msg::str(m_tsos->trackParameters()->momentum().perp()/GeV);
1089 //FIXME: parameter errors
1090 }
1091
1092 bool showDeviationsFromMeasurements = true;//Fixme (and see above)
1093 if ( showDeviationsFromMeasurements
1094 && hasParameters()
1095 && (rioOnTrack() || competingRIOsOnTrack() )
1096 && dynamic_cast<const Trk::TrackParameters *>(m_tsos->trackParameters()) )
1097 {
1099 l << " -> Std deviations from measurement: " + VP1Msg::str(deviationFromMeasurement()) + " (Outlier)";
1100 else
1101 l << " -> Std deviations from measurement: " + VP1Msg::str(deviationFromMeasurement());
1102 }
1103
1104 if (m_tsos->measurementOnTrack()){
1105 l << "----> "+TrkObjToString::name(*(m_tsos->measurementOnTrack()));
1106 QStringList list = TrkObjToString::fullInfo( *(m_tsos->measurementOnTrack()) );
1107 for (int i = 0; i < (list.size()-1); ){
1108 l<< (list.at(i)+QString(" = ")+list.at(i+1) );
1109 i+=2;
1110 }
1111 }
1112
1113
1114 if (m_tsos->fitQualityOnSurface())
1115 {
1116 l << "----> "+TrkObjToString::name((m_tsos->fitQualityOnSurface()));
1117 QStringList list = TrkObjToString::fullInfo( (m_tsos->fitQualityOnSurface()) );
1118 for (int i = 0; i < (list.size()-1); ){
1119 l<< (list.at(i)+QString(" = ")+list.at(i+1) );
1120 i+=2;
1121 }
1122 }
1123
1124 if (m_tsos->materialEffectsOnTrack())
1125 {
1126 l << "----> "+TrkObjToString::name(*(m_tsos->materialEffectsOnTrack())) ;
1127 QStringList list = TrkObjToString::fullInfo( *(m_tsos->materialEffectsOnTrack()) );
1128 for (int i = 0; i < (list.size()-1); ){
1129 l<< (list.at(i)+QString(" = ")+list.at(i+1) );
1130 i+=2;
1131 }
1132 }
1133
1134 if (common()->controller()->printVerboseInfoOnSingleSelection()) {
1135 l << " ===== TrackStateOnSurface =====";
1136 std::ostringstream s2;
1137 s2 << *m_tsos;
1138 l << QString(s2.str().c_str()).split('\n');
1139
1140 if (surface()) {
1141 l << " ===== Surface =====";
1142 std::ostringstream s;
1143 s << *(surface());
1144 l << QString(s.str().c_str()).split('\n');
1145 s << "Identfier:"<<surface()->associatedDetectorElementIdentifier();
1146 }
1147 }
1148
1149 // Object browser stuff m_indexOfPointOnTrack
1150 QTreeWidgetItem* trkObjBrowseritem = trackHandle()->browserTreeItem();
1151 if (trkObjBrowseritem){
1152 QTreeWidgetItem* me = trkObjBrowseritem->child(m_indexOfPointOnTrack); // I hope!
1153 if (!me) {
1154 VP1Msg::messageVerbose("ERROR! Can't find AscObj_TSOS item in track obj browser.");
1155 } else {
1156 QTreeWidget* trkObjBrowser = trkObjBrowseritem->treeWidget();
1157 trkObjBrowser->setCurrentItem(me);
1158 trkObjBrowser->scrollToItem(me);
1159 }
1160 }
1161
1162 zoomView(); // depending on controller settings, zoom view
1163
1164 return l;
1165}
1166
1169
1170 QTreeWidgetItem* trkObjBrowseritem = trackHandle()->browserTreeItem();
1171 if (trkObjBrowseritem){
1172 QTreeWidgetItem* me = trkObjBrowseritem->child(m_indexOfPointOnTrack); // I hope!
1173 if (!me) {
1174 VP1Msg::messageVerbose("ERROR! Can't find AscObj_TSOS item in track obj browser.");
1175 } else {
1176 QFont itemFont = me->font(1);
1177
1178 if (!visible()) {
1179 // std::cout<<"Hidden"<<std::endl;
1180 me->setFlags(Qt::ItemFlags()); // not selectable, not enabled
1181 itemFont.setStrikeOut(true);
1182
1183 } else {
1184 // std::cout<<"Vis"<<std::endl;
1185 me->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); // selectable, enabled
1186 itemFont.setStrikeOut(false);
1187
1188 }
1189 }
1190 }
1191}
1192
1193
1195 bool isShortMeasurement;
1196
1197 // FIXME! Duplication with clicked()
1198 const Trk::RIO_OnTrack* rio = rioOnTrack();
1199 if (!rio && competingRIOsOnTrack()){
1200 rio = &(competingRIOsOnTrack()->rioOnTrack(competingRIOsOnTrack()->indexOfMaxAssignProb()));
1201 }
1202
1204 bool isTRT = (type==TrkObjToString::TRT);
1205 bool isMDT = (type==TrkObjToString::MDT);
1206
1207 if (rio)
1208 {
1209 const bool settingsShort = (isTRT?common()->controller()->useShortTRTMeasurements()
1210 :isMDT&&common()->controller()->useShortMDTMeasurements());
1211 const bool showRioOnTrack(trackHandle()->shownTSOSParts()&m_parts & TrackCommonFlags::TSOS_AnyMeasRioOnTrack);
1212 isShortMeasurement = (settingsShort && showRioOnTrack);
1213 } else
1214 {
1215 isShortMeasurement = false;
1216 }
1217 return isShortMeasurement;
1218}
1219
1221 VP1Msg::messageVerbose("AscObj_TSOS::zoomView()");
1222
1223 if ( common()->controller()->orientAndZoomOnSingleSelection() )
1224 {
1225 const bool showParsErrors( trackHandle()->shownTSOSParts()&m_parts & TrackCommonFlags::TSOS_AnyParsErrors);
1226
1227
1228 if (!showParsErrors && !isShortMeasurement())
1229 { // Zoom without orientation
1230 VP1Msg::messageVerbose("AscObj_TSOS::zoomView() Zoom without orientation");
1231 std::set<SoCamera*> cameras = common()->system()->getCameraList();
1232 std::set<SoCamera*>::iterator it,itE = cameras.end();
1233 for (it=cameras.begin();it!=itE;++it) {
1234 if (common()->controller()->assocObjDetailLevel()==TrackCommonFlags::SIMPLE)
1235 {
1236 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeSimple(),2.0,1.0);
1237 } else
1238 {
1239 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeDetailed(),2.0,1.0);
1240 }
1241 }
1242 } else
1243 { // Zoom and orient (this is dependant of surface type)
1244 VP1Msg::messageVerbose("AscObj_TSOS::zoomView() Zoom and orient");
1245
1246 const Trk::Surface * theSurface = surface();
1247 const Trk::PerigeeSurface * perSurf = dynamic_cast<const Trk::PerigeeSurface *>(theSurface);
1248 const Trk::PlaneSurface * plaSurf = dynamic_cast<const Trk::PlaneSurface *>(theSurface);
1249 const Trk::StraightLineSurface * strSurf = dynamic_cast<const Trk::StraightLineSurface *>(theSurface);
1250 if ( plaSurf || perSurf )
1251 {
1252// Trk::GlobalMomentum u(m_tsos->trackParameters()->momentum().unit());
1253 Amg::Vector3D u(m_tsos->trackParameters()->momentum().unit());
1254
1255 SbVec3f lookat0 = SbVec3f(-u[0],-u[1],-u[2]);
1256
1257 std::set<SoCamera*> cameras = common()->system()->getCameraList();
1258 std::set<SoCamera*>::iterator it,itE = cameras.end();
1259 for (it=cameras.begin();it!=itE;++it) {
1260 if (common()->controller()->assocObjDetailLevel()==TrackCommonFlags::SIMPLE)
1261 {
1262 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeSimple(),2.0,100.0,100.0,1.0,lookat0);
1263 } else
1264 {
1265 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeDetailed(),2.0,100.0,100.0,1.0,lookat0);
1266 }
1267 }
1268 } else if ( strSurf )
1269 {
1270 SbVec3f lookat0 = SbVec3f(0,0,1);
1271 SbVec3f lookat1;
1272
1273 SbRotation rot = VP1LinAlgUtils::toSoTransform(theSurface->transform())->rotation.getValue();
1274 rot.multVec(lookat0,lookat0);
1275
1276 std::set<SoCamera*> cameras = common()->system()->getCameraList();
1277 std::set<SoCamera*>::iterator it,itE = cameras.end();
1278 for (it=cameras.begin();it!=itE;++it) {
1279 SbRotation camrot = (*it)->orientation.getValue();
1280 SbVec3f cameraDir = SbVec3f(0,0,-1);
1281 camrot.multVec(cameraDir,cameraDir);
1282
1283 lookat1 = cameraDir.dot(lookat0) > 0 ? lookat0 : -lookat0;
1284 if (common()->controller()->assocObjDetailLevel()==TrackCommonFlags::SIMPLE)
1285 {
1286 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeSimple(),2.0,100.0,100.0,1.0,lookat1);
1287 } else
1288 {
1289 VP1CameraHelper::animatedZoomToSubTree(*it,common()->ascObjSelectionManager()->getAscObjAttachSep(),shapeDetailed(),2.0,100.0,100.0,1.0,lookat1);
1290 }
1291 }
1292 }
1293 }
1294 } else {
1295 VP1Msg::messageVerbose("AscObj_TSOS::zoomView() - zooming on selection not turned on.");
1296 }
1297}
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
#define AmgSymMatrix(dim)
double length(const pvec &v)
static Double_t sp
int sign(int a)
#define y
#define x
#define z
#define min(a, b)
Definition cfImp.cxx:40
void addDeviationFromMeasurementInfoToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void buildShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void setDistToNextPar(const double &)
double deviationFromMeasurement(const bool &absolute=false)
void zoomView()
Depending on the controller settings, will attempt to zoom the view to this TSOS, for example in clic...
QStringList clicked()
void addRIO_OnTrackInfoToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed, const Trk::RIO_OnTrack *rio, bool blockDrawingOfGP=false)
void addErrors(const Trk::Surface &theSurface, const AmgSymMatrix(5)&tmpCovMat, const Amg::Vector2D &localPos, const Amg::Vector3D &p1, bool showSurfaces, SoSeparator *shape_simple, SoSeparator *shape_detailed, bool force1D, bool applyLocalTrans)
QTreeWidgetItem * m_objBrowseTree
Definition AscObj_TSOS.h:86
double m_distToNextPar
Definition AscObj_TSOS.h:85
SoTranslation * getZTranslationTube(const Trk::Surface *, const double &maxTrans) const
int regionIndex() const
HitToSoNode m_hitToSoNode
unsigned m_indexOfPointOnTrack
Definition AscObj_TSOS.h:84
virtual void setVisible(bool)
const Trk::TrackStateOnSurface * m_tsos
Definition AscObj_TSOS.h:82
TrackCommonFlags::TSOSPartsFlags m_parts
Definition AscObj_TSOS.h:83
Amg::Vector3D approxCenter() const
const Trk::RIO_OnTrack * rioOnTrack() const
void addSurfaceToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void addCompetingRIO_OnTrackInfoToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
const Trk::MeasurementBase * measurement() const
const Trk::Surface * surface() const
const Trk::CompetingRIOsOnTrack * competingRIOsOnTrack() const
bool isShortMeasurement()
Return true if TRT/MDT & shortened mode is on, false otherwise.
void addTransformToSurface(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
AscObj_TSOS(TrackHandleBase *, const Trk::TrackStateOnSurface *, unsigned indexOfPointOnTrack)
void addMaterialEffectsToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
void addTrackParamInfoToShapes(SoSeparator *&shape_simple, SoSeparator *&shape_detailed, bool showPars, bool showParsErrors, bool showSurfaces)
static void ensureInitSeps(SoSeparator *&shape_simple, SoSeparator *&shape_detailed)
TrackSysCommonData * common() const
TrackHandleBase * trackHandle() const
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
bool is_mdt(Identifier id) const
bool is_indet(Identifier id) const
bool is_muon(Identifier id) const
bool is_trt(Identifier id) const
CamList getCameraList()
value_type get_compact() const
Get the compact id.
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
Trk::DriftCircleSide side() const
returns the side on which the drift radius is.
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Trk::DriftCircleSide side() const
Returns the side on which the drift radius is wrt to the track.
static void initClass()
SoSFFloat transparency
SoNode * translateSurface(const Trk::Surface &sf, const bool &simple=false) const
@ TSOS_MeasCompetingRioOnTrackOutlier
bit 7
@ TSOS_MeasRioOnTrackOutlier
bit 6
@ TSOS_MeasRioOnTrackNotOutlier
bit 4
@ TSOS_TrackParsErrorsNotPerigee
bit 1
@ TSOS_MeasCompetingRioOnTrackNotOutlier
bit 5
@ TSOS_TrackParsErrorsPerigee
bit 2
@ TSOS_MaterialEffectsWithNoDeltaE
bit 12
QTreeWidgetItem * browserTreeItem() const
std::vector< Amg::Vector3D > * hackGetPointsPropagated()
FIXME.
SoPointSet * singlePoint() const
VP1TrackSystem * system() const
TrackSystemController * controller() const
SoMaterial * customMatParameters() const
SoMaterial * customMatHoleParameters() const
SoMaterial * customMatMeasurementsOutliers() const
SoMaterial * customMatParameterErrors() const
SoMaterial * customMatSurfaces() const
SoMaterial * customMatMaterialEffects() const
SoMaterial * customMatMeasurements() const
static MeasurementType type(const Trk::PrepRawData *prd)
static QString name(const Trk::MeasurementBase &mb)
static QStringList fullInfo(const Trk::MeasurementBase &tp)
Returns list of key, value, key, value etc.
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Class for a CylinderSurface in the ATLAS detector.
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
double deltaE() const
returns the
class holding information about momentum reduction and an additional noise term due to significant en...
bool contains(ParamDefs par) const
The simple check for the clients whether the parameter is contained.
double get(ParamDefs par) const
Retrieve specified parameter (const version).
int dimension() const
Dimension of this localParameters() vector.
base class to integrate material effects on Trk::Track in a flexible way.
const Surface & associatedSurface() const
returns the surface to which these m.eff. are associated.
represents the full description of deflection and e-loss of a track in material.
const EnergyLoss * energyLoss() const
returns the energy loss object.
This class is the pure abstract base class for all fittable tracking measurements.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
virtual const Amg::Vector3D & globalPosition() const =0
Interface method to get the global Position.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
Amg::Vector2D localPosition() const
Access method for the local coordinates, local parameter definitions differ for each surface type.
Class describing the Line to which the Perigee refers to.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
virtual const TrkDetElementBase * detectorElement() const =0
returns the detector element, assoicated with the PRD of this class
virtual const Surface & associatedSurface() const override=0
returns the surface for the local to global transformation
Identifier identify() const
return the identifier -extends MeasurementBase
virtual const Amg::Vector3D & globalPosition() const override=0
Interface method to get the global Position.
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
Abstract Base Class for tracking surfaces.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
const Amg::Vector3D & center() const
Returns the center position of the Surface.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Hole
A hole on the track - this is defined in the following way.
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 const AtlasDetectorID * atlasIDHelper()
static void errorAtPlaneSurface(SoSeparator *errSimple, SoSeparator *errDetailed, const AmgSymMatrix(5)&tmpCovMat, const Trk::Surface *theSurface, const Amg::Vector3D &p1, const double &nStdDev=3.0, int numNodes=12, const bool &moveToSurface=false, const bool &force1D=false, const bool &addTransform=true)
static void errorAtStraightLineSurface(SoSeparator *errSimple, SoSeparator *errDetailed, const AmgSymMatrix(5)&tmpcovmat, const Amg::Vector2D &localPos, const Trk::Surface *theSurface, const double &nStdDev=3.0, const bool &drawZErrCircles=false, const bool &drawCylinder=false, int numNodes=12, const bool &force1D=false, const bool &addTransform=true)
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
static void distPointLineParam(const Amg::Vector3D &point, const Amg::Vector3D &point0, const Amg::Vector3D &point1, double &s)
static void distLineLineParam(const Amg::Vector3D &point0, const Amg::Vector3D &point1, const Amg::Vector3D &point2, const Amg::Vector3D &point3, double &s, double &t)
static double distPointLine2(const Amg::Vector3D &point, const Amg::Vector3D &point0, const Amg::Vector3D &point1, double &s)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
static bool environmentVariableIsOn(const QString &name)
static QString str(const QString &s)
Definition VP1String.h:49
double angle(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
calculates the opening angle between two vectors
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersT< TrackParametersDim, Charged, DiscSurface > AtaDisc
@ LEFT
the drift radius is negative (see Trk::AtaStraightLine)
@ NONE
it was not possible to determine the which side of the straw the track passed;
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< TrackParametersDim, Charged, StraightLineSurface > AtaStraightLine
@ driftRadius
trt, straws
Definition ParamDefs.h:53
@ locR
Definition ParamDefs.h:44
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ loc1
Definition ParamDefs.h:34
ParametersBase< TrackParametersDim, Charged > TrackParameters
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane