Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions EventVisualisation/DataConverter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ o2_add_library(EventVisualisationDataConverter
SOURCES src/VisualisationEvent.cxx
src/VisualisationTrack.cxx
src/VisualisationCluster.cxx
src/VisualisationCalo.cxx
src/VisualisationEventSerializer.cxx
src/VisualisationEventJSONSerializer.cxx
PUBLIC_LINK_LIBRARIES RapidJSON::RapidJSON
O2::ReconstructionDataFormats
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// 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 VisualisationCalo.h
/// \author Julian Myrcha
///

#ifndef O2EVE_VISUALISATIONCALO_H
#define O2EVE_VISUALISATIONCALO_H

#include "rapidjson/document.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"

namespace o2
{
namespace 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;
};
// Constructor with properties initialisation
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;
}

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 mStartCoordinates[3]; /// Vector of track's start coordinates

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)
};

} // namespace event_visualisation
} // namespace o2

#endif // O2EVE_VISUALISATIONCALO_H
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace event_visualisation

class VisualisationCluster
{
public:
VisualisationCluster(rapidjson::Value& tree);
rapidjson::Value jsonTree(rapidjson::Document::AllocatorType& allocator);
friend class VisualisationEventJSONSerializer;
friend class VisualisationEventROOTSerializer;

public:
// Default constructor
VisualisationCluster(float XYZ[], float time);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ enum EVisualisationGroup {
MFT,
MCH,
MID,
EMC,
PHS,
CPV,
NvisualisationGroups
};

Expand All @@ -43,7 +46,10 @@ const std::string gVisualisationGroupName[NvisualisationGroups] = {
"TOF",
"MFT",
"MCH",
"MID"};
"MID",
"EMC",
"PHS",
"CPV"};

const bool R3Visualisation[NvisualisationGroups] = {
true, //"ITS",
Expand All @@ -52,18 +58,23 @@ const bool R3Visualisation[NvisualisationGroups] = {
true, //"TOF",
true, // "MFT"
true, //"MCH",
true //"MID",
true, //"MID",
true, //"EMC",
true, //"PHS",
true, // "CPV"
};

enum EVisualisationDataType {
Clusters, ///< Reconstructed clusters (RecPoints)
Tracks, ///< Event Summary Data
NdataTypes ///< number of supported data types
Clusters, ///< Reconstructed clusters (RecPoints)
Tracks, ///< Event Summary Data
Calorimeters, ///< Calorimeters
NdataTypes ///< number of supported data types
};

const std::string gDataTypeNames[NdataTypes] = {
"Clusters",
"Tracks"};
"Tracks",
"Calorimeters"};

} // namespace event_visualisation
} // namespace o2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@

#include "EventVisualisationDataConverter/VisualisationTrack.h"
#include "EventVisualisationDataConverter/VisualisationCluster.h"
#include "EventVisualisationDataConverter/VisualisationCalo.h"
#include "EventVisualisationDataConverter/VisualisationConstants.h"
#include <forward_list>
#include <ctime>
#include <gsl/span>

namespace o2
{
Expand All @@ -39,19 +41,17 @@ namespace event_visualisation

class VisualisationEvent
{
friend class VisualisationEventJSONSerializer;
friend class VisualisationEventROOTSerializer;

public:
struct GIDVisualisation {
bool contains[o2::dataformats::GlobalTrackID::NSources][o2::event_visualisation::EVisualisationGroup::NvisualisationGroups];
};
static GIDVisualisation mVis;
std::string toJson();
void fromJson(std::string json);
bool fromFile(std::string fileName);
VisualisationEvent();
VisualisationEvent(std::string fileName);
VisualisationEvent(const VisualisationEvent& source, EVisualisationGroup filter, float minTime, float maxTime);
void toFile(std::string fileName);
static std::string fileNameIndexed(const std::string fileName, const int index);

/// constructor parametrisation (Value Object) for VisualisationEvent class
///
Expand Down Expand Up @@ -105,6 +105,26 @@ class VisualisationEvent
return mTracks.size();
}

gsl::span<const VisualisationCluster> getClustersSpan() const
{
return mClusters;
}

gsl::span<const VisualisationTrack> getTracksSpan() const
{
return mTracks;
}

gsl::span<const VisualisationCalo> getCalorimetersSpan() const
{
return mCalo;
}

size_t getCaloCount() const
{
return mCalo.size();
}

// Returns number of tracks with ITS contribution (including standalone)
size_t getITSTrackCount() const
{
Expand All @@ -118,38 +138,59 @@ class VisualisationEvent
{
mTracks.clear();
mClusters.clear();
mCalo.clear();
}

const VisualisationCluster& getCluster(int i) const { return mClusters[i]; };
size_t getClusterCount() const { return mClusters.size(); } // Returns number of clusters
void setWorkflowVersion(float workflowVersion) { this->mWorkflowVersion = workflowVersion; }
void setWorkflowParameters(const std::string& workflowParameters) { this->mWorkflowParameters = workflowParameters; }

o2::header::DataHeader::RunNumberType getRunNumber() const { return this->mRunNumber; }
void setRunNumber(o2::header::DataHeader::RunNumberType runNumber) { this->mRunNumber = runNumber; }

std::string getCollisionTime() const { return this->mCollisionTime; }
void setCollisionTime(std::string collisionTime) { this->mCollisionTime = collisionTime; }

float getMinTimeOfTracks() const { return this->mMinTimeOfTracks; }
float getMaxTimeOfTracks() const { return this->mMaxTimeOfTracks; } /// maximum time of tracks in the event

bool isEmpty() const { return getTrackCount() == 0 && getClusterCount() == 0; }

int getClMask() const { return mClMask; }
void setClMask(int value) { mClMask = value; }

int getTrkMask() const { return mTrkMask; }
void setTrkMask(int value) { mTrkMask = value; }

o2::header::DataHeader::RunNumberType getRunNumber() const { return this->mRunNumber; }
void setRunNumber(o2::header::DataHeader::RunNumberType runNumber) { this->mRunNumber = runNumber; }

o2::header::DataHeader::TFCounterType getTfCounter() const { return this->mTfCounter; }
void setTfCounter(o2::header::DataHeader::TFCounterType value) { this->mTfCounter = value; }

o2::header::DataHeader::TForbitType getFirstTForbit() const { return this->mFirstTForbit; }
void setFirstTForbit(o2::header::DataHeader::TForbitType value) { this->mFirstTForbit = value; }

private:
int mClMask; /// clusters requested during aquisition
int mTrkMask; /// tracks requested during aquisition
o2::header::DataHeader::RunNumberType mRunNumber; /// run number
o2::header::DataHeader::TFCounterType mTfCounter;
o2::header::DataHeader::TForbitType mFirstTForbit;

float mMinTimeOfTracks; /// minimum time of tracks in the event
float mMaxTimeOfTracks; /// maximum time of tracks in the event
float mWorkflowVersion; /// workflow version used to generate this Event
std::string mWorkflowParameters; /// workflow parameters used to generate this Event
int mEventNumber; /// event number in file
o2::header::DataHeader::RunNumberType mRunNumber; /// run number
double mEnergy; /// energy of the collision
int mMultiplicity; /// number of particles reconstructed
std::string mCollidingSystem; /// colliding system (e.g. proton-proton)
std::string mCollisionTime; /// collision timestamp
std::vector<VisualisationTrack> mTracks; /// an array of visualisation tracks
std::vector<VisualisationCluster> mClusters; /// an array of visualisation clusters
std::vector<VisualisationCalo> mCalo; /// an array of visualisation calorimeters
};

} // namespace event_visualisation
} // namespace o2

#endif // ALICE_O2_EVENTVISUALISATION_BASE_VISUALISATIONEVENT_H
#endif // ALICE_O2_EVENTVISUALISATION_BASE_VISUALISATIONEVENT_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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 VisualisationEventSerializer.h
/// \author Julian Myrcha
///

#ifndef O2EVE_VISUALISATIONEVENTJSONSERIALIZER_H
#define O2EVE_VISUALISATIONEVENTJSONSERIALIZER_H

#include "EventVisualisationDataConverter/VisualisationEventSerializer.h"
#include "EventVisualisationDataConverter/VisualisationTrack.h"
#include <string>

namespace o2
{
namespace event_visualisation
{

class VisualisationEventJSONSerializer : public VisualisationEventSerializer
{
static int getIntOrDefault(rapidjson::Value& tree, const char* key, int defaultValue = 0);

std::string toJson(const VisualisationEvent& event) const;
void fromJson(VisualisationEvent& event, std::string json);

// create calo from their JSON representation
VisualisationCalo caloFromJSON(rapidjson::Value& tree);
// create JSON representation of the calo
rapidjson::Value jsonTree(const VisualisationCalo& calo, rapidjson::Document::AllocatorType& allocator) const;

// create cluster from their JSON representation
VisualisationCluster clusterFromJSON(rapidjson::Value& tree);
rapidjson::Value jsonTree(const VisualisationCluster& cluster, rapidjson::Document::AllocatorType& allocator) const;

// create track from their JSON representation
VisualisationTrack trackFromJSON(rapidjson::Value& tree);
// create JSON representation of the track
rapidjson::Value jsonTree(const VisualisationTrack& track, rapidjson::Document::AllocatorType& allocator) const;

public:
bool fromFile(VisualisationEvent& event, std::string fileName) override;
void toFile(const VisualisationEvent& event, std::string fileName) override;
};

} // namespace event_visualisation
} // namespace o2

#endif // O2EVE_VISUALISATIONEVENTJSONSERIALIZER_H
Loading