Skip to content

Commit

Permalink
o2-eve: implementation of *.eve binary format, many fixes (AliceO2Gro…
Browse files Browse the repository at this point in the history
…up#13241)

* o2-eve: implementation of *.eve binary format, many fixes

* formatting

* remove std::quick_exit

* clang format

* missed call to quick_exit removed

* clang

* clang

* requested changes

* clang

---------

Co-authored-by: Julian Myrcha <jmyrcha@cern.ch>
  • Loading branch information
jmyrcha and Julian Myrcha authored Jul 10, 2024
1 parent 68770ca commit b6adf2a
Show file tree
Hide file tree
Showing 31 changed files with 1,310 additions and 375 deletions.
1 change: 1 addition & 0 deletions EventVisualisation/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

o2_add_library(EventVisualisationBase
SOURCES src/ConfigurationManager.cxx
src/DataSource.cxx
src/DataSourceOnline.cxx
src/DataSourceOffline.cxx
src/GeometryManager.cxx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace o2
namespace event_visualisation
{
/// Version of the software
const static std::string o2_eve_version = "1.70";
const static int o2_eve_version = 171;

/// Configuration Manager allows an easy access to the config file.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DataSource
DataReader* mDataReader = nullptr;
float mTimeFrameMinTrackTime = 0;
float mTimeFrameMaxTrackTime = 0;
framework::DataProcessingHeader::CreationTime mCreationTime;

public:
float getTimeFrameMinTrackTime() const
Expand Down Expand Up @@ -76,8 +77,9 @@ class DataSource
virtual std::string getEventAbsoluteFilePath() { return ""; };
virtual int getFirstTForbit() const { return 0; }
virtual void setFirstTForbit(int) {}
virtual std::string getCollisionTime() const { return "not specified"; }
virtual void setCollisionTime(std::string) {}
void setCreationTime(framework::DataProcessingHeader::CreationTime mCreationTime) { this->mCreationTime = mCreationTime; }
framework::DataProcessingHeader::CreationTime getCreationTime() const { return mCreationTime; }
std::string getCreationTimeAsString() const;
virtual std::string getFileTime() const { return "not specified"; }
virtual void setFileTime(std::string) {}
virtual int getTrackMask() const { return 0; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class DataSourceOnline : public DataSource
int mFirstTForbit;
int mTrackMask;
int mClusterMask;
std::string mCollisionTime;

protected:
std::string mFileTime;

public:
Expand Down Expand Up @@ -69,8 +70,6 @@ class DataSourceOnline : public DataSource
std::string getEventAbsoluteFilePath() override { return mFileWatcher.currentFilePath(); };
int getFirstTForbit() const override { return this->mFirstTForbit; }
void setFirstTForbit(int firstTForbit) override { this->mFirstTForbit = firstTForbit; }
std::string getCollisionTime() const override { return this->mCollisionTime; }
void setCollisionTime(std::string collisionTime) override { this->mCollisionTime = collisionTime; }
std::string getFileTime() const override { return this->mFileTime; }
void setFileTime(std::string fileTime) override { this->mFileTime = fileTime; }
int getTrackMask() const override { return this->mTrackMask; }
Expand Down
34 changes: 34 additions & 0 deletions EventVisualisation/Base/src/DataSource.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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 DataSource.cxx
/// \brief reading from file(s) base class
/// \author j.myrcha@cern.ch

#include <EventVisualisationBase/DataSource.h>

#include <fairlogger/Logger.h>
// #include <time.h>

namespace o2::event_visualisation
{

std::string DataSource::getCreationTimeAsString() const
{
char buffer[90];
time_t time = this->mCreationTime;
const char* format = "%a %b %-d %H:%M:%S %Y";
struct tm* timeinfo = localtime(&time);
strftime(buffer, sizeof(buffer), format, timeinfo);
return buffer;
}

} // namespace o2::event_visualisation
5 changes: 3 additions & 2 deletions EventVisualisation/Base/src/DataSourceOnline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace o2
{
namespace event_visualisation
{
std::vector<std::string> DataSourceOnline::sourceFilextensions = {".json", ".root"};
std::vector<std::string> DataSourceOnline::sourceFilextensions = {".json", ".root", ".eve"};

std::vector<std::pair<VisualisationEvent, EVisualisationGroup>>
DataSourceOnline::getVisualisationList(int no, float minTime, float maxTime, float range)
Expand All @@ -51,7 +51,8 @@ std::vector<std::pair<VisualisationEvent, EVisualisationGroup>>
this->setRunNumber(vEvent.getRunNumber());
this->setRunType(vEvent.getRunType());
this->setFirstTForbit(vEvent.getFirstTForbit());
this->setCollisionTime(vEvent.getCollisionTime());
this->setCreationTime(vEvent.getCreationTime());

this->setTrackMask(vEvent.getTrkMask());
this->setClusterMask(vEvent.getClMask());

Expand Down
2 changes: 2 additions & 0 deletions EventVisualisation/DataConverter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ o2_add_library(EventVisualisationDataConverter
src/VisualisationEventSerializer.cxx
src/VisualisationEventJSONSerializer.cxx
src/VisualisationEventROOTSerializer.cxx
src/VisualisationEventOpenGLSerializer.cxx
PUBLIC_LINK_LIBRARIES RapidJSON::RapidJSON
O2::ReconstructionDataFormats
O2::DataFormatsParameters
Expand All @@ -28,6 +29,7 @@ o2_add_executable(eve-convert
src/VisualisationEventSerializer.cxx
src/VisualisationEventJSONSerializer.cxx
src/VisualisationEventROOTSerializer.cxx
src/VisualisationEventOpenGLSerializer.cxx
src/VisualisationTrack.cxx
src/VisualisationCluster.cxx
src/VisualisationCalo.cxx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,98 +20,47 @@
#include "rapidjson/document.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"

namespace o2
{
namespace event_visualisation
namespace o2::event_visualisation
{

class VisualisationCalo
{
friend class VisualisationEventJSONSerializer;
friend class VisualisationEventROOTSerializer;

public:
// Default constructor
VisualisationCalo();

/// constructor parametrisation (Value Object) for VisualisationCalo class
///
/// Simplifies passing parameters to constructor of VisualisationCalo
/// by providing their names
struct VisualisationCaloVO {
float time = 0;
float energy = 0.0f;
float phi = 0;
float eta = 0;
int PID = 0;
std::string gid = "";
o2::dataformats::GlobalTrackID::Source source;
o2::dataformats::GlobalTrackID gid = 0;
};

// Constructor with properties initialisation
explicit VisualisationCalo(const VisualisationCaloVO& vo);

VisualisationCalo(const VisualisationCalo& src);

// Energy getter
float getEnergy() const
{
return mEnergy;
}

// Time getter
float getTime() const
{
return mTime;
}

// PID (particle identification code) getter
int getPID() const
{
return mPID;
}

// GID getter
std::string getGIDAsString() const
{
return mGID;
}

// Source Getter
o2::dataformats::GlobalTrackID::Source getSource() const
{
return mSource;
}

// Phi getter
float getPhi() const
{
return mPhi;
}

// Theta getter
float getEta() const
{
return mEta;
}
[[nodiscard]] float getEnergy() const { return mEnergy; }
[[nodiscard]] float getTime() const { return mTime; }
[[nodiscard]] int getPID() const { return mPID; }
[[nodiscard]] o2::dataformats::GlobalTrackID getGID() const { return mBGID; }
[[nodiscard]] o2::dataformats::GlobalTrackID::Source getSource() const { return static_cast<o2::dataformats::GlobalTrackID::Source>(mBGID.getSource()); }
[[nodiscard]] float getPhi() const { return mPhi; }
[[nodiscard]] float getEta() const { return mEta; }

private:
// Set coordinates of the beginning of the track
void addStartCoordinates(const float xyz[3]);

float mTime; /// time
float mEnergy; /// Energy of the particle

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

float mEta; /// An angle from Z-axis to the radius vector pointing to the particle
float mPhi; /// An angle from X-axis to the radius vector pointing to the particle

// std::vector<int> mChildrenIDs; /// Unique IDs of children particles
o2::dataformats::GlobalTrackID::Source mSource; /// data source of the track (debug)
int mPID; /// PDG code of the particle
float mEta; /// An angle from Z-axis to the radius vector pointing to the particle
float mPhi; /// An angle from X-axis to the radius vector pointing to the particle
o2::dataformats::GlobalTrackID mBGID;
};

} // namespace event_visualisation
} // namespace o2
} // namespace o2::event_visualisation

#endif // O2EVE_VISUALISATIONCALO_H
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include <vector>
#include <ctime>

namespace o2
{
namespace event_visualisation
namespace o2::event_visualisation
{

/// Minimalistic description of a cluster
Expand All @@ -39,33 +37,32 @@ class VisualisationCluster
{
friend class VisualisationEventJSONSerializer;
friend class VisualisationEventROOTSerializer;
friend class VisualisationEventOpenGLSerializer;
friend class VisualisationEvent;

public:
// Default constructor
VisualisationCluster(float XYZ[], float time);
VisualisationCluster(const float XYZ[], float time, o2::dataformats::GlobalTrackID gid);
VisualisationCluster(TVector3 xyz)
{
mTime = 0;
mBGID = 0;
mCoordinates[0] = xyz[0];
mCoordinates[1] = xyz[1];
mCoordinates[2] = xyz[2];
mSource = o2::dataformats::GlobalTrackID::HMP;
}

float X() const { return mCoordinates[0]; }
float Y() const { return mCoordinates[1]; }
float Z() const { return mCoordinates[2]; }
float Time() const { return mTime; }

// GID getter
int getSource() const { return mSource; }

private:
void setCoordinates(float xyz[3]);
void setCoordinates(const float xyz[3]);
float mCoordinates[3]; /// Vector of cluster's coordinates
float mTime; /// time asociated with cluster
o2::dataformats::GlobalTrackID::Source mSource; /// data source of the cluster (debug)
o2::dataformats::GlobalTrackID mBGID;
};
} // namespace event_visualisation
} // namespace o2
} // namespace o2::event_visualisation

#endif // ALICE_O2_DATACONVERTER_VISUALISATIONCLUSTER_H
Loading

0 comments on commit b6adf2a

Please sign in to comment.