Belle II Software development
Belle2::ObjectInfo Namespace Reference

Return information on objects, for use by InfoWidget, Eve titles (popups) etc. More...

Functions

TString getName (const TObject *obj)
 human-readable name (e.g.
 
TString getIdentifier (const TObject *obj)
 Where is this object in the datastore?
 
TString getInfo (const TObject *obj)
 Get object info HTML (e.g.
 
TString getTitle (const TObject *obj)
 Get plain text for TEve object titles (shown on mouse-over).
 
std::pair< std::string, int > getDataStorePosition (const TObject *obj)
 return entry name & index for arrays, with index = -1 for objects.
 

Detailed Description

Return information on objects, for use by InfoWidget, Eve titles (popups) etc.

Expands on RelationsObject::getInfoHTML()/getName() by also providing info on e.g. genfit2::Track objects.

Function Documentation

◆ getDataStorePosition()

std::pair< std::string, int > getDataStorePosition ( const TObject *  obj)

return entry name & index for arrays, with index = -1 for objects.

Definition at line 78 of file ObjectInfo.cc.

79{
80 std::string name;
81 int index = -1;
82 if (const RelationsObject* relObj = dynamic_cast<const RelationsObject*>(obj)) {
83 name = relObj->getArrayName();
84 index = relObj->getArrayIndex();
85 } else {
86 //somewhat manual way to find location of object (might not inherit from RelationInterface)
87 DataStore::StoreEntry* entry = nullptr;
88 DataStore::Instance().findStoreEntry(obj, entry, index);
89 if (entry)
90 name = entry->name;
91 }
92 if (index == -1) {
93 //this thing might be in a StoreObjPtr...
94 for (const auto& pair : DataStore::Instance().getStoreEntryMap(DataStore::c_Event)) {
95 if (pair.second.object == obj) {
96 name = pair.second.name;
97 break;
98 }
99 }
100 }
101
102 return std::make_pair(name, index);
103}
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:398
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
Defines interface for accessing relations of objects in StoreArray.
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

◆ getIdentifier()

TString getIdentifier ( const TObject *  obj)

Where is this object in the datastore?

Definition at line 105 of file ObjectInfo.cc.

106{
107 auto pos = getDataStorePosition(obj);
108 if (pos.second != -1)
109 return TString::Format("%s[%d]", pos.first.c_str(), pos.second);
110 return pos.first;
111}
std::pair< std::string, int > getDataStorePosition(const TObject *obj)
return entry name & index for arrays, with index = -1 for objects.
Definition: ObjectInfo.cc:78

◆ getInfo()

TString getInfo ( const TObject *  obj)

Get object info HTML (e.g.

via RelationsObject::getInfoHTML()).

Definition at line 55 of file ObjectInfo.cc.

56{
57 if (!obj)
58 B2ERROR("ObjectInfo::getInfo() got null?");
59 if (auto relObj = dynamic_cast<const RelationsObject*>(obj)) {
60 return relObj->getInfoHTML();
61 } else if (auto vertex = dynamic_cast<const genfit::GFRaveVertex*>(obj)) {
62 return "<b>V</b>=" + HTML::getString(ROOT::Math::XYZVector(vertex->getPos())) + "<br>" +
63 TString::Format("pVal=%e", TMath::Prob(vertex->getChi2(), vertex->getNdf()));
64 }
65 return callStringMethod(obj, "getInfoHTML");
66}
std::string getString(const TMatrixFBase &matrix, int precision=2, bool color=true)
get HTML table representing a matrix.
Definition: HTML.cc:24

◆ getName()

TString getName ( const TObject *  obj)

human-readable name (e.g.

pi+)

Definition at line 45 of file ObjectInfo.cc.

46{
47 if (!obj)
48 B2ERROR("ObjectInfo::getName() got null?");
49 if (const RelationsObject* relObj = dynamic_cast<const RelationsObject*>(obj)) {
50 return relObj->getName();
51 }
52 return callStringMethod(obj, "getName");
53}

◆ getTitle()

TString getTitle ( const TObject *  obj)

Get plain text for TEve object titles (shown on mouse-over).

Definition at line 68 of file ObjectInfo.cc.

69{
70 TString out(getIdentifier(obj));
71 const TString& name = getName(obj);
72 if (name.Length() != 0)
73 out += " - " + name;
74
75 return out + "\n" + HTML::htmlToPlainText(getInfo(obj).Data()).c_str();
76}
std::string htmlToPlainText(const std::string &html)
Reformat given HTML string into terminal-friendly plain text.
Definition: HTML.cc:138
TString getName(const TObject *obj)
human-readable name (e.g.
Definition: ObjectInfo.cc:45
TString getIdentifier(const TObject *obj)
Where is this object in the datastore?
Definition: ObjectInfo.cc:105
TString getInfo(const TObject *obj)
Get object info HTML (e.g.
Definition: ObjectInfo.cc:55