Belle II Software light-2406-ragdoll
DisplayData Class Reference

Add custom information to the display. More...

#include <DisplayData.h>

Inheritance diagram for DisplayData:
Collaboration diagram for DisplayData:

Classes

struct  Arrow
 Stores data associated with an arrow. More...
 

Public Member Functions

 DisplayData ()
 Constructor.
 
 ~DisplayData ()
 Destructor.
 
void addArrow (const std::string &name, const ROOT::Math::XYZVector &start, const ROOT::Math::XYZVector &end, int color=-1)
 Add an arrow in the display (for axes, to point out some specific location).
 
void addHistogram (const std::string &name, const TH1 *hist)
 Add histogram with the given name.
 
void addLabel (const std::string &text, const ROOT::Math::XYZVector &pos)
 Add a text label at the given position.
 
void addPoint (const std::string &name, const ROOT::Math::XYZVector &pos)
 Add a point at the given position, as part of a collection specified by name.
 
void select (const TObject *object)
 Select the given object in the display.
 

Private Member Functions

 ClassDef (DisplayData, 5)
 Add custom information to the display.
 

Private Attributes

std::map< std::string, std::vector< ROOT::Math::XYZVector > > m_pointSets
 name -> points map
 
std::vector< std::pair< std::string, ROOT::Math::XYZVector > > m_labels
 text labels (to be shown at a given position).
 
std::vector< TH1 * > m_histograms
 Histograms to be shown in Eve.
 
std::vector< std::pair< std::string, unsigned int > > m_selectedObjects
 List of selected objects (array name, index).
 
std::vector< Arrowm_arrows
 List of arrows.
 

Friends

class DisplayUI
 
class EVEVisualization
 

Detailed Description

Add custom information to the display.

To use it, simply create a DisplayData object using StoreObjPtr and call the functions to add custom data. For example:

displayData.create();
//let's label the interaction point
displayData.addLabel("IP", ROOT::Math::XYZVector(0, 0, 0));
//add some dots along the x axis
for (int i = 0; i < 20; i++) {
displayData.addPoint("pointset", ROOT::Math::XYZVector(i*10.0, 0, 0));
}
//add an arrow to point to (0, 0, -2m)
displayData.addArrow("z=-2m", ROOT::Math::XYZVector(100, 100, -200),
ROOT::Math::XYZVector(0, 0, -200), kGray);
bool create(bool replace=false)
Create a default object in the data store.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96

You can then save the output of your module to a file and view it with 'b2display', or look at it directly after execution by adding the Display module in your steering file.

See also
Check display/examples/displaydata.py to see how to use most features from a python steering file.
See display/examples/histogram_monitor.py for an example that generates and adds histograms in Python.

Definition at line 55 of file DisplayData.h.

Constructor & Destructor Documentation

◆ DisplayData()

DisplayData ( )
inline

Constructor.

Definition at line 59 of file DisplayData.h.

59{}

◆ ~DisplayData()

Destructor.

Definition at line 15 of file DisplayData.cc.

16{
17 m_pointSets.clear();
18 m_labels.clear();
19 for (auto hist : m_histograms)
20 delete hist;
21 m_histograms.clear();
22}
std::vector< TH1 * > m_histograms
Histograms to be shown in Eve.
Definition: DisplayData.h:111
std::map< std::string, std::vector< ROOT::Math::XYZVector > > m_pointSets
name -> points map
Definition: DisplayData.h:108
std::vector< std::pair< std::string, ROOT::Math::XYZVector > > m_labels
text labels (to be shown at a given position).
Definition: DisplayData.h:109

Member Function Documentation

◆ addArrow()

void addArrow ( const std::string &  name,
const ROOT::Math::XYZVector &  start,
const ROOT::Math::XYZVector &  end,
int  color = -1 
)

Add an arrow in the display (for axes, to point out some specific location).

Parameters
nameText to be shown beside arrow.
startThe arrow will start here.
endThe pointy end ends up here.
colorColor_t to use for this object, default: random color.

Definition at line 24 of file DisplayData.cc.

25{
26 m_arrows.push_back(Arrow {name, start, end, color});
27}
std::vector< Arrow > m_arrows
List of arrows.
Definition: DisplayData.h:114

◆ addHistogram()

void addHistogram ( const std::string &  name,
const TH1 *  hist 
)

Add histogram with the given name.

The histogram will show up in the 'Histograms' tab and can be drawn on the active canvas by double-clicking it.

Definition at line 39 of file DisplayData.cc.

40{
41 auto* newhist = static_cast<TH1*>(hist->Clone(name.c_str()));
42 newhist->SetDirectory(nullptr);
43 m_histograms.push_back(newhist);
44}

◆ addLabel()

void addLabel ( const std::string &  text,
const ROOT::Math::XYZVector &  pos 
)

Add a text label at the given position.

Definition at line 34 of file DisplayData.cc.

35{
36 m_labels.emplace_back(text, pos);
37}

◆ addPoint()

void addPoint ( const std::string &  name,
const ROOT::Math::XYZVector &  pos 
)

Add a point at the given position, as part of a collection specified by name.

All points with the same name will be highlighted when clicked etc.

Definition at line 29 of file DisplayData.cc.

30{
31 m_pointSets[name].push_back(pos);
32}

◆ select()

void select ( const TObject *  object)

Select the given object in the display.

Only has an effect if the object actually has a visualisation. Can be called multiple times to select more than one object.

Parameters
objectobject to select, must be inside a StoreArray

Definition at line 46 of file DisplayData.cc.

47{
48 //where is this thing stored?
49 DataStore::StoreEntry* storeEntry = nullptr;
50 int index = -1;
51 DataStore::Instance().findStoreEntry(object, storeEntry, index);
52
53 if (storeEntry) {
54 m_selectedObjects.emplace_back(storeEntry->name, index);
55 } else {
56 B2WARNING("DisplayData::select(): object must be part of a StoreArray!");
57 }
58}
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:398
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
std::vector< std::pair< std::string, unsigned int > > m_selectedObjects
List of selected objects (array name, index).
Definition: DisplayData.h:113
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: StoreEntry.h:22
std::string name
Name of the entry.
Definition: StoreEntry.h:53

Friends And Related Function Documentation

◆ DisplayUI

friend class DisplayUI
friend

Definition at line 118 of file DisplayData.h.

◆ EVEVisualization

friend class EVEVisualization
friend

Definition at line 119 of file DisplayData.h.

Member Data Documentation

◆ m_arrows

std::vector<Arrow> m_arrows
private

List of arrows.

Definition at line 114 of file DisplayData.h.

◆ m_histograms

std::vector<TH1*> m_histograms
private

Histograms to be shown in Eve.

Definition at line 111 of file DisplayData.h.

◆ m_labels

std::vector<std::pair<std::string, ROOT::Math::XYZVector> > m_labels
private

text labels (to be shown at a given position).

Definition at line 109 of file DisplayData.h.

◆ m_pointSets

std::map<std::string, std::vector<ROOT::Math::XYZVector> > m_pointSets
private

name -> points map

Definition at line 108 of file DisplayData.h.

◆ m_selectedObjects

std::vector<std::pair<std::string, unsigned int> > m_selectedObjects
private

List of selected objects (array name, index).

Definition at line 113 of file DisplayData.h.


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