Skip to content

Commit 1e308ef

Browse files
authored
Merge pull request AliceO2Group#7511 from jmyrcha/dev1
o2-eve: storing track time and track gid
1 parent a9f7e65 commit 1e308ef

8 files changed

Lines changed: 72 additions & 27 deletions

File tree

EventVisualisation/Base/src/DataSourceOnline.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ std::vector<std::pair<VisualisationEvent, EVisualisationGroup>> DataSourceOnline
3636

3737
mFileWatcher.setCurrentItem(no);
3838
VisualisationEvent vEvent = this->mDataReader->getEvent(mFileWatcher.currentFilePath());
39-
/*
39+
4040
for(auto filter = EVisualisationGroup::ITS;
4141
filter != EVisualisationGroup::NvisualisationGroups;
4242
filter = static_cast<EVisualisationGroup>(static_cast<int>(filter) + 1)) {
4343
auto filtered = VisualisationEvent(vEvent, filter);
4444
res.push_back(std::make_pair(filtered, filter)); // we can switch on/off data
4545
}
46-
*/
47-
res.push_back(std::make_pair(vEvent, EVisualisationGroup::TPC)); // temporary
46+
47+
//res.push_back(std::make_pair(vEvent, EVisualisationGroup::ITS)); // temporary
48+
//res.push_back(std::make_pair(vEvent, EVisualisationGroup::TPC)); // temporary
4849
}
4950
return res;
5051
}

EventVisualisation/DataConverter/include/EventVisualisationDataConverter/VisualisationEvent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \file VisualisationEvent.h
1414
/// \author Jeremi Niedziela
1515
/// \author Maciej Grochowicz
16+
/// \author Julian Myrcha
1617
///
1718

1819
#ifndef ALICE_O2_EVENTVISUALISATION_BASE_VISUALISATIONEVENT_H

EventVisualisation/DataConverter/include/EventVisualisationDataConverter/VisualisationTrack.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ class VisualisationTrack
6363
float phi = 0;
6464
float theta = 0;
6565
float eta = 0;
66+
std::string gid = "";
6667
o2::dataformats::GlobalTrackID::Source source;
6768
};
6869
// Constructor with properties initialisation
6970
VisualisationTrack(const VisualisationTrackVO& vo);
7071

72+
VisualisationTrack(const VisualisationTrack& src);
73+
7174
// Add child particle (coming from decay of this particle)
7275
void addChild(int childID);
7376
// Add xyz coordinates of the point along the track
@@ -79,6 +82,8 @@ class VisualisationTrack
7982
// PID (particle identification code) getter
8083
int getPID() const { return mPID; }
8184
// GID getter
85+
std::string getGIDAsString() const { return mGID; }
86+
// Source Getter
8287
o2::dataformats::GlobalTrackID::Source getSource() const { return mSource; }
8388
// Phi getter
8489
float getPhi() const { return mPhi; }
@@ -101,6 +106,7 @@ class VisualisationTrack
101106
int mCharge; /// Charge of the particle
102107

103108
int mPID; /// PDG code of the particle
109+
std::string mGID; /// String representation of gid
104110

105111
float mStartCoordinates[3]; /// Vector of track's start coordinates
106112

@@ -121,4 +127,4 @@ class VisualisationTrack
121127

122128
} // namespace event_visualisation
123129
} // namespace o2
124-
#endif // ALICE_O2_EVENTVISUALISATION_BASE_VISUALISATIONTRACK_H
130+
#endif // ALICE_O2_EVENTVISUALISATION_BASE_VISUALISATIONTRACK_H

EventVisualisation/DataConverter/src/VisualisationEvent.cxx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ std::string VisualisationEvent::toJson()
101101

102102
// compatibility verification
103103
tree.AddMember("fileVersion", rapidjson::Value().SetInt(JSON_FILE_VERSION), allocator);
104-
//tree.AddMember("timeStamp", rapidjson::Value().SetFloat(this->mTimeStamp), allocator);
104+
tree.AddMember("timeStamp", rapidjson::Value().SetFloat(this->mTimeStamp), allocator);
105105
tree.AddMember("workflowVersion", rapidjson::Value().SetFloat(this->mWorkflowVersion), allocator);
106106
tree.AddMember("workflowParameters", rapidjson::Value().SetString(this->mWorkflowParameters.c_str(), this->mWorkflowParameters.size()), allocator);
107107
// Tracks
@@ -140,17 +140,13 @@ VisualisationEvent::VisualisationEvent(const VisualisationEvent& source, EVisual
140140
{
141141
for (auto it = source.mTracks.begin(); it != source.mTracks.end(); ++it) {
142142
if (VisualisationEvent::mVis.contains[it->getSource()][filter]) {
143-
this->addTrack({.time = it->getTime(),
144-
.charge = it->getCharge(),
145-
.PID = it->getPID(),
146-
.startXYZ = {
147-
it->getStartCoordinates()[0], it->getStartCoordinates()[1], it->getStartCoordinates()[2]},
148-
.phi = it->getPhi(),
149-
.theta = it->getTheta(),
150-
.source = it->getSource()});
143+
this->mTracks.push_back(*it);
151144
}
152145
}
153146
for (auto it = source.mClusters.begin(); it != source.mClusters.end(); ++it) {
147+
if (VisualisationEvent::mVis.contains[it->getSource()][filter]) {
148+
this->mClusters.push_back(*it);
149+
}
154150
}
155151
}
156152

EventVisualisation/DataConverter/src/VisualisationTrack.cxx

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
///
1818

1919
#include "EventVisualisationDataConverter/VisualisationTrack.h"
20+
#include "FairLogger.h"
2021

2122
using namespace std;
2223

@@ -31,11 +32,30 @@ VisualisationTrack::VisualisationTrack(const VisualisationTrackVO& vo)
3132
{
3233
this->mCharge = vo.charge;
3334
this->mPID = vo.PID;
35+
this->mGID = vo.gid;
3436
this->mTheta = vo.theta;
3537
this->mPhi = vo.phi;
38+
this->mEta = vo.eta;
3639
this->addStartCoordinates(vo.startXYZ);
3740
this->mSource = vo.source;
38-
this->mEta = vo.eta;
41+
this->mTime = vo.time;
42+
}
43+
44+
VisualisationTrack::VisualisationTrack(const VisualisationTrack& src)
45+
{
46+
this->mCharge = src.mCharge;
47+
this->mPID = src.mPID;
48+
this->mGID = src.mGID;
49+
this->mTheta = src.mTheta;
50+
this->mPhi = src.mPhi;
51+
this->mEta = src.mEta;
52+
this->addStartCoordinates(src.getStartCoordinates());
53+
this->mSource = src.mSource;
54+
this->mPolyX = src.mPolyX;
55+
this->mPolyY = src.mPolyY;
56+
this->mPolyZ = src.mPolyZ;
57+
this->mClusters = src.mClusters;
58+
this->mTime = src.mTime;
3959
}
4060

4161
void VisualisationTrack::addStartCoordinates(const float xyz[3])
@@ -67,7 +87,12 @@ VisualisationTrack::VisualisationTrack(rapidjson::Value& tree)
6787
this->mSource = o2::dataformats::GlobalTrackID::TPC; // temporary
6888
}
6989
this->mPID = (o2::dataformats::GlobalTrackID::Source)tree["source"].GetInt();
70-
//this->mTime = (o2::dataformats::GlobalTrackID::Source)tree["time"].GetFloat();
90+
this->mTime = (o2::dataformats::GlobalTrackID::Source)tree["time"].GetFloat();
91+
if (tree.HasMember("gid")) {
92+
this->mGID = tree["gid"].GetString();
93+
} else {
94+
this->mGID = "track";
95+
}
7196
this->mPolyX.reserve(count.GetInt());
7297
this->mPolyY.reserve(count.GetInt());
7398
this->mPolyZ.reserve(count.GetInt());
@@ -100,11 +125,14 @@ rapidjson::Value VisualisationTrack::jsonTree(rapidjson::Document::AllocatorType
100125

101126
tree.AddMember("count", rapidjson::Value().SetInt(this->getPointCount()), allocator);
102127
tree.AddMember("source", rapidjson::Value().SetInt(this->mSource), allocator);
103-
//tree.AddMember("time", rapidjson::Value().SetFloat(this->mTime), allocator);
104-
//tree.AddMember("charge", rapidjson::Value().SetInt(this->mCharge), allocator);
105-
//tree.AddMember("theta", rapidjson::Value().SetFloat(this->mTheta), allocator);
106-
//tree.AddMember("phi", rapidjson::Value().SetFloat(this->mPhi), allocator);
107-
//tree.AddMember("eta", rapidjson::Value().SetFloat(this->mEta), allocator);
128+
rapidjson::Value gid;
129+
gid.SetString(this->mGID.c_str(), this->mGID.size(), allocator);
130+
tree.AddMember("gid", gid, allocator);
131+
tree.AddMember("time", rapidjson::Value().SetFloat(isnan(this->mTime) ? 0 : this->mTime), allocator);
132+
tree.AddMember("charge", rapidjson::Value().SetInt(this->mCharge), allocator);
133+
tree.AddMember("theta", rapidjson::Value().SetFloat(isnan(this->mTheta) ? 0 : this->mTheta), allocator);
134+
tree.AddMember("phi", rapidjson::Value().SetFloat(isnan(this->mPhi) ? 0 : this->mPhi), allocator);
135+
tree.AddMember("eta", rapidjson::Value().SetFloat(isnan(this->mEta) ? 0 : this->mEta), allocator);
108136
tree.AddMember("PID", rapidjson::Value().SetInt(this->mPID), allocator);
109137

110138
jsonStartCoordinates.PushBack((float)mStartCoordinates[0], allocator);

EventVisualisation/View/src/EventManager.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ void EventManager::displayCurrentEvent()
7373

7474
auto displayList = getDataSource()->getVisualisationList(no);
7575
for (auto it = displayList.begin(); it != displayList.end(); ++it) {
76-
77-
//if (it->second == EVisualisationGroup::TPC) { // temporary
7876
displayVisualisationEvent(it->first, gVisualisationGroupName[it->second]);
79-
//}
8077
}
8178

8279
for (int i = 0; i < EVisualisationDataType::NdataTypes; ++i) {
@@ -162,7 +159,7 @@ void EventManager::displayVisualisationEvent(VisualisationEvent& event, const st
162159
// clusters
163160
size_t clusterCount = 0;
164161
auto* point_list = new TEvePointSet(detectorName.c_str());
165-
point_list->IncDenyDestroy();
162+
point_list->IncDenyDestroy(); // don't delete if zero parent
166163
point_list->SetMarkerColor(kBlue);
167164

168165
for (size_t i = 0; i < trackCount; ++i) {
@@ -173,6 +170,8 @@ void EventManager::displayVisualisationEvent(VisualisationEvent& event, const st
173170
t.fSign = track.getCharge() > 0 ? 1 : -1;
174171
auto* vistrack = new TEveTrack(&t, &TEveTrackPropagator::fgDefault);
175172
vistrack->SetLineColor(kMagenta);
173+
//vistrack->SetName(detectorName + " track: " + i);
174+
vistrack->SetName(track.getGIDAsString().c_str());
176175
size_t pointCount = track.getPointCount();
177176
vistrack->Reset(pointCount);
178177

EventVisualisation/View/src/Initializer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void Initializer::setup()
9191
// Temporary:
9292
// Later this will be triggered by button, and finally moved to configuration.
9393
gEve->AddEvent(&EventManager::getInstance());
94-
eventManager.getDataSource()->refresh();
94+
//eventManager.getDataSource()->refresh();
9595

9696
if (Options::Instance()->online()) {
9797
frame->StartTimer();

EventVisualisation/Workflow/src/EveWorkflowHelper.cxx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void EveWorkflowHelper::draw(const std::string& jsonPath, int numberOfFiles, int
5757
for (size_t it = 0; it < nTracks; it++) {
5858
const auto& gid = mTrackSet.trackGID[it];
5959
auto tim = mTrackSet.trackTime[it];
60-
// LOG(INFO) << "EveWorkflowHelper::draw " << gid.getSource();
60+
//LOG(INFO) << "EveWorkflowHelper::draw " << gid.asString();
6161
switch (gid.getSource()) {
6262
case GID::TPC:
6363
drawTPC(gid, tim);
@@ -163,6 +163,7 @@ void EveWorkflowHelper::addTrackToEvent(const o2::track::TrackParCov& tr, GID gi
163163
.phi = tr.getPhi(),
164164
.theta = tr.getTheta(),
165165
.eta = tr.getEta(),
166+
.gid = gid.asString(),
166167
.source = (o2::dataformats::GlobalTrackID::Source)gid.getSource()});
167168
auto pnts = getTrackPoints(tr, minmaxR[gid.getSource()].first, minmaxR[gid.getSource()].second, 4);
168169

@@ -352,6 +353,7 @@ void EveWorkflowHelper::drawTPC(GID gid, float trackTime)
352353
.phi = tr.getPhi(),
353354
.theta = tr.getTheta(),
354355
.eta = tr.getEta(),
356+
.gid = gid.asString(),
355357
.source = GID::TPC});
356358
auto pnts = getTrackPoints(tr, minmaxR[gid.getSource()].first, minmaxR[gid.getSource()].second, 4, -250, 250);
357359
float dz = 0.0;
@@ -371,8 +373,9 @@ void EveWorkflowHelper::drawITS(GID gid, float trackTime)
371373
.phi = tr.getPhi(),
372374
.theta = tr.getTheta(),
373375
.eta = tr.getEta(),
376+
.gid = gid.asString(),
374377
.source = GID::ITS});
375-
auto pnts = getTrackPoints(tr, minmaxR[gid.getSource()].first, minmaxR[gid.getSource()].second, 0.1, -250, 250);
378+
auto pnts = getTrackPoints(tr, minmaxR[gid.getSource()].first, minmaxR[gid.getSource()].second, 1.0, -250, 250);
376379
float dz = 0.0;
377380
for (size_t ip = 0; ip < pnts.size(); ip++) {
378381
vTrack->addPolyPoint(pnts[ip][0], pnts[ip][1], pnts[ip][2] + dz);
@@ -394,6 +397,8 @@ void EveWorkflowHelper::drawMFT(GID gid, float trackTime)
394397
.startXYZ = {(float)tr.getX(), (float)tr.getY(), (float)tr.getZ()},
395398
.phi = (float)tr.getPhi(),
396399
.theta = (float)tr.getTanl(),
400+
.eta = (float)0,
401+
.gid = gid.asString(),
397402
.source = GID::MFT});
398403
for (auto zPos : zPositions) {
399404
tr.propagateToZlinear(zPos);
@@ -412,8 +417,13 @@ void EveWorkflowHelper::drawMCH(GID gid, float trackTime)
412417
const auto& mchClusters = mRecoCont.getMCHTrackClusters(); // list of references to clusters, offset:offset+no
413418

414419
auto vTrack = mEvent.addTrack({.time = static_cast<float>(trackTime),
420+
.charge = 0,
415421
.PID = o2::track::PID::Muon,
416422
.startXYZ = {(float)track.getX(), (float)track.getY(), (float)track.getZ()},
423+
.phi = (float)0,
424+
.theta = (float)0,
425+
.eta = (float)0,
426+
.gid = gid.asString(),
417427
.source = GID::MCH});
418428

419429
for (int icl = noOfClusters - 1; icl > -1; --icl) {
@@ -445,6 +455,10 @@ void EveWorkflowHelper::drawMID(GID gid, float trackTime)
445455
.charge = (int)0,
446456
.PID = o2::track::PID::Muon,
447457
.startXYZ = {(float)midTrack.getPositionX(), (float)midTrack.getPositionY(), (float)midTrack.getPositionZ()},
458+
.phi = (float)0,
459+
.theta = (float)0,
460+
.eta = (float)0,
461+
.gid = gid.asString(),
448462
.source = GID::MID});
449463

450464
for (int ich = 0; ich < 4; ++ich) {

0 commit comments

Comments
 (0)