Skip to content

Commit

Permalink
Save run type for Event Display, show file modification date in Event…
Browse files Browse the repository at this point in the history
… Display
  • Loading branch information
pnwkw authored and davidrohr committed Nov 10, 2022
1 parent 5cda795 commit 24437b2
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ class DataSource
virtual void saveCurrentEvent(std::string /*targetFolder*/){};
virtual int getRunNumber() const { return 0; }
virtual void setRunNumber(int) {}
virtual o2::parameters::GRPECS::RunType getRunType() { return o2::parameters::GRPECS::RunType::NONE; }
virtual void setRunType(o2::parameters::GRPECS::RunType) {}
virtual std::string getEventName() { return "event"; };
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) {}
virtual std::string getFileTime() const { return "not specified"; }
virtual void setFileTime(std::string) {}
virtual int getTrackMask() const { return 0; }
virtual void setTrackMask(int) {}
virtual int getClusterMask() const { return 0; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class DataSourceOnline : public DataSource
static std::vector<std::string> sourceFilextensions;
FileWatcher mFileWatcher;
int mRunNumber;
o2::parameters::GRPECS::RunType mRunType;
int mFirstTForbit;
int mTrackMask;
int mClusterMask;
std::string mCollisionTime;
std::string mFileTime;

public:
DataSourceOnline(const std::string path);
Expand All @@ -61,12 +63,16 @@ class DataSourceOnline : public DataSource
void saveCurrentEvent(std::string targetFolder) override { mFileWatcher.saveCurrentFileToFolder(targetFolder); };
int getRunNumber() const override { return this->mRunNumber; }
void setRunNumber(int runNumber) override { this->mRunNumber = runNumber; }
parameters::GRPECS::RunType getRunType() override { return mRunType; }
void setRunType(parameters::GRPECS::RunType runType) override { this->mRunType = runType; }
std::string getEventName() override { return mFileWatcher.currentItem(); };
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; }
void setTrackMask(int trackMask) override { this->mTrackMask = trackMask; }
int getClusterMask() const override { return this->mClusterMask; }
Expand Down
12 changes: 12 additions & 0 deletions EventVisualisation/Base/src/DataSourceOnline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <TFile.h>
#include <TPRegexp.h>
#include <TObject.h>
#include <filesystem>
#include <chrono>

namespace o2
{
Expand All @@ -42,11 +44,21 @@ std::vector<std::pair<VisualisationEvent, EVisualisationGroup>> DataSourceOnline
VisualisationEvent vEvent = this->mDataReader->getEvent(mFileWatcher.currentFilePath());

this->setRunNumber(vEvent.getRunNumber());
this->setRunType(vEvent.getRunType());
this->setFirstTForbit(vEvent.getFirstTForbit());
this->setCollisionTime(vEvent.getCollisionTime());
this->setTrackMask(vEvent.getTrkMask());
this->setClusterMask(vEvent.getClMask());

auto write_time = std::filesystem::last_write_time(mFileWatcher.currentFilePath());
auto duration = std::chrono::time_point_cast<std::chrono::system_clock::duration>(write_time - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now());
auto duration_time = std::chrono::system_clock::to_time_t(duration);

char time_str[100];
std::strftime(time_str, sizeof(time_str), "%a %b %d %H:%M:%S %Y", std::localtime(&duration_time));

this->setFileTime(time_str);

double period = vEvent.getMaxTimeOfTracks() - vEvent.getMinTimeOfTracks();
if (period > 0) {
this->mTimeFrameMinTrackTime = minTime * period / range + vEvent.getMinTimeOfTracks();
Expand Down
1 change: 1 addition & 0 deletions EventVisualisation/DataConverter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ o2_add_library(EventVisualisationDataConverter
src/VisualisationEventROOTSerializer.cxx
PUBLIC_LINK_LIBRARIES RapidJSON::RapidJSON
O2::ReconstructionDataFormats
O2::DataFormatsParameters
)

o2_add_executable(eve-convert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "EventVisualisationDataConverter/VisualisationCluster.h"
#include "EventVisualisationDataConverter/VisualisationCalo.h"
#include "EventVisualisationDataConverter/VisualisationConstants.h"
#include "DataFormatsParameters/ECSDataAdapters.h"
#include <forward_list>
#include <ctime>
#include <gsl/span>
Expand Down Expand Up @@ -187,6 +188,9 @@ class VisualisationEvent
o2::header::DataHeader::RunNumberType getRunNumber() const { return this->mRunNumber; }
void setRunNumber(o2::header::DataHeader::RunNumberType runNumber) { this->mRunNumber = runNumber; }

o2::parameters::GRPECS::RunType getRunType() const { return this->mRunType; }
void setRunType(o2::parameters::GRPECS::RunType runType) { this->mRunType = runType; }

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

Expand All @@ -201,6 +205,7 @@ class VisualisationEvent
o2::header::DataHeader::RunNumberType mRunNumber; /// run number
o2::header::DataHeader::TFCounterType mTfCounter;
o2::header::DataHeader::TForbitType mFirstTForbit;
o2::parameters::GRPECS::RunType mRunType;
std::size_t mPrimaryVertex;

float mMinTimeOfTracks; /// minimum time of tracks in the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ std::string VisualisationEventJSONSerializer::toJson(const VisualisationEvent& e

// compatibility verification
tree.AddMember("runNumber", rapidjson::Value().SetInt(event.mRunNumber), allocator);
tree.AddMember("runType", rapidjson::Value().SetInt(event.mRunType), allocator);
tree.AddMember("clMask", rapidjson::Value().SetInt(event.mClMask), allocator);
tree.AddMember("trkMask", rapidjson::Value().SetInt(event.mTrkMask), allocator);
tree.AddMember("tfCounter", rapidjson::Value().SetInt(event.mTfCounter), allocator);
Expand Down Expand Up @@ -147,6 +148,7 @@ void VisualisationEventJSONSerializer::fromJson(VisualisationEvent& event, std::
tree.Parse(json.c_str());

event.setRunNumber(getIntOrDefault(tree, "runNumber", 0));
event.setRunType(static_cast<parameters::GRPECS::RunType>(getIntOrDefault(tree, "runType", 0)));
event.setClMask(getIntOrDefault(tree, "clMask"));
event.setTrkMask(getIntOrDefault(tree, "trkMask"));
event.setTfCounter(getIntOrDefault(tree, "tfCounter"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void VisualisationEventROOTSerializer::toFile(const VisualisationEvent& event, s
TFile f(fileName.c_str(), "recreate");

save("runNumber", event.mRunNumber);
save("runType", event.mRunType);
save("clMask", event.mClMask);
save("trkMask", event.mTrkMask);
save("tfCounter", event.mTfCounter);
Expand Down Expand Up @@ -195,6 +196,7 @@ bool VisualisationEventROOTSerializer::fromFile(VisualisationEvent& event, std::
TFile f(fileName.c_str());

event.setRunNumber(readInt(f, "runNumber"));
event.setRunType(static_cast<parameters::GRPECS::RunType>(readInt(f, "runType")));
event.setClMask(readInt(f, "clMask"));
event.setTrkMask(readInt(f, "trkMask"));
event.setTfCounter(readInt(f, "tfCounter"));
Expand Down
3 changes: 2 additions & 1 deletion EventVisualisation/View/src/EventManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "EventVisualisationDataConverter/VisualisationEvent.h"
#include <EventVisualisationBase/DataSourceOnline.h>
#include "EventVisualisationBase/ConfigurationManager.h"
#include "DataFormatsParameters/ECSDataAdapters.h"
#include <TEveManager.h>
#include <TEveTrack.h>
#include <TEveTrackPropagator.h>
Expand Down Expand Up @@ -117,7 +118,7 @@ void EventManager::displayCurrentEvent()

if (this->mShowDate) {
multiView->getAnnotationTop()->SetText(
TString::Format("Run %d\n%s", dataSource->getRunNumber(), dataSource->getCollisionTime().c_str()));
TString::Format("Run %d %s\n%s", dataSource->getRunNumber(), std::string(parameters::GRPECS::RunTypeNames[dataSource->getRunType()]).c_str(), dataSource->getFileTime().c_str()));
} else {
multiView->getAnnotationTop()->SetText(TString::Format("Run %d", dataSource->getRunNumber()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class O2DPLDisplaySpec : public o2::framework::Task
bool eveHostNameMatch, int minITSTracks, int minTracks, bool filterITSROF, bool filterTime,
const EveWorkflowHelper::Bracket& timeBracket, bool removeTPCEta,
const EveWorkflowHelper::Bracket& etaBracket, bool trackSorting, int onlyNthEvent, bool primaryVertex, int maxPrimaryVertices, bool primaryVertexTriggers, float primaryVertexMinZ, float primaryVertexMaxZ, float primaryVertexMinX, float primaryVertexMaxX, float primaryVertexMinY, float primaryVertexMaxY)
: mDisableWrite(disableWrite), mUseMC(useMC), mTrkMask(trkMask), mClMask(clMask), mDataRequest(dataRequest), mGGCCDBRequest(gr), mJsonPath(jsonPath), mExt(ext), mTimeInterval(timeInterval), mNumberOfFiles(numberOfFiles), mNumberOfTracks(numberOfTracks), mEveHostNameMatch(eveHostNameMatch), mMinITSTracks(minITSTracks), mMinTracks(minTracks), mFilterITSROF(filterITSROF), mFilterTime(filterTime), mTimeBracket(timeBracket), mRemoveTPCEta(removeTPCEta), mEtaBracket(etaBracket), mTrackSorting(trackSorting), mOnlyNthEvent(onlyNthEvent), mPrimaryVertexMode(primaryVertex), mMaxPrimaryVertices(maxPrimaryVertices), mPrimaryVertexTriggers(primaryVertexTriggers), mPrimaryVertexMinZ(primaryVertexMinZ), mPrimaryVertexMaxZ(primaryVertexMaxZ), mPrimaryVertexMinX(primaryVertexMinX), mPrimaryVertexMaxX(primaryVertexMaxX), mPrimaryVertexMinY(primaryVertexMinY), mPrimaryVertexMaxY(primaryVertexMaxY)
: mDisableWrite(disableWrite), mUseMC(useMC), mTrkMask(trkMask), mClMask(clMask), mDataRequest(dataRequest), mGGCCDBRequest(gr), mJsonPath(jsonPath), mExt(ext), mTimeInterval(timeInterval), mNumberOfFiles(numberOfFiles), mNumberOfTracks(numberOfTracks), mEveHostNameMatch(eveHostNameMatch), mMinITSTracks(minITSTracks), mMinTracks(minTracks), mFilterITSROF(filterITSROF), mFilterTime(filterTime), mTimeBracket(timeBracket), mRemoveTPCEta(removeTPCEta), mEtaBracket(etaBracket), mTrackSorting(trackSorting), mOnlyNthEvent(onlyNthEvent), mPrimaryVertexMode(primaryVertex), mMaxPrimaryVertices(maxPrimaryVertices), mPrimaryVertexTriggers(primaryVertexTriggers), mPrimaryVertexMinZ(primaryVertexMinZ), mPrimaryVertexMaxZ(primaryVertexMaxZ), mPrimaryVertexMinX(primaryVertexMinX), mPrimaryVertexMaxX(primaryVertexMaxX), mPrimaryVertexMinY(primaryVertexMinY), mPrimaryVertexMaxY(primaryVertexMaxY), mRunType(o2::parameters::GRPECS::NONE)

{
this->mTimeStamp = std::chrono::high_resolution_clock::now() - timeInterval; // first run meets condition
Expand Down Expand Up @@ -105,6 +105,7 @@ class O2DPLDisplaySpec : public o2::framework::Task
o2::dataformats::GlobalTrackID::mask_t mTrkMask;
o2::dataformats::GlobalTrackID::mask_t mClMask;
DetectorData mData;
o2::parameters::GRPECS::RunType mRunType;
std::shared_ptr<o2::globaltracking::DataRequest> mDataRequest;
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
};
Expand Down
2 changes: 2 additions & 0 deletions EventVisualisation/Workflow/src/O2DPLDisplay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void O2DPLDisplaySpec::run(ProcessingContext& pc)
helper.mEvent.setRunNumber(tinfo.runNumber);
helper.mEvent.setTfCounter(tinfo.tfCounter);
helper.mEvent.setFirstTForbit(tinfo.firstTForbit);
helper.mEvent.setRunType(this->mRunType);
helper.mEvent.setPrimaryVertex(pv);
helper.save(this->mJsonPath, this->mExt, this->mNumberOfFiles, this->mTrkMask, this->mClMask, tinfo.runNumber, tinfo.creation);
filesSaved++;
Expand Down Expand Up @@ -233,6 +234,7 @@ void O2DPLDisplaySpec::updateTimeDependentParams(ProcessingContext& pc)
if (!initOnceDone) { // this params need to be queried only once
initOnceDone = true;
auto grpECS = o2::base::GRPGeomHelper::instance().getGRPECS(); // RS
mRunType = grpECS->getRunType();
mData.init();
}
// pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldictITS"); // called by the RecoContainer
Expand Down

0 comments on commit 24437b2

Please sign in to comment.