Belle II Software  release-08-01-10
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 KLMSimHit *hit, const MCParticle *particle)
 Add a KLMSimHit.
 
void addSimHit (const TVector3 &v, const MCParticle *particle)
 Add simhit as a simple point.
 
void addSimHit (const ROOT::Math::XYZVector &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 KLMHit2d *bklm2dhit)
 Add a reconstructed 2d hit in the BKLM.
 
void addEKLMHit2d (const KLMHit2d *eklm2dhit)
 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).
 
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 63 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 1089 of file EVEVisualization.cc.

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