Skip to content

Commit

Permalink
o2-eve: HMPID display, fix in display configuration file read (AliceO…
Browse files Browse the repository at this point in the history
…2Group#11997)

* o2-eve: HMPID display, fix in display configuration file read
o2-eve-workflow: storing HMPID in *.root/*.json file

* clang

* LOG->LOGF

* clang

* geometry for HMP

---------

Co-authored-by: Julian Myrcha <jmyrcha@cern.ch>
  • Loading branch information
jmyrcha and Julian Myrcha authored Oct 4, 2023
1 parent 230c821 commit 1674604
Show file tree
Hide file tree
Showing 29 changed files with 147 additions and 92 deletions.
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.60";
const static std::string o2_eve_version = "1.70";

/// Configuration Manager allows an easy access to the config file.
///
Expand Down
10 changes: 5 additions & 5 deletions EventVisualisation/Base/src/ConfigurationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ void ConfigurationManager::getConfig(TEnv& settings) const
return; // precise located options file name read succesfully
}
if (settings.ReadFile(fileName = ".o2eve_config", kEnvUser) < 0) {
LOG(warn) << "could not find .o2eve_config in working directory! Trying .o2eve_config in home directory";
LOGF(warn, "could not find .o2eve_config in working directory! Trying .o2eve_config in home directory");
if (settings.ReadFile(fileName = Form("%s/.o2eve_config", gSystem->Getenv("HOME")), kEnvUser) < 0) {
LOG(warn) << "could not find .o2eve_config in home directory! Trying o2eve_config in home directory";
LOGF(warn, "could not find .o2eve_config in home directory! Trying o2eve_config in home directory");
if (settings.ReadFile(fileName = Form("%s/o2eve_config", gSystem->Getenv("HOME")), kEnvUser) < 0) {
LOG(warn) << "could not find o2eve_config in home directory! Trying o2eve_config in O2/EventVisualisation";
LOGF(warn, "could not find o2eve_config in home directory! Trying o2eve_config in O2/EventVisualisation");
if (settings.ReadFile(fileName = Form("%s/EventVisualisation/o2eve_config",
gSystem->Getenv("ALICEO2_INSTALL_PATH")),
kEnvUser) < 0) {
LOG(fatal) << "could not find .o2eve_config or o2eve_config file!.";
LOGF(fatal, "could not find .o2eve_config or o2eve_config file!.");
exit(0);
}
}
}
}
LOG(info) << Form("using %s config settings", fileName.Data());
LOGF(info, Form("using %s config settings", fileName.Data()));
}

const ConfigurationManager* ConfigurationManager::loadSettings()
Expand Down
2 changes: 1 addition & 1 deletion EventVisualisation/Base/src/DataSourceOnline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::vector<std::pair<VisualisationEvent, EVisualisationGroup>>
}
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
LOG(info) << "getVisualisationList: " << duration.count();
LOGF(info, "getVisualisationList: ", duration.count());
return res;
}

Expand Down
4 changes: 2 additions & 2 deletions EventVisualisation/Base/src/DirectoryLoader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ std::string DirectoryLoader::getLatestFile(std::string& path, std::vector<std::s
return oldest_file_name;
}

void DirectoryLoader::removeOldestFiles(std::string& path, std::vector<std::string>& ext, int remaining)
void DirectoryLoader::removeOldestFiles(std::string& path, std::vector<std::string>& ext, const int remaining)
{
while (getNumberOfFiles(path, ext) > remaining) {
LOG(info) << "removing oldest file in folder: " << path << " : " << getLatestFile(path, ext);
LOGF(info, "removing oldest file in folder: ", path, " : ", getLatestFile(path, ext));
filesystem::remove(path + "/" + getLatestFile(path, ext));
}
}
14 changes: 7 additions & 7 deletions EventVisualisation/Base/src/FileWatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ int FileWatcher::getPos() const
bool FileWatcher::refresh()
{
string previous = this->currentItem();
LOG(info) << "previous:" << previous;
LOG(info) << "currentFile:" << this->mCurrentFile;
LOGF(info, "previous:", previous);
LOGF(info, "currentFile:", this->mCurrentFile);

this->mFiles = DirectoryLoader::load(this->mDataFolders, "_", this->mExt); // already sorted according part staring with marker
if (this->mCurrentFile != mEndGuard) {
Expand All @@ -165,17 +165,17 @@ bool FileWatcher::refresh()
this->mFiles.push_front(mLowGuard);
this->mFiles.push_back(mEndGuard);

LOG(info) << "this->mFiles.size() = " << this->mFiles.size();
LOG(info) << "this->mCurrentFile = " << this->mCurrentFile;
LOG(info) << "current:" << this->currentItem();
LOGF(info, "this->mFiles.size() = ", this->mFiles.size());
LOGF(info, "this->mCurrentFile = ", this->mCurrentFile);
LOGF(info, "current:", this->currentItem());
return previous != this->currentItem();
}

void FileWatcher::setCurrentItem(int no)
{
this->mCurrentFile = this->mFiles[no];
LOG(info) << "this->setCurrentItem(" << no << ")";
LOG(info) << "this->mCurrentFile = " << this->mCurrentFile;
LOGF(info, "this->setCurrentItem(", no, ")");
LOGF(info, "this->mCurrentFile = ", this->mCurrentFile);
}

std::string FileWatcher::currentFilePath() const
Expand Down
8 changes: 4 additions & 4 deletions EventVisualisation/Base/src/GeometryManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ TEveGeoShape* GeometryManager::getGeometryForDetector(string detectorName)
// load ROOT file with geometry
TFile* f = TFile::Open(Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str()));
if (!f) {
LOG(error) << "GeometryManager::GetSimpleGeom -- no file with geometry found for: " << detectorName << "!";
LOGF(error, "GeometryManager::GetSimpleGeom -- no file with geometry found for: ", detectorName, "!");
return nullptr;
}
LOG(info) << "GeometryManager::GetSimpleGeom for: " << detectorName << " from "
<< Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str());
LOGF(info, "GeometryManager::GetSimpleGeom for: ", detectorName, " from ",
Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str()));

TEveGeoShapeExtract* geomShapreExtract = static_cast<TEveGeoShapeExtract*>(f->Get(detectorName.c_str()));
auto geomShapreExtract = dynamic_cast<TEveGeoShapeExtract*>(f->Get(detectorName.c_str()));
TEveGeoShape* geomShape = TEveGeoShape::ImportShapeExtract(geomShapreExtract);
f->Close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class VisualisationCalo
std::string gid = "";
o2::dataformats::GlobalTrackID::Source source;
};

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

VisualisationCalo(const VisualisationCalo& src);

Expand Down Expand Up @@ -103,8 +104,6 @@ class VisualisationCalo
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "rapidjson/document.h"
#include <TVector3.h>

#include <vector>
#include <ctime>
Expand All @@ -42,6 +43,14 @@ class VisualisationCluster
public:
// Default constructor
VisualisationCluster(float XYZ[], float time);
VisualisationCluster(TVector3 xyz)
{
mTime = 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]; }
Expand All @@ -59,4 +68,4 @@ class VisualisationCluster
};
} // namespace event_visualisation
} // namespace o2
#endif // ALICE_O2_DATACONVERTER_VISUALISATIONCLUSTER_H
#endif // ALICE_O2_DATACONVERTER_VISUALISATIONCLUSTER_H
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum EVisualisationGroup {
EMC,
PHS,
CPV,
HMP,
NvisualisationGroups
};

Expand All @@ -49,7 +50,8 @@ const std::string gVisualisationGroupName[NvisualisationGroups] = {
"MID",
"EMC",
"PHS",
"CPV"};
"CPV",
"HMP"};

const bool R3Visualisation[NvisualisationGroups] = {
true, //"ITS",
Expand All @@ -61,7 +63,8 @@ const bool R3Visualisation[NvisualisationGroups] = {
true, //"MID",
true, //"EMC",
true, //"PHS",
true, // "CPV"
true, //"CPV"
true, //"HMP"
};

enum EVisualisationDataType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class VisualisationEvent
return mTracks.back().addCluster(pos);
}

VisualisationCluster& addGlobalCluster(const TVector3& xyz)
{
return mClusters.emplace_back(xyz);
}

VisualisationCalo* addCalo(VisualisationCalo::VisualisationCaloVO vo)
{
mCalo.emplace_back(vo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ namespace event_visualisation

class VisualisationEventJSONSerializer : public VisualisationEventSerializer
{
public:
static int getIntOrDefault(rapidjson::Value& tree, const char* key, int defaultValue = 0);
float getFloatOrDefault(rapidjson::Value& tree, const char* key, float defaultValue = 0.0f);
std::string getStringOrDefault(rapidjson::Value& tree, const char* key, const char* defaultValue = "");
static float getFloatOrDefault(rapidjson::Value& tree, const char* key, float defaultValue = 0.0f);
static std::string getStringOrDefault(rapidjson::Value& tree, const char* key, const char* defaultValue = "");

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

Expand Down
3 changes: 3 additions & 0 deletions EventVisualisation/DataConverter/src/VisualisationEvent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ VisualisationEvent::GIDVisualisation VisualisationEvent::mVis = [] {
if (filter == o2::event_visualisation::EVisualisationGroup::PHS) {
res.contains[o2::dataformats::GlobalTrackID::PHS][filter] = true;
}
if (filter == o2::event_visualisation::EVisualisationGroup::HMP) {
res.contains[o2::dataformats::GlobalTrackID::HMP][filter] = true;
}
}
return res;
}();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
#include <fairlogger/Logger.h>
#include <iostream>
#include <iomanip>
#include <limits>

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"

Expand All @@ -40,7 +38,7 @@ void VisualisationEventJSONSerializer::toFile(const VisualisationEvent& event, s

bool VisualisationEventJSONSerializer::fromFile(VisualisationEvent& event, std::string fileName)
{
LOG(info) << "VisualisationEventJSONSerializer <- " << fileName;
LOGF(info, "VisualisationEventJSONSerializer <- ", fileName);
if (FILE* file = fopen(fileName.c_str(), "r")) {
fclose(file); // file exists
} else {
Expand Down Expand Up @@ -195,7 +193,7 @@ VisualisationCluster VisualisationEventJSONSerializer::clusterFromJSON(rapidjson
XYZ[2] = jsonZ.GetDouble();

VisualisationCluster cluster(XYZ, 0);
cluster.mSource = o2::dataformats::GlobalTrackID::TPC; // temporary
cluster.mSource = o2::dataformats::GlobalTrackID::HMP;
return cluster;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void VisualisationEventROOTSerializer::toFile(const VisualisationEvent& event, s

bool VisualisationEventROOTSerializer::fromFile(VisualisationEvent& event, std::string fileName)
{
LOG(info) << "VisualisationEventROOTSerializer <- " << fileName;
LOGF(info, "VisualisationEventROOTSerializer <- ", fileName);
event.mTracks.clear();
event.mClusters.clear();
event.mCalo.clear();
Expand Down
12 changes: 6 additions & 6 deletions EventVisualisation/DataConverter/src/converter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

int main(int argc, char** argv)
{
LOG(info) << "Welcome in O2 event conversion tool";
LOGF(info, "Welcome in O2 event conversion tool");
if (argc != 3) {
LOG(error) << "two filename required, second should point to not existent file";
LOGF(error, "two filename required, second should point to not existent file");
exit(-1);
}

Expand All @@ -45,13 +45,13 @@ int main(int argc, char** argv)

srcSerializer->fromFile(vEvent, src);
endTime = std::chrono::high_resolution_clock::now();
LOG(info) << "read took "
<< std::chrono::duration_cast<std::chrono::microseconds>(endTime - currentTime).count() * 1e-6;
LOGF(info, "read took ",
std::chrono::duration_cast<std::chrono::microseconds>(endTime - currentTime).count() * 1e-6);

currentTime = std::chrono::high_resolution_clock::now();
dstSerializer->toFile(vEvent, dst);
endTime = std::chrono::high_resolution_clock::now();
LOG(info) << "write took "
<< std::chrono::duration_cast<std::chrono::microseconds>(endTime - currentTime).count() * 1e-6;
LOGF(info, "write took ",
std::chrono::duration_cast<std::chrono::microseconds>(endTime - currentTime).count() * 1e-6);
return 0;
}
Binary file added EventVisualisation/Geometry/simple_geom_HMP.root
Binary file not shown.
Empty file modified EventVisualisation/Geometry/simple_geom_ITS.root
100755 → 100644
Empty file.
23 changes: 13 additions & 10 deletions EventVisualisation/View/src/EventManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "EventVisualisationView/MultiView.h"
#include "EventVisualisationView/Options.h"
#include "EventVisualisationDataConverter/VisualisationEvent.h"
#include "EventVisualisationDataConverter/VisualisationEventJSONSerializer.h"
#include <EventVisualisationBase/DataSourceOnline.h>
#include "EventVisualisationBase/ConfigurationManager.h"
#include "DataFormatsParameters/ECSDataAdapters.h"
Expand Down Expand Up @@ -59,7 +60,7 @@ EventManager& EventManager::getInstance()

EventManager::EventManager() : TEveEventManager("Event", "")
{
LOG(info) << "Initializing TEveManager";
LOGF(info, "Initializing TEveManager");

ConfigurationManager::getInstance().getConfig(settings);

Expand Down Expand Up @@ -141,7 +142,6 @@ void EventManager::displayCurrentEvent()
multiView->redraw3D();
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
LOG(info) << "+++ displayCurrentEvent: " << duration.count();
}

void EventManager::GotoEvent(Int_t no)
Expand Down Expand Up @@ -221,7 +221,7 @@ void EventManager::displayVisualisationEvent(VisualisationEvent& event, const st
{
double eta = 0.1;
size_t trackCount = event.getTrackCount();
LOG(info) << "displayVisualisationEvent: " << trackCount << " detector: " << detectorName;

// tracks
auto* list = new TEveTrackList(detectorName.c_str());
list->IncDenyDestroy();
Expand Down Expand Up @@ -266,7 +266,6 @@ void EventManager::displayVisualisationEvent(VisualisationEvent& event, const st
if (trackCount != 0) {
dataTypeLists[EVisualisationDataType::Tracks]->AddElement(list);
if (detectorName != "MCH" && detectorName != "MFT" && detectorName != "MID") {
// LOG(info) << "phi: " << trackCount << " detector: " << detectorName;
dataTypeListsPhi[EVisualisationDataType::Tracks]->AddElement(list);
}
}
Expand All @@ -283,15 +282,14 @@ void EventManager::displayVisualisationEvent(VisualisationEvent& event, const st
if (clusterCount != 0) {
dataTypeLists[EVisualisationDataType::Clusters]->AddElement(point_list);
if (detectorName != "MCH" && detectorName != "MFT" && detectorName != "MID") {
// LOG(info) << "phi: " << clusterCount << " detector: " << detectorName;
dataTypeListsPhi[EVisualisationDataType::Clusters]->AddElement(point_list);
}
}

LOG(info) << "tracks: " << trackCount << " detector: " << detectorName << ":"
<< dataTypeLists[EVisualisationDataType::Tracks]->NumChildren();
LOG(info) << "clusters: " << clusterCount << " detector: " << detectorName << ":"
<< dataTypeLists[EVisualisationDataType::Clusters]->NumChildren();
LOGF(info, "tracks: ", trackCount, " detector: ", detectorName, ":",
dataTypeLists[EVisualisationDataType::Tracks]->NumChildren());
LOGF(info, "clusters: ", clusterCount, " detector: ", detectorName, ":",
dataTypeLists[EVisualisationDataType::Clusters]->NumChildren());
}

void EventManager::displayCalorimeters(VisualisationEvent& event, const std::string& detectorName)
Expand Down Expand Up @@ -428,7 +426,7 @@ void EventManager::saveVisualisationSettings()

return arr;
};

d.AddMember("version", rapidjson::Value().SetString(o2_eve_version.c_str(), o2_eve_version.length()), allocator);
d.AddMember("trackVisibility", jsonArray(vizSettings.trackVisibility, allocator), allocator);
d.AddMember("trackColor", jsonArray(vizSettings.trackColor, allocator), allocator);
d.AddMember("trackStyle", jsonArray(vizSettings.trackStyle, allocator), allocator);
Expand Down Expand Up @@ -479,6 +477,11 @@ void EventManager::restoreVisualisationSettings()
Document d;
d.Parse(json.c_str());

if (VisualisationEventJSONSerializer::getStringOrDefault(d, "version", "0.0") != o2_eve_version) {
LOGF(info, "visualisation settings has wrong version and was not restored");
return;
}

auto updateArray = [](auto& array, const auto& document, const char* name, const auto& accessor) {
for (size_t i = 0; i < elemof(array); ++i) {
array[i] = accessor(document[name][i]);
Expand Down
7 changes: 3 additions & 4 deletions EventVisualisation/View/src/EventManagerFrame.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,9 @@ void EventManagerFrame::checkMemory()
if (success == 1) { // properly readed
size = 4 * size / 1024; // in MB
this->memoryUsedInfo = size;
LOG(info) << "Memory used: " << size << " memory allowed: " << memoryLimit;
LOGF(info, "Memory used: ", size, " memory allowed: ", memoryLimit);
if (size > memoryLimit) {
LOG(error) << "Memory used: " << size << " exceeds memory allowed: "
<< memoryLimit;
LOGF(error, "Memory used: ", size, " exceeds memory allowed: ", memoryLimit);
exit(-1);
}
}
Expand All @@ -412,7 +411,7 @@ void EventManagerFrame::createOutreachScreenshot()
if (!std::filesystem::is_regular_file(fileName)) {
std::vector<std::string> ext = {".png"};
DirectoryLoader::removeOldestFiles(imageFolder, ext, (int)ConfigurationManager::getOutreachFilesMax());
LOG(info) << "Outreach screenshot: " << fileName;
LOGF(info, "Outreach screenshot: ", fileName);

Screenshot::perform("outreach", fileName, this->mEventManager->getDataSource()->getDetectorsMask(),
this->mEventManager->getDataSource()->getRunNumber(),
Expand Down
Loading

0 comments on commit 1674604

Please sign in to comment.