Project
Loading...
Searching...
No Matches
tpc-factorize-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>
22
23using namespace o2::framework;
24
25// customize the completion policy
26void customize(std::vector<o2::framework::CompletionPolicy>& policies)
27{
29 policies.push_back(CompletionPolicyHelpers::defineByName("tpc-factorize-*.*", CompletionPolicy::CompletionOp::Consume));
30}
31
32// we need to add workflow options before including Framework/runDataProcessing
33void customize(std::vector<ConfigParamSpec>& workflowOptions)
34{
35 const std::string cruDefault = "0-" + std::to_string(o2::tpc::CRU::MaxCRU - 1);
36
37 std::vector<ConfigParamSpec> options{
38 {"configFile", VariantType::String, "", {"configuration file for configurable parameters"}},
39 {"timeframes", VariantType::Int, 2000, {"Number of TFs which will be aggregated per aggregation interval."}},
40 {"timeframesDeltaIDC", VariantType::Int, 100, {"Number of TFs used for storing the IDCDelta struct in the CCDB."}},
41 {"nthreads-IDC-factorization", VariantType::Int, 1, {"Number of threads which will be used during the factorization of the IDCs."}},
42 {"nthreads-grouping", VariantType::Int, 1, {"Number of threads which will be used during the grouping of IDCDelta."}},
43 {"sendOutputFFT", VariantType::Bool, false, {"sending the output for fourier transform device"}},
44 {"crus", VariantType::String, cruDefault.c_str(), {"List of CRUs, comma separated ranges, e.g. 0-3,7,9-15"}},
45 {"compression", VariantType::Int, 2, {"compression of DeltaIDC: 0 -> No, 1 -> Medium (data compression ratio 2), 2 -> High (data compression ratio ~6)"}},
46 {"input-lanes", VariantType::Int, 2, {"Number of parallel pipelines which were set in the TPCDistributeIDCSpec device."}},
47 {"groupPads", VariantType::String, "5,6,7,8,4,5,6,8,10,13", {"number of pads in a row which will be grouped per region"}},
48 {"groupRows", VariantType::String, "2,2,2,3,3,3,2,2,2,2", {"number of pads in row direction which will be grouped per region"}},
49 {"groupLastRowsThreshold", VariantType::String, "1", {"set threshold in row direction for merging the last group to the previous group per region"}},
50 {"groupLastPadsThreshold", VariantType::String, "1", {"set threshold in pad direction for merging the last group to the previous group per region"}},
51 {"use-precise-timestamp", VariantType::Bool, false, {"Use precise timestamp from distribute when writing to CCDB"}},
52 {"enable-CCDB-output", VariantType::Bool, false, {"send output for ccdb populator"}},
53 {"n-TFs-buffer", VariantType::Int, 1, {"Buffer which was defined in the TPCFLPIDCSpec."}},
54 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings (e.g. for pp 50kHz: 'TPCIDCCompressionParam.maxIDCDeltaValue=15;')"}}};
55
56 std::swap(workflowOptions, options);
57}
58
60
62{
63 using namespace o2::tpc;
64
65 const std::string sgroupPads = config.options().get<std::string>("groupPads");
66 const std::string sgroupRows = config.options().get<std::string>("groupRows");
67 const std::string sgroupLastRowsThreshold = config.options().get<std::string>("groupLastRowsThreshold");
68 const std::string sgroupLastPadsThreshold = config.options().get<std::string>("groupLastPadsThreshold");
69 ParameterIDCGroup::setGroupingParameterFromString(sgroupPads, sgroupRows, sgroupLastRowsThreshold, sgroupLastPadsThreshold);
70
71 // set up configuration
72 o2::conf::ConfigurableParam::updateFromFile(config.options().get<std::string>("configFile"));
73 o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
74 o2::conf::ConfigurableParam::writeINI("o2tpcfactorizeidc_configuration.ini");
75
76 const auto tpcCRUs = o2::RangeTokenizer::tokenize<int>(config.options().get<std::string>("crus"));
77 const auto nCRUs = tpcCRUs.size();
78 auto timeframes = static_cast<unsigned int>(config.options().get<int>("timeframes"));
79 auto timeframesDeltaIDC = static_cast<unsigned int>(config.options().get<int>("timeframesDeltaIDC"));
80 const auto sendOutputFFT = config.options().get<bool>("sendOutputFFT");
81 const auto nthreadsFactorization = static_cast<unsigned long>(config.options().get<int>("nthreads-IDC-factorization"));
82 IDCFactorization::setNThreads(nthreadsFactorization);
83 const auto nthreadsGrouping = static_cast<unsigned long>(config.options().get<int>("nthreads-grouping"));
85 const auto nLanes = static_cast<unsigned int>(config.options().get<int>("input-lanes"));
86 const bool usePrecisetimeStamp = config.options().get<bool>("use-precise-timestamp");
87 const bool sendCCDB = config.options().get<bool>("enable-CCDB-output");
88 int nTFsBuffer = config.options().get<int>("n-TFs-buffer");
89 if (nTFsBuffer <= 0) {
90 nTFsBuffer = 1;
91 }
92 assert(timeframes >= nTFsBuffer);
93 timeframes /= nTFsBuffer;
94 timeframesDeltaIDC = std::clamp(timeframesDeltaIDC / nTFsBuffer, static_cast<unsigned int>(1), timeframesDeltaIDC);
95
96 const int compressionTmp = config.options().get<int>("compression");
97 IDCDeltaCompression compression;
98 switch (compressionTmp) {
99 case static_cast<int>(IDCDeltaCompression::NO):
100 case static_cast<int>(IDCDeltaCompression::MEDIUM):
101 case static_cast<int>(IDCDeltaCompression::HIGH):
102 compression = static_cast<IDCDeltaCompression>(compressionTmp);
103 break;
104 default:
105 LOGP(error, "wrong compression type set. Setting compression to medium compression");
106 compression = static_cast<IDCDeltaCompression>(IDCDeltaCompression::MEDIUM);
107 break;
108 }
109
110 const auto first = tpcCRUs.begin();
111 const auto last = std::min(tpcCRUs.end(), first + nCRUs);
112 const std::vector<uint32_t> rangeCRUs(first, last);
113
114 WorkflowSpec workflow;
115 workflow.reserve(nLanes);
116 for (int ilane = 0; ilane < nLanes; ++ilane) {
117 workflow.emplace_back(getTPCFactorizeIDCSpec(ilane, rangeCRUs, timeframes, timeframesDeltaIDC, compression, usePrecisetimeStamp, sendOutputFFT, sendCCDB, nTFsBuffer));
118 }
119 return workflow;
120}
class for averaging and grouping of IDCs
class for aggregating IDCs for the full TPC (all sectors) and factorization of aggregated IDCs
Helper function to tokenize sequences and ranges of integral numbers.
static void writeINI(std::string const &filename, std::string const &keyOnly="")
static void updateFromFile(std::string const &, std::string const &paramsList="", bool unchangedOnly=false)
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
@ MaxCRU
Definition CRU.h:31
static void setNThreads(const int nThreads)
set the number of threads used for some of the calculations
static void setNThreads(const int nThreads)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
Global TPC definitions and constants.
Definition SimTraits.h:167
IDCDeltaCompression
IDC Delta IDC Compression types.
DataProcessorSpec getTPCFactorizeIDCSpec(const int lane, const std::vector< uint32_t > &crus, const unsigned int timeframes, const unsigned int timeframesDeltaIDC, const IDCDeltaCompression compression, const bool usePrecisetimeStamp, const bool sendOutputFFT, const bool sendCCDB, 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)
static void setGroupingParameterFromString(const std::string sgroupPads, const std::string sgroupRows, const std::string sgroupLastRowsThreshold, const std::string sgroupLastPadsThreshold)
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)