Belle II Software development
DisplayData.cc
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#include <framework/dataobjects/DisplayData.h>
9
10#include <framework/datastore/DataStore.h>
11#include <framework/logging/Logger.h>
12
13using namespace Belle2;
14
16{
17 m_pointSets.clear();
18 m_labels.clear();
19 for (auto hist : m_histograms)
20 delete hist;
21 m_histograms.clear();
22}
23
24void DisplayData::addArrow(const std::string& name, const ROOT::Math::XYZVector& start, const ROOT::Math::XYZVector& end, int color)
25{
26 m_arrows.push_back(Arrow {name, start, end, color});
27}
28
29void DisplayData::addPoint(const std::string& name, const ROOT::Math::XYZVector& pos)
30{
31 m_pointSets[name].push_back(pos);
32}
33
34void DisplayData::addLabel(const std::string& text, const ROOT::Math::XYZVector& pos)
35{
36 m_labels.emplace_back(text, pos);
37}
38
39void DisplayData::addHistogram(const std::string& name, const TH1* hist)
40{
41 auto* newhist = static_cast<TH1*>(hist->Clone(name.c_str()));
42 newhist->SetDirectory(nullptr);
43 m_histograms.push_back(newhist);
44}
45
46void DisplayData::select(const TObject* object)
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
void select(const TObject *object)
Select the given object in the display.
Definition: DisplayData.cc:46
void addHistogram(const std::string &name, const TH1 *hist)
Add histogram with the given name.
Definition: DisplayData.cc:39
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.
Definition: DisplayData.cc:29
std::vector< TH1 * > m_histograms
Histograms to be shown in Eve.
Definition: DisplayData.h:111
std::vector< Arrow > m_arrows
List of arrows.
Definition: DisplayData.h:114
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).
Definition: DisplayData.cc:24
void addLabel(const std::string &text, const ROOT::Math::XYZVector &pos)
Add a text label at the given position.
Definition: DisplayData.cc:34
std::map< std::string, std::vector< ROOT::Math::XYZVector > > m_pointSets
name -> points map
Definition: DisplayData.h:108
std::vector< std::pair< std::string, unsigned int > > m_selectedObjects
List of selected objects (array name, index).
Definition: DisplayData.h:113
std::vector< std::pair< std::string, ROOT::Math::XYZVector > > m_labels
text labels (to be shown at a given position).
Definition: DisplayData.h:109
~DisplayData()
Destructor.
Definition: DisplayData.cc:15
Abstract base class for different kinds of events.
Stores data associated with an arrow.
Definition: DisplayData.h:100
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