Belle II Software  release-06-00-14
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

static const int c_recoHitColor = getTColorID("Orange", 1)
 Color for reco hits.
 
static const int c_recoTrackColor = getTColorID("Sky Blue", 1)
 Color for TrackCandidates.
 
static const int c_trackColor = getTColorID("Sky Blue", 2)
 Color for tracks.
 
static const int c_trackMarkerColor = getTColorID("Chameleon", 3)
 Color for track markers.
 
static const int c_unassignedHitColor = getTColorID("Plum", 1)
 Color for unassigned (reco)hits.
 
static const 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 65 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 1096 of file EVEVisualization.cc.

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

◆ 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 1878 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 1883 of file EVEVisualization.cc.

◆ addTOPDigits()

void addTOPDigits ( const StoreArray< TOPDigit > &  digits)

Add TOPDigits (shown aggregated per module).

TOP module ID -> #digits

Definition at line 1785 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 1243 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 272 of file EVEVisualization.h.

272 { 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 329 of file EVEVisualization.h.

◆ m_options

std::string m_options
private

Option string for genfit::Track visualisation.

See also
setOptions

Definition at line 326 of file EVEVisualization.h.


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