38std::vector<int> generateIntegers(
size_t size,
int min,
int max)
40 std::uniform_int_distribution<int> distribution(
min,
max);
41 std::mt19937 generator(std::random_device{}());
42 std::vector<int>
data;
44 data.emplace_back(distribution(generator));
50 for (
auto i = 0;
i <
data.size(); ++
i) {
63std::vector<o2::dcs::DataPointCompositeObject>
generate(
const std::vector<o2::dcs::test::HintType> hints,
67 std::vector<o2::dcs::DataPointCompositeObject> dataPoints;
70 auto dsec = d.Convert();
74 std::string refDate = d.AsSQLString();
76 auto GenerateVisitor = [refDate](
const auto& t) {
80 for (
const auto& hint : hints) {
81 auto dpcoms = std::visit(GenerateVisitor, hint);
82 for (
auto dp : dpcoms) {
83 dataPoints.push_back(dp);
87 auto indices = generateIntegers(fraction * dataPoints.size(), 0, dataPoints.size() - 1);
88 std::vector<o2::dcs::DataPointCompositeObject> tmp;
92 dataPoints.push_back(tmp[
i]);
117 uint64_t mMaxCyclesNoFullMap;
118 float mDeltaFraction;
119 std::vector<o2::dcs::test::HintType> mDataPointHints;
123DCSRandomDataGenerator::DCSRandomDataGenerator(std::vector<o2::dcs::test::HintType> hints,
125 mDataDescription(description) {}
129 mMaxTF = ic.
options().
get<int64_t>(
"max-timeframes");
130 mDeltaFraction = ic.
options().
get<
float>(
"delta-fraction");
131 mMaxCyclesNoFullMap = ic.
options().
get<int64_t>(
"max-cycles-no-full-map");
137 uint64_t tfid = o2::header::get<o2::framework::DataProcessingHeader*>((*input).header)->startTime;
138 if (tfid >= mMaxTF) {
139 LOG(info) <<
"Data generator reached TF " << tfid <<
", stopping";
144 bool generateFBI = (mTFs % mMaxCyclesNoFullMap == 0);
146 float fraction = (generateFBI ? 1.0 : mDeltaFraction);
149 auto dpcoms =
generate(mDataPointHints, fraction, tfid);
151 LOG(info) <<
"***************** TF " << tfid <<
" has generated " << dpcoms.size() <<
" DPs";
153 auto timeNow = std::chrono::system_clock::now();
154 timingInfo.creation = std::chrono::duration_cast<std::chrono::milliseconds>(timeNow.time_since_epoch()).count();
166 std::string desc{detName};
167 desc +=
"DATAPOINTS";
174 "dcs-random-data-generator",
176 Outputs{{{
"outputDCS"},
"DCS", dd}},
177 AlgorithmSpec{adaptFromTask<DCSRandomDataGenerator>(hints, dd)},
179 {
"max-timeframes", VariantType::Int64, 99999999999ll, {
"max TimeFrames to generate"}},
180 {
"delta-fraction", VariantType::Float, 0.05f, {
"fraction of data points to put in the delta"}},
181 {
"max-cycles-no-full-map", VariantType::Int64, 6000ll, {
"max num of cycles between the sending of 2 full maps"}}}};
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
virtual void init(InitContext &context)
virtual void run(ProcessingContext &context)=0
GLsizei GLenum const void * indices
o2::framework::DataProcessorSpec getDCSRandomDataGeneratorSpec(std::vector< HintType > hints={}, const char *detName="TOF")
std::vector< DataPointCompositeObject > generateRandomDataPoints(const std::vector< std::string > &aliases, T min, T max, std::string refDate="")
Defining PrimaryVertex explicitly as messageable.
@ Me
Only quit this data processor.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
Enum< T >::Iterator begin(Enum< T >)
TLorentzVector generate(Vec3D &vtx, std::vector< o2::track::TrackParCov > &vctr, float bz, TGenPhaseSpace &genPHS, double parMass, const std::vector< double > &dtMass, std::vector< int > forceQ)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"