forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataInterpreterVSD.cxx
More file actions
158 lines (125 loc) · 4.17 KB
/
Copy pathDataInterpreterVSD.cxx
File metadata and controls
158 lines (125 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file DataInterpreterVSD.cxx
/// \brief converting VSD data to Event Visualisation primitives
/// \author julian.myrcha@cern.ch
/// \author p.nowakowski@cern.ch
///
/// \file DataInterpreterVSD.cxx
/// \author Julian Myrcha
#include "EventVisualisationDetectors/DataInterpreterVSD.h"
#include "EventVisualisationBase/ConfigurationManager.h"
#include "EventVisualisationDataConverter/VisualisationEvent.h"
#include <TEveManager.h>
#include <TEveTrackPropagator.h>
#include <TGListTree.h>
using namespace std;
namespace o2
{
namespace event_visualisation
{
DataInterpreterVSD::~DataInterpreterVSD()
{
//this->DropEvent();
if (mVSD) {
delete mVSD;
mVSD = nullptr;
}
}
std::unique_ptr<VisualisationEvent> DataInterpreterVSD::interpretDataForType(TObject* data, EVisualisationDataType type)
{
if (mVSD == nullptr)
mVSD = new TEveVSD;
this->DropEvent();
// Connect to new event-data.
this->mDirectory = dynamic_cast<TDirectory*>(data);
this->mVSD->SetDirectory(this->mDirectory);
this->AttachEvent();
auto ret_event = std::make_unique<VisualisationEvent>(0, 0, 0, 0, "", 0);
// Load event data into visualization structures.
// this->LoadClusters(this->fITSClusters, "ITS", 0);
// this->LoadClusters(this->fTPCClusters, "TPC", 1);
// this->LoadClusters(this->fTRDClusters, "TRD", 2);
// this->LoadClusters(this->fTOFClusters, "TOF", 3);
if (type == ESD) {
LoadEsdTracks(*ret_event);
}
return ret_event;
}
void DataInterpreterVSD::LoadClusters(TEvePointSet*& ps, const TString& det_name, Int_t det_id)
{
if (ps == nullptr) {
ps = new TEvePointSet(det_name);
ps->SetMainColor((Color_t)(det_id + 2));
ps->SetMarkerSize(0.5);
ps->SetMarkerStyle(2);
ps->IncDenyDestroy();
} else {
ps->Reset();
}
//TEvePointSelector ss(fVSD->fTreeC, ps, "fV.fX:fV.fY:fV.fZ", TString::Format("fDetId==%d", det_id));
//ss.Select();
ps->SetTitle(TString::Format("N=%d", ps->Size()));
gEve->AddElement(ps);
}
void DataInterpreterVSD::AttachEvent()
{
// Attach event data from current directory.
mVSD->LoadTrees();
mVSD->SetBranchAddresses();
}
void DataInterpreterVSD::DropEvent()
{
assert(mVSD != nullptr);
// Drop currently held event data, release current directory.
// Drop old visualization structures.
this->mViewers = gEve->GetViewers();
this->mViewers->DeleteAnnotations();
//TEveEventManager *manager = gEve->GetCurrentEvent();
//assert(manager != nullptr);
//manager->DestroyElements();
// Drop old event-data.
mVSD->DeleteTrees();
delete mDirectory;
mDirectory = nullptr;
}
void DataInterpreterVSD::LoadEsdTracks(VisualisationEvent& /*event*/)
{
// Read reconstructed tracks from current event.
if (mTrackList == nullptr) {
mTrackList = new TEveTrackList("ESD Tracks");
mTrackList->SetMainColor(6);
mTrackList->SetMarkerColor(kYellow);
mTrackList->SetMarkerStyle(4);
mTrackList->SetMarkerSize(0.5);
mTrackList->SetLineWidth(1);
mTrackList->IncDenyDestroy();
} else {
mTrackList->DestroyElements();
}
TEveTrackPropagator* trkProp = mTrackList->GetPropagator();
// !!!! Need to store field on file !!!!
// Can store TEveMagField ?
trkProp->SetMagField(0.5);
trkProp->SetStepper(TEveTrackPropagator::kRungeKutta);
Int_t nTracks = mVSD->fTreeR->GetEntries();
for (Int_t n = 0; n < nTracks; n++) {
mVSD->fTreeR->GetEntry(n);
auto* track = new TEveTrack(&mVSD->fR, trkProp);
track->SetAttLineAttMarker(mTrackList);
track->SetName(Form("ESD Track %d", mVSD->fR.fIndex));
track->SetStdTitle();
track->SetAttLineAttMarker(mTrackList);
mTrackList->AddElement(track);
}
mTrackList->MakeTracks();
}
} // namespace event_visualisation
} // namespace o2