Belle II Software  release-05-02-19
EVEVisualization Class Reference

Produces visualisation for MCParticles, simhits, genfit::Tracks, geometry and other things. More...

#include <EVEVisualization.h>

Collaboration diagram for EVEVisualization:

Classes

struct  ElementGroup
 Group of TEveElements, remembers wether user wants it visible or not. More...
 
struct  MCTrack
 Hold MC tracks and associated visualisation objects. More...
 

Public Member Functions

 EVEVisualization ()
 Constructor.
 
 EVEVisualization (const EVEVisualization &)=delete
 disabled.
 
EVEVisualizationoperator= (const EVEVisualization &)=delete
 disabled assignment
 
 ~EVEVisualization ()
 Destructor.
 
void addTrack (const Belle2::Track *belle2Track)
 Add this genfit::Track to event data. More...
 
void addTrackCandidate (const std::string &collectionName, const RecoTrack &recoTrack)
 Add a RecoTrack, to evaluate track finding.
 
void addTrackCandidateImproved (const std::string &collectionName, const RecoTrack &recoTrack)
 Add a RecoTrack, but use stored genfit track representation to make visualisation objects. More...
 
void addCDCTriggerTrack (const std::string &collectionName, const CDCTriggerTrack &track)
 Add a CDCTriggerTrack.
 
template<class T >
void addSimHits (const StoreArray< T > &hits)
 Add all entries in the given 'hits' array (and the corresponding MCParticles) to the event scene.
 
void addSimHit (const CDCSimHit *hit, const MCParticle *particle)
 Add a CDCSimHit.
 
void addSimHit (const PXDSimHit *hit, const MCParticle *particle)
 Add a PXDSimHit.
 
void addSimHit (const SVDSimHit *hit, const MCParticle *particle)
 Add a SVDSimHit.
 
void addSimHit (const BKLMSimHit *hit, const MCParticle *particle)
 Add a BKLMSimHit.
 
void addSimHit (const EKLMSimHit *hit, const MCParticle *particle)
 Add a EKLMSimHit.
 
void addSimHit (const TVector3 &v, const MCParticle *particle)
 Add simhit as a simple point.
 
MCTrackaddMCParticle (const MCParticle *particle)
 Return MCTrack for given particle, add it if it doesn't exist yet. More...
 
void addVertex (const genfit::GFRaveVertex *vertex)
 Add a vertex point and its covariance matrix.
 
void addECLCluster (const ECLCluster *cluster)
 Add a reconstructed cluster in the ECL.
 
void addKLMCluster (const KLMCluster *cluster)
 Add a reconstructed cluster in the KLM.
 
void addBKLMHit2d (const BKLMHit2d *bklm2dhit)
 Add a reconstructed 2d hit in the BKLM.
 
void addEKLMHit2d (const EKLMHit2d *bklm2dhit)
 Add a reconstructed 2d hit in the EKLM.
 
void addARICHHit (const ARICHHit *hit)
 Add recontructed hit in ARICH.
 
void addROI (const ROIid *roi)
 Add a Region Of Interest, computed by the PXDDataReduction module.
 
template<class T >
void addUnassignedRecoHits (const StoreArray< T > &hits)
 After adding recohits for tracks/candidates, this function adds the remaining hits in a global collection.
 
void addCDCHit (const CDCHit *hit, bool showTriggerHits=false)
 show CDCHits directly.
 
void addCDCTriggerSegmentHit (const std::string &collectionName, const CDCTriggerSegmentHit *hit)
 show outline of track segments.
 
void addTOPDigits (const StoreArray< TOPDigit > &digits)
 Add TOPDigits (shown aggregated per module). More...
 
void addObject (const TObject *dataStoreObject, TEveElement *visualRepresentation)
 Generic function to keep track of which objects have which visual representation. More...
 
void showUserData (const DisplayData &displayData)
 Add user-defined data (labels, points, etc.)
 
void makeTracks ()
 Create visual representation of all tracks. More...
 
void clearEvent ()
 clear event data.
 
void setOptions (const std::string &opts)
 Set the display options. More...
 
void setErrScale (double errScale=1.)
 Set the scaling factor for the visualization of track hit errors. More...
 
void setAssignToPrimaries (bool on)
 If true, hits created by secondary particles (e.g. More...
 
void setHideSecondaries (bool on)
 If true, secondary MCParticles (and hits created by them) will not be shown.
 

Private Types

enum  eFitterType {
  SimpleKalman,
  RefKalman,
  DafSimple,
  DafRef,
  Gbl
}
 Fitter type to be used for addTrack().
 

Private Member Functions

TEveBox * boxCreator (const TVector3 &o, TVector3 u, TVector3 v, float ud, float vd, float depth)
 Create a box around o, oriented along u and v with widths ud, vd and depth and return a pointer to the box object.
 
void makeLines (TEveTrack *eveTrack, const genfit::StateOnPlane *prevState, const genfit::StateOnPlane *state, const genfit::AbsTrackRep *rep, TEvePathMark::EType_e markType, bool drawErrors, int markerPos=1)
 Create hit visualisation for the given options, and add them to 'eveTrack'.
 
template<class SomeVXDHit >
void addRecoHit (const SomeVXDHit *hit, TEveStraightLineSet *lines)
 adds given VXD hit to lines.
 
void addRecoHit (const SVDCluster *hit, TEveStraightLineSet *lines)
 specialisation for SVDCluster
 
void addRecoHit (const CDCHit *hit, TEveStraightLineSet *lines)
 specialisation for CDCHit.
 
void addToGroup (const std::string &name, TEveElement *elem)
 Add 'elem' to the element group 'name' (created if necessary). More...
 

Private Attributes

TEveCalo3D * m_calo3d
 Object for the energy bar visualisation.
 
double m_errorScale
 Rescale PXD/SVD errors with this factor to ensure visibility.
 
std::string m_options
 Option string for genfit::Track visualisation. More...
 
bool m_assignToPrimaries
 If true, hits created by secondary particles (e.g. More...
 
bool m_hideSecondaries {false}
 If true, secondary MCParticles (and hits created by them) will not be shown.
 
std::map< const MCParticle *, MCTrackm_mcparticleTracks
 map MCParticles to MCTrack (so hits can be added to the correct track).
 
std::map< std::string, ElementGroupm_groups
 name -> grouping element.
 
TEveTrackList * m_tracklist
 parent object for MC tracks.
 
TEveTrackPropagator * m_trackpropagator
 Track propagator for MCParticles.
 
TEveTrackPropagator * m_gftrackpropagator
 Track propagator for genfit::Tracks (different mainly because of drawing options)
 
TEveTrackPropagator * m_consttrackpropagator
 Track propagator for CDCTriggerTracks (uses constant B field)
 
TEveCaloDataVec * m_eclData
 ECL cluster data.
 
EveVisBFieldm_bfield
 The global magnetic field.
 
std::set< const TObject * > m_shownRecohits
 List of shown recohits (PXDCluster, SVDCluster, CDCHit).
 
TEveStraightLineSet * m_unassignedRecoHits = nullptr
 Unassigned recohits.
 
bool m_unassignedRecoHitsVisibility = true
 is m_unassignedRecoHits visible?
 
bool m_drawCardinalRep = true
 Draw cardinal representation in addTrack.
 
bool m_drawErrors = false
 Draw errors in addTrack.
 
bool m_drawRefTrack = false
 Draw reference track in addTrack.
 
bool m_drawForward = false
 draw forward in addTrack
 
bool m_drawBackward = false
 draw backward in addTrack
 

Static Private Attributes

const static int c_recoHitColor = getTColorID("Orange", 1)
 Color for reco hits.
 
const static int c_recoTrackColor = getTColorID("Sky Blue", 1)
 Color for TrackCandidates.
 
const static int c_trackColor = getTColorID("Sky Blue", 2)
 Color for tracks.
 
const static int c_trackMarkerColor = getTColorID("Chameleon", 3)
 Color for track markers.
 
const static int c_unassignedHitColor = getTColorID("Plum", 1)
 Color for unassigned (reco)hits.
 
const static int c_klmClusterColor = getTColorID("Chameleon", 1)
 Color for KLMCluster objects.
 
static constexpr double c_minPCut = 0.00
 don't show MCParticles with momentum below this cutoff.
 

Detailed Description

Produces visualisation for MCParticles, simhits, genfit::Tracks, geometry and other things.

Creates TEve objects from the given data, and adds them to the global or event scene.

See also
DisplayModule

Definition at line 59 of file EVEVisualization.h.

Member Function Documentation

◆ addMCParticle()

EVEVisualization::MCTrack * addMCParticle ( const MCParticle particle)

Return MCTrack for given particle, add it if it doesn't exist yet.

If particle is NULL, a dummy MCTrack (with track=0) is created which can accept otherwise unassigned hits. Returns NULL if this particle and its hits shouldn't be shown.

Definition at line 1099 of file EVEVisualization.cc.

1100 {
1101  if (!particle) {
1102  if (!m_mcparticleTracks[nullptr].simhits) {
1103  const TString pointsTitle("Unassigned SimHits");
1104  m_mcparticleTracks[nullptr].simhits = new TEvePointSet(pointsTitle);
1105  m_mcparticleTracks[nullptr].simhits->SetTitle(pointsTitle);
1106  m_mcparticleTracks[nullptr].simhits->SetMarkerStyle(6);
1107  m_mcparticleTracks[nullptr].simhits->SetMainColor(c_unassignedHitColor);
1108  //m_mcparticleTracks[nullptr].simhits->SetMainTransparency(50);
1109  m_mcparticleTracks[nullptr].track = NULL;
1110  }
1111  return &m_mcparticleTracks[nullptr];
1112  }
1113 
1114  if (m_hideSecondaries and !particle->hasStatus(MCParticle::c_PrimaryParticle)) {
1115  return NULL;
1116  }
1117  if (m_assignToPrimaries) {
1118  while (!particle->hasStatus(MCParticle::c_PrimaryParticle) and particle->getMother())
1119  particle = particle->getMother();
1120  }
1121 
1122  if (!m_mcparticleTracks[particle].track) {
1123  const TVector3& p = particle->getMomentum();
1124  const TVector3& vertex = particle->getProductionVertex();
1125  const int pdg = particle->getPDG();
1126  TParticle tparticle(pdg, particle->getStatus(),
1127  (particle->getMother() ? particle->getMother()->getIndex() : 0), 0, particle->getFirstDaughter(), particle->getLastDaughter(),
1128  p.x(), p.y(), p.z(), particle->getEnergy(),
1129  vertex.x(), vertex.y(), vertex.z(), particle->getProductionTime());
1130  TEveMCTrack mctrack;
1131  mctrack = tparticle;
1132  mctrack.fTDecay = particle->getDecayTime();
1133  mctrack.fVDecay.Set(particle->getDecayVertex());
1134  mctrack.fDecayed = !boost::math::isinf(mctrack.fTDecay);
1135  mctrack.fIndex = particle->getIndex();
1136  m_mcparticleTracks[particle].track = new TEveTrack(&mctrack, m_trackpropagator);
1137 
1138  //Check if there is a trajectory stored for this particle
1139  const auto mcTrajectories = particle->getRelationsTo<MCParticleTrajectory>();
1140  bool hasTrajectory(false);
1141  for (auto rel : mcTrajectories.relations()) {
1142  //Trajectories with negative weight are from secondary daughters which
1143  //were ignored so we don't use them.
1144  if (rel.weight <= 0) continue;
1145  //Found one, let's add tose point as reference points to the TEveTrack.
1146  //This will force the track propagation to visit all points in order but
1147  //provide smooth helix interpolation between the points
1148  const MCParticleTrajectory& trajectory = dynamic_cast<const MCParticleTrajectory&>(*rel.object);
1149  for (const MCTrajectoryPoint& pt : trajectory) {
1150  m_mcparticleTracks[particle].track->AddPathMark(
1151  TEvePathMark(
1152  //Add the last trajectory point as decay point to prevent TEve to
1153  //propagate beyond the end of the track. So lets compare the adress
1154  //to the address of last point and choose the pathmark accordingly
1155  (&pt == &trajectory.back()) ? TEvePathMark::kDecay : TEvePathMark::kReference,
1156  TEveVector(pt.x, pt.y, pt.z),
1157  TEveVector(pt.px, pt.py, pt.pz)
1158  ));
1159  }
1160  //"There can only be One" -> found a trajectory, stop the loop
1161  hasTrajectory = true;
1162  break;
1163  }
1164 
1165  //If we have the full trajectory there is no need to add additional path marks
1166  if (!hasTrajectory) {
1167  //add daughter vertices - improves track rendering as lost momentum is taken into account
1168  for (int iDaughter = particle->getFirstDaughter(); iDaughter <= particle->getLastDaughter(); iDaughter++) {
1169  if (iDaughter == 0)
1170  continue; //no actual daughter
1171 
1172  const MCParticle* daughter = StoreArray<MCParticle>()[iDaughter - 1];
1173 
1174  TEvePathMarkD refMark(TEvePathMarkD::kDaughter);
1175  refMark.fV.Set(daughter->getProductionVertex());
1176  refMark.fP.Set(daughter->getMomentum());
1177  refMark.fTime = daughter->getProductionTime();
1178  m_mcparticleTracks[particle].track->AddPathMark(refMark);
1179  }
1180 
1181  //neutrals and very short-lived particles should stop somewhere
1182  //(can result in wrong shapes for particles stopped in the detector, so not used there)
1183  if ((TMath::Nint(particle->getCharge()) == 0 or !particle->hasStatus(MCParticle::c_StoppedInDetector))
1184  and mctrack.fDecayed) {
1185  TEvePathMarkD decayMark(TEvePathMarkD::kDecay);
1186  decayMark.fV.Set(particle->getDecayVertex());
1187  m_mcparticleTracks[particle].track->AddPathMark(decayMark);
1188  }
1189  }
1190  TString particle_name(mctrack.GetName());
1191 
1192  //set track title (for popup)
1193  const MCParticle* mom = particle->getMother();
1194  if (mom) {
1195  m_mcparticleTracks[particle].parentParticle = mom;
1196  addMCParticle(mom);
1197  }
1198 
1199  TString title = ObjectInfo::getTitle(particle);
1200  if (!hasTrajectory) {
1201  //Hijack the mother label to show that the track position is only
1202  //extrapolated, not known from simulation
1203  title += "\n(track estimated from initial momentum)";
1204  //Also, show those tracks with dashed lines
1205  m_mcparticleTracks[particle].track->SetLineStyle(2);
1206  }
1207 
1208  m_mcparticleTracks[particle].track->SetTitle(title);
1209 
1210  //add some color (avoid black & white)
1211  switch (abs(pdg)) {
1212  case 11:
1213  m_mcparticleTracks[particle].track->SetLineColor(kAzure);
1214  break;
1215  case 13:
1216  m_mcparticleTracks[particle].track->SetLineColor(kCyan + 1);
1217  break;
1218  case 22:
1219  m_mcparticleTracks[particle].track->SetLineColor(kSpring);
1220  break;
1221  case 211:
1222  m_mcparticleTracks[particle].track->SetLineColor(kGray + 1);
1223  break;
1224  case 321:
1225  m_mcparticleTracks[particle].track->SetLineColor(kRed + 1);
1226  break;
1227  case 2212:
1228  m_mcparticleTracks[particle].track->SetLineColor(kOrange - 2);
1229  break;
1230  default:
1231  m_mcparticleTracks[particle].track->SetLineColor(kMagenta);
1232  }
1233 
1234  //create point set for hits
1235  const TString pointsTitle = "SimHits for " + ObjectInfo::getIdentifier(particle) + " - " + particle_name;
1236  m_mcparticleTracks[particle].simhits = new TEvePointSet(pointsTitle);
1237  m_mcparticleTracks[particle].simhits->SetTitle(pointsTitle);
1238  m_mcparticleTracks[particle].simhits->SetMarkerStyle(6);
1239  m_mcparticleTracks[particle].simhits->SetMainColor(m_mcparticleTracks[particle].track->GetLineColor());
1240  //m_mcparticleTracks[particle].simhits->SetMainTransparency(50);
1241  addObject(particle, m_mcparticleTracks[particle].track);
1242  }
1243  return &m_mcparticleTracks[particle];
1244 }

◆ addObject()

void addObject ( const TObject *  dataStoreObject,
TEveElement *  visualRepresentation 
)

Generic function to keep track of which objects have which visual representation.

Should be called by functions adding TEveElements to the event scene (Hits are currently excluded).

Definition at line 1881 of file EVEVisualization.cc.

◆ addToGroup()

void addToGroup ( const std::string &  name,
TEveElement *  elem 
)
private

Add 'elem' to the element group 'name' (created if necessary).

name can also be a path, e.g. MyOwnStuff/SpecialObject A, which will automatically create sub-groups.

slashes at beginning and end of name are ignored.

Definition at line 1886 of file EVEVisualization.cc.

◆ addTOPDigits()

void addTOPDigits ( const StoreArray< TOPDigit > &  digits)

Add TOPDigits (shown aggregated per module).

TOP module ID -> #digits

Definition at line 1788 of file EVEVisualization.cc.

◆ addTrack()

void addTrack ( const Belle2::Track belle2Track)

Add this genfit::Track to event data.

Adapted from GenfitDisplay, originally written by Karl Bicker.

Definition at line 376 of file EVEVisualization.cc.

◆ addTrackCandidateImproved()

void addTrackCandidateImproved ( const std::string &  collectionName,
const RecoTrack recoTrack 
)

Add a RecoTrack, but use stored genfit track representation to make visualisation objects.

FIXME this is mostly just a workaround for monopoles.

Definition at line 254 of file EVEVisualization.cc.

◆ makeTracks()

void makeTracks ( )

Create visual representation of all tracks.

Needs to be called after all hits / tracks are added.

Definition at line 1246 of file EVEVisualization.cc.

◆ setAssignToPrimaries()

void setAssignToPrimaries ( bool  on)
inline

If true, hits created by secondary particles (e.g.

delta electrons) will be assigned to the original primary particle.

Definition at line 266 of file EVEVisualization.h.

266 { m_assignToPrimaries = on; }

◆ setErrScale()

void setErrScale ( double  errScale = 1.)

Set the scaling factor for the visualization of track hit errors.

(only affects PXD and SpacePoint hits, which are somewhat small

Definition at line 177 of file EVEVisualization.cc.

◆ setOptions()

void setOptions ( const std::string &  opts)

Set the display options.

The option string lets you steer the way the events are displayed. The following options are available:

'D': Draw detectors. This causes a simple representation for all detectors to be drawn. For planar detectors, this is a plane with the same position and orientation of the real detector plane, but with different size. For wires, this is a tube whose diameter is equal to the value measured by the wire. Spacepoint hits are not affected by this option.

'H': Draw hits. This causes the hits to be visualized. Normally, the size of the hit representation is connected to the covariance matrix of the hit, scaled by the value set in setErrScale which is normally 1. Normally used in connection with 'D'.

'M': Draw track markers. Draw the intersection points between the track and the virtual (and/or real) detector planes. 'P': Draw detector planes. Draws the virtual (and/or real) detector planes.

Definition at line 175 of file EVEVisualization.cc.

Member Data Documentation

◆ m_assignToPrimaries

bool m_assignToPrimaries
private

If true, hits created by secondary particles (e.g.

delta electrons) will be assigned to the original primary particle.

Definition at line 323 of file EVEVisualization.h.

◆ m_options

std::string m_options
private

Option string for genfit::Track visualisation.

See also
setOptions

Definition at line 320 of file EVEVisualization.h.


The documentation for this class was generated from the following files:
Belle2::MCParticle::c_StoppedInDetector
@ c_StoppedInDetector
bit 3: Particle was stopped in the detector (the simulation volume).
Definition: MCParticle.h:64
Belle2::MCTrajectoryPoint
Small struct to encode a position/momentum without additional overhead.
Definition: MCTrajectoryPoint.h:21
Belle2::EVEVisualization::c_unassignedHitColor
const static int c_unassignedHitColor
Color for unassigned (reco)hits.
Definition: EVEVisualization.h:93
Belle2::EVEVisualization::m_assignToPrimaries
bool m_assignToPrimaries
If true, hits created by secondary particles (e.g.
Definition: EVEVisualization.h:323
Belle2::MCParticleTrajectory
Class to save the full simulated trajectory of a particle.
Definition: MCParticleTrajectory.h:32
Belle2::ObjectInfo::getTitle
TString getTitle(const TObject *obj)
Get plain text for TEve object titles (shown on mouse-over).
Definition: ObjectInfo.cc:61
Belle2::EVEVisualization::addObject
void addObject(const TObject *dataStoreObject, TEveElement *visualRepresentation)
Generic function to keep track of which objects have which visual representation.
Definition: EVEVisualization.cc:1881
Belle2::EVEVisualization::addMCParticle
MCTrack * addMCParticle(const MCParticle *particle)
Return MCTrack for given particle, add it if it doesn't exist yet.
Definition: EVEVisualization.cc:1099
Belle2::ObjectInfo::getIdentifier
TString getIdentifier(const TObject *obj)
Where is this object in the datastore?
Definition: ObjectInfo.cc:98
Belle2::EVEVisualization::m_trackpropagator
TEveTrackPropagator * m_trackpropagator
Track propagator for MCParticles.
Definition: EVEVisualization.h:338
Belle2::EVEVisualization::m_mcparticleTracks
std::map< const MCParticle *, MCTrack > m_mcparticleTracks
map MCParticles to MCTrack (so hits can be added to the correct track).
Definition: EVEVisualization.h:329
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray< MCParticle >
Belle2::EVEVisualization::m_hideSecondaries
bool m_hideSecondaries
If true, secondary MCParticles (and hits created by them) will not be shown.
Definition: EVEVisualization.h:326
Belle2::MCParticle::c_PrimaryParticle
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:58