forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataInterpreterTPC.cxx
More file actions
146 lines (120 loc) · 5.31 KB
/
DataInterpreterTPC.cxx
File metadata and controls
146 lines (120 loc) · 5.31 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
// 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 DataInterpreterTPC.cxx
/// \brief converting TPC data to Event Visualisation primitives
/// \author julian.myrcha@cern.ch
/// \author p.nowakowski@cern.ch
#include "EventVisualisationDataConverter/VisualisationCluster.h"
#include "EventVisualisationDetectors/DataInterpreterTPC.h"
#include "EventVisualisationBase/ConfigurationManager.h"
#include "EventVisualisationDataConverter/VisualisationEvent.h"
#include <TEveManager.h>
#include <TEveTrackPropagator.h>
#include <TEveTrack.h>
#include <TGListTree.h>
#include <TFile.h>
#include <TTree.h>
#include <TVector2.h>
#include "TPCBase/Mapper.h"
#include "DataFormatsTPC/TrackTPC.h"
#include "DataFormatsTPC/ClusterNative.h"
#include "DataFormatsTPC/ClusterNativeHelper.h"
#include <iostream>
#include <gsl/span>
namespace o2
{
namespace event_visualisation
{
DataInterpreterTPC::~DataInterpreterTPC() = default;
VisualisationEvent DataInterpreterTPC::interpretDataForType(TObject* data, EVisualisationDataType type)
{
TList* list = (TList*)data;
// Int_t event = ((TVector2*)list->At(2))->X();
VisualisationEvent ret_event({.eventNumber = 0,
.runNumber = 0,
.energy = 0,
.multiplicity = 0,
.collidingSystem = "",
.timeStamp = 0});
if (type == Clusters) {
TFile* clustFile = (TFile*)list->At(1);
//Why cannot TPC clusters be read like other clusters?
auto reader = new tpc::ClusterNativeHelper::Reader();
reader->init(clustFile->GetName());
reader->read(0);
auto access = std::make_unique<o2::tpc::ClusterNativeAccess>();
std::unique_ptr<tpc::ClusterNative[]> clusterBuffer;
tpc::ClusterNativeHelper::ConstMCLabelContainerViewWithBuffer clusterMCBuffer;
reader->fillIndex(*access, clusterBuffer, clusterMCBuffer);
const auto& mapper = tpc::Mapper::instance();
const auto& clusterRefs = access->clusters;
for (int sector = 0; sector < o2::tpc::constants::MAXSECTOR; sector++) {
for (int row = 0; row < o2::tpc::constants::MAXGLOBALPADROW; row++) {
const auto& c = clusterRefs[sector][row];
const auto pad = mapper.globalPadNumber(tpc::PadPos(row, c->getPad()));
const tpc::LocalPosition3D localXYZ(mapper.padCentre(pad).X(), mapper.padCentre(pad).Y(), c->getTime());
const auto globalXYZ = mapper.LocalToGlobal(localXYZ, sector);
double xyz[3] = {globalXYZ.X(), globalXYZ.Y(), globalXYZ.Z()};
ret_event.addCluster(xyz);
}
}
} else if (type == ESD) {
TFile* trackFile = (TFile*)list->At(0);
TTree* tracks = (TTree*)trackFile->Get("tpcrec");
//Read all tracks to a buffer
std::vector<tpc::TrackTPC>* trkArr = nullptr;
tracks->SetBranchAddress("TPCTracks", &trkArr);
tracks->GetEntry(0);
TEveTrackList* trackList = new TEveTrackList("tracks");
trackList->IncDenyDestroy();
auto prop = trackList->GetPropagator();
prop->SetMagField(0.5);
int first, last;
first = 0;
last = trkArr->size();
gsl::span<tpc::TrackTPC> mTracks = gsl::make_span(&(*trkArr)[first], last - first);
for (const auto& rec : mTracks) {
std::array<float, 3> p;
rec.getPxPyPzGlo(p);
TEveRecTrackD t;
t.fP = {p[0], p[1], p[2]};
t.fSign = (rec.getSign() < 0) ? -1 : 1;
TEveTrack* eve_track = new TEveTrack(&t, prop);
eve_track->MakeTrack();
auto start = eve_track->GetLineStart();
auto end = eve_track->GetLineEnd();
VisualisationTrack* track = ret_event.addTrack({.charge = rec.getSign(),
.energy = 0.0,
.ID = 0,
.PID = 0,
.mass = 0.0,
.signedPT = 0.0,
.startXYZ = {start.fX, start.fY, start.fZ},
.endXYZ = {end.fX, end.fY, end.fZ},
.pxpypz = {p[0], p[1], p[2]},
.parentID = 0,
.phi = 0.0,
.theta = 0.0,
.helixCurvature = 0.0,
.type = 0,
.source = TPCSource});
for (Int_t i = 0; i < eve_track->GetN(); ++i) {
Float_t x, y, z;
eve_track->GetPoint(i, x, y, z);
track->addPolyPoint(x, y, z);
}
delete eve_track;
}
delete trackList;
}
return ret_event;
}
} // namespace event_visualisation
} // namespace o2