forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventManager.cxx
More file actions
140 lines (119 loc) · 3.49 KB
/
EventManager.cxx
File metadata and controls
140 lines (119 loc) · 3.49 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
// 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 EventManager.cxx
/// \author Jeremi Niedziela
#include "EventVisualisationView/EventManager.h"
#include "EventVisualisationDataConverter/MinimalisticEvent.h"
#include "EventVisualisationBase/ConfigurationManager.h"
#include "EventVisualisationBase/DataSource.h"
#include "EventVisualisationBase/DataInterpreter.h"
#include "EventVisualisationBase/EventRegistration.h"
#include <EventVisualisationBase/DataSourceOffline.h>
#include <EventVisualisationDetectors/DataReaderVSD.h>
#include <TEveManager.h>
#include <TEveProjectionManager.h>
#include <TSystem.h>
#include <TEnv.h>
#include <TEveElement.h>
#include <TGListTree.h>
#include <iostream>
using namespace std;
namespace o2
{
namespace event_visualisation
{
EventManager* EventManager::instance = nullptr;
EventManager& EventManager::getInstance()
{
instance = new EventManager();
return *instance;
}
EventManager::EventManager() : TEveEventManager("Event", "")
{
}
void EventManager::Open()
{
switch (mCurrentDataSourceType) {
case SourceOnline:
break;
case SourceOffline: {
DataSourceOffline* source = new DataSourceOffline();
if (DataInterpreter::getInstance(EVisualisationGroup::VSD)) {
DataReader* vsd = new DataReaderVSD();
vsd->open();
source->registerReader(vsd, EVisualisationGroup::VSD);
}
if (DataInterpreter::getInstance(EVisualisationGroup::RND)) {
source->registerReader(nullptr, EVisualisationGroup::RND); // no need to read
}
setDataSource(source);
} break;
case SourceHLT:
break;
}
}
void EventManager::GotoEvent(Int_t no)
{
//-1 means last event
if (no == -1) {
no = getDataSource()->GetEventCount() - 1;
}
this->currentEvent = no;
EventRegistration::getInstance()->destroyAllEvents();
for (int i = 0; i < EVisualisationGroup::NvisualisationGroups; i++) {
DataInterpreter* interpreter = DataInterpreter::getInstance((EVisualisationGroup)i);
if (interpreter) {
TObject* data = getDataSource()->getEventData(no, (EVisualisationGroup)i);
TEveElement* eveElement = interpreter->interpretDataForType(data, NoData);
EventRegistration::getInstance()->registerElement(eveElement);
}
}
}
void EventManager::NextEvent()
{
Int_t event = (this->currentEvent + 1) % getDataSource()->GetEventCount();
GotoEvent(event);
}
void EventManager::PrevEvent()
{
GotoEvent(this->currentEvent - 1);
}
void EventManager::Close()
{
delete this->dataSource;
this->dataSource = nullptr;
}
void EventManager::AfterNewEventLoaded()
{
TEveEventManager::AfterNewEventLoaded();
}
void EventManager::AddNewEventCommand(const TString& cmd)
{
TEveEventManager::AddNewEventCommand(cmd);
}
void EventManager::RemoveNewEventCommand(const TString& cmd)
{
TEveEventManager::RemoveNewEventCommand(cmd);
}
void EventManager::ClearNewEventCommands()
{
TEveEventManager::ClearNewEventCommands();
}
EventManager::~EventManager()
{
instance = nullptr;
}
void EventManager::DropEvent()
{
DestroyElements();
}
} // namespace event_visualisation
} // namespace o2