Skip to content

Commit 5bb3d25

Browse files
pnwkwdavidrohr
authored andcommitted
Replace empty output filter with filter on minimum amount of tracks
1 parent 556c337 commit 5bb3d25

File tree

5 files changed

+53
-25
lines changed

5 files changed

+53
-25
lines changed

EventVisualisation/DataConverter/include/EventVisualisationDataConverter/VisualisationEvent.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ class VisualisationEvent
105105
return mTracks.size();
106106
}
107107

108+
// Returns number of tracks with ITS contribution (including standalone)
109+
size_t getITSTrackCount() const
110+
{
111+
return std::count_if(mTracks.begin(), mTracks.end(), [](const auto& t) {
112+
return o2::dataformats::GlobalTrackID{0, t.getSource()}.includesDet(o2::detectors::DetID::ITS);
113+
});
114+
}
115+
108116
// Clears event from stored data (tracks, collisions)
109117
void clear()
110118
{
@@ -126,8 +134,6 @@ class VisualisationEvent
126134
float getMinTimeOfTracks() const { return this->mMinTimeOfTracks; }
127135
float getMaxTimeOfTracks() const { return this->mMaxTimeOfTracks; } /// maximum time of tracks in the event
128136

129-
bool isEmpty() const { return getTrackCount() == 0 && getClusterCount() == 0; }
130-
131137
private:
132138
float mMinTimeOfTracks; /// minimum time of tracks in the event
133139
float mMaxTimeOfTracks; /// maximum time of tracks in the event

EventVisualisation/Workflow/README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,25 @@ o2-eve -j -d /home/ed/jsons -o
4444

4545
## o2-eve-display command line parameters:
4646

47-
| *parameter*| *default value* | *description* |
48-
|-----|---|---|
49-
|jsons-folder | jsons |name of the host allowed to produce files |
50-
|eve-hostname | |name of the host allowed to produce files (empty means no limit) |
51-
|eve-dds-collection-index |-1 |number of dpl collection allowed to produce files (-1 means no limit) |
52-
|number-of_files |300 |maximum number of json files in folder (newer one will replace oldest) |
53-
|number-of_tracks |-1 |maximum number of track stored in json file (-1 means no limit) |
54-
|disable-mc |false |disable visualization of MC data |
55-
|display-clusters |ITS,TPC,TRD,TOF |comma-separated list of clusters to display |
56-
|display-tracks |TPC,ITS,ITS-TPC,TPC-TRD,ITS-TPC-TRD,TPC-TOF,ITS-TPC-TOF |comma-separated list of tracks to display |
57-
|disable-root-input |false | disable root-files input reader |
58-
|configKeyValues | |Semicolon separated key=value strings ..." |
47+
| *parameter* | *default value* | *description* |
48+
|--------------------------|---------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
49+
| jsons-folder | jsons | name of the host allowed to produce files |
50+
| eve-hostname | | name of the host allowed to produce files (empty means no limit) |
51+
| eve-dds-collection-index | -1 | number of dpl collection allowed to produce files (-1 means no limit) |
52+
| number-of_files | 300 | maximum number of json files in folder (newer one will replace oldest) |
53+
| number-of_tracks | -1 | maximum number of track stored in json file (-1 means no limit) |
54+
| time-interval | 5000 | time interval in milliseconds between stored files |
55+
| disable-mc | false | disable visualization of MC data |
56+
| display-clusters | ITS,TPC,TRD,TOF | comma-separated list of clusters to display |
57+
| display-tracks | TPC,ITS,ITS-TPC,TPC-TRD,ITS-TPC-TRD,TPC-TOF,ITS-TPC-TOF | comma-separated list of tracks to display |
58+
| disable-root-input | false | disable root-files input reader |
59+
| configKeyValues | | semicolon separated key=value strings ... |
60+
| skipOnEmptyInput | false | don't run the ED when no input is provided |
61+
| min-its-tracks | -1 | don't create file if less than the specified number of ITS tracks is present |
62+
| min-tracks | -1 | don't create file if less than the specified number of all tracks is present |
63+
| filter-its-rof | false | don't display tracks outside ITS readout frame |
64+
| filter-time-min | -1 | display tracks only in `[min, max]` microseconds time range in each time frame, requires `--filter-time-max` to be specified as well |
65+
| filter-time-max | -1 | display tracks only in `[min, max]` microseconds time range in each time frame, requires `--filter-time-min` to be specified as well |
5966

6067

6168

EventVisualisation/Workflow/include/EveWorkflow/EveWorkflowHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ class EveWorkflowHelper
150150
void prepareITSClusters(const o2::itsmft::TopologyDictionary* dict); // fills mITSClustersArray
151151
void prepareMFTClusters(const o2::itsmft::TopologyDictionary* dict); // fills mMFTClustersArray
152152
void clear() { mEvent.clear(); }
153-
bool isEmpty() { return mEvent.isEmpty(); }
153+
int getTrackCount() { return mEvent.getTrackCount(); }
154+
int getITSTrackCount() { return mEvent.getITSTrackCount(); }
154155

155156
GID::Source detectorMapToGIDSource(uint8_t dm);
156157

EventVisualisation/Workflow/include/EveWorkflow/O2DPLDisplay.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class O2DPLDisplaySpec : public o2::framework::Task
5050
O2DPLDisplaySpec(bool useMC, o2::dataformats::GlobalTrackID::mask_t trkMask,
5151
o2::dataformats::GlobalTrackID::mask_t clMask,
5252
std::shared_ptr<o2::globaltracking::DataRequest> dataRequest, const std::string& jsonPath,
53-
std::chrono::milliseconds timeInterval, int numberOfFiles, int numberOfTracks, bool eveHostNameMatch, bool noEmptyOutput, bool filterITSROF, bool filterTime, const EveWorkflowHelper::TBracket& timeBracket)
54-
: mUseMC(useMC), mTrkMask(trkMask), mClMask(clMask), mDataRequest(dataRequest), mJsonPath(jsonPath), mTimeInteval(timeInterval), mNumberOfFiles(numberOfFiles), mNumberOfTracks(numberOfTracks), mEveHostNameMatch(eveHostNameMatch), mNoEmptyOutput(noEmptyOutput), mFilterITSROF(filterITSROF), mFilterTime(filterTime), mTimeBracket(timeBracket)
53+
std::chrono::milliseconds timeInterval, int numberOfFiles, int numberOfTracks, bool eveHostNameMatch, int minITSTracks, int minTracks, bool filterITSROF, bool filterTime, const EveWorkflowHelper::TBracket& timeBracket)
54+
: mUseMC(useMC), mTrkMask(trkMask), mClMask(clMask), mDataRequest(dataRequest), mJsonPath(jsonPath), mTimeInterval(timeInterval), mNumberOfFiles(numberOfFiles), mNumberOfTracks(numberOfTracks), mEveHostNameMatch(eveHostNameMatch), mMinITSTracks(minITSTracks), mMinTracks(minTracks), mFilterITSROF(filterITSROF), mFilterTime(filterTime), mTimeBracket(timeBracket)
5555
{
5656
this->mTimeStamp = std::chrono::high_resolution_clock::now() - timeInterval; // first run meets condition
5757
}
@@ -66,12 +66,14 @@ class O2DPLDisplaySpec : public o2::framework::Task
6666

6767
bool mUseMC = false;
6868
bool mEveHostNameMatch; // empty or correct hostname
69+
int mMinITSTracks; // minimum number of ITS tracks to produce a file
70+
int mMinTracks; // minimum number of all tracks to produce a file
6971
bool mNoEmptyOutput; // don't create files with no tracks/clusters
7072
bool mFilterITSROF; // don't display tracks outside ITS readout frame
7173
bool mFilterTime; // don't display tracks outside [min, max] range in TF time
7274
EveWorkflowHelper::TBracket mTimeBracket; // [min, max] range in TF time for the filter
7375
std::string mJsonPath; // folder where files are stored
74-
std::chrono::milliseconds mTimeInteval; // minimal interval between files in milliseconds
76+
std::chrono::milliseconds mTimeInterval; // minimal interval between files in milliseconds
7577
int mNumberOfFiles; // maximum number of files in folder - newer replaces older
7678
int mNumberOfTracks; // maximum number of track in single file (0 means no limit)
7779
std::chrono::time_point<std::chrono::high_resolution_clock> mTimeStamp;

EventVisualisation/Workflow/src/O2DPLDisplay.cxx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
5151
{"display-clusters", VariantType::String, "ITS,TPC,TRD,TOF", {"comma-separated list of clusters to display"}},
5252
{"display-tracks", VariantType::String, "TPC,ITS,ITS-TPC,TPC-TRD,ITS-TPC-TRD,TPC-TOF,ITS-TPC-TOF", {"comma-separated list of tracks to display"}},
5353
{"disable-root-input", VariantType::Bool, false, {"disable root-files input reader"}},
54-
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}},
55-
{"skipOnEmptyInput", VariantType::Bool, false, {"Just don't run the ED when no input is provided"}},
54+
{"configKeyValues", VariantType::String, "", {"semicolon separated key=value strings ..."}},
55+
{"skipOnEmptyInput", VariantType::Bool, false, {"don't run the ED when no input is provided"}},
56+
{"min-its-tracks", VariantType::Int, -1, {"don't create file if less than the specified number of ITS tracks is present"}},
57+
{"min-tracks", VariantType::Int, -1, {"don't create file if less than the specified number of all tracks is present"}},
5658
{"filter-its-rof", VariantType::Bool, false, {"don't display tracks outside ITS readout frame"}},
57-
{"no-empty-output", VariantType::Bool, false, {"don't create files with no tracks/clusters"}},
5859
{"filter-time-min", VariantType::Float, -1.f, {"display tracks only in [min, max] microseconds time range in each time frame, requires --filter-time-max to be specified as well"}},
5960
{"filter-time-max", VariantType::Float, -1.f, {"display tracks only in [min, max] microseconds time range in each time frame, requires --filter-time-min to be specified as well"}},
6061
};
@@ -80,7 +81,7 @@ void O2DPLDisplaySpec::run(ProcessingContext& pc)
8081
// filtering out any run which occur before reaching next time interval
8182
auto currentTime = std::chrono::high_resolution_clock::now();
8283
std::chrono::duration<double> elapsed = currentTime - this->mTimeStamp;
83-
if (elapsed < this->mTimeInteval) {
84+
if (elapsed < this->mTimeInterval) {
8485
return; // skip this run - it is too often
8586
}
8687
this->mTimeStamp = currentTime;
@@ -114,7 +115,17 @@ void O2DPLDisplaySpec::run(ProcessingContext& pc)
114115

115116
helper.draw();
116117

117-
if (!(this->mNoEmptyOutput && helper.isEmpty())) {
118+
bool save = true;
119+
120+
if (this->mMinITSTracks != -1 && helper.getITSTrackCount() < this->mMinITSTracks) {
121+
save = false;
122+
}
123+
124+
if (this->mMinTracks != -1 && helper.getTrackCount() < this->mMinTracks) {
125+
save = false;
126+
}
127+
128+
if (save) {
118129
helper.save(this->mJsonPath, this->mNumberOfFiles, this->mTrkMask, this->mClMask, this->mWorkflowVersion, dh->runNumber, dph->creation);
119130
}
120131

@@ -220,13 +231,14 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
220231

221232
InputHelper::addInputSpecs(cfgc, specs, srcCl, srcTrk, srcTrk, useMC);
222233

223-
auto noEmptyFiles = cfgc.options().get<bool>("no-empty-output");
234+
auto minITSTracks = cfgc.options().get<int>("min-its-tracks");
235+
auto minTracks = cfgc.options().get<int>("min-tracks");
224236

225237
specs.emplace_back(DataProcessorSpec{
226238
"o2-eve-display",
227239
dataRequest->inputs,
228240
{},
229-
AlgorithmSpec{adaptFromTask<O2DPLDisplaySpec>(useMC, srcTrk, srcCl, dataRequest, jsonFolder, timeInterval, numberOfFiles, numberOfTracks, eveHostNameMatch, noEmptyFiles, filterITSROF, filterTime, timeBracket)}});
241+
AlgorithmSpec{adaptFromTask<O2DPLDisplaySpec>(useMC, srcTrk, srcCl, dataRequest, jsonFolder, timeInterval, numberOfFiles, numberOfTracks, eveHostNameMatch, minITSTracks, minTracks, filterITSROF, filterTime, timeBracket)}});
230242

231243
return std::move(specs);
232244
}

0 commit comments

Comments
 (0)