Project
Loading...
Searching...
No Matches
tpc-distribute-idc.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include <vector>
13#include <string>
20
21using namespace o2::framework;
22
23// customize the completion policy
24void customize(std::vector<o2::framework::CompletionPolicy>& policies)
25{
27 policies.push_back(CompletionPolicyHelpers::defineByName("tpc-distribute-*.*", CompletionPolicy::CompletionOp::Consume));
28}
29
30// we need to add workflow options before including Framework/runDataProcessing
31void customize(std::vector<ConfigParamSpec>& workflowOptions)
32{
33 const std::string cruDefault = "0-" + std::to_string(o2::tpc::CRU::MaxCRU - 1);
34
35 std::vector<ConfigParamSpec> options{
36 {"crus", VariantType::String, cruDefault.c_str(), {"List of CRUs, comma separated ranges, e.g. 0-3,7,9-15"}},
37 {"timeframes", VariantType::Int, 2000, {"Number of TFs which will be aggregated per aggregation interval."}},
38 {"firstTF", VariantType::Int, -1, {"First time frame index. (if set to -1 the first TF will be automatically detected. Values < -1 are setting an offset for skipping the first TFs)"}},
39 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
40 {"lanes", VariantType::Int, 1, {"Number of lanes of this device (CRUs are split per lane)"}},
41 {"send-precise-timestamp", VariantType::Bool, false, {"Send precise timestamp which can be used for writing to CCDB"}},
42 {"n-TFs-buffer", VariantType::Int, 1, {"Buffer which was defined in the TPCFLPIDCSpec."}},
43 {"output-lanes", VariantType::Int, 2, {"Number of parallel pipelines which will be used in the factorization device."}}};
44 std::swap(workflowOptions, options);
45}
46
48
50{
51 using namespace o2::tpc;
52
53 // set up configuration
54 o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
55 o2::conf::ConfigurableParam::writeINI("o2tpcdistributeidc_configuration.ini");
56
57 const auto tpcCRUs = o2::RangeTokenizer::tokenize<int>(config.options().get<std::string>("crus"));
58 const auto nCRUs = tpcCRUs.size();
59 auto timeframes = static_cast<unsigned int>(config.options().get<int>("timeframes"));
60 const auto outlanes = static_cast<unsigned int>(config.options().get<int>("output-lanes"));
61 const auto nLanes = static_cast<unsigned int>(config.options().get<int>("lanes"));
62 const auto firstTF = static_cast<unsigned int>(config.options().get<int>("firstTF"));
63 const bool sendPrecisetimeStamp = config.options().get<bool>("send-precise-timestamp");
64 int nTFsBuffer = config.options().get<int>("n-TFs-buffer");
65 if (nTFsBuffer <= 0) {
66 nTFsBuffer = 1;
67 }
68 assert(timeframes >= nTFsBuffer);
69 timeframes /= nTFsBuffer;
70 LOGP(info, "using {} timeframes as each TF contains {} IDCs", timeframes, nTFsBuffer);
71 const auto crusPerLane = nCRUs / nLanes + ((nCRUs % nLanes) != 0);
72 WorkflowSpec workflow;
73 for (int ilane = 0; ilane < nLanes; ++ilane) {
74 const auto first = tpcCRUs.begin() + ilane * crusPerLane;
75 if (first >= tpcCRUs.end()) {
76 break;
77 }
78 const auto last = std::min(tpcCRUs.end(), first + crusPerLane);
79 const std::vector<uint32_t> rangeCRUs(first, last);
80 workflow.emplace_back(getTPCDistributeIDCSpec(ilane, rangeCRUs, timeframes, outlanes, firstTF, sendPrecisetimeStamp, nTFsBuffer));
81 }
82
83 return workflow;
84}
Helper function to tokenize sequences and ranges of integral numbers.
TPC aggregation of grouped IDCs and factorization.
static void writeINI(std::string const &filename, std::string const &keyOnly="")
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
@ MaxCRU
Definition CRU.h:31
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
Global TPC definitions and constants.
Definition SimTraits.h:167
DataProcessorSpec getTPCDistributeIDCSpec(const int ilane, const std::vector< uint32_t > &crus, const unsigned int timeframes, const unsigned int outlanes, const int firstTF, const bool sendPrecisetimeStamp=false, const int nTFsBuffer=1)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static CompletionPolicy defineByName(std::string const &name, CompletionPolicy::CompletionOp op)
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< o2::framework::CompletionPolicy > &policies)