Belle II Software development
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 <Math/Vector3D.h>
34#include <TEveStraightLineSet.h>
35#include <TVector3.h>
36#include <TEveTrack.h>
37
38#include <string>
39
40
41class TEveBox;
42class TEveCaloDataVec;
43class TEveCalo3D;
44class TEveElementList;
45class TEvePointSet;
46class TEveTrackList;
47class TEveTrackPropagator;
48
49namespace Belle2 {
54 class DisplayData;
55 class EveVisBField;
56
67 SimpleKalman,
68 RefKalman,
69 DafSimple,
70 DafRef,
71 Gbl
72 };
73
74
76 struct MCTrack {
77 TEveTrack* track;
78 TEvePointSet* simhits;
80 };
81
83 struct ElementGroup {
84 ElementGroup(): group(nullptr), visible(true) { }
85 TEveElementList* group;
86 bool visible;
87 };
88
90 const static int c_recoHitColor;
92 const static int c_recoTrackColor;
94 const static int c_trackColor;
96 const static int c_trackMarkerColor;
98 const static int c_unassignedHitColor;
100 const static int c_klmClusterColor;
101
102 public:
105 explicit EVEVisualization();
106
113
114 // === adding event data ===
115
119 void addTrack(const Belle2::Track* belle2Track);
120
122 void addTrackCandidate(const std::string& collectionName,
123 const RecoTrack& recoTrack);
124
128 void addTrackCandidateImproved(const std::string& collectionName,
129 const RecoTrack& recoTrack);
130
132 void addCDCTriggerTrack(const std::string& collectionName,
133 const CDCTriggerTrack& track);
134
136 template <class T> void addSimHits(const StoreArray<T>& hits)
137 {
138 const int numHits = hits.getEntries();
139 for (int i = 0; i < numHits; i++) {
140 const RelationsObject* rel = hits[i];
141 const MCParticle* mcpart = rel->getRelatedFrom<MCParticle>();
142
143 addSimHit(hits[i], mcpart);
144 }
145 }
146
148 void addSimHit(const CDCSimHit* hit, const MCParticle* particle);
149
151 void addSimHit(const PXDSimHit* hit, const MCParticle* particle);
152
154 void addSimHit(const SVDSimHit* hit, const MCParticle* particle);
155
157 void addSimHit(const KLMSimHit* hit, const MCParticle* particle);
158
160 void addSimHit(const ROOT::Math::XYZVector& v, const MCParticle* particle);
161
167 MCTrack* addMCParticle(const MCParticle* particle);
168
170 void addVertex(const genfit::GFRaveVertex* vertex);
171
173 void addECLCluster(const ECLCluster* cluster);
174
176 void addKLMCluster(const KLMCluster* cluster);
177
179 void addBKLMHit2d(const KLMHit2d* bklm2dhit);
180
182 void addEKLMHit2d(const KLMHit2d* eklm2dhit);
183
185 void addARICHHit(const ARICHHit* hit);
186
188 void addROI(const ROIid* roi);
189
191 template <class T> void addUnassignedRecoHits(const StoreArray<T>& hits)
192 {
193 if (hits.getEntries() == 0)
194 return;
196 m_unassignedRecoHits = new TEveStraightLineSet("Unassigned RecoHits");
197 m_unassignedRecoHits->SetTitle("Unassigned RecoHits");
200 m_unassignedRecoHits->SetMarkerStyle(6);
201 //m_unassignedRecoHits->SetMainTransparency(60);
202 }
203 for (const T& hit : hits) {
204 if (m_shownRecohits.count(&hit) == 0) {
206 }
207 }
208 }
209
211 void addCDCHit(const CDCHit* hit, bool showTriggerHits = false);
212
214 void addCDCTriggerSegmentHit(const std::string& collectionName, const CDCTriggerSegmentHit* hit);
215
217 void addTOPDigits(const StoreArray<TOPDigit>& digits);
218
224 void addObject(const TObject* dataStoreObject, TEveElement* visualRepresentation);
225
226
228 void showUserData(const DisplayData& displayData);
229
230
235 void makeTracks();
236
238 void clearEvent();
239
240 // === configuration options ===
241
259 void setOptions(const std::string& opts);
260
265 void setErrScale(double errScale = 1.);
266
269
271 void setHideSecondaries(bool on) { m_hideSecondaries = on; }
272
273
274 private:
276 TEveCalo3D* m_calo3d;
277
281 TEveBox* boxCreator(const ROOT::Math::XYZVector& o, ROOT::Math::XYZVector u, ROOT::Math::XYZVector v, float ud, float vd,
282 float depth);
283
285 void makeLines(TEveTrack* eveTrack, const genfit::StateOnPlane* prevState, const genfit::StateOnPlane* state,
286 const genfit::AbsTrackRep* rep,
287 TEvePathMark::EType_e markType, bool drawErrors, int markerPos = 1);
288
290 template <class SomeVXDHit> void addRecoHit(const SomeVXDHit* hit, TEveStraightLineSet* lines)
291 {
293
294 const ROOT::Math::XYZVector local_pos(hit->getU(), hit->getV(), 0.0); //z-component is height over the center of the detector plane
295 const VXD::SensorInfoBase& sensor = geo.getSensorInfo(hit->getSensorID());
296 const ROOT::Math::XYZVector global_pos = sensor.pointToGlobal(local_pos);
297 lines->AddMarker(global_pos.X(), global_pos.Y(), global_pos.Z());
298
299 m_shownRecohits.insert(hit);
300 }
301
303 void addRecoHit(const SVDCluster* hit, TEveStraightLineSet* lines);
304
306 void addRecoHit(const CDCHit* hit, TEveStraightLineSet* lines);
307
314 void addToGroup(const std::string& name, TEveElement* elem);
315
318
323 std::string m_options;
324
327
329 bool m_hideSecondaries{false};
330
332 std::map<const MCParticle*, MCTrack> m_mcparticleTracks;
333
335 std::map<std::string, ElementGroup> m_groups;
336
338 TEveTrackList* m_tracklist;
339
341 TEveTrackPropagator* m_trackpropagator;
342
344 TEveTrackPropagator* m_gftrackpropagator;
345
347 TEveTrackPropagator* m_consttrackpropagator;
348
350 TEveCaloDataVec* m_eclData;
351
354
356 std::set<const TObject*> m_shownRecohits;
357
359 TEveStraightLineSet* m_unassignedRecoHits = nullptr;
362
364 static constexpr double c_minPCut = 0.00;
365
367 bool m_drawCardinalRep = true;
368
370 bool m_drawErrors = false;
371
373 bool m_drawRefTrack = false;
374
376 bool m_drawForward = false;
377
379 bool m_drawBackward = false;
380 };
382}
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().
TEveBox * boxCreator(const ROOT::Math::XYZVector &o, ROOT::Math::XYZVector u, ROOT::Math::XYZVector 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...
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 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.
TEveTrackList * m_tracklist
parent object for MC tracks.
EVEVisualization & operator=(const EVEVisualization &)=delete
disabled assignment
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.
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
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
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.