Skip to content

Commit e9d2649

Browse files
committed
ensure proper creation time in TOF test data generator
1 parent f5c6ca4 commit e9d2649

4 files changed

Lines changed: 50 additions & 3 deletions

File tree

Detectors/TOF/calibration/testWorkflow/DataGeneratorSpec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TFDispatcher : public o2::framework::Task
4242
void init(o2::framework::InitContext& ic) final
4343
{
4444
mMaxTF = ic.options().get<int64_t>("max-timeframes");
45-
mMinSize = ic.options().get<int64_t>("min-number-of-info");
45+
mMinSize = ic.options().get<int>("min-number-of-info");
4646
}
4747

4848
void run(o2::framework::ProcessingContext& pc) final
@@ -221,7 +221,7 @@ DataProcessorSpec getTFDispatcherSpec(int slot, int ngen, int nlanes, int latenc
221221
Outputs{{{"output"}, "TOF", "DATASIZE"}},
222222
AlgorithmSpec{adaptFromTask<o2::calibration::TFDispatcher>(slot, ngen, nlanes, latency)},
223223
Options{{"max-timeframes", VariantType::Int64, 99999999999ll, {"max TimeFrames to generate"}},
224-
{"min-number-of-info", VariantType::Int64, 99999999999ll, {"min number of Info (CalibTOFInfo, or Diagnostic) to generate"}}}};
224+
{"min-number-of-info", VariantType::Int, 9999, {"min number of Info (CalibTOFInfo, or Diagnostic) to generate"}}}};
225225
}
226226

227227
DataProcessorSpec getTFProcessorCalibInfoTOFSpec(int latency, int latencyRMS)

Detectors/TOF/calibration/testWorkflow/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ o2-calibration-ccdb-populator-workflow --ccdb-path localhost:8080
5555

5656
## TOF channel calibration:
5757

58-
To obtain the TOF channel offsets (at end of processing). Input from simulation, but is should work if attached to reco+calib flow
58+
To obtain the TOF channel offsets (at end of processing). Input from simulation, but it should work if attached to reco+calib flow
5959

6060
* simulating reading from ccdb, and using it, with "-b", in "test" mode --> to use this, we need an appropriate CCDB object in the CCDB
6161

@@ -109,6 +109,9 @@ o2-calibration-data-generator-workflow --lanes 8 --max-timeframes 5000 --gen-nor
109109
o2-calibration-data-generator-workflow --lanes 8 --max-timeframes 5000 --gen-norm 3 --gen-slot 2
110110
```
111111

112+
Note that the `o2-calibration-data-generator-workflow` parses the string passed via `--configKeyValues` option and the DataHeaders to generate can be steered using HBFUtils class,
113+
e.g. the "run start" time as HBFUtils.startTime (if 0, `now()` will be used), starting orbit via HBFUtils.orbitFirstSampled etc.
114+
112115
* To run the calibration with cosmics:
113116

114117
```shell

Detectors/TOF/calibration/testWorkflow/data-generator-diagnostic-workflow.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "Framework/DataProcessorSpec.h"
13+
#include "Framework/CallbacksPolicy.h"
1314
#include "DataGeneratorSpec.h"
1415

1516
using namespace o2::framework;
1617

18+
void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
19+
{
20+
policies.push_back(o2::framework::CallbacksPolicy{
21+
[](o2::framework::DeviceSpec const& spec, o2::framework::ConfigContext const& context) -> bool {
22+
return spec.name == "calib-tf-dispatcher"; // apply policy only to the upstream device
23+
},
24+
[](o2::framework::CallbackService& service, o2::framework::InitContext& context) {
25+
const auto& hbfu = o2::raw::HBFUtils::Instance();
26+
long startTime = hbfu.startTime > 0 ? hbfu.startTime : std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
27+
service.set(o2::framework::CallbackService::Id::NewTimeslice,
28+
[startTime](o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph) {
29+
const auto& hbfu = o2::raw::HBFUtils::Instance();
30+
dh.firstTForbit = hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit + int64_t(hbfu.nHBFPerTF) * dh.tfCounter;
31+
dh.runNumber = hbfu.runNumber;
32+
dph.creation = startTime + (dh.firstTForbit - hbfu.orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3;
33+
});
34+
}});
35+
}
36+
1737
// we need to add workflow options before including Framework/runDataProcessing
1838
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
1939
{
@@ -24,6 +44,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
2444
workflowOptions.push_back(ConfigParamSpec{"pressure", o2::framework::VariantType::Float, 1.f, {"generation / processing rate factor"}});
2545
workflowOptions.push_back(ConfigParamSpec{"mean-latency", o2::framework::VariantType::Int, 1000, {"mean latency of the processor in microseconds"}});
2646
workflowOptions.push_back(ConfigParamSpec{"latency-spread", o2::framework::VariantType::Int, 100, {"latency gaussian RMS of the processor in microseconds"}});
47+
workflowOptions.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}});
2748
}
2849

2950
// ------------------------------------------------------------------
@@ -33,6 +54,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
3354
WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
3455
{
3556
WorkflowSpec specs;
57+
o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
3658
auto nlanes = std::max(1, configcontext.options().get<int>("lanes"));
3759
auto ngen = std::max(1, configcontext.options().get<int>("gen-norm"));
3860
auto slot = std::max(0, configcontext.options().get<int>("gen-slot"));

Detectors/TOF/calibration/testWorkflow/data-generator-workflow.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "Framework/DataProcessorSpec.h"
13+
#include "Framework/CallbacksPolicy.h"
1314
#include "DataGeneratorSpec.h"
1415

1516
using namespace o2::framework;
1617

18+
void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
19+
{
20+
policies.push_back(o2::framework::CallbacksPolicy{
21+
[](o2::framework::DeviceSpec const& spec, o2::framework::ConfigContext const& context) -> bool {
22+
return spec.name == "calib-tf-dispatcher"; // apply policy only to the upstream device
23+
},
24+
[](o2::framework::CallbackService& service, o2::framework::InitContext& context) {
25+
const auto& hbfu = o2::raw::HBFUtils::Instance();
26+
long startTime = hbfu.startTime > 0 ? hbfu.startTime : std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
27+
service.set(o2::framework::CallbackService::Id::NewTimeslice,
28+
[startTime](o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph) {
29+
const auto& hbfu = o2::raw::HBFUtils::Instance();
30+
dh.firstTForbit = hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit + int64_t(hbfu.nHBFPerTF) * dh.tfCounter;
31+
dh.runNumber = hbfu.runNumber;
32+
dph.creation = startTime + (dh.firstTForbit - hbfu.orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3;
33+
});
34+
}});
35+
}
36+
1737
// we need to add workflow options before including Framework/runDataProcessing
1838
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
1939
{
@@ -24,6 +44,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
2444
workflowOptions.push_back(ConfigParamSpec{"pressure", o2::framework::VariantType::Float, 1.f, {"generation / processing rate factor"}});
2545
workflowOptions.push_back(ConfigParamSpec{"mean-latency", o2::framework::VariantType::Int, 1000, {"mean latency of the processor in microseconds"}});
2646
workflowOptions.push_back(ConfigParamSpec{"latency-spread", o2::framework::VariantType::Int, 100, {"latency gaussian RMS of the processor in microseconds"}});
47+
workflowOptions.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}});
2748
}
2849

2950
// ------------------------------------------------------------------
@@ -33,6 +54,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
3354
WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
3455
{
3556
WorkflowSpec specs;
57+
o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
3658
auto nlanes = std::max(1, configcontext.options().get<int>("lanes"));
3759
auto ngen = std::max(1, configcontext.options().get<int>("gen-norm"));
3860
auto slot = std::max(0, configcontext.options().get<int>("gen-slot"));

0 commit comments

Comments
 (0)