Belle II Software  release-05-02-19
DisplayData.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Pulvermacher *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <framework/dataobjects/DisplayData.h>
11 
12 #include <framework/datastore/DataStore.h>
13 #include <framework/logging/Logger.h>
14 
15 using namespace Belle2;
16 
18 {
19  m_pointSets.clear();
20  m_labels.clear();
21  for (auto hist : m_histograms)
22  delete hist;
23  m_histograms.clear();
24 }
25 
26 void DisplayData::addArrow(const std::string& name, const TVector3& start, const TVector3& end, int color)
27 {
28  m_arrows.push_back(Arrow {name, start, end, color});
29 }
30 
31 void DisplayData::addPoint(const std::string& name, const TVector3& pos)
32 {
33  m_pointSets[name].push_back(pos);
34 }
35 
36 void DisplayData::addLabel(const std::string& text, const TVector3& pos)
37 {
38  m_labels.emplace_back(text, pos);
39 }
40 
41 void DisplayData::addHistogram(const std::string& name, const TH1* hist)
42 {
43  auto* newhist = static_cast<TH1*>(hist->Clone(name.c_str()));
44  newhist->SetDirectory(nullptr);
45  m_histograms.push_back(newhist);
46 }
47 
48 void DisplayData::select(const TObject* object)
49 {
50  //where is this thing stored?
51  DataStore::StoreEntry* storeEntry = nullptr;
52  int index = -1;
53  DataStore::Instance().findStoreEntry(object, storeEntry, index);
54 
55  if (storeEntry) {
56  m_selectedObjects.emplace_back(storeEntry->name, index);
57  } else {
58  B2WARNING("DisplayData::select(): object must be part of a StoreArray!");
59  }
60 }
Belle2::DisplayData::Arrow
Stores data associated with an arrow.
Definition: DisplayData.h:110
Belle2::DisplayData::m_labels
std::vector< std::pair< std::string, TVector3 > > m_labels
text labels (to be shown at a given position).
Definition: DisplayData.h:119
Belle2::DisplayData::m_histograms
std::vector< TH1 * > m_histograms
Histograms to be shown in Eve.
Definition: DisplayData.h:121
Belle2::DataStore::Instance
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
Belle2::DisplayData::addHistogram
void addHistogram(const std::string &name, const TH1 *hist)
Add histogram with the given name.
Definition: DisplayData.cc:41
Belle2::StoreEntry
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: StoreEntry.h:15
Belle2::DisplayData::addLabel
void addLabel(const std::string &text, const TVector3 &pos)
Add a text label at the given position.
Definition: DisplayData.cc:36
Belle2::DisplayData::addArrow
void addArrow(const std::string &name, const TVector3 &start, const TVector3 &end, int color=-1)
Add an arrow in the display (for axes, to point out some specific location).
Definition: DisplayData.cc:26
Belle2::StoreEntry::name
std::string name
Name of the entry.
Definition: StoreEntry.h:46
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DisplayData::m_arrows
std::vector< Arrow > m_arrows
List of arrows.
Definition: DisplayData.h:124
Belle2::DisplayData::m_pointSets
std::map< std::string, std::vector< TVector3 > > m_pointSets
name -> points map
Definition: DisplayData.h:118
Belle2::DataStore::findStoreEntry
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:398
Belle2::DisplayData::addPoint
void addPoint(const std::string &name, const TVector3 &pos)
Add a point at the given position, as part of a collection specified by name.
Definition: DisplayData.cc:31
Belle2::DisplayData::select
void select(const TObject *object)
Select the given object in the display.
Definition: DisplayData.cc:48
Belle2::DisplayData::m_selectedObjects
std::vector< std::pair< std::string, unsigned int > > m_selectedObjects
List of selected objects (array name, index).
Definition: DisplayData.h:123
Belle2::DisplayData::~DisplayData
~DisplayData()
Destructor.
Definition: DisplayData.cc:17