Project
Loading...
Searching...
No Matches
DataSourceOnline.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
17
18#include <TSystem.h>
19#include <TEveTreeTools.h>
20#include <TEveTrack.h>
21#include <TEveManager.h>
22#include <TFile.h>
23#include <TPRegexp.h>
24#include <TObject.h>
25#include <filesystem>
26#include <chrono>
27#include <fairlogger/Logger.h>
28
29namespace o2
30{
31namespace event_visualisation
32{
33std::vector<std::string> DataSourceOnline::sourceFilextensions = {".json", ".root", ".eve"};
34
35std::vector<std::pair<VisualisationEvent, EVisualisationGroup>>
36 DataSourceOnline::getVisualisationList(int no, float minTime, float maxTime, float range)
37{
38 auto start = std::chrono::high_resolution_clock::now();
39
40 std::vector<std::pair<VisualisationEvent, EVisualisationGroup>> res;
41 if (getEventCount() == 2) {
42 this->setRunNumber(-1); // No available data to display
43 return res; // 2 means there are no real data = we have only "virtual" positions
44 }
45 if (no < getEventCount()) {
46 assert(no >= 0);
47
50
51 this->setRunNumber(vEvent.getRunNumber());
52 this->setRunType(vEvent.getRunType());
53 this->setFirstTForbit(vEvent.getFirstTForbit());
54 this->setCreationTime(vEvent.getCreationTime());
55
56 this->setTrackMask(vEvent.getTrkMask());
57 this->setClusterMask(vEvent.getClMask());
58
59 auto write_time = std::filesystem::last_write_time(mFileWatcher.currentFilePath());
60 auto duration = std::chrono::time_point_cast<std::chrono::system_clock::duration>(
61 write_time - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now());
62 auto duration_time = std::chrono::system_clock::to_time_t(duration);
63
64 char time_str[100];
65 std::strftime(time_str, sizeof(time_str), "%a %b %d %H:%M:%S %Y", std::localtime(&duration_time));
66
67 this->setFileTime(time_str);
68
69 double period = vEvent.getMaxTimeOfTracks() - vEvent.getMinTimeOfTracks();
70 if (period > 0) {
71 this->mTimeFrameMinTrackTime = minTime * period / range + vEvent.getMinTimeOfTracks();
72 this->mTimeFrameMaxTrackTime = maxTime * period / range + vEvent.getMinTimeOfTracks();
73 } else {
76 }
77
80 filter = static_cast<EVisualisationGroup>(static_cast<int>(filter) + 1)) {
81 auto filtered = VisualisationEvent(vEvent, filter, this->mTimeFrameMinTrackTime, this->mTimeFrameMaxTrackTime);
82 res.push_back(std::make_pair(filtered, filter)); // we can switch on/off data
83 }
84 }
85 auto stop = std::chrono::high_resolution_clock::now();
86 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
87 LOGF(info, "getVisualisationList: ", duration.count());
88 return res;
89}
90
91DataSourceOnline::DataSourceOnline(const std::vector<std::string>& path) : mFileWatcher(path, sourceFilextensions)
92{
93}
94
96{
97 return this->mFileWatcher.getSize();
98}
99
100void DataSourceOnline::setCurrentEvent(Int_t currentEvent)
101{
102 this->mFileWatcher.setCurrentItem(currentEvent);
103}
104
106{
107 return this->mFileWatcher.refresh();
108}
109
114
116{
117 return o2::dataformats::GlobalTrackID::getSourcesDetectorsMask(mTrackMask);
118}
119
120} // namespace event_visualisation
121} // namespace o2
Grouping reading from file(s)
uint32_t res
Definition RawData.h:0
virtual VisualisationEvent getEvent(std::string fileName)=0
DataSourceOnline(const std::vector< std::string > &path)
void setTrackMask(int trackMask) override
void setFileTime(std::string fileTime) override
static std::vector< std::string > sourceFilextensions
void setRunType(parameters::GRPECS::RunType runType) override
o2::detectors::DetID::mask_t getDetectorsMask() override
void setCurrentEvent(Int_t currentEvent) override
void setClusterMask(int clusterMask) override
void setRunNumber(int runNumber) override
std::vector< std::pair< VisualisationEvent, EVisualisationGroup > > getVisualisationList(int no, float minTime, float maxTime, float range) override
void setFirstTForbit(int firstTForbit) override
void setCreationTime(framework::DataProcessingHeader::CreationTime mCreationTime)
Definition DataSource.h:80
std::string currentFilePath() const
name of the file (with path) but guards replaced with file names
int getPos() const
include guards -> 0 points to mLowGuard
void setCurrentItem(int no)
sets using index
bool refresh()
reads folder content, updates current if points to not existing file
int getSize() const
include guards (so >=2 )
o2::header::DataHeader::TForbitType getFirstTForbit() const
o2::parameters::GRPECS::RunType getRunType() const
o2::header::DataHeader::RunNumberType getRunNumber() const
o2::framework::DataProcessingHeader::CreationTime getCreationTime() const
GLenum GLint * range
Definition glcorearb.h:1899
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLuint start
Definition glcorearb.h:469
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...