8#include <display/modules/display/DisplayModule.h>
10#include <framework/dataobjects/DisplayData.h>
11#include <display/DisplayUI.h>
12#include <display/EVEVisualization.h>
13#include <display/EveGeometry.h>
14#include <mdst/dataobjects/Track.h>
15#include <mdst/dataobjects/TrackFitResult.h>
16#include <simulation/dataobjects/MCParticleTrajectory.h>
18#include <framework/datastore/StoreArray.h>
19#include <framework/datastore/StoreObjPtr.h>
20#include <framework/gearbox/Gearbox.h>
21#include <framework/core/Path.h>
23#include <tracking/dataobjects/RecoTrack.h>
24#include <tracking/dataobjects/RecoHitInformation.h>
25#include <genfit/GFRaveVertex.h>
27#include <TApplication.h>
28#include <TEveManager.h>
36 setDescription(
"Interactive visualisation of Monte Carlo, intermediate and reconstructed objects, plus geometry. See https://software.belle2.org/development/sphinx/display/doc/index.html for detailed documentation.");
39 "Drawing options for RecoTracks, a combination of DHMP. See EVEVisualization::setOptions or the display.py example for an explanation.",
41 addParam(
"showMCInfo",
m_showMCInfo,
"Show Monte Carlo information (MCParticles, SimHits)",
true);
43 "If true, hits created by secondary particles (after scattering, decay-in-flight, ...) will be assigned to the original primary particle.",
46 "If true, all primary MCParticles will be shown, regardless of wether hits are produced.",
true);
47 addParam(
"hideSecondaries",
m_hideSecondaries,
"If true, secondary MCParticles (and hits created by them) will not be shown.",
50 "If true, all charged MCParticles will be shown, including secondaries (implies disabled assignHitsToPrimaries). May be slow.",
53 "If true, all neutral MCParticles will be shown, including secondaries (implies disabled assignHitsToPrimaries). May be slow.",
56 "If true, fitted Tracks, GFRave Vertices and ECLCluster objects will be shown in the display.",
true);
58 "If true, track candidates (RecoTracks) and reconstructed hits will be shown in the display.",
false);
60 "If true, CDCHit objects will be shown as drift cylinders (shortened, z position set to zero).",
false);
62 "If true, CDCHit objects will be assigned to trigger segments and trigger tracks will be shown.",
false);
64 "If true, KLMHit2d objects will be shown in the display.",
true);
66 "If true, ARICHHit objects will be shown.",
false);
68 "Non-interactively save visualisations for each event. Note that this still requires an X server, but you can use the 'Xvfb' dummy server by running basf2 using 'xvfb-run -s \"-screen 0 640x480x24\" basf2 ...' to run headless.",
71 "Show full geometry instead of simplified shapes. Further details can be enabled by changing the VisLevel option for Eve -> Scenes -> Geometry Scene -> Top_1.",
74 "Objects which are to be hidden (can be manually re-enabled in tree view). Names correspond to the object names in the 'Event'. (Note that this won't work for objects somewhere deep in the tree, only for those immediately below 'Event'.)", {});
77 "List of volumes to be hidden (can be re-enabled in Eve panel / Geometry scene. The volume and all its daughters will be hidden.", {});
79 "List of volumes to be deleted. The volume and all its daughters will be deleted completely. Uses Regular Expressions (RE)! If the expression starts with '#', only daughters are removed (# is removed for RE)", {});
81 "When launching the event display, immediately start advancing through events. Useful for control room uses etc.",
false);
85 if ((!gApplication) || (gApplication->TestBit(TApplication::kDefaultApplication))) {
86 new TApplication(
"ROOT_application", 0, 0);
125 m_display->
addParameter(
"Assign hits to primary particles", getParam<bool>(
"assignHitsToPrimaries"), 1);
132 m_display->
addParameter(
"Show tracks, vertices, gammas", getParam<bool>(
"showTrackLevelObjects"), 0);
136 if (detectorName !=
"Belle2Detector") {
137 B2INFO(
"Non-standard detector '" << detectorName <<
"' used, switching to full geometry.");
164 B2WARNING(
"Display window closed, continuing with next module. (hit Ctrl+C to exit)");
173 B2WARNING(
"assignHitsToPrimaries and showCharged/showNeutrals can not be used together!");
202 for (std::string colName : recoTrackArrays) {
204 for (
const RecoTrack& recoTrack : recoTracks) {
205 if (colName !=
"RecoTracksMpl") {
227 for (
int i = 0 ; i < testbeamROIs.
getEntries(); i++)
233 for (
auto& hit : cdchits)
239 for (
const auto& i : arrayList) {
241 for (
auto& hit : tshits)
247 for (std::string colName : trgTrackArrays) {
257 for (
auto& hit : klmHits) {
267 for (
auto& hit : arichhits)
274 for (
const Track& track : tracks)
278 const int nVertices = vertices.getEntries();
279 for (
int i = 0; i < nVertices; i++) {
298 for (
const KLMCluster& cluster : klmclusters) {
Track created by the CDC trigger.
bool m_showCDCHits
If true, CDCHit objects will be shown as drift cylinders (shortened, z position set to zero).
bool m_showTriggerObjects
If true, CDCHit objects will be assigned to trigger segments and trigger tracks will be shown.
bool m_showTrackLevelObjects
If true, fitted RecoTracks, GFRave Vertices and ECLGamma objects will be shown in the display.
DisplayModule()
Constructor. Sets all the module parameters.
bool m_showRecoTracks
Whether to show RecoTracks.
bool m_showKLM2dHits
If true, KLMHit2d objects will be shown in the display.
void initialize() override
Sets up geometry if needed.
bool m_automatic
Non-interactively save visualizations for each event.
void event() override
Show various reconstructed or simulated objects in the event viewer until the next event is requested...
std::vector< std::string > m_deleteVolumes
List of volumes to be deleted.
void terminate() override
Terminate gEve to avoid problems with root's cleanup.
bool m_showAllPrimaries
If true, all primary MCParticles will be shown, regardless of wether hits are produced.
bool m_showNeutrals
If true, all neutral primary and secondary MCParticles will be shown, regardless of wether hits are p...
bool m_showCharged
If true, all charged primary and secondary MCParticles will be shown, regardless of wether hits are p...
EVEVisualization * m_visualizer
Pointer to visualizer.
bool m_showMCInfo
Show Monte Carlo information (MCParticles, SimHits).
bool m_fullGeometry
Show full geometry instead of simplified shapes.
bool m_showARICHHits
If true, ARICHHit objects will be shown as squares, corresponding to channel pixels.
std::string m_options
List of drawing options, see EVEVisualization::setOptions()
DisplayUI * m_display
pointer to actual display
bool m_hideSecondaries
If true, secondary MCParticles (and hits created by them) will not be shown.
bool m_playOnStartup
Start the module advancing through events.
std::vector< std::string > m_hideVolumes
List of volumes to be hidden (can be re-enabled in Eve panel / Geometry scene.
bool m_assignToPrimaries
If true, hits created by secondary particles (e.g.
std::string m_customGeometryExtractPath
Path to custom file with geometry extract.
std::vector< std::string > m_hideObjects
objects which are to be hidden (can be manually re-enabled in tree view).
Control TEve browser user interface.
void clearEvent()
remove all event data in current event.
void hideObjects(const std::vector< std::string > &names)
hide objects with the given names.
bool getReturnValue() const
Return value for current event, only makes sense if allowFlaggingEvents(true) was called.
bool cumulativeIsOn() const
If true, DisplayModule shouldn't clear previous data (i.e.
void addParameter(const std::string &label, ModuleParam< bool > ¶m, int level)
Generate UI elements so the given module parameter can be changed at run time.
bool startDisplay()
Start interactive display for current event.
void showUserData(const DisplayData &displayData)
Add user-defined data (histograms, etc.).
void allowFlaggingEvents(const std::string &description="")
Show control for flagging events (to set module return value).
@ c_nPhotons
CR is split into n photons (N1)
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.
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.
void addCDCHit(const CDCHit *hit, bool showTriggerHits=false)
show CDCHits directly.
void addBKLMHit2d(const KLMHit2d *bklm2dhit)
Add a reconstructed 2d hit in the BKLM.
void addVertex(const genfit::GFRaveVertex *vertex)
Add a vertex point and its covariance matrix.
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.
void addECLCluster(const ECLCluster *cluster)
Add a reconstructed cluster in the ECL.
void makeTracks()
Create visual representation of all tracks.
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.
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.)
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.
MCTrack * addMCParticle(const MCParticle *particle)
Return MCTrack for given particle, add it if it doesn't exist yet.
void addTrackCandidate(const std::string &collectionName, const RecoTrack &recoTrack)
Add a RecoTrack, to evaluate track finding.
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
A Class to store the Monte Carlo particle information.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
const ModuleCondition * getCondition() const
Return a pointer to the first condition (or nullptr, if none was set)
void setDescription(const std::string &description)
Sets the description of the module.
void setReturnValue(int value)
Sets the return value for this module as integer.
bool hasCondition() const
Returns true if at least one condition was set for the module.
std::string getPathString() const override
return the module name.
This is the Reconstruction Event-Data Model Track.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
static std::vector< std::string > getArrayList(DataStore::EDurability durability=DataStore::c_Event)
Return list of array names with matching type.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
Class that bundles various TrackFitResults.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
void addGeometry(EType visMode)
Add TGeo geometry to Eve (only needs to be done once.)
void setDeleteVolumes(const std::vector< std::string > &volumes)
List of volumes to be removed.
void setVisualisationMode(EType visMode)
switch to given visualisation mode.
void setCustomExtractPath(const std::string &extractPath)
Set custom path to the geometry extract (to change originally hard-coded value)
void setHideVolumes(const std::vector< std::string > &volumes)
List of volumes to be hidden (can be re-enabled in Eve panel / Geometry scene.
@ c_Full
Full geometry converted from Geant4 (use this for non-standard Belle II setups!).
@ c_Simplified
a simplified Belle II geometry.
Abstract base class for different kinds of events.