Belle II Software  release-08-01-10
EVEVisualization.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #pragma once
9 
10 #include <mdst/dataobjects/MCParticle.h>
11 #include <mdst/dataobjects/ECLCluster.h>
12 #include <mdst/dataobjects/KLMCluster.h>
13 #include <mdst/dataobjects/Track.h>
14 #include <cdc/dataobjects/CDCSimHit.h>
15 #include <cdc/dataobjects/CDCHit.h>
16 #include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
17 #include <trg/cdc/dataobjects/CDCTriggerTrack.h>
18 #include <pxd/dataobjects/PXDSimHit.h>
19 #include <svd/dataobjects/SVDSimHit.h>
20 #include <svd/dataobjects/SVDCluster.h>
21 #include <klm/dataobjects/KLMHit2d.h>
22 #include <klm/dataobjects/KLMSimHit.h>
23 #include <arich/dataobjects/ARICHHit.h>
24 #include <top/dataobjects/TOPDigit.h>
25 #include <vxd/geometry/GeoCache.h>
26 #include <tracking/dataobjects/ROIid.h>
27 
28 #include <framework/datastore/StoreArray.h>
29 
30 #include <tracking/dataobjects/RecoTrack.h>
31 #include <genfit/GFRaveVertex.h>
32 
33 #include <TEveStraightLineSet.h>
34 #include <TVector3.h>
35 #include <TEveTrack.h>
36 
37 #include <string>
38 
39 
40 class TEveBox;
41 class TEveCaloDataVec;
42 class TEveCalo3D;
43 class TEveElementList;
44 class TEvePointSet;
45 class TEveTrackList;
46 class TEveTrackPropagator;
47 
48 namespace Belle2 {
53  class DisplayData;
54  class EveVisBField;
55 
65  enum eFitterType {
66  SimpleKalman,
67  RefKalman,
68  DafSimple,
69  DafRef,
70  Gbl
71  };
72 
73 
75  struct MCTrack {
76  TEveTrack* track;
77  TEvePointSet* simhits;
79  };
80 
82  struct ElementGroup {
83  ElementGroup(): group(nullptr), visible(true) { }
84  TEveElementList* group;
85  bool visible;
86  };
87 
89  const static int c_recoHitColor;
91  const static int c_recoTrackColor;
93  const static int c_trackColor;
95  const static int c_trackMarkerColor;
97  const static int c_unassignedHitColor;
99  const static int c_klmClusterColor;
100 
101  public:
104  explicit EVEVisualization();
105 
112 
113  // === adding event data ===
114 
118  void addTrack(const Belle2::Track* belle2Track);
119 
121  void addTrackCandidate(const std::string& collectionName,
122  const RecoTrack& recoTrack);
123 
127  void addTrackCandidateImproved(const std::string& collectionName,
128  const RecoTrack& recoTrack);
129 
131  void addCDCTriggerTrack(const std::string& collectionName,
132  const CDCTriggerTrack& track);
133 
135  template <class T> void addSimHits(const StoreArray<T>& hits)
136  {
137  const int numHits = hits.getEntries();
138  for (int i = 0; i < numHits; i++) {
139  const RelationsObject* rel = hits[i];
140  const MCParticle* mcpart = rel->getRelatedFrom<MCParticle>();
141 
142  addSimHit(hits[i], mcpart);
143  }
144  }
145 
147  void addSimHit(const CDCSimHit* hit, const MCParticle* particle);
148 
150  void addSimHit(const PXDSimHit* hit, const MCParticle* particle);
151 
153  void addSimHit(const SVDSimHit* hit, const MCParticle* particle);
154 
156  void addSimHit(const KLMSimHit* hit, const MCParticle* particle);
157 
159  void addSimHit(const TVector3& v, const MCParticle* particle);
161  inline void addSimHit(const ROOT::Math::XYZVector& v, const MCParticle* particle)
162  {
163  addSimHit(TVector3(v.X(), v.Y(), v.Z()), particle);
164  }
165 
171  MCTrack* addMCParticle(const MCParticle* particle);
172 
174  void addVertex(const genfit::GFRaveVertex* vertex);
175 
177  void addECLCluster(const ECLCluster* cluster);
178 
180  void addKLMCluster(const KLMCluster* cluster);
181 
183  void addBKLMHit2d(const KLMHit2d* bklm2dhit);
184 
186  void addEKLMHit2d(const KLMHit2d* eklm2dhit);
187 
189  void addARICHHit(const ARICHHit* hit);
190 
192  void addROI(const ROIid* roi);
193 
195  template <class T> void addUnassignedRecoHits(const StoreArray<T>& hits)
196  {
197  if (hits.getEntries() == 0)
198  return;
199  if (!m_unassignedRecoHits) {
200  m_unassignedRecoHits = new TEveStraightLineSet("Unassigned RecoHits");
201  m_unassignedRecoHits->SetTitle("Unassigned RecoHits");
204  m_unassignedRecoHits->SetMarkerStyle(6);
205  //m_unassignedRecoHits->SetMainTransparency(60);
206  }
207  for (const T& hit : hits) {
208  if (m_shownRecohits.count(&hit) == 0) {
210  }
211  }
212  }
213 
215  void addCDCHit(const CDCHit* hit, bool showTriggerHits = false);
216 
218  void addCDCTriggerSegmentHit(const std::string& collectionName, const CDCTriggerSegmentHit* hit);
219 
221  void addTOPDigits(const StoreArray<TOPDigit>& digits);
222 
228  void addObject(const TObject* dataStoreObject, TEveElement* visualRepresentation);
229 
230 
232  void showUserData(const DisplayData& displayData);
233 
234 
239  void makeTracks();
240 
242  void clearEvent();
243 
244  // === configuration options ===
245 
263  void setOptions(const std::string& opts);
264 
269  void setErrScale(double errScale = 1.);
270 
273 
275  void setHideSecondaries(bool on) { m_hideSecondaries = on; }
276 
277 
278  private:
280  TEveCalo3D* m_calo3d;
281 
285  TEveBox* boxCreator(const TVector3& o, TVector3 u, TVector3 v, float ud, float vd, float depth);
286 
288  void makeLines(TEveTrack* eveTrack, const genfit::StateOnPlane* prevState, const genfit::StateOnPlane* state,
289  const genfit::AbsTrackRep* rep,
290  TEvePathMark::EType_e markType, bool drawErrors, int markerPos = 1);
291 
293  template <class SomeVXDHit> void addRecoHit(const SomeVXDHit* hit, TEveStraightLineSet* lines)
294  {
296 
297  const ROOT::Math::XYZVector local_pos(hit->getU(), hit->getV(), 0.0); //z-component is height over the center of the detector plane
298  const VXD::SensorInfoBase& sensor = geo.get(hit->getSensorID());
299  const ROOT::Math::XYZVector global_pos = sensor.pointToGlobal(local_pos);
300  lines->AddMarker(global_pos.X(), global_pos.Y(), global_pos.Z());
301 
302  m_shownRecohits.insert(hit);
303  }
304 
306  void addRecoHit(const SVDCluster* hit, TEveStraightLineSet* lines);
307 
309  void addRecoHit(const CDCHit* hit, TEveStraightLineSet* lines);
310 
317  void addToGroup(const std::string& name, TEveElement* elem);
318 
320  double m_errorScale;
321 
326  std::string m_options;
327 
330 
332  bool m_hideSecondaries{false};
333 
335  std::map<const MCParticle*, MCTrack> m_mcparticleTracks;
336 
338  std::map<std::string, ElementGroup> m_groups;
339 
341  TEveTrackList* m_tracklist;
342 
344  TEveTrackPropagator* m_trackpropagator;
345 
347  TEveTrackPropagator* m_gftrackpropagator;
348 
350  TEveTrackPropagator* m_consttrackpropagator;
351 
353  TEveCaloDataVec* m_eclData;
354 
357 
359  std::set<const TObject*> m_shownRecohits;
360 
362  TEveStraightLineSet* m_unassignedRecoHits = nullptr;
365 
367  static constexpr double c_minPCut = 0.00;
368 
370  bool m_drawCardinalRep = true;
371 
373  bool m_drawErrors = false;
374 
376  bool m_drawRefTrack = false;
377 
379  bool m_drawForward = false;
380 
382  bool m_drawBackward = false;
383  };
385 }
Datastore class that holds photon hits. Input to the reconstruction.
Definition: ARICHHit.h:23
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Example Detector.
Definition: CDCSimHit.h:21
Combination of several CDCHits to a track segment hit for the trigger.
Track created by the CDC trigger.
Add custom information to the display.
Definition: DisplayData.h:55
ECL cluster data.
Definition: ECLCluster.h:27
Produces visualisation for MCParticles, simhits, genfit::Tracks, geometry and other things.
void clearEvent()
clear event data.
void setOptions(const std::string &opts)
Set the display options.
void addSimHits(const StoreArray< T > &hits)
Add all entries in the given 'hits' array (and the corresponding MCParticles) to the event scene.
static constexpr double c_minPCut
don't show MCParticles with momentum below this cutoff.
EVEVisualization(const EVEVisualization &)=delete
disabled.
void setHideSecondaries(bool on)
If true, secondary MCParticles (and hits created by them) will not be shown.
void setAssignToPrimaries(bool on)
If true, hits created by secondary particles (e.g.
void addTrackCandidateImproved(const std::string &collectionName, const RecoTrack &recoTrack)
Add a RecoTrack, but use stored genfit track representation to make visualisation objects.
EveVisBField * m_bfield
The global magnetic field.
eFitterType
Fitter type to be used for addTrack().
TEveStraightLineSet * m_unassignedRecoHits
Unassigned recohits.
static const int c_recoHitColor
Color for reco hits.
void addCDCHit(const CDCHit *hit, bool showTriggerHits=false)
show CDCHits directly.
std::map< const MCParticle *, MCTrack > m_mcparticleTracks
map MCParticles to MCTrack (so hits can be added to the correct track).
void addBKLMHit2d(const KLMHit2d *bklm2dhit)
Add a reconstructed 2d hit in the BKLM.
void addSimHit(const ROOT::Math::XYZVector &v, const MCParticle *particle)
Add simhit as a simple point.
void setErrScale(double errScale=1.)
Set the scaling factor for the visualization of track hit errors.
bool m_drawRefTrack
Draw reference track in addTrack.
void addVertex(const genfit::GFRaveVertex *vertex)
Add a vertex point and its covariance matrix.
bool m_drawForward
draw forward in addTrack
TEveCalo3D * m_calo3d
Object for the energy bar visualisation.
bool m_drawCardinalRep
Draw cardinal representation in addTrack.
void addCDCTriggerTrack(const std::string &collectionName, const CDCTriggerTrack &track)
Add a CDCTriggerTrack.
void addCDCTriggerSegmentHit(const std::string &collectionName, const CDCTriggerSegmentHit *hit)
show outline of track segments.
TEveTrackPropagator * m_trackpropagator
Track propagator for MCParticles.
std::map< std::string, ElementGroup > m_groups
name -> grouping element.
void addSimHit(const CDCSimHit *hit, const MCParticle *particle)
Add a CDCSimHit.
void addECLCluster(const ECLCluster *cluster)
Add a reconstructed cluster in the ECL.
EVEVisualization & operator=(const EVEVisualization &)=delete
disabled assignment
TEveTrackList * m_tracklist
parent object for MC tracks.
void addToGroup(const std::string &name, TEveElement *elem)
Add 'elem' to the element group 'name' (created if necessary).
void makeTracks()
Create visual representation of all tracks.
void addRecoHit(const SomeVXDHit *hit, TEveStraightLineSet *lines)
adds given VXD hit to lines.
void addUnassignedRecoHits(const StoreArray< T > &hits)
After adding recohits for tracks/candidates, this function adds the remaining hits in a global collec...
void addTrack(const Belle2::Track *belle2Track)
Add this genfit::Track to event data.
bool m_unassignedRecoHitsVisibility
is m_unassignedRecoHits visible?
static const int c_trackMarkerColor
Color for track markers.
TEveTrackPropagator * m_gftrackpropagator
Track propagator for genfit::Tracks (different mainly because of drawing options)
std::string m_options
Option string for genfit::Track visualisation.
static const int c_trackColor
Color for tracks.
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.
void addEKLMHit2d(const KLMHit2d *eklm2dhit)
Add a reconstructed 2d hit in the EKLM.
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 th...
void addARICHHit(const ARICHHit *hit)
Add recontructed hit in ARICH.
void showUserData(const DisplayData &displayData)
Add user-defined data (labels, points, etc.)
std::set< const TObject * > m_shownRecohits
List of shown recohits (PXDCluster, SVDCluster, CDCHit).
bool m_drawBackward
draw backward in addTrack
TEveTrackPropagator * m_consttrackpropagator
Track propagator for CDCTriggerTracks (uses constant B field)
bool m_assignToPrimaries
If true, hits created by secondary particles (e.g.
bool m_drawErrors
Draw errors in addTrack.
double m_errorScale
Rescale PXD/SVD errors with this factor to ensure visibility.
void addTOPDigits(const StoreArray< TOPDigit > &digits)
Add TOPDigits (shown aggregated per module).
void addROI(const ROIid *roi)
Add a Region Of Interest, computed by the PXDDataReduction module.
void addKLMCluster(const KLMCluster *cluster)
Add a reconstructed cluster in the KLM.
static const int c_klmClusterColor
Color for KLMCluster objects.
MCTrack * addMCParticle(const MCParticle *particle)
Return MCTrack for given particle, add it if it doesn't exist yet.
TEveCaloDataVec * m_eclData
ECL cluster data.
static const int c_recoTrackColor
Color for TrackCandidates.
void addTrackCandidate(const std::string &collectionName, const RecoTrack &recoTrack)
Add a RecoTrack, to evaluate track finding.
void addObject(const TObject *dataStoreObject, TEveElement *visualRepresentation)
Generic function to keep track of which objects have which visual representation.
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'.
Provide magnetic field values for TEveTrackPropagator.
Definition: EveVisBField.h:19
KLM cluster data.
Definition: KLMCluster.h:28
KLM 2d hit.
Definition: KLMHit2d.h:33
KLM simulation hit.
Definition: KLMSimHit.h:31
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Class PXDSimHit - Geant4 simulated hit for the PXD.
Definition: PXDSimHit.h:24
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
Definition: ROIid.h:25
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Defines interface for accessing relations of objects in StoreArray.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:29
Class SVDSimHit - Geant4 simulated hit for the SVD.
Definition: SVDSimHit.h:26
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Class that bundles various TrackFitResults.
Definition: Track.h:25
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
Base class to provide Sensor Information for PXD and SVD.
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
GFRaveVertex class.
Definition: GFRaveVertex.h:48
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
Abstract base class for different kinds of events.
Group of TEveElements, remembers wether user wants it visible or not.
TEveElementList * group
Contains elements of this group.
bool visible
Stores wether this group was visible in last event.
Hold MC tracks and associated visualisation objects.
TEvePointSet * simhits
simhit positions.
const MCParticle * parentParticle
parent particle, or nullptr.
TEveTrack * track
the actual MC track.